Commit Graph

233 Commits

Author SHA1 Message Date
Dan Williams fd4c9ba491 Incremental: return success in 'container not enough' case
Commit 97b4d0e9 "Incremental: honor an 'enough' flag from external
handlers" introduced a regression in that it changed the error return
code for successful invocations.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
Reported-by: Ignacy Kasperowicz <ignacy.kasperowicz@intel.com>
2010-08-10 08:44:45 -07:00
Doug Ledford 93c861ee57 Add warnings if we ever fail to get a lock on the mapfile.
Signed-off-by: Doug Ledford <dledford@redhat.com>
2010-07-22 10:16:31 -04:00
NeilBrown 8562409dd1 Merge branch 'master' of git://github.com/djbw/mdadm 2010-07-22 17:43:35 +10:00
Dan Williams 1dccfff910 Incremental: restore assembly for inactive containers, block active
GET_ARRAY_INFO always succeeds on an inactive container, so we need to
be a bit more diligent about adding a disk to an active container.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2010-07-19 14:59:25 -07:00
Przemyslaw Czarnowski aae3cdc35a fix: IncrementalRemove leaves open handle
Signed-off-by: Przemyslaw Czarnowski <przemyslaw.hawrylewicz.czarnowski@intel.com<mailto:przemyslaw.hawrylewicz.czarnowski@intel.com>>
2010-07-06 16:47:02 +10:00
NeilBrown 1538aca5cb Merge branch 'master' of git://github.com/djbw/mdadm 2010-07-06 14:46:47 +10:00
NeilBrown 7d2e6486e3 Add --test option to --re-add and similar
--test can be given in Manage mode.
This can be used when there is an attempt to fail or remove 'faulty',
'failed' or 'detached' devices, or to re-add 'missing' devices.
If no devices were failed, removed, or re-added, then mdadm will
exit with status '2'.

Signed-off-by: NeilBrown <neilb@suse.de>
2010-07-06 12:07:07 +10:00
NeilBrown 3a6ec29ad5 Don't let incremental add devices to active arrays.
Adding devices to active arrays in --incremental is a bit dubious.

Normally the array won't be activated until all expected devices are
present, so this situation would mean that the given device is not
expected, so is probably failed.  In that case it should only be added
by explicit sysadmin request.

However if --run was given, then quite possibly the array was
assembled earlier when not complete, so it is less clear whether it is
wrong to add this device or not.  In that case add it as that is
generally safest.

It would be nice to allow policy for this to be explicitly given by
sysadmin.

Signed-off-by: NeilBrown <neilb@suse.de>
2010-07-06 12:04:40 +10:00
NeilBrown 29ba480497 Add -fail support to --incremental
This can be used for hot-unplug.  When a device has been remove,
udev can call
   mdadm --incremental --fail sda

and mdadm will find the array holding sda and remove sda from
the array.

Based on code from  Doug Ledford <dledford@redhat.com>

Signed-off-by: NeilBrown <neilb@suse.de>
2010-06-30 16:55:17 +10:00
Dan Williams b526e52dc7 Always assume SKIP_GONE_DEVS behaviour and kill the flag
...i.e. GET_DEVS == (GET_DEVS|SKIP_GONE_DEVS)

A null pointer dereference in Incremental.c can be triggered by
replugging a disk while the old name is in use.  When mdadm -I is called
on the new disk we fail the call to sysfs_read().  I audited all the
locations that use GET_DEVS and it appears they can tolerate missing a
drive.  So just make SKIP_GONE_DEVS the default behaviour.

Also fix up remaining unchecked usages of the sysfs_read() return value.

Reported-by: Dave Jiang <dave.jiang@intel.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2010-06-16 17:26:04 -07:00
Dan Williams 3288b419b9 Revert "Incremental: honor --no-degraded to delay assembly"
This reverts commit fdb482f99b.

Now that containers can report state for ->container_enough we can
automatically determine when the array can be started, and no longer
need the --no-degraded hammer.

Conflicts:

	Incremental.c

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2010-05-26 13:25:47 -07:00
Dan Williams 97b4d0e971 Incremental: honor an 'enough' flag from external handlers
This is needed for imsm where:
1/ we want to report raid_disks as zero to allow mdadm -As to
   incorporate all spares
2/ we can't determine stale disks by looking at the event counts.
3/ we can't see per-subarray expectations with the info returned from
   the container level ->getinfo_super()

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2010-05-26 13:22:36 -07:00
NeilBrown d1d3482b56 config: add 'homehost' option to 'AUTO' line.
This allows basing auto-assembly decisions on whether
the array is recorded as belonging to this host or not.

