Commit Graph

701 Commits

Author SHA1 Message Date
Adam Kwolek 0228d92ca3 imsm: FIX: Detect migration end during migration record saving
Checkpoint should be saved when migration is in progress only.
End of reshape (based on passes status) should be detected and it should
not cause abort of reshape/check-pointing/ operation.

Signed-off-by: Adam Kwolek <adam.kwolek@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
2011-06-09 13:00:55 +10:00
Adam Kwolek 2e062e8210 imsm: FIX: Verify if migration record is loaded correctly
Migration compatibility can be checked when general migration record
is present.

Signed-off-by: Adam Kwolek <adam.kwolek@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
2011-06-09 13:00:54 +10:00
Adam Kwolek 6b7a407dce imsm: FIX: Opened handle is not closed
Opened file handle should be closed before function exit.

Signed-off-by: Adam Kwolek <adam.kwolek@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
2011-06-09 13:00:54 +10:00
NeilBrown 9894ec0d64 Fix some fall-out from recent memset-zero for getinfo_super
container_content_imsm was setting info->next before calling
getinfo_super_imsm_container which now zeros everything.
So move that assignment to afterwards.

So both imsm and ddf were assuming info->disk.raid_disk means
something but it doesn't.  So fix those.

Signed-off-by: NeilBrown <neilb@suse.de>
2011-06-09 12:42:02 +10:00
Adam Kwolek 480be36336 imsm: Remove user warning before reshape start
imsm's arrays supports imsm native check-pointing now.
User warning is no longer required.

Signed-off-by: Adam Kwolek <adam.kwolek@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
2011-06-08 17:14:33 +10:00
Adam Kwolek 0ec5d470e0 imsm: Apply checkpoint metadata update for general migration
mdmon has to update checkpoint information in metadata during
general migration according to received metadata update.

Signed-off-by: Adam Kwolek <adam.kwolek@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
2011-06-08 17:13:21 +10:00
Adam Kwolek c17608eac3 imsm: Prepare checkpoint update for general migration
mdadm has to prepare checkpoint information update and send it to mdmon.

Signed-off-by: Adam Kwolek <adam.kwolek@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
2011-06-08 17:12:48 +10:00
Adam Kwolek 2d40f3a132 imsm: Add metadata update type for general migration check-pointing
There are 2 places for keeping checkpoint information:
- metadata (per volume information used during volume
  initialization and rebuilding).
- migration record (per container information used during
  migration/reshape)

During reshape both checkpoints has to contains the same information.
To do this mdadm will send metadta update with checkpoint information.

Note: Checkpoint information consistence is not critical. During general
      migration restart, information from migration record is used only.

Signed-off-by: Adam Kwolek <adam.kwolek@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
2011-06-08 17:12:39 +10:00
Adam Kwolek 5b83bacff6 imsm: Disable checkpoint updating by mdmon for general migration
imsm contains 2 check-pointing mechanism. One (per array) is used for
initialization and rebuild and second (per container) is used for general
migration (reshape). First is controlled by mdmon, second by mdadm.
To avoid conflicts disable mdmon checkpoints updating for general
migration.

Signed-off-by: Adam Kwolek <adam.kwolek@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
2011-06-08 17:11:49 +10:00
Adam Kwolek 276d77db1f imsm: Implement recover_backup_imsm() for imsm metadata
Add ability to restore data backed up in General Migration Copy Area
in case of unexpected reshape interruption.
Function restores data during an array assembly and then reshape
is continues from next checkpoint.

Signed-off-by: Krzysztof Wojcik <krzysztof.wojcik@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
2011-06-08 17:11:23 +10:00
Adam Kwolek c47b0ff69a imsm: update blocks_per_migr_unit() to support migration record
blocks_per_migr_unit() has to use information from migration record
for general migration case. This causes to pass intel_super pointer
to this function and some other interfaces changes.

Signed-off-by: Adam Kwolek <adam.kwolek@intel.com>
Signed-off-by: Krzysztof Wojcik <krzysztof.wojcik@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
2011-06-08 17:09:50 +10:00
Adam Kwolek 520e69e25c imsm: Add information about migration record to mdadm '-E' option
Add ability to display information from migration record in examine
option.

Signed-off-by: Adam Kwolek <adam.kwolek@intel.com>
Signed-off-by: Krzysztof Wojcik <krzysztof.wojcik@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
2011-06-08 17:09:29 +10:00
Adam Kwolek 146c626037 imsm: Clear migration record when no migration in progress
When metadata is saved and there is no general migration in progress
/in container/ clear migration record in container.

Signed-off-by: Adam Kwolek <adam.kwolek@intel.com>
Signed-off-by: Krzysztof Wojcik <krzysztof.wojcik@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
2011-06-08 17:09:16 +10:00
Adam Kwolek b915c95fd3 imsm: Check if array degradation has been changed
Before reshaping every "migration unit", check if array is still usable.
In failed disks number is greater than allowed degradation level, reshape
has to be aborted.

Signed-off-by: Maciej Trela <maciej.trela@intel.com>
Signed-off-by: Adam Kwolek <adam.kwolek@intel.com>
Signed-off-by: Krzysztof Wojcik <krzysztof.wojcik@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
2011-06-08 17:09:09 +10:00
Adam Kwolek 10f228541c imsm: Implement imsm_manage_reshape(), reshape workhorse
Before reshape is started, mdadm should check again if there is only one
array (in container) under reshape. Then function "divides" array in to
"migration units" that can fits migration copy area and enters main loop.
It checks if current "migration unit" requires to be backed up.
If necessary mdadm saves it to copy area and updates migration record.
Then MD-driver is directed to perform reshape step (by "migration unit" size)
and checkpoint is moved forward. In this way reshape is executed until
array ends.

Signed-off-by: Adam Kwolek <adam.kwolek@intel.com>
Signed-off-by: Krzysztof Wojcik <krzysztof.wojcik@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
2011-06-08 17:09:08 +10:00
Adam Kwolek eee67a47f2 imsm: Add wait_for_reshape_imsm() implementation
After each checkpoint mdadm should set new reshaped area and wait
until md finishes reshape. Function wait_for_reshape_imsm() sets
new reshape range and waits for job completion.

Signed-off-by: Adam Kwolek <adam.kwolek@intel.com>
Signed-off-by: Krzysztof Wojcik <krzysztof.wojcik@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
2011-06-08 17:07:10 +10:00
Adam Kwolek e2f41b2c6a imsm: check migration compatibility
Under Windows IMSM can reshape arrays in 2 directions
(ascending and decsending).
Under Linux one (ascending) direction is supported at this moment.
Block loading metadata when decsending reshape is detected

Windows also uses optimalization area during reshaping array.
Linux does not support it.
The patch blocks this operation also.

Signed-off-by: Maciej Trela <maciej.trela@intel.com>
Signed-off-by: Adam Kwolek <adam.kwolek@intel.com>
Signed-off-by: Krzysztof Wojcik <krzysztof.wojcik@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
2011-06-08 16:46:37 +10:00
Adam Kwolek 687629c2b2 imsm: Add support for copy area and backup operations
This patch adds methods of manipulating migration record:
init_migr_record_imsm() - initiate migration record at the beginning of
     the reshape process
write_imsm_migr_rec() - saves migration record to array.
     Migration record is stored on 2 first disks in array only.
save_backup_imsm() - saves critical data stripes to Migration Copy Area
     and updates the current migration unit status.
     Uses restore_stripes() to format a destination stripe, and to write it
     to the Migration Copy Area.
save_checkpoint_imsm() - Updates the current unit status in the
     migration record.

Migration record is written to 2 first array disks only (similar to reading
operation).

Signed-off-by: Maciej Trela <maciej.trela@intel.com>
Signed-off-by: Adam Kwolek <adam.kwolek@intel.com>
Signed-off-by: Krzysztof Wojcik <krzysztof.wojcik@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
2011-06-08 16:46:35 +10:00
Adam Kwolek 8e59f3d882 imsm: Add migration record to intel_super
IMSM for securing reshape process uses special disk area outside metadata
for reshaped area backup purposes. If just reshaped array area requires
backup, bunch of array stripes prepared for reshape is stored in to
Migration Copy Area. In case of reshape interruption, Option ROM during
restart or mdadm during reshape restart (when no reboot occurs) will
restore Migration Copy Area to designation array. Reshape can be
continued from stable array stable state.

This patch adds support for IMSM migration record structure.
IMSM migration record is stored on the first two disks of IMSM volume
during the migration.

Add function for reading migration record, so mdadm can read (if present)
migration record. Migration record has to be cleared every time
MIGR_GEN_MIGR is started.

Signed-off-by: Maciej Trela <maciej.trela@intel.com>
Signed-off-by: Adam Kwolek <adam.kwolek@intel.com>
Signed-off-by: Krzysztof Wojcik <krzysztof.wojcik@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
2011-06-08 16:19:06 +10:00
NeilBrown 95eeceeb32 getinfo_super now clears the 'info' structure before filling it in.
Some code currently clears 'info' before calling getinfo_super,
some code doesn't.

To be consistent, change it so no caller ever clears 'info',
but ever getinfo_super function must clear it.

Note that ->raid_disk may be meaningful if that 'map' is passed
non-NULL.  In that case it is copied out before the structure
is zeroed.

Signed-off-by: NeilBrown <neilb@suse.de>
2011-06-08 15:54:13 +10:00
Przemyslaw Czarnowski 4bba043921 imsm: add new chunk size to metadata update
Put information about new chunk size change in to migration metadata
update allowing simultaneous level change and re-striping.

Signed-off-by: Adam Kwolek <adam.kwolek@intel.com>
Signed-off-by: Przemyslaw Czarnowski <przemyslaw.hawrylewicz.czarnowski@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
2011-05-09 11:45:53 +10:00
Przemyslaw Czarnowski a29911dac1 imsm: process update for raid level migrations
Received update and prepared memory is processed to update imsm metadata.

Signed-off-by: Adam Kwolek <adam.kwolek@intel.com>
Signed-off-by: Przemyslaw Czarnowski <przemyslaw.hawrylewicz.czarnowski@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
2011-05-09 11:45:53 +10:00
Przemyslaw Czarnowski bc0b9d3496 imsm: prepare memory for level migration update
When level is changed from raid0 to raid5 memory is required for replace device
smaller device/array object.
This memory is allocated in manager context in prepare_update()

Prepare_update() is called in manager context so memory allocation are
allowed here. This allows us to look for spare devices for meta update.

Signed-off-by: Adam Kwolek <adam.kwolek@intel.com>
Signed-off-by: Przemyslaw Czarnowski <przemyslaw.hawrylewicz.czarnowski@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
2011-05-09 11:45:53 +10:00
Przemyslaw Czarnowski c7958710e7 imsm: fix: disable migration from raid5->raid0
it is not supported yet, so start such transition is improper.

Signed-off-by: Przemyslaw Czarnowski <przemyslaw.hawrylewicz.czarnowski@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
2011-05-09 11:45:53 +10:00
Przemyslaw Czarnowski 48c5303aff imsm: prepare update for level migrations reshape
Introducing raid0->raid5 level migration metadata update structure
is prepared for future use.

Adding spare device is required to hold additional raid5 parity.
Mdadm just checks for spares, but it is not included in update.
If there are no spares available, abort. Otherwise we will create
degraded array what should be not allowed.
Mdmon will decide what spare device is used for parity.

Signed-off-by: Adam Kwolek <adam.kwolek@intel.com>
Signed-off-by: Przemyslaw Czarnowski <przemyslaw.hawrylewicz.czarnowski@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
2011-05-09 11:45:53 +10:00
Adam Kwolek bfd80a5677 imsm: FIX: Do not write check-point '0'
When 2 arrays are configured in container and arrays are reassembled during
rebuild or initialization, checkpoint for one array can be reset. It depends
on arrays assembly order.

Scenario:
1. Create 2 arrays (e.g. raid5)
2. Add spare to container
3. Degrade arrays /rebuild starts on array #1 and continues to n%/
4. Reassembly arrays
5. Rebuild starts on array #2 /because of assembly order/ from 0%
6. On first checkpoint stored for array #2 (non 0 value), checkpoint
   for array #1 is cleared /it is delayed rebuild in md, so progress is 0/
7. Rebuild on #1 starts from n% /it was configured before checkpoint
   was cleared/.

Any next reassembly during rebuild of #2 array (after p.6) causes
checkpoint information lost for array #1.

Solution is not store checkpoint for progress == 0.
Checkpoint is set to 0 when rebuild/initialization starts.

Signed-off-by: Adam Kwolek <adam.kwolek@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
2011-05-02 16:12:03 +10:00
Adam Kwolek cd0430a17c FIX: Always report new raid_disks during migration
To behave in the similar way as native metadata during migration,
new raid disks number has to be reported by metadata handler.

Signed-off-by: Adam Kwolek <adam.kwolek@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
2011-04-18 10:11:33 +10:00
Adam Kwolek 139dae1137 imsm: fix: report aligned component size value
OROM can create array with chunk size not aligned.
To resolve this problem in mdadm, metadata handler has to report
component size aligned value for mdadm operations
while metadata value stays unchanged.

Do not correct alignment for raid1 and in error case.

Correction allows check in analyse_change() (Grow.c:905) to pass.

Signed-off-by: Adam Kwolek <adam.kwolek@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
2011-04-06 12:40:31 +10:00
Adam Kwolek 2a4a08e7d3 imsm: FIX: Check array alignment before expansion
It can occur that OROM creates array not aligned properly.
Expansion cannot be run in such cases. It is detected in analyse_change().
It is too late. This causes that metadata is in migration state already,
when expansion cannot be started.
This problem has to be detected before metadata is updated,
in all arrays in reshaped container.

