]> git.ipfire.org Git - thirdparty/mdadm.git/log
thirdparty/mdadm.git
12 years agoimsm: fix: correct printing value of blocks per migration unit
Lukasz Dorau [Fri, 18 Nov 2011 14:28:36 +0000 (15:28 +0100)] 
imsm: fix: correct printing value of blocks per migration unit

The value of blocks per migration unit is not printed correctly
when the metadata's content is examined using -E option on disks
without present migration record. (Migration record is present only
on 2 first disks in array due to IMSM compatibility restrictions.)

Printing the value of blocks per migration unit was corrected.
It is printed as N/A (Not Available) for disks
without the migration record.

Signed-off-by: Lukasz Dorau <lukasz.dorau@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
12 years agoimsm: platform capabilities are not validated during level migration
Labun, Marcin [Wed, 16 Nov 2011 04:24:10 +0000 (15:24 +1100)] 
imsm: platform capabilities are not validated during level migration

Migration from RAID0 to RAID5 should be blocked on the system without
support for RAID5. No platform validation was performed in RAID
level migrations: verification for all level migrations added.

Signed-off-by: Marcin Labun <marcin.labun@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
12 years agoimsm: fix: correct checking newly missing disks
Lukasz Dorau [Mon, 14 Nov 2011 14:52:52 +0000 (15:52 +0100)] 
imsm: fix: correct checking newly missing disks

The problem occurs when RAID10 array under rebuild
(after one disk fails) is assembled incrementally.
Mdadm tries to start array just after adding the third disk
and the volume is assembled incorrectly (in degraded state).

The cause is that container_enough depends on
newly missing disks which are checked incorrectly now.
They should be checked using always the first map.

Signed-off-by: Lukasz Dorau <lukasz.dorau@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
12 years agoimsm: fix: Allowed to create 2 volumes with total size less then maximum.
Lukasz Orlowski [Mon, 14 Nov 2011 05:41:03 +0000 (16:41 +1100)] 
imsm: fix: Allowed to create 2 volumes with total size less then maximum.

mdadm allows to create second volume on the same disk set, whose size is
less then the free space left in the container (with IMSM_NO_PLATFORM
undefined or set to 0). This is an OROM compatibility issue.
It is fixed by verifying whether IMSM_NO_PLATFORM is set and for
the second volume creation scenario, requested size is verified against
remaining available space.

Signed-off-by: Lukasz Orlowski <lukasz.orlowski@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
12 years agoimsm: fix: add support for OLCE and migration to imsm_count_failed
Lukasz Dorau [Mon, 7 Nov 2011 01:23:49 +0000 (12:23 +1100)] 
imsm: fix: add support for OLCE and migration to imsm_count_failed

The problem occurs when array under OLCE (from 3 to 6 disks)
is assembled incrementally. Mdadm tries to start array
just after adding the third disk (this is equal to the number of disks
before the start of reshape). It does not succeed,
the volume does not assembly correctly.

The function counting failed disks (imsm_count_failed())
was fixed for migration case. Now all disk members in both maps
are checked when failed disks are counted correctly.

Signed-off-by: Lukasz Dorau <lukasz.dorau@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
12 years agofix: Allowed to assemble 2 volumes with the same names from config file.
Lukasz Orlowski [Mon, 7 Nov 2011 01:20:34 +0000 (12:20 +1100)] 
fix: Allowed to assemble 2 volumes with the same names from config file.

mdadm allowes to assemble 2 volumes with the same names based on the
config file. The issue is fixed by iterating over the list of md device
identifiers and comparing the names of md devices against each other,
detecting identical names and blocking the assembly should the same names
be found.
Now having detected duplicate names, mdadm terminates without assembling
the container, displaying appropriate prompt.

Signed-off-by: Lukasz Orlowski <lukasz.orlowski@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
12 years agoFIX: Do not continue container reshape when mdmon is absent
Adam Kwolek [Mon, 7 Nov 2011 00:46:35 +0000 (11:46 +1100)] 
FIX: Do not continue container reshape when mdmon is absent

When mdmon is absent metadata is not updated, and container_reshape()
can fall in to endless loop. This can cause user data corruption.

In case when mdmon is absent do not continue container reshape process.

Signed-off-by: Adam Kwolek <adam.kwolek@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
12 years agomdmon: avoid using victim_sock when it is -1.
NeilBrown [Mon, 7 Nov 2011 00:44:21 +0000 (11:44 +1100)] 
mdmon: avoid using victim_sock when it is -1.

It possible that we try to use victim_sock even when we couldn't open
it.  This is never actually harmful but it looks wrong and it is best
to fix it.

Signed-off-by: NeilBrown <neilb@suse.de>
12 years agoRevert "mdmon(): Error out if failing to connect to victim monitor"
NeilBrown [Mon, 7 Nov 2011 00:37:12 +0000 (11:37 +1100)] 
Revert "mdmon(): Error out if failing to connect to victim monitor"

This reverts commit 819c158866f466075a1c719f0dc496deb2fb3814.

Adam Kwolek reports that with this patch, mdmon sometimes doesn't start:

    When array is not clean dismounted directory /dev/.mdadm is not cleaned up.
    On array re-assembly read pid is not valid and it is not possible
    to connect to monitor. This causes mdmon to exit and array remains
    not monitored.
    Problem is introduced by fix:
       mdmon(): Error out if failing to connect to victim monitor
       819c158866f466075a1c719f0dc496deb2fb3814

    This is critical for container reshape when mdmon is should finish reshape.
    when reshape is not finished, array is reshaped again by mdadm.

