thirdparty/mdadm.git
11 years agoRebuildMap: handle missing disks
Dan Williams [Sun, 12 Apr 2009 07:58:28 +0000 (00:58 -0700)] 
RebuildMap: handle missing disks

When rebuilding the map file tolerate missing/offline disks, otherwise
we will segfault on the NULL return from sysfs_read.

Reported-by: Jacek Danecki <jacek.danecki@intel.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
11 years agoimsm: add the ddf field
Dan Williams [Sun, 12 Apr 2009 07:58:28 +0000 (00:58 -0700)] 
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>
11 years agoimsm: round down array size at Create
Dan Williams [Sun, 12 Apr 2009 07:58:28 +0000 (00:58 -0700)] 
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>
11 years agoimsm: set array size at Create/Assemble
Dan Williams [Sun, 12 Apr 2009 07:58:28 +0000 (00:58 -0700)] 
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>
11 years agoimsm: turn off curr_migr_unit updates
Dan Williams [Sun, 12 Apr 2009 07:58:28 +0000 (00:58 -0700)] 
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>
11 years agoimsm: defend against unsupported migrations (temporary)
Dan Williams [Sun, 12 Apr 2009 07:58:28 +0000 (00:58 -0700)] 
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>
11 years agoimsm: add 'verify', 'verify with fixup', and 'general' migration types
Dan Williams [Sun, 12 Apr 2009 07:58:27 +0000 (00:58 -0700)] 
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>
11 years agoimsm: fix imsm_map.num_domains
Dan Williams [Sun, 12 Apr 2009 07:58:27 +0000 (00:58 -0700)] 
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>
11 years agoimsm: ensure mpb buffer is zeroed
Dan Williams [Sun, 12 Apr 2009 07:58:27 +0000 (00:58 -0700)] 
imsm: ensure mpb buffer is zeroed

Don't leak unitialized data into the mpb.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
11 years agoimsm: support --examine --export
Dan Williams [Sun, 12 Apr 2009 04:53:25 +0000 (21:53 -0700)] 
imsm: support --examine --export

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
11 years agoimsm: make uuid separator consistent with ddf
Dan Williams [Sun, 12 Apr 2009 04:53:25 +0000 (21:53 -0700)] 
imsm: make uuid separator consistent with ddf

'-' to ':'

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
11 years agoimsm: extract right-most whitespace stripped serial number
Dan Williams [Wed, 8 Apr 2009 18:41:51 +0000 (11:41 -0700)] 
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>
11 years agoRelease mdadm-3.0-devel3 mdadm-3.0-devel3
NeilBrown [Tue, 10 Mar 2009 05:59:57 +0000 (16:59 +1100)] 
Release mdadm-3.0-devel3

11 years agoMerge branch 'master' in devel-3.0
NeilBrown [Tue, 10 Mar 2009 05:47:02 +0000 (16:47 +1100)] 
Merge branch 'master' in devel-3.0

11 years agoRelease mdadm-2.6.9 mdadm-2.6.9
NeilBrown [Tue, 10 Mar 2009 05:38:37 +0000 (16:38 +1100)] 
Release mdadm-2.6.9

11 years agomdmon: allow incremental assembly of containers.
NeilBrown [Tue, 10 Mar 2009 05:28:22 +0000 (16:28 +1100)] 
mdmon: allow incremental assembly of containers.

If mdmon sees a device added to a container, it should assume it is
a new spare.  It could be a part of the array that just hadn't been
assembled yet.  So check first.

Signed-off-by: NeilBrown <neilb@suse.de>
11 years agoDDF: fix up container_content
NeilBrown [Tue, 10 Mar 2009 05:28:22 +0000 (16:28 +1100)] 
DDF: fix up container_content

If we haven't got hold of all the devices yet, we need to be
ready to skip over some while gathering content information.

