]> git.ipfire.org Git - thirdparty/mdadm.git/log
thirdparty/mdadm.git
12 years agoFix component size checks in validate_super0.
NeilBrown [Thu, 8 Sep 2011 02:20:36 +0000 (12:20 +1000)] 
Fix component size checks in validate_super0.

A 0.90 array can use at most 4TB of each device - 2TB between
2.6.39 and 3.1 due to a kernel bug.

The test for this in validate_super0 is very wrong.  'size' is sectors
and the number it is compared against is just confusing.

So fix it all up and correct the spelling of terabytes and remove
a second redundant test on 'size'.

Signed-off-by: NeilBrown <neilb@suse.de>
12 years agoFix small memory leak
Thomas Jarosch [Fri, 26 Aug 2011 05:33:37 +0000 (07:33 +0200)] 
Fix small memory leak

Found by cppcheck

Signed-off-by: Thomas Jarosch <thomas.jarosch@intra2net.com>
Signed-off-by: NeilBrown <neilb@suse.de>
12 years agofix: segfault when killing subarray of non-existent container
Czarnowska, Anna [Mon, 1 Aug 2011 14:33:06 +0000 (15:33 +0100)] 
fix: segfault when killing subarray of non-existent container

Negative value must be returned to indicate error in open_subarray

Reviewed-by: Dan Williams <dan.j.williams@intel.com>
Signed-off-by: Anna Czarnowska <anna.czarnowska@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
12 years agoshorten remove rules
Michal Soltys [Wed, 7 Sep 2011 04:02:29 +0000 (14:02 +1000)] 
shorten remove rules

This implicitly adds ddf containers to 'add' and 'remove' rules.

Signed-off-by: Michal Soltys <soltys@ziu.info>
Signed-off-by: NeilBrown <neilb@suse.de>
12 years agostart_mdmon: provide more dynamic way to close-all-fds
NeilBrown [Wed, 7 Sep 2011 03:00:32 +0000 (13:00 +1000)] 
start_mdmon: provide more dynamic way to close-all-fds

When forking mdmon we need to close all other fds because we don't
use O_CLOEXEC yet.
Any approach will be fairly arbitrary, but as we can expect fds to be
fairly dense, closing until we find a set number that don't need
closing is possible safer than only closing the first 100.
So keep closing until we find 20 that are already closed.

Signed-off-by: NeilBrown <neilb@suse.de>
12 years agoFIX: Prevent using null list pointer
NeilBrown [Wed, 7 Sep 2011 02:45:24 +0000 (12:45 +1000)] 
FIX: Prevent using null list pointer

When not all attributes are supported (attributes incompatibility)
function container_content_imsm returns NULL pointer.
We need to cope with a NULL list better.

Reported-by: Lukasz Dorau <lukasz.dorau@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
12 years agoFIX: Mdmon crashes after changing RAID level from 1 to 0
Lukasz Dorau [Thu, 1 Sep 2011 13:10:34 +0000 (15:10 +0200)] 
FIX: Mdmon crashes after changing RAID level from 1 to 0

Description of the bug:
Sometimes mdmon crashes after changing RAID level from 1 to 0 (takeover).

Cause of the bug:
The managemon marks an active_array for removal from monitoring
by assigning a->container to NULL value (in the "manage_member" function).
Sometimes (during stress test) it happens right when the monitor
is in the "read_and_act" function and a->container pointer is in use.
This causes the monitor crashes.

Solution:
The active array has to be marked for removal in another way
than setting NULL pointer when it can be in use.
A new field "to_remove" was added to the "active_array" structure.
It is used in the managemon to mark a container to remove
(instead of the old assigment: a->container = NULL)
and monitor checks it to determine if the array should be removed.
The field "to_remove" should be checked in some other places
to avoid managing of the array which is going to be removed.

Signed-off-by: Lukasz Dorau <lukasz.dorau@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
12 years agoimsm: support 'missing' devices at Create
Dan Williams [Tue, 30 Aug 2011 03:11:42 +0000 (13:11 +1000)] 
imsm: support 'missing' devices at Create

Specifying missing devices at create is very useful for array recovery.

For imsm create dummy disk entries at init_super_imsm time, and then use
them to fill in unoccupied slots in the final array (if the container is
unpopulated).

If the container is already populated (has a subarray)
'missing' disks must be in reference to already recorded missing devices
in the metadata.

Also add support for --assume-clean for imsm arrays.

Cc: Dave Jiang <dave.jiang@intel.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
12 years agomdmon: fix, close spare activation race
Dan Williams [Fri, 26 Aug 2011 02:14:29 +0000 (19:14 -0700)] 
mdmon: fix, close spare activation race

The following test fails when the md_check_recovery() event triggered by
the ro->rw transition causes remove_and_add_spares() to run while mdmon
is attempting spare activation.

Result is that the kernel races to set the slot immediately after
sysfs_add_disk() writes new_dev.  mdmon thinks the spare activation
failed and declines to send the monitor a new acitve_array.  We show
degraded after the wait because the monitor cannot notify the metadata
that all disks are in_sync.

#!/bin/bash
i=0
false
while [ $? == 1 ]
do
i=$((i+1))
mdadm -Ss
mdadm -CR /dev/md0 /dev/loop[0-2] -n 3 -e imsm
mdadm -CR /dev/md1 /dev/loop[01] missing -n 3 -l 5
mdadm --wait /dev/md1
mdadm -E /dev/loop2 | grep -i degraded
done
echo "failed: $i"

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
12 years agoimsm: fix reserved sectors for spares
Dan Williams [Fri, 26 Aug 2011 02:14:24 +0000 (19:14 -0700)] 
imsm: fix reserved sectors for spares

