]> git.ipfire.org Git - thirdparty/mdadm.git/log
thirdparty/mdadm.git
13 years agofix array_size in child_monitor
NeilBrown [Tue, 11 Jan 2011 23:37:26 +0000 (10:37 +1100)] 
fix array_size in child_monitor

The array_size we need to consider is the largest possible size of the
array, which is a different calculation depending on whether the array
is growing or shrinking.

Signed-off-by: NeilBrown <neilb@suse.de>
13 years agoFix calculations for max_progress and completed.
NeilBrown [Tue, 11 Jan 2011 23:34:44 +0000 (10:34 +1100)] 
Fix calculations for max_progress and completed.

'sync_completed' can sometimes have a value which is slightly high.
So round-down relevant values to new-chunk size and that is what we
want.

Subtract from component_size after scaling down rather than before as
that is easier.
Make sure max_progress never goes negative when reshaping backwards.

Signed-off-by: NeilBrown <neilb@suse.de>
13 years agoImprove determination of when a backup is needed.
NeilBrown [Tue, 11 Jan 2011 04:20:40 +0000 (15:20 +1100)] 
Improve determination of when a backup is needed.

The current code is right.
Instead compute where we might eventually need to back up to, and
then compare that to how far we have progressed.

Also move suspend_point up towards where we might need to backup to,
rather than just as far as max_progress - as max_progress can never
exceed where we are currently suspended to.

Signed-off-by: NeilBrown <neilb@suse.de>
13 years agoRemove write_range from calculation of max_progress
NeilBrown [Tue, 11 Jan 2011 04:07:57 +0000 (15:07 +1100)] 
Remove write_range from calculation of max_progress

It isn't needed as we always work in multiples of full
destination stripes.

Also multiply by 'after' disks, not before.

We can progress until the point we would write then lines up with
where we would read now.
We read now from
  array-address: reshape_progress   device-address: read_offset
So we write then to
  device-address: read_offset    array-address:  read_offset * after.disks

Signed-off-by: NeilBrown <neilb@suse.de>
13 years agoSwitch calculations of read_offset and write_offset
NeilBrown [Tue, 11 Jan 2011 03:57:14 +0000 (14:57 +1100)] 
Switch calculations of read_offset and write_offset

These were backwards...  we read from 'before' and write to 'after'.

Signed-off-by: NeilBrown <neilb@suse.de>
13 years agoAvoid confusing with 'blocks' number.
NeilBrown [Tue, 11 Jan 2011 03:51:09 +0000 (14:51 +1100)] 
Avoid confusing with 'blocks' number.

The 'blocks' number computed by analyse_change is the number of
blocks that it makes sense to back-up at a time.
It is the smallest number of blocks that is a whole number of
stripes in both the old and the new layout.

However we are also using it as the smallest amount of progress
that can be made at a time, which is wrong as it is always valid
to progress a single stripe in the new layout.

So change 'blocks' to be called 'backup_blocks' to make it more clear.
And pass new_chunk size down so it can be used for 'minimum forward
progress' calculations.

Also set 'stripes' (the amount actually backed up) from the
possibly-scaled 'blocks' number rather than ignoring it and using
backup_blocks.

Finally, get rid of 'read_range' as it isn't used (or needed).

Signed-off-by: NeilBrown <neilb@suse.de>
13 years agoCorrectly abort level change when reshape_array fails.
NeilBrown [Tue, 11 Jan 2011 03:41:49 +0000 (14:41 +1100)] 
Correctly abort level change when reshape_array fails.

We were returning too early.

Signed-off-by: NeilBrown <neilb@suse.de>
13 years agoMisc reshape_array fixes.
NeilBrown [Tue, 11 Jan 2011 03:41:48 +0000 (14:41 +1100)] 
Misc reshape_array fixes.

1/ test on spares_needed is backwards
2/ stray white space
3/ reuse a goto instead of explicit exit().

Signed-off-by: NeilBrown <neilb@suse.de>
13 years agoAvoid double-unfreeze of arrays during grow.
NeilBrown [Tue, 11 Jan 2011 03:41:47 +0000 (14:41 +1100)] 
Avoid double-unfreeze of arrays  during grow.

Once we have called reshape_container or reshape_super we have handed
on the responsibility for unfreezing the array, so Grow_reshape
shouldn't call unfreeze.

Signed-off-by: NeilBrown <neilb@suse.de>
13 years agoanalyse_change fixes
NeilBrown [Tue, 11 Jan 2011 03:41:46 +0000 (14:41 +1100)] 
analyse_change fixes

When converting to RAID6, the new layout should match the old
layout, not the RAID6 version of the old layout.

Signed-off-by: NeilBrown <neilb@suse.de>
13 years agoFix some typos in fprintf messages.
NeilBrown [Tue, 11 Jan 2011 03:41:42 +0000 (14:41 +1100)] 
Fix some typos in fprintf messages.

Signed-off-by: NeilBrown <neilb@suse.de>
13 years agoGrow: fix type when 'or'ing flags together.
NeilBrown [Tue, 11 Jan 2011 03:16:11 +0000 (14:16 +1100)] 
Grow: fix type when 'or'ing flags together.

'||' should have been '|'

Signed-off-by: NeilBrown <neilb@suse.de>
13 years agoEnsure start_reshape copes with unexpected state
NeilBrown [Tue, 11 Jan 2011 02:23:16 +0000 (13:23 +1100)] 
Ensure start_reshape copes with unexpected state

We want start_reshape to work no matter what the current values
of suspend_lo/suspend_hi are.  So initialise suspend_lo very high
as this allows suspend_hi to be set to anything.

Signed-off-by: NeilBrown <neilb@suse.de>
13 years agoRaid0: detect reshape on array start
Adam Kwolek [Thu, 6 Jan 2011 08:27:25 +0000 (19:27 +1100)] 
Raid0: detect reshape on array start

