Commit Graph

658 Commits

Author SHA1 Message Date
NeilBrown 3c558363a1 Factor out test for subarray version string.
We are about to change the syntax of the version string
for 'subarray's.  So factor out the test into a single function.

Signed-off-by: NeilBrown <neilb@suse.de>
2008-08-19 17:55:15 +10:00
Dan Williams 6c386dd368 imsm: allow container assembly in the presence of failed disks
For example, this allows one to still say mdadm -A /dev/sd[b-e] even
though /dev/sde has replaced /dev/sdd.  Otherwise mdadm will say:

	mdadm: superblock on /dev/sdd doesn't match others - assembly aborted

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2008-08-19 17:55:15 +10:00
NeilBrown 567df5fd0a Fix bug with ddf if devices have different sizes.
We cannot use the header of the 'best' device to find the
sections on the other devices!!


Signed-off-by: NeilBrown <neilb@suse.de>
2008-08-19 17:55:15 +10:00
NeilBrown 2cc2983d80 Provide ddf support for adding a device to an active container.
Signed-off-by: NeilBrown <neilb@suse.de>
2008-08-19 17:55:15 +10:00
Dan Williams 43dad3d6fb mdadm: add device to a container
Adding a device updates the container and then mdmon takes action upon
noticing a change in devices.  This reuses the container version of
add_to_super to create a new record for the device.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
2008-08-19 17:19:51 +10:00
Dan Williams 7bc1962f8c mdmon: remove devices from container
Once the monitor thread has kicked a drive from all managed arrays mdadm
-r is permitted.  We are guaranteed that the drive is marked failed at
this point, so allow the drive to be re-added as a spare.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2008-08-19 14:55:12 +10:00
Dan Williams ae6aad8239 imsm: delete kicked disks
When we have determined that a disk is no longer of any value, remove
it from the data structure.   This is now safe because the manager
will back off while any metadata update is pending in the monitor.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
2008-08-19 14:55:10 +10:00
NeilBrown 0b5ec75e01 Fix mdstat_wait_fd
It didn't necessarily wait for the fd.

Signed-off-by: NeilBrown <neilb@suse.de>
2008-08-19 14:55:07 +10:00
NeilBrown 3c00ffbe98 Make metadata updates from manage to monitor 'synchronous'
A metadata update may modify the data structure of the metadata
including freeing things, so it is not safe of the manager to touch
the metadata while an update is pending in the monitor.
So When an update has been submitted, don't do anything else in the
manager until it is complete.

Signed-off-by: NeilBrown <neilb@suse.de>
2008-08-19 14:55:03 +10:00
NeilBrown 01f157d74a Extra option for set_array_state: you choose dirty or clean.
When we first start an array, it might be good to start recovery
straight away.  That requires setting the array to 'dirty', but
only the metadata handler can know if that is required or not.
So have a third possible 'consistent' option to set_array_state.
Either 'no' or 'yes' or 'you choose'.

Return value indicates what was chosen.

'1' (no) should be chosen unless there is a good reason.

Signed-off-by: NeilBrown <neilb@suse.de>
2008-08-19 14:54:55 +10:00
Dan Williams 9296754385 mdmon: handle failures versus readauto arrays
Transition readauto arrays to active before failing drives.