Different OROMs reserve different amounts of space for the migration area.
When activating a spare minimize the reserved space otherwise a valid spare
can be prevented from joining an array with a migration area smaller than
IMSM_RESERVED_SECTORS.

This may result in an array that cannot be reshaped, but that is less
surprising than not being able to rebuild a degraded array.
imsm_reserved_sectors() already reports the minimal value which adds to
the confusion when trying rebuild an array because mdadm -E indicates
that the device has enough space.

Cc: Anna Czarnowska <anna.czarnowska@intel.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
12 years agosysfs: fix sysfs_disk_to_scsi_id
Dan Williams [Fri, 26 Aug 2011 02:14:19 +0000 (19:14 -0700)] 
sysfs: fix sysfs_disk_to_scsi_id

Not sure how this ever worked, but now we just try to parse a directory
name that looks like <host>:<bus>:<target>:<lun>.

Array creation segfaults on Fedora 14 without this.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
12 years agoimsm: fix display spares
Dan Williams [Fri, 26 Aug 2011 02:14:14 +0000 (19:14 -0700)] 
imsm: fix display spares

Commit 94827db3 "imsm: add spares to --examine output." may try to
display failed disks whose imsm_disk info is not uptodate (due to not
being able to look itself up by serial).  The same effect can be had by
just loosening the restriction in print_imsm_disk().

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
12 years agoimsm: fix, stop metadata updates to newly failed devices
Dan Williams [Fri, 26 Aug 2011 02:14:09 +0000 (19:14 -0700)] 
imsm: fix, stop metadata updates to newly failed devices

We already refrain from updating metadata on disks that are failed at
load, need to do the same for new failures.  This also reverts b4add146
as we *do* want to update other disks' view of the failed device as out of
date.

Cc: Krzysztof Wojcik <krzysztof.wojcik@intel.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
12 years agoimsm: fix max disks per array
Dan Williams [Fri, 26 Aug 2011 02:14:04 +0000 (19:14 -0700)] 
imsm: fix max disks per array

Validate geometry is incorrectly looking at max disks support which is
irrelevant for md/mdadm.  ->dpa (disks per array) is how many disks the
orom will allow per volume.

Also cleanup an unnecessary ->orom check, is_raid_level_supported()
already does the right thing in the !orom case.

Cc: Marcin Labun <marcin.labun@intel.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
12 years agomd.4: two typos fixed
Bill Allaire [Mon, 22 Aug 2011 21:24:17 +0000 (17:24 -0400)] 
md.4: two typos fixed

Signed-off-by: Bill Allaire <vger@bogoflop.com>
Signed-off-by: NeilBrown <neilb@suse.de>
12 years agomd.4: Fixed typo.
Bill Allaire [Sat, 20 Aug 2011 23:11:03 +0000 (19:11 -0400)] 
md.4: Fixed typo.

Signed-off-by: Bill Allaire <vger@bogoflop.com>
Signed-off-by: NeilBrown <neilb@suse.de>
12 years agoudev rules improvement
NeilBrown [Thu, 18 Aug 2011 05:17:52 +0000 (15:17 +1000)] 
udev rules improvement

Don't try to pass and empty path to "mdadm -If" - it will cause
problems.

Signed-off-by: NeilBrown <neilb@suse.de>
12 years agoUpdate COPYING file.
NeilBrown [Thu, 18 Aug 2011 02:55:24 +0000 (12:55 +1000)] 
Update COPYING file.

Update to latest from http://www.gnu.org/licenses/gpl-2.0.txt
This corrects the address and some other minor details.
No change in the license.

Signed-off-by: NeilBrown <neilb@suse.de>
12 years agoRAID-6 check standalone man page
Piergiorgio Sartor [Tue, 9 Aug 2011 00:43:58 +0000 (10:43 +1000)] 
RAID-6 check standalone man page

Signed-off-by: NeilBrown <neilb@suse.de>
12 years agoIMSM: allow some array attribute bits to be ignored.
NeilBrown [Mon, 8 Aug 2011 22:49:34 +0000 (08:49 +1000)] 
IMSM: allow some array attribute bits to be ignored.

Some bits are not handled by mdadm, but their presence should not
cause failure.
In particular MPB_ATTRIB_NEVER_USE appears harmless.

Reported-by: Thomas Steinborn <thestonewell@googlemail.com>
Signed-off-by: NeilBrown <neilb@suse.de>
12 years agosuper1: fix spacing for 'Flags' field in --examine.
NeilBrown [Tue, 2 Aug 2011 03:36:08 +0000 (13:36 +1000)] 
super1: fix spacing for 'Flags' field in --examine.

Signed-off-by: NeilBrown <neilb@suse.de>
12 years ago--add incorrectly sets writemostly
Scott Schaefer [Tue, 2 Aug 2011 03:27:32 +0000 (13:27 +1000)] 
--add incorrectly sets writemostly

Origin: vendor, http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=628667
Bug-Debian: http://bugs.debian.org/628667

Signed-off-by: NeilBrown <neilb@suse.de>
12 years agoAdd some more settings of ignore_hw_compat
NeilBrown [Mon, 1 Aug 2011 02:21:19 +0000 (12:21 +1000)] 
Add some more settings of ignore_hw_compat

There are some more times when we don't care that the hardware doesn't
support the metadata:
 - when removing old metadata
 - when reporting the metadata present before over-writing it.

So set ignore_hw_compat in these cases.

Signed-off-by: NeilBrown <neilb@suse.de>
12 years agoGrow: ensure clean abort if we cannot read the 'completed' file.
NeilBrown [Wed, 27 Jul 2011 07:26:12 +0000 (17:26 +1000)] 
Grow: ensure clean abort if we cannot read the 'completed' file.

If a read of 'completed' returns an error, select will never fail, so
this loop would never exit.

