Commit Graph

363 Commits

Author SHA1 Message Date
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
NeilBrown 5da9ab9874 Grow_reshape re-factor
Significant rewrite/refactor of Grow_reshape to make it easier to work
with externally-managed-metadata.

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

Signed-off-by: NeilBrown <neilb@suse.de>
2011-01-06 15:58:00 +11:00
NeilBrown b5420ef325 Grow: add disks chosen by metadata handler to array for growth.
With externally managed container based metadata, the ->reshape_super
method must choose any spares that are to be added to the array.
They should be prepared so that ->container_content will find them
as spares (disk.state == 0) which are assigned to a slot
(raid_disk >= 0).
We need to take those and add them to the array(s).

Signed-off-by: NeilBrown <neilb@suse.de>
2010-12-16 09:07:52 +11:00
NeilBrown 4347544720 Grow: call start/abort_reshape as appropriate when reshaping a container.
This means that ->manage_reshape will be called with reshape ready to
roll.

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

Signed-off-by: NeilBrown <neilb@suse.de>
2010-12-16 09:07:52 +11:00
NeilBrown d18bfbe3d0 Grow: make sure rv is set correctly in reshape_container_raid_disks
Whenever there is an error, rv must be -1.

Signed-off-by: NeilBrown <neilb@suse.de>
2010-12-16 09:07:52 +11:00
NeilBrown 47eb4d5a18 Grow: split out start_reshape for initiating reshape via sysfs.
Rather than sprinkling various sysfs setting around, put them all
in one place.  This will make implementing ->manage_reshape easier.

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

Signed-off-by: NeilBrown <neilb@suse.de>
2010-12-16 09:07:52 +11:00
NeilBrown 7d469585fc Grow: fix calculation of stripe_cache_size when reshaping.
The two places that this was done were different.  The original was
most correct, thought it used odisks rather than odata.

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

Signed-off-by: NeilBrown <neilb@suse.de>
2010-12-16 09:07:52 +11:00
NeilBrown 76266030d6 Grow: be more careful about metadata updates.
1/ When we sunc_metadata, we must reset ->update_tail else
   future metadata updates might go direct to the device bypassing
   mdmon.

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

Signed-off-by: NeilBrown <neilb@suse.de>
2010-12-16 09:07:51 +11:00
NeilBrown d7ca196cbd Grow: check container is idle before freezing it.
Before we freeze a container in preparation for growing a subarray, we
need to be sure all the subarrays are idle.

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

Signed-off-by: NeilBrown <neilb@suse.de>
2010-12-16 09:07:51 +11:00
NeilBrown 691a36b76f Grow: warn if growing an array will make it degraded.
Growing an array when there aren't enough spares can make the array
degraded.  This works but might not be what is wanted.
So warn the user in this case and require a --force to go ahead
with the reshape.

Signed-off-by: NeilBrown <neilb@suse.de>
2010-12-09 11:51:13 +11:00
Adam Kwolek 9376b5aac2 FIX: wait_backup() sometimes hungs
Sometimes wait_backup() omits transition from reshape to idle state
and mdadm seams to be hung.  So check the 'complete' count
*before* waiting rather than only after.

Signed-off-by: Adam Kwolek <adam.kwolek@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
2010-12-03 21:33:55 +11:00
Adam Kwolek 92a19f1a78 FIX: Honor !reshape state on wait_reshape() entry
When wait_reshape() function starts it can occurs that reshape is
finished already, before wait_reshape() start. This can lead to wait
for change state inside this function for a long time.  To avoid this
before wait we should test if finish conditions are not reached
already.

Signed-off-by: Adam Kwolek <adam.kwolek@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
2010-12-03 15:10:20 +11:00
Adam Kwolek e6e9d47b76 Grow: open backup file for reshape as function
Move opening backup file to the function for future reuse during
container reshape.

Signed-off-by: Adam Kwolek <adam.kwolek@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
2010-12-03 15:00:16 +11:00
NeilBrown acab7bb189 Create/grow: improve checks on number of devices.
Check on upper limit of number of devices was in the wrong place.
Result was could not create array with more than 27 devices without
explicitly setting metadata, even though default metadata allows more.

