]> git.ipfire.org Git - thirdparty/mdadm.git/log
thirdparty/mdadm.git
10 years agosuper1: simplify setting of array size.
NeilBrown [Tue, 30 Jul 2013 06:51:38 +0000 (16:51 +1000)] 
super1: simplify setting of array size.

Currently the extra space to leave before the data in the array
is calculated in two separate places, and they can be inconsistent.

Instead, do it all in validate_geometry.  This records the
'data_offset' chosen which all other devices then use.

'write_init_super' now just uses the value rather than doing all the
calculations again.

This results in more consistent numbers.

Also, load_super sets st->data_offset so that it is used by "--add",
so the new device has a data offset matching a pre-existing device.

Signed-off-by: NeilBrown <neilb@suse.de>
10 years agosuper1: separate to version of _avail_space1().
NeilBrown [Tue, 30 Jul 2013 05:17:22 +0000 (15:17 +1000)] 
super1: separate to version of _avail_space1().

_avail_space1() is calls from both avail_space1() and validate_geometry1()
and does slightly different things.

The partial code sharing doesn't really help.  In particularly the
responsibility for setting the size of the array is currently
confused.

So duplicate the code into the two locations - one where 'super' is
always NULL (validate_geometry1) and one where it is never NULL
(avail_space1), and simplify.

No behaviour change - just code re-organisation.

Signed-off-by: NeilBrown <neilb@suse.de>
10 years agoManage: remove call to validate_geometry.
NeilBrown [Tue, 30 Jul 2013 03:45:22 +0000 (13:45 +1000)] 
Manage: remove call to validate_geometry.

This call to validate_geometry is really rather gratuitous.
It is purely about the fact that super0 cannot use more than 4TB.
So just make it an explicit test - less confusing that way.

With this, validate_geometry is only called from Create, which
makes it easier to reason about.

Also validate_geometry is now never passed NULL for the 'chunk'
parameter, so we can remove those annoying tests for NULL.

Signed-off-by: NeilBrown <neilb@suse.de>
10 years agoDDF: ddf_activate_spare: fix metadata update for SVDs
mwilck@arcor.de [Thu, 25 Jul 2013 18:59:13 +0000 (20:59 +0200)] 
DDF: ddf_activate_spare: fix metadata update for SVDs

Metadata updates for secondary RAID (RAID10) need to cover
all BVDs. Compare with code in write_init_super_ddf().

Signed-off-by: NeilBrown <neilb@suse.de>
10 years agoDDF: ddf_activate_spare: only activate good drives
mwilck@arcor.de [Thu, 25 Jul 2013 18:59:12 +0000 (20:59 +0200)] 
DDF: ddf_activate_spare: only activate good drives

Do not try to activate drives marked missing or failed.

Signed-off-by: NeilBrown <neilb@suse.de>
10 years agoDDF: ddf_activate_spare: Add RAID10 code
mwilck@arcor.de [Thu, 25 Jul 2013 18:59:11 +0000 (20:59 +0200)] 
DDF: ddf_activate_spare: Add RAID10 code

The check for degraded array is a bit more complex for RAID10.
Fixing it.

Signed-off-by: NeilBrown <neilb@suse.de>
10 years agoDDF: find_vdcr: fix minor bug in debug message
mwilck@arcor.de [Thu, 25 Jul 2013 18:59:10 +0000 (20:59 +0200)] 
DDF: find_vdcr: fix minor bug in debug message

This code could find disk -1. Fixed.

Signed-off-by: NeilBrown <neilb@suse.de>
10 years agoChange version to 3.3-rc2 mdadm-3.3-rc2
NeilBrown [Thu, 25 Jul 2013 07:54:54 +0000 (17:54 +1000)] 
Change version to 3.3-rc2

Signed-off-by: NeilBrown <neilb@suse.de>
10 years agoAdd test for --replace handling.
NeilBrown [Wed, 24 Jul 2013 00:40:26 +0000 (10:40 +1000)] 
Add test for --replace handling.

Signed-off-by: NeilBrown <neilb@suse.de>
10 years agoManage: fix typo in error for "--with" handling
NeilBrown [Wed, 24 Jul 2013 05:32:26 +0000 (15:32 +1000)] 
Manage: fix typo in error for "--with" handling

Signed-off-by: NeilBrown <neilb@suse.de>
10 years agoImprove revert tests
NeilBrown [Wed, 24 Jul 2013 00:40:26 +0000 (10:40 +1000)] 
Improve revert tests

1/ perform revert-grow on more metadata versions
2/ add revert-inplace.

Signed-off-by: NeilBrown <neilb@suse.de>
10 years agosuper0/1: fix typo in error messages.
NeilBrown [Wed, 24 Jul 2013 02:22:58 +0000 (12:22 +1000)] 
super0/1: fix typo in error messages.

Signed-off-by: NeilBrown <neilb@suse.de>
10 years agoGrow: don't hold array open while waiting for reshape.
NeilBrown [Wed, 24 Jul 2013 02:21:10 +0000 (12:21 +1000)] 
Grow: don't hold array open while waiting for reshape.

If we will need to change array level when a reshape completes, a copy
of mdadm waits in the background.
Currently this copy hold the device (/dev/mdX) open.  This prevents
the array from being stopped.

So close the file descriptor and re-open after the reshape completes.

Signed-off-by: NeilBrown <neilb@suse.de>
10 years agosuper1: update data_size when performing "revert-reshape".
NeilBrown [Wed, 24 Jul 2013 00:21:27 +0000 (10:21 +1000)] 
super1: update data_size when performing "revert-reshape".