Signed-off-by: NeilBrown <neilb@suse.de>
12 years agoIMSM: set ->raid_disk correctly in getinfo_super_imsm_volume
NeilBrown [Wed, 27 Jul 2011 06:11:48 +0000 (16:11 +1000)] 
IMSM: set ->raid_disk correctly in getinfo_super_imsm_volume

The 'raid_disk' can be different to the 'number' and must be
the position of the device in the array, not in the container.

Normally these should not be different, but the test-suite creates a
possibility so it should work.

Signed-off-by: NeilBrown <neilb@suse.de>
12 years agomdadm.8.in: clarify some issues with --size
NeilBrown [Wed, 27 Jul 2011 04:06:13 +0000 (14:06 +1000)] 
mdadm.8.in: clarify some issues with --size

- explain it's use in guarding against small replacements
- clarify relationship with containers.
- include information about --grow --size not being supported by IMSM metadata.

Reported-by: maciej.naruszewicz <maciej.naruszewicz@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
12 years agoGrow: fix version number in error message
Namhyung Kim [Tue, 19 Jul 2011 04:34:13 +0000 (13:34 +0900)] 
Grow: fix version number in error message

As the conditional checks, reshape to fewer devices is supported
since Linux kernel 2.6.30 not 2.6.32.

Signed-off-by: Namhyung Kim <namhyung@gmail.com>
Signed-off-by: NeilBrown <neilb@suse.de>
12 years agoimsm: fix default chunk in the !orom case
Dan Williams [Mon, 18 Jul 2011 20:52:29 +0000 (06:52 +1000)] 
imsm: fix default chunk in the !orom case

Set a valid default in the !orom case, otherwise we segfault, or
otherwise fail.

Cc: Anna Czarnowska <anna.czarnowska@intel.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
12 years agoimsm: getinfo_super_imsm_volume() doesn't fill all disk information
NeilBrown [Thu, 14 Jul 2011 05:42:10 +0000 (15:42 +1000)] 
imsm: getinfo_super_imsm_volume() doesn't fill all disk information

getinfo_super_imsm_volume doesn't correctly set info.disk fields
because it doesn't know which disk to set them from.
It should be the last disk passed to add_to_super.

So add a field 'current_disk' to record this disk in add_to_super, and
use it in getinfo_super.

This allows us to remove a hack in Create.c

Signed-off-by: NeilBrown <neilb@suse.de>
12 years agomdadm: fix build failures (ppc64)
Milan Broz [Thu, 14 Jul 2011 03:58:36 +0000 (13:58 +1000)] 
mdadm: fix build failures (ppc64)

This patch fixes these build issues:

super-intel.c: In function 'getinfo_super_imsm_volume':
super-intel.c:2327:4: error: format '%llu' expects argument of type 'long long
unsigned int', but argument 3 has type '__u64' [-Werror=format]

super-intel.c: In function 'imsm_reshape_super':
super-intel.c:8665:7: error: 'devnum' may be used uninitialized in this function [-Werror=uninitialized]

Signed-off-by: Milan Broz <mbroz@redhat.com>
Signed-off-by: NeilBrown <neilb@suse.de>
12 years agosuper-intel: fix buffer overflow in detail-platform.
NeilBrown [Wed, 13 Jul 2011 02:38:50 +0000 (12:38 +1000)] 
super-intel: fix buffer overflow in detail-platform.

The serial number is not necessarily nul terminated, so we need to be
sure to only use the allowed number of chars.

Signed-off-by: NeilBrown <neilb@suse.de>
Reported-by: Arvin Schnell <aschnell@novell.com>
12 years agomd.4: fix possible typos
Namhyung Kim [Fri, 24 Jun 2011 04:26:50 +0000 (13:26 +0900)] 
md.4: fix possible typos

Signed-off-by: Namhyung Kim <namhyung@gmail.com>
Signed-off-by: NeilBrown <neilb@suse.de>
12 years agomdmon.8: fix possible typos
Namhyung Kim [Fri, 24 Jun 2011 04:26:49 +0000 (13:26 +0900)] 
mdmon.8: fix possible typos

Signed-off-by: Namhyung Kim <namhyung@gmail.com>
Signed-off-by: NeilBrown <neilb@suse.de>
12 years agoShow DELAYED, PENDING status of resync process in "--detail"
Krzysztof Wojcik [Thu, 23 Jun 2011 02:06:47 +0000 (12:06 +1000)] 
Show DELAYED, PENDING status of resync process in "--detail"

Initially there is no proper translation mdstat's DELAYED/PENDING processes
to "--detail" output.
For example, if we have recover=DELAYED in mdstat, "--detail"
shows "State: recovering" and "Rebuild Status = 0%".
It was incorrect in case of process waiting on checkpoint different
than 0%. In fact rebuild status is differnt than 0% and user is misled.

The patch fix the problem. Current "--detail" command shows
in the exampe: "State: recovering (DELAYED)" and no information
about precentage.

Signed-off-by: Krzysztof Wojcik <krzysztof.wojcik@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
12 years agomdadm --detail was incorrect for shrinking reshapes
Andrew Burgess [Thu, 23 Jun 2011 01:48:03 +0000 (11:48 +1000)] 
mdadm --detail was incorrect for shrinking reshapes

Since info->delta_disks is signed it doesn't need to be special-cased.

This allowed my 9->8 reshape to display correctly instead of as 8->7

Signed-off-by: NeilBrown <neilb@suse.de>
12 years ago.gitignore: ignore mdadm.8 file
Namhyung Kim [Thu, 23 Jun 2011 01:40:14 +0000 (11:40 +1000)] 
.gitignore: ignore mdadm.8 file

mdadm.8 is auto-generated from mdadm.8.in, so ignore it.