Signed-off-by: Adam Kwolek <adam.kwolek@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
2011-04-06 12:40:04 +10:00
Adam Kwolek 6dc0be309d imsm: Warn user about reboot risk
Current check-pointing implementation doesn't allow for interrupting reshape of boot arrays
due to checkpoint restore has to be done before system start.
There is problem with passing backup file name to array automatically mounted during boot time,
especially when scan mode is used.

Until IMSM check-pointing implementation will be introduced, warning about reboot risk
should be placed in mdadm.

Signed-off-by: Adam Kwolek <adam.kwolek@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
2011-04-06 12:38:50 +10:00
NeilBrown 7b0bbd0f71 Release 3.2.1
Signed-off-by: NeilBrown <neilb@suse.de>
2011-03-28 13:30:29 +11:00
Krzysztof Wojcik b4add146a0 FIX: imsm: Do not change serial if disk failed
This patch rollback one change connected with mdadm-OROM
compatibility:
adding ':0' at the end of disk serial number if disk is
detected as failed.
Current mdadm's implementation does not distinguish two
cases when disk is marked as failed:
1. If disk is really failed- disconnected, broken
2. Just marked as failed by mdadm- using "-f" option

Second case is not yet fully handled and compatible with
IMSM standard.
Changing serial number of existing, operational disk causes
problems in "thunderdome" and "load_super" functions that use
serial numbers to disks comparisons and searching.
The change must be recalled until full support will be
developed.

Signed-off-by: Krzysztof Wojcik <krzysztof.wojcik@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
2011-03-24 10:15:01 +11:00
Labun, Marcin ea2bc72b00 super-intel: enable loading metadata from non-IMSM compliant disks
Honor ignore_hw_compat to load metadata from disk attached to non-IMSM
controller or when there are no IMSM OROM/EFI capabilities.
Used only for guessing and examining metadata format.

Signed-off-by: Marcin Labun <marcin.labun@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
2011-03-23 12:05:53 +11:00
Adam Kwolek ceaf0ee19e imsm: FIX: indicate that metadada has to be written
During adding spare disks to raid0, spare metadata is not written.
This is due to exit form sync_metadata() on empty updates_pending flag.

When mdmon is absent indicate sync_metadata() to flush changes to disks.

Signed-off-by: Adam Kwolek <adam.kwolek@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
2011-03-20 15:47:31 +11:00
Adam Kwolek 6289d1e079 imsm: FIX: Store checkpoint in per disk units
While last_checkpoint is counter in per disk units, checkpoints
should be stored in the same manner.
Restoring from checkpoint should should recalculate checkpoint in to
array position (reshape_progress).

Signed-off-by: Adam Kwolek <adam.kwolek@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
2011-03-14 18:17:53 +11:00
NeilBrown d424212ed9 Make find_intel_hba_capability less verbose.
mdadm has a convention in some areas of passing a device name
if error messages about it are interesting, or NULL if not.

Follow this convention with find_intel_hba_capability so that it
doesn't complain when not appropriate - and so that it doesn't
have to go and find a device name that it wasn't given.

Signed-off-by: NeilBrown <neilb@suse.de>
2011-03-10 14:53:30 +11:00
Labun, Marcin f2f5c343ff imsm: introduce SAS controller support in imsm metadata handler
OROM/EFI capabilities are retrieved based on disk's controller type.
1/ alloc_super no longer retrieves OROM capabilities
2/ find_imsm_capability replaces find_imsm_orom
3/ new function find_intel_hba_capability gets disk's HBA and relevant
capability

Signed-off-by: Marcin Labun <marcin.labun@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
2011-03-10 11:52:15 +11:00
Labun, Marcin f0f5a01660 imsm: move code for retrieving HBA to a function
Function find_intel_hba_capability attaches HBA information
to intel_super structure based on fd of the component disk.

Signed-off-by: Marcin Labun <marcin.labun@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
2011-03-10 11:50:58 +11:00
Labun, Marcin 8603ea6f22 imsm: verify that component disks are attached to the same type of HBA
compare_super_imsm verifies that the component disks use the same type of HBA
in platform dependent environment. Otherwise print-out error message and block
the action.

Signed-off-by: Marcin Labun <marcin.labun@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
2011-03-10 11:50:57 +11:00
Labun, Marcin 7340812950 imsm: add maximum number of disk validation in RAID array
Arrays exceeding the OROM/EFI maximum number of supported disk are
blocked in validate_geometry_imsm_orom function.

Signed-off-by: Marcin Labun <marcin.labun@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
2011-03-10 11:50:54 +11:00
Labun, Marcin d54559f08a imsm: print-out error message when volume validation fails
Print-out error message when volume geometry fails to comply with
OROM/EFI controller's capabilities.

Signed-off-by: Marcin Labun <marcin.labun@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
2011-03-10 11:50:52 +11:00
Labun, Marcin 2db863023e imsm: do not publish OROM/EFI unsupported arrays
Container_content_imsm calls validate_goemtry_imsm_orom to verify that
the array parameters are supported by controller's OROM/EFI.

Signed-off-by: Marcin Labun <marcin.labun@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
2011-03-10 11:50:49 +11:00
Labun, Marcin a891a3c24d imsm: detail_platform_imsm displays AHCI and SAS controller information
The function uses find_intel_device and find_imsm_capability to present
AHCI and SAS controller capabilities taken from OROM or EFI.

Signed-off-by: Marcin Labun <marcin.labun@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
2011-03-10 11:46:11 +11:00
Labun, Marcin b4cf4cba74 imsm: remove unused parameters in function attach_hba_to_super
Signed-off-by: Marcin Labun <marcin.labun@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
2011-03-10 11:45:49 +11:00
Adam Kwolek b6796ce1ed imsm : FIX: Assemble dirty array when reshape is in progress
During reshape for dirty volumes reshape_progress has to be calculated
also.  To keep the same logic for array creation:
  not setting info->resync_start = MaxSector when first condition is
  true,
  resync_start is initialized by MaxSector to allow proper array
  initialization.

Signed-off-by: Adam Kwolek <adam.kwolek@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
2011-03-10 11:41:33 +11:00
Adam Kwolek 633b561073 imsm: FIX: Mark checkpoint and array state clean during reshape
Array state has to be managed during reshape based on consistent flag.
To achieve this existing code will be reused. Currently existing code for
blocks_per_unit calculation can be removed
and existing code can be reused also.

Signed-off-by: Adam Kwolek <adam.kwolek@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
2011-03-09 09:03:54 +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
Adam Kwolek 04fa952309 imsm: FIX: Variables declaration cleanup
Variables declaration moved a little bit up,
to not mix declaration and code.

Signed-off-by: Adam Kwolek <adam.kwolek@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
2011-03-08 17:18:44 +11:00
Adam Kwolek 072b112dfb imsm: FIX: Return blocks_per unit for general migration
For general migration, blocks per unit are required for all disks,
not for per-member.

Signed-off-by: Adam Kwolek <adam.kwolek@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
2011-03-08 16:10:35 +11:00
NeilBrown 3f83228aa8 imsm: improve getinfo_super when reshape is in progress.
If a reshape (migration) is happening, we might need to modify the information
with provide to md so that it can cope with the reshape.
For example, if a migration from 4-device RAID0 to 5-device RAID0 is
happening, we need to tell md that it is reshape from degraded
5-device RAID4 to degraded 6-device RAID4 so md doesn't handle direct
reshape of RAID0.

There may be other migrations supported by IMSM that need special
treatment here.

Signed-off-by: NeilBrown <neilb@suse.de>
2011-03-08 15:59:09 +11:00
Krzysztof Wojcik e14e59602a Enable error message in case of lack of spares for grow
When we cannot find spare devices for grow operation we should
print error message.
This patch changes debug error message to 'stderr' print.

Signed-off-by: Krzysztof Wojcik <krzysztof.wojcik@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
2011-03-08 09:52:44 +11:00
Krzysztof Wojcik 1a2487c2cb FIX: imsm: OROM does not recognize degraded arrays (V2)
Defect description:
When we create an redundant array in mdadm and then degrade it
by disk removing, Option ROM and Windows OS does not detect any array.
Reason:
Metadata created and updated after degrading array is not compatible
with IMSM standard.

This patch synchronizes the metadata according IMSM requirements.
Following inconsistencies have been fixed:
- reset all fields in imsm_dev during creation to avoid random values
- init dev status during creation to proper state
- not reset CONFIGURED_DISK flag when disk is missing
- add ":0" suffix to the serial number for missing/failed disks
- update medatada signature after takeover operation
- mark map state as degraded after raid0->raid10 takeover

Note:
Patch reworked after Dan Willams review.

Signed-off-by: Krzysztof Wojcik <krzysztof.wojcik@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
2011-02-27 17:13:10 +11:00
Adam Kwolek 75156c4690 imsm: FIX: Report correct array size during reshape
When reshape is started imsm stores new size in metadata.
mdadm requires "old" size to proper initialization restarted array.

When reshape is in progress getinfo_super_imsm_volume() should report
computed array size value instead array size stored in metatda.

Signed-off-by: Adam Kwolek <adam.kwolek@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
2011-02-23 14:16:37 +11:00
Adam Kwolek d2e6d5d65b imsm: FIX: initalize reshape progress as it is stored in metatdata
reshape prodess cannot be restarted due to no checkpoint information
in mdinfo.
When metadata is read during reshape process or reshape restart,
rehape_progress (mdinfo field) has to be initialized to value
stored in metadata. This allows start reshape from stored
in metadata checkpoint.

Signed-off-by: Adam Kwolek <adam.kwolek@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
2011-02-23 14:16:37 +11:00
Czarnowska, Anna c21e737ba1 set default chunk in validate_geometry
When chunk size is not set from command line we need to guess it
depending on metadata given on command line or found on listed devices.

Validate_geometry sets the default for it's metadata if chunk is not set.
For external metadata chunk is set only when creating in a container.
For imsm validate_geometry_imsm_orom is responsible for finding default
chunk depending on container metadata loaded. Container will already know
which controller it is attached to, and have this controllers orom
available.
do_default_chunk indicates that we need to find default chunk and
if validate_geometry fails for some metadata it tells us to reset chunk
that may have been set.

Current solution would set default chunk correctly for imsm only if
container device was given on command line. With the list of devices
chunk was always set to 512.

Signed-off-by: Anna Czarnowska <anna.czarnowska@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
2011-02-22 11:25:07 +11:00
Adam Kwolek abef11a38d imsm: FIX: Add spare disks information to array description
Spares that are specified on container can be used by any array in container.
this means that for every array in container they should be reported.
This let caller know how many spare devices (not used in any array)
are still available.

Signed-off-by: Adam Kwolek <adam.kwolek@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
2011-02-14 11:09:22 +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
Czarnowska, Anna 196b0d4497 fix: imsm: assemble doesn't restart recovery
Because IMSM_ORD_REBUILD is set in second map not first.

Signed-off-by: Anna Czarnowska <anna.czarnowska@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
2011-02-14 09:27:43 +11:00
Czarnowska, Anna 612e59d838 fix: imsm: size must be in K for rounding to chunk
chunk is in K so size must be converted to K before it is rounded.
Otherwise we may get wrong freesize returned
resulting in creation failure.

Signed-off-by: Anna Czarnowska <anna.czarnowska@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
2011-02-14 09:27:09 +11:00
Adam Kwolek 7095bccbb0 imsm: Add information about failed disk to '-E' option
During metadata printout in '-E' option failed disk map field
information is missing.  Add this information to mdadm '-E' option
output.

Signed-off-by: Adam Kwolek <adam.kwolek@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
2011-02-14 09:25:57 +11:00
Adam Kwolek b53477997d imsm: Use single migration type for all migrations
Use single enum definition/migration type for all migrations.
Using separate definitions causes limitation for number of changes
in metadata implementation during single update for migration/reshape.
Single CH_MIGRATION enum allows for many mtadata parameters change
in single update. It will be possible to change i.e. chunk size together
with raid level. In current implementation 2 metadata updates would be
required for such action, one using CH_CHUNK_MIGR and second using
CH_LEVEL_MIGRATION migration type.

Signed-off-by: Adam Kwolek <adam.kwolek@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
2011-02-14 09:23:36 +11:00
Adam Kwolek 41bf155e12 imsm: FIX: add raid5 to raid0 case to analyse_change()
Transition raid0 to raid5 is not possible
due to wrong condition in imsm_analyze_change().
Current condition blocks migration possibility instead allow for it.

Signed-off-by: Adam Kwolek <adam.kwolek@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
2011-02-14 09:18:48 +11:00
Adam Kwolek e7ff7e4092 imsm: FIX: Wrong output string format
On wrong starting container reshape conditions, mdadm returns information on console:
mdadmimsm: Operation is not allowed on this container

it is changed to:
mdadm: (imsm) Operation is not allowed on this container

Signed-off-by: Adam Kwolek <adam.kwolek@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
2011-02-09 13:47:55 +11:00
Czarnowska, Anna 21f3b9cc44 fix: array is reassembled inactive if stopped during resync
If initial resync or recovery of a redundant array is not finished
before it is stopped then during assembly md will start it as inactive.
Writing readonly to array_state in assemble_container_content
fails because md thinks the array is during reshape.

In fact we only have a reshape if both current and previous map
states are the same. Otherwise we may have resync or recovery.
Setting reshape_active in such cases causes the issue.

Signed-off-by: Anna Czarnowska <anna.czarnowska@intel.com>
Signed-off-by: Adam Kwolek <adam.kwolek@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
2011-02-08 11:44:42 +11:00
Adam Kwolek f49ee92d55 imsm: FIX: Size is already set in metadata
In metadata size is set already during migration initialization.
There is no reason for second /the same/ calculation.