Signed-off-by: NeilBrown <neilb@suse.de>
2010-03-03 14:33:55 +11:00
NeilBrown e736b62389 Update copyright dates and remove references to @cse.unsw.edu.au
Also removed 'paper' addresses.

Signed-off-by: NeilBrown <neilb@suse.de>
2009-06-02 14:35:45 +10:00
NeilBrown 2400e6eb21 Incr: use devname_matches to when looking in mdadm.conf for bitmap file
This is more likely to always do the right thing than a strcmp.

Signed-off-by: NeilBrown <neilb@suse.de>
2009-05-11 15:47:11 +10:00
NeilBrown ac7de9d97a Incremental: fix uninitialised variable.
st2 might not be initialised at this point.  So use the
more correct 'st'.

Signed-off-by: NeilBrown <neilb@suse.de>
2009-05-11 15:47:10 +10:00
NeilBrown 339c2d6c5e Incr: cope better with possibility that mp->path might be NULL
Signed-off-by: NeilBrown <neilb@suse.de>
2009-05-11 15:47:10 +10:00
NeilBrown 7cdc087234 Be more consistent about keeping the host: prefix on array names.
If an array name contains a "hostname:" prefix, then
--assemble will tend to leave it there, while --incremental
will strip it off (when chosing a device name during auto-assembly).

Make this more consistent:  strip the name off if we decide that
the name will be treated as 'local'.  Leave it on if it will be
treated as 'foreign'.

Signed-off-by: NeilBrown <neilb@suse.de>
2009-05-11 15:47:10 +10:00
NeilBrown 0ac91628b9 Allow homehost to be largely ignored when assembling arrays.
If mdadm.conf contains
   HOMEHOST <ignore>
or commandline contains
   --homehost=<ignore>

then the check that array metadata mentions the given homehost is
replace by a check that the name recorded in the metadata is not
already used by some other array mentioned in mdadm.conf.

This allows more arrays to use their native name rather than having
an _NN suffix added.

This should only be used during boot time if all arrays required for
normal boot are listed in mdadm.conf.

If auto-assembly is used to find all array during boot, then the
HOMEHOST feature should be used to ensure there is no room for
confusion in choosing array names, and so it should not be set
to <ignore>.

Signed-off-by: NeilBrown <neilb@suse.de>
2009-05-11 15:46:46 +10:00
NeilBrown 05833051ee Assemble/Incr : minor tidy up of setting 'trustworthy'.
Signed-off-by: NeilBrown <neilb@suse.de>
2009-05-11 15:19:30 +10:00
NeilBrown 31015d5798 conf/assemble: new config line "auto".
The line 'auto' in mdadm.conf can be used to disable assembly
of specific metadata types, or of all arrays.

This does not affect assembly of arrays listed in mdadm.conf
or on command line.

 auto -all

will disable all auto-assembly.

 auto -ddf

will cause mdadm to ignore ddf arrays that are not explicitly
mentioned, and auto assemble anything else it finds.

Signed-off-by: NeilBrown <neilb@suse.de>
2009-05-11 15:17:33 +10:00
NeilBrown 112cace627 config: support "ARRAY <ignore> ..." lines in mdadm.conf
Sometimes we want to ensure particular arrays are never
assembled automatically.  This might include an array made of
devices that are shared between hosts.

