]> git.ipfire.org Git - thirdparty/mdadm.git/log
thirdparty/mdadm.git
13 years agoblock monitor: freeze spare assignment for external arrays
Dan Williams [Tue, 23 Nov 2010 04:00:54 +0000 (15:00 +1100)] 
block monitor: freeze spare assignment for external arrays

In order to support reshape and atomic removal of spares from containers
we need to prevent mdmon from activating spares.  In the reshape case we
additionally need to freeze sync_action while the reshape transaction is
initiated with the kernel and recorded in the metadata.

When reshaping a raid0 array we need to freeze the array *before* it is
transitioned to a redundant raid level.  Since sync_action does not exist
at this point we extend the '-' prefix of a subarray string to flag
mdmon not to activate spares.

Mdadm needs to be reasonably certain that the version of mdmon in the
system honors this 'freeze' indication.  If mdmon is not already active
then we assume the version that gets started is the same as the mdadm
version.  Otherwise, we check the version of mdmon as returned by the
extended ping_monitor() operation.  This is to catch cases where mdadm
is upgraded in the filesystem, but mdmon started in the initramfs is
from a previous release.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
13 years agoProvide a mdstat_ent to subarray helper
Dan Williams [Thu, 18 Nov 2010 09:21:29 +0000 (10:21 +0100)] 
Provide a mdstat_ent to subarray helper

...before introducing another open coded instace of this conversion.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
13 years agoAssemble: get content before testing it.
NeilBrown [Tue, 23 Nov 2010 00:34:36 +0000 (11:34 +1100)] 
Assemble: get content before testing it.

When checking that a container matches the required uuid,
we need to call 'getinfo_super' before we have a 'content'
to test.

Reported-by: "Czarnowska, Anna" <anna.czarnowska@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
13 years agoMonitor: check spare group is non-NULL before adding to domain list
NeilBrown [Tue, 23 Nov 2010 00:11:45 +0000 (11:11 +1100)] 
Monitor: check spare group is non-NULL before adding to domain list

... otherwise we crash.

Reported-by: "Labun, Marcin" <Marcin.Labun@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
13 years agoPolicy is aware of metadata disk's controller domains.
Marcin Labun [Mon, 22 Nov 2010 09:58:07 +0000 (20:58 +1100)] 
Policy is aware of metadata disk's controller domains.

Platform (metadata) domain let the metadata handlers differentiate
disk domains based on controllers that the disk belongs to.
Platform domain is sub-domain inside user specified domain
in mdadm.conf configuration files inheriting all parameters from it.
The metadata domain name is used disk domain matching functions.
The disk with the same metadata domain name belong to the same metadata
domain.

New metadata handler is added that retrieves platform domain string based
on disk path:
const char *(*get_disk_controller_domain)(const char *path);

Signed-off-by: Marcin Labun <marcin.labun@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
13 years agoMonitor: Allow metadata to set minimum size for spare to migrate in.
Anna Czarnowska [Mon, 22 Nov 2010 09:58:07 +0000 (20:58 +1100)] 
Monitor: Allow metadata to set minimum size for spare to migrate in.

Signed-off-by: Anna Czarnowska <anna.czarnowska@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
13 years agoMonitor: teach spare migration about containers
NeilBrown [Mon, 22 Nov 2010 09:58:07 +0000 (20:58 +1100)] 
Monitor: teach spare migration about containers

When trying to move a spare, move to the container of a degraded
array, not to the array itself.
And don't try to move from a subarray, only from a native or container
array.
And don't move from a container which contains degraded subarrays.

Signed-off-by: NeilBrown <neilb@suse.de>
13 years agoMonitor: policy based spare migration.
NeilBrown [Mon, 22 Nov 2010 09:58:07 +0000 (20:58 +1100)] 
Monitor: policy based spare migration.

Rather than only migrating between arrays with the same spare_group,
we now migrate based on domains set in the policy.

In order for spare_group to continue to work, we treat it as a domain
of the destination array, and a domain of any device we might remove
from a source array.

Signed-off-by: NeilBrown <neilb@suse.de>
13 years agoMonitor: split out check_donor
NeilBrown [Mon, 22 Nov 2010 09:58:07 +0000 (20:58 +1100)] 
Monitor: split out check_donor

Checking compatibility between arrays for spare migration is going to
become a little more complicated, so split it out into a separate
function.

Signed-off-by: NeilBrown <neilb@suse.de>
13 years agoMonitor: split out move_spare in spare migration.
NeilBrown [Mon, 22 Nov 2010 09:58:07 +0000 (20:58 +1100)] 
Monitor: split out move_spare in spare migration.

This is a simple refactoring with no functionality change.

Signed-off-by: NeilBrown <neilb@suse.de>
13 years agoMonior: create struct for holding alert info.
NeilBrown [Mon, 22 Nov 2010 09:58:07 +0000 (20:58 +1100)] 
Monior: create struct for holding alert info.

Rather than passing mailaddr, mailfrom, cmd, dosyslog around in
argument lists, create a structure to hold them all.

Signed-off-by: NeilBrown <neilb@suse.de>
13 years agoMonitor: use calloc rather than malloc
NeilBrown [Mon, 22 Nov 2010 09:58:07 +0000 (20:58 +1100)] 
Monitor: use calloc rather than malloc

calloc zeros the memory allocated, which is safer, particularly as
we add more things to struct state.