The "data_size" is with respect to "data_offset".  When the kernel
changes "data_offset" it modifies "data_size" to match - see
md_finish_reshape() in the kernel.

So when mdadm switches the data_offset for the new data_offset, it
must update data_size correspondingly.

Signed-off-by: NeilBrown <neilb@suse.de>
10 years agosuper-ddf: allow mdassemble to compile.
NeilBrown [Tue, 23 Jul 2013 04:00:56 +0000 (14:00 +1000)] 
super-ddf: allow mdassemble to compile.

Just add/move some #ifdefs and move some code.

Signed-off-by: NeilBrown <neilb@suse.de>
10 years agoDDF: convert big-endian __u16 to be16 type
mwilck@arcor.de [Sun, 21 Jul 2013 17:28:22 +0000 (19:28 +0200)] 
DDF: convert big-endian __u16 to be16 type

Last step of endian-safe recoding. This requires also bit
operations.

Signed-off-by: NeilBrown <neilb@suse.de>
10 years agoDDF: convert big-endian __u64 to be64 type
mwilck@arcor.de [Sun, 21 Jul 2013 17:28:21 +0000 (19:28 +0200)] 
DDF: convert big-endian __u64 to be64 type

Signed-off-by: NeilBrown <neilb@suse.de>
10 years agoDDF: convert big endian to be32 type
mwilck@arcor.de [Sun, 21 Jul 2013 17:28:20 +0000 (19:28 +0200)] 
DDF: convert big endian to be32 type

Part 2 of endianness-safe conversion

Signed-off-by: NeilBrown <neilb@suse.de>
10 years agoDDF: add endian-safe typedefs
mwilck@arcor.de [Sun, 21 Jul 2013 17:28:19 +0000 (19:28 +0200)] 
DDF: add endian-safe typedefs

This adds typedefs for big-endian numbers. This will hopefully
reduce the number of endianness bugs I make.

Signed-off-by: NeilBrown <neilb@suse.de>
10 years agotests/10ddf-geometry: new unit test
mwilck@arcor.de [Fri, 19 Jul 2013 19:04:15 +0000 (21:04 +0200)] 
tests/10ddf-geometry: new unit test

Test various RAID geometries, creation and deletion of subarrays

Signed-off-by: NeilBrown <neilb@suse.de>
10 years agotest: increase number of devices to 13
mwilck@arcor.de [Fri, 19 Jul 2013 19:04:14 +0000 (21:04 +0200)] 
test: increase number of devices to 13

extended DDF/RAID10 tests need 6 disks for DDF.

Signed-off-by: NeilBrown <neilb@suse.de>
10 years agotests/10ddf-create: create RAID5 first
mwilck@arcor.de [Fri, 19 Jul 2013 19:04:13 +0000 (21:04 +0200)] 
tests/10ddf-create: create RAID5 first

Let the first created array be RAID5 rather than RAID0. This makes
the test harder than before, because everything after the first
Create has do be done indirectly through mdmon.

Signed-off-by: NeilBrown <neilb@suse.de>
10 years agoDDF: getinfo_super_ddf_bvd: fix offset calculation for SVDs
mwilck@arcor.de [Fri, 19 Jul 2013 19:04:12 +0000 (21:04 +0200)] 
DDF: getinfo_super_ddf_bvd: fix offset calculation for SVDs

Fix a bug that caused the wrong conf record to be used to derive
data offset and size on secondary RAID (RAID10).

Signed-off-by: NeilBrown <neilb@suse.de>
10 years agoDDF: kill_subarray_ddf: fix case without mdmon running
mwilck@arcor.de [Fri, 19 Jul 2013 19:04:11 +0000 (21:04 +0200)] 
DDF: kill_subarray_ddf: fix case without mdmon running

When mdmon wasn't runnning, meta data wasn't committed to disk.
Fixed.

Signed-off-by: NeilBrown <neilb@suse.de>
10 years agoDDF: err_bad_md_layout: fix return value
mwilck@arcor.de [Fri, 19 Jul 2013 19:04:10 +0000 (21:04 +0200)] 
DDF: err_bad_md_layout: fix return value

This function must use -1 to indicate failure. Fix it.

Signed-off-by: NeilBrown <neilb@suse.de>
10 years agoDDF: factor out writing super block to single disk
mwilck@arcor.de [Thu, 18 Jul 2013 18:49:01 +0000 (20:49 +0200)] 
DDF: factor out writing super block to single disk

Factor out single disk from __write_init_super_ddf to a new function
_write_super_to_disk. Use this function in store_super_ddf.

Signed-off-by: NeilBrown <neilb@suse.de>
10 years agoDDF: make "null_aligned" a static buffer
mwilck@arcor.de [Thu, 18 Jul 2013 18:49:00 +0000 (20:49 +0200)] 
DDF: make "null_aligned" a static buffer

Use a static buffer for this "zero page". This makes it easier
to factor out the header writing code.

Signed-off-by: NeilBrown <neilb@suse.de>
10 years agoDDF: increase seq number in ddf_set_updates_pending
mwilck@arcor.de [Thu, 18 Jul 2013 18:48:59 +0000 (20:48 +0200)] 
DDF: increase seq number in ddf_set_updates_pending

Increase seq number only when there's actually a metadata change.
This is better then increasing it at every write.

This also fixes another endianness bug.