Signed-off-by: Namhyung Kim <namhyung@gmail.com>
Signed-off-by: NeilBrown <neilb@suse.de>
12 years agomdadm.8: fix possible typos
Namhyung Kim [Thu, 23 Jun 2011 01:40:10 +0000 (11:40 +1000)] 
mdadm.8: fix possible typos

Fix random typos and add a few of missing words/macros.
Also update RAID website URL as it is not accessible anymore.

Signed-off-by: Namhyung Kim <namhyung@gmail.com>
Signed-off-by: NeilBrown <neilb@suse.de>
12 years agomdadm.8: move description of --add under Grow mode
Namhyung Kim [Tue, 21 Jun 2011 16:19:03 +0000 (01:19 +0900)] 
mdadm.8: move description of --add under Grow mode

It is supposed to be under Grow mode. Since Create/Build/Grow modes
use common options and '-a' is already used for '--auto' in Create/
Build modes, describe it to avoid confusion.

Signed-off-by: NeilBrown <neilb@suse.de>
12 years agomdadm.8: change linux version 2.6.40 -> 3.0
Namhyung Kim [Tue, 21 Jun 2011 16:19:02 +0000 (01:19 +0900)] 
mdadm.8: change linux version 2.6.40 -> 3.0

Signed-off-by: Namhyung Kim <namhyung@gmail.com>
Signed-off-by: NeilBrown <neilb@suse.de>
12 years agoutil: correctly parse shorter linux version numbers.
NeilBrown [Fri, 17 Jun 2011 12:49:24 +0000 (22:49 +1000)] 
util: correctly parse shorter linux version numbers.

The next version of Linux might be 3.0.  If it is, get_linux_version
will fail.
So make it more robust.

Reported-by: Namhyung Kim <namhyung@gmail.com>
Reported-by: Milan Broz <mbroz@redhat.com>
Signed-off-by: NeilBrown <neilb@suse.de>
12 years agoRelease mdadm-3.2.2 mdadm-3.2.2
NeilBrown [Fri, 17 Jun 2011 05:15:37 +0000 (15:15 +1000)] 
Release mdadm-3.2.2
Stability release

12 years agoDon't index past the end of 'best' array in Assemble.
NeilBrown [Fri, 17 Jun 2011 04:48:33 +0000 (14:48 +1000)] 
Don't index past the end of 'best' array in Assemble.

The 'best' array only has 'bestcnt' entries allocated, so 'i' should
always be "< bestcnt", not "<= bestcnt".

Reported-by: "Lawrence, Joe" <Joe.Lawrence@stratus.com>
Signed-off-by: NeilBrown <neilb@suse.de>
12 years agoImprovements to GPT reading code.
Luca Berra [Fri, 17 Jun 2011 04:41:01 +0000 (14:41 +1000)] 
Improvements to GPT reading code.

looking at the gpt code in util.c i found i did not like it at all, a
gpt partition entry is currently 128 bytes, but the spec does not say it
is a fixed value, so the code that reads into a buffer with 512bytes
chunk expecting this to be a multiplier of part_size is imho incorrect.
my fix was to read each partition entry directly into a struct
GPT_part_entry, the advantage is that the code is very simple to read,
the disadvantage it is 128 reads of 128 bytes each, which is
sub-optimal, but i believe readahead will mitigate this a lot.

Signed-off-by: NeilBrown <neilb@suse.de>
12 years agoFix some type-aliasing issues.
Luca Berra [Fri, 17 Jun 2011 04:38:14 +0000 (14:38 +1000)] 
Fix some type-aliasing issues.

Warnings for these are reported with -Wstrict-aliasing=2, and
avoiding the cast is certainly an improvement.

Signed-off-by: NeilBrown <neilb@suse.de>
12 years agoFix some compiler warnings.
Luca Berra [Fri, 17 Jun 2011 04:35:06 +0000 (14:35 +1000)] 
Fix some compiler warnings.

Original by Luca, with various changes by Neil

Signed-off-by: NeilBrown <neilb@suse.de>
12 years agoVarious fixes so that "make everything" works.
NeilBrown [Thu, 16 Jun 2011 07:13:50 +0000 (17:13 +1000)] 
Various fixes so that "make everything" works.

In particular: protect some stuff from MDASSEMBLE and report and error
from 'write'.

Signed-off-by: NeilBrown <neilb@suse.de>
12 years agoMore fixes for tests.
NeilBrown [Thu, 16 Jun 2011 04:18:18 +0000 (14:18 +1000)] 
More fixes for tests.

Some more fixes to help some tests run properly.

Signed-off-by: NeilBrown <neilb@suse.de>
12 years agotest/ddf add a udevadm settle
NeilBrown [Wed, 15 Jun 2011 06:30:12 +0000 (16:30 +1000)] 
test/ddf  add a udevadm settle

We need to settle udev before assuming the devices exist.

Signed-off-by: NeilBrown <neilb@suse.de
12 years agoRemove more duplicated code
NeilBrown [Wed, 15 Jun 2011 06:30:09 +0000 (16:30 +1000)] 
Remove more duplicated code

Code from env-imsm-template is also in 09imsm-create-fail-rebuild,
so remove it from there.

Signed-off-by: NeilBrown <neilb@suse.de>
12 years agotests/08imsm-overlap - remove duplicated code
NeilBrown [Wed, 15 Jun 2011 06:06:57 +0000 (16:06 +1000)] 
tests/08imsm-overlap - remove duplicated code

This test contains a lot of code that is also in env-imsm-template.
So remove it and simple source the other.

Signed-off-by: NeilBrown <neilb@suse.de>
12 years agoddf: fix up getinfo_super_bvd
NeilBrown [Wed, 15 Jun 2011 05:49:23 +0000 (15:49 +1000)] 
ddf: fix up getinfo_super_bvd