Signed-off-by: NeilBrown <neilb@suse.de>
13 years agoMonitor: minor optimisation to spare migration.
NeilBrown [Mon, 22 Nov 2010 09:58:07 +0000 (20:58 +1100)] 
Monitor: minor optimisation to spare migration.

Only try spare migration if we know that at least one array is
degraded.

Signed-off-by: NeilBrown <neilb@suse.de>
13 years agoimsm: create mdinfo list of disks in a container from supertype
Anna Czarnowska [Mon, 22 Nov 2010 09:58:07 +0000 (20:58 +1100)] 
imsm: create mdinfo list of disks in a container from supertype

If getinfo_super is called on a container supertype we only get information
on first disk. As a parameter it uses reference to preallocated
mdinfo structure. Amending getinfo_super to return full list of disks
would require ammending all previous calls and subsequently freeing memory
allocated for mdinfo list.
Function container_content that returns a mdinfo list is written
specifically for assembly, performing actions not needed to just fill
mdinfo. It also does not include spares so is unsuitable.
As an alternative a new function getinfo_super_disks is created
to obtain information about all disks states in array.
Existing function sysfs_free is used to free memory
allocated by getinfo_super_disks.

Signed-off-by: Anna Czarnowska <anna.czarnowska@intel.com>
Signed-off-by: Marcin Labun <marcin.labun@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
13 years agoMonitor: link containers with subarrays in statelist
Marcin Labun [Mon, 22 Nov 2010 09:58:07 +0000 (20:58 +1100)] 
Monitor: link containers with subarrays in statelist

Each containers has list of its subarrays. Each subarray
has back link to its parent container.

Signed-off-by: Marcin Labun <marcin.labun@intel.com>
Signed-off-by: Anna Czarnowska <anna.czarnowska@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
13 years agoBreak Monitor into smaller functions.
NeilBrown [Mon, 22 Nov 2010 09:58:07 +0000 (20:58 +1100)] 
Break Monitor into smaller functions.

Monitor() has become way too big.  Break it up into multiple smaller
functions that are all called from the main loop.

Signed-off-by: NeilBrown <neilb@suse.de>
13 years agoMonitor: track metadata type or parent/container of arrays.
NeilBrown [Mon, 22 Nov 2010 09:58:07 +0000 (20:58 +1100)] 
Monitor: track metadata type or parent/container of arrays.

For subarrays, record the devid of the parent.
For others arrays, record the metadata type.

This will be used in a subsequent patch to link related arrays
together and allow spare migration between containers.

Signed-off-by: NeilBrown <neilb@suse.de>
13 years agoMonitor: include containers in scan mode
Anna Czarnowska [Mon, 22 Nov 2010 09:58:07 +0000 (20:58 +1100)] 
Monitor: include containers in scan mode

Signed-off-by: Marcin Labun <marcin.labun@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
13 years agoMonitor: avoid skipping checks on external arrays
NeilBrown [Mon, 22 Nov 2010 09:58:06 +0000 (20:58 +1100)] 
Monitor: avoid skipping checks on external arrays

utime is not correct for external metadata so we must
not risk the observed time ever matching the old time.

Reported-by: Anna Czarnowska <anna.czarnowska@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
13 years agomdadm: added --no-sharing option for Monitor mode
Anna Czarnowska [Mon, 22 Nov 2010 09:58:06 +0000 (20:58 +1100)] 
mdadm: added --no-sharing option for Monitor mode

--no-sharing option disables moving spares between arrays/containers.
Without the option spares are moved if needed according to config rules.
We only allow one process moving spares started with --scan option.
If there is such process running and another instance of Monitor
is starting without --scan, then we issue a warning but allow it
to continue.

Signed-off-by: Anna Czarnowska <anna.czarnowska@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
13 years agoMonitor: set err on arrays not in mdstat
Anna Czarnowska [Mon, 22 Nov 2010 09:58:06 +0000 (20:58 +1100)] 
Monitor: set err on arrays not in mdstat

mse can be NULL when the array was not in mdstat when we read it
but existed in statelist and was recreated after reading mdstat.
In this case we set err as we can't get full update on this array
this time.
If the same array is given twice in command line it appears twice
in statelist. The first one will mark mse->devnum=INT_MAX
so the second one can't find mse. We set err on the second one as
it's not needed. Also if it becomes degraded we would look for spares
twice for the same array.

Signed-off-by: Anna Czarnowska <anna.czarnowska@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
13 years agoUtil: get device size from id
Anna Czarnowska [Mon, 22 Nov 2010 09:58:06 +0000 (20:58 +1100)] 
Util: get device size from id

Signed-off-by: Anna Czarnowska <anna.czarnowska@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
13 years agoAdd action=spare-same-slot policy.
NeilBrown [Mon, 22 Nov 2010 09:58:06 +0000 (20:58 +1100)] 
Add action=spare-same-slot policy.

When "mdadm -I" is given a device with no metadata, mdadm tries to add
it as a 'spare' somewhere based on policy.

This patch changes the behaviour in two ways:

1/ If the device is at a 'path' where a previous device was removed
  from an array or container, then we preferentially add the spare to
  that array or container.

2/ Previously only 'bare' devices were considered for adding as
  spares.  Now if action=spare-same-slot is active, we will add
  non-bare devices, but *only* if the path was previously in use
  for some array, and the device will only be added to that array.