Signed-off-by: Adam Kwolek <adam.kwolek@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
2011-02-03 21:41:43 +11:00
Adam Kwolek 9653001d8b imsm: FIX: size have to be calculated based on first map
Before reshape finalization migration is still present in metadata.
After patch 'imsm: FIX: crash during getting map'
function get_imsm_map() returns correct value,
this means in our case from second (start) map.

We should calculate map size basing on first (final) map.
For this we should request it by setting second function parameter to '0'

Signed-off-by: Adam Kwolek <adam.kwolek@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
2011-02-03 18:23:50 +11:00
Adam Kwolek 70bdf0dcc3 imsm: move common code for array size calculation to function
Array size calculation is made in the same way in few places in code.
Make function imsm_set_device_size() for this common code.

Signed-off-by: Adam Kwolek <adam.kwolek@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
2011-02-03 17:57:25 +11:00
Adam Kwolek ed7333bd68 imsm: FIX: Debug strings cleanup
Some debug strings remains as they were introduced,
before code was moved to separate function.
Information displayed by debug information in not all cases
was correct.

Signed-off-by: Adam Kwolek <adam.kwolek@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
2011-02-03 17:57:10 +11:00
Adam Kwolek d55adef98e imsm: fix: imsm_num_data_members() can return error
imsm_num_data_members() can indicate error by returning 0 value
In such case size cannot be set based on 0 value.

Signed-off-by: Adam Kwolek <adam.kwolek@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
2011-02-03 17:47:52 +11:00
Adam Kwolek e154ced310 imsm: FIX: put expansion finalization in to one place
When a->last_checkpoint variable can reach array end,
reshape finalization can be put in to single place.

There is no need to reset migration variables.
imsm_set_disk() will call end_migration() and this sets
all migration variables to required values.

Signed-off-by: Adam Kwolek <adam.kwolek@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
2011-02-03 17:46:17 +11:00
Adam Kwolek 5e7b033066 imsm: FIX: crash during getting map
When get_imsm_map() is called with second_map parameter == '-1'
and array is not in migration state NULL pointer is returned.
This is wrong. '-1' means return map as migration record points.

'-1' can be passed to get_imsm_map() from imsm_num_data_members().
imsm_num_data_members() is called to get current map members based
on migr_state information

Signed-off-by: Adam Kwolek <adam.kwolek@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
2011-02-03 17:02:39 +11:00
NeilBrown 71204a5029 Various compile fixes.
Make "make everything" succeed.
This fixed some real bugs.

Signed-off-by: NeilBrown <neilb@suse.de>
2011-02-01 15:48:03 +11:00
Adam Kwolek 1dfaa38015 imsm: FIX: map coping causes mdmon crash
Too big map was copied (outside allocated memory) and this causes
mdmon crash for 2 raid0 arrays in container.
Map of correct (smaller) size should be copied,
to not overwrite any internal data.

Signed-off-by: Adam Kwolek <adam.kwolek@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
2011-02-01 10:40:56 +11:00
Adam Kwolek 401d313b7f imsm: FIX: mdmon crash during 2 raid0 arrays expansion
When expansion is run on 2 raid0 arrays in container no update
is sent to mdmon because mdmon is off (mdadm performs update)
Memory size for first reshaped array is allocated to satisfy memory
requirements for expanded maps.
Memory for second device is allocated using old disks number, as in
metadata there is no information about this array reshape.
When mdmon initiates second array reshape it overwrites internal
structures and crashes). There is no place to keep expanded maps.
To avoid this situation during loading metadata, allocated memory
should be performed using the maximum used disks number in particular
container.

Signed-off-by: Adam Kwolek <adam.kwolek@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
2011-02-01 10:31:27 +11:00
Adam Kwolek 820eb8dba7 imsm: Update metadata for second array
When second array reshape is about to start external metadata should
be updated by mdmon in imsm_set_array_state().  For this purposes
imsm_progress_container_reshape() is reused.

Signed-off-by: Adam Kwolek <adam.kwolek@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
2011-02-01 10:31:06 +11:00
Adam Kwolek d098291aec imsm:FIX: change arrays reshape order
Reshape is started from second array, so it causes imsm incompatibility
and problems during second array start.

Reshape should be started in arrays metadata order.

Signed-off-by: Adam Kwolek <adam.kwolek@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
2011-02-01 10:17:06 +11:00
Adam Kwolek cb82edca14 imsm: FIX: not all disks are released in free_imsm_disks()
Adding spare disks to imsm container fails due to problem with writing
new_dev to sysfs. This problem was caused by not closed handle
(opened exclusively) in Manage.c:803.

Disk handle was not closed by free_imsm().
This is due to not released disk_mgmt_list in free_imsm_disks().

Proper release of imsm metadata allows for spare adding without problems.
Memory leak was fixed also.

Signed-off-by: Adam Kwolek <adam.kwolek@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
2011-01-31 11:06:42 +11:00
Adam Kwolek d7d205bd25 imsm: FIX: do not allow for container operation for the same disks number
imsm_reshape_super() currently allows for expansion when requested
raid_disks number is the same as current.
This is wrong. Existing in code condition is too weak.
We should allow for expansion when new disks_number is greater
than current only.

Signed-off-by: Adam Kwolek <adam.kwolek@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
2011-01-28 10:25:26 +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
Labun Marcin 96234762a6 imsm: support for Intel SAS controller in get_disk_controller_domain handler
get_disk_controller_domain recognizes Intel (R) SAS controller (isci).
The function returns three different strings that differentiate disk attached
to AHCI, ISCI or unknown controller types to create separate domains
for each case.

Signed-off-by: Marcin Labun <marcin.labun@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
2011-01-26 11:22:34 +10:00
Labun Marcin 155cbb4c2c imsm: detail_platform_imsm supports Intel SAS controller (isci driver)
Added support in detail_platform_imsm for Intel (R) SAS controller.
Function supports AHCI and ISCI controllers. RAID properties are derived
from common OROM for both types.

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:22:07 +10:00
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
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 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
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
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
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 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
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
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
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
Adam Kwolek 89c6788213 imsm: FIX: do not repair raid4 arrays
As raid4 is not supported by imsm (this is takeovered raid0)
do not fix degraded raid4 arrays.

Signed-off-by: Adam Kwolek <adam.kwolek@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
2011-01-06 19:20:25 +11:00
Adam Kwolek ed08d51c1a imsm: Update raid0 metadata for reshape
When raid0 reshape is performed metadata has to be applied by mdadm.
(without mdmon)

Signed-off-by: Adam Kwolek <adam.kwolek@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
2011-01-06 19:14:24 +11:00
NeilBrown 2e5dc01050 imsm: Move reshape update processing to function
For code reuse in raid0 reshape case when monitor is not loaded.

Signed-off-by: Adam Kwolek <adam.kwolek@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
2011-01-06 19:10:04 +11:00
Adam Kwolek 0e2d1a4e68 imsm: Update metadata for second array
When second array reshape is about to start metadata should be updated
by mdmon in imsm_set_array_state().

Signed-off-by: Adam Kwolek <adam.kwolek@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
2011-01-06 18:29:23 +11:00
Adam Kwolek ef83fa1a7c imsm: update array size information in metadata
When disks are added size has to increase in metadata.
This size should be used by common code to set size in md when reshape will be finished.

Signed-off-by: Adam Kwolek <adam.kwolek@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
2011-01-06 18:29:15 +11:00
Adam Kwolek 6345120e38 imsm: FIX: Division by 0
For general migration function blocks_per_migr_unit() has to return valid value.
If there is no valid return, 0 is returned instead and causes division by 0 error.
Additionally guard in function was added for such case.

Signed-off-by: Adam Kwolek <adam.kwolek@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
2011-01-06 18:29:11 +11:00
Adam Kwolek a4546b6189 imsm: Finalize reshape in metadata
When reshape is finished monitor calls set_array_state() and finishes migration in metadata.
This change allows for finishing metadata migration on reshape end.

Signed-off-by: Adam Kwolek <adam.kwolek@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
2011-01-06 18:29:07 +11:00
Adam Kwolek b335e59305 imsm: FIX: support general migration by getinfo_super_imsm_volume
Add support for reading volume information during migration process.

Signed-off-by: Adam Kwolek <adam.kwolek@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
2011-01-06 18:28:56 +11:00
Adam Kwolek 834acc0bd2 imsm: FIX: update first array in container only
During first metadata update imsm for compatibility reason should update
only one array.
Buffers in prepare_update() are prepared for second update as well.

Signed-off-by: NeilBrown <neilb@suse.de>
2011-01-06 18:26:59 +11:00
Adam Kwolek d677e0b8ec imsm: FIX: Perform first metadata update for container operation
Meta data was not updated due to the following problems:
1.disk index < 0 was treated as invalid, but this is spare device
2. disk index greater than currently used disks is correct also
3. newmap pointer has to be refreshed for second map copy operation
4. size calculation has to be guarded for shrinking operation

Signed-off-by: Adam Kwolek <adam.kwolek@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
2011-01-06 16:24:07 +11:00
Adam Kwolek 690aae1ae5 imsm: FIX: display error message
When container operation is not allowed user has to get proper information on console about it
Currently this information was displayed as debug info only.

Signed-off-by: Adam Kwolek <adam.kwolek@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
2011-01-06 16:22:01 +11:00
Adam Kwolek dd8bcb3b69 imsm: FIX: display correct information for '-E' option
Correct information displayed by '-E' option.
1. FIX: Slot information during raid0 migration is displayed incorrectly
        (missing disk position is taken from wrong map)
2. Improvement: information about (level, members, chunk size) migration is displayed.

Signed-off-by: Adam Kwolek <adam.kwolek@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
2011-01-06 16:11:35 +11:00
Adam Kwolek 98130f4013 mdadm: second_map enhancement for imsm_get_map()
Allow map related operations for the given map: first of second.
For reshape specific functionality it is required to have an access

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

Signed-off-by: Maciej Trela <maciej.trela@intel.com>
Signed-off-by: Adam Kwolek <adam.kwolek@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
2011-01-06 16:08:04 +11:00
Anna Czarnowska 326727d9c9 Use one function chosing spares from container
container_chose_spares in Monitor.c and
get_spares_for_grow in super-intel.c
do the same thing: search for spares in a container.

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

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

Signed-off-by: Anna Czarnowska <anna.czarnowska@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
2011-01-05 14:34:14 +11:00
Anna Czarnowska 22e263f64a imsm: set imsm spare uuid to 0
uuid_match_any is replaced by uuid_zero for imsm spares.

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

Signed-off-by: Anna Czarnowska <anna.czarnowska@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
2010-12-26 21:59:31 +11:00
Krzysztof Wojcik a06d022db4 FIX: Bad block verification during assembling array
We need to refuse to assemble an arrays with bad blocks.
Initially there was condition in container_content function
that returns error value in the case when metadata store information
about bad blocks.
When the container_content function is called from functions NOT connected
with assemble (Kill_subarray, Detail) we get faulty error return value.
Patch introduces new flag in array.status - MD_SB_BBM_ERRORS. It is set
in container_content when bad blocks are detected and can be checked by
container_content caller.

Signed-off-by: Krzysztof Wojcik <krzysztof.wojcik@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
2010-12-26 21:41:57 +11:00
Adam Kwolek 81ac8b4d56 imsm: Fill delta_disks field in getinfo_super()
delta_disks field is not always filled during getinfo_super() call.

Signed-off-by: Adam Kwolek <adam.kwolek@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
2010-12-16 15:55:40 +11:00
Adam Kwolek 4c9bc37b97 imsm: Do not indicate resync during reshape
If reshape is started resync is not allowed in parallel. This would
break reshape.  If array is in General Migration state do not indicate
resync and allow for reshape continuation.

Signed-off-by: Adam Kwolek <adam.kwolek@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
2010-12-16 15:48:27 +11:00
NeilBrown aad6f216a1 Handle checkpointing during reshape
We need to allow metadata to handle progress of reshape,
completion, and abort-before-start.

Include all those in ->set_array_state()

Signed-off-by: NeilBrown <neilb@suse.de>
2010-12-16 15:48:05 +11:00
Adam Kwolek 1af97990a6 imsm: Block array state change during reshape
Array state change is blocked due to reshape action in progress
metadata changes are during applying.

'1' is returned to indicate that array is clean

Signed-off-by: Adam Kwolek <adam.kwolek@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
2010-12-16 13:17:47 +11:00
Adam Kwolek d195167d9c imsm: Process reshape_update in mdmon
For this update prepare_update() allocates memory to relink imsm
(bigger) device imsm structures. It calculates new /bigger/ anchor
size.

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

Signed-off-by: Adam Kwolek <adam.kwolek@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
2010-12-16 13:17:45 +11:00
NeilBrown cb23f1f4c3 Allow a metadata update to have a linked list of allocated spaces.
Sometimes one metadata update will require allocating several
larger data structures.  As 'monitor' cannot allocate, 'manager'
must, so it must be able to attach a list of allocates to the
update, and importantly it must be able to easily free them.

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

Signed-off-by: NeilBrown <neilb@suse.de>
2010-12-16 12:10:01 +11:00
NeilBrown 78b10e663c imsm: Prepare reshape_update in mdadm
During Online Capacity Expansion metadata has to be updated to show
array changes and allow for future assembly of array.  To do this
mdadm prepares and sends reshape_update metadata update to mdmon.
The update contains the old and new number of raid disks, and the
indices of the spare disks that will be used to fill the spaces.

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

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

Signed-off-by: Krzysztof Wojcik <krzysztof.wojcik@intel.com>
Signed-off-by: Adam Kwolek <adam.kwolek@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
2010-12-16 11:45:21 +11:00
NeilBrown 94827db3b3 imsm: add spares to --examine output.
When we examine a container, list the spare devices as well as
the active devices.