As victim_sock is subsequently tested, we don't really need to test-and-fail here.

Reported-by: Adam Kwolek <adam.kwolek@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
12 years agomatch_metadata_desc(): Fix memory leak
Jes Sorensen [Wed, 2 Nov 2011 21:10:08 +0000 (08:10 +1100)] 
match_metadata_desc(): Fix memory leak

Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
Signed-off-by: NeilBrown <neilb@suse.de>
12 years agofd2devname(): Don't dereference NULL pointer
Jes Sorensen [Wed, 2 Nov 2011 21:09:56 +0000 (08:09 +1100)] 
fd2devname(): Don't dereference NULL pointer

Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
Signed-off-by: NeilBrown <neilb@suse.de>
12 years agoManage_ro(): Check pointer rather than dereferencing it
Jes Sorensen [Wed, 2 Nov 2011 21:09:41 +0000 (08:09 +1100)] 
Manage_ro(): Check pointer rather than dereferencing it

Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
Signed-off-by: NeilBrown <neilb@suse.de>
12 years agounblock_monitor(): Check sra is valid before dereferencing
Jes Sorensen [Wed, 2 Nov 2011 21:09:19 +0000 (08:09 +1100)] 
unblock_monitor(): Check sra is valid before dereferencing

Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
Signed-off-by: NeilBrown <neilb@suse.de>
12 years agoahci_enumerate_ports(): Don't close fd that failed to open
Jes Sorensen [Wed, 2 Nov 2011 21:08:34 +0000 (08:08 +1100)] 
ahci_enumerate_ports(): Don't close fd that failed to open

Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
Signed-off-by: NeilBrown <neilb@suse.de>
12 years agoclose_aa(): Verify file descriptors are valid before trying to close them
Jes Sorensen [Wed, 2 Nov 2011 21:08:23 +0000 (08:08 +1100)] 
close_aa(): Verify file descriptors are valid before trying to close them

Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
Signed-off-by: NeilBrown <neilb@suse.de>
12 years agodisk_init_and_add(): Fail if opening sysfs file descriptors fail
Jes Sorensen [Wed, 2 Nov 2011 21:08:09 +0000 (08:08 +1100)] 
disk_init_and_add(): Fail if opening sysfs file descriptors fail

Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
Signed-off-by: NeilBrown <neilb@suse.de>
12 years agoarray_try_spare(): open_dev() returns -1 on error, not zero
Jes Sorensen [Wed, 2 Nov 2011 21:08:00 +0000 (08:08 +1100)] 
array_try_spare(): open_dev() returns -1 on error, not zero

Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
Signed-off-by: NeilBrown <neilb@suse.de>
12 years agoget_component_size(): Check read() return value for error before using it
Jes Sorensen [Wed, 2 Nov 2011 21:07:39 +0000 (08:07 +1100)] 
get_component_size(): Check read() return value for error before using it

Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
Signed-off-by: NeilBrown <neilb@suse.de>
12 years agomdstat_read(): Check return value of dup() before using file descriptor
Jes Sorensen [Wed, 2 Nov 2011 21:07:21 +0000 (08:07 +1100)] 
mdstat_read(): Check return value of dup() before using file descriptor

Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
Signed-off-by: NeilBrown <neilb@suse.de>
12 years agoping_monitor(): check file descriptor is valid before using and closing it
Jes Sorensen [Wed, 2 Nov 2011 21:07:02 +0000 (08:07 +1100)] 
ping_monitor(): check file descriptor is valid before using and closing it

Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
Signed-off-by: NeilBrown <neilb@suse.de>
12 years agomdadm: Rearrange option parsing for KillSubarray and UpdateSubarray
Jes Sorensen [Wed, 2 Nov 2011 21:06:47 +0000 (08:06 +1100)] 
mdadm: Rearrange option parsing for KillSubarray and UpdateSubarray

Extracting the 'subarray' arg for these options was being done at the
wrong place which lead to the code being a bit confusing and looking
wrong.

So reformat that code a bit better and move the extraction of
'subarray' down to the main parsing of these options rather than the
mode setting.

Signed-off-by: NeilBrown <neilb@suse.de>
12 years agomake_parts(): Fix case of comparing against uninitialized variables
Jes Sorensen [Tue, 1 Nov 2011 19:30:12 +0000 (20:30 +0100)] 
make_parts(): Fix case of comparing against uninitialized variables

Silencing gcc's warning of uninitialized variables was hiding a bug
where if we have /dev/md64 as a symlink, and /dev/md64p1 was a real
device node.

In this case major_num and minor_num would not get populated, but we
end up comparing against them because the stat for md64p1 succeeds.

