Commit Graph

201 Commits

Author SHA1 Message Date
NeilBrown 1799c9e8f8 super-intel: Fix compilation of mdassemble.
Signed-off-by: NeilBrown <neilb@suse.de>
2009-10-20 13:50:23 +11:00
Dan Williams 6e46bf344b imsm: add --update=uuid support
When disks have conflicting container memberships (same container ids
but incompatible member arrays) --update=uuid can be used to move
offenders to a new container id by changing 'orig_family_num'.

Note that this only supports random updates of the uuid as the actual
uuid is synthesized.  We also need to communicate the new
'orig_family_num' value to all disks involved in the update.  A new
field 'update_private' is added to struct mdinfo to allow this
information to be transmitted.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2009-10-13 17:41:53 -07:00
Dan Williams e683ca88ac imsm: fix/support --update
Fix init_super_imsm() to return an empty mpb when info == NULL, and
teach store_super_imsm() to simply write out the passed in mpb.

Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=523320

Reported-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2009-10-13 17:41:53 -07:00
Dan Williams f796af5d5e imsm: fix spare record writeout race
imsm_activate_spare() in the manager thread may race against
write_super_imsm_spares() in the monitor thread.  Give
write_super_imsm_spares() its own private mpb buffer to prevent
confusing the manager.

This change uncovered cases where spares were not being assembled due to
a failed metadata version number check.  Spares can freely associate
across metadata version number, so reduce the scope of the version check
in the spare assembly case.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2009-10-13 17:41:53 -07:00
Dan Williams a2b9798159 imsm: disambiguate family_num
This is a result of trawling through the Windows implementation to learn
the mechanism of how it disambiguates family_num.  It is a continuation
of commit 148acb7b "imsm: fix family number handling" which introduced a
regression when reassembling a container with stale disks and rebuilt
members.

When rebuilding, a new family number is assigned to protect against the
"prodigal array member" problem.  It prevents a former family member
from returning to the system and causing a rebuild to go the wrong
direction.  However, this invalidates looking at the generation number to
determine the most up-to-date disk when comparing across family numbers.
Instead the assembly logic looks for agreement between a disk's local
family membership compared against a global list of all families in the
system.  Whenever a disk's local metadata does not match a family number
on the global list that family number is marked offline.

It is possible that this logic results in multiple incompatible but
valid family numbers existing in a container.  In this case mdadm.conf
cannot be consulted because it only records the uuid which is generated
from static fields in the metadata.  The metadata lacks the data needed
to disambiguate "local" versus "foreign".  The "foreign" array in this
case requires updating to change its container-id information
(orig_family_num), and possibly the member array names.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2009-09-30 11:45:41 -07:00
Dan Williams 51725a7c25 imsm: kill close() of component device
None of the other formats close the passed in fd at load, and this
becomes a problem when trying to support --update where we need O_EXCL
protection across the entire operation.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2009-09-30 11:44:38 -07:00
Dan Williams 25ed7e5924 imsm: cleanup disk status tests
Add is_failed(), is_configured(), and is_spare() helpers to clean up
disk status flag testing.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2009-09-28 14:40:59 -07:00
Dan Williams cf53434e5c imsm: clear CONFIGURED_DISK for failed drives
Synchronizing with what the Windows driver does.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2009-09-15 11:35:28 -07:00
Dan Williams ee5aad5ae2 imsm: kill USABLE_DISK flag
'USABLE_DISK' is not a 'persistent' status flag it is an internal status
flag used for the in memory representation of the disk in the Windows
driver.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2009-09-15 11:35:28 -07:00
Dan Williams 709743c554 imsm: fix spare promotion
1/ Fix an off by one error when detecting whether the device allocation
   loop succeeded or not
2/ Update ->num_raid_devs before copying to avoid a segmentation fault

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2009-09-15 11:34:20 -07:00
NeilBrown 4737ae25de Exmaine/brief: put member arrays after container arrays.
A previous patch moved move the '--examine --brief' reporting of
member arrays to before their containers.  This breaks "mdadm -As"
assembly.  So put them back, but still fix the problem addressed by
previous patch.

Signed-off-by: NeilBrown <neilb@suse.de>
2009-08-07 14:17:40 +10:00
Dan Williams 7e8545e954 imsm: fix spare-uuid assignment
imsm spares do not have container membership by default so we associate
them with the first container found in the configuration file.  Some
ARRAY lines do not specify the metadata type so we cannot assume that
_cst will always be valid.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2009-07-31 17:11:42 -07:00
Dan Williams 148acb7baa imsm: fix family number handling
The family_number field can change.  The option-rom will change the
family number when it starts a rebuild process (flags a container for
rebuild).  This was not seen previously as mdadm would usually start the
rebuild process, preserving the family number.