Signed-off-by: NeilBrown <neilb@suse.de>
2010-12-16 11:33:23 +11:00
Adam Kwolek 6c93202898 imsm: FIX: imsm_add_spare() wrongly tests spares list
For more than one disk tested additional_test_list was searched from last
point, not from begin.

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

Signed-off-by: Adam Kwolek <adam.kwolek@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
2010-12-16 09:03:03 +11:00
Labun, Marcin 95d07a2cdd IMSM: do not rebuild the array if a non-redundant sub-array with failed disks is present
Before looking for a spare to rebuild a degraded array, check if there
are any failed disks in container.  Block rebuild if another sub-array
is failed until failed disks are removed from container.

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

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

Signed-off-by: Marcin Labun <marcin.labun@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
2010-12-15 15:51:53 +11:00
Labun, Marcin 1a64be565b IMSM: Fix problem in mdmon monitor of using removed disk in imsm container.
Manager thread shall pass the information to monitor thread (mdmon)
that some devices are removed from container.  Otherwise, monitor
(mdmon) might use such devices (spares) to rebuild the array that has
gone degraded.

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

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

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

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

Signed-off-by: Marcin Labun <marcin.labun@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
2010-12-15 15:51:51 +11:00
NeilBrown 1d54f2867b Merge branch 'master' into devel-3.2
Conflicts:
	super-intel.c
2010-12-13 14:00:05 +11:00
Luca Berra a2973b6af2 segfault in imsm create with wrong arguments
When calling mdadm -C --metadata=imsm -l 1 /dev/sd..
mdadm segfaults in default_chunk_imsm()
above syntax is incorrect, but mdadm should error instead of segfaulting

Signed-off-by: Luca Berra <bluca@comedia.it>
Signed-off-by: NeilBrown <neilb@suse.de>
2010-12-13 13:51:07 +11:00
Adam Kwolek 8ba77d3281 imsm: Allow multiple spares to be collected.
Assumption for spares searching was that after picking new device, it
has to be added to array before next search.  This causes returning
different disk on each call.

When creating a spare list during Online Capacity Expansion, we will
first collect the devices list and then all devices are added to md.
Picked device from spares pool has to be checked against picked
devices so far. If not, the same disk will be returned all the time.
Already picked devices are stored in the list and this list is used
for new devices verification also.

So add an extra arg to imsm_add_spare to hold a list of known
spares to ignore.

Signed-off-by: Adam Kwolek <adam.kwolek@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
2010-11-30 13:14:24 +11:00
Adam Kwolek 36988a3dda imsm: FIX: core dump during imsm metadata writing
Wrong number of disks during metadata update causes core dump.  New
disks number based on internal mdmon information has to used for
calculation (not previously read from metadata).

Signed-off-by: Adam Kwolek <adam.kwolek@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
2010-11-29 12:53:16 +11:00
Adam Kwolek 28bce06f17 imsm: Add support for general migration
Internal IMSM procedures need to support the General Migration.
It is used during operations like:
- Online Capacity Expansion,
- migration initialization,
- finishing migration,
- apply changes to raid disks etc.

Signed-off-by: Adam Kwolek <adam.kwolek@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
2010-11-29 12:28:01 +11:00
Dan Williams 30f58b2208 Create: cleanup/unify default geometry handling
Support metadata specific level, layout and chunksize defaults.  Kill an
uneeded superswitch methods ahead of adding more for the reshape case.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
2010-11-23 15:20:50 +11:00
Marcin Labun 2cda7640f9 Policy is aware of metadata disk's controller domains.
Platform (metadata) domain let the metadata handlers differentiate
disk domains based on controllers that the disk belongs to.
Platform domain is sub-domain inside user specified domain
in mdadm.conf configuration files inheriting all parameters from it.
The metadata domain name is used disk domain matching functions.
The disk with the same metadata domain name belong to the same metadata
domain.

New metadata handler is added that retrieves platform domain string based
on disk path:
const char *(*get_disk_controller_domain)(const char *path);

Signed-off-by: Marcin Labun <marcin.labun@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
2010-11-22 20:58:07 +11:00
Anna Czarnowska 80e7f8c31a Monitor: Allow metadata to set minimum size for spare to migrate in.
Signed-off-by: Anna Czarnowska <anna.czarnowska@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
2010-11-22 20:58:07 +11:00
Anna Czarnowska 5c4cd5da70 imsm: create mdinfo list of disks in a container from supertype
If getinfo_super is called on a container supertype we only get information
on first disk. As a parameter it uses reference to preallocated
mdinfo structure. Amending getinfo_super to return full list of disks
would require ammending all previous calls and subsequently freeing memory
allocated for mdinfo list.
Function container_content that returns a mdinfo list is written
specifically for assembly, performing actions not needed to just fill
mdinfo. It also does not include spares so is unsuitable.
As an alternative a new function getinfo_super_disks is created
to obtain information about all disks states in array.
Existing function sysfs_free is used to free memory
allocated by getinfo_super_disks.

Signed-off-by: Anna Czarnowska <anna.czarnowska@intel.com>
Signed-off-by: Marcin Labun <marcin.labun@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
2010-11-22 20:58:07 +11:00
NeilBrown 157e6e24b9 Remove loaded_container
This field is now only set, never used.

So remove it.

Signed-off-by: NeilBrown <neilb@suse.de>
2010-11-22 20:58:06 +11:00
NeilBrown ab3cb6b3b7 imsm: always calculate container_enough in getinfo_super_imsm
We are about to lose the loaded_container field, and we don't really
need to use it to protect the calculation of container_enough.
So drop the test.

Signed-off-by: NeilBrown <neilb@suse.de>
2010-11-22 20:58:06 +11:00
NeilBrown fa56eddbd1 Improve mddev_ident type definitions.
Remove the _t typedef and remove the _s suffix from the struct name.

These things do not help readability.

Signed-off-by: NeilBrown <neilb@suse.de>
2010-11-22 20:58:05 +11:00
NeilBrown 2b959fbf66 New method: load_container
This handles the 'container' part of 'load_super', so we can
soon make them completely separate - it is just confusing to
overload these two.

Signed-off-by: NeilBrown <neilb@suse.de>
2010-11-22 20:24:50 +11:00
NeilBrown e1902a7b6c Remove keep_fd arg from load_super_XXX_all
It is always set to 1, so we don't need it.

Signed-off-by: NeilBrown <neilb@suse.de>
2010-11-22 20:24:50 +11:00
NeilBrown 69b2fcc5bb Remove subarray field in supertype.
This is now only ever set, never used.
So remove it.

Signed-off-by: NeilBrown <neilb@suse.de>
2010-11-22 20:24:50 +11:00
NeilBrown d1d599ea0d Create: user container_dev rather than subarray for some tests.
It makes more sense to test for container_dev than for subarray
for several places in Create where it then uses container_dev.

This allows us to subsequently remove subarray.

Signed-off-by: NeilBrown <neilb@suse.de>
2010-11-22 20:24:50 +11:00
NeilBrown e32bd33f44 Remove subarray detection from load_super.
Nothing relies on this any more, so remove it.

Signed-off-by: NeilBrown <neilb@suse.de>
2010-11-22 20:24:50 +11:00
NeilBrown a951a4f78f Pass subarray arg explicitly to ->update_subarray.
This is better than hiding it in the supertype structure
where we are never quite sure who needs it.

Signed-off-by: NeilBrown <neilb@suse.de>
2010-11-22 20:24:50 +11:00
NeilBrown 00bbdbdac6 Add subarray arg to container_content.
This allows the info for a single array to be extracted,
so we don't have to write it into st->subarray.

For consistency, implement container_content for super0 and super1,
to just return the mdinfo for the single array.

Signed-off-by: NeilBrown <neilb@suse.de>
2010-11-22 19:35:26 +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 1e2b276535 Report error in --update string is not recognised.
If an --update is requested by the relevant metadata doesn't
understand it, print a useful message rather than silently ignoring
the issue.

Signed-off-by: NeilBrown <neilb@suse.de>
2010-11-22 19:35:24 +11:00
NeilBrown 64436f0628 intel: Don't try to read from tiny devices.
If a device is less than 1K, avoid even trying to seek to 1K before
the end.
The seek will fail anyway so this is a fairly cosmetic fix.

Signed-off-by: NeilBrown <neilb@suse.de>
2010-09-06 11:26:28 +10:00
NeilBrown cdbe98cd54 Fix compiler warning concering bad use of snprintf.
Signed-off-by: NeilBrown <neilb@suse.de>
Reported-by: Mikael Abrahamsson <swmike@swm.pp.se>
2010-08-06 20:10:48 +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
Dan Williams 569cc43ffb imsm: fix a -O2 build warning
super-intel.c: In function ‘imsm_add_spare’:
super-intel.c:4833: error: ‘array_start’ may be used uninitialized in this function
super-intel.c:4834: error: ‘array_end’ may be used uninitialized in this function

This is valid, if we don't find a spare candidate then array_{start,end}
will be uninitialized.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2010-07-06 12:48:59 -07:00
Dan Williams d19e3cfb66 Merge branch 'fixes' into for-neil 2010-07-01 17:36:11 -07:00
Dan Williams 8cfc801c72 Merge branch 'subarray' into for-neil
Conflicts:
	mdadm.h
	super-intel.c
2010-07-01 17:36:05 -07:00
Dan Williams aa534678ba Rename subarray v2
Allow the name of the array stored in the metadata to be updated.  In
some cases the metadata format may not be able to support this rename
without modifying the UUID.  In these cases the request will be blocked.
Otherwise we allow the rename to take place, even for active arrays.
This assumes that the user understands the difference between the kernel
node name, the device node symlink name, and the metadata specific name.

Anticipating further need to modify subarrays in-place, introduce the
->update_subarray() superswitch method.  A future potential use
case is setting storage pool (spare-group) identifiers.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2010-06-22 16:30:59 -07: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
Dan Williams 4f0a7acc9a mdmon: record sync_completed directly to the metadata
When sync_action is idle mdmon takes the latest value of md/resync_start
or md/<dev>/recovery_start to record the resync/rebuild checkpoint in
the metadata.  However, now that mdmon is reading sync_completed there
is no longer a need to wait for, or force an idle event to take a
checkpoint.

Simply update the forward progress of ->last_checkpoint at every wakeup
event and force it to be recorded at least every 1/16th array-size
interval.  It may be recorded more frequently if a ->set_array_state()
event occurs.

This also cleans up some confusion in handling the dual-rebuild case.
If more than one spare has been activated the kernel starts the rebuild
at the lowest recovery offset, so we do not need to worry about
min_recovery_start().

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2010-06-15 18:41:57 -07:00
Dan Williams 0d80bb2f97 imsm: dump each disk's view of the slot state
Allow --examine to determine which disk might have a stale view of the
per-disk out-of-sync state.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2010-06-15 18:41:57 -07:00
Dave Jiang 0bd16cf217 create: Check with OROM limit before setting default chunk size
Make create check with the appropriate meta data handler and see what the
largest chunk size is supported. The current 512K default is not supported
by existing imsm OROM.

[dan.j.williams@intel.com: trim the upper limit to 512k for future oroms]
Signed-off-by: Dave Jiang <dave.jiang@intel.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2010-06-15 18:41:53 -07:00
Dan Williams 33414a0182 Kill subarray v2
Support for deleting a subarray out of a container.  When all subarrays
are deleted the component devices are converted back into spares, a
--zero-superblock is still needed to kill the remaining metadata at this
point.  This operation is blocked when the subarray is active and may
also be blocked by the metadata handler when deleting the subarray might
change the uuid of other active subarrays.  For example, with imsm,
deleting subarray 'n' may change the uuid of subarrays with indexes > n.

Deleting a subarray needs to be a container wide event to ensure
disks that record the modified subarray list perceive other disks that
did not receive this change as out of date.

Notes:
The st->subarray parsing in super-intel.c and super-ddf.c is updated to
be more strict now that we are reading user supplied subarray values.

Offline container modification shares actions that mdmon typically
handles so promote is_container_member() and version_to_superswitch()
(formerly find_metadata_methods()) to generic utility functions for the
cases where mdadm performs the operation.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2010-06-15 17:55:41 -07:00
NeilBrown d492df0307 Merge commit '3288b419b988b20a53a2b12eb8e5f9f536228db4'; commit '4363fd80bcc9f85ed824228dee5e6350a8d73e18'; commit '63b4aae33ebf00d443378daf313622630f2336c0'
* commit '3288b419b988b20a53a2b12eb8e5f9f536228db4':
  Revert "Incremental: honor --no-degraded to delay assembly"
  Incremental: honor an 'enough' flag from external handlers

* commit '4363fd80bcc9f85ed824228dee5e6350a8d73e18':
  imsm: robustify recovery-start detection
  fix: memory leak in mdmon_pid()

* commit '63b4aae33ebf00d443378daf313622630f2336c0':
  mdmon: fix missing open of md/<dev>/recovery_start
2010-05-31 11:34:14 +10:00
Dan Williams 4363fd80bc imsm: robustify recovery-start detection
update_recovery_start() assumed that the out-of-sync disk would always be
marked as IMSM_ORD_REBUILD in the disk_ord_tbl, but the segmentation
fault reported by Andy proves otherwise.  This might also be explained by
an interrupted rebuild and the disk has not yet been marked missing.

https://bugzilla.redhat.com/show_bug.cgi?id=592030

Reported-by: Andy Lutomirski <luto@mit.edu>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2010-05-26 13:33:43 -07:00
Dan Williams 97b4d0e971 Incremental: honor an 'enough' flag from external handlers
This is needed for imsm where:
1/ we want to report raid_disks as zero to allow mdadm -As to
   incorporate all spares