Instead of using the int foo = foo trick, change the code to set
set the variables to invalid values so comparisons will fail.

Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
Signed-off-by: NeilBrown <neilb@suse.de>
12 years agovalidate_geometry_imsm_volume(): Avoid NULL pointer dereference
Jes Sorensen [Tue, 1 Nov 2011 15:09:34 +0000 (16:09 +0100)] 
validate_geometry_imsm_volume(): Avoid NULL pointer dereference

Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
Signed-off-by: NeilBrown <neilb@suse.de>
12 years agobitmap_fd_read(): fix memory leak
Jes Sorensen [Tue, 1 Nov 2011 15:09:33 +0000 (16:09 +0100)] 
bitmap_fd_read(): fix memory leak

Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
Signed-off-by: NeilBrown <neilb@suse.de>
12 years agoMonitor(): free allocated memory on exit
Jes Sorensen [Tue, 1 Nov 2011 15:09:32 +0000 (16:09 +0100)] 
Monitor(): free allocated memory on exit

Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
Signed-off-by: NeilBrown <neilb@suse.de>
12 years agoManage_runstop(): Avoid memory leak
Jes Sorensen [Tue, 1 Nov 2011 15:09:31 +0000 (16:09 +0100)] 
Manage_runstop(): Avoid memory leak

Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
Signed-off-by: NeilBrown <neilb@suse.de>
12 years agoManaga_ro(): free() mdi before exiting
Jes Sorensen [Tue, 1 Nov 2011 15:09:30 +0000 (16:09 +0100)] 
Managa_ro(): free() mdi before exiting

Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
Signed-off-by: NeilBrown <neilb@suse.de>
12 years agoIncrementalScan(): Fix memory leak
Jes Sorensen [Tue, 1 Nov 2011 15:09:29 +0000 (16:09 +0100)] 
IncrementalScan(): Fix memory leak

Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
Signed-off-by: NeilBrown <neilb@suse.de>
12 years agoManage_subdevs(): avoid leaking super
Jes Sorensen [Tue, 1 Nov 2011 15:09:28 +0000 (16:09 +0100)] 
Manage_subdevs(): avoid leaking super

Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
Signed-off-by: NeilBrown <neilb@suse.de>
12 years agoenough_fd(): remember to free buffer for avail array
Jes Sorensen [Tue, 1 Nov 2011 15:09:27 +0000 (16:09 +0100)] 
enough_fd(): remember to free buffer for avail array

Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
Signed-off-by: NeilBrown <neilb@suse.de>
12 years agoGrow_reshape(): Fix another 'sra' leak
Jes Sorensen [Tue, 1 Nov 2011 15:09:26 +0000 (16:09 +0100)] 
Grow_reshape(): Fix another 'sra' leak

Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
Signed-off-by: NeilBrown <neilb@suse.de>
12 years agoDetail(): Remember to free 'avail'
Jes Sorensen [Tue, 1 Nov 2011 15:09:25 +0000 (16:09 +0100)] 
Detail(): Remember to free 'avail'

Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
Signed-off-by: NeilBrown <neilb@suse.de>
12 years agoAssemble(): don't dup_super() before we need it.
Jes Sorensen [Tue, 1 Nov 2011 15:09:24 +0000 (16:09 +0100)] 
Assemble(): don't dup_super() before we need it.

Avoid resource leak in case we bail loop early

Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
Signed-off-by: NeilBrown <neilb@suse.de>
12 years agoGrow_restart(): free() offsets after use
Jes Sorensen [Tue, 1 Nov 2011 15:09:23 +0000 (16:09 +0100)] 
Grow_restart(): free() offsets after use

Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
Signed-off-by: NeilBrown <neilb@suse.de>
12 years agoassemble_container_content(): fix memory leak
Jes Sorensen [Tue, 1 Nov 2011 15:09:22 +0000 (16:09 +0100)] 
assemble_container_content(): fix memory leak

Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
Signed-off-by: NeilBrown <neilb@suse.de>
12 years agoremove_devices(): readlink returns -1 on error
Jes Sorensen [Tue, 1 Nov 2011 15:09:21 +0000 (16:09 +0100)] 
remove_devices(): readlink returns -1 on error

Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
Signed-off-by: NeilBrown <neilb@suse.de>
12 years agosysfs_unique_holder(): Check read() return value before using as buffer index
Jes Sorensen [Tue, 1 Nov 2011 15:09:20 +0000 (16:09 +0100)] 
sysfs_unique_holder(): Check read() return value before using as buffer index

Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
Signed-off-by: NeilBrown <neilb@suse.de>
12 years agoIncremental(): Check return value of dev_open() before trying to use it
Jes Sorensen [Tue, 1 Nov 2011 15:09:19 +0000 (16:09 +0100)] 
Incremental(): Check return value of dev_open() before trying to use it

Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
Signed-off-by: NeilBrown <neilb@suse.de>
12 years agoGrow_addbitmap(): don't try to close a file descriptor which failed to open
Jes Sorensen [Tue, 1 Nov 2011 15:09:18 +0000 (16:09 +0100)] 
Grow_addbitmap(): don't try to close a file descriptor which failed to open

Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
Signed-off-by: NeilBrown <neilb@suse.de>
12 years agoGrow_Add_device(): dev_open() return a negative fd on error
Jes Sorensen [Tue, 1 Nov 2011 15:09:17 +0000 (16:09 +0100)] 
Grow_Add_device(): dev_open() return a negative fd on error

Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
Signed-off-by: NeilBrown <neilb@suse.de>
12 years agoGrow: fix check_reshape and open_code it.
NeilBrown [Tue, 1 Nov 2011 04:45:46 +0000 (15:45 +1100)] 
Grow: fix check_reshape and open_code it.

check_reshape should not try to parse the subarray string - only
metadata handlers are allowed to do that.

The common code and only interpret a subarray string by passing it to
"container_content" which will then return only the member for that
subarray.

So remove check_reshape and place similar logic explicitly at the two
call-sites.  They are different enough that it is probably clearer to
have explicit code.

Signed-off-by: NeilBrown <neilb@suse.de>
12 years agoIncremental: Fix a merge error in recent patch
NeilBrown [Tue, 1 Nov 2011 04:17:03 +0000 (15:17 +1100)] 
Incremental: Fix a merge error in recent patch

commit  81219e70f2a9be7292046860ea15528fe5854cab required
merging and I messed it up.
The locking shouldn't be there - the caller locks now.