Based on code
  From: Przemyslaw Czarnowski <przemyslaw.hawrylewicz.czarnowski@intel.com>

Signed-off-by: Przemyslaw Czarnowski <przemyslaw.hawrylewicz.czarnowski@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
13 years agoincr/spare: recheck allowed action for each metadata.
NeilBrown [Mon, 22 Nov 2010 09:58:06 +0000 (20:58 +1100)] 
incr/spare: recheck allowed action for each metadata.

The current act_spare tests only test if it is allowed for some
metadata.
As we check each array or partitioning type, we need to double-check
that sparing is allowed for that array or partitioning type.

Signed-off-by: NeilBrown <neilb@suse.de>
13 years agoIncr/spare: make sure failure to identify metadata if handled gracefully.
NeilBrown [Mon, 22 Nov 2010 09:58:06 +0000 (20:58 +1100)] 
Incr/spare: make sure failure to identify metadata if handled gracefully.

Signed-off-by: NeilBrown <neilb@suse.de>
13 years agoIncr: fix up return value in try_spare
NeilBrown [Mon, 22 Nov 2010 09:58:06 +0000 (20:58 +1100)] 
Incr: fix up return value in try_spare

We only want to try partition_try_spare if array_try_spare failed.
If it succeeded, there is nothing more to try.

Signed-off-by: NeilBrown <neilb@suse.de>
13 years agoFactor out is_bare test.
NeilBrown [Mon, 22 Nov 2010 09:58:06 +0000 (20:58 +1100)] 
Factor out is_bare test.

Instead of open coding (and using horrible gotos), make this
a separate function.

Also fix the check for end of device - SEEK_END doesn't work on
block devices.

Signed-off-by: NeilBrown <neilb@suse.de>
13 years agoextension of IncrementalRemove to store location (path-id) of removed device
Przemyslaw Czarnowski [Mon, 22 Nov 2010 09:58:06 +0000 (20:58 +1100)] 
extension of IncrementalRemove to store location (path-id) of removed device

If the disk is taken out from its port this port information is
lost. Only udev rule can provide us with this information, and then we
have to store it somehow. This patch adds writing 'cookie' file in
/dev/.mdadm/failed-slots directory in form of file named with value of
f<path-id> containing the metadata type and uuid of the array (or
container) that the device was a member of.  The uuid is in exactly
the same format as in the mapfile.

FAILED_SLOTS_DIR constant has been added to hold the location of
cookie files.

Signed-off-by: Przemyslaw Czarnowski <przemyslaw.hawrylewicz.czarnowski@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
13 years agoTeach IncrementalRemove about containers.
NeilBrown [Mon, 22 Nov 2010 09:58:06 +0000 (20:58 +1100)] 
Teach IncrementalRemove about containers.

When we -I -R a device in a container, we must first fail it
from each member array before we can remove it from the container.

Signed-off-by: NeilBrown <neilb@suse.de>
13 years agoUpdate of udev rules to support IMSM devices
Przemyslaw Czarnowski [Mon, 22 Nov 2010 09:58:06 +0000 (20:58 +1100)] 
Update of udev rules to support IMSM devices

ID_FS_TYPE for IMSM members is set to isw_raid_member, so they must also
be handled in udev.

Signed-off-by: Przemyslaw Czarnowski <przemyslaw.hawrylewicz.czarnowski@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
13 years agoadded --path <path_id> to give the information on the 'path-id' of removed device
Przemyslaw Czarnowski [Mon, 22 Nov 2010 09:58:06 +0000 (20:58 +1100)] 
added --path <path_id> to give the information on the 'path-id' of removed device

<path-id> allows to identify the port to which given device is plugged
in.  In case of hot-removal, udev can pass this information for future
use (eg. write this name as 'cookie' allowing to detect the fact of
reinserting device to the same port).

--path <path-id> parameter has been added to device removal handle
(and char *path has been added to IncrementalRemove() to pass this
value) in order to pass path-id to this handler.

Signed-off-by: Przemyslaw Czarnowski <przemyslaw.hawrylewicz.czarnowski@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
13 years agoRemove loaded_container
NeilBrown [Mon, 22 Nov 2010 09:58:06 +0000 (20:58 +1100)] 
Remove loaded_container

This field is now only set, never used.

So remove it.

Signed-off-by: NeilBrown <neilb@suse.de>
13 years agoimsm: always calculate container_enough in getinfo_super_imsm
NeilBrown [Mon, 22 Nov 2010 09:58:06 +0000 (20:58 +1100)] 
imsm: always calculate container_enough in getinfo_super_imsm

We are about to lose the loaded_container field, and we don't really
need to use it to protect the calculation of container_enough.
So drop the test.

Signed-off-by: NeilBrown <neilb@suse.de>
13 years agoReplace various load_super calls with load_container
NeilBrown [Mon, 22 Nov 2010 09:58:06 +0000 (20:58 +1100)] 
Replace various load_super calls with load_container

When we call load_super expecting to find a container, we now
just call load_container directly.

Signed-off-by: NeilBrown <neilb@suse.de>
13 years agoAssemble: use load_container
NeilBrown [Mon, 22 Nov 2010 09:58:06 +0000 (20:58 +1100)] 
Assemble: use load_container

Separate the load_container call from the load_super call,
and use different validity tests as appropriate.

Add some general code tidying and a bit of indent change to make
structure a little clearer.