Now that getinfo_super clears the info structure, we need
to make sure the correct values are filled in to info->dev.

Signed-off-by: NeilBrown <neilb@suse.de>
12 years agoRemove compiler warning about signed/unsigned comparison.
Albert Pauw [Wed, 15 Jun 2011 04:39:30 +0000 (14:39 +1000)] 
Remove compiler warning about signed/unsigned comparison.

Signed-off-by: NeilBrown <neilb@suse.de>
12 years agoFix imsm-overlap test.
NeilBrown [Wed, 15 Jun 2011 04:39:28 +0000 (14:39 +1000)] 
Fix imsm-overlap test.

Now that we reserve space for migration buffer devices are a little
bit smaller so we need to allow for that in the test suite.

Also add a 'udevadm settle' - it seems to help

Signed-off-by: NeilBrown <neilb@suse.de>
12 years agoIncr: fix breakage in count_active.
NeilBrown [Wed, 15 Jun 2011 02:21:26 +0000 (12:21 +1000)] 
Incr: fix breakage in count_active.

If the second device is much newer than the first, but has a lower
raid_disk number, we clear 'avail' badly and don't set up
'best' properly.

Fix these things.

Signed-off-by: NeilBrown <neilb@suse.de>
12 years agoimsm: Metadata Attributes compatibility support
Adam Kwolek [Tue, 14 Jun 2011 13:59:18 +0000 (15:59 +0200)] 
imsm: Metadata Attributes compatibility support

IMSM's meta data contains Attributes field that contains information about
supported features.
To assembly an array mdadm has to support all features specified by attributes.

The patch introduces new attributes support and validation of the attribuses
during an array assembly.

Signed-off-by: Adam Kwolek <adam.kwolek@intel.com>
Signed-off-by: Krzysztof Wojcik <krzysztof.wojcik@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
12 years agoimsm: FIX: Sometimes reshape cannot be finished
Adam Kwolek [Tue, 14 Jun 2011 23:13:49 +0000 (09:13 +1000)] 
imsm: FIX: Sometimes reshape cannot be finished

When array size is not aligned to copy area, number of migration unit
is increased in init_migr_record_imsm():7665 to reshape whole array.
During calculation of last migration unit, this should be in mind also,
otherwise checkpoint (max-1) is always written and reshape
is never finished in mdadm.

Signed-off-by: Adam Kwolek <adam.kwolek@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
12 years agoimsm: FIX: klocwork: passed dev pointer to is_gen_migration() can be NULL
Adam Kwolek [Tue, 14 Jun 2011 02:48:58 +0000 (12:48 +1000)] 
imsm: FIX: klocwork: passed dev pointer to is_gen_migration() can be NULL

Pointer dev2 passed in write_super_imsm():4451 can be equal to NULL.

Signed-off-by: Adam Kwolek <adam.kwolek@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
12 years agoimsm: Fix: klocwork: targets variable can be used uninitialized
Adam Kwolek [Tue, 14 Jun 2011 02:48:53 +0000 (12:48 +1000)] 
imsm: Fix: klocwork: targets variable can be used uninitialized

When target_offsets allocation fails execution goes to abort label,
where elements from targets table are closed.

Initialize targets table after allocation.

Signed-off-by: Adam Kwolek <adam.kwolek@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
12 years agoimsm: FIX: Migration Raid0->Raid5 cannot be restarted correctly
Adam Kwolek [Tue, 14 Jun 2011 02:46:53 +0000 (12:46 +1000)] 
imsm: FIX: Migration Raid0->Raid5 cannot be restarted correctly

When array raid0 is migrated to raid5, reshape cannot be continued
correctly due to wrong array parameters settings.
Raid disks number is set too big.

There is no need, during raid0->raid5 migration to increase
info->array.raid_disks, it is already set to final value using
designation map information.

Signed-off-by: Adam Kwolek <adam.kwolek@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
12 years agoimsm: FIX: Raid5 data corruption data recovering from backup
Adam Kwolek [Tue, 14 Jun 2011 02:42:22 +0000 (12:42 +1000)] 
imsm: FIX: Raid5 data corruption data recovering from backup

Sporadicaly when Raid5's data are restored from backup area,
corruption occurs.
It doesn't happen if reshape process is beyond critical section.

Root cause of the problem is passing wrong starting point in
restore_stripes(). It was hard coded to 0 so far.
This causes that parity disks position in first stripe was always set
to the last raid disk. This position should depend on data position in array.

Proper start position was set and pointer for restoring data
(copy area address) is adjusted to passed start parameter.

Signed-off-by: Adam Kwolek <adam.kwolek@intel.com>
Signed-off-by: Krzysztof Wojcik <krzysztof.wojcik@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
12 years agoimsm: FIX: Disable automatic metadata rollback for broken reshape
Adam Kwolek [Tue, 14 Jun 2011 02:42:16 +0000 (12:42 +1000)] 
imsm: FIX: Disable automatic metadata rollback for broken reshape

mdmon cannot rollback metadata changes automatically.
It can break reshape process in the way that in case of reshape break
user will not be able to deal with broken reshape due to lack of information
about reshape geometry.

mdadm (process that invokes reshape) doesn't make any rollback to allow
for user action. mdmon should not do this either unless it knows for sure
it is save. such knowledge is not available for automatic rollback.

Signed-off-by: Adam Kwolek <adam.kwolek@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
12 years agoimsm: FIX: Use function to obtain array layout
Adam Kwolek [Tue, 14 Jun 2011 02:42:08 +0000 (12:42 +1000)] 
imsm: FIX: Use function to obtain array layout

Function imsm_level_to_layout() should be use to get array layout.