Reported-by: "Labun, Marcin" <Marcin.Labun@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
12 years agomdmon(): Error out if failing to connect to victim monitor
Jes Sorensen [Tue, 1 Nov 2011 03:56:28 +0000 (14:56 +1100)] 
mdmon(): Error out if failing to connect to victim monitor

Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
Signed-off-by: NeilBrown <neilb@suse.de>
12 years agoWrite_rules(): Avoid stack corruption if using extremely long udev pathname
Jes Sorensen [Tue, 1 Nov 2011 03:56:12 +0000 (14:56 +1100)] 
Write_rules(): Avoid stack corruption if using extremely long udev pathname

Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
Signed-off-by: NeilBrown <neilb@suse.de>
12 years agopolicy_add(): Add missing va_end()
Jes Sorensen [Tue, 1 Nov 2011 03:56:06 +0000 (14:56 +1100)] 
policy_add(): Add missing va_end()

Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
Signed-off-by: NeilBrown <neilb@suse.de>
12 years agoAvoid memory leak
Jes Sorensen [Tue, 1 Nov 2011 03:55:59 +0000 (14:55 +1100)] 
Avoid memory leak

In case of second posix_memalign() failing, release memory allocated
in first posix_memalign() call.

Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
Signed-off-by: NeilBrown <neilb@suse.de>
12 years agoAdd missing return in case of trying to grow sub-array
Jes Sorensen [Tue, 1 Nov 2011 03:55:14 +0000 (14:55 +1100)] 
Add missing return in case of trying to grow sub-array

Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
Signed-off-by: NeilBrown <neilb@suse.de>
12 years agoFix memory leak
Jes Sorensen [Tue, 1 Nov 2011 03:54:56 +0000 (14:54 +1100)] 
Fix memory leak

Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
Signed-off-by: NeilBrown <neilb@suse.de>
12 years agopartition_try_spare() use closedir() to release DIR * returned by opendir()
Jes Sorensen [Tue, 1 Nov 2011 03:54:27 +0000 (14:54 +1100)] 
partition_try_spare() use closedir() to release DIR * returned by opendir()

Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
Signed-off-by: NeilBrown <neilb@suse.de>
12 years agoFix memory leak of 'st3' in array_try_spare()
Jes Sorensen [Tue, 1 Nov 2011 03:51:30 +0000 (14:51 +1100)] 
Fix memory leak of 'st3' in array_try_spare()

Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
Signed-off-by: NeilBrown <neilb@suse.de>
12 years agoFix memory leak
Jes Sorensen [Tue, 1 Nov 2011 03:51:14 +0000 (14:51 +1100)] 
Fix memory leak

Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
Signed-off-by: NeilBrown <neilb@suse.de>
12 years agoFix memory leak
Jes Sorensen [Tue, 1 Nov 2011 03:50:44 +0000 (14:50 +1100)] 
Fix memory leak

Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
Signed-off-by: NeilBrown <neilb@suse.de>
12 years agoFix memory leaks in reshape_array()
Jes Sorensen [Tue, 1 Nov 2011 02:33:48 +0000 (13:33 +1100)] 
Fix memory leaks in reshape_array()

Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
Signed-off-by: NeilBrown <neilb@suse.de>
12 years agoKill: remove duplicate tests on 'force'.
NeilBrown [Tue, 1 Nov 2011 02:30:44 +0000 (13:30 +1100)] 
Kill: remove duplicate tests on 'force'.

We test 'force' twice with the second having not chance of
taking effect.
As a result a subsequent message - intended for use in the 'force'
case is never generated.

So remove the first test - it is unnecessary.

Reported-by: Jes.Sorensen@redhat.com
Signed-off-by: NeilBrown <neilb@suse.de>
12 years agoRemove duplicated code: search_mdstat and conf_match
NeilBrown [Tue, 1 Nov 2011 02:30:41 +0000 (13:30 +1100)] 
Remove duplicated code:  search_mdstat and conf_match

search_mdstat and conf_match are almost identical.

Put all the functionality in conf_match, and remove search_mdstat.

Reported-by: Jes.Sorensen@redhat.com
Signed-off-by: NeilBrown <neilb@suse.de>
12 years agokill-subarray: fix, IMSM cannot kill-subarray with unsupported metadata
Labun, Marcin [Mon, 31 Oct 2011 00:29:46 +0000 (11:29 +1100)] 
kill-subarray: fix, IMSM cannot kill-subarray with unsupported metadata

container_content retrieves volume information from disks in the
container.  For unsupported volumes the function was not returning
mdinfo. When all volumes were unsupported the function was returning
NULL pointer to block actions on the volumes. Therefore, such volumes
were not activated in Incremental and Assembly. As side effect they
also could not be deleted using kill-subarray since "kill" function
requires to obtain a valid mdinfo from container_content.

This patch fixes the kill-subarray problem by allowing to obtain
mdinfo of all volumes types including unsupported and introducing new
array.status flags.

There are following changes:

1. Added MD_SB_BLOCK_VOLUME for blocking an array, other arrays in the
   container can be activated.

2. Added MD_SB_BLOCK_CONTAINER_RESHAPE block container wide reshapes
   (like changing disk numbers in arrays).

3. IMSM container_content handler is to load mdinfo for all volumes
   and set both blocking flags in array.state field in mdinfo of
   unsupported volumes.  In case of some errors, all volumes can be
   affected. Only blocked array is not activated (also reshaped as
   result). The container wide reshapes are also blocked since by
   metadata definition they require modifications of both arrays.