Fixed, and also perform check when growing an array.

Signed-off-by: NeilBrown <neilb@suse.de>
2010-12-01 14:51:27 +11:00
NeilBrown c82afc17a8 Grow: disallow placing backup file on array being reshaped.
the tests here aren't perfect, but they could catch some cases.

Signed-off-by: NeilBrown <neilb@suse.de>
2010-12-01 11:58:32 +11:00
NeilBrown 87f26d14f7 Assemble: allow an array undergoing reshape to be started without backup file
Though not having the proper backup file can cause data corruption, it
is not enough to justify not being able to start the array at all.
So allow "--invalid-backup" to be specified which says "just continue
even if a backup cannot be restored".

Signed-off-by: NeilBrown <neilb@suse.de>
2010-12-01 11:47:32 +11:00
NeilBrown ff63406404 Grow: give useful message when adding bitmap gives EBUSY.
If adding a bitmap fails with EBUSY, then it is because the array is
currently resyncing/recovering/reshaping.
As this is non-obvious, give a message explaining the fact.

Signed-off-by: NeilBrown <neilb@suse.de>
2010-11-30 16:34:25 +11:00
NeilBrown b3bd581b1d Fix warning about host-endian bitmaps.
Hostendian bitmaps should be warned about on all arch's.
And fix a speeling mistake.

Signed-off-by: NeilBrown <neilb@suse.de>
2010-11-30 16:25:26 +11:00
Adam Kwolek 1c009fc218 Compute backup blocks in function.
number of backup blocks evaluation is put in to function for code reuse.

Signed-off-by: Adam Kwolek <adam.kwolek@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
2010-11-30 13:30:22 +11:00
Adam Kwolek 130994cb83 Prepare and free fdlist in functions
fd handles table creation is put in to function for code reuse.

In manage_reshape(), child_grow() function from Grow.c will be reused.
To prepare parameters for this function, code from Grow.c can be
reused also.

Signed-off-by: Adam Kwolek <adam.kwolek@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
2010-11-30 13:27:08 +11:00
Adam Kwolek 62a48395f6 Disk removal support for Raid10->Raid0 takeover
Until now Raid10->Raid0 takeover was possible only if all the mirrors
where removed before md starts the takeover.  Now mdadm, when
performing Raid10->raid0 takeover, will remove all unwanted mirrors
from the array before actual md takeover is called.

Signed-off-by: Maciej Trela <maciej.trela@intel.com>
Signed-off-by: Adam Kwolek <adam.kwolek@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
2010-11-29 11:57:51 +11:00
Dan Williams 7f2ba464e4 External reshape (step 2): Freeze container
When growing the number of raid disks the reshape process will promote
container-spares to subarray-spares (later the kernel promotes them to
subarray-members in raid5_start_reshape()).  The automatic spare
promotion that mdmon performs upon seeing a degraded array must be
disabled until the reshape process has been initiated.  Otherwise, mdmon
may start a rebuild before the reshape parameters can be specified.

In the external case we arrange for the monitor to be blocked, and
turn off the safemode delay.
Mdmon is updated to check sync_action is not frozen before initiating
recovery.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
2010-11-23 16:39:58 +11:00
Dan Williams 7bc7119671 External reshape (step 1): container reshape and ->reshape_super()
In the native metadata case Grow_reshape() and the kernel validate what
reshapes are possible / supported and the kernel handles all the metadata
updates.  In the external case the metadata format may have specific
constraints above this baseline.  External formats also introduce the
constraint of only permitting some reshapes at container scope versus subarray
scope.  For exmaple imsm changes to 'raiddisks' must be applied to all arrays
in the container.

This operation assumes that its 'st' parameter has been obtained from
super_by_fd() (such that st->subarray is up to date), and that a snapshot of
the metadata has been loaded from the container.

Why a new method, versus extending an existing one?
->validate_geometry: this routine assumes it is being called from Create(),
adding reshape complicates the cases that this routine needs to handle.  Where
we find that checks can be shared between the two cases those routines
refactored into common code internal to the metadata handler, i.e. no need to
provide a unified external interface.  ->validate_geometry() also does not
expect to update the metadata.