Signed-off-by: Adam Kwolek <adam.kwolek@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
12 years agoFIX: Cannot create volume
Adam Kwolek [Tue, 14 Jun 2011 02:42:06 +0000 (12:42 +1000)] 
FIX: Cannot create volume

getinfo_super() can clear entire 'inf' structure before filling with new
information. Disk number required later is lost.

Restore disk number information after getinfo_super() call.

Signed-off-by: Adam Kwolek <adam.kwolek@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
12 years agoMAN: Man update for check-pointing
Adam Kwolek [Thu, 9 Jun 2011 03:00:56 +0000 (13:00 +1000)] 
MAN: Man update for check-pointing

Signed-off-by: Adam Kwolek <adam.kwolek@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
12 years agoimsm: Optimize expansion speed when no backup is required
Adam Kwolek [Thu, 9 Jun 2011 03:00:56 +0000 (13:00 +1000)] 
imsm: Optimize expansion speed when no backup is required

When no reshape backup is required (e.g. OLCE after critical section),
check-pointing can use bigger steps than backup space allows for.

Signed-off-by: Adam Kwolek <adam.kwolek@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
12 years agoimsm: FIX: Remove timeout from wait_for_reshape_imsm()
Adam Kwolek [Thu, 9 Jun 2011 03:00:55 +0000 (13:00 +1000)] 
imsm: FIX: Remove timeout from wait_for_reshape_imsm()

Timeout should not be used for select function in wait_for_reshape_imsm().

Signed-off-by: Adam Kwolek <adam.kwolek@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
12 years agoimsm: FIX: wait_for_reshape_imsm() cleanup
Adam Kwolek [Thu, 9 Jun 2011 03:00:55 +0000 (13:00 +1000)] 
imsm: FIX: wait_for_reshape_imsm() cleanup

This function needs to be corrected.
It should check sysfs operations status and it should not interpret
0 reshape position special meaning.

Unused input parameter is removed also.

Signed-off-by: Adam Kwolek <adam.kwolek@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
12 years agoimsm: FIX: Do not continue reshape when backup exists
Adam Kwolek [Thu, 9 Jun 2011 03:00:55 +0000 (13:00 +1000)] 
imsm: FIX: Do not continue reshape when backup exists

When backup exists in copy area reshape cannot be continued.
In such situation, array is in unstable state.

Signed-off-by: Adam Kwolek <adam.kwolek@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
12 years agoFIX: Move buffer to next location
Adam Kwolek [Thu, 9 Jun 2011 03:00:55 +0000 (13:00 +1000)] 
FIX: Move buffer to next location

When no output file is given save_stripes() should collect amount of stripes
in passed buffer. Currently all stripes are saved in the same area in passed
buffer. This causes that last stripe is returned on buffer begin only.
Increase buffer (buf) pointer when save_stripes() is about switch to next
stripe operation. This allows for proper buffer filling as input parameter
length directs.

Signed-off-by: Adam Kwolek <adam.kwolek@intel.com>
Signed-off-by: Krzysztof Wojcik <krzysztof.wojcik@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
12 years agoimsm: FIX: Remove unused variables and code
Adam Kwolek [Thu, 9 Jun 2011 03:00:55 +0000 (13:00 +1000)] 
imsm: FIX: Remove unused variables and code

Unused variables and code can be removed from imsm_manage_reshape()

Signed-off-by: Adam Kwolek <adam.kwolek@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
12 years agoimsm: FIX: Move reshape_progress forward
Adam Kwolek [Thu, 9 Jun 2011 03:00:55 +0000 (13:00 +1000)] 
imsm: FIX: Move reshape_progress forward

When array under reshape is assembled, reshape position used in sysfs_set_array()
should be set to position after recovered from backup area.
This avoids data corruption due to reshape the same array area again.

Signed-off-by: Adam Kwolek <adam.kwolek@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
12 years agoimsm: FIX: Detect failed devices during recover_backup_imsm()
Adam Kwolek [Thu, 9 Jun 2011 03:00:55 +0000 (13:00 +1000)] 
imsm: FIX: Detect failed devices during recover_backup_imsm()

Detect in recover_backup_imsm() if not opened disks number is smaller
than allowed degradation for given raid level. This allows for reshape restart
on degraded array.

Signed-off-by: Adam Kwolek <adam.kwolek@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
12 years agoimsm: FIX: Use metadata information for restore_stripes() and save_stripes()
Adam Kwolek [Thu, 9 Jun 2011 03:00:55 +0000 (13:00 +1000)] 
imsm: FIX: Use metadata information for restore_stripes() and save_stripes()

For raid0 reshape imsm uses degraded raid4 for this operation.
Using real raid level (raid0) for stripe calculation causes no need
for parity calculation and can speed up reshape process.

Signed-off-by: Adam Kwolek <adam.kwolek@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
12 years agoimsm: FIX: Remove unused parameter from save_backup_imsm() interface
Adam Kwolek [Thu, 9 Jun 2011 03:00:55 +0000 (13:00 +1000)] 
imsm: FIX: Remove unused parameter from save_backup_imsm() interface

new_data parameter is not used in save_backup_imsm().
It is removed from function interface.

Signed-off-by: Adam Kwolek <adam.kwolek@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
12 years agoimsm: FIX: Do not use pba_of_lba0 for copy position calculation
Adam Kwolek [Thu, 9 Jun 2011 03:00:55 +0000 (13:00 +1000)] 
imsm: FIX: Do not use pba_of_lba0 for copy position calculation

imsm_manage_reshape() should not shift start copy position.
This offset is passed to manage reshape function /and it is used/
as input parameter in offsets table already.

Signed-off-by: Adam Kwolek <adam.kwolek@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
12 years agoimsm: FIX: Do not verify unused parameters
Adam Kwolek [Thu, 9 Jun 2011 03:00:55 +0000 (13:00 +1000)] 
imsm: FIX: Do not verify unused parameters