4. Incremental_container and Assemble functions check array.state and
   do not activate volumes with blocking bits set.

5. assemble_container_content is changed to check container wide reshapes
   before activating reshapes of assembled containers.

6. Grow_reshape and Grow_continue_command checks blocking bits
   before starting reshapes or continueing (-G --continue) reshapes.

7. kill-subarray ignores array.state info and can remove requested array.

Signed-off-by: Marcin Labun <marcin.labun@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
12 years agoAvoid stack overflow if GPT partition entries on disk are > 128 bytes
Jes Sorensen [Sun, 30 Oct 2011 23:24:55 +0000 (10:24 +1100)] 
Avoid stack overflow if GPT partition entries on disk are > 128 bytes

Per [1] GPT partition table entries are not guaranteed to be 128
bytes, in which case read() straight into a struct GPT_part_entry
would result in a buffer overflow corrupting the stack.

[1] http://en.wikipedia.org/wiki/GUID_Partition_Table

Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
Signed-off-by: NeilBrown <neilb@suse.de>
12 years agoFIX: Close unused handle in child process during reshape restart
Adam Kwolek [Wed, 26 Oct 2011 16:16:55 +0000 (18:16 +0200)] 
FIX: Close unused handle in child process during reshape restart

When array reshape (e.g. raid0->raid5 migration) is restarted during
array assembly, file system placed on this array cannot be mounted until
reshape is finished due to "busy" error.

This is caused when reshape is executed on array for external metadata
and array handle is cloned /forked/ to child process environment but not
closed.

Handle can't be closed before executing Grow_continue() because it is
used later in code.

Close unused handle in child process /reshape_container()/.
It is similar to close fd handle in reshape_array() before calling
manage_reshape()/child_monitor() in Grow.c:2290.

Signed-off-by: Adam Kwolek <adam.kwolek@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
12 years agoGCC compile fix: remove calculation of unused variable 'reservation'
Jes Sorensen [Thu, 6 Oct 2011 14:43:51 +0000 (16:43 +0200)] 
GCC compile fix: remove calculation of unused variable 'reservation'

gcc 4.6.1 doesn't like calculating a variable that then isn't
used. Remove it.

Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
Signed-off-by: NeilBrown <neilb@suse.de>
12 years agoutil.c: two typos fixed
Lukasz Dorau [Tue, 25 Oct 2011 13:42:25 +0000 (15:42 +0200)] 
util.c: two typos fixed

Two typos fixed.

Signed-off-by: Lukasz Dorau <lukasz.dorau@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
12 years agoimsm: fix: Fixes metadata after migration from Raid 0 to Raid 10
root [Sat, 22 Oct 2011 00:42:16 +0000 (11:42 +1100)] 
imsm: fix: Fixes metadata after migration from Raid 0 to Raid 10

After migration from Raid 0 to Raid 10, the metadata is incorrect,
leaving one mirror disk marked as spare and one missing disk as a member
of the array.
The reason is that the metadata update code for spare activation
procedure takes into account one spare disk only, not checking
the following ones.

Signed-off-by: Lukasz Orlowski <lukasz.orlowski@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
12 years agoimsm: Moves metadata update code for spare activation to separate function
Lukasz Orlowski [Sat, 22 Oct 2011 00:38:56 +0000 (11:38 +1100)] 
imsm: Moves metadata update code for spare activation to separate function

The metadata update code during spare activation is moved to a separate
function for clarity of code, as a prework for the next patch fixing
the bug.

Signed-off-by: Lukasz Orlowski <lukasz.orlowski@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
12 years agoIncremental() lock error handling
Jes Sorensen [Sat, 22 Oct 2011 00:34:08 +0000 (11:34 +1100)] 
Incremental() lock error handling

Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
Signed-off-by: NeilBrown <neilb@suse.de>
12 years agoCreate() check malloc() return value
Jes Sorensen [Sat, 22 Oct 2011 00:33:53 +0000 (11:33 +1100)] 
Create() check malloc() return value

Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
Signed-off-by: NeilBrown <neilb@suse.de>
12 years agoCreate() don't leave the lock hanging on error
Jes Sorensen [Sat, 22 Oct 2011 00:32:52 +0000 (11:32 +1100)] 
Create() don't leave the lock hanging on error

Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
Signed-off-by: NeilBrown <neilb@suse.de>
12 years agoarray_try_spare(): missing map_unlock()
Jes Sorensen [Sat, 22 Oct 2011 00:32:19 +0000 (11:32 +1100)] 
array_try_spare(): missing map_unlock()

Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
Signed-off-by: NeilBrown <neilb@suse.de>
12 years agoHold the map lock while performing Assemble to avoid races with udev
Jes Sorensen [Sat, 22 Oct 2011 00:30:43 +0000 (11:30 +1100)] 
Hold the map lock while performing Assemble to avoid races with udev

Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
Signed-off-by: NeilBrown <neilb@suse.de>
12 years agoDon't tell sysfs to launch the container as we are doing it ourselves
Jes Sorensen [Sat, 22 Oct 2011 00:30:02 +0000 (11:30 +1100)] 
Don't tell sysfs to launch the container as we are doing it ourselves

Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
Signed-off-by: NeilBrown <neilb@suse.de>
12 years agoRemove race for starting container devices.
Jes Sorensen [Sat, 22 Oct 2011 00:29:47 +0000 (11:29 +1100)] 
Remove race for starting container devices.

This moves the lock handling out of Incremental_container() and relies
on the caller holding the lock. This prevents conflict with a
follow-on mdadm comment which may try and launch the device in
parallel.