Signed-off-by: NeilBrown <neilb@suse.de>
11 years agoAssemble/container: catch errors when starting a partial container.
NeilBrown [Tue, 10 Mar 2009 05:28:22 +0000 (16:28 +1100)] 
Assemble/container: catch errors when starting a partial container.

If we are assembling an array in a container and it isn't complete
enough to start yet, then
  - don't start mdmon
  - don't say the array is started
  - don't wait for the device to appear in /dev

Signed-off-by: NeilBrown <neilb@suse.de>
11 years agoIncremental/container: don't create when we should just be opening.
NeilBrown [Tue, 10 Mar 2009 05:28:22 +0000 (16:28 +1100)] 
Incremental/container:  don't create when we should just be opening.

When incr-assembling in a container, if the array already exists,
don't try to create it again, just open it.

Signed-off-by: NeilBrown <neilb@suse.de>
11 years agomdopen: be more careful when adding digit to names.
NeilBrown [Tue, 10 Mar 2009 05:28:22 +0000 (16:28 +1100)] 
mdopen:  be more careful when adding digit to names.

If we need to add digits to a name to make it unique, but don't have
to add '_', we need to avoid adding a digit immediately after a digit.
So if the last character of the name is a digit, add the '_' anyway.

Signed-off-by: NeilBrown <neilb@suse.de>
11 years agoIncremental: fix some handling of trustworthy.
NeilBrown [Tue, 10 Mar 2009 05:28:22 +0000 (16:28 +1100)] 
Incremental:  fix some handling of trustworthy.

1/ if homehost matches, then we need to set trustworthy to 'LOCAL'
2/ if we decide to set trustworthy to 'METADATA' because we have to
   use the metadata version name, do that *after* we have checked if
   we are going to assemble within a container, as inside the
   container there could be different sources of names to use.

Signed-off-by: NeilBrown <neilb@suse.de>
11 years agoddf: use better random number generation.
NeilBrown [Tue, 10 Mar 2009 05:28:18 +0000 (16:28 +1100)] 
ddf:  use better random number generation.

use /dev/urandom rather than calls to 'random()' if possible.

Signed-off-by: NeilBrown <neilb@suse.de>
11 years agoExamine: add examine_export for ddf and avoid crashes.
NeilBrown [Mon, 9 Mar 2009 03:10:52 +0000 (14:10 +1100)] 
Examine:  add examine_export for ddf and avoid crashes.

If the personality doesn't provide export_examine_super, don't crash.

Signed-off-by: NeilBrown <neilb@suse.de>
11 years agoddf: fix memory corruption bug.
NeilBrown [Mon, 9 Mar 2009 02:55:59 +0000 (13:55 +1100)] 
ddf: fix memory corruption bug.

When adding to a point, you don't need to multiple by the size
of the pointer - C does that for you!

11 years agoDDF: minor formatting improvement
NeilBrown [Mon, 9 Mar 2009 02:55:13 +0000 (13:55 +1100)] 
DDF: minor formatting improvement

avoid long lines in --examine output

11 years agoSupport new raid6 layouts needed for DDF
NeilBrown [Mon, 9 Mar 2009 00:16:53 +0000 (11:16 +1100)] 
Support new raid6 layouts needed for DDF

DDF raid6 layouts are subtly different from the standard 'md' layouts.
From 2.6.30 the kernel knows about these.
Teach mdadm about them, and also allow 'ddf' to set an appropriate default.

Signed-off-by: NeilBrown <neilb@suse.de>
11 years agosuper1/examine: remove confusing information.
NeilBrown [Sun, 8 Mar 2009 23:38:33 +0000 (10:38 +1100)] 
super1/examine:  remove confusing information.

The information about how slots and roles in the array lined up
turned out to be confusing.

So simplify it and one provide the interesting information.

Signed-off-by: NeilBrown <neilb@suse.de>
11 years agosuper1 - do metadata IO in sector_size units.
NeilBrown [Sun, 8 Mar 2009 23:17:42 +0000 (10:17 +1100)] 
super1 - do metadata IO in sector_size units.