->update_super: this is meant to update single fields at Assembly() and only at
the container scope.  Reshape potentially wants to update multiple fields at
either container or subarray scope.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
2010-11-23 16:09:27 +11:00
Dan Williams 72e4a37822 Grow: fix check for raid6 layout normalization
If the user does not specify a layout, don't skip asking about retaining
the non-standard raid6 layout which may be implicitly changed.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
2010-11-23 15:11:37 +11:00
Dan Williams 4411fb1749 Grow: mark some functions static
Going through the Grow api found some local routines that could be
marked static.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
2010-11-23 15:08:42 +11:00
NeilBrown 4725bc31fb super_by_fd: return subarray info explicitly.
Rather than hiding this in the 'st', return it explicitly.

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

Signed-off-by: NeilBrown <neilb@suse.de>
2010-11-22 19:35:25 +11:00
NeilBrown a5d85af748 get_info_super: report which other devices are thought to be working/failed.
To accurately detect when an array has been split and is now being
recombined, we need to track which other devices each thinks is
working.

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

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

Signed-off-by: NeilBrown <neilb@suse.de>
2010-11-22 19:35:25 +11:00
NeilBrown 925211e323 Grow: use raid_disks, not nr_disks
nr_disks is just wrong here - the arrays need room for all disk slots,
even if some are empty, plus spares, plus a possible backup file.
So raid_disks is correct.

Signed-off-by: NeilBrown <neilb@suse.de>
2010-08-06 14:40:53 +10:00
NeilBrown 7204495377 Fix writing of second backup superblock during grow
There 'rv' tests were confused and sometimes wrong.
This resulted in not writing the second bsb.

Also fix the test script so the the critical section is long enough
that we have some hope of interrupting it.

Signed-off-by: NeilBrown <neilb@suse.de>
2010-08-05 21:39:17 +10:00
NeilBrown f21e18ca89 Compile with -Wextra by default
This produced lots of warning, some of which pointed to actual bugs.

Signed-off-by: NeilBrown <neilb@suse.de>
2010-08-05 13:13:02 +10:00
NeilBrown 5f6ca90a9b Fix restarting of reshaping arrays.
We cannot get stripe_cache_size until after the array have
been activated!!

Signed-off-by: NeilBrown <neilb@suse.de>
2010-07-29 13:50:15 +10:00
NeilBrown b7e734fc22 Fix use of rv in Grow_reshape
1/ and extra local var was declared, which causes rv setting
   to be lost
2/ a -ve rv was left -ve while we should be return 1 on err.

Signed-off-by: NeilBrown <neilb@suse.de>
2010-07-29 13:16:01 +10:00
Doug Ledford 0155af90d8 Bugfix: don't issue a read larger than the buffer to hold it
Signed-off-by: Doug Ledford <dledford@redhat.com>
2010-07-22 10:16:31 -04:00
Dan Williams b526e52dc7 Always assume SKIP_GONE_DEVS behaviour and kill the flag
...i.e. GET_DEVS == (GET_DEVS|SKIP_GONE_DEVS)

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

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

Reported-by: Dave Jiang <dave.jiang@intel.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2010-06-16 17:26:04 -07:00
NeilBrown c03ef02d92 Grow: move error message closer to error cause.
A recent change move the sysfs_read call away from the check that it
succeeded.  This patch moves the check back next to the sysfs_read
call.

Signed-off-by: NeilBrown <neilb@suse.de>
2010-05-18 12:29:28 +10:00
NeilBrown 200871adf9 Grow: avoid overflow of chunk sizes.
Chunks aren't particularly big, but when you could them in bytes
and multiply them together (as we do for calculating the backup
size for 'grow') they can overflow a 32bit int.

So group the division by 512 more closely with the
chunk size so were would need 30Meg chunks to come close to
overflowing 32bits.