Signed-off-by: NeilBrown <neilb@suse.de>
10 years agoMerge commit '956a13fb850321bed8568dfa8692c0c323538d7c'
NeilBrown [Mon, 15 Jul 2013 01:39:50 +0000 (11:39 +1000)] 
Merge commit '956a13fb850321bed8568dfa8692c0c323538d7c'

10 years agotest: allow resync/reshape etc to go faster.
NeilBrown [Thu, 11 Jul 2013 03:16:40 +0000 (13:16 +1000)] 
test: allow resync/reshape etc to go faster.

Whenever we "check wait" - make the resync process go at full speed.

Also allow script to adjust it manually.

Signed-off-by: NeilBrown <neilb@suse.de>
10 years agoGrow: pass INVALID_SECTORS to reshape_array, not 0.
NeilBrown [Thu, 11 Jul 2013 02:42:12 +0000 (12:42 +1000)] 
Grow: pass INVALID_SECTORS to reshape_array, not 0.

'0' means 'make it 0', which isn't what we want here.
We want 'leave it unchanged'.

Signed-off-by: NeilBrown <neilb@suse.de>
10 years agoIMSM: fix wait_for_reshape_imsm
NeilBrown [Wed, 10 Jul 2013 23:48:25 +0000 (09:48 +1000)] 
IMSM: fix wait_for_reshape_imsm

This was waiting on "reshape_position" which doesn't
get update events.
Before sysfs_wait was introduced, the code to wait didn't
wait at all, so it spun.
With sysfs_wait, it would wait forever.

Change to wait in sync_completed which does get events.

Signed-off-by: NeilBrown <neilb@suse.de>
10 years agoalign spelling of “RAID” and RAID levels
Christoph Anton Mitterer [Wed, 10 Jul 2013 20:42:46 +0000 (22:42 +0200)] 
align spelling of “RAID” and RAID levels

* Aligned the spelling of “RAID” to use captial letters in all places.
* Aligned the spelling of the RAID level names (LINEAR, RAID1, …) to use capital
  letters in all places, except for the string “faulty” in places where not the
  RAID level was meant.

Signed-off-by: Christoph Anton Mitterer <mail@christoph.anton.mitterer.name>
10 years agoStop: fix up synchronising end of reshape to good boundary.
NeilBrown [Tue, 9 Jul 2013 01:46:54 +0000 (11:46 +1000)] 
Stop: fix up synchronising end of reshape to good boundary.

If we stop too soon after reshape starts (probably only during
testing), we can get confused by the status of the reshape.
If that might be happening - sleep a bit longer.

Also allow for reshape going unusually slowly (again, probably only
during testing).

Signed-off-by: NeilBrown <neilb@suse.de>
10 years agoGrow: use mdstat_wait to wait for delayed reshape.
NeilBrown [Wed, 10 Jul 2013 01:10:54 +0000 (11:10 +1000)] 
Grow: use mdstat_wait to wait for delayed reshape.

Having a fix time for a wait is clumsy and can make us
wait much too long.
So use mdstat_wait and keep the mdstat_fd open.
This requires an 'mdstat_close' so it doesn't stay open
forever.

Signed-off-by: NeilBrown <neilb@suse.de>
10 years agoDon't set 'hold' option for mdstat_read if not needed.
NeilBrown [Wed, 10 Jul 2013 01:02:10 +0000 (11:02 +1000)] 
Don't set 'hold' option for mdstat_read if not needed.

We only need 'hold' if we want to mdstat_wait for a change.
These two callers don't care about a change, so they shouldn't
use the 'hold' flag.

Signed-off-by: NeilBrown <neilb@suse.de>
10 years agoDDF load headers: if primary is invalid, don't check fields.
NeilBrown [Wed, 10 Jul 2013 00:47:22 +0000 (10:47 +1000)] 
DDF load headers: if primary is invalid, don't check fields.

Currently we compare fields between primary and secondary
superblocks, before we check if the primary is even valid.
This is a bit backwards, so reverse it.

Signed-off-by: NeilBrown <neilb@suse.de>
10 years agoDDF: ddf_process_update: Fix updates for SVDs
mwilck@arcor.de [Mon, 8 Jul 2013 21:50:48 +0000 (23:50 +0200)] 
DDF: ddf_process_update: Fix updates for SVDs

The "indirect" code path for adding VDs was not working correctly
for secondary RAID level. The "other BVDs" were not transmitted
to mdmon. Thus mdmon wouldn't build up correct information, and
RAID creation would fail when mdmon was already running on the container.

This patch fixes this.

Signed-off-by: NeilBrown <neilb@suse.de>
10 years agoDDF: ddf_process_update: some more debug messages
mwilck@arcor.de [Mon, 8 Jul 2013 21:50:47 +0000 (23:50 +0200)] 
DDF: ddf_process_update: some more debug messages

Signed-off-by: NeilBrown <neilb@suse.de>
10 years agoDDF: guid_str: more readable output
mwilck@arcor.de [Mon, 8 Jul 2013 21:50:46 +0000 (23:50 +0200)] 
DDF: guid_str: more readable output

Print ASCII characters as ASCII

Signed-off-by: NeilBrown <neilb@suse.de>
10 years agoDDF: ddf_process_update: add debug messages fore adding VDs
mwilck@arcor.de [Mon, 8 Jul 2013 21:50:45 +0000 (23:50 +0200)] 
DDF: ddf_process_update: add debug messages fore adding VDs

Add some debug messages for the DDF_VIRTR_RECORDS_MAGIC case.

Signed-off-by: NeilBrown <neilb@suse.de>
10 years agoDDF: add debug message in add_super_ddf_bvd
mwilck@arcor.de [Mon, 8 Jul 2013 21:50:44 +0000 (23:50 +0200)] 
DDF: add debug message in add_super_ddf_bvd