If the sector size is > 512, we need to be more careful about
alignment.
The largest known sector size is 4096 and (fortunately) both the
superblock and (in many cases) the bitmap are 4096-byte aligned.
So there should be no data-overlap problems.

The exception is when the bitmap is squeezed into the 3K after the
superblock.  This arrangement cannot currently be supported on
4K sector-size devices.

Signed-off-by: NeilBrown <neilb@suse.de>
11 years agosuper0: Do all metadata IO with 4096byte alignment
NeilBrown [Sun, 8 Mar 2009 23:16:17 +0000 (10:16 +1100)] 
super0:  Do all metadata IO with 4096byte alignment

.. because some devices (dasd) have 4096 byte sector size.

As the superblock is 4096 bytes and the bitmap is in a
60K region, this is safe from any possible corruption.

Signed-off-by: NeilBrown <neilb@suse.de>
11 years agoFix udev-rules for case where array isn't really there..
NeilBrown [Sun, 8 Mar 2009 23:14:48 +0000 (10:14 +1100)] 
Fix udev-rules for case where array isn't really there..

See http://git.kernel.org/?p=linux/hotplug/udev.git;a=commitdiff;h=b822542608326092e177fd1707ca7fb53b2846c4

Signed-off-by: NeilBrown <neilb@suse.de>
11 years agosuper1: make sure max_dev grows enough when adding a device to an array.
NeilBrown [Sun, 8 Mar 2009 22:59:39 +0000 (09:59 +1100)] 
super1: make sure max_dev grows enough when adding a device to an array.

There was a few kernel releases where the kernel would shrink max_dev
to be just enough to hold the current number of devices.
More recent kernels never shrink it.
However to be as compatible as possible, if we notice that
max_dev is too small to successfully add a device, increase it.

Signed-off-by: NeilBrown <neilb@suse.de>
11 years agoimsm: display supported chunk sizes in --detail-platform
Dan Williams [Fri, 27 Feb 2009 22:35:20 +0000 (15:35 -0700)] 
imsm: display supported chunk sizes in --detail-platform

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
11 years agoIncremental: honor --no-degraded to delay assembly
Dan Williams [Wed, 25 Feb 2009 01:45:57 +0000 (18:45 -0700)] 
Incremental: honor --no-degraded to delay assembly

Currently Incremental_container is being called after adding each disk.
In the imsm case where spares are not tracked in the raid_disks field we
can use --no-degraded to block premature assembly.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
11 years agoIncremental: fix 'name_to_use' in the container case
Dan Williams [Wed, 25 Feb 2009 01:45:57 +0000 (18:45 -0700)] 
Incremental: fix 'name_to_use' in the container case

Just like the Assemble case, default to the text_version of the
container if another name is not specified.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
11 years agomdmon: update cmdline when scanning
Dan Williams [Wed, 25 Feb 2009 01:45:57 +0000 (18:45 -0700)] 
mdmon: update cmdline when scanning

Allows ps -ax | grep mdmon to show:
mdmon md127
mdmon md126
...rather than:
mdmon /proc/mdstat
mdmon /proc/mdstat

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
11 years agomdmon: man page
Dan Williams [Wed, 25 Feb 2009 01:45:57 +0000 (18:45 -0700)] 
mdmon: man page

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
11 years agomdmon: fix missed 'clean' event
Dan Williams [Wed, 25 Feb 2009 01:45:57 +0000 (18:45 -0700)] 
mdmon: fix missed 'clean' event

mdmon may miss events because it re-reads state after read_and_act.  The
additional read is used to determine dirty status before allowing a
sigterm to proceed.  Since read_and_act is in the best position to
determine 'dirty' status and its return value is not used, modify it to
return true if the array is dirty.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
11 years agoimsm: auto layout
Dan Williams [Wed, 25 Feb 2009 01:45:57 +0000 (18:45 -0700)] 
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>
11 years agoCreate: fixup 'insert_point', dependent on 'subdevs', for auto-layout
Dan Williams [Wed, 25 Feb 2009 01:45:57 +0000 (18:45 -0700)] 
Create: fixup 'insert_point', dependent on 'subdevs', for auto-layout