This is the mechanism that helps to prevent a prodigal array member from
being returned to its original system and cause a rebuild to go in the
wrong direction.  With the change we will end up with a container that
will fail to assemble unless the device with the incompatible family
number is left out of the assembly.

So, take several actions:
1/ Convert uuid generation to use orig_family_num, being careful to
   preserve the existing uuid in the case where orig_family_num is not
   set (i.e. previous mdadm created imsm arrays)
2/ Set orig_family_num at Create.  For arrays created by mdadm prior to
   this release orig_family_num will be zero, so set it to family_num at
   the first metadata write.
3/ Add checks for orig_family_num to compare_super_imsm
4/ Update the family number when initiating rebuild
5/ The option-rom mixes some random data into the family number, add
   this functionality to the mdadm implementation.

Reported-by: Marcin Labun <marcin.labun@intel.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2009-07-31 17:11:41 -07:00
Dan Williams 329c827869 imsm: fix activate_spare off-by-one
The last sector of an array is calculated by start + size - 1.

Reported-by: Rafal Marszewski <rafal.marszewski@intel.com>
Reported-by: Jarema Bielanski <jarema.bielanski@intel.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2009-07-31 17:11:41 -07:00
Dan Williams 9b1fb67776 conditionally update uuids in the map file after Create()
The map file needs to be updated after adding the first member array to
an Intel metadata container.  The uuid for an imsm container uses the
->family_num field of the metadata.  This field is static, but is only
set after the first member array has been created.  Prior to this all
devices are free floating spares and do not have any information that
can identify specific container membership.  At Create() time we take
the uninitialized uuid from ->get_info_super() prior to updating the
metadata.  So the current result is:

# mdadm --create /dev/md/imsm /dev/sd[b-e] -n 4 -e imsm
# mdadm --create /dev/md/vol0 /dev/md/imsm -n 4 -l 0
# cat /var/run/mdadm/map
md126 /md127/0 3e03aee2:78c3c593:1e8ecaf0:eefb53ed /dev/md/vol0
md127 imsm 53d6f8b1:7a783f24:f30483c5:705c48c7 /dev/md/imsm
# mdadm -Ebs
ARRAY metadata=imsm UUID=589d2d2c:4221a54d:acb63c06:c3907f52
ARRAY /dev/md/vol0 container=589d2d2c:4221a54d:acb63c06:c3907f52
	member=0 UUID=57b89b63:5cd0eae1:17dd26b3:51cc78d4

So, before we write out the new metadata check to see if the member
array uuid has changed as a result of this addition.  If it has, update
its uuid in the map file and flag its parent container for updating.  In
support of updating the container uuid the semantics of
->write_init_super are changed to clear any metadata specific member
array cursors (e.g. ddf_super.currentconf or intel_super.current_vol)
such that a subsequent call to ->getinfo_super returns container
information.

Reported-by: Ignacy Kasperowicz <ignacy.kasperowicz@intel.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2009-07-31 17:11:41 -07:00
Dan Williams 0d5a423fe7 imsm: fixup examine_brief to be more descriptive in the container only case
Prior to creating any arrays in a new container the output from -Ebs for
a 4-disk imsm array returns:

		spares=4

We should at least display that these are imsm spares:

	ARRAY metadata=imsm
		spares=4

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2009-07-31 17:11:41 -07:00
Dan Williams 37424f132c fix examine_brief segfault
When performing an "-Ebs -e <metadata type>" we segfault because the
superblock has been freed too early.  We also leak memory for 'ddf' and
'imsm' because, unlike super[01], we do not implicitly free when
->load_super is called on an already loaded supertype.

So, fix up imsm and ddf to match type 0 and 1 ->load_super() semantics,
and update Examine to not free the superblock until all usages have been
exhausted.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2009-07-31 17:11:41 -07:00
Dan Williams af99d9ca67 teach imsm and ddf what st->subarray means at load_super time
RebuildMap wants to poll through mdstat and retrieve a (kernel name,
uuid, user name) tuple for each array.  Teach imsm and ddf to honor
st->sub_array at ->load_super() time to set their internal subarray
pointers to the value specified in st->subarray, or return an error if
st->subarray specifies an invalid array.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2009-07-31 17:08:22 -07:00
NeilBrown fa09d4961e Examine: fix --examine --brief --verbose on containers.
With --verbose, --examine --brief prints dev= information after
the personality has done its bit.
But with containers, the member array are printed in between.
So in super-ddf and super-intel, move printing of the member
arrays to before printing of the container.  This avoids
confusion.