Signed-off-by: NeilBrown <neilb@suse.de>
10 years agoDDF: fix endianness of refnum in debug messages
mwilck@arcor.de [Mon, 8 Jul 2013 21:50:43 +0000 (23:50 +0200)] 
DDF: fix endianness of refnum in debug messages

This makes it easier to match the debug output to existing
structures.

Signed-off-by: NeilBrown <neilb@suse.de>
10 years agoDDF: getinfo_super_ddf_bvd: fix raid_disk calculation
mwilck@arcor.de [Mon, 8 Jul 2013 21:50:42 +0000 (23:50 +0200)] 
DDF: getinfo_super_ddf_bvd: fix raid_disk calculation

The return value of disk.raid_disk may be wrong.
The old code was using raiddisk, which is only valid with auto
layout. This leads to errors when arrays are created with
specified disks and mdmon is already running, like this:

mdadm -CR /dev/md/container -n5 $d1 $d2 $d3 $d4 $d5
mdadm -CR /dev/md/r5 -n5 -l5 /dev/md/container -z 5000
mdadm -CR /dev/md/r1 -n2 -l1 $d1 $d2
  => resulting array will use wrong disks

This patch fixes that.

Signed-off-by: NeilBrown <neilb@suse.de>
10 years agoDDF: getinfo_super_ddf_bvd: identify disk by refnum
mwilck@arcor.de [Mon, 8 Jul 2013 21:50:41 +0000 (23:50 +0200)] 
DDF: getinfo_super_ddf_bvd: identify disk by refnum

Use refnum rather than raiddisk for identifying the physical disk.
raiddisk should only be used for auto-layout.

Signed-off-by: NeilBrown <neilb@suse.de>
10 years agoDDF: implement kill_subarray
mwilck@arcor.de [Mon, 8 Jul 2013 21:50:40 +0000 (23:50 +0200)] 
DDF: implement kill_subarray

Implement kill_subarray, for mdmon running and not running.

The way Kill_subarray() is implemented, this requires that the
DDF layer uses "currentconf" to remember the last subarray
queried with container_content(), and use it as the one to kill.
I don't like this much but IMSM does it the same way.

Signed-off-by: NeilBrown <neilb@suse.de>
10 years agoDDF: write_init_super_ddf: don't zero superblocks for subarrays
mwilck@arcor.de [Mon, 8 Jul 2013 21:50:39 +0000 (23:50 +0200)] 
DDF: write_init_super_ddf: don't zero superblocks for subarrays

commit d682f344 inserted this call to "Kill" in write_init_super_ddf:

    "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."

But we should do this only at first container creation, not when
subarrays are created later.

Signed-off-by: NeilBrown <neilb@suse.de>
10 years agoMonitor: Don't write metadata in inactive array state
mwilck@arcor.de [Mon, 8 Jul 2013 21:50:38 +0000 (23:50 +0200)] 
Monitor: Don't write metadata in inactive array state

The kernel docs state that meta data is never written in states
clear, inactive, suspended, readonly, and read_auto.
Why should this be different for containers?

We need to write metadata when the array is disabled, though.
Tested with the DDF (10*) and IMSM (9*) tests, works.

Signed-off-by: NeilBrown <neilb@suse.de>
10 years agotest/10-ddf-create: fix comments
mwilck@arcor.de [Mon, 8 Jul 2013 21:50:37 +0000 (23:50 +0200)] 
test/10-ddf-create: fix comments

Comments should reflect the changes in the script.

Signed-off-by: NeilBrown <neilb@suse.de>
10 years agotests/10ddf-create: add RAID 10 array
mwilck@arcor.de [Wed, 3 Jul 2013 20:28:07 +0000 (22:28 +0200)] 
tests/10ddf-create: add RAID 10 array

This patch adds RAID10 support to the DDF test script.
It actually passes!

Signed-off-by: Martin Wilck <mwilck@arcor.de>
Signed-off-by: NeilBrown <neilb@suse.de>
10 years agoDDF: ddf_process_update: Fix vlist treatment for SVDs
mwilck@arcor.de [Wed, 3 Jul 2013 20:28:06 +0000 (22:28 +0200)] 
DDF: ddf_process_update: Fix vlist treatment for SVDs

With secondary RAID level, disks may belong to other BVDs in
a given conf record. This needs to be taken into account
when fixing the vlist.

Signed-off-by: Martin Wilck <mwilck@arcor.de>
Signed-off-by: NeilBrown <neilb@suse.de>
10 years agoDDF: ddf_process_update: handle update of conf records for SVD
mwilck@arcor.de [Wed, 3 Jul 2013 20:28:05 +0000 (22:28 +0200)] 
DDF: ddf_process_update: handle update of conf records for SVD

For secondary RAID, we need to check which BVD needs to be updated.

Signed-off-by: Martin Wilck <mwilck@arcor.de>
Signed-off-by: NeilBrown <neilb@suse.de>
10 years agoDDF: ddf_set_array_state: more meaningful output
mwilck@arcor.de [Wed, 3 Jul 2013 20:28:04 +0000 (22:28 +0200)] 
DDF: ddf_set_array_state: more meaningful output

Print the array GUID and the array state.

Signed-off-by: Martin Wilck <mwilck@arcor.de>
Signed-off-by: NeilBrown <neilb@suse.de>
10 years agoDDF: guid_str: convenience function to print GUID for debugging
mwilck@arcor.de [Wed, 3 Jul 2013 20:28:03 +0000 (22:28 +0200)] 
DDF: guid_str: convenience function to print GUID for debugging