Hmm... why do we keep reblocking / renotifying in the readonly case?
Need to bottom out on this, but not right now.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2008-08-15 10:58:43 -07:00
Dan Williams f1d267661d mdmon: allow degraded arrays to be monitored
manage_new is too strict in the face of failed devices.  Teach it to
monitor degraded arrays.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2008-08-15 10:58:43 -07:00
Dan Williams fcb844757f imsm: include not synced disks in imsm_count_failed
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2008-08-15 10:58:42 -07:00
Dan Williams 7eef045331 imsm: use disk_ord_tbl to identify rebuilding disks
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2008-08-15 10:57:19 -07:00
Dan Williams 9a1608e5d0 imsm: fix up assembly of disks that are not in-sync
1/ Do not assemble !in_sync or failed devices in container_content.
2/ Prevent activation of failed or configured devices in activate_spare.
3/ Be sure to avoid dirty degraded if the array was shutdown cleanly.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2008-08-12 02:25:49 -07:00
Dan Williams 6a3e913ee9 imsm: fix create by mdmon-update
imsm_dev dynamically grows, so dev_idx needs to be moved up in the
definition to avoid getting clobbered.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2008-08-12 02:25:49 -07:00
Dan Williams e74255d907 imsm: write_super return 0 on success
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2008-08-12 02:25:49 -07:00
Dan Williams a48ac0a8d6 imsm: update mpb_size in write_super_imsm
With dev->vol.map and mpb->disk entries entering and leaving the parameter
block write_super_imsm needs to update the size before writeback.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2008-08-12 02:25:49 -07:00
Dan Williams 272906ef49 mdmon: use activate spare for re-add
Disks that are not in-sync or failed are not assembled into member
arrays by mdadm.  Teach mdmon to resolve this situation by checking for
spares at start.  imsm_activate_spare() is updated to prefer devices
that can be re-added versus new spares.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2008-08-12 02:25:46 -07:00
Dan Williams 3393c6af8b imsm: fix handling of the 'migr_state' and 'migr_type' bits
The option-rom and the Matrix driver mark resyncs/rebuilds with the
migrate state bits.  Update sizeof_imsm_dev to allow allocation of
imsm_dev entries large enough to grow if migr_state is later set.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2008-08-12 02:05:20 -07:00
Dan Williams a965f303c7 imsm: add get_imsm_map and sizeof_imsm_map
retrieve map entries from a imsm_dev, and cleanup imsm_copy_dev

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2008-08-11 01:16:24 -07:00
Dan Williams 828408ebef imsm: drop 'external' from imsm_examine_brief
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2008-08-11 01:16:24 -07:00
Dan Williams 19859edc2d imsm: ensure 'usable' remains clear until the disk is in_sync
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2008-08-11 01:16:24 -07:00
Dan Williams d23fe9472d imsm: spare devices are represented as single disk containers
This poses a small problem for the case of handling multiple raid1 arrays
across separate disk pairs i.e. 2 mirrors on 4 disks.  The option-ROM will
configure this as two containers.  We may need the capability for one
container to ask for an unused spare in another container.  For now spares
will just maintain the affinity established at assemble time.

To support this configuration spare devices must be allowed to be assembled
into the container even though the metadata indicates the disk belongs to a
different family.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2008-08-09 13:37:54 -07:00
Dan Williams b9f594fea0 imsm: store imsm_disk entries in the super->disks list
removes the need to lookup the disk by index in a few cases and is a
preparation step for tracking spares outside the current anchor.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2008-08-09 13:37:54 -07:00
Dan Williams 63d7cc784b mdmon: use 'recover' instead of 'repair' when activating a spare
Repair sets MD_RECOVERY_REQUESTED in md which may not result in the
spare device being recovered.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2008-08-07 11:54:09 -07:00
NeilBrown 3dff19c8e8 Merge branch 'devel' of git://git.kernel.org/pub/scm/linux/kernel/git/djbw/mdadm into dan 2008-08-07 17:46:44 +10:00
Jacek Danecki 604b746f7c imsm: bad block management (phase1)
This is the initial defensive implementation of bad block management
support.  It simply precludes assembly if there are entries in the bad
block logs.  This is sufficient for now as the conditions that lead to
an entry in the bad block log would cause the array to be failed by MD
(as of 2.6.27).

[dan.j.williams@intel.com: general cleanups]
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2008-08-06 23:55:53 -07:00
Dan Williams 115c380305 imsm: do not mark arrays 'clean' if resync still in progress
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2008-08-06 23:53:44 -07:00
Dan Williams a380c027e3 imsm: raid5 layout is left-asymmetric
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2008-08-06 23:53:44 -07:00
NeilBrown 37ea3936a6 Merge branch 'master' into from-stable
Conflicts:

	Create.c
	Manage.c
2008-08-07 14:12:25 +10:00
Dan Williams 836759d561 mdmon: ignore inactive arrays and other manage_new() cleanups
While mdadm is constructing an array mdmon may see an intermediate state
(some disks not yet added / redundancy attributes like sync_action not
available).  Waiting for mdstat->active == true ensures that the array
is ready to be handled.  This fixes a bug in create array via mdmon
update whereby failures are not detected in the new array.