'subdevs' is read from the container in the auto-layout case so reset
subdevs dependent default values.  'insert_point' without this
change is always 2 blocking creation of arrays with > 2 raid disks.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
11 years agoCreate: wait_for container creation
Dan Williams [Wed, 25 Feb 2009 01:45:57 +0000 (18:45 -0700)] 
Create: wait_for container creation

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
11 years agoManage: permit '--remove detached' for containers
Dan Williams [Wed, 25 Feb 2009 01:45:57 +0000 (18:45 -0700)] 
Manage: permit '--remove detached' for containers

Skip the unique holder check in the detached case... pretty sure no one is
holding on to it if open() returns ENXIO.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
11 years agomdmon: record added disks
Dan Williams [Wed, 25 Feb 2009 01:45:57 +0000 (18:45 -0700)] 
mdmon: record added disks

Prevent duplicate disks from being sent to the monitor thread.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
11 years agomdmon: fix removed disk handling
Dan Williams [Wed, 25 Feb 2009 01:45:57 +0000 (18:45 -0700)] 
mdmon: fix removed disk handling

Use SKIP_GONE_DEVS when reading the container, and correct some confused
logic in manage_new().

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
11 years agosysfs: allow sysfs_read to detect and drop removed disks
Dan Williams [Wed, 25 Feb 2009 01:45:56 +0000 (18:45 -0700)] 
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>
11 years agoimsm: retry load_imsm_mpb if we suspect mdmon has made modifications
Dan Williams [Wed, 25 Feb 2009 01:45:56 +0000 (18:45 -0700)] 
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>
11 years agoimsm: verify single sector mpb checksums
Dan Williams [Wed, 25 Feb 2009 01:45:56 +0000 (18:45 -0700)] 
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>
11 years agoimsm: fix mark_failure / introduce mark_missing
Dan Williams [Wed, 25 Feb 2009 01:45:56 +0000 (18:45 -0700)] 
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>
11 years agoimsm: introduce get_imsm_disk_slot
Dan Williams [Wed, 25 Feb 2009 01:45:56 +0000 (18:45 -0700)] 
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>
11 years agoimsm: fix activate spare to ignore foreign disks
Dan Williams [Tue, 24 Feb 2009 06:06:24 +0000 (23:06 -0700)] 
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>
11 years agoimsm: fixup container spare uuids by default
Dan Williams [Mon, 23 Feb 2009 21:26:11 +0000 (14:26 -0700)] 
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>
11 years agoimsm: fix missing initializations of the per-disk extents pointer
Dan Williams [Tue, 24 Feb 2009 06:06:24 +0000 (23:06 -0700)] 
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>
11 years agotest: fix a call to udevsettle
Dan Williams [Tue, 24 Feb 2009 06:06:24 +0000 (23:06 -0700)] 
test: fix a call to udevsettle

udevsettle is deprecated, use udevadm settle

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
11 years agoimsm: provide a simulated option-rom for regression tests
Dan Williams [Mon, 23 Feb 2009 21:26:10 +0000 (14:26 -0700)] 
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>
11 years agoMonitor: send --test message for arrays in /proc/mdstat that aren't in mdadm.conf
NeilBrown [Thu, 5 Feb 2009 06:06:03 +0000 (17:06 +1100)] 
Monitor: send --test message for arrays in /proc/mdstat that aren't in mdadm.conf

"mdadm --monitor --test --scan" currently only sends test messages for
arrays listed on the command line or in /etc/mdadm.conf.  With this
patch it also reports on any active arrays, which is more in line with
the description in the manpage.

Thanks to  Andrew Walrond <andrew@walrond.org> for reporting this error.