For debugging DDF structure changes, it is important to be able
to identify VCs by their GUIDs.

Signed-off-by: Martin Wilck <mwilck@arcor.de>
Signed-off-by: NeilBrown <neilb@suse.de>
10 years agoDDF: getinfo_super_ddf_bvd: lba_offset calculation for RAID10
mwilck@arcor.de [Wed, 3 Jul 2013 20:28:02 +0000 (22:28 +0200)] 
DDF: getinfo_super_ddf_bvd: lba_offset calculation for RAID10

Secondary RAID needs some extra logic here, too.

Signed-off-by: Martin Wilck <mwilck@arcor.de>
Signed-off-by: NeilBrown <neilb@suse.de>
10 years agoDDF: add_to_super_ddf_bvd: use get_svd_state()
mwilck@arcor.de [Wed, 3 Jul 2013 20:28:01 +0000 (22:28 +0200)] 
DDF: add_to_super_ddf_bvd: use get_svd_state()

Reuse get_svd_state() rather than own state algorithm.

Signed-off-by: Martin Wilck <mwilck@arcor.de>
Signed-off-by: NeilBrown <neilb@suse.de>
10 years agoDDF: add_to_super_ddf: RAID10 changes
mwilck@arcor.de [Wed, 3 Jul 2013 20:28:00 +0000 (22:28 +0200)] 
DDF: add_to_super_ddf: RAID10 changes

The index in the BVD may be different in the RAID10 case.

Signed-off-by: Martin Wilck <mwilck@arcor.de>
Signed-off-by: NeilBrown <neilb@suse.de>
10 years agoDDF: add_to_super_ddf: Use same amount of workspace as other disks
mwilck@arcor.de [Wed, 3 Jul 2013 20:27:59 +0000 (22:27 +0200)] 
DDF: add_to_super_ddf: Use same amount of workspace as other disks

If there are already disks in the container, reserve the same amount
of workspace as the first disk. Fill in the primary/secondary/
workspace LBA values.

Signed-off-by: Martin Wilck <mwilck@arcor.de>
Signed-off-by: NeilBrown <neilb@suse.de>
10 years agoDDF: add_to_super_ddf: allow empty slots in phys disk table
mwilck@arcor.de [Wed, 3 Jul 2013 20:27:58 +0000 (22:27 +0200)] 
DDF: add_to_super_ddf: allow empty slots in phys disk table

The used slots in the phys disk table aren't necessarily the
first ones. Rather, unused entries are represented by entries
where the GUID is all 0xff.

Signed-off-by: Martin Wilck <mwilck@arcor.de>
Signed-off-by: NeilBrown <neilb@suse.de>
10 years agoDDF: get_extents: support secondary RAID level
mwilck@arcor.de [Wed, 3 Jul 2013 20:27:57 +0000 (22:27 +0200)] 
DDF: get_extents: support secondary RAID level

Use get_pd_index_from_refnum() in get_extents to determine
matching VD. This will ensure RAID 10 (secondary RAID level)
support, too.

This also fixes a bug in the previous get_extents() code (missing
__be16_to_cpu for conf.prim_elmnt_count).

DDF test case (10ddf-create) verified.

Signed-off-by: Martin Wilck <mwilck@arcor.de>
Signed-off-by: NeilBrown <neilb@suse.de>
10 years agoDDF: use LBA_OFFSET macro instead of lba_offset field
mwilck@arcor.de [Wed, 3 Jul 2013 20:27:56 +0000 (22:27 +0200)] 
DDF: use LBA_OFFSET macro instead of lba_offset field

Remove the lba_offset field from struct vcl. This field acted as
a "cache" for the address of the lba_offset field in the vd_config
structure. This isn't useful any more if there are multiple
vd_configs in a vcl.

This patch also adds __cpu_to_be64 in two places where it has been
quite obviously forgotten (ddf_set_disk, ddf_activate_spare).

Signed-off-by: Martin Wilck <mwilck@arcor.de>
Signed-off-by: NeilBrown <neilb@suse.de>
10 years agoDDF: validate_geometry_ddf: support RAID10
mwilck@arcor.de [Wed, 3 Jul 2013 20:27:55 +0000 (22:27 +0200)] 
DDF: validate_geometry_ddf: support RAID10

Make validate_geometry_ddf() use the same logic to check supported
RAID levels that init_super_ddf_bvd() uses.

Signed-off-by: Martin Wilck <mwilck@arcor.de>
Signed-off-by: NeilBrown <neilb@suse.de>
10 years agoDDF: init_super_ddf_bvd: initialize other bvds
mwilck@arcor.de [Wed, 3 Jul 2013 20:27:54 +0000 (22:27 +0200)] 
DDF: init_super_ddf_bvd: initialize other bvds

Properly initialize the data structures of the other BVDs
in Create().

Signed-off-by: Martin Wilck <mwilck@arcor.de>
Signed-off-by: NeilBrown <neilb@suse.de>
10 years agoDDF: Simplify allocation of "other BVDs"
mwilck@arcor.de [Wed, 3 Jul 2013 20:27:53 +0000 (22:27 +0200)] 
DDF: Simplify allocation of "other BVDs"

Instead of allocating the other_bvds array and every element
separately, allocate all in a single chunk. Also, move allocation
in a subroutine as it's used in several places.

