Commit Graph

234 Commits

Author SHA1 Message Date
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
NeilBrown b31df43682 intel,ddf: don't require partitions when ignore_hw_compat is set.
Partitions are a hw-compat issue.

This allows e.g "--examine" to be used on image files.

Signed-off-by: NeilBrown <neilb@suse.de>
2013-05-16 13:24:07 +10:00
mwilck@arcor.de 3f188b1081 DDF: fix bug in compare_super_ddf
Fix bug in previous patch
"DDF: compare_super_ddf: merge local info of other superblock"

Just discovered this bug in my last patch set - unfortunately, just after
you committed it.

Signed-off-by: Martin Wilck <mwilck@arcor.de>
Signed-off-by: NeilBrown <neilb@suse.de>
2013-04-24 16:33:46 +10:00
mwilck@arcor.de 7d5a7ff3da DDF: add code to debug state changes
The 10ddf-create test case fails sporadically because wrong meta
data is written, making the array appear inconsistent when it's
restarted. Added code to aid debugging this.

Signed-off-by: Martin Wilck <mwilck@arcor.de>
Signed-off-by: NeilBrown <neilb@suse.de>
2013-04-23 14:55:32 +10:00
mwilck@arcor.de bedbf68a08 DDF: brief_detail_super_ddf: print correct UUID for subarrays
Commit c1ea5a98 caused brief_detail_super_ddf() to be called
for subarrays. But the UUID printed was always the one of the
container. This is wrong and actually worse than printing no UUID
at all, and causes the DDF test case (10ddf-create) to fail.

This patch adds code to determine the MD UUID of a subarray correctly.
The hard part is to figure out for which subarray the function is
called. Moved that to an extra function.

Signed-off-by: Martin Wilck <mwilck@arcor.de>
Signed-off-by: NeilBrown <neilb@suse.de>
2013-04-23 14:55:31 +10:00
mwilck@arcor.de dc9e279c13 DDF: __write_init_super_ddf: just use seq number of active header
It's not necessary to check for 0xffffffff, which is a valid
sequential number.

Signed-off-by: Martin Wilck <mwilck@arcor.de>
Signed-off-by: NeilBrown <neilb@suse.de>
2013-04-23 14:55:31 +10:00
mwilck@arcor.de dacf3dc5d4 DDF: __write_ddf_structure: Fix wrong reference to ddf->primary
Should reference "header" instead here.

Signed-off-by: Martin Wilck <mwilck@arcor.de>
Signed-off-by: NeilBrown <neilb@suse.de>
2013-04-23 14:55:31 +10:00
mwilck@arcor.de 4eefd651f0 DDF: compare_super_ddf: merge local info of other superblock
If a match is found in compare_super_ddf, check the other SB
for local DDF information (VD config records, physical disk data)
which is not available in the current superblock, and add it
if needed.

This is important for the mdmon - when disks are added to a
auto read-only array, they must be present in the DDF structure
in order to guarantee consistent writeback of metadata to all
disks.

Signed-off-by: Martin Wilck <mwilck@arcor.de>
Signed-off-by: NeilBrown <neilb@suse.de>
2013-03-04 16:15:06 +11:00
mwilck@arcor.de 2d21069764 DDF: add sanity checks in compare_super_ddf
Besides container GUID, also check seqnum, physical and virtual
disk numbers, and check match between local and global sections.

Signed-off-by: Martin Wilck <mwilck@arcor.de>
Signed-off-by: NeilBrown <neilb@suse.de>
2013-03-04 16:14:17 +11:00
mwilck@arcor.de e3c2a365e9 DDF: __write_init_super_ddf: use correct VD conf
When writing back the DDF structure, make sure that on each disk
we write the configs that include this disk even if a secondary
RAID level is present. Otherwise the secondary RAID will not be
read correctly any more when we open the device next time.

Signed-off-by: Martin Wilck <mwilck@arcor.de>
Signed-off-by: NeilBrown <neilb@suse.de>
2013-03-04 16:13:21 +11:00
mwilck@arcor.de 4e5870181a DDF: container_content_ddf: handle RAID layout for RAID10
This patch adds basic handling for the special case of RAID10.

Signed-off-by: Martin Wilck <mwilck@arcor.de>
Signed-off-by: NeilBrown <neilb@suse.de>
2013-03-04 16:10:38 +11:00
mwilck@arcor.de a5c7adb310 DDF: container_content_ddf: check for secondary RAID
Check for supportable secondary RAID configurations.
There is currently only one: RAID 10, if the stripe
sizes and Basic volume sizes are all equal.

With this patch, mdadm will not try to start unsupported
secondary RAID level configurations any more.

Signed-off-by: Martin Wilck <mwilck@arcor.de>
Signed-off-by: NeilBrown <neilb@suse.de>
2013-03-04 16:08:46 +11:00