Signed-off-by: NeilBrown <neilb@suse.de>
11 years agoimsm: block creation of devices with identical names
Dan Williams [Mon, 2 Feb 2009 22:01:13 +0000 (15:01 -0700)] 
imsm: block creation of devices with identical names

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
11 years agoimsm: don't check raid1 chunk size
Dan Williams [Mon, 2 Feb 2009 17:54:58 +0000 (10:54 -0700)] 
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>
11 years agoMerge branch 'master' into devel-3.0
NeilBrown [Mon, 2 Feb 2009 00:09:09 +0000 (11:09 +1100)] 
Merge branch 'master' into devel-3.0

11 years agoFix possible crash if bitmap metadata is bad.
NeilBrown [Mon, 2 Feb 2009 00:06:38 +0000 (11:06 +1100)] 
Fix possible crash if bitmap metadata is bad.

We really should never divide by 0.

Thanks to "Jon Nelson" <jnelson-linux-raid@jamponi.net>
for finding the problem.

Signed-off-by: NeilBrown <neilb@suse.de>
11 years agoDocument 'max' option to --grow --size in --help output.
NeilBrown [Sun, 1 Feb 2009 23:58:08 +0000 (10:58 +1100)] 
Document 'max' option to --grow --size in --help output.

Suggestion from Christian Hudon <chrish@debian.org>

Signed-off-by: NeilBrown <neilb@suse.de>
11 years agoTypo in earlier patch : asprintf -> vasprintf
Dustin Kirkland [Sun, 1 Feb 2009 23:54:23 +0000 (10:54 +1100)] 
Typo in earlier patch : asprintf -> vasprintf

Signed-off-by: NeilBrown <neilb@suse.de>
11 years agoFix the used device size in mdadm -D output.
NeilBrown [Sun, 1 Feb 2009 23:03:20 +0000 (10:03 +1100)] 
Fix the used device size in mdadm -D output.

As get_component_size() returns the number of used sectors of a device
we need halve before pringing as K, and shift the value by 9, not 10,
before passing to human_size.

Thanks to Andre Noll <maan@systemlinux.org> for identifying problem
(and a slightly different version of this patch)

Signed-off-by: NeilBrown <neilb@suse.de>
11 years agomdadm fix compilation for uClibc
Bernhard Reutner-Fischer [Mon, 8 Dec 2008 16:00:59 +0000 (17:00 +0100)] 
mdadm fix compilation for uClibc

2008-12-08  Bernhard Reutner-Fischer  <rep.dot.nop@gmail.com>

* Makefile (dadm.uclibc): Remove misspelled and unneeded rule.
* md5.h: Include stdint.h for uClibc.
* mdadm.h: uClibc defines __UCLIBC__. If uClibc has LFS off
then use lseek instead of lseek64.

Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
11 years agoimsm: fix failed disks are allowed back into the container
Dan Williams [Fri, 23 Jan 2009 22:45:34 +0000 (15:45 -0700)] 
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>
11 years agoCreate: warn when a metadata format's platform components are missing
Dan Williams [Tue, 20 Jan 2009 08:36:51 +0000 (01:36 -0700)] 
Create: warn when a metadata format's platform components are missing

If the metadata handler can not find its platform support components
then there is no way for it to verify that the raid configuration will
be supported by the option-rom.  Provide a generic method for metadata
handlers to warn the user that the array they are about to create may
not work as intended with a given platform.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
11 years agoimsm: enforce "all member disks must be members of all arrays"
Dan Williams [Tue, 20 Jan 2009 08:36:51 +0000 (01:36 -0700)] 
imsm: enforce "all member disks must be members of all arrays"

This is a key orom-compatibility constraint.  A nice side effect is that
it precludes the corner case of 'create' racing against 'spare activate'
since the create will fail to convert a spare into an array member.  At
create time we check if this is the first member array in the container
if it is than all disks are possible candidates, if it is not then only
current members are permitted.