Signed-off-by: NeilBrown <neilb@suse.de>
2010-04-29 16:14:30 +10:00
NeilBrown ebeb366382 Don't attempt to create or read bitmaps where the metadata doesn't support it.
In particular, if the relevant bitmap method is NULL, don't try to
call it, print an error instead.

Signed-off-by: NeilBrown <neilb@suse.de>
2010-04-07 09:18:01 +10:00
NeilBrown a847575aa1 Grow: fix recent breakage - lseek return status.
Recent fix to check lseek64 return status got it badly wrong.
It doesn't return 0 on success!!

Fix it.

Signed-off-by: NeilBrown <neilb@suse.de>
2010-03-10 15:21:28 +11:00
NeilBrown be1cabbd29 Grow: fix problem with validating chunk size
When checking if the new chunk size fit in the component size
we were confusing sectors and K, and so getting it wrong.

Signed-off-by: NeilBrown <neilb@suse.de>
2010-03-09 14:14:39 +11:00
NeilBrown fcf5762500 Add _FORTIFY_SOURCE to mdadm.O2 build.
When building mdadm.O2, set _FORTIFY_SOURCE to get more
warnings, and also build mdmon.O2 to find warnings in that
code too.
Then fix the warnings.

Suggested-by: Luca Berra <bluca@comedia.it>
Signed-off-by: NeilBrown <neilb@suse.de>
2010-03-03 10:54:17 +11:00
NeilBrown 53f5035339 Fix warning about unused variable.
Warning only appears with -O2, but is invalid.

Signed-off-by: NeilBrown <neilb@suse.de>
2010-03-03 10:29:24 +11:00
NeilBrown 097075b611 Grow: be more relaxed about timestamp mismatches on backup file.
As backup file has a timestamp which is updated quite separately
from the metadata timestamp.  They should be largely in-sync but
sometimes are not.
So be more generous in the check, and allow it to be over-ridden
by an environment variable.

Signed-off-by: NeilBrown <neilb@suse.de>
2010-02-24 11:59:11 +11:00
NeilBrown 39bbb39202 Grow: If bitmap interferes with grow, report this.
If a bitmap exists on an array, then current kernels cannot grow
that array.
So when we try to grow an array, test for EBUSY and if a bitmap is
present, report that the bitmap needs to be removed.

Resolves-Debian-Bug: 534571
Signed-off-by: NeilBrown <neilb@suse.de>
2010-01-28 11:48:03 +11:00
NeilBrown 080fd00521 Remove stray debugging printfs
These were never supposed to be released, and due
to a type issue they cause compile problems on
some architectures.

Resolves-Debian-Bug: 567167
Signed-off-by: NeilBrown <neilb@suse.de>
2010-01-28 08:55:18 +11:00
NeilBrown f98841b385 Grow: be more careful when using array.size
As array.size is 32bit we need to prefer the 'component_size'
read from sysfs when that is available.
Grow wasn't always suitably careful.

Signed-off-by: NeilBrown <neilb@suse.de>
2009-11-26 16:28:35 +11:00
NeilBrown 2ed4f75388 Grow: avoid truncation error when checking size of array.
array.size is only 32bit so it is not safe to multiply it
up before casting to (long long).
Actually, we shouldn't be using array.size here at all, but that
will get fixed in a subsequent patch.

Reported-by: Andrew Burgess <aab@cichlid.com>
Signed-off-by: NeilBrown <neilb@suse.de>
2009-11-26 14:19:26 +11:00
NeilBrown ff94fb86fd Grow: various fixes to recent breakages.
- I forgot to write the send backup-super-block on spares.
- I wasn't adding the data_offset to an offset

Signed-off-by: NeilBrown <neilb@suse.de>
2009-11-17 13:15:33 +11:00
NeilBrown 14e5b4d72b Grow: data_offset is in sectors, offsets[] is in bytes - convert
Another missed sectors->bytes conversion.

Signed-off-by: NeilBrown <neilb@suse.de>
2009-11-16 11:06:44 +11:00
NeilBrown 9ce510be9c Grow: do not allow size changes with other changes.
A change the reduces the size of an array always happens
before any other change.  So it can cause data to be lost.
By themselves these changes are reversible.  But once another
change has started, the data would be permanently lost.
So recommend data integrity be checked between a size change
and any other change.