Signed-off-by: Martin Wilck <mwilck@arcor.de>
Signed-off-by: NeilBrown <neilb@suse.de>
10 years agoDDF: layout_md2ddf: new md->DDF layout conversion
mwilck@arcor.de [Wed, 3 Jul 2013 20:27:52 +0000 (22:27 +0200)] 
DDF: layout_md2ddf: new md->DDF layout conversion

Support for RAID 10 makes it necessary to rewrite the algorithm
for deriving DDF layout from MD layout. The functions level_to_prl
and layout_to_rlq are combined in a single function that takes
md layout parameters and converts them to DDF.

Signed-off-by: Martin Wilck <mwilck@arcor.de>
Signed-off-by: NeilBrown <neilb@suse.de>
10 years agoDDF: layout_ddf2md: new DDF->md RAID layout conversion
mwilck@arcor.de [Wed, 3 Jul 2013 20:27:51 +0000 (22:27 +0200)] 
DDF: layout_ddf2md: new DDF->md RAID layout conversion

layout_ddf2md() is a new RAID layout conversion routine.
It obsoletes the previous separate routines for obtaining
md level and layout (map_num1, rlq_to_layout).

Signed-off-by: Martin Wilck <mwilck@arcor.de>
Signed-off-by: NeilBrown <neilb@suse.de>
10 years agoDDF: allow empty slots in virt disk table
mwilck@arcor.de [Wed, 3 Jul 2013 20:27:50 +0000 (22:27 +0200)] 
DDF: allow empty slots in virt disk table

The DDF code was assuming that the VD slots 0..populated_vdes
were used and the rest was unused. Remove this assumption and
deal with empty slots instead.

Signed-off-by: Martin Wilck <mwilck@arcor.de>
Signed-off-by: NeilBrown <neilb@suse.de>
10 years agoDDF: get_svd_state: Status logic for secondary RAID level
mwilck@arcor.de [Wed, 3 Jul 2013 20:27:49 +0000 (22:27 +0200)] 
DDF: get_svd_state: Status logic for secondary RAID level

Implement logic to derive the status of a secondary RAID
from its members. Use it in ddf_set_disk.

Signed-off-by: Martin Wilck <mwilck@arcor.de>
Signed-off-by: NeilBrown <neilb@suse.de>
10 years agoDDF: ddf_set_disk: move status logic to separate function
mwilck@arcor.de [Wed, 3 Jul 2013 20:27:48 +0000 (22:27 +0200)] 
DDF: ddf_set_disk: move status logic to separate function

Moved code to determine RAID status to a separate function
get_bvd_status(). I need this to account for secondary RAID level.

Signed-off-by: Martin Wilck <mwilck@arcor.de>
Signed-off-by: NeilBrown <neilb@suse.de>
10 years agoDDF: find_vdcr: account for secondary RAID level
mwilck@arcor.de [Wed, 3 Jul 2013 20:27:47 +0000 (22:27 +0200)] 
DDF: find_vdcr: account for secondary RAID level

If secondary RAID level is taken into account, translation between
the md RAID member (raid_disk) and the index of a physical disk
in a BVD becomes more complex.

Also, take into account that the member list can have unused entries
(this is independent of secondary RAID level).

Adapt usage of find_vdcr() accordingly

Signed-off-by: Martin Wilck <mwilck@arcor.de>
Signed-off-by: NeilBrown <neilb@suse.de>
10 years agoDDF: ddf_open_new: implement minimal consistency check
mwilck@arcor.de [Wed, 3 Jul 2013 20:27:46 +0000 (22:27 +0200)] 
DDF: ddf_open_new: implement minimal consistency check

Added a minimal consitency check as in imsm_open_new().

Signed-off-by: Martin Wilck <mwilck@arcor.de>
Signed-off-by: NeilBrown <neilb@suse.de>
10 years agoDDF: Implement store_super_ddf
mwilck@arcor.de [Wed, 3 Jul 2013 20:27:45 +0000 (22:27 +0200)] 
DDF: Implement store_super_ddf

This patch implements the previously unsupported case where
store_super_ddf is called with a non-empty superblock.

For DDF, writing meta data to just one disk makes no sense.
We would run the risk of writing inconsistent meta data
to the devices. So just call __write_init_super_ddf and
write to all devices, including the one passed by the caller.

This patch assumes that the device to store the superblock on
has already been added to the DDF structure. Otherwise, an
error message will be emitted.

Signed-off-by: Martin Wilck <mwilck@arcor.de>
Signed-off-by: NeilBrown <neilb@suse.de>
10 years agoDDF: handle "open flag" according to spec
mwilck@arcor.de [Wed, 3 Jul 2013 20:27:44 +0000 (22:27 +0200)] 
DDF: handle "open flag" according to spec

The DDF spec mandates that the "open flag" be set to non-0 before
writing a configuration, and reset to 0 when finished to indicate
success.

Signed-off-by: Martin Wilck <mwilck@arcor.de>
Signed-off-by: NeilBrown <neilb@suse.de>
10 years agoDDF: load_ddf_headers: use secondary header as fallback
mwilck@arcor.de [Wed, 3 Jul 2013 20:27:43 +0000 (22:27 +0200)] 
DDF: load_ddf_headers: use secondary header as fallback

When the primary header can't be read, use the secondary header
as fallback.

Signed-off-by: Martin Wilck <mwilck@arcor.de>
Signed-off-by: NeilBrown <neilb@suse.de>
10 years agoDDF: check_secondary: fix treatment of missing BVDs
mwilck@arcor.de [Wed, 3 Jul 2013 20:27:42 +0000 (22:27 +0200)] 
DDF: check_secondary: fix treatment of missing BVDs