A bit hairier is spare-activation handling in the presence of this
constraint.  It is difficult because spare handling is per array.  The
approach taken is to:

1/ check that a new spare can cover all defined arrays in the container
2/ ensure that partially assimilated spares are the first candidates
   when looking for a spare region to activate.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
11 years agoimsm: enforce num_disks constraints
Dan Williams [Tue, 20 Jan 2009 08:36:50 +0000 (01:36 -0700)] 
imsm: enforce num_disks constraints

RAID1 == 2 disks
RAID5 >= 3 disks
RAID10 == 4 disks

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
11 years agoimsm: rename vprintf macro to pr_vrb
Dan Williams [Tue, 20 Jan 2009 08:36:50 +0000 (01:36 -0700)] 
imsm: rename vprintf macro to pr_vrb

Don't redefine standard library calls unecessarily...

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
11 years agoCreate: allow per-metadata default layouts
Dan Williams [Tue, 20 Jan 2009 08:36:50 +0000 (01:36 -0700)] 
Create: allow per-metadata default layouts

Let handlers specifiy their own defaults, specifically needed for the
imsm-raid5 case where mdadm defaults to 'ls' and imsm to 'la'.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
11 years agomdmon: make switchroot an undecorated option
Dan Williams [Tue, 20 Jan 2009 08:36:50 +0000 (01:36 -0700)] 
mdmon: make switchroot an undecorated option

Simplify the usage from:
mdmon [--switch-root dir] /device/name/for/container
to...
mdmon /device/name/for/container [target_dir]

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
11 years agoAssemble: fix busy detection
Dan Williams [Tue, 20 Jan 2009 08:36:50 +0000 (01:36 -0700)] 
Assemble: fix busy detection

Use mddev_busy() as GET_ARRAY_INFO can succeed on 'clear' arrays.

Ran into this after an encountering a case where mdadm -Ss ended in
segfault (missing check for NULL return from map_by_devnum() in
sles11:Manage.c).  So, tried to stop the array by hand with echo clear >
md/array_state, after which I could not reassemble since GET_ARRAY_INFO
was succeeding.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
11 years agomdmon: support scanning for containers
Dan Williams [Tue, 20 Jan 2009 08:36:50 +0000 (01:36 -0700)] 
mdmon: support scanning for containers

When the given container is '/proc/mdstat' then launch an mdmon instance
per container found in /proc/mdstat.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
11 years agomdmon: expand permissible container device names
Dan Williams [Tue, 20 Jan 2009 08:36:50 +0000 (01:36 -0700)] 
mdmon: expand permissible container device names

Allow any path that dereferences to an md device to be used in addition
to the current symbolic md device names.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
11 years agoimsm: imsm_read_serial check for zero-length response
Dan Williams [Tue, 20 Jan 2009 08:33:56 +0000 (01:33 -0700)] 
imsm: imsm_read_serial check for zero-length response

VMWare virtual disks successfully run the inquiry but return a zero response.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
11 years agoimsm: fix dev_open return value handling
Dan Williams [Tue, 20 Jan 2009 07:29:34 +0000 (00:29 -0700)] 
imsm: fix dev_open return value handling

dev_open returns an fd

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
11 years agomdmon: fix missing ->subarray initialization
Dan Williams [Tue, 13 Jan 2009 22:46:05 +0000 (15:46 -0700)] 
mdmon: fix missing ->subarray initialization

This can cause mdmon to fail at startup.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
11 years agoMerge branch 'master' into scratch-3.0
NeilBrown [Wed, 7 Jan 2009 22:31:28 +0000 (09:31 +1100)] 
Merge branch 'master' into scratch-3.0

Conflicts:

Assemble.c
config.c

11 years agoFail overtly when asprintf fails to allocate memory
Dustin Kirkland [Wed, 7 Jan 2009 22:25:33 +0000 (09:25 +1100)] 
Fail overtly when asprintf fails to allocate memory

.. rather that causing a less-obvious violation of segments.