Signed-off-by: NeilBrown <neilb@suse.de>
13 years agoAdd must_be_container helper.
NeilBrown [Mon, 22 Nov 2010 09:58:06 +0000 (20:58 +1100)] 
Add must_be_container helper.

This checks a block device to see if it could be a container, and
in particular cannot be a member device.

Signed-off-by: NeilBrown <neilb@suse.de>
13 years agoAssemble: turn next_member goto loop into a for loop.
NeilBrown [Mon, 22 Nov 2010 09:58:06 +0000 (20:58 +1100)] 
Assemble: turn next_member goto loop into a for loop.

It becomes much clearer what is happening now.

Signed-off-by: NeilBrown <neilb@suse.de>
13 years agoAssemble: simplify the handling of is_member_busy.
NeilBrown [Mon, 22 Nov 2010 09:58:06 +0000 (20:58 +1100)] 
Assemble: simplify the handling of is_member_busy.

This is somewhat inconsistent with the last member of a
container getting special handling.
Just simplify it so the code seems to make sense and important
is easy to follow.

Signed-of-by: NeilBrown <neilb@suse.de>
13 years agoAssemble: remove the skip variable.
NeilBrown [Mon, 22 Nov 2010 09:58:06 +0000 (20:58 +1100)] 
Assemble: remove the skip variable.

it seems we don't need it any more

Signed-off-by: NeilBrown <neilb@suse.de>
13 years agoAssemble: merge 'member' test into ident_matches.
NeilBrown [Mon, 22 Nov 2010 09:58:05 +0000 (20:58 +1100)] 
Assemble: merge 'member' test into ident_matches.

This is a more sensible place for it, gathering all the tests
together.

Signed-off-by: NeilBrown <neilb@suse.de>
13 years agoAssemble: change 'skip' label to a variable.
NeilBrown [Mon, 22 Nov 2010 09:58:05 +0000 (20:58 +1100)] 
Assemble: change 'skip' label to a variable.

This gets rid of some gotos which makes the code flow a bit
more clear.

Signed-off-by: NeilBrown <neilb@suse.de>
13 years agoRemove content from mddev_dev
NeilBrown [Mon, 22 Nov 2010 09:58:05 +0000 (20:58 +1100)] 
Remove content from mddev_dev

Now that the next_member loop is much smaller it is easy to
just use 'content' rather than stashing it in 'tmpdev->content'.
So we can remove the 'content' field from 'struct mddev_dev'.

Signed-off-by: NeilBrown <neilb@suse.de>
13 years agoAssemble: contract next_member loop.
NeilBrown [Mon, 22 Nov 2010 09:58:05 +0000 (20:58 +1100)] 
Assemble: contract next_member loop.

We have a 'goto next_member' loop which is rather spread-out and
confusing.
Recent refactoring make it possible to contract that loop
significantly.

Signed-off-by: NeilBrown <neilb@suse.de>
13 years agoAssemble: merge to large 'if' statements.
NeilBrown [Mon, 22 Nov 2010 09:58:05 +0000 (20:58 +1100)] 
Assemble: merge to large 'if' statements.

In assemble, we see (inside a 'for' loop):

 if (condition) {
    lots of stuff
 } else
    something

 small thing

 if (same condition) {
     lots more stuff
     break;
 }

where 'condition' cannot be changed in the middle.

So simplify this to

 if (condition) {
    lots of stuff
    small thing
    lots more stuff
    break;
 }

 something
 small thing

which duplicates the small thing, but provides much
conceptual simplicity.

Signed-off-by: NeilBrown <neilb@suse.de>
13 years agoImprove type names for mddev_dev
NeilBrown [Mon, 22 Nov 2010 09:58:05 +0000 (20:58 +1100)] 
Improve type names for mddev_dev

Remove the _t pointer typedef and remove the _s suffix for the
structure,

These things do not help readability.

Signed-off-by: NeilBrown <neilb@suse.de>
13 years agoImprove mddev_ident type definitions.
NeilBrown [Mon, 22 Nov 2010 09:58:05 +0000 (20:58 +1100)] 
Improve mddev_ident type definitions.

Remove the _t typedef and remove the _s suffix from the struct name.

These things do not help readability.

Signed-off-by: NeilBrown <neilb@suse.de>
13 years agoAssemble: factor out ident_matches
NeilBrown [Mon, 22 Nov 2010 09:58:05 +0000 (20:58 +1100)] 
Assemble: factor out ident_matches

This will help future patch, and we need to make "Assemble()" smaller
anyway.

Signed-off-by: NeilBrown <neilb@suse.de>
13 years agoAssemble: small cleanup of error checking.
NeilBrown [Mon, 22 Nov 2010 09:58:05 +0000 (20:58 +1100)] 
Assemble: small cleanup of error checking.

If we get an early error (e.g. not a block device) we need to
not continue through and check e.g. uuid.

Also make sure we set used=2 whenever we find an error, and don't
bother with ->free_super as 'goto loop' does that.

Now that we abort earlier, we can remove lots of tests on
  tst && tst->sb

Signed-off-by: NeilBrown <neilb@suse.de>
13 years agoUse load_container in Incremental assembly.
NeilBrown [Mon, 22 Nov 2010 09:57:58 +0000 (20:57 +1100)] 
Use load_container in Incremental assembly.

We more clearly separate out -I on a container, and use
load_container in that case and load_super only for true members.