Signed-off-by: NeilBrown <neilb@suse.de>
2009-11-06 17:26:47 +11:00
NeilBrown b5ea446ae7 Grow: goto release rather than just return
otherwise we exit with the array frozen.

Signed-off-by: NeilBrown <neilb@suse.de>
2009-11-06 15:22:14 +11:00
NeilBrown d2505cff5a Grow: restrict to 2.6.32
2.6.31 has a bug which can lead to unsafe reshaping.
So only allow a reshape with 2.6.32.
When the required fixed get into 2.6.31.y, this can be relaxed
slightly

Signed-off-by: NeilBrown <neilb@suse.de>
2009-11-06 15:19:39 +11:00
NeilBrown 1b13faf757 Grow: use large block count and make sure stripe cache can hold it.
The bigger the backup is, the fast it goes to some extend.

16Meg is fairly arbitrary

Signed-off-by: NeilBrown <neilb@suse.de>
2009-11-06 14:48:10 +11:00
NeilBrown e380d3be42 Grow: get component_size before using it.
We were using ->component_size while it hadn't been set.
This effectively meant that 'blocks' wasn't multiplied by
16 and reshape was even slower than it should have been.

Signed-off-by: NeilBrown <neilb@suse.de>
2009-11-06 14:18:49 +11:00
NeilBrown d44453876e Grow: handle array going degraded during reshape.
If an array goes degraded during reshape, we need to
adjust the devices we read from so as not to back up
stale data.

Signed-off-by: NeilBrown <neilb@suse.de>
2009-11-06 13:56:05 +11:00
NeilBrown 92dcdf7c01 Grow: restore backup to proper location.
The 'arraystart' is in sectors while restore_stripes requires
bytes, so we need a conversion.

Without this, backups get restored to the wrong offset.

Reported-by: "KueiHuan Chen" <kueihuan.chen@gmail.com>
Signed-off-by: NeilBrown <neilb@suse.de>
2009-11-06 13:38:43 +11:00
NeilBrown 9739642288 Grow: update backup-metadata mtime every time we write it.
Originally the backup-metadata was only written once at the
start of a raid5 reshape that made the array bigger.  So we only
set the mtime once.

Now that we can be writing metadata continually during an in-place
reshape, we need to update the mtime more often.

Also, allow the metadata mtime to be slightly in advance of the
array mtime.  Normally the difference will be less than a second,
so 10 minutes should be plenty.  This guards against an old backup
file being used to restart an array.  but starting two reshapes in the
10 minutes is sufficiently unlikely, and the possibility of an
accident is already sufficiently small, that 10 minutes is probably
fine.

Thanks to Guy Martin <gmsoft@tuxicoman.be> for discovering and
reporting that .mtime wasn't being updated properly.

Signed-off-by: NeilBrown <neilb@suse.de>
2009-10-22 10:42:06 +11:00
NeilBrown 24d40069d7 Grow: reject raid-disks reduction in RAID5 etc before 2.6.32
2.6.31 has some bugs with restarting a RAID5 reduction, so
refuse to try unless at least 2.6.32.

Signed-off-by: NeilBrown <neilb@suse.de>
2009-10-20 16:36:03 +11:00
NeilBrown ea0ebe9685 Assemble: print more verbose messages about restarting a reshape
Signed-off-by: NeilBrown <neilb@suse.de>
2009-10-20 16:23:45 +11:00
NeilBrown 22e305169f Add missing 'continue' in Grow_restart.
Thus we weren't checking the uuid properly.

Signed-off-by: NeilBrown <neilb@suse.de>
2009-10-20 15:36:49 +11:00
NeilBrown 82f2d6abf0 Grow_restart to handle reducing number of devices in an array.
FIXME this is wrong . what direction does reshape_position move?

If the device count in an array is shrinking, the critical
region is different so the tests need to be different when
restarting.