When raid0 array is takeovered to raid4 for reshape it should be possible to detect
that array for reshape is monitored now for metadata update.

Signed-off-by: Adam Kwolek <adam.kwolek@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
13 years agoimsm: FIX: do not repair raid4 arrays
Adam Kwolek [Thu, 6 Jan 2011 08:20:25 +0000 (19:20 +1100)] 
imsm: FIX: do not repair raid4 arrays

As raid4 is not supported by imsm (this is takeovered raid0)
do not fix degraded raid4 arrays.

Signed-off-by: Adam Kwolek <adam.kwolek@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
13 years agoRaid0: execute backward takeover
Adam Kwolek [Thu, 6 Jan 2011 08:20:01 +0000 (19:20 +1100)] 
Raid0: execute backward takeover

After raid0 reshape is finished backward takeover has to be executed.

Signed-off-by: Adam Kwolek <adam.kwolek@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
13 years agoDetect level change
Adam Kwolek [Thu, 6 Jan 2011 08:17:29 +0000 (19:17 +1100)] 
Detect level change

For level migration support it is necessary to allow mdmon to react for level changes.
It has to have ability to change configuration of active array,
and for array level change to raid0 finish array monitoring.

Signed-off-by: Maciej Trela <maciej.trela@intel.com>
Signed-off-by: Adam Kwolek <adam.kwolek@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
13 years agoimsm: Update raid0 metadata for reshape
Adam Kwolek [Thu, 6 Jan 2011 08:14:24 +0000 (19:14 +1100)] 
imsm: Update raid0 metadata for reshape

When raid0 reshape is performed metadata has to be applied by mdadm.
(without mdmon)

Signed-off-by: Adam Kwolek <adam.kwolek@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
13 years agoimsm: Move reshape update processing to function
NeilBrown [Thu, 6 Jan 2011 08:10:04 +0000 (19:10 +1100)] 
imsm: Move reshape update processing to function

For code reuse in raid0 reshape case when monitor is not loaded.

Signed-off-by: Adam Kwolek <adam.kwolek@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
13 years agoAdd spares to raid0 in mdadm
Adam Kwolek [Thu, 6 Jan 2011 07:42:53 +0000 (18:42 +1100)] 
Add spares to raid0 in mdadm

When user wants to add spares to container with raid0 arrays only
it is not possible to update metadata due to lack of running mdmon.
To allow for this direct metadata update by mdadm is used in such case.

Signed-off-by: Krzysztof Wojcik <krzysztof.wojcik@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
13 years agoimsm: Update metadata for second array
Adam Kwolek [Thu, 6 Jan 2011 07:29:23 +0000 (18:29 +1100)] 
imsm: Update metadata for second array

When second array reshape is about to start metadata should be updated
by mdmon in imsm_set_array_state().

Signed-off-by: Adam Kwolek <adam.kwolek@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
13 years agoSet array size after adding new disks
Adam Kwolek [Thu, 6 Jan 2011 07:29:20 +0000 (18:29 +1100)] 
Set array size after adding new disks

When new disks are added array size has to be set by mdadm as array grows.

Signed-off-by: Adam Kwolek <adam.kwolek@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
13 years agoimsm: update array size information in metadata
Adam Kwolek [Thu, 6 Jan 2011 07:29:15 +0000 (18:29 +1100)] 
imsm: update array size information in metadata

When disks are added size has to increase in metadata.
This size should be used by common code to set size in md when reshape will be finished.

Signed-off-by: Adam Kwolek <adam.kwolek@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
13 years agoimsm: FIX: Division by 0
Adam Kwolek [Thu, 6 Jan 2011 07:29:11 +0000 (18:29 +1100)] 
imsm: FIX: Division by 0

For general migration function blocks_per_migr_unit() has to return valid value.
If there is no valid return, 0 is returned instead and causes division by 0 error.
Additionally guard in function was added for such case.

Signed-off-by: Adam Kwolek <adam.kwolek@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
13 years agoimsm: Finalize reshape in metadata
Adam Kwolek [Thu, 6 Jan 2011 07:29:07 +0000 (18:29 +1100)] 
imsm: Finalize reshape in metadata

When reshape is finished monitor calls set_array_state() and finishes migration in metadata.
This change allows for finishing metadata migration on reshape end.

Signed-off-by: Adam Kwolek <adam.kwolek@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
13 years agoFIX: Use sysfs to change array parameters
Adam Kwolek [Thu, 6 Jan 2011 07:29:03 +0000 (18:29 +1100)] 
FIX: Use sysfs to change array parameters

For external metadata parameters has to be changed via sysfs.
i.e. change of raid_disks requires handshake mdmon<->md (md_allow_write())

Signed-off-by: Adam Kwolek <adam.kwolek@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
13 years agoFIX: Get array information in reshape_array()
Adam Kwolek [Thu, 6 Jan 2011 07:29:02 +0000 (18:29 +1100)] 
FIX: Get array information in reshape_array()

Uninitialized array structure is used.

Signed-off-by: Adam Kwolek <adam.kwolek@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
13 years agoimsm: FIX: support general migration by getinfo_super_imsm_volume
Adam Kwolek [Thu, 6 Jan 2011 07:28:56 +0000 (18:28 +1100)] 
imsm: FIX: support general migration by getinfo_super_imsm_volume

Add support for reading volume information during migration process.

Signed-off-by: Adam Kwolek <adam.kwolek@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
13 years agoimsm: FIX: update first array in container only
Adam Kwolek [Tue, 4 Jan 2011 14:36:57 +0000 (15:36 +0100)] 
imsm: FIX: update first array in container only

