Commit Graph

263 Commits

Author SHA1 Message Date
mwilck@arcor.de 5daa35ac1a DDF: ddf_open_new: check device status for new subarray
It is possible that mdadm creates a new subarray containing failed
devices. This may happen if a device has failed, but the meta data
containing that information hasn't been written out yet.

This code tests for this situation, and handles it in the monitor.

Signed-off-by: Martin Wilck <mwilck@arcor.de>
Signed-off-by: NeilBrown <neilb@suse.de>
2013-08-08 10:33:21 +10:00
NeilBrown 3921e41a9d DDF: Write new conf entries with a single write.
The recent change to skip over invalid conf entries was bad because
it could leave garbage on the disk.
But we don't to write each entry separately as the writes a O_DIRECT
and so synchronous so it takes way too long.

So allocate a large buffer (probably the one used to read the config records)
and fill that then write it all at once.

Reported-by: Martin Wilck <mwilck@arcor.de>
Signed-off-by: NeilBrown <neilb@suse.de>
2013-08-07 17:09:24 +10:00
mwilck@arcor.de 60056e1c3d DDF: get_extents: don't allocate space on failed disks
We should skip known failed disks when allocating space for
new arrays. This fixes the problem with 10ddf-fail-spare.

Signed-off-by: Martin Wilck <mwilck@arcor.de>
Signed-off-by: NeilBrown <neilb@suse.de>
2013-08-06 09:54:47 +10:00
NeilBrown 92939eb291 DDF: fix removal of failed devices.
Commit c7079c84 arrange for DDF to forget about any device
that is failed and not still marked as part of any array.

However such devices could still be part of the container and this
removal and updating of 'pdnum' can result in multiple devices having
the same pdnum.  This in turn easily leads to confusion and
corruption.

So only discard pd entries for devices which are failed, not listed in
any virtual device, and for which we don't have a handle on the
device.

pd entries will not get removed until a new device is added after
the device has been removed from the container, either by
"mdadm --remove" or by assembling without the failed devices.

Reported-by: Albert Pauw <albert.pauw@gmail.com>
Analysed-by: Martin Wilck <mwilck@arcor.de>
Signed-off-by: NeilBrown <neilb@suse.de>
2013-08-05 15:10:05 +10:00
NeilBrown ce45c81986 DDF: fix writing metadata updates.
Recent commit 273989b93a
skipped writing some large blocks of 0xFF, but didn't seek
over the space, so subsequent data was written wrongly.

When we don't write, we need to seek.

Signed-off-by: NeilBrown <neilb@suse.de>
2013-08-05 14:21:10 +10:00
mwilck@arcor.de 9591a2de77 DDF: no need for GET_LAYOUT any more
With the previous patch, mdmon will provide the layout property for us.

Signed-off-by: Martin Wilck <mwilck@arcor.de>
Signed-off-by: NeilBrown <neilb@suse.de>
2013-08-05 11:31:56 +10:00
NeilBrown 273989b93a DDF: differentiate between new metadata and metadata updates.
When writing an update, we don't need to overwrite lots of
empty fields.  This makes updates somewhat faster.

Signed-off-by: NeilBrown <neilb@suse.de>
2013-08-01 15:33:19 +10:00
NeilBrown cc83a81972 DDF: use some #defines instead of bare constants.
Signed-off-by: NeilBrown <neilb@suse.de>
2013-08-01 15:21:24 +10:00
Martin Wilck ce6844b99c DDF: ddf_set_disk: add some debug messages
Adds more verbose debugging in ddf_set_disk, to understand failures
better.

Signed-off-by: Martin Wilck <mwilck@arcor.de>
Signed-off-by: NeilBrown <neilb@suse.de>
2013-07-31 12:47:44 +10:00
Martin Wilck 0e5fa86239 DDF: load_ddf_header: more error logging
Try to determine problem if load_ddf_header fails. May be useful
for determining compatibility problems with Fake RAID BIOSes.

Signed-off-by: Martin Wilck <mwilck@arcor.de>
Signed-off-by: NeilBrown <neilb@suse.de>
2013-07-31 12:47:44 +10:00
Martin Wilck 0847945b8e DDF: ddf_process_update: log offsets for conf changes
I needed this for tracking a bug with wrong offsets after array
creation.

Signed-off-by: Martin Wilck <mwilck@arcor.de>
Signed-off-by: NeilBrown <neilb@suse.de>
2013-07-31 12:47:44 +10:00
Martin Wilck 2a645ee220 DDF: log disk status changes more nicely
In particular, include refnum for better tracking. This makes
it a little easier for humans to track what happened to which disk.

Signed-off-by: Martin Wilck <mwilck@arcor.de>
Signed-off-by: NeilBrown <neilb@suse.de>
2013-07-31 12:47:44 +10:00
Martin Wilck 6f56dbb970 DDF: ddf_activate_spare: bugfix for 62ff3c40
Move the check for good drives in the dl loop - otherwise dl
may be NULL and mdmon may crash.

Signed-off-by: Martin Wilck <mwilck@arcor.de>
Signed-off-by: NeilBrown <neilb@suse.de>
2013-07-31 12:47:44 +10:00
NeilBrown 7ccc4cc4fc 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>
2013-07-30 13:45:22 +10:00
mwilck@arcor.de 0c78849f2b 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>
2013-07-30 10:57:14 +10:00
mwilck@arcor.de 62ff3c40c1 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>
2013-07-30 10:57:13 +10:00
mwilck@arcor.de 7733b91d37 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>
2013-07-30 10:57:13 +10:00
mwilck@arcor.de 84e32e1977 DDF: find_vdcr: fix minor bug in debug message
This code could find disk -1. Fixed.

Signed-off-by: NeilBrown <neilb@suse.de>
2013-07-30 10:57:13 +10:00
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