Signed-off-by: NeilBrown <neilb@suse.de>
2009-10-16 17:43:51 +11:00
NeilBrown eba7152931 Grow: don't make 'blocks' too large during in-place reshape.
On small (test) arrays, multiplying by 16 can make the 'chunk' size
larger than half the array, which is a problem.

Signed-off-by: NeilBrown <neilb@suse.de>
2009-10-16 17:02:34 +11:00
NeilBrown 725cac4c56 Grow: ignore error from final wait_backup
The last time wait_backup is called, it might see reshape
finish and so return an error indicator.
But this is not an error, and we must go ahead and prepare
the array for full access.

Signed-off-by: NeilBrown <neilb@suse.de>
2009-10-12 16:55:19 +11:00
NeilBrown 5fdf37e357 Grow: make sure bsb2 is properly aligned
We do O_DIRECT io in bsb2, so it must be aligned
properly.  Easiest if it is static.

Signed-off-by: NeilBrown <neilb@suse.de>
2009-10-12 16:55:12 +11:00
NeilBrown ca4f89a3b7 Merge branch 'master' into devel-3.1
Conflicts:
	mdadm.8
2009-10-01 16:58:40 +10:00
NeilBrown e9e43ec367 Grow: support restart of new migrations. 2009-08-13 11:12:54 +10:00
NeilBrown 7236ee7ad4 Handle extra 'grow' variations.
UNFINISHED
2009-08-11 13:02:49 +10:00
NeilBrown a628848379 restripe: support saving when not all devices are present. 2009-07-14 15:12:30 +10:00
NeilBrown 5f4fc0e191 Grow: --size improvements.
1/ allow --size to be given with 'G' or 'T' suffix.
2/ allow size to exceed 32bits, and in that case write through sysfs.

Signed-off-by: NeilBrown <neilb@suse.de>
2009-07-14 14:32:30 +10:00
NeilBrown 19678e536d Grow: pass layout as a string rather than a number.
This allows the layout to be parsed after the current level of the
array is know, so that the level doesn't need to be given (otherwise
pointlessly) on the command line.

Signed-off-by: NeilBrown <neilb@suse.de>
2009-07-14 12:13:29 +10:00
NeilBrown e736b62389 Update copyright dates and remove references to @cse.unsw.edu.au
Also removed 'paper' addresses.

Signed-off-by: NeilBrown <neilb@suse.de>
2009-06-02 14:35:45 +10:00
NeilBrown c256924e52 Merge branch 'master' of git://github.com/djbw/mdadm into devel-3.0
Conflicts:
	Grow.c
	mdadm.h
	sysfs.c
Due to independent fixes for the "mdadm hangs if reshape finishes too quickly"
problem.
2009-04-14 11:11:14 +10:00
Dan Williams 48924014b0 Grow: fix hang when reshape completes too fast
For short reshapes the kernel may be done before mdadm can check that
progress has passed the critical section.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2009-04-12 00:58:28 -07:00
NeilBrown 93ecfa01d4 grow: don't wait forever for critical section to pass.
If an array reshape completed within 1 second, then --grow will not
notice that it has finished and will keep waiting for the critical
section to pass.

So be more cautious in the test.

Signed-off-by: NeilBrown <neilb@suse.de>
2009-04-01 12:26:08 +11:00
NeilBrown 94a20f0c80 Fix alignment for backup of reshape data.
Since we introduced O_DIRECT for device access we need
properly aligned buffers and IO requests.  The reshape code
missed out on the conversion.

Signed-off-by: NeilBrown <neilb@suse.de>
2008-08-19 17:55:15 +10:00
NeilBrown 37ea3936a6 Merge branch 'master' into from-stable
Conflicts:

	Create.c
	Manage.c
2008-08-07 14:12:25 +10:00
Doug Ledford fb97b4d691 Clean up usage of open()
Fix on call that passed an invalid mode to open
	Don't pass a third arg unless we also pass O_CREAT
	Use symbolic args for 2nd and 3rd args