During first metadata update imsm for compatibility reason should update
only one array.
Buffers in prepare_update() are prepared for second update as well.

Signed-off-by: NeilBrown <neilb@suse.de>
13 years agoFIX: get updated information from metadata
Adam Kwolek [Thu, 6 Jan 2011 05:56:05 +0000 (16:56 +1100)] 
FIX: get updated information from metadata

Metadata is not modified by metadata preparation handler.
It has to be read again from array.
There is 2 read required:
1. before 'for' entry to get updated information after reshape_super() call
2. inside 'for' loop to get updated information for every processed array
  (it can happen /i.e. imsm case/ that container operation is a set of array operations
   and information in metadata is changed after every loop).

Signed-off-by: Adam Kwolek <adam.kwolek@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
13 years agoimsm: FIX: Perform first metadata update for container operation
Adam Kwolek [Thu, 6 Jan 2011 05:24:07 +0000 (16:24 +1100)] 
imsm: FIX: Perform first metadata update for container operation

Meta data was not updated due to the following problems:
1.disk index < 0 was treated as invalid, but this is spare device
2. disk index greater than currently used disks is correct also
3. newmap pointer has to be refreshed for second map copy operation
4. size calculation has to be guarded for shrinking operation

Signed-off-by: Adam Kwolek <adam.kwolek@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
13 years agoimsm: FIX: display error message
Adam Kwolek [Thu, 6 Jan 2011 05:22:01 +0000 (16:22 +1100)] 
imsm: FIX: display error message

When container operation is not allowed user has to get proper information on console about it
Currently this information was displayed as debug info only.

Signed-off-by: Adam Kwolek <adam.kwolek@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
13 years agoimsm: FIX: display correct information for '-E' option
Adam Kwolek [Thu, 6 Jan 2011 05:11:35 +0000 (16:11 +1100)] 
imsm: FIX: display correct information for '-E' option

Correct information displayed by '-E' option.
1. FIX: Slot information during raid0 migration is displayed incorrectly
        (missing disk position is taken from wrong map)
2. Improvement: information about (level, members, chunk size) migration is displayed.

Signed-off-by: Adam Kwolek <adam.kwolek@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
13 years agomdadm: second_map enhancement for imsm_get_map()
Adam Kwolek [Thu, 6 Jan 2011 05:08:04 +0000 (16:08 +1100)] 
mdadm: second_map enhancement for imsm_get_map()

Allow map related operations for the given map: first of second.
For reshape specific functionality it is required to have an access

Until now, the active map was chosen according to the current volume status.

Signed-off-by: Maciej Trela <maciej.trela@intel.com>
Signed-off-by: Adam Kwolek <adam.kwolek@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
13 years agoFIX: Position calculation in mdstat_by_subdev
Krzysztof Wojcik [Thu, 6 Jan 2011 05:07:20 +0000 (16:07 +1100)] 
FIX: Position calculation in mdstat_by_subdev

Signed-off-by: Krzysztof Wojcik <krzysztof.wojcik@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
13 years agoRefactor reshape monitoring.
NeilBrown [Thu, 6 Jan 2011 04:58:32 +0000 (15:58 +1100)] 
Refactor reshape monitoring.

Combine all the non-backing-up code into a single function:
progress_reshape.  It is called repeatedly to monitor a
reshape and allow it to happen safely.

Have a single separate function 'child_monitor' which
performs backups of data and calls progress_reshape to
wait for the next backup to be needed.

Signed-off-by: NeilBrown <neilb@suse.de>
13 years agoGrow_reshape re-factor
NeilBrown [Thu, 6 Jan 2011 04:58:00 +0000 (15:58 +1100)] 
Grow_reshape re-factor

Significant rewrite/refactor of Grow_reshape to make it easier to work
with externally-managed-metadata.

This patch it too big, but we'll just have to live with that.

Signed-off-by: NeilBrown <neilb@suse.de>
13 years agoIncremental: move suitable spares to container when subarrays started.
Anna Czarnowska [Wed, 5 Jan 2011 03:42:27 +0000 (14:42 +1100)] 
Incremental: move suitable spares to container when subarrays started.

By default Incremental places all imsm spares in separate container
with uuid=0:0:0:0. (patch giving spares uuid_zero needed)

When we find enough members to start an array
we are able to determine domain so we search spare container
for suitable spares and move them to the container that
is currently assembled.

Signed-off-by: Anna Czarnowska <anna.czarnowska@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
13 years agomove_spare function modified and moved to Manage.c
Anna Czarnowska [Wed, 5 Jan 2011 03:34:32 +0000 (14:34 +1100)] 
move_spare function modified and moved to Manage.c

It will also be needed for Incremental.

Signed-off-by: Anna Czarnowska <anna.czarnowska@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
13 years agoUse one function chosing spares from container
Anna Czarnowska [Wed, 5 Jan 2011 03:34:14 +0000 (14:34 +1100)] 
Use one function chosing spares from container

container_chose_spares in Monitor.c and
get_spares_for_grow in super-intel.c
do the same thing: search for spares in a container.

Another version will also be needed for Incremental
so a more general solution is presented here and
applied in two previous contexts.

Normally domlist==NULL would lead an empty list but
this is typically checked earlier so here it is interpreted
as "do not test domains".

Signed-off-by: Anna Czarnowska <anna.czarnowska@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
13 years agoAssemble: allow to assemble spares on their own
Anna Czarnowska [Wed, 5 Jan 2011 02:54:18 +0000 (13:54 +1100)] 
Assemble: allow to assemble spares on their own

If we find spares but no members of given array
we create container with just spares.

This allows auto assemble to pick up all lose imsm spares when there
is no config file.
When there is a valid config file and any array is assembled from it
we don't try auto assembly so we will not assemble spares that don't
match any array.
To remedy this we must add
ARRAY metadata=imsm UUID=00000000:00000000:00000000:00000000
to config file.
This container will include all remaining spares.