To support this, allow ARRAY lines in mdadm.conf to use the word
"ignore" rather than a device name.  Arrays which match such lines
are never automatically assembled (though they can still be assembled
by explicitly giving identification information on the mdadm command
line.

Signed-off-by: NeilBrown <neilb@suse.de>
2009-05-11 15:17:05 +10:00
NeilBrown 745f72f61a assemble: support arrays created with --homehost=any
If an array is created with --homehost=any, then --assemble and
--incremental will treat it as being local to 'this' host, no matter
what the name of this host is.

This is useful for array that will be given unique names and be
moved between machines.

This needs to be documented.

Signed-off-by: NeilBrown <neilb@suse.de>
2009-05-11 15:16:49 +10:00
NeilBrown 7c5483270d Incremental - avoid NULL dereference.
There structure returned by sysfs_read might not have any 'devs',
don't assume it does.

Signed-off-by: NeilBrown <neilb@suse.de>
2009-04-07 17:54:09 +10:00
NeilBrown 03b7f6c6bd Incremental: be more relaxed about member arrays not completely assembling.
During incremental assembly, if the member array doesn't assemble
properly (yet), that isn't an error.

Signed-off-by: NeilBrown <neilb@suse.de>
2009-04-07 17:49:05 +10:00
NeilBrown a7c6e3fb24 wait_for improvement.
wait not only for the name to appear, but for it to refer to the
correct device.
Sometimes old symlinks left lying around can be confusing.

Signed-off-by: NeilBrown <neilb@suse.de>
2009-04-07 17:34:38 +10:00
NeilBrown 3092660000 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>
2009-03-10 16:28:22 +11:00
NeilBrown ecb02e31d5 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>
2009-03-10 16:28:22 +11:00
Dan Williams fdb482f99b 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>
2009-02-24 18:45:57 -07:00
Dan Williams e12e1d1d6a 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>
2009-02-24 18:45:57 -07:00
NeilBrown 8a659c3321 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
2008-12-18 16:56:13 +11:00
NeilBrown 3a56f223e9 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>
2008-12-18 16:23:46 +11:00
NeilBrown 4408ee768b Assemble: close mdfd before returning from assemble_container_content
This makes sure it is consistently closed.

Signed-off-by: NeilBrown <neilb@suse.de>
2008-11-07 22:15:14 +11:00
NeilBrown a714580e02 Wait for name to appear after create/assemble etc.
We don't really want mdadm to exit until udev has
created the names in /dev.  So wait.

Signed-off-by: NeilBrown <neilb@suse.de>
2008-11-04 21:56:42 +11:00
NeilBrown ffb3e4945d Incrmental: cope with udev slowness and errors in map file.
If udev hasn't created the array yet, we might still want to
open it.  So open directly by major:minor.

Also, of array in map file doesn't appear to exist, do use
the name associated with it.

Signed-off-by: NeilBrown <neilb@suse.de>
2008-11-04 21:01:56 +11:00
Dan Williams 6234c63ccc Assemble: factor out assemble_container_content
Factor out, from Incremental_container,  the code for assembling an
array based on information extracted from a container.  We will
shortly use this from Assemble too.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
2008-11-04 20:51:11 +11:00
Dan Williams 197e3eb690 Quiet unitialized variable warnings
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
2008-11-04 20:50:39 +11:00
NeilBrown ad5bc697ad Incremental: lock against multiple concurrent additions to an array.
In two devices are added via -I to one array at the same time, mdadm
can get badly confused.

Signed-off-by: NeilBrown <neilb@suse.de>
2008-11-04 20:50:39 +11:00
NeilBrown 9759037678 Generate 'change' uevents when arrays change in non-obvious ways.
When a 'container' gets started, we need udev to notice, but the
kernel has no way of knowing that a KOBJ_CHANGE event is needed.  So
send one directly via the 'uevent' sysfs attribute.

Also, uevents don't get generated when md arrays are stopped (prior to
2.6.28) so send 'change' events then too.

Signed-off-by: NeilBrown <neilb@suse.de>
2008-11-04 20:50:39 +11:00
NeilBrown 1771a6e214 config: Support container=uuid as alternative to container=/dev/name in mdadm.conf
When mdadm.conf is automatically generated, we might not know a
suitable /dev/name.  But we do know the uuid of the container.
So allow that as an option.

Signed-off-by: NeilBrown <neilb@suse.de>
2008-11-04 20:50:38 +11:00
NeilBrown fe056d1fb0 config: Don't require an array to have a device name.
i.e. in mdadm.conf you can have a line like

   ARRAY uuid=whatever

and it will use auto-name-generation to give a name to the array at
assemble-time.  The is different from blind auto-assembly in that the
array will be treated as 'local'.
2008-11-04 20:50:38 +11:00
NeilBrown 215bb3f776 Incremental: adjust to the new naming scheme.
--incremental now uses exactly the same create_mddev that
other code uses.
2008-11-04 20:50:38 +11:00
NeilBrown 2399204ddd Rename open_mddev to create_mddev
This reflect that fact that more often than not it is creating things
in /dev, and allows for a new open_mddev which does just that.

Signed-off-by: NeilBrown <neilb@suse.de>
2008-11-04 10:35:10 +11:00
Dan Williams 5c8d7dc132 cleanup an unused call to container2devname
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
2008-11-04 10:34:53 +11:00
NeilBrown 2eb91c81d8 Merge branch 'master' into scratch-3.0 2008-11-03 06:40:12 +11:00
NeilBrown 350ac35d1f Incremental: change precedence order for autof setting.
It doesn't really make sense for the --auto setting to ever over-ride
the setting on an ARRAY line.  That could cause failure if the
ARRAY line has a 'standard' now.  So revert to the array line having
precedence over command line, then CREATE line last.

Signed-off-by: NeilBrown <neilb@suse.de>
2008-11-03 06:39:02 +11:00
NeilBrown 6c766cf101 Merge branch 'master' into devel-3.0
Conflicts:

	Incremental.c
	super0.c
	super1.c
