Commit Graph

245 Commits

Author SHA1 Message Date
NeilBrown 4441541f1f super-ddf: allow mdassemble to compile.
Just add/move some #ifdefs and move some code.

Signed-off-by: NeilBrown <neilb@suse.de>
2013-07-23 14:00:56 +10:00
mwilck@arcor.de a8173e4349 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>
2013-07-23 13:53:34 +10:00
mwilck@arcor.de 9d0c6b7071 DDF: convert big-endian __u64 to be64 type
Signed-off-by: NeilBrown <neilb@suse.de>
2013-07-23 13:53:32 +10:00
mwilck@arcor.de 60931cf94a DDF: convert big endian to be32 type
Part 2 of endianness-safe conversion

Signed-off-by: NeilBrown <neilb@suse.de>
2013-07-23 13:49:41 +10:00
mwilck@arcor.de 4d1bdc1840 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>
2013-07-23 13:49:11 +10:00
mwilck@arcor.de fbf0c2a7ac 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>
2013-07-22 16:56:32 +10:00
mwilck@arcor.de 6a350d82b9 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>
2013-07-22 16:56:32 +10:00
mwilck@arcor.de 2aba583f28 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>
2013-07-22 16:56:32 +10:00
mwilck@arcor.de 9bf3870442 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>
2013-07-22 16:56:32 +10:00
mwilck@arcor.de 8e9387ac9f 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>
2013-07-22 16:56:32 +10:00
mwilck@arcor.de 35c3606df7 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>
2013-07-22 16:56:32 +10:00
NeilBrown 3eff7c1d2f 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>
2013-07-10 10:47:22 +10:00
mwilck@arcor.de c5943560f8 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>
2013-07-10 10:43:05 +10:00
mwilck@arcor.de ed5ff7a22b DDF: ddf_process_update: some more debug messages
Signed-off-by: NeilBrown <neilb@suse.de>
2013-07-10 10:43:01 +10:00
mwilck@arcor.de 4a03cbd10b DDF: guid_str: more readable output
Print ASCII characters as ASCII

Signed-off-by: NeilBrown <neilb@suse.de>
2013-07-10 10:42:17 +10:00
mwilck@arcor.de 6a7e7ecce9 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>
2013-07-10 10:42:11 +10:00
mwilck@arcor.de 4f9bbe63c1 DDF: add debug message in add_super_ddf_bvd
Signed-off-by: NeilBrown <neilb@suse.de>
2013-07-10 10:42:01 +10:00
mwilck@arcor.de ad60eea1e2 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>
2013-07-10 10:41:50 +10:00
mwilck@arcor.de 7c3fb3ecb3 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>
2013-07-10 10:41:34 +10:00
mwilck@arcor.de f5ded78768 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>
2013-07-10 10:41:18 +10:00
mwilck@arcor.de f646805e80 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>
2013-07-10 10:40:43 +10:00
mwilck@arcor.de 19041058d2 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>
2013-07-10 10:40:18 +10:00
mwilck@arcor.de 5838fccdd2 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>
2013-07-08 16:50:50 +10:00
mwilck@arcor.de 21a635519e 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>
2013-07-08 16:50:46 +10:00
mwilck@arcor.de b27336a28e 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>
2013-07-08 16:50:43 +10:00
mwilck@arcor.de be9b9ef42e 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>
2013-07-08 16:50:41 +10:00
mwilck@arcor.de ddf94a437e 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>
2013-07-08 16:50:37 +10:00
mwilck@arcor.de 63eb245403 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>
2013-07-08 16:50:33 +10:00
mwilck@arcor.de 475ccbdbf6 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>
2013-07-08 16:49:32 +10:00
mwilck@arcor.de 4ee8cca90e 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>
2013-07-08 16:49:28 +10:00
mwilck@arcor.de 4a3ca8acc3 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>
2013-07-08 16:49:25 +10:00
mwilck@arcor.de fcc22180b1 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>
2013-07-08 16:49:23 +10:00
mwilck@arcor.de 57a666623d 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>
2013-07-08 16:48:36 +10:00
mwilck@arcor.de 94b08b7c31 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>
2013-07-08 16:48:34 +10:00
mwilck@arcor.de 5aaf6c7b5d 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>
2013-07-08 16:48:32 +10:00
mwilck@arcor.de 3c48f7be46 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>
2013-07-08 16:48:30 +10:00
mwilck@arcor.de a3163bf069 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>
2013-07-08 16:46:32 +10:00
mwilck@arcor.de 8a2848a700 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>
2013-07-08 15:28:31 +10:00
mwilck@arcor.de fb9d0acbbc 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>
2013-07-08 15:28:31 +10:00
mwilck@arcor.de 0777d17d58 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>
2013-07-08 15:28:31 +10:00
mwilck@arcor.de 5ec636b7ad 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>
2013-07-08 15:28:31 +10:00
mwilck@arcor.de baba3f4e81 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>
2013-07-08 15:28:31 +10:00
mwilck@arcor.de a2aa439e99 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>
2013-07-08 15:28:31 +10:00
mwilck@arcor.de dbf98368fe 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>
2013-07-08 15:28:31 +10:00
mwilck@arcor.de a4057a88a2 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>
2013-07-08 15:28:31 +10:00
mwilck@arcor.de dbeb699a77 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>
2013-07-08 15:28:31 +10:00
mwilck@arcor.de c98567bac1 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>
2013-07-08 15:28:31 +10:00
mwilck@arcor.de d6e7b0837d 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>
2013-07-08 15:28:30 +10:00
NeilBrown ed503f89e4 Change some "fprintf(stderr,"s to pr_err.
They just keep slipping in..

Signed-off-by: NeilBrown <neilb@suse.de>
2013-05-21 12:42:57 +10:00
NeilBrown 74db60b00a Add --dump / --restore functionality.
This allows the metadata on a device to be saved and later restored.
This can be useful before experimenting on an array that is misbehaving.

Suggested-by: Dan Williams <dan.j.williams@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
2013-05-16 15:07:16 +10:00