Signed-off-by: Anna Czarnowska <anna.czarnowska@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
13 years agoAssemble: we need to read policy to know array domains
Anna Czarnowska [Wed, 5 Jan 2011 02:42:59 +0000 (13:42 +1100)] 
Assemble: we need to read policy to know array domains

Policy must be read on all disks identified as array members
to get array's domains list.
Currently it is only read on first array member in auto assembly mode.

Signed-off-by: Anna Czarnowska <anna.czarnowska@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
13 years agoConsider target only for spare-same-domain
Przemyslaw Czarnowski [Sun, 26 Dec 2010 11:38:44 +0000 (22:38 +1100)] 
Consider target only for spare-same-domain

otherwise, matching target will force spare-same-domain regardless of
action that comes in domain.

Signed-off-by: NeilBrown <neilb@suse.de>
13 years agoValidate size of potential spare disk for external metadata (with containers)
Przemyslaw Czarnowski [Sun, 26 Dec 2010 11:38:42 +0000 (22:38 +1100)] 
Validate size of potential spare disk for external metadata (with containers)

mdinfo read with sysfs_read do not contain information about the space
needed to store data of all volumes created in that container, so that
spare can be used as replacement for existing subarrays in the future.

Signed-off-by: NeilBrown <neilb@suse.de>
13 years agoSkip domain check for spare-same-slot
Przemyslaw Czarnowski [Sun, 26 Dec 2010 11:36:46 +0000 (22:36 +1100)] 
Skip domain check for spare-same-slot

If lost disk was the only one that belonged to particular domain, array
won't match with that domain any longer. We can achieve this by moving
domain check below the 'target' test.

Signed-off-by: NeilBrown <neilb@suse.de>
13 years agoAdded test for array degradation for spare-same-slot
Przemyslaw Czarnowski [Sun, 26 Dec 2010 11:33:14 +0000 (22:33 +1100)] 
Added test for array degradation for spare-same-slot

spare-same-slot allows re-adding of missing array member with disk
re-inserted into the same slot where previous member was plugged in.
If in the meantime another spare has been used for recovery, same slot
cookie should be ignored.

Signed-off-by: Przemyslaw Czarnowski <przemyslaw.hawrylewicz.czarnowski@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
13 years agoexternal: get number of failed disks for container
Przemyslaw Czarnowski [Sun, 26 Dec 2010 11:31:25 +0000 (22:31 +1100)] 
external: get number of failed disks for container

Container degradation here is defined as the number of failed disks in
mostly degraded sub-array. This number is used as value for
array.failed_disks and used in comparison to find best match.

Signed-off-by: Przemyslaw Czarnowski <przemyslaw.hawrylewicz.czarnowski@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
13 years agoAssemble imsm spares in matching domain only
Anna Czarnowska [Sun, 26 Dec 2010 11:08:51 +0000 (22:08 +1100)] 
Assemble imsm spares in matching domain only

Imsm spare will only be taken if it matches domain of
identified members of currently assembled array.

This implies that:
- spare with null domain will match first array assembled.
- if array has null domain then no spare will match

If we allow spares to set st they may block assembly of subarrays.
This is because in auto-assembly tmpdev->used=0 for a spare not matching
any array. If we find such spare before container and set st, the content
will not get assembled.

We allow uuid_zero match any uuid in assembly as unsuitable spares will
be rejected on domain check.

Signed-off-by: Anna Czarnowska <anna.czarnowska@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
13 years agoimsm: set imsm spare uuid to 0
Anna Czarnowska [Sun, 26 Dec 2010 10:59:31 +0000 (21:59 +1100)] 
imsm: set imsm spare uuid to 0

uuid_match_any is replaced by uuid_zero for imsm spares.

Function fixup_container_spare_uuid not needed as it gives
unwanted uuid to spares.

Signed-off-by: Anna Czarnowska <anna.czarnowska@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
13 years agoEnable tests for OLCE, takeover, migrations for imsm metadata
Krzysztof Wojcik [Sun, 26 Dec 2010 10:59:14 +0000 (21:59 +1100)] 
Enable tests for OLCE, takeover, migrations for imsm metadata