This involves replacing a call to "Incremental" with an
unrolled version with just the case that calls Incremental_container
and so needs a call to ->load_container.

Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
Signed-off-by: NeilBrown <neilb@suse.de>
12 years agosuper0: fix overflow when checking max size.
NeilBrown [Thu, 20 Oct 2011 02:14:26 +0000 (13:14 +1100)] 
super0: fix overflow when checking max size.

We need to force multiplication to use ULL before they
get to big, else it overflows.  So move the "2ULL" to the start.

Signed-off-by: NeilBrown <neilb@suse.de>
12 years agoimsm: fix: correct debug printing of the volume's name
Lukasz Dorau [Wed, 19 Oct 2011 13:16:33 +0000 (15:16 +0200)] 
imsm: fix: correct debug printing of the volume's name

The volume's name is saved in the array of chars.
All elements of the array can have nonzero values
and the next byte in memory does not have to have
the value of 0, so one must be cautious when
printing out the volume's name.

Signed-off-by: Lukasz Dorau <lukasz.dorau@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
12 years agoimsm: fix: prevent segfault in mark_failure
Lukasz Dorau [Wed, 19 Oct 2011 09:51:48 +0000 (11:51 +0200)] 
imsm: fix: prevent segfault in mark_failure

Using an array of chars without the terminating null byte
as a parameter of sprintf() function causes segfault
when dealing with SAS drives (with 20-digits serial number).
The memcpy() function is used instead.

Signed-off-by: Lukasz Dorau <lukasz.dorau@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
12 years agoGrow: Only ping monitor on level change if array is container based.
NeilBrown [Mon, 17 Oct 2011 05:51:31 +0000 (16:51 +1100)] 
Grow: Only ping monitor on level change if array is container based.

Pinging the monitor for a NULL container is bad.

Reported-by: Daniel Kahn Gillmor <dkg@fifthhorseman.net>
Tested-by: Daniel Kahn Gillmor <dkg@fifthhorseman.net>
Signed-off-by: NeilBrown <neilb@suse.de>
12 years agoFix unterminated buffer after readlink() call
Thomas Jarosch [Thu, 13 Oct 2011 09:22:13 +0000 (11:22 +0200)] 
Fix unterminated buffer after readlink() call

Signed-off-by: Thomas Jarosch <thomas.jarosch@intra2net.com>
Signed-off-by: NeilBrown <neilb@suse.de>
12 years agoFix off-by-one in readlink() buffer size handling
Thomas Jarosch [Thu, 13 Oct 2011 09:21:07 +0000 (11:21 +0200)] 
Fix off-by-one in readlink() buffer size handling

readlink() returns the number of bytes in the buffer.

If we do something like

len = readlink(path, buf, sizeof(buf));
buf[len] = '\0';

we might write one byte past the end of the buffer.

Signed-off-by: Thomas Jarosch <thomas.jarosch@intra2net.com>
Signed-off-by: NeilBrown <neilb@suse.de>
12 years agoimsm: fix: stopped resync does not continue after auto-assemblation
Lukasz Dorau [Sun, 9 Oct 2011 22:16:40 +0000 (09:16 +1100)] 
imsm: fix: stopped resync does not continue after auto-assemblation

Resync stopped with "mdadm -Ss" command does not continue
after issuing "mdadm -As" command.

Signed-off-by: Lukasz Dorau <lukasz.dorau@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
12 years agoAlways run Grow_continue() for started array.
Adam Kwolek [Thu, 6 Oct 2011 09:13:22 +0000 (11:13 +0200)] 
Always run Grow_continue() for started array.

So far there were 2 reshape continuation cases:
 1. array is started /e.g. reshape was already invoked during initrd
                      start-up stage using "--freeze-reshape" option/
 2. array is not started yet /"normal" assembling array under reshape case/

This patch narrows continuation cases in to single one. To do this
array should be started /set readonly in to array_state/ before calling
Grow_continue() function.

Signed-off-by: Adam Kwolek <adam.kwolek@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
12 years agoimsm: always use set_migr_type to set type of migration
Przemyslaw Czarnowski [Wed, 5 Oct 2011 09:59:50 +0000 (11:59 +0200)] 
imsm: always use set_migr_type to set type of migration

For 'resync' besides the update of migration type (imsm_vol.migr_type
structure) additionally status (imsm_dev.status) flag is set to
DEV_VERIFY_AND_FIX. In order to clean up after migration, status flag
must be cleared. For this reason, migration type shouldn't be set
directly but via set_migr_type(). Otherwise status does not reflect
the state of array.

Signed-off-by: Przemyslaw Czarnowski <przemyslaw.hawrylewicz.czarnowski@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
12 years agoFix handling for "auto" line in mdadm.conf
NeilBrown [Thu, 6 Oct 2011 02:00:28 +0000 (13:00 +1100)] 
Fix handling for "auto" line in mdadm.conf

Two problems.

1/ pol_merge was ignoring the pol_auto tag so any 'auto' information
   was lost
2/ If a device had not path (e.g. loop devices) or if there were no
   path-based policies, we didn't bother looking for policy at all.
   So path-independant policies were ignored.

Reported-by: Christian Boltz <suse-beta@cboltz.de>
Signed-off-by: NeilBrown <neilb@suse.de>
12 years agoimsm: fix: correct adding and activation of spare disks
Lukasz Dorau [Wed, 5 Oct 2011 03:17:38 +0000 (14:17 +1100)] 
imsm: fix: correct adding and activation of spare disks