2008-10-30 13:59:11 +11:00
NeilBrown 7b403fef7e Incremental: allow assembly of foreign array.
If a foreign (i.e. not known to be local) array is discovered
by --incremental assembly, we now assemble it.  However we ignore
any name information in the array so as not to potentially create
a name that conflict with a 'local' array.
Also, foreign arrays are always assembled 'read-auto' to avoid writing
anything until the array is actually used.

Signed-off-by: NeilBrown <neilb@suse.de>
2008-10-30 09:48:18 +11:00
NeilBrown 4ef2f11e28 Incremental: fix setting of 'autof' flag.
When doing auto-assembly, the 'autof' flag from array lines
in mdadm.conf was being ignored.

Signed-off-by: NeilBrown <neilb@suse.de>
2008-10-30 09:34:06 +11:00
NeilBrown 2b4ca8f079 Fix --incremental assembly of partitions arrays.
If incremental assembly finds an array mentioned in mdadm.conf,
with a 'standard partitioned' name like /dev/md_d0 or /dev/md/d0,
it will not create a partitioned array like it should.
This is because it mishandled the 'devnum' returned by
is_standard.
That is a devnum that does not have the partition-or-not encoded
into it.  So we need to check the actual return value of
is_standard and encode the partition-or-not info into the devnum.

Also fix a couple of comments.


Signed-off-by: NeilBrown <neilb@suse.de>
2008-10-30 09:34:04 +11:00
Doug Ledford 43aaf431f6 Fix NULL pointer oops
RAID10 is the only raid level that uses the avail char array pointer
during the enough() operation, so it was the only one that saw this.
The code in incremental assumes unconditionally that count_active will
allocate the avail char array, that it might be used by enough, and that
it will need to be freed afterward.  Once you make count_active actually
do that, then the oops goes away.

Signed-off-by: Doug Ledford <dledford@redhat.com>
Signed-off-by: NeilBrown <neilb@suse.de>
2008-10-30 08:53:02 +11:00
Dan Williams 71d60c480a Preliminary -As support for container member arrays
Given an mdadm.conf like the following allow /dev/imsm and /dev/md/r1 to be
created by "mdadm -As".

DEVICES partitions 
ARRAY /dev/imsm metadata=imsm auto=md UUID=b98f5dbe-aa859e7b-0e369b89-a80986d4 
ARRAY /dev/md/r1 container=/dev/imsm member=0 auto=mdp UUID=3538e39c-b397c2e9-1aa031f9-2bc0eca4 
   spares=1

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2008-10-28 10:55:31 -07:00
NeilBrown 04c0634e8f Don't try to set_array_info when -I find new devices for an array.
When -I get a new device for a container and tries to incrementally
assemble the container array, it calls sysfs_set_array to create the
array without first checking if it already exists.  This produces
unpleasant error messages.

So check first.

Signed-off-by: NeilBrown <neilb@suse.de>
2008-09-18 17:05:02 +10:00
NeilBrown dbb44303d7 Add support for assembling specific subarrays.
This normally isn't needed as --incremental does all the work.
But it is needed to recognise member= and container= in mdadm.conf
2008-09-18 16:21:08 +10:00
NeilBrown ff54de6e47 Report uuid in --detail --brief for ddf and intel
The uuid is slightly fictitious but needed for array matching.
2008-09-18 16:11:40 +10:00
NeilBrown d7288ddc3a Use uuid as /dev name when assembling array of uncertain origin.
If we aren't sure that the array belongs to 'this' host, use the
uuid to choose a name to avoid any conflict.
2008-09-18 16:08:10 +10:00
NeilBrown 9362c1c80c Allow metadata handler to report that it doesn't record homehost.
For now, this means that the lack of a homehost doesn't always prevent
assembly.
Soon we will allow assembly anyway, but have different messages if
homehost isn't supported.
2008-09-18 16:06:41 +10:00
NeilBrown c5afc314e2 Lots of fixes to make incremental assembly of containers work.
So:
  mdadm -I /dev/whatever

will (if appropriate) add whatever to a container, then start
any arrays inside the container.
2008-09-18 16:03:05 +10:00
NeilBrown 352452c364 Handle incremental assembly of containers.
mdadm -I /dev/part-of-container

should add that to a container, creating if it needed,
and then try to assemble any arrays in the container.

Signed-off-by: NeilBrown <neilb@suse.de>
2008-09-18 16:01:57 +10:00
NeilBrown f35f252592 Move calls to SET_ARRAY_INFO to common helper.
When we assemble an array, there are three different approaches
depending on whether metadata is internal or external, and on
kernel version.