Unused BVDs should just be skipped instead of bailing out.

Signed-off-by: Martin Wilck <mwilck@arcor.de>
Signed-off-by: NeilBrown <neilb@suse.de>
10 years agoDDF (cleanup): use a common macro for failed searches
mwilck@arcor.de [Wed, 3 Jul 2013 20:27:41 +0000 (22:27 +0200)] 
DDF (cleanup): use a common macro for failed searches

Use DDF_NOTFOUND instead of NO_SUCH_REFNUM.

Signed-off-by: Martin Wilck <mwilck@arcor.de>
Signed-off-by: NeilBrown <neilb@suse.de>
10 years agomdadm.8: growing RAID10 chunk size is possible
Christoph Anton Mitterer [Fri, 5 Jul 2013 02:14:44 +0000 (04:14 +0200)] 
mdadm.8: growing RAID10 chunk size is possible

Signed-off-by: NeilBrown <neilb@suse.de>
10 years agoAssemble: avoid a consistency check when --force is given.
NeilBrown [Mon, 8 Jul 2013 02:02:23 +0000 (12:02 +1000)] 
Assemble: avoid a consistency check when --force is given.

mdadm will normally not include a device into an array if that device
reports that the "best" device has failed, as this normally implies
some sort of inconsistency.
However when --force is given it means that the given drives really
should be assembled if at all possible so in that case the test should
be avoided.

The particular case where this was a problem was a RAID5 were all
devices had the same event count but three of them reported that the
first two had failed.
As they all had the same event count the first was taken as the 'best'
and that caused the later ones to be excluded.  Listing one of the
later ones first allowed the array to be assembled.  So in this case
the test clearly just got in the way and did nothing useful.

Reported-by: "Marek Jaros" <mjaros1@nbox.cz>
Signed-off-by: NeilBrown <neilb@suse.de>
10 years agotests: add test to revert shrinking reshapes.
NeilBrown [Thu, 4 Jul 2013 07:16:58 +0000 (17:16 +1000)] 
tests: add test to revert shrinking reshapes.

Signed-off-by: NeilBrown <neilb@suse.de>
10 years agoGrow: notice when --stop is synchronising a reshape and don't mess it up.
NeilBrown [Thu, 4 Jul 2013 07:16:20 +0000 (17:16 +1000)] 
Grow: notice when --stop is synchronising a reshape and don't mess it up.

--stop now tries to wait for a reshape to be at just the right spot.
However for a reducing reshape, mdadm will be running in the
background watching, and might adjust sync_max and mess things up.

So teach "progress_reshape" to notice when "sync_max" is modified, and
leave it alone.

Signed-off-by: NeilBrown <neilb@suse.de>
10 years agoGrow: fix small bug when reshape interrupted.
NeilBrown [Wed, 3 Jul 2013 01:39:28 +0000 (11:39 +1000)] 
Grow: fix small bug when reshape interrupted.

progress_reshape() may not set reshape_completed if the reshape is
interrupted, so we need to initialize it to the current value before
hand, so the value used afterwards is credible.

Signed-off-by: NeilBrown <neilb@suse.de>
10 years agotests: add a test for reverting reshapes
NeilBrown [Tue, 2 Jul 2013 06:19:52 +0000 (16:19 +1000)] 
tests: add a test for reverting reshapes

Only reverting reshapes that grow the array so far.

Signed-off-by: NeilBrown <neilb@suse.de>
10 years agoStop: improve synchronising of reshape with whole stripes.
NeilBrown [Tue, 2 Jul 2013 06:18:21 +0000 (16:18 +1000)] 
Stop: improve synchronising of reshape with whole stripes.

It is possible for 'sync_completed' to be further ahead than
we deduced from 'reshape_position'.  However we cannot read it while
the array is frozen, so it is hard to know.

Once that array is unfrozen, check and if sync_completed is ahead of
'sync_max',  push 'sync_max' well ahead if 'sync_completed' so it
will all synchronise up properly.

Signed-off-by: NeilBrown <neilb@suse.de>
10 years agorevert-reshape: only impose reshape_position tests on raid[456]
NeilBrown [Tue, 2 Jul 2013 06:10:27 +0000 (16:10 +1000)] 
revert-reshape: only impose reshape_position tests on raid[456]

This test is irrelevant for RAID10, so restrict it to those
levels in which it is meaningful.

Signed-off-by: NeilBrown <neilb@suse.de>
10 years agosysfs: fix bugs in new sysfs_wait function.
NeilBrown [Tue, 2 Jul 2013 06:08:34 +0000 (16:08 +1000)] 
sysfs: fix bugs in new sysfs_wait function.

- 'tv' isn't initialised properly.
- 100?  I'm sure I fixed that already! Seems not.

Signed-off-by: NeilBrown <neilb@suse.de>
10 years agoraid6check - fix compile
NeilBrown [Tue, 2 Jul 2013 06:06:55 +0000 (16:06 +1000)] 
raid6check - fix compile

Recent rearrangement of library code broke 'raid6check' and this
wasn't noticed because 'make everything' doesn't build it.

So fix the breakage and have 'make everything' built it.

Signed-off-by: NeilBrown <neilb@suse.de>
10 years agotest: include any 'stderr' output in the log file.
NeilBrown [Tue, 2 Jul 2013 03:12:07 +0000 (13:12 +1000)] 
test: include any 'stderr' output in the log file.

Errors from mdadm go to 'stderr', so if there is an array,
copy those to the log file.