During activation of spare disks, only one of all available
spare disks can be activated at this moment.
It causes that for example during take-over from
RAID0 with 2 disks to RAID10, only one of two spare disks
is taken for recovery and a degraded RAID10 array
with only 3 of 4 working disks is created.
It has been fixed by adding more than one of all available
spare disks and saving them in additional_test_list
which is passed to imsm_add_spare().

Signed-off-by: Lukasz Dorau <lukasz.dorau@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
12 years agoSet correct reshape restart position
Adam Kwolek [Wed, 5 Oct 2011 03:00:00 +0000 (14:00 +1100)] 
Set correct reshape restart position

This patch version is simplified compared to previous one.
There is no use of freeze_reshape flag in start_reshape(). It is assumed
that for reshape starting condition reshape_progress field contains
0 value /correct start position/. For reshape restart case, it contains
correct restart position. This approach doesn't make start_reshape()
difficult to read/manage and /imho/ kernel changes to change mdstat
reporting behavior are not necessary.

Setting correct position allows user to see it in the mdstat during
reshape restart and reshape process is not reported as resync.

Signed-off-by: Adam Kwolek <adam.kwolek@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
12 years agoMonitor reshaped array
Adam Kwolek [Wed, 5 Oct 2011 02:59:28 +0000 (13:59 +1100)] 
Monitor reshaped array

Reshape can be run for monitored arrays only /external metadata case/.
Before reshape can be executed, make sure that just starter array/container
is monitored. If not, run mdmon for it.

Signed-off-by: Adam Kwolek <adam.kwolek@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
12 years agoRemove freeze() call from Grow_continue()
Adam Kwolek [Wed, 5 Oct 2011 02:33:29 +0000 (13:33 +1100)] 
Remove freeze() call from Grow_continue()

Grow_continue() for external metadata should be executed on blocked
from monitoring array(s)/container.
Additional call to freeze() is not necessary in such case.
It produces meaningless error message only.

Signed-off-by: Adam Kwolek <adam.kwolek@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
12 years agoimsm: Fill recovery_blocked field present in mdinfo
Adam Kwolek [Wed, 5 Oct 2011 02:32:28 +0000 (13:32 +1100)] 
imsm: Fill recovery_blocked field present in mdinfo

If any reshape in container is active set recovery_blocked field.

Signed-off-by: Adam Kwolek <adam.kwolek@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
12 years agoAdd recovery blocked field to mdinfo
Adam Kwolek [Wed, 5 Oct 2011 02:30:50 +0000 (13:30 +1100)] 
Add recovery blocked field to mdinfo

When container is assembled while reshape is active on one of its member
whole container can be required to be blocked from monitoring.
For such purpose field recovery blocked is added to mdinfo structure.

When metadata handler finds active reshape in container it should set
recovery_blocked field to disable whole container monitoring during
reshape.

For arrays that doesn't use containers, recovery_blocked field
has the same value as reshape_active field e.g. super0/1.
In fact,recovery is blocked during reshape for such arrays.
For ddf, metadata handler doesn't set reshape_active field,
so recovery_blocked is not set also.

Signed-off-by: Adam Kwolek <adam.kwolek@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
12 years agorestore_backup() throws core dump
NeilBrown [Wed, 5 Oct 2011 02:29:16 +0000 (13:29 +1100)] 
restore_backup() throws core dump

restore_backup() throws core dump during releasing fdlist.
Loop for closing handlers checks next_spare variable,
but iterates disk_count.

Reported-by: Adam Kwolek <adam.kwolek@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
12 years agoMove code to check_mdmon_version() function
Adam Kwolek [Sun, 2 Oct 2011 23:32:02 +0000 (10:32 +1100)] 
Move code to check_mdmon_version() function

Move code to function for code reuse.

Signed-off-by: Adam Kwolek <adam.kwolek@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
12 years agoimsm: Do not mark resync during reshape
Adam Kwolek [Sun, 2 Oct 2011 23:31:22 +0000 (10:31 +1100)] 
imsm: Do not mark resync during reshape

During reshape, resync/rebuild in the same container is not possible
due to fact that all arrays in container has to share the same disks set.

Block new resync/rebuild process initialization and setting resync_start
to 0 while any reshape in container is active. This avoids breaking
container reshape and doesn't allow for starting multiple processes
/resync/rebuild and reshape/ at the same time in md.

Signed-off-by: Adam Kwolek <adam.kwolek@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
12 years agoimsm: FIX: Do not allow for spare disk activation during reshape
Adam Kwolek [Sun, 2 Oct 2011 23:30:28 +0000 (10:30 +1100)] 
imsm: FIX: Do not allow for spare disk activation during reshape

Spare disk activation or starting repair for one array while on second
reshape is in progress, will lead to IMSM incompatible situation when
2 arrays in container shares different disks sets.
This can cause that 2 processes in container /reshape and rebuild/
are in progress in parallel. This is IMSM incompatible situation also.

Block spare disk activation and starting resync if any reshape in container
is in progress.

Signed-off-by: Adam Kwolek <adam.kwolek@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
12 years agoManual update for --continue option
Adam Kwolek [Sun, 2 Oct 2011 23:09:21 +0000 (10:09 +1100)] 
Manual update for --continue option

Patch adds to mdadm man the following information:

 --continue
   This option is complementary pair to assembly --freeze-reshape option.
   It is needed when --grow operation is interrupted and it is not restarted
   automatically due to --freeze-reshape usage during array assembly.
   Option --continue has to be used together with -G , ( --grow ) command
   and device that it should be executed on.  All parameters required for
   reshape continuation will be read from array metadata.  If initial
   --grow command had required --backup-file= option to be set,
   continuation option will require to  have  exactly the same backup
   file pointed to also.

   Any other parameter passed together with --continue option will be ignored.