Signed-off-by: NeilBrown <neilb@suse.de>
11 years agoFree mdstat data structures properly.
NeilBrown [Wed, 7 Jan 2009 22:25:31 +0000 (09:25 +1100)] 
Free mdstat data structures properly.

In one case we called 'free' instead of 'mdstat_free'.
In others we didn't free at all.

Signed-off-by: NeilBrown <neilb@suse.de>
11 years agoMerge branch 'devel' of git://git.kernel.org/pub/scm/linux/kernel/git/djbw/mdadm...
NeilBrown [Thu, 18 Dec 2008 05:58:25 +0000 (16:58 +1100)] 
Merge branch 'devel' of git://git./linux/kernel/git/djbw/mdadm into devel-3.0

11 years agoMerge branch 'master' into devel-3.0
NeilBrown [Thu, 18 Dec 2008 05:56:13 +0000 (16:56 +1100)] 
Merge branch 'master' into devel-3.0

Conflicts:

Assemble.c
Incremental.c
Kill.c
ReadMe.c
inventory
mapfile.c
mdadm.8
mdadm.spec
mdassemble.8

11 years agomap: rebuild map if it doesn't exist.
NeilBrown [Thu, 18 Dec 2008 05:23:46 +0000 (16:23 +1100)] 
map: rebuild map if it doesn't exist.

It is possible for some arrays to be created e.g. by initrd, and so
not get mentioned in /var/run/mdadm/map.
As "-I" depends on things being listed in 'map', we create it by
scanning all devices if it doesn't exist.

Signed-off-by: NeilBrown <neilb@suse.de>
11 years agoAssemble: set stripe_cache_size properly when restarting a reshape.
NeilBrown [Thu, 18 Dec 2008 03:24:41 +0000 (14:24 +1100)] 
Assemble: set stripe_cache_size properly when restarting a reshape.

Reshape with large chunk size can require a large stripe_cache.
We make this work when starting the reshape but not when
restarting at assemble time.  So fix that.

Signed-off-by: NeilBrown <neilb@suse.de>
11 years agoAssemble: don't assume array is 'clean' unless all devices think it is.
NeilBrown [Thu, 18 Dec 2008 03:11:59 +0000 (14:11 +1100)] 
Assemble: don't assume array is 'clean' unless all devices think it is.

This is only significant for --assemble --force where some old
devices might be included into the array.  If anything looks like
it isn't clean, the kernel will not allow a degraded array to be started.

Signed-off-by: NeilBrown <neilb@suse.de>
11 years agoKill: Don't use O_EXCL when --force is used.
NeilBrown [Thu, 18 Dec 2008 03:04:45 +0000 (14:04 +1100)] 
Kill:  Don't use O_EXCL when --force is used.

We really want --zero-super --force to zero the superblock in
all situations.  So don't open with O_EXCL - trust the user.

Signed-off-by: NeilBrown <neilb@suse.de>
11 years agoimsm: test overlapping creates
Dan Williams [Mon, 8 Dec 2008 23:59:19 +0000 (16:59 -0700)] 
imsm: test overlapping creates

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
11 years agoworkaround a hald interaction and quiet cleanup
Dan Williams [Mon, 8 Dec 2008 23:59:18 +0000 (16:59 -0700)] 
workaround a hald interaction and quiet cleanup

The 'udevadm settle' call appears to resolve:

mdadm: failed to stop array /dev/md127: Device or resource busy
Perhaps a running process, mounted filesystem or active volume group?

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
11 years agotest: enable per-test custom environment setup/teardown
Dan Williams [Mon, 8 Dec 2008 23:59:18 +0000 (16:59 -0700)] 
test: enable per-test custom environment setup/teardown

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
11 years agoimsm: don't take chunk_size into account for raid1
Dan Williams [Mon, 8 Dec 2008 23:59:18 +0000 (16:59 -0700)] 
imsm: don't take chunk_size into account for raid1