This removes another use of loaded_container.

Signed-off-by: NeilBrown <neilb@suse.de>
13 years agoIncremental: Factor out search of mdstat
NeilBrown [Mon, 22 Nov 2010 09:24:50 +0000 (20:24 +1100)] 
Incremental: Factor out search of mdstat

As we will soon use it in two places.

Signed-off-by: NeilBrown <neilb@suse.de>
13 years agoMake Incremental_container static
NeilBrown [Mon, 22 Nov 2010 09:24:50 +0000 (20:24 +1100)] 
Make Incremental_container static

as it is only used in Incremental.c

Signed-off-by: NeilBrown <neilb@suse.de>
13 years agoSwitch open_subarray to use the new load_container
NeilBrown [Mon, 22 Nov 2010 09:24:50 +0000 (20:24 +1100)] 
Switch open_subarray to use the new load_container

This removes another user of loaded_container

Signed-off-by: NeilBrown <neilb@suse.de>
13 years agoUse new load_container in Examine
NeilBrown [Mon, 22 Nov 2010 09:24:50 +0000 (20:24 +1100)] 
Use new load_container in Examine

This makes explicit the two different ways to use Examine
And removes a user of container_loaded.

Signed-off-by: NeilBrown <neilb@suse.de>
13 years agoNew method: load_container
NeilBrown [Mon, 22 Nov 2010 09:24:50 +0000 (20:24 +1100)] 
New method: load_container

This handles the 'container' part of 'load_super', so we can
soon make them completely separate - it is just confusing to
overload these two.

Signed-off-by: NeilBrown <neilb@suse.de>
13 years agoRemove keep_fd arg from load_super_XXX_all
NeilBrown [Mon, 22 Nov 2010 09:24:50 +0000 (20:24 +1100)] 
Remove keep_fd arg from load_super_XXX_all

It is always set to 1, so we don't need it.

Signed-off-by: NeilBrown <neilb@suse.de>
13 years agoRemove subarray field in supertype.
NeilBrown [Mon, 22 Nov 2010 09:24:50 +0000 (20:24 +1100)] 
Remove subarray field in supertype.

This is now only ever set, never used.
So remove it.

Signed-off-by: NeilBrown <neilb@suse.de>
13 years agoCreate: user container_dev rather than subarray for some tests.
NeilBrown [Mon, 22 Nov 2010 09:24:50 +0000 (20:24 +1100)] 
Create: user container_dev rather than subarray for some tests.

It makes more sense to test for container_dev than for subarray
for several places in Create where it then uses container_dev.

This allows us to subsequently remove subarray.

Signed-off-by: NeilBrown <neilb@suse.de>
13 years agoUse container_member rather than subarray info ddf getinfo_super.
NeilBrown [Mon, 22 Nov 2010 09:24:50 +0000 (20:24 +1100)] 
Use container_member rather than subarray info ddf getinfo_super.

We are in the processes of discarding the subarray field, so remove
the unnecessary use of it.

Signed-off-by: NeilBrown <neilb@suse.de>
13 years agoRemove subarray detection from load_super.
NeilBrown [Mon, 22 Nov 2010 09:24:50 +0000 (20:24 +1100)] 
Remove subarray detection from load_super.

Nothing relies on this any more, so remove it.

Signed-off-by: NeilBrown <neilb@suse.de>
13 years agoPass subarray arg explicitly to ->update_subarray.
NeilBrown [Mon, 22 Nov 2010 09:24:50 +0000 (20:24 +1100)] 
Pass subarray arg explicitly to ->update_subarray.

This is better than hiding it in the supertype structure
where we are never quite sure who needs it.

Signed-off-by: NeilBrown <neilb@suse.de>
13 years agoUse new container_content rather than passing subarray to load_super.
NeilBrown [Mon, 22 Nov 2010 09:24:35 +0000 (20:24 +1100)] 
Use new container_content rather than passing subarray to load_super.

Now that we can ask container_content for a specific subarray,
we don't need to pass the subarray name to load_super, and have it
secretly modify the returned state.

Signed-off-by: NeilBrown <neilb@suse.de>
13 years agoAdd subarray arg to container_content.
NeilBrown [Mon, 22 Nov 2010 08:35:26 +0000 (19:35 +1100)] 
Add subarray arg to container_content.

This allows the info for a single array to be extracted,
so we don't have to write it into st->subarray.

For consistency, implement container_content for super0 and super1,
to just return the mdinfo for the single array.

Signed-off-by: NeilBrown <neilb@suse.de>
13 years agomapinfo: simplify subarray handling.
NeilBrown [Mon, 22 Nov 2010 08:35:25 +0000 (19:35 +1100)] 
mapinfo: simplify subarray handling.

We don't need ->container_dev here, and we will soon be passing
subarray as an explicit arg to load_super.
So simplify extraction of subarray and move the strcpy close to
->load_super.

Signed-off-by: NeilBrown <neilb@suse.de>
13 years agosuper_by_fd: return subarray info explicitly.
NeilBrown [Mon, 22 Nov 2010 08:35:25 +0000 (19:35 +1100)] 
super_by_fd: return subarray info explicitly.

Rather than hiding this in the 'st', return it explicitly.

In the one case we still need it, copy it into st where needed.
This will disappear in a future patch.