Move all this to a common helper instead of duplicating in 3 places.

Signed-off-by: NeilBrown <neilb@suse.de>
2008-09-18 16:01:55 +10:00
NeilBrown 7801ac2092 Factor out add-disk code
The variety of approaches to 'add_disk' are factored out into
a separate function, and Incremental mode benefits by being
closer to supporting the assembly of containers.

Also remove the adding-to-array-data-structure out of sysfs_add_disk
and into add_disk.

And add some tests for --incremental mode to make sure we don't break it.

Signed-off-by: NeilBrown <neilb@suse.de>
2008-09-18 15:13:32 +10:00
Dan Williams 8ed3e5e1bf Honor safemode_delay at Create() and Incremental() time
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2008-09-15 20:58:42 -07:00
NeilBrown 8850ee3e1e Factor common code into new "start_mdmon".
Signed-off-by: Neil Brown <neilb@suse.de>
2008-07-18 16:37:11 +10:00
Dan Williams 5dcfcb715d mdadm: add an environment variable to prevent auto-launching mdmon
Useful for attaching gdb to mdmon before any action is taken on the array.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2008-07-14 14:59:32 -07:00
Neil Brown d7161f3b51 Fix fd comparison in Incremental
fd==0 is theoretically possible...
2008-07-12 20:28:38 +10:00
Neil Brown b8ac196795 Remove 'major' from superswitch.
It isn't generally meaningful.
2008-07-12 20:27:37 +10:00
Neil Brown 1522c538b1 Use text_version in map_file rather than major.minor. 2008-07-12 20:27:37 +10:00
Neil Brown dd15dc4a4d Discard st->container_member
'container_member' isn't really a well defined concept.
Each metadata might enumerate members differently, so just
let each format /mdX/YYYY as appropriate.
2008-05-27 09:18:56 +10:00
Neil Brown 75aa18b53c Start mdmon during incremental assembly of container 2008-05-27 09:18:52 +10:00
Neil Brown 25dbe93ab4 allow --incremental to reuse devices that already exist
.. and other fixes.
2008-05-27 09:18:43 +10:00
Neil Brown 2318b9f0dc Remove 'fd' arg from sysfs_add_disk
It it never used, and removing means there are several 'open's that can
go.
2008-05-27 09:18:32 +10:00
Dan Williams 5f2aace8eb Set 'metadata_version' for container_member in Incremental_container
From: Dan Williams <dan.j.williams@intel.com>

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2008-05-15 16:48:25 +10:00
Neil Brown 598f0d58ac Can now mostly assemble DDF arrays 2008-05-15 16:48:19 +10:00
Neil Brown 9a02c62af9 Make device-special files for partitions when using --incremental 2008-05-05 21:55:39 +10:00
Neil Brown 63152c1b33 Unify code into find_free_devnum.
Two places have code to find a free md device number.  Make this
a subroutine.
2008-05-05 21:55:36 +10:00
Neil Brown 2cdb64897d Fix for segfault when reading /proc/mdstat
Some kernel versions don't put a space between 'active' and '(auto-read-only)'
in /proc/mdstat.  This causes a parsing problem leaving 'level' set to
NULL which causes a crash.

So synthesise a space there if it is missing, and check for 'level' to
be NULL and don't de-ref if it is.
2008-04-28 16:29:12 +10:00
Neil Brown 7e0f69790c Replace sysarray with mdinfo
Sure, mdinfo is bigger, but having a uniform structure for lots of things
will make life easier.
2007-12-14 20:14:59 +11:00
Neil Brown 06c7f68e40 Use 'mdinfo' instead of special 'sysdev' structure.
there is needless duplicatiion between mdinfo and sysdev, so discard
the latter.
2007-12-14 20:14:57 +11:00
Neil Brown 3da92f272d Drop the superblock arg from all metadata methods.
It is now in the 'supertype'
2007-12-14 20:14:33 +11:00
Neil Brown 68c7d6d790 Add 'supertype' arg to almost all metadata methods.
The 'superblock' will be moved into this structure soon.
2007-12-14 20:14:16 +11:00
Neil Brown df37ffc039 Allow metadata handlers to free their own superblock.
As the metadata handler allocates the superblock, it should free it
too.  DDF will have a more complex 'superblock' which needs more complex
freeing.
2007-12-14 20:14:00 +11:00
Neil Brown f8409e5478 Release 2.6 2006-12-21 17:24:38 +11:00
Neil Brown 8382f19bdc Add new mode: --incremental
--incremental allows arrays to be assembled one device at a time.
This is expected to be used with udev.
2006-12-21 17:10:52 +11:00