Results in chopping off usable parts of the requested size.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
11 years agoimsm: reverse swapped arguments to posix_memalign in imsm_prepare_update
Dan Williams [Mon, 8 Dec 2008 23:59:18 +0000 (16:59 -0700)] 
imsm: reverse swapped arguments to posix_memalign in imsm_prepare_update

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
11 years agoimsm: convert dev_tbl to devlist
Dan Williams [Mon, 8 Dec 2008 23:57:08 +0000 (16:57 -0700)] 
imsm: convert dev_tbl to devlist

...to facilitate testing arbitrary numbers of raid devices

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
11 years agoimsm: provide a detail_platform method
Dan Williams [Mon, 8 Dec 2008 23:59:18 +0000 (16:59 -0700)] 
imsm: provide a detail_platform method

Dump the orom capabilities and hardware disk configuration.  This code
relies on the name of scsi_host objects to determine the hardware port
number.  Hopefully this information is stable...

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
11 years agointroduce --detail-platform to display platform raid capabilities
Dan Williams [Mon, 8 Dec 2008 23:59:18 +0000 (16:59 -0700)] 
introduce --detail-platform to display platform raid capabilities

Metadata formats like imsm work in concert with platform firmware and
hardware, so provide a way for mdadm to display this info to the user.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
11 years agoimsm: validate arrays being created against firmware capabilities
Dan Williams [Mon, 8 Dec 2008 23:59:18 +0000 (16:59 -0700)] 
imsm: validate arrays being created against firmware capabilities

These checks are only enabled when platform support for imsm is found,
i.e. ahci driver is loaded and talking to an Intel(R) controller, and
the option rom header is located.

They can be turned off by setting the environment variable
IMSM_NO_PLATFORM to 1.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
11 years agoimsm: sysfs support routines for determining device connectivity
Dan Williams [Mon, 8 Dec 2008 23:59:18 +0000 (16:59 -0700)] 
imsm: sysfs support routines for determining device connectivity

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
11 years agoimsm: detect option-rom capabilities
Dan Williams [Mon, 8 Dec 2008 23:59:18 +0000 (16:59 -0700)] 
imsm: detect option-rom capabilities

The option-rom advertises its capabilities in a data structure located in
the platform ROM region 0xc0000-0xf0000.  Attempt to detect the option-rom
and limit array creation to the platform's capabilities.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
11 years agoport arch/x86/kernel/probe_roms_32.c for use in 'platform' support
Dan Williams [Mon, 8 Dec 2008 23:59:18 +0000 (16:59 -0700)] 
port arch/x86/kernel/probe_roms_32.c for use in 'platform' support

This provides at least a kernel bug compatible method of scanning for an
adapter-rom.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
11 years agoimsm: pass disk info in create message
Dan Williams [Mon, 8 Dec 2008 18:46:57 +0000 (11:46 -0700)] 
imsm: pass disk info in create message

We may be creating on spare disks in which case we need to know which
disk goes in which slot.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
11 years agoimsm: correct start offset handling at create time
Dan Williams [Mon, 8 Dec 2008 18:38:59 +0000 (11:38 -0700)] 
imsm: correct start offset handling at create time

imsm metadata requires all members of a raid volume to start at the same
offset.  So, incrementally build a composite disk from all the
candidates passed to ->validate_geometry.  After each disk is added
merge the extents and search for a common start offset that satisfies
the requested raid device size.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
11 years agoimsm: fix setting of device size for raid1
Dan Williams [Mon, 8 Dec 2008 18:28:54 +0000 (11:28 -0700)] 
imsm: fix setting of device size for raid1

When chunksize is 0 in the raid1 case we need to use
info_to_blocks_per_member() to calculate the array size.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
11 years agowait_for container assembly
Dan Williams [Mon, 8 Dec 2008 23:59:17 +0000 (16:59 -0700)] 
wait_for container assembly

Signed-off-by: Dan Williams <dan.j.williams@intel.com>