Signed-off-by: NeilBrown <neilb@suse.de>
13 years agoopen_subarray: pass subarray name as explicit arg.
NeilBrown [Mon, 22 Nov 2010 08:35:25 +0000 (19:35 +1100)] 
open_subarray: pass subarray name as explicit arg.

Rather than hiding this arg in the 'st' structure, pass it explicitly.

This is a first step to getting rid of 'subarray' from 'supertype'.

The strcpy in open_subarray should have better error checking, but it
will disappear soon so there is little point.

Signed-off-by: NeilBrown <neilb@suse.de.
13 years agoddf: remove duplicate container_member setting.
NeilBrown [Mon, 22 Nov 2010 08:35:25 +0000 (19:35 +1100)] 
ddf: remove duplicate container_member setting.

We were setting ->container_member twice in ddf get_info.
Once to currentconf->vcnum,
once to atoi(st->subarray).

Both should be the same.
For consistency with super-intel, use the first.

Signed-off-by: NeilBrown <neilb@suse.de>
13 years agoIncremental - fix small bug in count_active.
NeilBrown [Mon, 22 Nov 2010 08:35:25 +0000 (19:35 +1100)] 
Incremental - fix small bug in count_active.

If the first device found has a much smaller event count than a
subsequent device, that device will not be entered in the 'avail'
array properly.

Signed-off-by: NeilBrown <neilb@suse.de>
13 years agoAssemble - avoid including wayward devices.
NeilBrown [Mon, 22 Nov 2010 08:35:25 +0000 (19:35 +1100)] 
Assemble - avoid including wayward devices.

If a device - typically in a mirrored set - is assembled independently
of the other devices, and then attempted to be brought back into the
set it could contain inconsistent data.  It should not be included.

So detect this situation by ensuring that the 'most recent' device is
believed to be active by every other device.  If a device is wayward,
it will only consider fellow wayward devices to be active and will
think all others are failed or missing.

This patch only fixes --assemble, not --incremental

Signed-off-by: NeilBrown <neilb@suse.de>
13 years agoAssemble: handle devices array better.
NeilBrown [Mon, 22 Nov 2010 08:35:25 +0000 (19:35 +1100)] 
Assemble: handle devices array better.

Only allocate when it is about to be used, and free it when finished.

Signed-off-by: NeilBrown <neilb@suse.de>
13 years agoget_info_super: report which other devices are thought to be working/failed.
NeilBrown [Mon, 22 Nov 2010 08:35:25 +0000 (19:35 +1100)] 
get_info_super:  report which other devices are thought to be working/failed.

To accurately detect when an array has been split and is now being
recombined, we need to track which other devices each thinks is
working.

We should never include a device in an array if it thinks that the
primary device has failed.

This patch just allows get_info_super to return a list of devices
and whether they are thought to be working or not.

Signed-off-by: NeilBrown <neilb@suse.de>
13 years agodetail/wait: better handling of monitoring sync action.
NeilBrown [Mon, 22 Nov 2010 08:35:25 +0000 (19:35 +1100)] 
detail/wait: better handling of monitoring sync action.

Detail: report reshape and check as well as resync and recovery
Wait: if the resync is pending or delayed, wait for that too.

Signed-off-by: NeilBrown <neilb@suse.de>
13 years agoManage: be more careful about --add attempts.
NeilBrown [Mon, 22 Nov 2010 08:35:25 +0000 (19:35 +1100)] 
Manage:  be more careful about --add attempts.

If an --add is requested and a re-add looks promising but fails or
cannot possibly succeed, then don't try the add.  This avoids
inadvertently turning devices into spares when an array is failed but
the devices seem to actually work.

Signed-off-by: NeilBrown <neilb@suse.de>
13 years agopolicy: don't try to get policy when path == NULL.
NeilBrown [Mon, 22 Nov 2010 08:35:25 +0000 (19:35 +1100)] 
policy: don't try to get policy when path == NULL.

config_rules_has_path, we fail if path==NULL, so we should when
config_rules doesn't has_path too.

Signed-Off-By: NeilBrown <neilb@suse.de>
13 years agoFix error in pol_sort.
NeilBrown [Mon, 22 Nov 2010 08:35:25 +0000 (19:35 +1100)] 
Fix error in pol_sort.

pol_sort could go into an infinite loop.

The proof of this patch is left as a exercise for the reader :-)

Reported-by: "Hawrylewicz Czarnowski, Przemyslaw" <przemyslaw.hawrylewicz.czarnowski@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
13 years agoReport error in --update string is not recognised.
NeilBrown [Mon, 22 Nov 2010 08:35:24 +0000 (19:35 +1100)] 
Report error in --update string is not recognised.

If an --update is requested by the relevant metadata doesn't
understand it, print a useful message rather than silently ignoring
the issue.

Signed-off-by: NeilBrown <neilb@suse.de>
13 years agomdadm.8: man page improvements concerning reshape and metadata types.
John Robinson [Wed, 3 Nov 2010 03:08:00 +0000 (23:08 -0400)] 
mdadm.8: man page improvements concerning reshape and metadata types.

- other differences between 0.90 and 1.x metadata explained
- reshape text enhanced to properly acknowledge shrinks and in-place
  reshapes, particularly in the context of --backup-file.

Signed-off-by: NeilBrown <neilb@suse.de>
13 years agoFix byte-order conversion in update_super1("assemble")
NeilBrown [Thu, 16 Sep 2010 10:58:31 +0000 (20:58 +1000)] 
Fix byte-order conversion in update_super1("assemble")