2/ we can't determine stale disks by looking at the event counts.
3/ we can't see per-subarray expectations with the info returned from
   the container level ->getinfo_super()

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2010-05-26 13:22:36 -07:00
Dan Williams 484240d8a3 mdmon: periodically checkpoint recovery
The kernel updates and notifies md/sync_completed when it is time to
take a checkpoint.  When this occurs (at 1/16 array size intervals)
write 'idle' to md/sync_action to have the current recovery position
updated in recovery_start and resync_start.

Requires the metadata handler to reset ->last_checkpoint when it has
determined that recovery has ended.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2010-05-14 17:42:49 -07:00
NeilBrown 691c6ee1b6 IMSM/DDF: don't recognised these metadata on partitions.
These metadata are not expected on partitions, and they have
no way of differentiation whether which is correct if they
are found both on the device and on the last partition.

So if the device is a partition, refuse to read the metadata.

Signed-off-by: NeilBrown <neilb@suse.de>
2010-04-29 16:09:59 +10:00
Dan Williams 4eb269706f Create: cleanup after failed create in duplicated array member case
mdadm prevents creation when device names are duplicated on the command
line, but leaves the partially created array intact.  Detect this case
in the error code from add_to_super() and cleanup the partially created
array.  The imsm handler is updated to report this conflict in
add_to_super_imsm_volume().

Note that since neither mdmon, nor userspace for that matter, ever saw an
active array we only need to perform a subset of the cleanup actions.
So call ioctl(STOP_ARRAY) directly and arrange for Create() to cleanup
the map file rather than calling Manage_runstop().

Reported-by: Krzysztof Wojcik <krzysztof.wojcik@intel.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2010-04-19 15:28:07 +10:00
Doug Ledford 94fcb80a8e powerpc compile fix
Signed-off-by: Doug Ledford <dledford@redhat.com>
Signed-off-by: NeilBrown <neilb@suse.de>
2010-04-07 09:19:42 +10:00
NeilBrown d682f3445c ddf/intel: zero out old metadata before creating a container.
Matching the functionality already in super0 and super1, when
we first create a container, remove any other recognisable metadata to
ensure it doesn't cause confusion.

Signed-off-by: NeilBrown <neilb@suse.de>
2010-03-10 15:55:47 +11:00
NeilBrown c147484252 Merge branch 'master' of git://github.com/djbw/mdadm 2010-03-10 07:54:03 +11:00
NeilBrown 624c5ad4cb Make sure reshape_active is cleared by getinfo_super
There were cases where --detail would report phantom reshapes.

Signed-off-by: NeilBrown <neilb@suse.de>
2010-03-09 16:15:29 +11:00
Dan Williams 49133e5782 imsm: kill ->creating_imsm flag
It is an unused holdover from long since removed functionality.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2010-03-03 00:03:04 -07:00
Dan Williams 32ba9157f5 Revert "Make the IMSM_DEVNAME_AS_SERIAL option work when creating containers."
This reverts commit 9ef5dbff4a as it is
duplicating the check that is done internal to imsm_read_serial().

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2010-03-03 00:03:04 -07:00
NeilBrown 921d9e164f Assemble: fix --force assembly of v1.x arrays which are recovering.
1.x metadata allows a device to be a member of the array while it
is still recoverying.  So it is a working member, but is not
completely in-sync.

mdadm/assemble does not understand this distinction and assumes that a
work member is fully in-sync for the purpose of determining if there
are enough in-sync devices for the array to be functional.

So collect the 'recovery_start' value from the metadata and use it in
assemble when determining how useful a given device is.

Reported-by: Mikael Abrahamsson <swmike@swm.pp.se>
Signed-off-by: NeilBrown <neilb@suse.de>
2010-02-04 12:02:09 +11:00
Luca Berra cf1be220e2 super-intel.c: use %zu specifier for printf of size_t
Fix compile warning when size_t is not a long.

Acked-by: Dan Williams <dan.j.williams@intel.com>
Signed-off-by: Luca Berra <bluca@vodka.it>
Signed-off-by: NeilBrown <neilb@suse.de>
2010-02-01 09:15:35 +11:00
Doug Ledford 9ef5dbff4a Make the IMSM_DEVNAME_AS_SERIAL option work when creating containers.
This allows a person to testing using loopback devices that don't
support serial number queries.

Signed-off-by: Doug Ledford <dledford@redhat.com>
Signed-off-by: NeilBrown <neilb@suse.de>
2010-01-19 10:39:39 +13:00
NeilBrown 8409bc51e8 Merge branch 'klockwork' of git://github.com/djbw/mdadm
Conflicts:
	super-intel.c
2009-12-30 13:46:52 +11:00
Dan Williams 1e5c69836d imsm: add support for checkpointing via 'curr_migr_unit'
Unlike native md checkpointing some data about the geometry and type of
the migration process is coded into curr_migr_unit.  Provide logic to
convert between md/{resync_start|recovery_start} and imsm/curr_migr_unit.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2009-12-21 17:54:32 -07:00
Dan Williams d23534e464 Teach sysfs_add_disk() callers to use ->recovery_start versus 'insync' parameter
Also fixup 'in_sync' versus 'insync' typo.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2009-12-21 11:26:21 -07:00
Dan Williams b7528a20cc Introduce MaxSector
Replace occurrences of ~0ULL to make it clear we are talking about maximal
resync/recovery position.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2009-12-21 10:23:26 -07:00
Dan Williams b7941fd68d mdmon: cleanup resync_start
We don't need to sprinkle reads of this attribute all over the place,
just once at the entry of read_and_act().  Also, the mdinfo structure
for the array already has a 'resync_start' member, so just reuse that.
Finally, rename get_resync_start() to read_resync_start to make it
consistent with the other sysfs accessors in monitor.c.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2009-12-14 12:57:55 -07:00
Dan Williams 8655a7b194 imsm: cleanup print_imsm_dev()
When printing the migration state there is no need to print "migrating".
The fact that the state is non-idle should be enough indication.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2009-12-12 13:57:28 -07:00
Dan Williams ecf408e914 imsm: fix thunderdome segfault
disk_list_get() can return NULL if:
1/ A formerly missing disk is re-added
2/ The original array has not been rebuilt, so the family number of the
   missing disk still matches
3/ The metadata record of the in-sync disks are read before the missing
   disk

This will result in the missing disk not adding its own serial number to
the disk_list, only its truncated value will be present.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2009-12-12 13:57:25 -07:00
Dan Williams ac6449bee9 imsm: fix spare promotion
When associating a spare take on the target's metadata version number to
satisfy future compare_super checks.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2009-12-10 15:03:34 -07:00
Dan Williams 6592ce37ee imsm: honor orom constraints for auto-layout
Factor out the orom checking bits to validate_geometry_imsm_orom() and
share it between validate_geometry_imsm_volume() and the entry path to
reserve_space().

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2009-12-10 15:03:31 -07:00
Dan Williams dd9bb2fbed imsm: prune dead code in validate_geometry_imsm
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2009-12-10 12:03:40 -07:00
Artur Wojcik 33a6535d00 Fix required to enable RAID arrays on SAS disks.
The patch increases the capacity of buffers used to store
sysfs path names. Originally the buffers were too small to
hold the canonical representation of sysfs path (in case
of a SAS device, especially a device installed behind an
expander).

Signed-off-by: Artur Wojcik <artur.wojcik@intel.com>
Reviewed-by: Andre Noll <maan@systemlinux.org>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2009-12-10 12:03:40 -07:00
Artur Wojcik 389508223e Fix for memory leak defect.
Possible memory leak. Dynamic memory stored in 'dev' and 'dev' allocated
through function 'malloc' can be lost on exit path.

Signed-off-by: Artur Wojcik <artur.wojcik@intel.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2009-12-10 12:03:40 -07:00
Artur Wojcik 1602d52c99 Fix for memory leak defect.
Possible memory leak. Dynamic memory stored in 'sra' allocated through
function 'sysfs_read' at line 2484 can be lost at lines 2491, 2560 and
2571.

Signed-off-by: Artur Wojcik <artur.wojcik@intel.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2009-12-10 12:03:40 -07:00
Artur Wojcik e207da2f1b Fix for memory leak defect.
Dynamic memory stored in 'devnum2devname(st->container_dev)' allocated
through function 'devnum2devname' at line 1274 is lost at line 1278.

Signed-off-by: Artur Wojcik <artur.wojcik@intel.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2009-12-10 12:03:40 -07:00
Artur Wojcik 4e5e717d72 Fix for NULL pointer dereference defect.
Pointer 'c' returned from call to function 'strchr' at line 954 may
be NULL and will be dereferenced at line 955.

Signed-off-by: Artur Wojcik <artur.wojcik@intel.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2009-12-10 12:03:40 -07:00
Artur Wojcik d362da3dfe Fix for NULL pointer dereference defect.
Pointer 'disk' returned from call to function '_get_imsm_disk' at line
700 may be NULL and will be dereferenced at line 710.

Signed-off-by: Artur Wojcik <artur.wojcik@intel.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2009-12-10 12:03:40 -07:00
Artur Wojcik 4e9d21862d Fix for NULL pointer dereference defect.
Pointer 'st' returned from call to function 'malloc' at line 320 may
be NULL and it will be dereferenced at line 321.

Signed-off-by: Artur Wojcik <artur.wojcik@intel.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2009-12-10 12:03:39 -07:00
Dan Williams c3ca5f6028 imsm: no need to report the component device name from container_content
sysfs_add_disk() regenerates the name from major:minor, so we can drop a
strcpy that the static analysis checker does not like.

Reported-by: Artur Wojcik <artur.wojcik@intel.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2009-12-10 12:03:39 -07:00
Artur Wojcik 7a6ecd5544 Fix for buffer overflow defect.
Buffer overflow, array index of 'nm' may be out of bounds.

Signed-off-by: Artur Wojcik <artur.wojcik@intel.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2009-12-10 12:03:39 -07:00
Artur Wojcik 791b666ae8 Fix for NULL pointer dereference.
Pointers '_dev' and '_disk' returned from call to function '_get_imsm_dev'
and '_get_imsm_disk' may be NULL and will be dereferenced at lines
2933 and 2934, respectively.

Signed-off-by: Artur Wojcik <artur.wojcik@intel.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2009-12-10 12:03:39 -07:00
Artur Wojcik d10d56feb8 Fix for NULL pointer dereference.
Suspicious dereference of pointer 'super' before NULL check at
line 3429.

Signed-off-by: Artur Wojcik <artur.wojcik@intel.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2009-12-10 12:03:39 -07:00
Artur Wojcik 20cbe8d2ba Fix for memory and resource leak.
Make sure opened file descriptor is cleaned up on exit
path. Also make sure allocated memory for 'sra' is released
on exit path, too.

Signed-off-by: Artur Wojcik <artur.wojcik@intel.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2009-12-10 12:03:39 -07:00
Artur Wojcik 0fbd635caa Fix for possible NULL pointer dereference.
Pointer 'this' returned from call to function 'malloc' at line 3795
may be NULL and will be dereferenced at line 3796.

Artur Wojcik <artur.wojcik@intel.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2009-12-10 12:03:37 -07:00
Dan Williams a7dd165b4e imsm: catch attempt to auto-layout zero-length arrays
When -z is omitted reserve_space() looks to satisfy a zero length
allocation which lo and behold is equal to the amount of free space on a
full disk.  So, catch maxsize == 0 and simplify the return value from
merge_extents() to always equal amount of free space (no benefit to
having a special case ~0ULL == error).

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2009-12-01 16:04:06 -07:00
NeilBrown b42f577a0d Improve error messages when metadata handler does not support request.
->validate_geometry is called to validate overall parameters,
and to validate each individual device.
If it ever fails, it needs to report the reason, as common code
cannot possible know.

Signed-off-by: NeilBrown <neilb@suse.de>
2009-11-17 13:15:34 +11:00
NeilBrown 1799c9e8f8 super-intel: Fix compilation of mdassemble.
Signed-off-by: NeilBrown <neilb@suse.de>
2009-10-20 13:50:23 +11:00
Dan Williams 6e46bf344b imsm: add --update=uuid support
When disks have conflicting container memberships (same container ids
but incompatible member arrays) --update=uuid can be used to move
offenders to a new container id by changing 'orig_family_num'.

Note that this only supports random updates of the uuid as the actual
uuid is synthesized.  We also need to communicate the new
'orig_family_num' value to all disks involved in the update.  A new
field 'update_private' is added to struct mdinfo to allow this
information to be transmitted.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2009-10-13 17:41:53 -07:00
Dan Williams e683ca88ac imsm: fix/support --update
Fix init_super_imsm() to return an empty mpb when info == NULL, and
teach store_super_imsm() to simply write out the passed in mpb.

Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=523320

Reported-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2009-10-13 17:41:53 -07:00
Dan Williams f796af5d5e imsm: fix spare record writeout race
imsm_activate_spare() in the manager thread may race against
write_super_imsm_spares() in the monitor thread.  Give
write_super_imsm_spares() its own private mpb buffer to prevent
confusing the manager.

This change uncovered cases where spares were not being assembled due to
a failed metadata version number check.  Spares can freely associate
across metadata version number, so reduce the scope of the version check
in the spare assembly case.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2009-10-13 17:41:53 -07:00
Dan Williams a2b9798159 imsm: disambiguate family_num
This is a result of trawling through the Windows implementation to learn
the mechanism of how it disambiguates family_num.  It is a continuation
of commit 148acb7b "imsm: fix family number handling" which introduced a
regression when reassembling a container with stale disks and rebuilt
members.

