Commit Graph

1675 Commits

Author SHA1 Message Date
Labun Marcin 120dc88745 imsm: prepare detail_platform_imsm to support different types of controllers
Pull out the AHCI specific parts of detail_platform_imsm to separate functions.
Introduce support new types of controllers.

Based on code From: Artur Wojcik <artur.wojcik@intel.com>
Signed-off-by: Marcin Labun <marcin.labun@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
2011-01-26 11:21:29 +10:00
Labun Marcin 88654014d4 imsm: support for Intel(R) SAS controller in imsm handler
add_to_super_imsm handler is able to recognize new type of controller.
It stores the controller information in its structures and blocks
mixing of different controller type in the same container.
In this way it maintains compatibility between Linux and Windows IMSM RAID
stacks. IMSM metadata does not allow arrays to span on devices attached to
different storage controllers.

Based on code From: Artur Wojcik <artur.wojcik@intel.com>
Signed-off-by: Marcin Labun <marcin.labun@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
2011-01-26 11:09:57 +10:00
Labun Marcin a8e5382a54 imsm platform: support for Intel(R) SAS controller.
This patch adds platform support for SAS controller(s) built in Intel(R) Patsburg
chipset.

Signed-off-by: Marcin Labun <marcin.labun@intel.com>
Signed-off-by: Artur Wojcik <artur.wojcik@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
2011-01-26 11:06:55 +10:00
Krzysztof Wojcik 10ce18083d FIX: Reset disk state if disk is missing
If we can't read actual disk state, it shoud be initiated
to 0.
Overwise it may be out of date value resulting false action
later in code (e.g. set disk to improper state).

Signed-off-by: Krzysztof Wojcik <krzysztof.wojcik@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
2011-01-26 10:47:52 +10:00
Krzysztof Wojcik 43d5ec1844 Check number of failed disks durig raid10->raid0 takeover
Number of failed disks MUST be half of initial number of disks.
If number of failed disks is different we should not update
metadata- data corruption may occur after array reassemlation.

Signed-off-by: Krzysztof Wojcik <krzysztof.wojcik@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
2011-01-26 10:44:59 +10:00
Krzysztof Wojcik 8ca6df95a2 raid0->raid10 takeover- process metadata update
Implementation of raid0->raid10 takeover metadata update
at process_update level.
- We are using memory previously allocated in prepare_update to
  create two dummy disks will be inserted in the metadata and
  new imsm_dev structure with expanded disk order table.
- Update indexes in disk list
- Update metadata map
- Update disk order table

Signed-off-by: Krzysztof Wojcik <krzysztof.wojcik@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
2011-01-26 10:41:27 +10:00
Krzysztof Wojcik abedf5fc46 raid0->raid10 takeover- allocate memory for added disks
Allocate memory will be used in process_update.
For raid0->raid10 takeover operation number of disks doubles
so we should allocate memory for additional disks
and one imsm_dev structure with extended order table.

Signed-off-by: Krzysztof Wojcik <krzysztof.wojcik@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
2011-01-26 10:38:10 +10:00
Krzysztof Wojcik 0529c688e8 raid0->raid10 takeover- create metadata update
Create metadata update for raid0 -> raid10 takeover.
Because we have no mdmon running for raid0 we have to
update metadata using local update mechanism

Signed-off-by: Krzysztof Wojcik <krzysztof.wojcik@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
2011-01-26 10:38:00 +10: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 1cc7f4feb9 Don't close fds in write_init_super
We previously closed all 'fds' associated with an array in
write_init_super .. sometimes, and sometimes at bad times.
This isn't neat and free_super is a better place to close them.

So make sure free_super always closes the fds that the metadata
manager kept hold of, and stop closing them in write_init_super.

Also add a few more calls to free_super to make sure they really do
get closed.

Reported-by: Adam Kwolek <adam.kwolek@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
2011-01-25 07:56:53 +11: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
Krzysztof Wojcik 471bceb681 Define imsm_analyze_change function
Function intended to use for single volume migration.
Function analyze transition and validate if it is supported.

Signed-off-by: Krzysztof Wojcik <krzysztof.wojcik@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
2011-01-17 12:52:36 +11:00
Czarnowska, Anna 300f503323 fix: Monitor: min_size must be set to 0
Otherwise a random value will be used for comparison later
for native and ddf metadata (until min_acceptable_spare_size is defined).