Parameters that are not used by imsm_manage_reshape() should not cause
failure of this function.

Signed-off-by: Adam Kwolek <adam.kwolek@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
12 years agoimsm: FIX: Calculate backup location based on metadata information
Adam Kwolek [Thu, 9 Jun 2011 03:00:55 +0000 (13:00 +1000)] 
imsm: FIX: Calculate backup location based on metadata information

Use metadata information to calculate backup write offset.

Signed-off-by: Adam Kwolek <adam.kwolek@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
12 years agoimsm: FIX: Use macros to data access
Adam Kwolek [Thu, 9 Jun 2011 03:00:55 +0000 (13:00 +1000)] 
imsm: FIX: Use macros to data access

Metadata fields has to be accessed using proper macros.

Signed-off-by: Adam Kwolek <adam.kwolek@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
12 years agoimsm: FIX: Check layout for level migration
Adam Kwolek [Thu, 9 Jun 2011 03:00:55 +0000 (13:00 +1000)] 
imsm: FIX: Check layout for level migration

When user doesn't specify raid 5 layout for raid0->rai5 migration,
layout structure member is uninitialized. Earlier it cannot be determined
if it is correct or not.
In metadata handle proper verification is placed.

Signed-off-by: Adam Kwolek <adam.kwolek@intel.com>
Signed-off-by: Krzysztof Wojcik <krzysztof.wojcik@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
12 years agoimsm: FIX: Max position could not be rounded to MB
Adam Kwolek [Thu, 9 Jun 2011 03:00:55 +0000 (13:00 +1000)] 
imsm: FIX: Max position could not be rounded to MB

When rounded array size information from metadata is used for number
of migration units calculation it can occurs that result of units
can be smaller (-1) than required due to used (rounded) array size).

Signed-off-by: Adam Kwolek <adam.kwolek@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
12 years agoimsm: FIX: Detect migration end during migration record saving
Adam Kwolek [Thu, 9 Jun 2011 03:00:55 +0000 (13:00 +1000)] 
imsm: FIX: Detect migration end during migration record saving

Checkpoint should be saved when migration is in progress only.
End of reshape (based on passes status) should be detected and it should
not cause abort of reshape/check-pointing/ operation.

Signed-off-by: Adam Kwolek <adam.kwolek@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
12 years agoimsm: FIX: Verify if migration record is loaded correctly
Adam Kwolek [Thu, 9 Jun 2011 03:00:54 +0000 (13:00 +1000)] 
imsm: FIX: Verify if migration record is loaded correctly

Migration compatibility can be checked when general migration record
is present.

Signed-off-by: Adam Kwolek <adam.kwolek@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
12 years agoimsm: FIX: Opened handle is not closed
Adam Kwolek [Thu, 9 Jun 2011 03:00:54 +0000 (13:00 +1000)] 
imsm: FIX: Opened handle is not closed

Opened file handle should be closed before function exit.

Signed-off-by: Adam Kwolek <adam.kwolek@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
12 years agorestripe: fix compile error in stand-alone program.
NeilBrown [Thu, 9 Jun 2011 03:00:46 +0000 (13:00 +1000)] 
restripe: fix compile error in stand-alone program.

Signed-off-by: NeilBrown <neilb@suse.de>
12 years agoFix some fall-out from recent memset-zero for getinfo_super
NeilBrown [Thu, 9 Jun 2011 02:42:02 +0000 (12:42 +1000)] 
Fix some fall-out from recent memset-zero for getinfo_super

container_content_imsm was setting info->next before calling
getinfo_super_imsm_container which now zeros everything.
So move that assignment to afterwards.

So both imsm and ddf were assuming info->disk.raid_disk means
something but it doesn't.  So fix those.

Signed-off-by: NeilBrown <neilb@suse.de>
12 years agoimsm: Unit Tests - remove backup-file during grow command
Adam Kwolek [Wed, 8 Jun 2011 07:15:04 +0000 (17:15 +1000)] 
imsm: Unit Tests - remove backup-file during grow command

Update reshape/migration unit tests to not to use backup file.
Imsm native check-pointing has to be used (internally) instead.

Signed-off-by: Krzysztof Wojcik <krzysztof.wojcik@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
12 years agoimsm: Remove user warning before reshape start
Adam Kwolek [Wed, 8 Jun 2011 07:14:33 +0000 (17:14 +1000)] 
imsm: Remove user warning before reshape start

imsm's arrays supports imsm native check-pointing now.
User warning is no longer required.

Signed-off-by: Adam Kwolek <adam.kwolek@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
12 years agoDo not use backup file for external metadata
Adam Kwolek [Wed, 8 Jun 2011 07:13:30 +0000 (17:13 +1000)] 
Do not use backup file for external metadata

When external metatdata handler supports manage_reshape()
and recover_backup() functions in super switch backup file is not required
and can be omitted. For backup purposes metadata specific mechanisms
are used.

Signed-off-by: Adam Kwolek <adam.kwolek@intel.com>
Signed-off-by: Krzysztof Wojcik <krzysztof.wojcik@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
12 years agoFIX: Enable metadata updates for raid0
Adam Kwolek [Wed, 8 Jun 2011 07:13:26 +0000 (17:13 +1000)] 
FIX: Enable metadata updates for raid0

When raid0 is takeovered to degraded raid4, metadata updates has to be
applied via mdmon (raid4 has to be monitored).
It is not possible due to no update_tail pointer initialization
in supertype structure.

Signed-off-by: Adam Kwolek <adam.kwolek@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
12 years agoimsm: Apply checkpoint metadata update for general migration
Adam Kwolek [Wed, 8 Jun 2011 07:13:21 +0000 (17:13 +1000)] 
imsm: Apply checkpoint metadata update for general migration