When rebuilding, a new family number is assigned to protect against the
"prodigal array member" problem.  It prevents a former family member
from returning to the system and causing a rebuild to go the wrong
direction.  However, this invalidates looking at the generation number to
determine the most up-to-date disk when comparing across family numbers.
Instead the assembly logic looks for agreement between a disk's local
family membership compared against a global list of all families in the
system.  Whenever a disk's local metadata does not match a family number
on the global list that family number is marked offline.

It is possible that this logic results in multiple incompatible but
valid family numbers existing in a container.  In this case mdadm.conf
cannot be consulted because it only records the uuid which is generated
from static fields in the metadata.  The metadata lacks the data needed
to disambiguate "local" versus "foreign".  The "foreign" array in this
case requires updating to change its container-id information
(orig_family_num), and possibly the member array names.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2009-09-30 11:45:41 -07:00
Dan Williams 51725a7c25 imsm: kill close() of component device
None of the other formats close the passed in fd at load, and this
becomes a problem when trying to support --update where we need O_EXCL
protection across the entire operation.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2009-09-30 11:44:38 -07:00
Dan Williams 25ed7e5924 imsm: cleanup disk status tests
Add is_failed(), is_configured(), and is_spare() helpers to clean up
disk status flag testing.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2009-09-28 14:40:59 -07:00
Dan Williams cf53434e5c imsm: clear CONFIGURED_DISK for failed drives
Synchronizing with what the Windows driver does.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2009-09-15 11:35:28 -07:00
Dan Williams ee5aad5ae2 imsm: kill USABLE_DISK flag
'USABLE_DISK' is not a 'persistent' status flag it is an internal status
flag used for the in memory representation of the disk in the Windows
driver.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2009-09-15 11:35:28 -07:00
Dan Williams 709743c554 imsm: fix spare promotion
1/ Fix an off by one error when detecting whether the device allocation
   loop succeeded or not
2/ Update ->num_raid_devs before copying to avoid a segmentation fault

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2009-09-15 11:34:20 -07:00
NeilBrown 4737ae25de Exmaine/brief: put member arrays after container arrays.
A previous patch moved move the '--examine --brief' reporting of
member arrays to before their containers.  This breaks "mdadm -As"
assembly.  So put them back, but still fix the problem addressed by
previous patch.

Signed-off-by: NeilBrown <neilb@suse.de>
2009-08-07 14:17:40 +10:00
Dan Williams 7e8545e954 imsm: fix spare-uuid assignment
imsm spares do not have container membership by default so we associate
them with the first container found in the configuration file.  Some
ARRAY lines do not specify the metadata type so we cannot assume that
_cst will always be valid.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2009-07-31 17:11:42 -07:00
Dan Williams 148acb7baa imsm: fix family number handling
The family_number field can change.  The option-rom will change the
family number when it starts a rebuild process (flags a container for
rebuild).  This was not seen previously as mdadm would usually start the
rebuild process, preserving the family number.

This is the mechanism that helps to prevent a prodigal array member from
being returned to its original system and cause a rebuild to go in the
wrong direction.  With the change we will end up with a container that
will fail to assemble unless the device with the incompatible family
number is left out of the assembly.

So, take several actions:
1/ Convert uuid generation to use orig_family_num, being careful to
   preserve the existing uuid in the case where orig_family_num is not
   set (i.e. previous mdadm created imsm arrays)
2/ Set orig_family_num at Create.  For arrays created by mdadm prior to
   this release orig_family_num will be zero, so set it to family_num at
   the first metadata write.
3/ Add checks for orig_family_num to compare_super_imsm
4/ Update the family number when initiating rebuild
5/ The option-rom mixes some random data into the family number, add
   this functionality to the mdadm implementation.

Reported-by: Marcin Labun <marcin.labun@intel.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2009-07-31 17:11:41 -07:00
Dan Williams 329c827869 imsm: fix activate_spare off-by-one
The last sector of an array is calculated by start + size - 1.

Reported-by: Rafal Marszewski <rafal.marszewski@intel.com>
Reported-by: Jarema Bielanski <jarema.bielanski@intel.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2009-07-31 17:11:41 -07:00
Dan Williams 9b1fb67776 conditionally update uuids in the map file after Create()
The map file needs to be updated after adding the first member array to
an Intel metadata container.  The uuid for an imsm container uses the
->family_num field of the metadata.  This field is static, but is only
set after the first member array has been created.  Prior to this all
devices are free floating spares and do not have any information that
can identify specific container membership.  At Create() time we take
the uninitialized uuid from ->get_info_super() prior to updating the
metadata.  So the current result is:

# mdadm --create /dev/md/imsm /dev/sd[b-e] -n 4 -e imsm
# mdadm --create /dev/md/vol0 /dev/md/imsm -n 4 -l 0
# cat /var/run/mdadm/map
md126 /md127/0 3e03aee2:78c3c593:1e8ecaf0:eefb53ed /dev/md/vol0
md127 imsm 53d6f8b1:7a783f24:f30483c5:705c48c7 /dev/md/imsm
# mdadm -Ebs
ARRAY metadata=imsm UUID=589d2d2c:4221a54d:acb63c06:c3907f52
ARRAY /dev/md/vol0 container=589d2d2c:4221a54d:acb63c06:c3907f52
	member=0 UUID=57b89b63:5cd0eae1:17dd26b3:51cc78d4

So, before we write out the new metadata check to see if the member
array uuid has changed as a result of this addition.  If it has, update
its uuid in the map file and flag its parent container for updating.  In
support of updating the container uuid the semantics of
->write_init_super are changed to clear any metadata specific member
array cursors (e.g. ddf_super.currentconf or intel_super.current_vol)
such that a subsequent call to ->getinfo_super returns container
information.

Reported-by: Ignacy Kasperowicz <ignacy.kasperowicz@intel.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2009-07-31 17:11:41 -07:00
Dan Williams 0d5a423fe7 imsm: fixup examine_brief to be more descriptive in the container only case
Prior to creating any arrays in a new container the output from -Ebs for
a 4-disk imsm array returns:

		spares=4

We should at least display that these are imsm spares:

	ARRAY metadata=imsm
		spares=4

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2009-07-31 17:11:41 -07:00
Dan Williams 37424f132c fix examine_brief segfault
When performing an "-Ebs -e <metadata type>" we segfault because the
superblock has been freed too early.  We also leak memory for 'ddf' and
'imsm' because, unlike super[01], we do not implicitly free when
->load_super is called on an already loaded supertype.

So, fix up imsm and ddf to match type 0 and 1 ->load_super() semantics,
and update Examine to not free the superblock until all usages have been
exhausted.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2009-07-31 17:11:41 -07:00
Dan Williams af99d9ca67 teach imsm and ddf what st->subarray means at load_super time
RebuildMap wants to poll through mdstat and retrieve a (kernel name,
uuid, user name) tuple for each array.  Teach imsm and ddf to honor
st->sub_array at ->load_super() time to set their internal subarray
pointers to the value specified in st->subarray, or return an error if
st->subarray specifies an invalid array.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2009-07-31 17:08:22 -07:00
NeilBrown fa09d4961e Examine: fix --examine --brief --verbose on containers.
With --verbose, --examine --brief prints dev= information after
the personality has done its bit.
But with containers, the member array are printed in between.
So in super-ddf and super-intel, move printing of the member
arrays to before printing of the container.  This avoids
confusion.

Signed-off-by: NeilBrown <neilb@suse.de>
2009-06-04 12:44:32 +10:00
NeilBrown 4291d691b6 super-intel: fix test on failed_disk_num.
We sometimes set failed_disk_num to ~0.
However we cannot test for equality with that as  failed_disk_num
is 8bit and ~0 is probably 32bit with lots of 1's.
So test if ~failed_disk_num is 0 instead.

Reported-By: "Mr. James W. Laferriere" <babydr@baby-dragons.com>
Signed-off-by: NeilBrown <neilb@suse.de>
2009-06-04 12:29:21 +10:00
Dan Williams 1124b3cf29 imsm: kill "auto=" in brief_examine_super_imsm
The auto parameter is obsolete after kernel version 2.6.28 as all arrays
are partitionable via block device extended minor support.  Environments
that requre the mdp style of array can always edit the configuration
file to specify auto=mdp.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2009-05-18 10:02:58 -07:00
Dan Williams 81062a36ab imsm: fix num_domains
The 'num_domains' field simply identifies the number of mirrors.  So it
is 2 for a 2-disk raid1 or a 4-disk raid10.  The orom does not currently
support more than 2 mirrors, but a three disk raid1 for example would
increase num_domains to 3.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2009-05-18 09:58:55 -07:00
NeilBrown 13a3b65d54 Fix printf compile warning.
It always afters to cast big things to (unsigned long long) before
printing as %llu - it seems there will always be one arch which
has something to complain about ....

Signed-off-by: NeilBrown <neilb@suse.de>
2009-05-11 15:47:10 +10:00
NeilBrown 061f2c6abd Make --brief even briefer.
Because ---examine --brief, or --detail --brief are
often used to create mdadm.conf, and because people don't want to
have to update their mdadm.conf unnecessarily, we don't want to
include information that might change.
And now that level changing is supported, that is almost everything
but UUID.

So move some more fields into the "Only print with --verbose" class.

Signed-off-by: NeilBrown <neilb@suse.de>
2009-05-11 15:18:20 +10:00
Dan Williams 252d23c018 imsm: add the ddf field
This field is always one in arrays created by the Windows driver / OROM,
not sure why...

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2009-04-12 00:58:28 -07:00
Dan Williams 979d38be50 imsm: round down array size at Create
Store the 1MB rounded down size of the array at create time.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2009-04-12 00:58:28 -07:00
Dan Williams da9b4a62af imsm: set array size at Create/Assemble
imsm arrays round down the effective array size to the closest 1
megabyte boundary so teach get_info_super_imsm and sysfs_set_array to
set 'md/array_size' if available (and make sure ddf uses the default
size).

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2009-04-12 00:58:28 -07:00
Dan Williams da18878954 imsm: turn off curr_migr_unit updates
New documentation shows that this field is not equivalent to
md/resync_start.  Disable updates until full support can be developed.

Writing '0' when a migration starts/re-starts remains correct.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2009-04-12 00:58:28 -07:00
Dan Williams 1ce0101c9a imsm: defend against unsupported migrations (temporary)
Until support for higher order migrations (online capacity expansion,
raid level migration, chunk size migration...) are implemented do not
allow arrays in these states to be assembled.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2009-04-12 00:58:28 -07:00
Dan Williams 1484e72797 imsm: add 'verify', 'verify with fixup', and 'general' migration types
imsm distinguishes parity initialization from parity checking in the
metadata. Older option roms marked the repair operation with the
'verify' type and a 'with fixup' flag in the raid device 'status' field.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2009-04-12 00:58:27 -07:00
Dan Williams ff5963088d imsm: fix imsm_map.num_domains
'num_domains' is the number of parity domains.  I.e. 2 in the raid10
case (2-mirrors), while raid0 through raid5 have 1 parity domain (even
though raid0 does not have parity).

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2009-04-12 00:58:27 -07:00
Dan Williams 1f45a8ad20 imsm: ensure mpb buffer is zeroed
Don't leak unitialized data into the mpb.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2009-04-12 00:58:27 -07:00
Dan Williams 9d84c8eac2 imsm: support --examine --export
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2009-04-11 21:53:25 -07:00
Dan Williams ae2bfd4e13 imsm: make uuid separator consistent with ddf
'-' to ':'

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2009-04-11 21:53:25 -07:00
Dan Williams 316e2bf426 imsm: extract right-most whitespace stripped serial number
According to new documentation the metadata expects that all whitespace
(characters <= 0x20) are stripped from the incoming serial number.  If
the length remains longer than MAX_RAID_SERIAL_LEN then only the
right-most characters are preserved.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2009-04-08 11:41:51 -07:00
NeilBrown b9d77223eb Release mdadm-3.0-devel3 2009-03-10 16:59:57 +11:00
Dan Williams 8be094f0ee imsm: display supported chunk sizes in --detail-platform
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2009-02-27 15:35:20 -07:00
Dan Williams efb30e7f1e imsm: auto layout
In support of auto-layout:

1/ collect and merge all extents to find the largest common-start free region
2/ verify that we meet the "all volumes must use the same set of disks"
2/ mark the disks to be added in add_to_super_imsm_volume

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2009-02-24 18:45:57 -07:00
Dan Williams dab4a5134e sysfs: allow sysfs_read to detect and drop removed disks
All operations that rely on loading from an existing container (like
--add) will fail after a disk has been removed.  Provide an option to
skip missing / offline disks rather than abort.  We attempt to do this
in the load_super_{imsm,ddf}_all cases when mdmon is running i.e. we
already have a consitent version of the metadata running in the system.
Otherwise, we fail as normal and let the administrator fix up the
container.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2009-02-24 18:45:56 -07:00
Dan Williams db575f3b9e imsm: retry load_imsm_mpb if we suspect mdmon has made modifications
If the checksum verification fails and mdmon is running we retry the
load to get a consistent snapshot of the mpb.  Found by
tests/08imsm-overlap.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2009-02-24 18:45:56 -07:00
Dan Williams ecf45690f2 imsm: verify single sector mpb checksums
If the mpb is only one sector do not skip the checksum verification.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2009-02-24 18:45:56 -07:00
Dan Williams 0556e1a2b1 imsm: fix mark_failure / introduce mark_missing
Actually, rename mark_failure to mark_missing and then implement the
correct mark_failure which according to new documentation is to:

1/ Set the FAILED status bit
2/ Set IMSM_ORD_REBUILD to mark the disk out of sync
3/ Set map->failed_disk_num if this is the first failure detected
   failure (it is ~0 otherwise)