Patch provides set of tests for On-line Capacity Expansion,
takeover, migrations operations for imsm metadata type.
Tests are grouped by operation type:
12 - On-line Capacity Expansion on one volume
13 - On-line Capacity Expansion on two volumes
14 - Negative tests for takeover, migrations
15 - Chunk size migrations
16 - raid0 -> raid5, raid5 -> raid0 migrations
18 - takeover operations
To run particular test group, following command should be executed:
(from mdadm's source code root directory)
./test <group number>
Example:
To run On-line Capacity Expansion on one volume tests:
./test 12
Tests execution results:
- In case of test pass, "succeeded" word is printed on console
- If test is failed, "FAILED" word is printed on console
and logs are stored in <mdadm-root-dir>/tests/log/ directory

Signed-off-by: Artur Wojcik <artur.wojcik@intel.com>
Signed-off-by: Krzysztof Wojcik <krzysztof.wojcik@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
13 years agoFIX: Bad block verification during assembling array
Krzysztof Wojcik [Thu, 16 Dec 2010 13:34:54 +0000 (14:34 +0100)] 
FIX: Bad block verification during assembling array

We need to refuse to assemble an arrays with bad blocks.
Initially there was condition in container_content function
that returns error value in the case when metadata store information
about bad blocks.
When the container_content function is called from functions NOT connected
with assemble (Kill_subarray, Detail) we get faulty error return value.
Patch introduces new flag in array.status - MD_SB_BBM_ERRORS. It is set
in container_content when bad blocks are detected and can be checked by
container_content caller.

Signed-off-by: Krzysztof Wojcik <krzysztof.wojcik@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
13 years agoRemove stray 'free' in block_monitor.
NeilBrown [Mon, 20 Dec 2010 22:14:10 +0000 (09:14 +1100)] 
Remove stray 'free' in block_monitor.

This value is passed in by caller so we should not be
freeing it.

Reported-by: "Wojcik, Krzysztof" <krzysztof.wojcik@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
13 years agofix: incremental for bare disks returns invalid value
Przemyslaw Czarnowski [Mon, 20 Dec 2010 22:11:34 +0000 (09:11 +1100)] 
fix: incremental for bare disks returns invalid value

return value should remain the same as result of Manage_Subdevs (last
significant operation). Right now it is inverted what results in
error status for successful operation.

Signed-off-by: NeilBrown <neilb@suse.de>
13 years agofix: adding spare via incremental do not trigger recovery
Przemyslaw Czarnowski [Mon, 20 Dec 2010 22:10:32 +0000 (09:10 +1100)] 
fix: adding spare via incremental do not trigger recovery

After incremental has added spare, monitor should be woken up in order
to see if anything has changed. If mdmon is not waken up, recovery do not
start.

Signed-off-by: NeilBrown <neilb@suse.de>
13 years agoMonitor: Check destination array domain early.
Marcin Labun [Thu, 16 Dec 2010 14:16:12 +0000 (15:16 +0100)] 
Monitor: Check destination array domain early.

Destination arrays that do not have any domains are excluded
from spare sharing. We can check it early, without searching
for donor arrays.

Signed-off-by: Marcin Labun <marcin.labun@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
13 years agomdmon-design.txt
NeilBrown [Thu, 16 Dec 2010 11:12:26 +0000 (22:12 +1100)] 
mdmon-design.txt

Add document discussing design on mdmon

Signed-off-by: NeilBrown <neilb@suse.de>
13 years agoimsm: Fill delta_disks field in getinfo_super()
Adam Kwolek [Thu, 16 Dec 2010 04:55:40 +0000 (15:55 +1100)] 
imsm: Fill delta_disks field in getinfo_super()

delta_disks field is not always filled during getinfo_super() call.

Signed-off-by: Adam Kwolek <adam.kwolek@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
13 years agoimsm: Do not indicate resync during reshape
Adam Kwolek [Thu, 16 Dec 2010 04:48:27 +0000 (15:48 +1100)] 
imsm: Do not indicate resync during reshape

If reshape is started resync is not allowed in parallel. This would
break reshape.  If array is in General Migration state do not indicate
resync and allow for reshape continuation.

Signed-off-by: Adam Kwolek <adam.kwolek@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
13 years agoHandle checkpointing during reshape
NeilBrown [Thu, 16 Dec 2010 04:48:05 +0000 (15:48 +1100)] 
Handle checkpointing during reshape

We need to allow metadata to handle progress of reshape,
completion, and abort-before-start.

Include all those in ->set_array_state()

Signed-off-by: NeilBrown <neilb@suse.de>
13 years agoimsm: Block array state change during reshape
Adam Kwolek [Thu, 16 Dec 2010 02:17:47 +0000 (13:17 +1100)] 
imsm: Block array state change during reshape

Array state change is blocked due to reshape action in progress
metadata changes are during applying.

'1' is returned to indicate that array is clean

Signed-off-by: Adam Kwolek <adam.kwolek@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
13 years agoimsm: Process reshape_update in mdmon
Adam Kwolek [Thu, 16 Dec 2010 02:17:45 +0000 (13:17 +1100)] 
imsm: Process reshape_update in mdmon

For this update prepare_update() allocates memory to relink imsm
(bigger) device imsm structures. It calculates new /bigger/ anchor
size.

Process update applies update in to imsm structures.  This includes
 - converting selected spares into configured devices
 - marking the arrays as migrating
 - making a new 'map' for each array with the changed details.

Signed-off-by: Adam Kwolek <adam.kwolek@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
13 years agoAllow a metadata update to have a linked list of allocated spaces.
NeilBrown [Thu, 16 Dec 2010 01:10:01 +0000 (12:10 +1100)] 
Allow a metadata update to have a linked list of allocated spaces.

Sometimes one metadata update will require allocating several
larger data structures.  As 'monitor' cannot allocate, 'manager'
must, so it must be able to attach a list of allocates to the
update, and importantly it must be able to easily free them.

So add a 'space_list' element to metadata updates where each
element on the list starts with a pointer to the next.

Signed-off-by: NeilBrown <neilb@suse.de>
13 years agoimsm: Prepare reshape_update in mdadm
NeilBrown [Thu, 16 Dec 2010 00:45:21 +0000 (11:45 +1100)] 
imsm: Prepare reshape_update in mdadm

During Online Capacity Expansion metadata has to be updated to show
array changes and allow for future assembly of array.  To do this
mdadm prepares and sends reshape_update metadata update to mdmon.
The update contains the old and new number of raid disks, and the
indices of the spare disks that will be used to fill the spaces.

This works as follows:
1. reshape_super() prepares metadata update.
2. mdadm discovers the spares and adds them to the array
3. mdadm sends the update to mdmon
4. managemon in prepare_update() allocates required memory for bigger
   device object
5. monitor in process_update() updates the metadata to record the
   new sizes and the newly assigned devices.
6. mdadm initiates the reshape

Based on code From: Adam Kwolek <adam.kwolek@intel.com>

Signed-off-by: Krzysztof Wojcik <krzysztof.wojcik@intel.com>
Signed-off-by: Adam Kwolek <adam.kwolek@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
13 years agoimsm: add spares to --examine output.
NeilBrown [Thu, 16 Dec 2010 00:33:23 +0000 (11:33 +1100)] 
imsm: add spares to --examine output.

When we examine a container, list the spare devices as well as
the active devices.

Signed-off-by: NeilBrown <neilb@suse.de>
13 years agomdmon: when a reshape is detected, add any newly added devices to the array.
NeilBrown [Wed, 15 Dec 2010 22:07:52 +0000 (09:07 +1100)] 
mdmon: when a reshape is detected, add any newly added devices to the array.

When mdadm starts a reshape, it might add some devices to the array
first.  mdmon needs to notice the reshape starting and check for any
new devices.  If there are any they need to be provided to be
monitored.

Signed-off-by: NeilBrown <neilb@suse.de>
13 years agoGrow: add disks chosen by metadata handler to array for growth.
NeilBrown [Wed, 15 Dec 2010 22:07:52 +0000 (09:07 +1100)] 
Grow: add disks chosen by metadata handler to array for growth.

With externally managed container based metadata, the ->reshape_super
method must choose any spares that are to be added to the array.
They should be prepared so that ->container_content will find them
as spares (disk.state == 0) which are assigned to a slot
(raid_disk >= 0).
We need to take those and add them to the array(s).

Signed-off-by: NeilBrown <neilb@suse.de>
13 years agoGrow: call start/abort_reshape as appropriate when reshaping a container.
NeilBrown [Wed, 15 Dec 2010 22:07:52 +0000 (09:07 +1100)] 
Grow: call start/abort_reshape as appropriate when reshaping a container.

This means that ->manage_reshape will be called with reshape ready to
roll.

Also move the current start_reshape call earlier so that it is before
the other ->manage_reshape call.

Signed-off-by: NeilBrown <neilb@suse.de>
13 years agoGrow: make sure rv is set correctly in reshape_container_raid_disks
NeilBrown [Wed, 15 Dec 2010 22:07:52 +0000 (09:07 +1100)] 
Grow: make sure rv is set correctly in reshape_container_raid_disks

Whenever there is an error, rv must be -1.

Signed-off-by: NeilBrown <neilb@suse.de>
13 years agoGrow: split out start_reshape for initiating reshape via sysfs.
NeilBrown [Wed, 15 Dec 2010 22:07:52 +0000 (09:07 +1100)] 
Grow: split out start_reshape for initiating reshape via sysfs.

Rather than sprinkling various sysfs setting around, put them all
in one place.  This will make implementing ->manage_reshape easier.

This changes behaviour slightly.
Previously we would not set 'sync_action' to 'reshape' until we were
ready for the process to start.  Now we set sync_max to zero and set
sync_action to 'reshape' at that time.  When we want reshape to
actually start we advance sync_max.

Signed-off-by: NeilBrown <neilb@suse.de>
13 years agoGrow: fix calculation of stripe_cache_size when reshaping.
NeilBrown [Wed, 15 Dec 2010 22:07:52 +0000 (09:07 +1100)] 
Grow: fix calculation of stripe_cache_size when reshaping.

The two places that this was done were different.  The original was
most correct, thought it used odisks rather than odata.

So fix that and make them both use the same calculation.

Signed-off-by: NeilBrown <neilb@suse.de>
13 years agoGrow: be more careful about metadata updates.
NeilBrown [Wed, 15 Dec 2010 22:07:51 +0000 (09:07 +1100)] 
Grow: be more careful about metadata updates.

1/ When we sunc_metadata, we must reset ->update_tail else
   future metadata updates might go direct to the device bypassing
   mdmon.

2/ When converting to an array with redundancy so we can add disks
   it is neater to sync_metadata before starting mdmon rather that
   artificially setting update_tail early.

Signed-off-by: NeilBrown <neilb@suse.de>
13 years agoGrow: be extra careful about races when freezing an array
NeilBrown [Wed, 15 Dec 2010 22:07:51 +0000 (09:07 +1100)] 
Grow: be extra careful about races when freezing an array

If any subarray has any spare devices, then something raced,
and we should abort the reshape.

Signed-off-by: NeilBrown <neilb@suse.de>
13 years agoGrow: check container is idle before freezing it.
NeilBrown [Wed, 15 Dec 2010 22:07:51 +0000 (09:07 +1100)] 
Grow: check container is idle before freezing it.

Before we freeze a container in preparation for growing a subarray, we
need to be sure all the subarrays are idle.

This test is racy as recovery could start at any moment following a
failure.  However it is still useful as it stops us from even trying
to start a reshape while a reshape or recovery is active.

Signed-off-by: NeilBrown <neilb@suse.de>
13 years agoSplit fmt_devnum out from devnum2devname
NeilBrown [Wed, 15 Dec 2010 22:07:51 +0000 (09:07 +1100)] 
Split fmt_devnum out from devnum2devname

Sometimes we want to convert a devnum to a devname without allocating
memory.  So provide function to do the formatting without allocation.

Signed-off-by: NeilBrown <neilb@suse.de>
13 years agoUpdate external reshape documentation.
NeilBrown [Wed, 15 Dec 2010 22:07:51 +0000 (09:07 +1100)] 
Update external reshape documentation.

Revise documentation for external reshape, correcting some problems,
and clarifying some issues.

Signed-off-by: NeilBrown <neilb@suse.de>
13 years agoimsm: FIX: imsm_add_spare() wrongly tests spares list
Adam Kwolek [Wed, 15 Dec 2010 09:38:15 +0000 (10:38 +0100)] 
imsm: FIX: imsm_add_spare() wrongly tests spares list

For more than one disk tested additional_test_list was searched from last
point, not from begin.

This bug causes that more than 2 disks cannot be added to imsm array,
when imsm_add_spare() is used for this.

Signed-off-by: Adam Kwolek <adam.kwolek@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
13 years agofix: Monitor doesn't return after starting daemon
Anna Czarnowska [Wed, 15 Dec 2010 04:51:53 +0000 (15:51 +1100)] 
fix: Monitor doesn't return after starting daemon

Signed-off-by: Anna Czarnowska <anna.czarnowska@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
13 years agoIMSM: do not rebuild the array if a non-redundant sub-array with failed disks is...
Labun, Marcin [Wed, 15 Dec 2010 04:51:53 +0000 (15:51 +1100)] 
IMSM: do not rebuild the array if a non-redundant sub-array with failed disks is present

Before looking for a spare to rebuild a degraded array, check if there
are any failed disks in container.  Block rebuild if another sub-array
is failed until failed disks are removed from container.

Currently, Intel metadata handler rebuilds all sub-arrays even if one
of them is non-redundant. In case of failed sub-array, failed disks
are just replaced with new ones in the metadata mapping. The data for
failed disk is not restored even the disk is present in the system.

With this fix, we require the removal of the failed disk from
container to start the process of rebuilding the array with failed
member. If the disk is physically pulled out of the system, the disk
is removed from container automatically by exiting udev rules.

Signed-off-by: Marcin Labun <marcin.labun@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
13 years agoIMSM: Fix problem in mdmon monitor of using removed disk in imsm container.
Labun, Marcin [Wed, 15 Dec 2010 04:51:51 +0000 (15:51 +1100)] 
IMSM: Fix problem in mdmon monitor of using removed disk in imsm container.

Manager thread shall pass the information to monitor thread (mdmon)
that some devices are removed from container.  Otherwise, monitor
(mdmon) might use such devices (spares) to rebuild the array that has
gone degraded.

This problem happens for imsm containers, since a list of the
container disks is maintained in intel_super structure. When array
goes degraded, the list is searched to find a spare disks to start
rebuild.  Without this fix the rebuild could be stared on the spare
device that was a member of the container, but has been removed from
it.

New super type function handler has been introduced to prepare
metadata format specific information about removed devices.

int (*remove_from_super)(struct supertype *st, mdu_disk_info_t *dinfo)

The message prepared in remove_from_super is later processed by
process_update handler in monitor thread.

Signed-off-by: Marcin Labun <marcin.labun@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
13 years agoMerge branch 'master' into devel-3.2
NeilBrown [Mon, 13 Dec 2010 03:00:05 +0000 (14:00 +1100)] 
Merge branch 'master' into devel-3.2

Conflicts:
super-intel.c

13 years agosegfault in imsm create with wrong arguments
Luca Berra [Sun, 12 Dec 2010 10:33:55 +0000 (11:33 +0100)] 
segfault in imsm create with wrong arguments

When calling mdadm -C --metadata=imsm -l 1 /dev/sd..
mdadm segfaults in default_chunk_imsm()
above syntax is incorrect, but mdadm should error instead of segfaulting

Signed-off-by: Luca Berra <bluca@comedia.it>
Signed-off-by: NeilBrown <neilb@suse.de>
13 years agoAllow --update=devicesize with --re-add
NeilBrown [Thu, 9 Dec 2010 02:06:29 +0000 (13:06 +1100)] 
Allow --update=devicesize with --re-add

This is useful with 1.1 and 1.2 metadata to update the metadata if
the device size has changed.
The same functionality can be achieved by writing to the device size
in sysfs after re-adding normally, but in some cases this might be
easier.

Signed-off-by: NeilBrown <neilb@suse.de>
13 years agoGrow: warn if growing an array will make it degraded.
NeilBrown [Thu, 9 Dec 2010 00:51:13 +0000 (11:51 +1100)] 
Grow: warn if growing an array will make it degraded.

Growing an array when there aren't enough spares can make the array
degraded.  This works but might not be what is wanted.
So warn the user in this case and require a --force to go ahead
with the reshape.

Signed-off-by: NeilBrown <neilb@suse.de>
13 years agoMerge branch 'master' into devel-3.2
NeilBrown [Thu, 9 Dec 2010 00:16:42 +0000 (11:16 +1100)] 
Merge branch 'master' into devel-3.2

Conflicts:
mdadm.8.in

Same conceptual change was written with different words in each version.
Signed-off-by: NeilBrown <neilb@suse.de>
13 years agofix: mdstat_read() incorrectly translates value of mdstat_ent->reshape for recovering
Hawrylewicz Czarnowski, Przemyslaw [Wed, 8 Dec 2010 11:30:28 +0000 (11:30 +0000)] 
fix: mdstat_read() incorrectly translates value of mdstat_ent->reshape for recovering

it results in wrong output of mdadm --detail (shows reshaping instead
of recovering)

Signed-off-by: Przemyslaw Czarnowski <przemyslaw.hawrylewicz.czarnowski@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
13 years agofix: mdadm -Ss for external metadata don't stop container
Hawrylewicz Czarnowski, Przemyslaw [Tue, 7 Dec 2010 06:44:21 +0000 (06:44 +0000)] 
fix: mdadm -Ss for external metadata don't stop container

Sometimes (~50%) mdadm -Ss cannot stop container as mdmon opens its device
and do not close it before exit(). The period between open and release of
handle is too long and md is not able stop device. Releasing handle before
exit does not block md.

Signed-off-by: Przemyslaw Czarnowski <przemyslaw.hawrylewicz.czarnowski@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
13 years agofix: incremental on invalid container causes segfault
Hawrylewicz Czarnowski, Przemyslaw [Mon, 6 Dec 2010 06:40:40 +0000 (06:40 +0000)] 
fix: incremental on invalid container causes segfault

counterpart of 417f346ee0 for incremental.
If md device has metadata_version="none" super_by_fd() matches
supertype=super0.
Call of load_container() dereferences null, so we have to forbid it.

Signed-off-by: Przemyslaw Czarnowski <przemyslaw.hawrylewicz.czarnowski@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
13 years agoFIX: wait_backup() sometimes hungs
Adam Kwolek [Fri, 3 Dec 2010 10:33:55 +0000 (21:33 +1100)] 
FIX: wait_backup() sometimes hungs

Sometimes wait_backup() omits transition from reshape to idle state
and mdadm seams to be hung.  So check the 'complete' count
*before* waiting rather than only after.

Signed-off-by: Adam Kwolek <adam.kwolek@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
13 years agoFIX: Honor !reshape state on wait_reshape() entry
Adam Kwolek [Fri, 3 Dec 2010 04:10:20 +0000 (15:10 +1100)] 
FIX: Honor !reshape state on wait_reshape() entry

When wait_reshape() function starts it can occurs that reshape is
finished already, before wait_reshape() start. This can lead to wait
for change state inside this function for a long time.  To avoid this
before wait we should test if finish conditions are not reached
already.

Signed-off-by: Adam Kwolek <adam.kwolek@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
13 years agoFIX: sync_completed_fd handler has to be closed
Adam Kwolek [Fri, 3 Dec 2010 04:07:04 +0000 (15:07 +1100)] 
FIX: sync_completed_fd handler has to be closed

sync_completed_fd handler has to be closed when array is closing.
This is in pair to open handler code.

Signed-off-by: Adam Kwolek <adam.kwolek@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
13 years agoFIX: Do not use layout for raid4 and raid0 while geo map computing
Adam Kwolek [Fri, 3 Dec 2010 04:03:25 +0000 (15:03 +1100)] 
FIX: Do not use layout for raid4 and raid0 while geo map computing

After takeover, layout has no meaning for computing geo map for raid0
and raid4.  Set layout to 0 for such cases.  It can happen after
takeover operation when not all array information is reread.

Signed-off-by: Adam Kwolek <adam.kwolek@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
13 years agoGrow: open backup file for reshape as function
Adam Kwolek [Fri, 3 Dec 2010 04:00:16 +0000 (15:00 +1100)] 
Grow: open backup file for reshape as function

Move opening backup file to the function for future reuse during
container reshape.

Signed-off-by: Adam Kwolek <adam.kwolek@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
13 years agoAdd support to skip slot configuration
Adam Kwolek [Thu, 2 Dec 2010 08:19:12 +0000 (09:19 +0100)] 
Add support to skip slot configuration

When disk is added, set valid slot numbers (positive) only.

Signed-off-by: Adam Kwolek <adam.kwolek@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
13 years agoFIX: Cannot exit monitor after takeover
Adam Kwolek [Thu, 2 Dec 2010 08:18:49 +0000 (09:18 +0100)] 
FIX: Cannot exit monitor after takeover

When performing backward takeover to raid0 monitor cannot exit
for single raid0 array configuration.
Monitor is locked by communication (ping_manager()) after unfreeze()

Do not ping manager for raid0 array as they shouldn't be monitored.

Signed-off-by: Adam Kwolek <adam.kwolek@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
13 years agoMonitor: don't add more spares than needed
Anna Czarnowska [Fri, 3 Dec 2010 03:11:29 +0000 (14:11 +1100)] 
Monitor: don't add more spares than needed

When we add a spare to a container it takes a while
before it is noticed by mdmon and recovery starts.
During this time the array remains degraded but we don't want to add
any more spares to this container. Therefore we must check container
with degraded array if it doesn't already have a suitable spare.
container_choose_spare is reused with from=to
Domain check is not needed in this situation.

Ping_manager after moving disk is needed to be able to see
newly added disk in container after coming back through the loop.

Signed-off-by: Anna Czarnowska <anna.czarnowska@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
13 years agoMonitor: only get min_size once
Anna Czarnowska [Fri, 3 Dec 2010 03:05:11 +0000 (14:05 +1100)] 
Monitor: only get min_size once

We may call chose_spare several times before we find a suitable one
so it is better to get the size beforehand.

Signed-off-by: Anna Czarnowska <anna.czarnowska@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
13 years agoMonitor: pass statelist reference when adding new arrays
Anna Czarnowska [Tue, 30 Nov 2010 12:44:45 +0000 (13:44 +0100)] 
Monitor: pass statelist reference when adding new arrays

Otherwise it will not get updated.

Signed-off-by: Anna Czarnowska <anna.czarnowska@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
13 years agoCreate/grow: improve checks on number of devices.
NeilBrown [Wed, 1 Dec 2010 03:51:27 +0000 (14:51 +1100)] 
Create/grow: improve checks on number of devices.

Check on upper limit of number of devices was in the wrong place.
Result was could not create array with more than 27 devices without
explicitly setting metadata, even though default metadata allows more.

Fixed, and also perform check when growing an array.

Signed-off-by: NeilBrown <neilb@suse.de>
13 years agoGrow: disallow placing backup file on array being reshaped.
NeilBrown [Wed, 1 Dec 2010 00:58:32 +0000 (11:58 +1100)] 
Grow: disallow placing backup file on array being reshaped.

the tests here aren't perfect, but they could catch some cases.

Signed-off-by: NeilBrown <neilb@suse.de>
13 years agoAssemble: allow an array undergoing reshape to be started without backup file
NeilBrown [Wed, 1 Dec 2010 00:47:32 +0000 (11:47 +1100)] 
Assemble: allow an array undergoing reshape to be started without backup file

Though not having the proper backup file can cause data corruption, it
is not enough to justify not being able to start the array at all.
So allow "--invalid-backup" to be specified which says "just continue
even if a backup cannot be restored".

Signed-off-by: NeilBrown <neilb@suse.de>