This code is wrong is several ways, and failed on big-endian machines.
Put in correct endian coversions: 'want' is cpu-order, dev_roles[] is little-endian,
16 bit.

Reported-by: Doug Nazar <nazard.michi@gmail.com>
Signed-off-by: NeilBrown <neilb@suse.de>
13 years agoConvert 'auto' config line to policy statements
NeilBrown [Thu, 2 Sep 2010 11:21:36 +0000 (21:21 +1000)] 
Convert 'auto' config line to policy statements

13 years agoAdd support for auto-partitioning base devices.
NeilBrown [Thu, 2 Sep 2010 04:30:03 +0000 (14:30 +1000)] 
Add support for auto-partitioning base devices.

If a device is bare and policy suggests that it can be used as a spare
for virtual 'partitions' array, find an appropriate partition table
and write it to the device.

Signed-off-by: NeilBrown <neilb@suse.de>
13 years agoAdd guess_super_type
NeilBrown [Thu, 2 Sep 2010 01:54:06 +0000 (11:54 +1000)] 
Add guess_super_type

This can select to only guess array types,
or only guess partition types.

Signed-off-by: NeilBrown <neilb@suse.de>
13 years agoFactor out path_policy functon.
NeilBrown [Thu, 2 Sep 2010 00:04:26 +0000 (10:04 +1000)] 
Factor out path_policy functon.

Allow disk-policy to be computed given the path and
disk type explicitly.  This can be used when hunting through
/dev/disk/by-path for something interesting.

Signed-off-by: NeilBrown <neilb@suse.de>
13 years agoFirst steps to supporting auto-spare-add to groups of partitioned devices.
NeilBrown [Wed, 1 Sep 2010 07:27:23 +0000 (17:27 +1000)] 
First steps to supporting auto-spare-add to groups of partitioned devices.

Adding a spare to a group of partitioned devices is quite different
from adding one to an array.  So detect which option is worth trying
based on policy and then try one or the other - or possibly both - as
appropriate.

Signed-off-by: NeilBrown <neilb@suse.de>
13 years agoAdd gpt pseudo-metadata
NeilBrown [Fri, 20 Aug 2010 03:10:50 +0000 (13:10 +1000)] 
Add gpt pseudo-metadata

This allows mdadm to work with gpt metadata to a limited extent.

Signed-off-by: NeilBrown <neilb@suse.de>
13 years agoAdd mbr pseudo metadata handler.
NeilBrown [Thu, 19 Aug 2010 06:48:34 +0000 (16:48 +1000)] 
Add mbr pseudo metadata handler.

To support incorpating a new bare device into a collection of arrays -
one partition each - mdadm needs a modest understanding of partition
tables.
The main needs to be able to recognise a partition table on one device
and copy it onto another.

This will be done using pseudo metadata types 'mbr' and 'gpt'.

Signed-off-by: NeilBrown <neilb@suse.de>
13 years agointel: Don't try to read from tiny devices.
NeilBrown [Wed, 1 Sep 2010 06:14:26 +0000 (16:14 +1000)] 
intel: Don't try to read from tiny devices.

If a device is less than 1K, avoid even trying to seek to 1K before
the end.
The seek will fail anyway so this is a fairly cosmetic fix.

Signed-off-by: NeilBrown <neilb@suse.de>
13 years agoAllow --incremental to add a device as a spare if policy allows.
NeilBrown [Mon, 23 Aug 2010 06:34:23 +0000 (16:34 +1000)] 
Allow --incremental to add a device as a spare if policy allows.

If policy allows act_spare or act_force_spare, -I will add a
bare device as a spare to an appropriate array.

We don't support adding non-bare devices as spares yet.

Signed-off-by: NeilBrown <neilb@suse.de>
13 years agoUse action policy to keep recently-disconnected devices in the array.
NeilBrown [Mon, 23 Aug 2010 05:54:13 +0000 (15:54 +1000)] 
Use action policy to keep recently-disconnected devices in the array.

When we find a device that was recently part of the array but is now
out of date (based on the event count) we might want to add it back in
(like --re-add) if the likely cause was a connection problem or we
might not if the likely cause was device failure.

So make this a policy issue: if action=re-add or better, try to re-add
any device that looks like it might be part of the array.

This applies:
  when we assemble the array:  old devices will be evicted by the
     kernel and need to be re-added.
  when we assemble the array during --incr for the same reason.
  when we find a device that could be added to a running array.

This doesn't affect arrays with external metadata at all.
For such arrays:
 When the container is assembled, the most recent instance of each
 device is included without reference to whether it is too old or not.
 Then the metadata handler must which slices of which devices to
 include in which array and with what state.  So the
 ->container_content should probably check the policy and compare the
 sequence numbers/event counts.
 When a device is added (--add) to a container with active arrays
 we only add as a 'spare'. --re-add doesn't seem to be an option.
 When a device is added with -I ->container_content gets another
 chance to assess things again.  So again it should check the policy.

Signed-off-by: NeilBrown <neilb@suse.de>
13 years agoIntroduce single-exit pattern for Incremental
NeilBrown [Mon, 23 Aug 2010 06:59:50 +0000 (16:59 +1000)] 
Introduce single-exit pattern for Incremental

All exits should goto the end for clean-up.