Previously the assumption was that IMSM_ORD_REBUILD only appeared in
map[1], so all routines that care about out-of-sync disks need to be
updated.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2009-02-24 18:45:56 -07:00
Dan Williams 620b171338 imsm: introduce get_imsm_disk_slot
Implement a common disk index to disk slot routine and replace open
coded versions.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2009-02-24 18:45:56 -07:00
Dan Williams df4746577e imsm: fix activate spare to ignore foreign disks
A foreign disk is one that all other drives believe is not-in-sync but
does not have the 'failed' status bit set.

This also reverts, because that commit is addressing the wrong problem.
Ideally mdmon would kick "non-fresh" drives like the kernel does at
native-md activation time, but that is too awkward to implement at the
moment because mdadm owns container manipulations.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2009-02-23 23:06:24 -07:00
Dan Williams 7a70e8aa8d imsm: fixup container spare uuids by default
Spares in the imsm case are marked with the "match-all" uuid of
ffffffff-ffffffff-ffffffff-ffffffff.  When performing incremental
assembly we need to associate such devices with a populated container
uuid.  Also when performing --detail on a container with only spares
present we can make an attempt to return a real uuid.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2009-02-23 23:06:24 -07:00
Dan Williams 689c9bf3c3 imsm: fix missing initializations of the per-disk extents pointer
Fixes a glibc assertion when trying to free a pointer that was not
malloc'd.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2009-02-23 23:06:24 -07:00
Dan Williams cceebc67f1 imsm: provide a simulated option-rom for regression tests
IMSM_NO_PLATFORM turns off checks that should be tested, so provide a
IMSM_TEST_OROM variable to allow testing the orom constraints in the
mdadm regression suite.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2009-02-23 14:26:10 -07:00
Dan Williams 5a03814040 imsm: block creation of devices with identical names
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2009-02-02 15:01:13 -07:00
Dan Williams 78757ce8a5 imsm: don't check raid1 chunk size
mdadm -C /dev/md/r1d2n1s0-5 -amd -l1  --size 5242880 -n 2 /dev/sdb /dev/sdc  -R -f -v -c 64
mdadm: chunk size ignored for this level
mdadm: super0.90 cannot open /dev/sdb: Device or resource busy
mdadm: super1.x cannot open /dev/sdb: Device or resource busy
mdadm: platform does not support a chunk size of: 0
mdadm: device /dev/sdb not suitable for any style of array

Reported-by: Krzysztof Wojcik <krzysztof.wojcik@intel.com>
Tested-by: Jacek Danecki <jacek.danecki@intel.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2009-02-02 10:55:31 -07:00
Dan Williams caf8d23175 imsm: fix failed disks are allowed back into the container
Failed disks do not have valid serial numbers which means we will not
pick up the 'failed' status bit from the metadata entry.  Check for
dl->index == -2 to prevent failed disks from being incorporated into the
container.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2009-01-23 15:45:34 -07:00
Dan Williams 5615172f1d Create: warn when a metadata format's platform components are missing
If the metadata handler can not find its platform support components
then there is no way for it to verify that the raid configuration will
be supported by the option-rom.  Provide a generic method for metadata
handlers to warn the user that the array they are about to create may
not work as intended with a given platform.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2009-01-20 01:36:51 -07:00
Dan Williams a20d2ba5f3 imsm: enforce "all member disks must be members of all arrays"
This is a key orom-compatibility constraint.  A nice side effect is that
it precludes the corner case of 'create' racing against 'spare activate'
since the create will fail to convert a spare into an array member.  At
create time we check if this is the first member array in the container
if it is than all disks are possible candidates, if it is not then only
current members are permitted.

A bit hairier is spare-activation handling in the presence of this
constraint.  It is difficult because spare handling is per array.  The
approach taken is to:

1/ check that a new spare can cover all defined arrays in the container
2/ ensure that partially assimilated spares are the first candidates
   when looking for a spare region to activate.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2009-01-20 01:36:51 -07:00
Dan Williams 1c556e92ba imsm: enforce num_disks constraints
RAID1 == 2 disks
RAID5 >= 3 disks
RAID10 == 4 disks

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2009-01-20 01:36:50 -07:00
Dan Williams 35f81cbbc5 imsm: rename vprintf macro to pr_vrb
Don't redefine standard library calls unecessarily...

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2009-01-20 01:36:50 -07:00
Dan Williams a18a888ea7 Create: allow per-metadata default layouts
Let handlers specifiy their own defaults, specifically needed for the
imsm-raid5 case where mdadm defaults to 'ls' and imsm to 'la'.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2009-01-20 01:36:50 -07:00
Dan Williams 03cd4cc810 imsm: imsm_read_serial check for zero-length response
VMWare virtual disks successfully run the inquiry but return a zero response.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2009-01-20 01:33:56 -07:00
Dan Williams be2c0e387b imsm: fix dev_open return value handling
dev_open returns an fd

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2009-01-20 00:29:34 -07:00
NeilBrown 45b662b611 Merge branch 'devel' of git://git.kernel.org/pub/scm/linux/kernel/git/djbw/mdadm into devel-3.0 2008-12-18 16:58:25 +11:00
Dan Williams 4025c288b2 imsm: don't take chunk_size into account for raid1
Results in chopping off usable parts of the requested size.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2008-12-08 16:59:18 -07:00
Dan Williams c8151cbc42 imsm: reverse swapped arguments to posix_memalign in imsm_prepare_update
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2008-12-08 16:59:18 -07:00
Dan Williams ba2de7ba05 imsm: convert dev_tbl to devlist
...to facilitate testing arbitrary numbers of raid devices

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2008-12-08 16:59:18 -07:00
Dan Williams d665cc31e7 imsm: provide a detail_platform method
Dump the orom capabilities and hardware disk configuration.  This code
relies on the name of scsi_host objects to determine the hardware port
number.  Hopefully this information is stable...

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2008-12-08 16:59:18 -07:00
Dan Williams 4cce406959 introduce --detail-platform to display platform raid capabilities
Metadata formats like imsm work in concert with platform firmware and
hardware, so provide a way for mdadm to display this info to the user.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2008-12-08 16:59:18 -07:00
Dan Williams 88c32bb1ec imsm: validate arrays being created against firmware capabilities
These checks are only enabled when platform support for imsm is found,
i.e. ahci driver is loaded and talking to an Intel(R) controller, and
the option rom header is located.

They can be turned off by setting the environment variable
IMSM_NO_PLATFORM to 1.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2008-12-08 16:59:18 -07:00
Dan Williams 54c2c1ea23 imsm: pass disk info in create message
We may be creating on spare disks in which case we need to know which
disk goes in which slot.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2008-12-08 16:59:17 -07:00
Dan Williams 0dcecb2e2d imsm: correct start offset handling at create time
imsm metadata requires all members of a raid volume to start at the same
offset.  So, incrementally build a composite disk from all the
candidates passed to ->validate_geometry.  After each disk is added
merge the extents and search for a common start offset that satisfies
the requested raid device size.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2008-12-08 16:59:17 -07:00
Dan Williams 03bcbc654f imsm: fix setting of device size for raid1
When chunksize is 0 in the raid1 case we need to use
info_to_blocks_per_member() to calculate the array size.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2008-12-08 16:59:17 -07:00
NeilBrown 8592f29d64 Create: support autolayout when creating in a DDF
If, when creating an array, a signal target device is given which
is a container, then allow the metadata handler to choose which
devices to use.
This is currently only supported for DDF.

Signed-off-by: NeilBrown <neilb@suse.de>
2008-12-04 16:08:33 +11:00
NeilBrown e46273ebe4 Change 'size' argument to validate_geometry to be sectors, not K
That way it is the same a *freesize, and generally less confusing.

Signed-off-by: NeilBrown <neilb@suse.de>
2008-12-04 15:47:57 +11:00
Dan Williams dda5855f96 imsm: fix metadata reservation
1/ When truncating the space reserved for the metadata round down to an
   even numbered sector count to avoid an off-by-one error when
   sysfs_add_disk rounds up.
2/ Set the current metadata parameter block size
   as a floor.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2008-11-27 15:41:03 +11:00
NeilBrown 208933a7a8 Tidy error messages for add_to_super failure.
Make sure every failure from add_to_super prints a suitable
error message, and then don't print any error in the caller.

Signed-off-by: NeilBrown <neilb@suse.de>
2008-11-27 15:39:59 +11:00
Dan Williams f20c396836 allow add_to_super to return errors
Prepare add_to_super to validate disks against the platform capabilities

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2008-11-27 15:30:39 +11:00
Dan Williams 92bd8f8d3f imsm: fix uuid_from_super given 'signature' is not constant
The version portion of the signature changes depending on the contents
of the container.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2008-11-08 16:03:07 -07:00
Dan Williams 4d1313e901 imsm: compatibility fixes for creating imsm arrays
When creating an imsm array use the lowest possible feature set to
maximize compatibility.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2008-11-08 16:03:07 -07:00
Dan Williams f2f27e63c4 imsm: fixup disk status definition endianess
Change the multibyte disk status field definitions to imsm byte-order
(little-endian) to match other multibyte field definitions.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2008-11-08 16:02:56 -07:00
Dan Williams fe7ed8cb4f imsm: add definitions for recent imsm versions
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2008-11-08 15:47:39 -07:00
Dan Williams e3bba0e010 imsm: cleanup migration definitions and usage
imsm_set_array_state need not look at the map_state when failed==0

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2008-11-07 15:57:31 -07:00
Dan Williams 5115ca67fd imsm: cleanup ->match_home and comment on return value
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2008-11-07 15:08:09 -07:00
NeilBrown 97f734fde2 A couple of bugfixes found by suse autobuilding:
1/ ia64 appear to have __clone2, not clone.
2/ Including "++" in the arg to a macro is a bad thing to do.

Signed-off-by: NeilBrown <neilb@suse.de>
2008-11-07 14:46:30 +11:00
Dan Williams 3ebe00a1e2 imsm: display container uuid in detail_super
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
2008-11-04 20:50:39 +11:00
Dan Williams 44470971ce imsm: display member array uuid in examine_super_imsm
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
2008-11-04 20:50:39 +11:00
NeilBrown cf8de6913b Don't give array name in --examine --brief output if it is doubtful.
Now that mdadm.conf doesn't need an array name, we don't need to
give one if the array cannot reliably provide one.
2008-11-04 20:50:38 +11:00
NeilBrown 40ebbb9cfe util: make env checking more generic
Change the "env_check_mdmon" function to be more generic, accepting
and environment variable name, as soon we will have a new use for it.

Signed-off-by: NeilBrown <neilb@suse.de>
2008-11-04 10:35:43 +11:00
NeilBrown d9b420a5cd intel: Avoid 'may be used before initialised' warning.
When compile with -Os, the compile doesn't work out that the
variable is always initialised before usage, so we tell it.
2008-11-04 10:35:40 +11:00
Dan Williams 1e7bc0ed08 imsm: include members in ->brief_examine
A prerquisite for getting imsm arrays assembled by mdadm -As.
2008-10-28 10:55:31 -07:00
Dan Williams 78d30f94c4 imsm: copy raid device info when associating spares
If a spare is included in the list of examined disks we need to copy in at
least enough information to get the uuid of the populated container.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2008-10-28 10:55:31 -07:00
Dan Williams a575e2a7cd imsm: return associated uuid for spares
This prevents a uuid of all f's from being displayed when an imsm spare is
listed along with active disks for mdadm -Eb.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2008-10-28 10:55:31 -07:00
Dan Williams 032e9e2953 Examine: fix MD_DISK_SYNC is a bit not a flag
Examine() is actually looking at the ACTIVE bit.  This happened to work for
imsm spares but now it needs to be fixed up.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2008-10-28 10:55:31 -07:00
Dan Williams 072b727f72 imsm: update metadata immediately on "add spare" events
...without this the spare record is delayed until the next metadata
event.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2008-10-28 10:55:31 -07:00
Dan Williams a54d52625a update copyright headers
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2008-10-28 10:55:29 -07:00
Dan Williams 57ed8c9155 Treat all devices at the container level as spares
Raid disk and disk number information is not relevant at the container
level, especially for imsm.  So arrange for getinfo_super_imsm() to
always publish devices as spares and report the number of spares at
Assemble() time.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2008-10-15 14:43:57 -07:00
Dan Williams 36ba7d4849 Allow a uuid of all f's to always match
The uuid returned for an imsm spare device will never match the uuid of an
active disk.  So make mdadm interpret a uuid of all f's as "match any".

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2008-10-15 14:43:57 -07:00
Dan Williams 27fd627414 imsm: show uuid in ->examine_super()
...and add "auto=md" to the brief output.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2008-10-15 14:43:56 -07:00
Dan Williams 792449393d non-trivial warn_unused_result fixes, activate_spare
Both super-ddf and super-intel ignore memory allocation failures during
->activate_spare.  Fix these up by cancelling the activation.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2008-10-15 14:15:52 -07:00
Dan Williams 3f6efecc4c imsm: determine failed indexes from the most up-to-date disk
load_imsm_disk() currently notices if spares missed their activation
update, but we allow a stale failed disk back in to the array because its
serial number is clobbered in the most up-to-date disk.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2008-10-15 14:15:51 -07:00
Dan Williams 47ee5a4566 imsm: manage a list of missing disks
If a drive is removed while mdmon is not running we need a way to
identify what is missing and mark that disk as failed in the metadata.
At ->load_super() time create a list of missing disks defined as a disk
that is marked in-sync yet does not appear in super->disks.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2008-10-15 14:15:51 -07:00
Dan Williams 1ee1e9fc62 imsm: fix mpb_size calculation in write_super_imsm
Spotted a thinko... raid devices are dynamically sized, disks are not.
The space for disks is always mpb->num_disks * sizeof(struct imsm_disk).

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2008-10-15 14:15:51 -07:00
Dan Williams f8f603f133 imsm: enable checkpointing of migration (resync/rebuild)
When the array is shutdown, or when mdadm --wait-clean is called, any
active resync process will be idled allowing mdmon to record the current
resync position.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2008-10-15 14:15:51 -07:00
Dan Williams 593add1b56 monitor: protect against CONFIG_LBD=n
md/resync_start reports different terminal values depending on kernel
configuration (~0UL versus ~0ULL).  Make detection of the
resync-complete state more robust by comparing against array size.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2008-10-15 14:15:51 -07:00
Dan Williams 14e8215b1b imsm: trust sector reservation from metadata
On ich6r the option-rom appears to reserve only 432 sectors rather than
the 418+4096 of newer implementations.  For compatibility trust the
metadata in these cases.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2008-10-15 14:15:51 -07:00
Dan Williams c92a2527e1 imsm: confirm raid10 layout, fix up handling raid10 failures
1/ near-2 indeed matches how the Windows driver lays out the data
2/ update imsm_check_degraded to check for rebuilding disks in the
   raid10 case

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2008-10-15 14:15:47 -07:00
Dan Williams 5c3db629a6 imsm: more serial handling fixups
zero-initialize the serial buffer to handle cases where the response is
less than MAX_RAID_SERIAL_LEN.