Signed-off-by: Doug Ledford <dledford@redhat.com>
2008-07-24 18:35:11 -04:00
Neil Brown 6416d5275d Use O_DIRECT for all IO to devices.
Using buffered IO risks non-atomic updates to parts of the
device that we don't actually want to write to.  This isn't in
general safe.
So switch to O_DIRECT for all that IO and make sure we have
properly aligned buffers.
2008-07-12 20:28:33 +10:00
Neil Brown 0aa389dc62 Add test for stoping and restarting a raid5 reshape.
There was a kernel bug with stopping and restarting
raid5 recently.  So add a test to check for it.
2008-06-27 16:07:52 +10:00
Neil Brown 7e0f69790c Replace sysarray with mdinfo
Sure, mdinfo is bigger, but having a uniform structure for lots of things
will make life easier.
2007-12-14 20:14:59 +11:00
Neil Brown 06c7f68e40 Use 'mdinfo' instead of special 'sysdev' structure.
there is needless duplicatiion between mdinfo and sysdev, so discard
the latter.
2007-12-14 20:14:57 +11:00
Neil Brown 1686dc25ec Find super from fd on an array.
We used to use the major/minor numbers, but that isn't sufficient
any more, so pass the fd, and possibly check 'text' version.
2007-12-14 20:14:38 +11:00
Neil Brown 3da92f272d Drop the superblock arg from all metadata methods.
It is now in the 'supertype'
2007-12-14 20:14:33 +11:00
Neil Brown 68c7d6d790 Add 'supertype' arg to almost all metadata methods.
The 'superblock' will be moved into this structure soon.
2007-12-14 20:14:16 +11:00
Neil Brown df37ffc039 Allow metadata handlers to free their own superblock.
As the metadata handler allocates the superblock, it should free it
too.  DDF will have a more complex 'superblock' which needs more complex
freeing.
2007-12-14 20:14:00 +11:00
Neil Brown aba69144fd Remove spaces/tabs from ends of lines. 2007-12-14 20:13:43 +11:00
Neil Brown 6e9eac4f08 Fix restarting of a reshaping array.
The last release broke the ability to assemble an array that
was in the middle of a reshape.
This patch adds code to test if the critical section needs
to be restored or not so that - if we have failed to restore it,
we know whether to fail or not.
2007-10-16 13:52:35 +10:00
Neil Brown 2295250a73 Report error when grow cannot be restarted.
Make sure that if --assemble find an array in the critical region
of a reshape, and cannot find the critical data to restart the
reshape, it gives an error message.
2007-08-20 14:14:42 +10:00
Neil Brown 5b28bd5672 Improve error message for adding bitmap to a level that cannot support it.
Also give error on --build if no devices given.
2007-05-21 14:25:47 +10:00
Neil Brown f752781f81 Fix --grow --add for linear arrays.
The new superblock needs to have a new disk.number.  This is a bit of a hack...
Fix handling of negative bitmap offsets on 64bit hosts.

The bitmap offset is a signed 32bit number, so casting to (long)
isn't sufficient.  We must cast to (int32_t).
Fix various problems with --grow --add for linear.

The code to add a drive to a live linear array had never
been tested properly and so was buggy.  This tidies it up
and means that the new regression-test passes.
2007-05-21 14:25:37 +10:00
Neil Brown beae1dfe2e Central calls to ioctl BLKGETSIZE
Instead of opencoding the same thing everywhere.
2006-12-14 17:32:57 +11:00
Neil Brown 758d3a8e7d Increase raid456 stripe cache size if needed to --grow the array.
The setting used unfortunately requires intimate knowledge of the
kernel, and it not reset when the reshape finishes.
2006-12-14 17:31:16 +11:00
Neil Brown 199171a297 Improve allocation and use of space for bitmaps in version1 metadata
Depending on the size of the array we reserve space for up to 128K
of bitmap, and we use it where possible.
When hot-adding to a version 1.0 we can still only use the 3K at the
end though - need a sysfs interface to improve that.

If a small chunksize is requested on Create, we don't auto-enlarge
the reserved space - this still needs to be fixed.
2006-12-14 17:31:00 +11:00
Neil Brown e81cdd9f37 Stop map_dev from returning [0:0]
We sometimes need the NULL when major==minor==0.
So make sure all callers of map_dev can cope with NULL.
2006-06-20 10:01:43 +10:00
Neil Brown 9fca7d6236 check return status of all write/fwrite functions as required by glibc 2.4
From: Luca Berra <bluca@vodka.it>