Signed-off-by: NeilBrown <neilb@suse.de>
13 years agoAdd domain policy support.
NeilBrown [Mon, 23 Aug 2010 05:36:08 +0000 (15:36 +1000)] 
Add domain policy support.

A device can be in a number of domains.

The domains of an array is the union of the domains of all devices.

A device is allowed to join an array when its set of domains is a
subset of the array's domains.

Signed-off-by: NeilBrown <neilb@suse.de>
13 years agoAdd policy_action support
NeilBrown [Mon, 23 Aug 2010 04:33:28 +0000 (14:33 +1000)] 
Add policy_action support

Add code for easy working 'action' policies.

Signed-off-by: NeilBrown <neilb@suse.de>
13 years agoAdd policy framework.
NeilBrown [Mon, 5 Jul 2010 00:11:21 +0000 (10:11 +1000)] 
Add policy framework.

Policy can be stated as lines in mdadm.conf like:

POLICY  type=disk path=pci-0000:00:1f.2-* action=ignore domain=onboard

This defines two distinct policies which apply to any disk (but not
partition) device reached through the pci device 0000:00:1f.2.
The policies are "action=ignore" which means certain actions will
ignore the device, and "domain=onboard" which means all such devices
as treated as being united under the name 'onboard'.

This patch just adds data structures and code to read and
manipulate them.  Future patches will actually use them.

Signed-off-by: NeilBrown <neilb@suse.de>
13 years agoFix compile error on non-x86 systems.
NeilBrown [Fri, 3 Sep 2010 03:33:29 +0000 (13:33 +1000)] 
Fix compile error on non-x86 systems.

-z is not an option for 'gcc', it is an option for the loader!!

Reported-by: Debian build system
Signed-off-by: NeilBrown <neilb@suse.de>
13 years agoRelease mdadm-3.1.4 mdadm-3.1.4
NeilBrown [Tue, 31 Aug 2010 05:41:12 +0000 (15:41 +1000)] 
Release mdadm-3.1.4

bugfix/stability.

Signed-off-by: NeilBrown <neilb@suse.de>
13 years agoFix spare migration.
NeilBrown [Tue, 31 Aug 2010 07:20:58 +0000 (17:20 +1000)] 
Fix spare migration.

Spare migration uses major:minor device names.
When we added support for kernel style names, we broke that.

Signed-off-by: NeilBrown <neilb@suse.de>
13 years agoDon't remove md devices with standard names.
NeilBrown [Tue, 31 Aug 2010 05:21:40 +0000 (15:21 +1000)] 
Don't remove md devices with standard names.

If udev is not in use, we create device in /dev when assembling
arrays and remove them when stopping the array.

However it may not always be correct to remove the device.  If
the array was started with kernel auto-detect, them mdadm didn't
create anything and so shouldn't remove anything.

We don't record whether we created things, so just don't remove
anything with a 'standard' name.  Only remove symlinks to the
standard name as we almost certainly created those.

Reported-by: Petre Rodan <petre.rodan@avira.com>
Signed-off-by: NeilBrown <neilb@suse.de>
13 years agoAllow dev_open to work on read-only /dev
NeilBrown [Sun, 29 Aug 2010 22:48:48 +0000 (08:48 +1000)] 
Allow dev_open to work on read-only /dev

/dev could be read-only in which case we cannot make devices
there.
So dev_open should first try to use an existing device name,
and if that doesn't work try creating a node in /dev or /tmp.

Reported-by: Paweł Sikora <pluto@agmk.net>
Signed-off-by: NeilBrown <neilb@suse.de>
13 years agoAllow --incremental to add spares to an array.
NeilBrown [Thu, 12 Aug 2010 01:41:41 +0000 (11:41 +1000)] 
Allow --incremental to add spares to an array.

Commit 3a6ec29ad56 stopped us from adding apparently-working devices
to an active array with --incremental as there is a good chance that they
are actually old/failed devices.

Unfortunately it also stopped spares from being added to an active
array, which is wrong.  This patch refines the test to be more
careful.

Reported-by: <fibreraid@gmail.com>
Analysed-by: Dan Williams <dan.j.williams@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
13 years agoIncremental: accept '--no-degraded' as a deprecated option
Dan Williams [Mon, 9 Aug 2010 17:26:24 +0000 (10:26 -0700)] 
Incremental: accept '--no-degraded' as a deprecated option

Commit 3288b419 (Revert "Incremental: honor --no-degraded to delay assembly")
killed the --no-degraded flag since commit 97b4d0e9 (Incremental: honor
an 'enough' flag from external handlers) made this the default behavior
of -I, and brought -I usage for external/container formats in line with
native metadata.  However, this breaks existing usages of '-I
--no-degraded', so allow it as a deprecated option.

Starting a degraded container, like the native metadata case, requires -R.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
Reported-by: Ignacy Kasperowicz <ignacy.kasperowicz@intel.com>
13 years agoIncremental: return success in 'container not enough' case
Dan Williams [Tue, 10 Aug 2010 15:44:45 +0000 (08:44 -0700)] 
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>
13 years agoDon't link mdadm with pthreads
NeilBrown [Fri, 6 Aug 2010 10:11:43 +0000 (20:11 +1000)] 
Don't link mdadm with pthreads

Only mdmon needs pthreads, so link accordingly.

Signed-off-by: NeilBrown <neilb@suse.de>
Reported-by: martin f krafft <madduck@madduck.net>