Signed-off-by: NeilBrown <neilb@suse.de>
2009-06-04 12:44:32 +10:00
NeilBrown 4291d691b6 super-intel: fix test on failed_disk_num.
We sometimes set failed_disk_num to ~0.
However we cannot test for equality with that as  failed_disk_num
is 8bit and ~0 is probably 32bit with lots of 1's.
So test if ~failed_disk_num is 0 instead.

Reported-By: "Mr. James W. Laferriere" <babydr@baby-dragons.com>
Signed-off-by: NeilBrown <neilb@suse.de>
2009-06-04 12:29:21 +10:00
Dan Williams 1124b3cf29 imsm: kill "auto=" in brief_examine_super_imsm
The auto parameter is obsolete after kernel version 2.6.28 as all arrays
are partitionable via block device extended minor support.  Environments
that requre the mdp style of array can always edit the configuration
file to specify auto=mdp.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2009-05-18 10:02:58 -07:00
Dan Williams 81062a36ab imsm: fix num_domains
The 'num_domains' field simply identifies the number of mirrors.  So it
is 2 for a 2-disk raid1 or a 4-disk raid10.  The orom does not currently
support more than 2 mirrors, but a three disk raid1 for example would
increase num_domains to 3.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2009-05-18 09:58:55 -07:00
NeilBrown 13a3b65d54 Fix printf compile warning.
It always afters to cast big things to (unsigned long long) before
printing as %llu - it seems there will always be one arch which
has something to complain about ....

Signed-off-by: NeilBrown <neilb@suse.de>
2009-05-11 15:47:10 +10:00
NeilBrown 061f2c6abd Make --brief even briefer.
Because ---examine --brief, or --detail --brief are
often used to create mdadm.conf, and because people don't want to
have to update their mdadm.conf unnecessarily, we don't want to
include information that might change.
And now that level changing is supported, that is almost everything
but UUID.

So move some more fields into the "Only print with --verbose" class.

Signed-off-by: NeilBrown <neilb@suse.de>
2009-05-11 15:18:20 +10:00
Dan Williams 252d23c018 imsm: add the ddf field
This field is always one in arrays created by the Windows driver / OROM,
not sure why...

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2009-04-12 00:58:28 -07:00
Dan Williams 979d38be50 imsm: round down array size at Create
Store the 1MB rounded down size of the array at create time.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2009-04-12 00:58:28 -07:00
Dan Williams da9b4a62af imsm: set array size at Create/Assemble
imsm arrays round down the effective array size to the closest 1
megabyte boundary so teach get_info_super_imsm and sysfs_set_array to
set 'md/array_size' if available (and make sure ddf uses the default
size).

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2009-04-12 00:58:28 -07:00
Dan Williams da18878954 imsm: turn off curr_migr_unit updates
New documentation shows that this field is not equivalent to
md/resync_start.  Disable updates until full support can be developed.

Writing '0' when a migration starts/re-starts remains correct.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2009-04-12 00:58:28 -07:00
Dan Williams 1ce0101c9a imsm: defend against unsupported migrations (temporary)
Until support for higher order migrations (online capacity expansion,
raid level migration, chunk size migration...) are implemented do not
allow arrays in these states to be assembled.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2009-04-12 00:58:28 -07:00
Dan Williams 1484e72797 imsm: add 'verify', 'verify with fixup', and 'general' migration types
imsm distinguishes parity initialization from parity checking in the
metadata. Older option roms marked the repair operation with the
'verify' type and a 'with fixup' flag in the raid device 'status' field.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2009-04-12 00:58:27 -07:00
Dan Williams ff5963088d imsm: fix imsm_map.num_domains
'num_domains' is the number of parity domains.  I.e. 2 in the raid10
case (2-mirrors), while raid0 through raid5 have 1 parity domain (even
though raid0 does not have parity).

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2009-04-12 00:58:27 -07:00
Dan Williams 1f45a8ad20 imsm: ensure mpb buffer is zeroed
Don't leak unitialized data into the mpb.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2009-04-12 00:58:27 -07:00
Dan Williams 9d84c8eac2 imsm: support --examine --export
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2009-04-11 21:53:25 -07:00
Dan Williams ae2bfd4e13 imsm: make uuid separator consistent with ddf
'-' to ':'

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2009-04-11 21:53:25 -07:00
Dan Williams 316e2bf426 imsm: extract right-most whitespace stripped serial number
According to new documentation the metadata expects that all whitespace
(characters <= 0x20) are stripped from the incoming serial number.  If
the length remains longer than MAX_RAID_SERIAL_LEN then only the
right-most characters are preserved.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2009-04-08 11:41:51 -07:00
NeilBrown b9d77223eb Release mdadm-3.0-devel3 2009-03-10 16:59:57 +11:00
Dan Williams 8be094f0ee imsm: display supported chunk sizes in --detail-platform
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2009-02-27 15:35:20 -07:00
Dan Williams efb30e7f1e imsm: auto layout
In support of auto-layout:

