Commit Graph

188 Commits

Author SHA1 Message Date
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