Commit Graph

471 Commits

Author SHA1 Message Date
NeilBrown d33f151842 Change some fprintf(stderrs to cont_err()
Signed-off-by: NeilBrown <neilb@suse.de>
2013-05-21 12:51:33 +10:00
NeilBrown ed503f89e4 Change some "fprintf(stderr,"s to pr_err.
They just keep slipping in..

Signed-off-by: NeilBrown <neilb@suse.de>
2013-05-21 12:42:57 +10:00
NeilBrown 93f174b986 Grow: set_new_data_offset should report if kernel is too old.
For RAID5, not being able to set new_data_offset because of
old kernel is not a problem.  So make this fatal on for RAID10.

Also remove an unused assignment to 'rv'.

Signed-off-by: NeilBrown <neilb@suse.de>
2013-05-21 12:34:24 +10:00
NeilBrown 033d0929ad comment typo 2013-05-21 12:25:21 +10:00
NeilBrown 50a4962f0f Grow: just pass delta_disks instead of all of 'info'.
That is all we need, so make purpose of code more obvious
by only passing delta_disks.

Signed-off-by: NeilBrown <neilb@suse.de>
2013-05-21 11:55:44 +10:00
NeilBrown 13bbb145cd Grow: split out code for setting new_data_offset
This will soon be used for more than just RAID10, so
it deserves independent existence.

Signed-off-by: NeilBrown <neilb@suse.de>
2013-05-21 11:53:43 +10:00
NeilBrown 5582b118c6 Grow: replace '1' with 'INVALID_SECTORS' where appropriate.
Here are some '1's which missed the introduction of INVALID_SECTORS
as a useful #define.

Signed-off-by: NeilBrown <neilb@suse.de>
2013-05-21 11:32:57 +10:00
NeilBrown 4dd2df0966 Discard devnum in favour of devnm
We widely use a "devnum" which is 0 or +ve for md%d devices
and -ve for md_d%d devices.
But I want to be able to use md_%s device names.

So get rid of devnum (a number) and use devnm (a 32char string).
eg.
  md0
  md_d2
  md_home

Signed-off-by: NeilBrown <neilb@suse.de>
2013-02-21 17:05:23 +11:00
NeilBrown fdcad551e9 Grow: fix problem with reshaping RAID4 to RAID0.
As 'layout' doesn't map neatly from RAID4 to RAID5, we need to
set it correctly for RAID4.
Also, when no reshape is needed we should set re->level to the final
desired level.

Signed-off-by: NeilBrown <neilb@suse.de>
2013-02-21 17:02:21 +11:00
NeilBrown 3920235ea2 Grow: disallow --size changes on RAID0 and Linear.
These aren't meaningful and must be disabled.

Signed-off-by: NeilBrown <neilb@suse.de>
2013-02-21 14:51:11 +11:00
NeilBrown ae0dcfbdb2 Grow: fix bug when multiple arrays present.
commit 1f9b0e2845
    Grow - be careful about 'delayed' reshapes.

Introduced a bug where a list of devices longer than 1
would cause an infinite loop.  Oops.

Signed-off-by: NeilBrown <neilb@suse.de>
2012-11-22 08:57:25 +11:00
Lukasz Dorau f3f09a520f Grow.c: fix uninitialized variables compilation-time error
It fixes the following uninitialized variables compilation-time error:
WARN  - Grow.c: In function ‘reshape_array’:
WARN  - Grow.c:2413:21: error: ‘min_space_after’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
WARN  - Grow.c:2376:39: note: ‘min_space_after’ was declared here
WARN  - Grow.c:2414:22: error: ‘min_space_before’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
WARN  - Grow.c:2376:21: note: ‘min_space_before’ was declared here
WARN  - cc1: all warnings being treated as errors
WARN  - make: *** [Grow.o] Error 1
It occurs during compilation of mdadm on Fedora 17.

Signed-off-by: Lukasz Dorau <lukasz.dorau@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
2012-11-20 12:12:03 +11:00
NeilBrown 6a67848ab6 Grow: fix reshape from RAID5 to RAID1.
Commit 5da9ab9874
       Grow_reshape re-factor
in mdadm-3.2 broke conversion from RAID5 and RAID1 - and we
never noticed.

This fixes it.

Signed-off-by: NeilBrown <neilb@suse.de>
2012-11-20 12:06:34 +11:00
NeilBrown 869523878e Grow: fix a couple of typos with --assume-clean usage
Signed-off-by: NeilBrown <neilb@suse.de>
2012-10-11 11:35:41 +11:00
NeilBrown e0ab37a3ae Grow: allow --grow --continue to work for native metadata.
As it was the code would crash due to "mdstat" being NULL.
Code is now more sane, but hasn't been tested on an array that
needs to grow.

Signed-off-by: NeilBrown <neilb@suse.de>
2012-10-09 13:54:59 +11:00
NeilBrown ee2429e0bc Grow/raid10: support reducing the devices in a RAID10.
When reducing the number of devices in a RAID10, we increase the
data offset to avoid the need for backup area.

If there is no room at the end of the device to allow this, we need
to first reduce the component size of each device.  However if there
is room, we don't want to insist on that, otherwise growing then
shrinking the array would not be idempotent.

So find the min before/after space before analysing a RAID10 for
reshape, and if the after space is insufficient, reduce the total size
of the array and the component size accordingly.

Signed-off-by: NeilBrown <neilb@suse.de>
2012-10-04 16:34:21 +10:00
NeilBrown 19ceb16daf Grow: add raid10 reshape.
RAID10 reshape requires that data_offset be changed.
So we only allow it if the new_data_offset attribute is available,
and we compute a suitable change in data offset.

Signed-off-by: NeilBrown <neilb@suse.de>
2012-10-04 16:34:21 +10:00
NeilBrown b48e2e25c4 Split 'GCD' out into a separate function.
It is neater that way.

Signed-off-by: NeilBrown <neilb@suse.de>
2012-10-04 16:34:21 +10:00
NeilBrown 40c9a66a5c Add --data-offset flag for Create and Grow
This can be used to over-ride the automatic assignment of
data offset.
For --create, it is useful to re-create old arrays where different
   defaults applied.
For --grow it may be able to force a reshape in the reverse direction.

Signed-off-by: NeilBrown <neilb@suse.de>
2012-10-04 16:34:21 +10:00
NeilBrown 676ab3120b Grow: make warning about old metadata more explicit.
Don't print it just when --verbose is set, and explain how
to over-ride it.

Signed-off-by: NeilBrown <neilb@suse.de>
2012-10-03 14:44:20 +10:00
NeilBrown 1f9b0e2845 Grow - be careful about 'delayed' reshapes.
If multiple reshapes are activated on the same devices (different
partitions) then one might be forced to wait for the other to
complete.
As reshaping suspends access to small sections of the array
at time, this cause a region to be suspended for a long time,
which isn't good.

To try to detect this and don't start suspending until
the reshape is actually happening.

This is only effective on 3.7 and later as prior kernels
don't report when the delayed reshape can progress.  For
the earlier kernels, just give a warning.

Signed-off-by; NeilBrown <neilb@suse.de>
2012-10-03 14:41:31 +10:00
NeilBrown 887a7a9e98 grow: fix typo : MAX_DISKS -> MAX_SIZE
oopps.

Signed-off-by: NeilBrown <neilb@suse.de>
2012-09-20 11:32:39 +10:00
Lukasz Dorau 7ec0996cf6 Grow.c: change size to be unsigned and use '0' in case of 'no change'
The 'size' has been changed to be unsigned recently.
Analogous changes should be made to reshape_super().
'0' should be used in case of 'no change' now.

Signed-off-by: Lukasz Dorau <lukasz.dorau@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
2012-08-13 08:07:01 +10:00
NeilBrown ca3b669603 Minor cosmetic fixes in various files.
Signed-off-by: NeilBrown <neilb@suse.de>
2012-08-13 08:00:21 +10:00
NeilBrown 0a8b92a6f6 Fix default size calculations that were recently broken.
commit d04f65f48c
    Change the values for "max size" from -1 to 1.

Messed up 's->size' - leaving it as '1' (MAX_SIZE) in some cases and
causing the array reshape to fail.

Signed-off-by: NeilBrown <neilb@suse.de>
2012-08-13 08:00:18 +10:00
NeilBrown 50f01ba5a1 Use new struct context and struct shape for Grow_addbitmap
Signed-off-by: NeilBrown <neilb@suse.de>
2012-07-09 17:22:12 +10:00
NeilBrown 32754b7d84 Use new struct context and struct shape in Grow_reshape
Signed-off-by: NeilBrown <neilb@suse.de>
2012-07-09 17:22:09 +10:00
NeilBrown d04f65f48c Change the values for "max size" from -1 to 1.
Both are impossible, and '1' allows size to be unsigned,
which is neater.
Also #define MAX_SIZE to be '1' to make it all more explicit.

Signed-off-by: NeilBrown <neilb@suse.de>
2012-07-09 17:20:32 +10:00
NeilBrown ba728be72f Convert 'quiet' to 'not verbose' in various places.
If we change some functions to accept 'verbose', where <0 means to be
quiet, in place of 'quiet', then we will be able to merge
'quiet' and 'verbose' together for simplicity.

Signed-off-by: NeilBrown <neilb@suse.de>
2012-07-09 17:18:09 +10:00
NeilBrown 503975b9d5 Remove scattered checks for malloc success.
malloc should never fail, and if it does it is unlikely
that anything else useful can be done.  Best approach is to
abort and let some super-daemon restart.

So define xmalloc, xcalloc, xrealloc, xstrdup which don't
fail but just print a message and exit.  Then use those
removing all the tests for failure.

Also replace all "malloc;memset" sequences with 'xcalloc'.

Signed-off-by: NeilBrown <neilb@suse.de>
2012-07-09 17:14:16 +10:00
NeilBrown e7b84f9d50 Introduce pr_err for printing error messages.
'pr_err("' is a lot shorter than 'fprintf(stderr, Name ": '
cont_err() is also available.

Signed-off-by: NeilBrown <neilb@suse.de>
2012-07-09 17:14:16 +10:00
NeilBrown c456301a05 Grow: don't print message if unfreezing fails.
This is most likely to happen if the array has been stopped,
in which case the error is pointless.

Reported-by: Patrik Horník <patrik@dsl.sk>
Signed-off-by: NeilBrown <neilb@suse.de>
2012-05-15 12:12:58 +10:00
NeilBrown 385167f364 Grow: fix --layout=preserve to match man page.
I think there was some confusion about what --layout=preserve
actually means, but in any case it wasn't doing what the man
page says it should.
So add some case analysis and make sure it does the right thing,
or complains if it cannot.

Reported-by: Patrik Horník <patrik@dsl.sk>
Signed-off-by: NeilBrown <neilb@suse.de>
2012-05-15 11:59:40 +10:00
NeilBrown b0a658ffbc Grow: failing the set the per-device size is not an error.
Signed-off-by: NeilBrown <neilb@suse.de>
2012-05-03 16:18:22 +10:00
Jes Sorensen 012a864129 Introduce sysfs_set_num_signed() and use it to set bitmap/offset
mdinfo->bitmap_offset is a signed long and needs to be treated as
such when passed to the kernel.

This resolves the problem with adding internal bitmaps to a 1.0 array.

Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
Signed-off-by: NeilBrown <neilb@suse.de>
2012-04-30 09:56:22 +10:00
Lukasz Dorau b51702b827 fix: correct extending size of raid0 array
Setting "sync_action" to "idle" while extending size of raid0 array
is racy and sometimes fails.
"sync_action" should be set to "frozen" instead.

Signed-off-by: Lukasz Dorau <lukasz.dorau@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
2012-04-23 10:12:33 +10:00
Adam Kwolek 58d26a2a81 FIX: Size change is possible as standalone change only
Size change is possible as standalone change only. To make sure size change
is not requested pass '-1' as size parameter.

Signed-off-by: Adam Kwolek <adam.kwolek@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
2012-04-17 12:33:38 +10:00
Adam Kwolek 65a9798b58 FIX: Detect error and rollback metadata
Some setting size error cases were not detected.
When error occurs, stop setting new size action and rollback metadata
changes.

Signed-off-by: Adam Kwolek <adam.kwolek@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
2012-04-17 12:33:38 +10:00
Adam Kwolek 7e7e9a4d72 FIX: Respect metadata size limitations
When reshape_super() updates metadata with new size, due to some metadata
limitations saved value can be different than requested value by user.
Update size (read it from metadata) for setting it in md.

Signed-off-by: Adam Kwolek <adam.kwolek@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
2012-04-17 12:33:37 +10:00
Adam Kwolek 44f6f18113 FIX: Extend size of raid0 array
For raid0, takeover operation is required for size change.
Add takeover to degraded raid4 before size change and back to raid0 after.
Array information has to be read again from md after takeover.

Signed-off-by: Adam Kwolek <adam.kwolek@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
2012-04-17 12:33:37 +10:00
Adam Kwolek 016e00f546 FIX: Support metadata changes rollback
Function reshape_super() guards metadata changes.
It is used to apply changes rollback in error case also.
As change (apply and rollback) can be not bi-directional reshape_super()
has to know if current action is metadata change that should be guarded
using metadata restrictions, or this is metadata rollback change
executed due to error occurrence.

In second case change has to be unconditional.

Signed-off-by: Adam Kwolek <adam.kwolek@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
2012-04-17 12:33:37 +10:00
Adam Kwolek 54397ed97a imsm: Execute size change for external metatdata
For external metatdata ioctl doesn't set new size. Set new size using sysfs.
Put code for size change in to function to re-use the same code as during
On-line Capacity Expansion

Signed-off-by: Adam Kwolek <adam.kwolek@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
2012-04-17 12:33:37 +10:00
NeilBrown 5ca3a902fd Grow: print useful error when converting RAID1->RAID5 will fail.
RAID1 can only be converted to RAID0 or RAID5 if the size is
a multiple of 4K as we cannot have chunks smaller than 4K.

If this might happen, report a useful error message.

Signed-off-by: NeilBrown <neilb@suse.de>
2012-03-22 17:00:57 +11:00
NeilBrown 0073a6e189 Remove possible crash during RAID6 -> RAID5 reshape.
If a RAID6 array is in a state which doesn't have a
RAID5 equivalent, the code currently dereferences a NULL.

If it does have an equivalent - use that.
If it doesn't but it already in the RAID5-compatible layout
with the Q block last, handle that case,
else require the new layout to be explicitly requested.

Signed-off-by: NeilBrown <neilb@suse.de>
2012-03-22 15:34:17 +11:00
Adam Kwolek 178950eacc FIX: Changes in '0' case for reshape position verification
Reading sysfs entry that is '0' long should cause an error.
Reshape position cannot be empty.

Absence of reshape position should be ignored. It is possible
that we are about raid0 reshape continuation and it is before takeover.
This means that according metadata (changed by mdmon) it should be reshaped
but md knows nothing about it at this moment. Reshape continuation
in reshape_array() will change it to raid4 and reshape position appears
in sysfs.

Signed-off-by: Adam Kwolek <adam.kwolek@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
2012-02-20 14:10:11 +11:00
Adam Kwolek 1ca90aa648 FIX: Do not try to (continue) reshape using inactive array
When one of arrays is inactive, do not try to continue reshape
on this array. Just skip it.

Signed-off-by: Adam Kwolek <adam.kwolek@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
2012-02-09 12:38:15 +11:00
Adam Kwolek e1dd332a09 FIX: restart reshape when reshape process is stopped just between 2 reshapes
When reshape is restarted from '0', very begin of array
it is possible that for external metadata reshape and array
configuration doesn't happen.
Check if md has the same opinion, and reshape is restarted
from 0. If so, this is regular reshape start after reshape
switch in metadata to next array only.

Signed-off-by: Adam Kwolek <adam.kwolek@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
2012-02-09 12:37:40 +11:00
Adam Kwolek f93346ef07 FIX: use md position to reshape restart
When reshape is broken, it can occur that metadata is not saved properly.
This can cause that reshape process is farther in md than metadata states.

On reshape restart use md position as start position, if it is farther than
position specified in metadata. Opposite situation treat as error.

Signed-off-by: Adam Kwolek <adam.kwolek@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
2012-02-09 12:36:41 +11:00
Adam Kwolek 78340e26a5 Flush mdmon before next reshape step during container operation
Using takeover operation for grow purposes, mdadm has to be sure
that mdmon processes all updates, and if necessary it will be closed
at takeover to raid0 operation. If mdmon is late, next array in container
is processed and due to race condition mdmon closes itself instead to monitor
next reshape operation.

Signed-off-by: Adam Kwolek <adam.kwolek@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
2012-02-09 12:20:52 +11:00
Adam Kwolek 59ab9f54a0 FIX: Typo error in fprint command
Signed-off-by: Adam Kwolek <adam.kwolek@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
2012-01-30 11:36:25 +11:00
Adam Kwolek 3c20f9899b FIX: mdmon check in reshape_container() can cause a problem
When raid0 reshape is executed mdmon can dissappear due to raid level
takeover operation. If this happen before mdmon check, mdadm would treat
it as error condition. It is not true for this case.

Remove mdmon check from reshape_container() function.
Error condition check will remain using reshape_array() reentry test
for the same array (line 2577).

Signed-off-by: Adam Kwolek <adam.kwolek@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
2012-01-30 11:36:25 +11:00
Adam Kwolek 5d1c7cdaca FIX: External metadata sometimes is not updated
External metadata sometimes is not updated.
It can be observed during 2 raid0 arrays Capacity Expansion.
New array size is not set, because metadata is not updated and on the reshape
end mdadm doesn't read new array size from metadata.
This happens when mdmon finishes his work (due to takeover to raid0),
before all metadata updates are processed.

Make sure that all updates are flushed to disk before executing takeover.

Signed-off-by: Adam Kwolek <adam.kwolek@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
2012-01-30 11:36:25 +11:00
NeilBrown c0c1acd691 Grow/bitmap: support adding bitmap via sysfs.
Adding a bitmap via ioctl can only add it at a fixed location.
That location is not suitable for 4K-block devices.

So allow setting the bitmap location via sysfs if kernel supports it
and aim to always use 4K alignments.

Signed-off-by: NeilBrown <neilb@suse.de>
2011-12-23 14:10:41 +11:00
NeilBrown 24daa16fa1 Grow.c: fix lots of white-space issues.
Signed-off-by: NeilBrown <neilb@suse.de>
2011-12-23 06:59:51 +11:00
NeilBrown ce4783d3d6 Grow: fix reshape-array for shrinking reshapes.
The value in info->array.raid_disks is the total number of
devices, which is the 'after' number when the number is increasing,
and the 'before' number when the number is decreasing.

The code currently assumes it is always the 'after' number - so fix
that.

Signed-off-by: NeilBrown <neilb@suse.de>
2011-12-23 06:59:48 +11:00
NeilBrown 27a1e5b5a4 Grow: fix start_reshape for shrinking arrays.
When an array is being reshaped to fewer data devices the relationship
between sync_max and reshape_progress is different to when the number
of devices increases - we need to allow for that when setting
sync_max/sync_min.

Signed-off-by: NeilBrown <neilb@suse.de>
2011-12-23 06:59:45 +11:00
Adam Kwolek 97a3490c0d FIX: Add error message in container_reshape()
Add proper error message for container reshape when device cannot be opened.
fd variable operation is moved down to display information what particular
device cannot be opened.

Signed-off-by: Adam Kwolek <adam.kwolek@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
2011-12-15 14:34:46 +11:00
Adam Kwolek 2d04d7e5c3 FIX: Do not allow for multiple reshape_array() execution during reshape_container() call
It can happen during reshape restart that reshape_array() can exit without
error (e.g. Grow.c:1915) and reshape is not moved to next array.
reshape_array() is called again for the same device.
Do not allow for such execution and check if last reshaped array is not
the current one.
This patch can be treat not as solution, but it allows for such errors
detection.

Signed-off-by: Adam Kwolek <adam.kwolek@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
2011-12-15 14:34:36 +11:00
Adam Kwolek 4584621ab4 FIX: Do not continue container reshape when mdmon is absent
When mdmon is absent metadata is not updated, and container_reshape()
can fall in to endless loop. This can cause user data corruption.

In case when mdmon is absent do not continue container reshape process.

Signed-off-by: Adam Kwolek <adam.kwolek@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
2011-11-07 11:46:35 +11:00
Jes Sorensen 8e61e0d7f9 Grow_reshape(): Fix another 'sra' leak
Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
Signed-off-by: NeilBrown <neilb@suse.de>
2011-11-02 10:48:53 +11:00
Jes Sorensen 730ae51fdd Grow_restart(): free() offsets after use
Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
Signed-off-by: NeilBrown <neilb@suse.de>
2011-11-02 10:48:53 +11:00
Jes Sorensen e7344e9007 Grow_addbitmap(): don't try to close a file descriptor which failed to open
Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
Signed-off-by: NeilBrown <neilb@suse.de>
2011-11-02 10:48:53 +11:00
Jes Sorensen 68fe8c6ed0 Grow_Add_device(): dev_open() return a negative fd on error
Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
Signed-off-by: NeilBrown <neilb@suse.de>
2011-11-02 10:48:53 +11:00
NeilBrown 446894ea8d Grow: fix check_reshape and open_code it.
check_reshape should not try to parse the subarray string - only
metadata handlers are allowed to do that.

The common code and only interpret a subarray string by passing it to
"container_content" which will then return only the member for that
subarray.

So remove check_reshape and place similar logic explicitly at the two
call-sites.  They are different enough that it is probably clearer to
have explicit code.

Signed-off-by: NeilBrown <neilb@suse.de>
2011-11-01 15:45:46 +11:00
Jes Sorensen 2641101b2f Add missing return in case of trying to grow sub-array
Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
Signed-off-by: NeilBrown <neilb@suse.de>
2011-11-01 14:55:14 +11:00
Jes Sorensen d152f53eaa Fix memory leaks in reshape_array()
Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
Signed-off-by: NeilBrown <neilb@suse.de>
2011-11-01 13:33:48 +11:00
Labun, Marcin 81219e70f2 kill-subarray: fix, IMSM cannot kill-subarray with unsupported metadata
container_content retrieves volume information from disks in the
container.  For unsupported volumes the function was not returning
mdinfo. When all volumes were unsupported the function was returning
NULL pointer to block actions on the volumes. Therefore, such volumes
were not activated in Incremental and Assembly. As side effect they
also could not be deleted using kill-subarray since "kill" function
requires to obtain a valid mdinfo from container_content.

This patch fixes the kill-subarray problem by allowing to obtain
mdinfo of all volumes types including unsupported and introducing new
array.status flags.

There are following changes:

1. Added MD_SB_BLOCK_VOLUME for blocking an array, other arrays in the
   container can be activated.

2. Added MD_SB_BLOCK_CONTAINER_RESHAPE block container wide reshapes
   (like changing disk numbers in arrays).

3. IMSM container_content handler is to load mdinfo for all volumes
   and set both blocking flags in array.state field in mdinfo of
   unsupported volumes.  In case of some errors, all volumes can be
   affected. Only blocked array is not activated (also reshaped as
   result). The container wide reshapes are also blocked since by
   metadata definition they require modifications of both arrays.

4. Incremental_container and Assemble functions check array.state and
   do not activate volumes with blocking bits set.

5. assemble_container_content is changed to check container wide reshapes
   before activating reshapes of assembled containers.

6. Grow_reshape and Grow_continue_command checks blocking bits
   before starting reshapes or continueing (-G --continue) reshapes.

7. kill-subarray ignores array.state info and can remove requested array.

Signed-off-by: Marcin Labun <marcin.labun@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
2011-10-31 11:29:46 +11:00
Adam Kwolek 9ad6f6e65a FIX: Close unused handle in child process during reshape restart
When array reshape (e.g. raid0->raid5 migration) is restarted during
array assembly, file system placed on this array cannot be mounted until
reshape is finished due to "busy" error.

This is caused when reshape is executed on array for external metadata
and array handle is cloned /forked/ to child process environment but not
closed.

Handle can't be closed before executing Grow_continue() because it is
used later in code.

Close unused handle in child process /reshape_container()/.
It is similar to close fd handle in reshape_array() before calling
manage_reshape()/child_monitor() in Grow.c:2290.

Signed-off-by: Adam Kwolek <adam.kwolek@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
2011-10-27 15:49:51 +11:00
NeilBrown fde139b91e Grow: Only ping monitor on level change if array is container based.
Pinging the monitor for a NULL container is bad.

Reported-by: Daniel Kahn Gillmor <dkg@fifthhorseman.net>
Tested-by: Daniel Kahn Gillmor <dkg@fifthhorseman.net>
Signed-off-by: NeilBrown <neilb@suse.de>
2011-10-17 16:51:31 +11:00
Adam Kwolek 3bd58dc65f Always run Grow_continue() for started array.
So far there were 2 reshape continuation cases:
 1. array is started /e.g. reshape was already invoked during initrd
                      start-up stage using "--freeze-reshape" option/
 2. array is not started yet /"normal" assembling array under reshape case/

This patch narrows continuation cases in to single one. To do this
array should be started /set readonly in to array_state/ before calling
Grow_continue() function.

Signed-off-by: Adam Kwolek <adam.kwolek@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
2011-10-07 09:46:07 +11:00
Adam Kwolek 6937e6d216 Set correct reshape restart position
This patch version is simplified compared to previous one.
There is no use of freeze_reshape flag in start_reshape(). It is assumed
that for reshape starting condition reshape_progress field contains
0 value /correct start position/. For reshape restart case, it contains
correct restart position. This approach doesn't make start_reshape()
difficult to read/manage and /imho/ kernel changes to change mdstat
reporting behavior are not necessary.

Setting correct position allows user to see it in the mdstat during
reshape restart and reshape process is not reported as resync.

Signed-off-by: Adam Kwolek <adam.kwolek@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
2011-10-05 14:00:00 +11:00
Adam Kwolek 2370a4dc02 Remove freeze() call from Grow_continue()
Grow_continue() for external metadata should be executed on blocked
from monitoring array(s)/container.
Additional call to freeze() is not necessary in such case.
It produces meaningless error message only.

Signed-off-by: Adam Kwolek <adam.kwolek@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
2011-10-05 13:33:29 +11:00
NeilBrown cc7f63e553 restore_backup() throws core dump
restore_backup() throws core dump during releasing fdlist.
Loop for closing handlers checks next_spare variable,
but iterates disk_count.

Reported-by: Adam Kwolek <adam.kwolek@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
2011-10-05 13:29:16 +11:00
Adam Kwolek f1fe496bce Verify reshape restart position
Check if reshape restart position is the same as set in md.
If position doesn't match this means that we cannot restart reshape.

Signed-off-by: Adam Kwolek <adam.kwolek@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
2011-10-03 10:04:32 +11:00
Adam Kwolek 2dddadb0f7 Add continue option to grow command
To allow for reshape continuation '--continue' option is added
to grow command.
Function that will be executed in grow-continue case doesn't require
information about reshape geometry. All required information are read
from metadata.
For external metadata reshape can be run for monitored array/container
only. In case when array/container is not monitored run mdmon for it.

Signed-off-by: Adam Kwolek <adam.kwolek@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
2011-10-03 09:26:48 +11:00
Adam Kwolek b76b30e0f9 Do not continue reshape during initrd phase
During initrd phase continuing reshape will cause file system context
lost. This blocks ability to control reshape using checkpoints.

To avoid this, during initrd phase assemble has to be executed with
'--freeze-reshape' option. This causes that mdadm restores reshape
critical section only.

Reshape can be continued later after system full boot.

Signed-off-by: Adam Kwolek <adam.kwolek@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
2011-10-03 09:15:22 +11:00
Lukasz Dorau cc700db34f fix: correct unlocking of map file
1. Three missing map_unlock() calls were added.
2. Map file must be unlocked on fork, else child will hold lock.

Signed-off-by: Lukasz Dorau <lukasz.dorau@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
2011-10-03 08:55:02 +11:00
Adam Kwolek 3f54bd62dc Move restore backup code to function
Reshape backup should be able to be restored during reshape continuation
also. To reuse already existing code it is moved to function.

Signed-off-by: Adam Kwolek <adam.kwolek@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
2011-09-21 12:17:30 +10:00
NeilBrown 20a4675688 Grow: refuse to grow a 0.90 array beyond 2TB
A kernel bug makes handling for arrays using more than 2TB per device
incorrect, and the kernel doesn't stop an array from growing beyond
any limit.
This is fixed in 3.1

So prior to 3.1, make sure not to ask for an array to grow bigger than
2TB per device.

Signed-off-by: NeilBrown <neilb@suse.de>
2011-09-08 13:08:51 +10:00
NeilBrown 11b391ece9 Discourage large devices from being added to 0.90 arrays.
0.90 arrays can only use up to 4TB per device.  So when a larger
device is added, complain a bit.  Still allow it if --force is given
as there could be a valid use.

Signed-off-by: NeilBrown <neilb@suse.de>
2011-09-08 13:05:31 +10:00
NeilBrown 6560987b25 Grow: ensure clean abort if we cannot read the 'completed' file.
If a read of 'completed' returns an error, select will never fail, so
this loop would never exit.

Signed-off-by: NeilBrown <neilb@suse.de>
2011-07-27 17:26:12 +10:00
Namhyung Kim 508ede8621 Grow: fix version number in error message
As the conditional checks, reshape to fewer devices is supported
since Linux kernel 2.6.30 not 2.6.32.

Signed-off-by: Namhyung Kim <namhyung@gmail.com>
Signed-off-by: NeilBrown <neilb@suse.de>
2011-07-26 14:30:49 +10:00
Namhyung Kim 6cbf8fb8c1 mdadm.8: change linux version 2.6.40 -> 3.0
Signed-off-by: Namhyung Kim <namhyung@gmail.com>
Signed-off-by: NeilBrown <neilb@suse.de>
2011-06-23 11:34:34 +10:00
Luca Berra 3b7e9d0cbe Fix some type-aliasing issues.
Warnings for these are reported with -Wstrict-aliasing=2, and
avoiding the cast is certainly an improvement.

Signed-off-by: NeilBrown <neilb@suse.de>
2011-06-17 14:38:14 +10:00
Adam Kwolek 13c37ad3f3 Do not use backup file for external metadata
When external metatdata handler supports manage_reshape()
and recover_backup() functions in super switch backup file is not required
and can be omitted. For backup purposes metadata specific mechanisms
are used.

Signed-off-by: Adam Kwolek <adam.kwolek@intel.com>
Signed-off-by: Krzysztof Wojcik <krzysztof.wojcik@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
2011-06-08 17:13:30 +10:00
Adam Kwolek e919fb0af2 FIX: Enable metadata updates for raid0
When raid0 is takeovered to degraded raid4, metadata updates has to be
applied via mdmon (raid4 has to be monitored).
It is not possible due to no update_tail pointer initialization
in supertype structure.

Signed-off-by: Adam Kwolek <adam.kwolek@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
2011-06-08 17:13:26 +10:00
NeilBrown 90b60dfa48 Grow: Add paranoid level checking to analyse_change.
Just in case array.level is ever something that we don't expect, make
sure we report an error clearly rather than get confused.

Signed-off-by: NeilBrown <neilb@suse.de>
2011-06-08 16:56:41 +10:00
Adam Kwolek 2fcb75aea1 Support restore_stripes() from the given buffer
For external metadata backup location and saving methods depends
on metadata specific implementation details. Currently restore_stripes()
function is able to restore data only from the given backup file handles
and it is used only for assembling partially reshaped arrays.
As this function will be very helpful for external metadata backup
mechanism, add the support for restoring data from the given source buffer.
Add possibility for save_stripes() to work without designation targets.
Save_stripes() can now prepare data for restore_stripes() only.

Signed-off-by: Maciej Trela <maciej.trela@intel.com>
Signed-off-by: Adam Kwolek <adam.kwolek@intel.com>
Signed-off-by: Krzysztof Wojcik <krzysztof.wojcik@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
2011-06-08 16:24:48 +10:00
NeilBrown ce52f92f04 Grow: accept --assume-clean with --grow --size
When an array is resized to have larger members, --assume-clean will
disable any resync if the kernel supports it (2.6.40 and later).

Signed-off-by: NeilBrown <neilb@suse.de>
2011-05-16 17:28:27 +10:00
NeilBrown 815c8a7e0b Grow: allow auto-readonly arrays to be reshaped.
In an array is auto-readonly then a reshape will not start.
But auto-readonly is only wanted until something is explicitly
done to acknowledge that the array is really wanted.
So it is perfectly correct to switch an auto-readonly array to
'clean' if a reshape has been requested.

Signed-off-by: NeilBrown <neilb@suse.de>
2011-05-10 13:09:37 +10:00
NeilBrown 621ea11b58 Grow: handle abort/restart of grow while being monitored.
If a device fails while the grow is being monitored but the array is
still functional, the Grow will appear to abort and then almost
instantly restart from where it was up to.

So if it appears to abort, wait up to 10 seconds for a restart (it
should be much much less than this.

Signed-off-by: NeilBrown <neilb@suse.de>
2011-05-10 12:53:51 +10:00
NeilBrown 907ea75325 Grow: restore ability to configure 'faulty' arrays via mdadm.
The big 'grow' refactor lost us the ability to configure 'faulty'
arrays through --grow.
So put that back as a special case.

Signed-off-by: NeilBrown <neilb@suse.de>
2011-05-10 12:09:02 +10:00
NeilBrown 85f102879f Grow: report if a --size change has no effect.
e.g. if "--grow --size=max" doesn't actually change anything, it is
useful to report that.

Signed-off-by: NeilBrown <neilb@suse.de>
2011-05-10 11:56:38 +10:00
NeilBrown d515d27f60 Grow: check if any changes needed before proceeding to analyse_change.
Analyse_change can give unhelpful error messages if nothing was
changed.  This is particularly awkward when only changing --size.

So check and re-introduce a message that was list in commit
5da9ab9874

Signed-off-by: NeilBrown <neilb@suse.de>
2011-05-10 11:49:57 +10:00
NeilBrown d1537ed192 Grow: When setting component size make sure components are ready.
If you change the size of a member of an array (e.g. it might be a
dm device that can be resized, or on a smart storage device), md
doesn't notice and so the space cannot be used without explicitly
telling md that the device is bigger.

This change causes "mdadm --grow --size=...." to make sure each
component device is making at least that much space available if it
can.

Normally usage of "--size=max" will cause all devices to make max
space available, the md will use as much as it can of that.

Signed-off-by: NeilBrown <neilb@suse.de>
2011-05-10 10:44:00 +10:00
Adam Kwolek 384e9be133 FIX: Check correctly raid disks during reshape restart
During reshape restart info->array.raid_disks contains new raid_disks number
It cannot be compared against old disks number. Such check will always fail.

Check raid disks array field against final disks number for restart.

Signed-off-by: Adam Kwolek <adam.kwolek@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
2011-04-19 17:25:43 +10:00
Adam Kwolek 178b8f353c FIX: Fiddle raid_disks number when restarting reshape
When restarting a reshape, the value of 'raid_disks' is the *new*
value.  The old value is found by subtracting delta_disks.
So before calling analyse_change we must set raid_disks to be the
old value, and then reset it afterwards.

All other fields are cleanly separated with the main field being
the 'old' value and a new_* field available.

Signed-off-by: Adam Kwolek <adam.kwolek@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
2011-04-18 10:31:06 +10:00
Adam Kwolek 77f8d358b5 FIX: Use successfully loaded metadata only
Values greater than 0, means error. We exit from loop on error
with empty super-block pointer when sd pointer is valid.
This cannot be detected by check condition as error.
For sure we shouldn't go forward with error condition.
It leads to throwing exception with core file when metadata handler
wants to access non existing super-block.

Signed-off-by: Adam Kwolek <adam.kwolek@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
2011-04-14 17:50:17 +10:00
Adam Kwolek b357ef43f9 FIX: Raid0 expansion cannot be restarted
When raid0 expansion is restarted, mdadm refuses to correctly assemble
array because critical section cannot be restored from backup file.
mdadm exits with information:
	mdadm: Failed to restore critical section for reshape - sorry.

For raid0 new level is 0, current array level is 4.
Function Grow_restart() doesn't allow for level change.

Grow_restart really shouldn't be checking for level changes.
As they are always instantaneous they should never appear
in the metadata so it doesn't mean anything to check for them.

Signed-off-by: Adam Kwolek <adam.kwolek@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
2011-04-11 15:00:13 +10:00
NeilBrown 0d5ac3c6ef Grow: increase raid_disks before adding specific spares.
When we add spared that have been targeted at a specific slot,
we need raid_disks to be bigger than the slot number.
But currently we don't increase raid_disks until after we add
these spares.

So introduce an early increase of raid_disks to allow the spares
to be added.

Signed-off-by: NeilBrown <neilb@suse.de>
2011-03-22 14:52:36 +11:00
Adam Kwolek 983fff45a1 FIX: ping_monitor() usage causes memory leaks
When for ping_monitor() input devnum2devname() is used,
received string pointer should be passed to free() for memory release.
It is not made in several places. This use case should have function
to avoid memory leak.

Signed-off-by: Adam Kwolek <adam.kwolek@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
2011-03-18 12:32:16 +11:00
Adam Kwolek bcc9e9edd0 FIX: Unfreeze array on success only
Unfreeze array on success only.
rv is initialized by restart variable so we have 2 cases.
1. regular reshape start
	rv == restart == 0
   this means that real error (returned by reshape) can cause leaving container frozen
   If array is not touched by reshape it can be unfrozen
2. During reshape restart even untouched array under reshape is left unfrozen,
   If reshape is started do not unfreeze array on error also.

This allows user for array repair action
(mdmon will not change array state).

Signed-off-by: Adam Kwolek <adam.kwolek@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
2011-03-14 18:12:57 +11:00
NeilBrown 2d4de5f980 Grow: allow monitor thread to exit when there is nothing more to do.
When an array using native metadata is increasing in size, we don't
need to keep monitoring it after the initial 'critical section'.
So detect that case.
If a final level-change is still needed mdadm will wait for that,
otherwise it will simply exit.

Signed-off-by: NeilBrown <neilb@suse.de>
2011-03-10 15:59:24 +11:00
NeilBrown b3cf095a94 Grow: don't forget_backup when length of backup is zero.
This is just a waste of IO

Signed-off-by: NeilBrown <neilb@suse.de>
2011-03-10 15:43:04 +11:00
NeilBrown 8ff6d0946c Grow: make sure 'info' doesn't have confusing data.
We now test ->reshape_active, but don't set it in a common case.

So just zero out the whole structure to be on the safe side.

Signed-off-by: NeilBrown <neilb@suse.de>
2011-03-10 15:36:07 +11:00
NeilBrown e2e53a2da5 Grow: support reshape of RAID0 arrays.
This is done via conversion to RAID4 and back.

To grow the array, extra devices will be needed which cannot
already be present as spares - so allow a list of new devices
to be included in grow request which changed the number of devices.

Signed-off-by: NeilBrown <neilb@suse.de>
2011-03-10 15:05:23 +11:00
NeilBrown 9468aeac57 Grow: Allow for component_size not being set for RAID0 arrays.
When an RAID0 is started using SET_ARRAY_INFO ioctl the
component_size will be zero.
This confused the code for reshaping a RAID0 via RAID4.

So if that seems to be the case, fake a believable component_size

Signed-off-by: NeilBrown <neilb@suse.de>
2011-03-10 15:00:38 +11:00
Adam Kwolek fcdfb81488 FIX: Set 'active' array state before array configuration
For not reshaped array in container during assembly array is in
auto-read-only state.  It is not possible to set disk slot for such
array and later reshape cannot be started also.  To move array from
'auto-read-only' to 'active' state storing 'active' state to sysfs is
added. This allows for disks configuration and reshape.

During reshaped array restart it is disabled by condition on restart
variable.

When reshape is starting, storing 'active' state to already active
array should not matter.

Signed-off-by: Adam Kwolek <adam.kwolek@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
2011-03-10 11:41:28 +11:00
NeilBrown f362d22b5b Grow: make sure mdmon is running for Grow_continue arrays.
when starting an array that is in the middle of a migration,
we need to start mdmon, just as we do for arrays which are not
in the middle of a migration.

Repored-by: Adam Kwolek <adam.kwolek@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
2011-03-10 11:36:47 +11:00
Adam Kwolek 3db2fdd834 FIX: Load container content for container reshape continuation
st->sb is null. This is exception cause.
reshape_container() function expects that super block will be loaded.

Signed-off-by: Adam Kwolek <adam.kwolek@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
2011-03-10 09:54:56 +11:00
NeilBrown 3cb2aed250 Grow: don't let analyse_change see new level from metadata.
This is a bit of a hack - probably analyse change needs to be
re-written a bit to handle this properly.

However when the metadata deduced the intermediate state for a
reshaping array, the 'new_level' it sets should not be used to
interpret the 'delta_disks' number.
So in that case, hide the new_level while calling analyse_change.

Signed-off-by: NeilBrown <neilb@suse.de>
2011-03-09 18:53:09 +11:00
NeilBrown eff4954d9a Grow: don't try to use 'raid_disks' value for a container.
The 'raid_disks' for a container is zero, so subtracting it
from the given raid_disks to get delta_disks doesn't make sense.

Rather set delta_disks to UnSet and set raid_disks to the requested
number of disks.   This then gets passed to reshape_super() which
can use it as required.

Signed-off-by: NeilBrown <neilb@suse.de>
2011-03-09 18:50:59 +11:00
NeilBrown 817ed7d6d6 Grow: only check 'native format' when really needed.
The check that the array info is already in 'native format' is
only relevant when restarting a growth, so only perform it then.

Signed-off-by: NeilBrown <neilb@suse.de>
2011-03-09 18:47:24 +11:00
Adam Kwolek eae35f5c55 FIX: Check correct 'old' level to see if reshape is needed.
Normally when reshape_array is called with restart == 0,
info->array is the same as the 'array' read from the kernel
(via ioctl) so both have the same level.

However when called from reshape_container, info->array was
generated by the metadata so it will have 'level' set to the
intermediate (or final) level already.

So to test if we need to change the level, we need to compare the
desired level with that which was loaded from the kernel (array.level)
rather than that which was read from metadata (info->array.level).

Signed-off-by: Adam Kwolek <adam.kwolek@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
2011-03-09 18:42:40 +11:00
NeilBrown e06c4e59b3 Grow: add check that there are enough devices.
The check for 'enough spares' doesn't apply to RAID0 as we don't
mind it going degraded.  But add a test that there are enough spares
to actually produce a working array.

Signed-off-by: NeilBrown <neilb@suse.de>
2011-03-09 18:37:00 +11:00
NeilBrown 83732c285b Typo in dprintf
Canot -> Cannot

Signed-off-by: NeilBrown <neilb@suse.de>
2011-03-09 18:31:56 +11:00
NeilBrown 9e034f70ae Fix comment in progress_reshape
The possible return values have changed since that comment.

Signed-off-by: NeilBrown <neilb@suse.de>
2011-03-09 18:31:15 +11:00
NeilBrown 5652f2d9ce Grow: allow a RAID1 to be reshaped directly to 3-drive RAID5
Self-tests require this but code didn't allow it any more.

Signed-off-by: NeilBrown <neilb@suse.de>
2011-03-09 18:30:03 +11:00
NeilBrown 493f5dd6b2 Allow Grow_continue for whole container as well as single array.
Some grow operations must be applied to a whole container.  These
are performed one array at a time, so only one array appears to
be reshaping.

When re-assembling such an array, we need to make sure that
when the reshape finished, we move on to the next array.

So require metadata to set ->reshape_active = 2 in that case,
and use reshape_container to complete the reshape.

Signed-off-by: NeilBrown <neilb@suse.de>
2011-03-08 17:36:40 +11:00
NeilBrown 20a40eca4b Change way that reshaping arrays with external-metadata are assembled.
Now that the external metadata handler must provide an md-compatible
old/new geometry, sys_set_array can do all of the array set-up for
an array that is undergoing reshape.
That leave less for reshape_array to do.

Also clean up how reshape_array tells if the reshape has started or
not.
Don't use ->reshape_active as that doesn't tell us anything consistent
at this stage, only use the 'restart' flag passed in.

Signed-off-by: NeilBrown <neilb@suse.de>
2011-03-08 16:10:29 +11:00
Adam Kwolek ef5414b282 FIX: Set readonly state in Grow_continue() when necessary
When assembling array using assemble_container_content() for external
metadata case, array is in 'readonly' state already.
There is not necessary to duplicate this operation.

Signed-off-by: Adam Kwolek <adam.kwolek@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
2011-03-02 11:36:46 +11:00
Adam Kwolek 864a004f7e FIX: Pass container name to reshape array for external meta data
When calling reshape_array() for external metadata 'container name'
parameter have to be passed.
Find and pass container name in external metadata case.

Signed-off-by: Adam Kwolek <adam.kwolek@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
2011-03-02 11:36:46 +11:00
Adam Kwolek 20c8698dfc FIX: Spelling error in dprintf output
Signed-off-by: Adam Kwolek <adam.kwolek@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
2011-03-02 11:36:46 +11:00
NeilBrown b545e14a21 analyse_change: fix calculation of after.data_disks and ->delta_disks.
When changing level when a new number of raid disks was explicitly
specified, we much make sure that the change implied by the
change in level is properly incorporated into the final result.

So explicitly track the change in number of parity disks
(delta_parity) and use it together with delta_disks to determine
final data_disks.
Also set info->delta_disks so other code doesn't need to mirror
this analysis.

And add some errors in cases where a new number of disks was
requested but is not currently supported

Reported-by: Adam Kwolek <adam.kwolek@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
2011-02-14 12:17:08 +11:00
Adam Kwolek f0cce4425b FIX: Add raid5 to raid0 case to analyse_change()
Transition raid5 to raid0 was not covered in analyse_change()
Missing case added.

Signed-off-by: Adam Kwolek <adam.kwolek@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
2011-02-14 11:15:48 +11:00
Adam Kwolek 08f9e34bb5 FIX: Get spares from external metadata
For external metadata cases, information about number of spares cannot
be get via ioctl GET_ARRAY_INFO for particular array
(as info variable is initialized by). In md this information is present
in container object not array one.
This causes need to get spare disks number from external metadata.

This information is required for reshape_array() function to decide
if spare disks number satisfy operation requirements.

Signed-off-by: Adam Kwolek <adam.kwolek@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
2011-02-14 11:06:31 +11:00
Adam Kwolek 41784c88f3 FIX: delta_disk can have UnSet value
Delta_disk can be set to UnSet value.
This can a cause to pass wrong parameter to reshape_super().
To avoid such situations raid_disks and delta_disks parameters
have to be passed to reshape_super() separately.
It will be up to reshape_super() function validation
and usage of this parameters to avoid not valid values.

Signed-off-by: Adam Kwolek <adam.kwolek@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
2011-02-14 11:04:09 +11:00
Adam Kwolek e84f2c006e FIX: array after migration should be unfrozen
After level migration array is left frozen.
When process is not externally forked reshape_array() should
unfreeze array before exit (this is not container operation).

Signed-off-by: Adam Kwolek <adam.kwolek@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
2011-02-14 09:23:37 +11:00
Adam Kwolek 3cd4e7c4dd FIX: md runs recovery instead reshape for growing single disk raid0 array
Problem occurs when we want to expand single disk raid0 array.
This is done via degraded 2 disks raid4 array. When new spare disk
for reshape is added to array, md immediately initiates recovery before
mdadm can configure and start reshape. This is due fact that 2 disk
raid4/5 array is special md case.
Mdmon does nothing here because container is blocked.
This is caused because after takeover array is not in frozen state in md.

Put array in to frozen state after takeover to allow mdadm to finish
configuration before reshape is executed in md.

Signed-off-by: Adam Kwolek <adam.kwolek@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
2011-02-09 14:07:33 +11:00
Adam Kwolek 9e3254422d FIX: Container can be left frozen
When container operation fails before child process starts,
array can be left frozen because container_reshape() doesn't make
unfreeze() operation in all error cases, as it is responsible for.

add unfreeze() operation for error case scenarios in reshape_container()

Signed-off-by: Adam Kwolek <adam.kwolek@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
2011-02-09 14:07:26 +11:00
NeilBrown e4b1107355 Grow: make sure to break out of the backup loop when finished.
If there is nothing more to backup, then break out of the loop.

Signed-off-by: NeilBrown <neilb@suse.de>
2011-02-01 10:08:24 +11:00
NeilBrown b8b286a639 Make sure odisks is consistent between creating and using the fdlist
reshape_prepare_fdlist and child_monitor currently have slightly
different ideas of the 'old number of raid devices' which can cause
major confusion.

So settle on one value, and assign it to odisks early and always use
it.

Signed-off-by: NeilBrown <neilb@suse.de>
2011-01-31 17:09:20 +11:00
NeilBrown 7f913e9b21 Grow: round max_progress to old chunk size too.
kernel requires sync_max to be a multiple of the current
chunk size.  This is not really 'correct', but we need to work
with it.  So round down.

Signed-off-by: NeilBrown <neilb@suse.de>
2011-01-31 17:04:37 +11:00
NeilBrown ca4fe0bfd3 Initialise all of file when opening backup file for reshape.
Due to a miscalculation we didn't initialise the whole file.
There is 4K (8 sectors) for the metadata, then the data.

Signed-off-by: NeilBrown <neilb@suse.de>
2011-01-31 16:57:40 +11:00
NeilBrown 1e971e7163 Grow: when restarting, do set new details if they are already set.
When restarting a reshape with internal metadata, the new geometry
is already set and the reshape has been start (but has not been
allowed to continue yet).

So in that case, don't set things and don't ask for a reshape.

Signed-off-by: NeilBrown <neilb@suse.de>
2011-01-31 15:32:19 +11:00
NeilBrown 6ef421be17 Grow:make sure 'array' is up-to-date before SET_ARRAY_INFO
The value of 'array' might not be current, so SET_ARRAY_INFO
and fail.  Just refresh it before setting raid_disks.

Signed-off-by: NeilBrown <neilb@suse.de>
2011-01-31 15:30:15 +11:00
NeilBrown cdc6068148 Grow: don't try setting new geometry when restarting a native reshape.
md won't let us change raid_disks in this case, so don't even try.

Signed-off-by: NeilBrown <neilb@suse.de>
2011-01-31 15:01:15 +11:00
Krzysztof Wojcik 24aebf3add FIX: Meet SET_ARRAY_INFO ioctl requirements
Problem has been observed when raid10<->raid0 takeover operation
is executed.
In code updating layout, raid_disks and chunk_size for non-restriping
operations in reshape array functions SET_ARRAY_INFO ioctl call was
not succeeded.
Takeover process finish execution with error, mdadm shows message:
"mdadm: failed to set disks"

Cause is not meeting SET_ARRAY_INFO ioctl requirements:
- only one parameter may be changed at one time
- level of current array info and new info should be the same

Patch introduces solution for this issue.
At the beginning of discussed code we read current information
about array and then compare them with new values should be set.
If particular value is different (and should be set),
we are overwrite only this one in array info and then call ioctl.

Signed-off-by: Krzysztof Wojcik <krzysztof.wojcik@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
2011-01-28 11:03:12 +10:00
Krzysztof Wojcik d5ca4a23fc FIX: Remove disks in mdmon for external metadata
For raid10 -> raid0 takeover operation we should reject disks
in mirror by marking them as 'failed' and then remove them from
array by writing "remove" to disk state.

For external metadata second action is executed by mdmon.
According the description in monitor.c:175 when monitor detect
"faulty" in device state, it blocks the device, mark it as failed
in metadata, unblocks the device and finally writes "remove"
to device state.
For external case writing "remove" to device state in mdadm
is not necessary and harmful.
It may cause following issues:
1. "remove" operation for external case in mdadm is not finish
with successful result because monitor may block the device or disk
has been already removed by monitor.
2. If disk is removed by mdadm earlier than mdmon catch "failed" state,
metadata is not properly updated- is not marked as failed.

Signed-off-by: Krzysztof Wojcik <krzysztof.wojcik@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
2011-01-28 11:03:11 +10:00
Adam Kwolek 10d0d365eb WORKAROUND: mdadm hangs during reshape (PART #2)
After loop can occurs that due to 0 value reported by kernel
we have 0 in completed variable.
This is wrong. we are interested in real completed point.
0 value means that we reached sync point set in md,
so we can set completed variable to just reached point.
this point value is stored in max_progress variable.

Signed-off-by: Adam Kwolek <adam.kwolek@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
2011-01-28 11:03:11 +10:00
Adam Kwolek fab32c9702 FIX: start_reshape status should be checked
mdadm should verify if reshape is started before it goes
in to check-pointing machine.

Signed-off-by: Adam Kwolek <adam.kwolek@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
2011-01-28 10:40:42 +10:00
Adam Kwolek a9c3e78fdd FIX: Array after takeover has to be frozen
Problem occurs when we want to expand single disk raid0 array.
This is done via degraded 2 disks raid4 array. When new spare
is added to array, md immediately initiates recovery before
mdadm can configure and start reshape. This is due fact that 2 disk
raid4/5 array is special md case. Mdmon does nothing here because
container is blocked.
Put array in to frozen state allows mdadm to finish configuration
before reshape is executed in md.

Signed-off-by: Adam Kwolek <adam.kwolek@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
2011-01-28 10:26:15 +10:00
NeilBrown d6bd632c41 Ignore/don't set data_disks for level=1
When analyse_change sets level=1, data_disks is meaningless
as is layout.
So don't set them, and make sure we ignore them.

Signed-off-by: NeilBrown <neilb@suse.de>
2011-01-27 12:47:58 +10:00
Krzysztof Wojcik c8b06d8239 Mistake in raid1->raid5 migration
1. Mistake in target level comparison.
2. Initialize reshape->after.data_disks field
to proper spares_needed calculation

Signed-off-by: NeilBrown <neilb@suse.de>
2011-01-27 12:47:53 +10:00
Krzysztof Wojcik dfe77a9ed2 Add raid1->raid0 takeover support
Add support for raid1 to raid0 takeover operation in user space.
This patch includes support for native and imsm metadata.

Signed-off-by: Krzysztof Wojcik <krzysztof.wojcik@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
2011-01-27 12:47:15 +10:00
Adam Kwolek 26d6e1574a WORKAROUND: mdadm hangs during reshape
During reshape when reshape is finished in md, progress_reshape() hangs
on select().
This is because 'sync_completed' is reset to zero before 'sync_action'
becomes 'idle', and we don't look for notification on 'sync_action'.

So if completed becomes zero after reshape_progress has made some
progress, then deduce that reshape has finished.

Signed-off-by: Adam Kwolek <adam.kwolek@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
2011-01-27 07:56:21 +11:00
Adam Kwolek 16d4d84e5d FIX: monitor doesn't handshake with md
when in container are present raid0 and raid5 arrays, and reshape order is:
1. raid0 array
2. raid5 array

mdadm cannot set new raid_disks for raid0 array. For this action md has to have
handshake with mdmon. We have the following conditions:
1. Raid0 is not monitored
2. raid0 has been just takeovered to raid4/5 (it has to be monitored
3. monitor has to start monitor new raid4/5 array
4. monitor is not started (it is started to second raid5 array)
In such situation pig_monitor is required to let know to m monitor about new array
(not in the starting monitor case only)

Signed-off-by: Adam Kwolek <adam.kwolek@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
2011-01-27 07:31:25 +11:00
Krzysztof Wojcik bb025c2f22 Add raid10 -> raid0 takeover support
The patch introduces takeover from level 10 to level 0 for imsm
metadata. This patch contains procedures connected with preparing
and applying metadata update during 10 -> 0 takeover.
When performing takeover 10->0 mdmon should update the external
metadata (due to disk slot and level changes).
To achieve that mdadm calls reshape_super() and prepare
the "update_takeover" metadata update type.
Prepared update is processed by mdmon in process_update().

Signed-off-by: Krzysztof Wojcik <krzysztof.wojcik@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
2011-01-26 08:50:37 +10:00
NeilBrown f897078e8b Fix some issues with setting 'new' state of a reshape
- when reshaping a container, ->reshape_active is already set
  even though it isn't really active yet, so we need to set
  the new geometry even when reshape_active is set.  This is safe.

- When restarting a reshape, make sure the reshape_position is set
  appropriately when external metadata is used.

Signed-off-by: NeilBrown <neilb@suse.de>
2011-01-26 08:50:28 +10:00
NeilBrown 446d2a5ad4 Fix up analysis of reshape from RAID1 to RAID5.
Need to allow raid-disks to change at the same time.

NeilBrown <neilb@suse.de>
2011-01-21 09:13:44 +11:00
NeilBrown e7a71c6b77 reindent/reformat some code.
Indenting was all wrong here, so fix it up.

Signed-off-by: NeilBrown <neilb@suse.de>
2011-01-21 09:06:31 +11:00
NeilBrown 10af14c4d2 Be more careful about adjusting reshape_progress based on backup.
Only adjust reshape_progress based on the backup that was found
if the backup covered the current reshape_progress point.

Signed-off-by: NeilBrown <neilb@suse.de>
2011-01-21 09:03:53 +11:00
NeilBrown 25da62d9ad Correctly initialise backup_point when reshaping backwards.
When reshaping backwards we only backup from backup_blocks to
the start, so initialise backup_point appropriately.

Signed-off-by: NeilBrown <neilb@suse.de>
2011-01-21 09:01:09 +11:00
NeilBrown 2c6ac128c4 error check reading of 'degraded' from sysfs.
I'm seen mdadm spinning while failing to read 'degraded'.
This doesn't really fix it, but is a reminder that it needs to be
fixed.

Signed-off-by: NeilBrown <neilb@suse.de>
2011-01-21 08:59:00 +11:00
NeilBrown ddee071d3e Initialise reshape_progress properly in reshape_array.
Previously uninitialised.

Signed-off-by: NeilBrown <neilb@suse.de>
2011-01-21 08:56:35 +11:00
NeilBrown 38dad34a35 Fix management of backed-up region for hi-to-low reshapes.
When reshaping from the end of the array to the start, for times
when the number of data devices is decreasing, the handling of the
backup area isn't a simple mirror of the handling on low-to-hi
reshapes as the backup areas is always low in the array.

So re-write that to make it work.

Signed-off-by: NeilBrown <neilb@suse.de>
2011-01-21 07:59:53 +11:00
Adam Kwolek 55f1472192 FIX: Arrays cannot be opened exclusively
When reshaping it is correct to open containers exclusively, but not
arrays.  The array could very easily be in use, e.g. by a mounted
filesystem.

Signed-off-by: Adam Kwolek <adam.kwolek@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
2011-01-17 15:06:02 +11:00
Krzysztof Wojcik e35b189b4e Unfreeze for non re-striping transitions
For non re-striping transitions array must be unfrozen
before end of processing.
For restriping transitions we normally let the child
unfreeze the array but in this case there is no child.

Signed-off-by: Krzysztof Wojcik <krzysztof.wojcik@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
2011-01-17 12:56:43 +11:00
Krzysztof Wojcik 031d445c18 Set reshape.after.data_disks for raid0<->raid10 takeover
reshape.after.data_disks field must be initiated
for raid0<->raid10 transition.
Instead calculated spares_needed variable in reshape_array
function has random value.

Signed-off-by: Krzysztof Wojcik <krzysztof.wojcik@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
2011-01-17 12:53:31 +11:00
Adam Kwolek cf6ac177b4 FIX: mdadm throws coredump on exit in error case
When mdadm falls in "reduce size" error on takeovered array it jumps
to release and tries execute backward takeover. This time sra pointer
is not initialized and coredump is generated.

Signed-off-by: Adam Kwolek <adam.kwolek@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
2011-01-17 12:38:13 +11:00
NeilBrown a93f87eee6 Add 'restart' arg to various functions used for reshaping.
When we restart an array in the middle of a reshape, we reuse a lot of
the code for starting the reshape, but it needs to know that
circumstances are slightly different.

So add a 'restart' arg which is used:
 - skip checking and adding spares
 - activate the array (rather than start reshape)
 - allow the backup file to already exist

Signed-off-by: NeilBrown <neilb@suse.de>
2011-01-17 09:53:56 +11:00
NeilBrown 6d5316f66a Be more careful checking why reshape has stopped.
If reshape_position reports 'none', check array_state to see if array
is still active.

Signed-off-by: NeilBrown <neilb@suse.de>
2011-01-17 09:53:25 +11:00
NeilBrown 18eaf9e553 Ignore error when setting sync_min
When restarting an array that is in the middle of a reshape,
sync_min cannot be set.  So just ignore any errors we get
when trying to set it.

Signed-off-by: NeilBrown <neilb@suse.de>
2011-01-17 09:51:33 +11:00
NeilBrown 77a73a17be Make sure child_monitor reliably reports whether reshape completed or aborted.
Signed-off-by: NeilBrown <neilb@suse.de>
2011-01-17 09:51:25 +11:00
NeilBrown 631d7405f1 Clean up return path for reshape_array.
Particular problem was that we didn't unfreeze if a reshape
wasn't needed.

But all that 'rv' stuff isn't needed and some of it was wrong,
so simplify it all.

Signed-off-by: NeilBrown <neilb@suse.de>
2011-01-13 15:20:21 +11:00
Krzysztof Wojcik 5dad078d99 FIX: Mistake in delta_disk comparison.
Signed-off-by: Krzysztof Wojcik <krzysztof.wojcik@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
2011-01-13 13:37:31 +11:00
NeilBrown 1cbc5680c8 Clean up exit paths from reshape_array.
We only 'goto release' on error, but that branch contained handling
for non-error conditions:  reloading metadata.  Obviously that doesn't
work.

So re-arrange the code to make it more of a straight line that is
easier to follow and reload the metadata if that might be at all
needed.

Signed-off-by: NeilBrown <neilb@suse.de>
2011-01-13 12:57:25 +11:00
NeilBrown 6b2d630c7d reshape_array: move lots of code out of a 'switch'.
Everything other than the 'child' part of the 'switch(fork)' returns
quickly, so leave them inside the switch but move the other large bit
out so as to make the flow of code more natural.

Signed-off-by: NeilBrown <neilb@suse.de>
2011-01-13 10:44:52 +11:00
NeilBrown 9202b8eb6a Fix up calls to unfrozen at end of reshape.
1/ don't pass 'frozen' as an arg to unfreeze - just use it
   to conditionally call 'unfreeze'.

2/ Always unfreeze at end of reshape_container

3/ Only unfreeze at end of reshape_array if not 'forked'.  So when
   reshape_array is called from reshape_container it doesn't unfreeze,
   but when called directly.

Signed-off-by: NeilBrown <neilb@suse.de>
2011-01-13 10:39:34 +11:00
Adam Kwolek eb744788d1 FIX: Cannot load container information
When container is passed to grow_reshape(), load_container() function
has to be used to get all required information from metadata.
So load_super is never correct here - in particular, cfd is a
'container fd' so we must 'load_container' on it.

Signed-off-by: Adam Kwolek <adam.kwolek@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
2011-01-13 10:15:54 +11:00
Kwolek, Adam d8eb27f71a FIX: size is passed incorrectly
reshape_super() called from reshape_container() with size set to
info->component_size gives size in reshape_super == -2 due to unsigned
signed conversion (info->component_size is not initializes).

As size is not changed during container reshape '-1' value is passed
to indicate this.

Signed-off-by: Adam Kwolek <adam.kwolek@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
2011-01-12 21:42:44 +11:00
Marcin Labun 3fa436ace2 Make text_version available to reshape_array for subarray processing.
reshape_array uses text_version to reload the container content,
so make sure it is available.

Signed-off-by: Marcin Labun <marcin.labun@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
2011-01-12 17:11:56 +11:00
Adam Kwolek 2dd0d6971c FIX: Fill sys_name for disk add
Add disks fails due to empty sys name field.
sysfs_init fills out required fields for add disk operation.

Signed-off-by: Adam Kwolek <adam.kwolek@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
2011-01-12 16:01:27 +11:00
NeilBrown 88c1a08391 Don't complain about missing spares when reshaping a raid0.
To reshape a RAID0 we convert to RAID4 first.  This makes it look
like it could be degraded and so we are tempted to ensure there are
enough spares.  However this is not appropriate for RAID0, so
explicitly exclude new_level == RAID0 in this check

Reported-by: Adam Kwolek <adam.kwolek@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
2011-01-12 15:59:24 +11:00
NeilBrown 999b497251 Make child_monitor a candidate for ->manage_reshape
Child_monitor was design to perform 'manage_reshape' for native
arrays.  So change the signature for ->manage_reshape to match
child_monitor and move the all to the same place that child_monitor
is called from.

Also give super-intel a manage_reshape handler which simple calls
child_monitor.

Signed-off-by: NeilBrown <neilb@suse.de>
2011-01-12 14:46:17 +11:00
NeilBrown da8100ca48 Move setup of backup superblock into child_monitor
child_monitor has overall responsibility for backups using the generic
bsb, so move all handling under it's control.

signed-off-by: NeilBrown <neilb@suse.de>
2011-01-12 14:42:51 +11:00
NeilBrown 832b2b9a7e Add comment about future enhancement
We currently suspend rather large sections of
the array which can take a while to process.
Possibly smaller sections are better.  Possibly it should be
adjusted on a timeout basis.

Signed-off-by: NeilBrown <neilb@suse.de>
2011-01-12 14:04:09 +11:00
NeilBrown e97ca00244 Correctly handle the final partial backup of an in-place reshape.
The array might not be a multiple of the chosen backup size, so
the last bit to be backed up might be a bit smaller.  Handle that
correctly.

Signed-off-by: NeilBrown <neilb@suse.de>
2011-01-12 14:01:36 +11:00
NeilBrown 49cd738ba2 Handle edge case with suspend_point updates.
If reshape_progress equals suspend_point, it is also appropriate to
update the end of the suspend region.

Signed-off-by: NeilBrown <neilb@suse.de>
2011-01-12 10:51:44 +11:00
NeilBrown 60204e4e54 Be more enthusiastic/flexible in backing up data.
At some points we need to perform 2 backups at once so as to
start the 'double buffering' approach.  So rather than assuming
what the next backup should be, example suspend_point and backup
as much as possible up to there.

Signed-off-by: NeilBrown <neilb@suse.de>
2011-01-12 10:44:58 +11:00
NeilBrown 223c5c999e Fix issues with the finish of monitoring a reshape.
1/ We need to clean up the backup file after the reshape finishes.
2/ We need to remove the suspended region and clear the resync
   controls after the resync finishes.

Signed-off-by: NeilBrown <neilb@suse.de>
2011-01-12 10:40:56 +11:00
NeilBrown 9653307272 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>
2011-01-12 10:37:26 +11:00
NeilBrown 92d1991fff 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>
2011-01-12 10:34:44 +11:00
NeilBrown d0ab945ee1 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>
2011-01-11 15:20:40 +11:00
NeilBrown 2f3dd5e4bc 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>
2011-01-11 15:07:57 +11:00
NeilBrown ec757320c2 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>
2011-01-11 14:57:14 +11:00
NeilBrown b4f8e38b94 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>
2011-01-11 14:51:09 +11:00
NeilBrown 6eb48844a5 Correctly abort level change when reshape_array fails.
We were returning too early.

Signed-off-by: NeilBrown <neilb@suse.de>
2011-01-11 14:41:49 +11:00
NeilBrown 374ba335cb 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>
2011-01-11 14:41:48 +11:00
NeilBrown f94eedafc1 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>
2011-01-11 14:41:47 +11:00
NeilBrown 4a8703648a 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>
2011-01-11 14:41:46 +11:00
NeilBrown b6b951557d Fix some typos in fprintf messages.
Signed-off-by: NeilBrown <neilb@suse.de>
2011-01-11 14:41:42 +11:00
NeilBrown 3656edcdc6 Grow: fix type when 'or'ing flags together.
'||' should have been '|'

Signed-off-by: NeilBrown <neilb@suse.de>
2011-01-11 14:16:11 +11:00
NeilBrown 0f28668b93 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>
2011-01-11 13:23:16 +11:00
Adam Kwolek 1b3cbac57f 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>
2011-01-06 19:20:01 +11:00
Adam Kwolek 582496b2c2 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>
2011-01-06 18:29:20 +11:00
Adam Kwolek 7477d51305 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>
2011-01-06 18:29:03 +11:00
Adam Kwolek 9ff87c16ce 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>
2011-01-06 18:29:02 +11:00
Adam Kwolek 1bb174ba0b 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>
2011-01-06 16:56:05 +11:00
NeilBrown 7443ee8187 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>
2011-01-06 15:58:32 +11:00