1/ collect and merge all extents to find the largest common-start free region
2/ verify that we meet the "all volumes must use the same set of disks"
2/ mark the disks to be added in add_to_super_imsm_volume

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2009-02-24 18:45:57 -07:00
Dan Williams dab4a5134e sysfs: allow sysfs_read to detect and drop removed disks
All operations that rely on loading from an existing container (like
--add) will fail after a disk has been removed.  Provide an option to
skip missing / offline disks rather than abort.  We attempt to do this
in the load_super_{imsm,ddf}_all cases when mdmon is running i.e. we
already have a consitent version of the metadata running in the system.
Otherwise, we fail as normal and let the administrator fix up the
container.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2009-02-24 18:45:56 -07:00
Dan Williams db575f3b9e imsm: retry load_imsm_mpb if we suspect mdmon has made modifications
If the checksum verification fails and mdmon is running we retry the
load to get a consistent snapshot of the mpb.  Found by
tests/08imsm-overlap.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2009-02-24 18:45:56 -07:00
Dan Williams ecf45690f2 imsm: verify single sector mpb checksums
If the mpb is only one sector do not skip the checksum verification.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2009-02-24 18:45:56 -07:00
Dan Williams 0556e1a2b1 imsm: fix mark_failure / introduce mark_missing
Actually, rename mark_failure to mark_missing and then implement the
correct mark_failure which according to new documentation is to:

1/ Set the FAILED status bit
2/ Set IMSM_ORD_REBUILD to mark the disk out of sync
3/ Set map->failed_disk_num if this is the first failure detected
   failure (it is ~0 otherwise)

Previously the assumption was that IMSM_ORD_REBUILD only appeared in
map[1], so all routines that care about out-of-sync disks need to be
updated.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2009-02-24 18:45:56 -07:00
Dan Williams 620b171338 imsm: introduce get_imsm_disk_slot
Implement a common disk index to disk slot routine and replace open
coded versions.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2009-02-24 18:45:56 -07:00
Dan Williams df4746577e imsm: fix activate spare to ignore foreign disks
A foreign disk is one that all other drives believe is not-in-sync but
does not have the 'failed' status bit set.

This also reverts, because that commit is addressing the wrong problem.
Ideally mdmon would kick "non-fresh" drives like the kernel does at
native-md activation time, but that is too awkward to implement at the
moment because mdadm owns container manipulations.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2009-02-23 23:06:24 -07:00
Dan Williams 7a70e8aa8d imsm: fixup container spare uuids by default
Spares in the imsm case are marked with the "match-all" uuid of
ffffffff-ffffffff-ffffffff-ffffffff.  When performing incremental
assembly we need to associate such devices with a populated container
uuid.  Also when performing --detail on a container with only spares
present we can make an attempt to return a real uuid.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2009-02-23 23:06:24 -07:00
Dan Williams 689c9bf3c3 imsm: fix missing initializations of the per-disk extents pointer
Fixes a glibc assertion when trying to free a pointer that was not
malloc'd.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2009-02-23 23:06:24 -07:00
Dan Williams cceebc67f1 imsm: provide a simulated option-rom for regression tests
IMSM_NO_PLATFORM turns off checks that should be tested, so provide a
IMSM_TEST_OROM variable to allow testing the orom constraints in the
mdadm regression suite.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2009-02-23 14:26:10 -07:00
Dan Williams 5a03814040 imsm: block creation of devices with identical names
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2009-02-02 15:01:13 -07:00
Dan Williams 78757ce8a5 imsm: don't check raid1 chunk size
mdadm -C /dev/md/r1d2n1s0-5 -amd -l1  --size 5242880 -n 2 /dev/sdb /dev/sdc  -R -f -v -c 64
mdadm: chunk size ignored for this level
mdadm: super0.90 cannot open /dev/sdb: Device or resource busy
mdadm: super1.x cannot open /dev/sdb: Device or resource busy
mdadm: platform does not support a chunk size of: 0
mdadm: device /dev/sdb not suitable for any style of array

Reported-by: Krzysztof Wojcik <krzysztof.wojcik@intel.com>
Tested-by: Jacek Danecki <jacek.danecki@intel.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2009-02-02 10:55:31 -07:00
Dan Williams caf8d23175 imsm: fix failed disks are allowed back into the container
Failed disks do not have valid serial numbers which means we will not
pick up the 'failed' status bit from the metadata entry.  Check for
dl->index == -2 to prevent failed disks from being incorporated into the
container.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2009-01-23 15:45:34 -07:00