Signed-off-by: Anna Czarnowska <anna.czarnowska@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
2011-01-17 12:46:14 +11:00
Adam Kwolek 2a9f840972 FIX: sync_completed == 0 causes reshape cancellation in metadata
md signals reshape completion (whole area or parts) by setting
sync_completed to 0.  This causes in set_array_state() to rollback
metadata changes (super-intel.c:4977.  To avoid this do not allow for
set last_checkpoint to 0 if reshape is finished.

This was also root cause of my previous fix for finalization reshape
that I agreed earlier is not necessary,

Signed-off-by: Adam Kwolek <adam.kwolek@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
2011-01-17 12:44:52 +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
Czarnowska, Anna c0dc0ad5f8 fix: segfault if subarray is monitored but container is not
In this situation to->parent is null so "to" doesn't change to
parent container and to->metadata is still null.
This results in segmentation fault when checking
to->metadata->ss->external.
We should just skip this array as container is needed to move spares to.

Signed-off-by: Anna Czarnowska <anna.czarnowska@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
2011-01-17 12:01:11 +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
Krzysztof Wojcik 694575e786 reshape_super reorganization
Function has been divided into two clear parts:
1. Container operations
2. Volume operations

Prototype of imsm_analyze_change function has been added.

Signed-off-by: Krzysztof Wojcik <krzysztof.wojcik@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
2011-01-13 13:02:44 +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 04c3c51413 imsm: FIX: spares are not counted
Field info->array.spare_disks is used on begin of reshape_array() to
check if there is enough number of spares to process reshape.  During
container_content_imsm() call spare disks are not counted.  This
causes that reshape_array() reports that there is not enough spares to
execute reshape.

Patch adds spares counting for reshape process.

Signed-off-by: Adam Kwolek <adam.kwolek@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
2011-01-13 10:16:07 +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
Adam Kwolek 819bc6345e imsm: FIX: old devices memory has to be released
When process_update() replaces memory for bigger devices, old memory
areas are collected in a list and has to be assigned in to pointer in
update for later release.

List created from old devices is created and attached to space_list
for later releasing.

Signed-off-by: Adam Kwolek <adam.kwolek@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
2011-01-13 10:06:29 +11:00
Adam Kwolek f557efbb3f imsm: FIX: local mdadm update shouldn't be done in update creation function.
Local update is performed based on created update, so this code can broke
local update and it is not necessary as prepare and process update functions
are used.

Code removed.

Signed-off-by: Adam Kwolek <adam.kwolek@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
2011-01-13 10:05:31 +11:00
Adam Kwolek 8dd70bce5b imsm: FIX: mdadm should process local data
When update is created by mdadm, local information should be updated
also.  This makes us to prepare one update for mdmon and second
"update" to maintain local changes.  we can use prepared update for
"local/mdadm" metadata update purposes.

We have 2 cases:
1. when metadata is updated by mdmon, we avoid metadata reloading in
   mdadm.
   we proceed the same updtate 2 times:
	- one time in mdadm for "local update"
        - second time in mdmon for real metadat update
2. when metadata is updated by mdadm (no mdmon running) updates are
   processed in the same way.
	- one time in mdadm for "local update"
	- there is no "second time" update but mdadm just flushes
          metadata to array

   This let us to avoid code duplication by using prepare and process
   update functions as for update via mdmon. This makes update
   preparing mdmon independent and there is no need to maintain the
   same thing in 2 places in code.

Signed-off-by: Adam Kwolek <adam.kwolek@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
2011-01-13 10:04:33 +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 bbd24d8616 imsm: FIX: only one spare is passed in update
Only one spare is passed in update.
When more than one disk is added first spare is passed multiple times.

Signed-off-by: Adam Kwolek <adam.kwolek@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
2011-01-12 16:46:38 +11:00
Adam Kwolek ee4beede22 imsm: FIX: set correct slot information in metadata (raid0)
Slot was set based on anchor information.
Disks information was copied outside disk list area.

Signed-off-by: Adam Kwolek <adam.kwolek@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
2011-01-12 16:40:42 +11:00
NeilBrown 4a011f1009 load_super should not try to load_container
Now that load_container is a separate operation, load_super
should not try it first.

Signed-off-by: NeilBrown <neilb@suse.de>
2011-01-12 16:18:04 +11:00
Anna Czarnowska de697acc4c Monitor: skip array if error getting size
load_super tries to load container first anyway but if it fails
eg. after physically removing a disk
then it tries to read metadata from container device.
This will always fail and print confusing errors.
So use load_container instead of load_super on container.

On failure to read metadata we should skip this array.
It will be dealt with the next time round.

Signed-off-by: Anna Czarnowska <anna.czarnowska@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
2011-01-12 16:16:14 +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
Adam Kwolek 86e3692b06 imsm: FIX: update disks status in container_contents()
Based on status information disks are added to array during grow (in reshape_array()).
This information currently is not present and all disks (old and new) were added to md.
To avoid adding already present disks, disk.state has to be set.

Signed-off-by: Adam Kwolek <adam.kwolek@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
2011-01-12 15:12:44 +11:00