Tested-by: Jacek Danecki <jacek.danecki@intel.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2008-10-15 13:12:17 -07:00
NeilBrown ff54de6e47 Report uuid in --detail --brief for ddf and intel
The uuid is slightly fictitious but needed for array matching.
2008-09-18 16:11:40 +10:00
NeilBrown 51006d8586 Add uuid support for super-intel.
'imsm' does not provide any real uuid, so we synthesise one
from various stable bits of the superblock.
2008-09-18 16:07:32 +10:00
NeilBrown 9362c1c80c Allow metadata handler to report that it doesn't record homehost.
For now, this means that the lack of a homehost doesn't always prevent
assembly.
Soon we will allow assembly anyway, but have different messages if
homehost isn't supported.
2008-09-18 16:06:41 +10:00
NeilBrown c5afc314e2 Lots of fixes to make incremental assembly of containers work.
So:
  mdadm -I /dev/whatever

will (if appropriate) add whatever to a container, then start
any arrays inside the container.
2008-09-18 16:03:05 +10:00
NeilBrown 352452c364 Handle incremental assembly of containers.
mdadm -I /dev/part-of-container

should add that to a container, creating if it needed,
and then try to assemble any arrays in the container.

Signed-off-by: NeilBrown <neilb@suse.de>
2008-09-18 16:01:57 +10:00
NeilBrown f35f252592 Move calls to SET_ARRAY_INFO to common helper.
When we assemble an array, there are three different approaches
depending on whether metadata is internal or external, and on
kernel version.

Move all this to a common helper instead of duplicating in 3 places.

Signed-off-by: NeilBrown <neilb@suse.de>
2008-09-18 16:01:55 +10:00
NeilBrown 7801ac2092 Factor out add-disk code
The variety of approaches to 'add_disk' are factored out into
a separate function, and Incremental mode benefits by being
closer to supporting the assembly of containers.

Also remove the adding-to-array-data-structure out of sysfs_add_disk
and into add_disk.

And add some tests for --incremental mode to make sure we don't break it.

Signed-off-by: NeilBrown <neilb@suse.de>
2008-09-18 15:13:32 +10:00
NeilBrown 0e60042683 Compile fixes, particularly moving more stuff under MDASSEMBLE
Now 'make everything' works again.
2008-09-18 15:04:47 +10:00
NeilBrown a8473e68c7 Fix compile warning/error.
gcc said:
  error: large integer implicitly truncated to unsigned type

Signed-off-by: NeilBrown <neilb@suse.de>
2008-09-18 14:10:42 +10:00
Dan Williams e553d2a458 imsm: allow a failed disk to be readded
Allow the following sequence to rebuild the array
mdadm --fail /dev/md/r1 /dev/disk
mdadm --remove /dev/imsm /dev/disk
mdadm --add /dev/imsm /dev/disk

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2008-09-15 20:58:42 -07:00
Dan Williams 301406c9fd imsm: use ->getinfo_super() in ->container_content()
* allows container_content() to pick up the safemode_delay
* removes some duplicate code
* fixes an endian bug setting info->array.chunk_size

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2008-09-15 20:58:42 -07:00
Dan Williams a67dd8cc58 Allow metadata handlers to communicate desired safemode delay via mdinfo
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2008-09-15 20:58:42 -07:00
Dan Williams 1f24f03530 imsm: fix up serial handling
* Trim trailing and leading whitespace
* Allow unterminated serial numbers up to MAX_RAID_SERIAL_LEN

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2008-09-15 20:58:41 -07:00
Dan Williams f9ba0ff124 imsm: only use the device name as a fallback when IMSM_DEVNAME_AS_SERIAL=1
Also ensure that the serial buffer is initialized.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2008-09-15 20:58:41 -07:00
Dan Williams 0c046afd06 imsm: rectify map handling
The secondary map is used to reflect the migration state of the array
i.e.  from dev->vol.map[1] to dev->vol.map[0].  Ensure a rebuilding /
initializing array is marked in the second map, while normal status is
reflected in the first map.  Also mark rebuilding drives with
IMSM_ORD_REBUILD.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2008-09-15 20:58:41 -07:00
Dan Williams 24565c9a99 imsm: fix imsm_delete()
* fix breakage from last merge (infinite loop in imsm_process_update())
* add ability to delete by index

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2008-09-15 20:58:41 -07:00
Dan Williams b10b37b839 imsm: use IMSM_ORD_REBUILD instead of USABLE flag
IMSM_ORD_REBUILD is the 'insync' flag in MD terms.  USABLE is a flag to
opt-in disks for use with the Windows driver.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2008-09-15 20:58:41 -07:00
Dan Williams be73972fac imsm: introduce set_imsm_ord_tbl_ent()
Collapse all the open coded occurrences.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2008-09-15 20:58:41 -07:00
Dan Williams fb49eef264 imsm: cleanup arguments to imsm_check_degraded
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2008-09-15 20:58:41 -07:00
Dan Williams ff077194a1 imsm: cleanup get_imsm_disk_idx(), unify with get_imsm_ord_tbl_ent()
Save some unnecessary calls to get_imsm_map() by teaching
get_imsm_disk_idx() to retrieve the map.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2008-09-15 20:58:41 -07:00
Dan Williams 3e372e5a72 imsm: fix up compare_super_imsm() to match family_num for populated mpb's
This allows spares to be associated with any family while not allowing
disks from different families to be assembled.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2008-09-15 20:58:40 -07:00
Dan Williams e0783b419d imsm: fix up spare handling holdover in update_create_array
We used to leave SPARE_DISK unset to indicate it was available to be
assimilated into other arrays.  Now we explicitly check the size.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2008-09-15 20:55:40 -07:00
Dan Williams 8796fdc4cd imsm: mark failures like the Matrix driver
* Truncate the first character of the serial number
* Set 'scsi_id' to all f's
* Expect to find disk entries with unmatchable serial numbers, i.e.
  expect get_imsm_disk() to return NULL in some situations
* Allow discrepencies between mpb->num_disks and len(super->disks)

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2008-09-15 20:55:34 -07:00
Dan Williams 4d7b1503a7 imsm: provide for a larger mpb buffer when necessary
Ensure that the mpb buffer is large enough to hold the extra imsm_map's
of migrating arrays and dynamically created raid devices.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2008-09-15 20:55:34 -07:00
Dan Williams fb9bf0d3e7 imsm: fix logic inversion in get_imsm_ord_tbl_ent()
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2008-09-15 20:55:30 -07:00
Dan Williams 6c386dd368 imsm: allow container assembly in the presence of failed disks
For example, this allows one to still say mdadm -A /dev/sd[b-e] even
though /dev/sde has replaced /dev/sdd.  Otherwise mdadm will say:

	mdadm: superblock on /dev/sdd doesn't match others - assembly aborted

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2008-08-19 17:55:15 +10:00
Dan Williams 43dad3d6fb mdadm: add device to a container
Adding a device updates the container and then mdmon takes action upon
noticing a change in devices.  This reuses the container version of
add_to_super to create a new record for the device.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
2008-08-19 17:19:51 +10:00
Dan Williams ae6aad8239 imsm: delete kicked disks
When we have determined that a disk is no longer of any value, remove
it from the data structure.   This is now safe because the manager
will back off while any metadata update is pending in the monitor.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
2008-08-19 14:55:10 +10:00
NeilBrown 01f157d74a Extra option for set_array_state: you choose dirty or clean.
When we first start an array, it might be good to start recovery
straight away.  That requires setting the array to 'dirty', but
only the metadata handler can know if that is required or not.
So have a third possible 'consistent' option to set_array_state.
Either 'no' or 'yes' or 'you choose'.

Return value indicates what was chosen.

'1' (no) should be chosen unless there is a good reason.

Signed-off-by: NeilBrown <neilb@suse.de>
2008-08-19 14:54:55 +10:00
Dan Williams fcb844757f imsm: include not synced disks in imsm_count_failed
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2008-08-15 10:58:42 -07:00
Dan Williams 7eef045331 imsm: use disk_ord_tbl to identify rebuilding disks
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2008-08-15 10:57:19 -07:00
Dan Williams 9a1608e5d0 imsm: fix up assembly of disks that are not in-sync
1/ Do not assemble !in_sync or failed devices in container_content.
2/ Prevent activation of failed or configured devices in activate_spare.
3/ Be sure to avoid dirty degraded if the array was shutdown cleanly.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2008-08-12 02:25:49 -07:00
Dan Williams 6a3e913ee9 imsm: fix create by mdmon-update
imsm_dev dynamically grows, so dev_idx needs to be moved up in the
definition to avoid getting clobbered.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2008-08-12 02:25:49 -07:00
Dan Williams e74255d907 imsm: write_super return 0 on success
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2008-08-12 02:25:49 -07:00
Dan Williams a48ac0a8d6 imsm: update mpb_size in write_super_imsm
With dev->vol.map and mpb->disk entries entering and leaving the parameter
block write_super_imsm needs to update the size before writeback.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2008-08-12 02:25:49 -07:00
Dan Williams 272906ef49 mdmon: use activate spare for re-add
Disks that are not in-sync or failed are not assembled into member
arrays by mdadm.  Teach mdmon to resolve this situation by checking for
spares at start.  imsm_activate_spare() is updated to prefer devices
that can be re-added versus new spares.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2008-08-12 02:25:46 -07:00
Dan Williams 3393c6af8b imsm: fix handling of the 'migr_state' and 'migr_type' bits
The option-rom and the Matrix driver mark resyncs/rebuilds with the
migrate state bits.  Update sizeof_imsm_dev to allow allocation of
imsm_dev entries large enough to grow if migr_state is later set.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2008-08-12 02:05:20 -07:00
Dan Williams a965f303c7 imsm: add get_imsm_map and sizeof_imsm_map
retrieve map entries from a imsm_dev, and cleanup imsm_copy_dev

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2008-08-11 01:16:24 -07:00
Dan Williams 828408ebef imsm: drop 'external' from imsm_examine_brief
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2008-08-11 01:16:24 -07:00
Dan Williams 19859edc2d imsm: ensure 'usable' remains clear until the disk is in_sync
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2008-08-11 01:16:24 -07:00
Dan Williams d23fe9472d imsm: spare devices are represented as single disk containers
This poses a small problem for the case of handling multiple raid1 arrays
across separate disk pairs i.e. 2 mirrors on 4 disks.  The option-ROM will
configure this as two containers.  We may need the capability for one
container to ask for an unused spare in another container.  For now spares
will just maintain the affinity established at assemble time.

To support this configuration spare devices must be allowed to be assembled
into the container even though the metadata indicates the disk belongs to a
different family.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2008-08-09 13:37:54 -07:00
Dan Williams b9f594fea0 imsm: store imsm_disk entries in the super->disks list
removes the need to lookup the disk by index in a few cases and is a
preparation step for tracking spares outside the current anchor.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2008-08-09 13:37:54 -07:00
Jacek Danecki 604b746f7c imsm: bad block management (phase1)
This is the initial defensive implementation of bad block management
support.  It simply precludes assembly if there are entries in the bad
block logs.  This is sufficient for now as the conditions that lead to
an entry in the bad block log would cause the array to be failed by MD
(as of 2.6.27).

[dan.j.williams@intel.com: general cleanups]
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2008-08-06 23:55:53 -07:00
Dan Williams 115c380305 imsm: do not mark arrays 'clean' if resync still in progress
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2008-08-06 23:53:44 -07:00
Dan Williams a380c027e3 imsm: raid5 layout is left-asymmetric
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2008-08-06 23:53:44 -07:00
Dan Williams 9ca2c81c0f imsm: trim some memory wastage
drop the previously loaded data as load_imsm_super_all loops through the
disks.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2008-07-25 17:45:13 -07:00
Dan Williams 949c47a0fa imsm: refactor mpb handling into parse and coalesce
Maintaining a single global buffer is unwieldly when extending/rewriting
sections of the metadata.  Parse the metadata into component data
structures upon reading and coalesce to a coherent buffer before
writing.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2008-07-25 16:59:47 -07:00
Dan Williams f54e6321a2 imsm: use component_size not total array size in container_content_imsm
Also kill setting ->array.size as nothing appears to be using it.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2008-07-24 17:26:24 -07:00