mdmon has to update checkpoint information in metadata during
general migration according to received metadata update.

Signed-off-by: Adam Kwolek <adam.kwolek@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
12 years agoimsm: Prepare checkpoint update for general migration
Adam Kwolek [Wed, 8 Jun 2011 07:12:48 +0000 (17:12 +1000)] 
imsm: Prepare checkpoint update for general migration

mdadm has to prepare checkpoint information update and send it to mdmon.

Signed-off-by: Adam Kwolek <adam.kwolek@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
12 years agoimsm: Add metadata update type for general migration check-pointing
Adam Kwolek [Wed, 8 Jun 2011 07:12:39 +0000 (17:12 +1000)] 
imsm: Add metadata update type for general migration check-pointing

There are 2 places for keeping checkpoint information:
- metadata (per volume information used during volume
  initialization and rebuilding).
- migration record (per container information used during
  migration/reshape)

During reshape both checkpoints has to contains the same information.
To do this mdadm will send metadta update with checkpoint information.

Note: Checkpoint information consistence is not critical. During general
      migration restart, information from migration record is used only.

Signed-off-by: Adam Kwolek <adam.kwolek@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
12 years agoimsm: Disable checkpoint updating by mdmon for general migration
Adam Kwolek [Wed, 8 Jun 2011 07:11:49 +0000 (17:11 +1000)] 
imsm: Disable checkpoint updating by mdmon for general migration

imsm contains 2 check-pointing mechanism. One (per array) is used for
initialization and rebuild and second (per container) is used for general
migration (reshape). First is controlled by mdmon, second by mdadm.
To avoid conflicts disable mdmon checkpoints updating for general
migration.

Signed-off-by: Adam Kwolek <adam.kwolek@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
12 years agoimsm: Implement recover_backup_imsm() for imsm metadata
Adam Kwolek [Wed, 8 Jun 2011 07:11:23 +0000 (17:11 +1000)] 
imsm: Implement recover_backup_imsm() for imsm metadata

Add ability to restore data backed up in General Migration Copy Area
in case of unexpected reshape interruption.
Function restores data during an array assembly and then reshape
is continues from next checkpoint.

Signed-off-by: Krzysztof Wojcik <krzysztof.wojcik@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
12 years agoAdd reshape restart support for external metadata
Adam Kwolek [Wed, 8 Jun 2011 07:11:11 +0000 (17:11 +1000)] 
Add reshape restart support for external metadata

Patch introduces support for reshape process restart for external metadata
using metadata specific data handling methods.
It introduces recover_backup() function that restores array to stable state
It is equivalent to Grow_restart() functionality for native metadata.

Signed-off-by: Maciej Trela <maciej.trela@intel.com>
Signed-off-by: Adam Kwolek <adam.kwolek@intel.com>
Signed-off-by: Krzysztof Wojcik <krzysztof.wojcik@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
12 years agoimsm: update blocks_per_migr_unit() to support migration record
Adam Kwolek [Wed, 8 Jun 2011 07:09:50 +0000 (17:09 +1000)] 
imsm: update blocks_per_migr_unit() to support migration record

blocks_per_migr_unit() has to use information from migration record
for general migration case. This causes to pass intel_super pointer
to this function and some other interfaces changes.

Signed-off-by: Adam Kwolek <adam.kwolek@intel.com>
Signed-off-by: Krzysztof Wojcik <krzysztof.wojcik@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
12 years agoimsm: Add information about migration record to mdadm '-E' option
Adam Kwolek [Wed, 8 Jun 2011 07:09:29 +0000 (17:09 +1000)] 
imsm: Add information about migration record to mdadm '-E' option

Add ability to display information from migration record in examine
option.

Signed-off-by: Adam Kwolek <adam.kwolek@intel.com>
Signed-off-by: Krzysztof Wojcik <krzysztof.wojcik@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
12 years agoimsm: Clear migration record when no migration in progress
Adam Kwolek [Wed, 8 Jun 2011 07:09:16 +0000 (17:09 +1000)] 
imsm: Clear migration record when no migration in progress

When metadata is saved and there is no general migration in progress
/in container/ clear migration record in container.

Signed-off-by: Adam Kwolek <adam.kwolek@intel.com>
Signed-off-by: Krzysztof Wojcik <krzysztof.wojcik@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
12 years agoimsm: Check if array degradation has been changed
Adam Kwolek [Wed, 8 Jun 2011 07:09:09 +0000 (17:09 +1000)] 
imsm: Check if array degradation has been changed

Before reshaping every "migration unit", check if array is still usable.
In failed disks number is greater than allowed degradation level, reshape
has to be aborted.

Signed-off-by: Maciej Trela <maciej.trela@intel.com>
Signed-off-by: Adam Kwolek <adam.kwolek@intel.com>
Signed-off-by: Krzysztof Wojcik <krzysztof.wojcik@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
12 years agoimsm: Implement imsm_manage_reshape(), reshape workhorse
Adam Kwolek [Wed, 8 Jun 2011 07:09:08 +0000 (17:09 +1000)] 
imsm: Implement imsm_manage_reshape(), reshape workhorse

Before reshape is started, mdadm should check again if there is only one
array (in container) under reshape. Then function "divides" array in to
"migration units" that can fits migration copy area and enters main loop.
It checks if current "migration unit" requires to be backed up.
If necessary mdadm saves it to copy area and updates migration record.
Then MD-driver is directed to perform reshape step (by "migration unit" size)
and checkpoint is moved forward. In this way reshape is executed until
array ends.

Signed-off-by: Adam Kwolek <adam.kwolek@intel.com>
Signed-off-by: Krzysztof Wojcik <krzysztof.wojcik@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>