Signed-off-by: Adam Kwolek <adam.kwolek@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
12 years agoManual update for --continue option
Adam Kwolek [Sun, 2 Oct 2011 23:07:30 +0000 (10:07 +1100)] 
Manual update for --continue option

Patch adds to mdadm man the following information:

--freeze-reshape
  Option  is  intended  to  be used in start-up scripts during initrd boot
  phase.  When array under reshape is assembled during initrd phase,
  this option stops reshape after reshape critical section is being
  restored. This happens before file system pivot operation and avoids lost
  of file system context.  Loosing file system context would cause
  reshape to be broken.

  Reshape can be continued later using -continue option for grow command.

Signed-off-by: Adam Kwolek <adam.kwolek@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
12 years agoVerify reshape restart position
Adam Kwolek [Sun, 2 Oct 2011 23:04:32 +0000 (10:04 +1100)] 
Verify reshape restart position

Check if reshape restart position is the same as set in md.
If position doesn't match this means that we cannot restart reshape.

Signed-off-by: Adam Kwolek <adam.kwolek@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
12 years agoMove code to get_data_disks() function
Adam Kwolek [Sun, 2 Oct 2011 22:57:12 +0000 (09:57 +1100)] 
Move code to get_data_disks() function

Move code to function for code reuse.

Signed-off-by: Adam Kwolek <adam.kwolek@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
12 years agoAdd continue option to grow command
Adam Kwolek [Sun, 2 Oct 2011 22:26:48 +0000 (09:26 +1100)] 
Add continue option to grow command

To allow for reshape continuation '--continue' option is added
to grow command.
Function that will be executed in grow-continue case doesn't require
information about reshape geometry. All required information are read
from metadata.
For external metadata reshape can be run for monitored array/container
only. In case when array/container is not monitored run mdmon for it.

Signed-off-by: Adam Kwolek <adam.kwolek@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
12 years agoDo not continue reshape during initrd phase
Adam Kwolek [Sun, 2 Oct 2011 22:15:22 +0000 (09:15 +1100)] 
Do not continue reshape during initrd phase

During initrd phase continuing reshape will cause file system context
lost. This blocks ability to control reshape using checkpoints.

To avoid this, during initrd phase assemble has to be executed with
'--freeze-reshape' option. This causes that mdadm restores reshape
critical section only.

Reshape can be continued later after system full boot.

Signed-off-by: Adam Kwolek <adam.kwolek@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
12 years agofix: correct unlocking of map file
Lukasz Dorau [Sun, 2 Oct 2011 21:55:02 +0000 (08:55 +1100)] 
fix: correct unlocking of map file

1. Three missing map_unlock() calls were added.
2. Map file must be unlocked on fork, else child will hold lock.

Signed-off-by: Lukasz Dorau <lukasz.dorau@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
12 years agoFix small memory leak
Thomas Jarosch [Sun, 2 Oct 2011 19:45:41 +0000 (21:45 +0200)] 
Fix small memory leak

Credit goes to cppcheck.

Signed-off-by: Thomas Jarosch <thomas.jarosch@intra2net.com>
Signed-off-by: NeilBrown <neilb@suse.de>
12 years agoimsm: Calculate reservation for a spare based on active disks in container
Czarnowska, Anna [Mon, 19 Sep 2011 12:57:48 +0000 (12:57 +0000)] 
imsm: Calculate reservation for a spare based on active disks in container

New function to calculate minimum reservation to expect from a spare
is introduced.

The required amount of space at the end of the disk depends on what we
plan to do with the spare and what array we want to use it in.
For creating new subarray in an empty container the full reservation of
MPB_SECTOR_COUNT + IMSM_RESERVED_SECTORS is required.

For recovery or OLCE on a volume using new metadata format at least
MPB_SECTOR_CNT + NUM_BLOCKS_DIRTY_STRIPE_REGION is required.
The additional space for migration optimization included in
IMSM_RESERVED_SECTORS is not necessary and is not reserved by some oroms.

MPB_SECTOR_CNT alone is not sufficient as it does not include the
reservation at the end of subarray.

However if the real reservation on active disks is smaller than this
(when the array uses old metadata format) we should use the real value.
This will allow OLCE and recovery to start on the spare even if the volume
doesn't have the reservation we normally use for new volumes.

Signed-off-by: Anna Czarnowska <anna.czarnowska@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
12 years agoCreate: improve messages from validate_geometry.
NeilBrown [Wed, 21 Sep 2011 04:39:01 +0000 (14:39 +1000)] 
Create: improve messages from validate_geometry.

When validate_geometry finds that we haven't committed to
a metadata yet and that the subdev is a member of 'our'
container, it needs to report any errors it finds as Create()
cannot report them effectively.

So make a slight change to the semantics of the 'verbose' flag
and allow validate_geometry to report if it printed any error
messages.

Signed-off-by: NeilBrown <neilb@suse.de>
12 years agoCreate: Allow to create two volumes of different sizes within one container
Lukasz Orlowski [Mon, 19 Sep 2011 16:52:31 +0000 (18:52 +0200)] 
Create: Allow to create two volumes of different sizes within one container

Allows to create RAID 5 volume on 3 disks and then RAID 1 volume on 2
disks withing the same container.

Signed-off-by: Lukasz Orlowski <lukasz.orlowski@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>