Signed-off-by: NeilBrown <neilb@suse.de>
10 years agoAssemble: improve messages when restarting a reshape.
NeilBrown [Tue, 2 Jul 2013 03:09:07 +0000 (13:09 +1000)] 
Assemble: improve messages when restarting a reshape.

If the restarted reshape needs a backup file and we don't have one,
that should be reported before we try to start the array.
Also we shouldn't say the "Cannot grow" but "cannot complete".

Signed-off-by: NeilBrown <neilb@suse.de>
10 years agoAssemble: ignore devices= if container= is present.
NeilBrown [Tue, 2 Jul 2013 01:07:38 +0000 (11:07 +1000)] 
Assemble: ignore devices= if container= is present.

If "container=" is present, then we are going to assemble from the
given container where that container is made of those devices or not.
So in this case the "devices=" is purely documentation and is best
ignored.

As part of this, move the test on the "container=" value when that
start with "/" up before the device is opened.  There sooner we test
things, the better.

Reported-by: Martin Wilck <mwilck@arcor.de>
Signed-off-by: NeilBrown <neilb@suse.de>
10 years agoConfig: use better device names for "DEVICES container"
NeilBrown [Tue, 2 Jul 2013 00:46:43 +0000 (10:46 +1000)] 
Config: use better device names for "DEVICES container"

When "containers" appears on the "DEVICES" line (which is does by
default), use names from the mdadm map file instead of kernel names,
when possible.
This mean that the name will be more likely to appear in mdadm.conf
and so more likely to match "container=" tags.

Signed-off-by: NeilBrown <neilb@suse.de>
10 years agoAssemble: write raid-disks should be less fatal.
NeilBrown [Tue, 2 Jul 2013 00:31:31 +0000 (10:31 +1000)] 
Assemble: write raid-disks should be less fatal.

If the container metadata doesn't know how many device to expect (as
is the case with IMSM), don't fail an --assemble which over-specifies
the number of devices.

Signed-off-by: NeilBrown <neilb@suse.de>
10 years agoMove find_free_devnum to mdopen.c
NeilBrown [Tue, 2 Jul 2013 00:24:50 +0000 (10:24 +1000)] 
Move find_free_devnum to mdopen.c

There is only one called to find_free_devnum and it is in mdopen.c

The removes a dependency between util.c and config.c which allows
us to now drop config.o from mdmon.

Signed-off-by: NeilBrown <neilb@suse.de>
10 years agoMove conf_line and free_line from conf.c to lib.c
NeilBrown [Tue, 2 Jul 2013 00:17:51 +0000 (10:17 +1000)] 
Move conf_line and free_line from conf.c to lib.c

As they are uses for mdstat as well as mdadm.conf, they don't really
belong in conf.c

This removes a dependency between mdmon and conf.c

Signed-off-by: NeilBrown <neilb@suse.de>
10 years agoDetail: Factor out add_device()
Martin Wilck [Thu, 27 Jun 2013 19:39:27 +0000 (21:39 +0200)] 
Detail: Factor out add_device()

Makes the code a little more readable.

Signed-off-by: Martin Wilck <mwilck@arcor.de>
Signed-off-by: NeilBrown <neilb@suse.de>
10 years agomdadm.8.in: Fix typo: previous -> previously
NeilBrown [Mon, 1 Jul 2013 22:30:28 +0000 (08:30 +1000)] 
mdadm.8.in: Fix typo: previous -> previously

Signed-off-by: Wieland Hoffmann <themineo@gmail.com>
Signed-off-by: NeilBrown <neilb@suse.de>
10 years agoManage: check alignment when stopping an array undergoing reshape.
NeilBrown [Mon, 1 Jul 2013 05:10:05 +0000 (15:10 +1000)] 
Manage: check alignment when stopping an array undergoing reshape.

To be able to revert-reshape of raid4/5/6 which is changing
the number of devices, the reshape must has been stopped on a multiple
of the old and new stripe sizes.

The kernel only enforces the new stripe size multiple.

So we enforce the old-stripe-size multiple by careful use of
"sync_max" and monitoring "reshape_position".

Signed-off-by: NeilBrown <neilb@suse.de>
10 years agoNew function: sysfs_wait
NeilBrown [Mon, 1 Jul 2013 03:28:13 +0000 (13:28 +1000)] 
New function: sysfs_wait

We have several places that wait for activity on a sysfs
file.  Combine most of these into a single 'sysfs_wait' function.

Signed-off-by: NeilBrown <neilb@suse.de>
10 years agorevert-reshape: make sure reshape_position is acceptable.
NeilBrown [Thu, 27 Jun 2013 06:38:53 +0000 (16:38 +1000)] 
revert-reshape: make sure reshape_position is acceptable.

We can only revert a reshape if the reshape_position aligns
properly for the old geometry.
If it doesn't we just fail for now.

Also fix a +/- error with updating raid_disks for super1.c

Signed-off-by: NeilBrown <neilb@suse.de>
10 years agotests/raid6repair: default data offset has changed.
NeilBrown [Thu, 27 Jun 2013 04:29:18 +0000 (14:29 +1000)] 
tests/raid6repair: default data offset has changed.

So the test scripts must change too.

Signed-off-by: NeilBrown <neilb2suse.de>
10 years ago"make test" should build "raid6check"
NeilBrown [Thu, 27 Jun 2013 04:09:48 +0000 (14:09 +1000)] 
"make test" should build "raid6check"

As there are selftests for raid6check.

Signed-off-by: NeilBrown <neilb@suse.de>