Introduce aa_ready() to catch cases where the active_array is not
correctly initialized.  Barring a kernel bug this should never trigger,
nonetheless it precludes a class of bugs like the one mentioned above
from triggering.

Cleanup the exit paths and only call replace_array when the new array is
ready to be inserted into container->arrays.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2008-08-04 16:48:27 -07:00
NeilBrown e5669f4004 Cosmetic cleanup of some messages.
e.g. --raid-disks is preferred over --raid-devices.

 Thanks to "Jon Nelson" <jnelson-linux-raid@jamponi.net>

Signed-off-by: NeilBrown <neilb@suse.de>
2008-08-01 16:48:08 +10:00
Dan Williams 9ca2c81c0f imsm: trim some memory wastage
drop the previously loaded data as load_imsm_super_all loops through the
disks.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2008-07-25 17:45:13 -07:00
Dan Williams 949c47a0fa imsm: refactor mpb handling into parse and coalesce
Maintaining a single global buffer is unwieldly when extending/rewriting
sections of the metadata.  Parse the metadata into component data
structures upon reading and coalesce to a coherent buffer before
writing.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2008-07-25 16:59:47 -07:00
Dan Williams 16ddab0daf mdmon: don't fork if DEBUG 2008-07-24 17:26:24 -07:00
Dan Williams f54e6321a2 imsm: use component_size not total array size in container_content_imsm
Also kill setting ->array.size as nothing appears to be using it.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2008-07-24 17:26:24 -07:00
Dan Williams fcfd95998b imsm: take chunksize into account when calculating blocks_per_member
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2008-07-24 17:26:24 -07:00
Dan Williams 755c99faf2 sysfs: deprecate sysfs_disk_to_sg
The cmd_filter patch merged for 2.6.27 broke retrieving the serial
number via an ioctl to /dev/sgN.  In debugging this I found that other
utilities like sdparm simply run the ioctl on /dev/sdX.  So just convert
to that for protection in numbers, but scream on the mailing list for
the inconvenience grr...

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2008-07-24 17:26:24 -07:00
Dan Williams eb7ea4630f imsm: fix store_zero_imsm breakage from posix_memalign conversion
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2008-07-24 17:26:23 -07:00
Dan Williams 0030e8d690 imsm: debug environment variable to use 'device name' as 'serial number'
Facilitate using loopback devices for the imsm regression suite

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2008-07-24 17:26:23 -07:00
Dan Williams e9d82038f8 imsm: allow --examine to succeed with damaged metadata
limp along after seeing mismatched serial numbers

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2008-07-24 17:26:23 -07:00
Dan Williams 5802a8118e imsm: handle degraded->normal transitions in set_disk
Removes the need for the call to ->set_array_state when sync_action
transitions from 'recover' to 'idle'.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2008-07-24 17:26:23 -07:00
Dan Williams 8273f55e4f imsm: create array via update to mdmon 2008-07-24 17:26:19 -07:00
Doug Ledford fb97b4d691 Clean up usage of open()
Fix on call that passed an invalid mode to open
	Don't pass a third arg unless we also pass O_CREAT
	Use symbolic args for 2nd and 3rd args

Signed-off-by: Doug Ledford <dledford@redhat.com>
2008-07-24 18:35:11 -04:00
Doug Ledford 0bc38b5020 Add support for distribution specific build extensions
Signed-off-by: Doug Ledford <dledford@redhat.com>
2008-07-24 12:34:34 -04:00
Jacek Danecki 4ad866b132 install mdmon to the same location as mdadm
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2008-07-21 17:42:12 -07:00
Dan Williams ef649044b7 imsm: remove some casts
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2008-07-21 17:42:10 -07:00
Dan Williams 5257ce365b imsm: activate_spare: fix handling of data_offset
Neil rightly points out that imsm_activate_spare may skip valid free space
on a spare, fix this up.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2008-07-21 11:08:20 -07:00
Dan Williams 5545fa6d94 Document MDADM_NO_MDMON
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2008-07-18 17:47:34 -07:00