glibc 2.4 is pedantic on ignoring return values from fprintf, fwrite and
write, so now we check the rval and actually do something with it.
in the Grow.c case i only print a warning, since i don't think we can do
anything in case we fail invalidating those superblocks (is should never
happen, but then...)

Signed-off-by: Neil Brown <neilb@suse.de>
2006-05-29 02:06:32 +00:00
Neil Brown e5eac01f3d Make sure homehost is set correctly when --update=uuid
Signed-off-by: Neil Brown <neilb@suse.de>
2006-05-23 04:51:39 +00:00
Neil Brown 4f589ad0c5 Just updaqte copyright dates and email address
Signed-off-by: Neil Brown <neilb@suse.de>
2006-05-19 05:25:11 +00:00
Neil Brown 1bfdbe01ff Limit size of bitmap to 2million chunks.
When creating a file bitmap, choose a default size that
results in fewer than 2^21 chunks.  Without this kmalloc
failure in the kernel becomes likely.

Signed-off-by: Neil Brown <neilb@suse.de>
2006-05-15 04:21:33 +00:00
Neil Brown 8686f3ed06 Fix problem with sector/KB size confuision for bitmap sizing.
Signed-off-by: Neil Brown <neilb@suse.de>
2006-05-15 03:57:53 +00:00
Neil Brown 9860f2711d Bug fixes to pass test suite
Signed-off-by: Neil Brown <neilb@suse.de>
2006-03-29 06:28:07 +00:00
Neil Brown 16c6fa807c Create missing /dev files where needed.
Whenever we need a device file to open, if one cannot be found in /dev,
create a temporary one.

Signed-off-by: Neil Brown <neilb@suse.de>
2006-03-28 06:26:53 +00:00
Neil Brown 06b0d78675 Allow resize to backup to a file.
To support resizing an array without a spare, mdadm now understands
  --backup-file=
which should point to a file for storing a backup of critical data.
This can be given to --grow which will create the file, or
--assemble which will restore from the file if needed.

Signed-off-by: Neil Brown <neilb@suse.de>
2006-03-27 06:38:46 +00:00
Neil Brown 313176636e Remove ident arg from getinfo_super;
Add a 'name' field to 'info' to compensate.

Signed-off-by: Neil Brown <neilb@suse.de>
2006-03-27 04:34:38 +00:00
Neil Brown 2efedc7bd2 Put a 'canary' block in front of the backup
.. so corruptio can be detected.

Signed-off-by: Neil Brown <neilb@suse.de>
2006-03-27 04:14:43 +00:00
Neil Brown 206c5eaedf Fix a few issues with the reshape patches.
Signed-off-by: Neil Brown <neilb@suse.de>
2006-03-20 03:26:42 +00:00
Neil Brown 353632d927 Support restarting of a reshape on --assemble
Signed-off-by: Neil Brown <neilb@suse.de>
2006-03-20 03:17:31 +00:00
Neil Brown e86c9dd6d8 Initial reshape support
Needs work for other levels etc.

Signed-off-by: Neil Brown <neilb@suse.de>
2006-03-13 05:51:32 +00:00
Neil Brown 8fac0577f0 Stuff like..
- report Intent Bitmap in --detail
- report internal bitmap in --examine
- pass' --force through to --grow --bitmap
- support v.large arrays in --grow --bitmap

Signed-off-by: Neil Brown <neilb@suse.de>
2006-01-30 23:23:45 +00:00
Neil Brown 21e92547e7 Work towards allowing larger internal bitmaps in version1 superblocks.
Signed-off-by: Neil Brown <neilb@suse.de>
2006-01-30 02:57:49 +00:00
Neil Brown f9c25f1d2a Support bitmaps with raid10
And a couple of other little things

Signed-off-by: Neil Brown <neilb@suse.de>
2005-11-22 03:37:14 +00:00