Justin Maggard [Tue, 23 Oct 2012 22:04:00 +0000 (15:04 -0700)]
Create new md devices consistently
Creating a new MD device with the name 'd-0' results in some
unexpected behavior, since mdadm sees that '-0' is a
non-negative integer and therefore makes a "partitionable"
device (/dev/md_d0). This is not the expected behavior,
since the documentation mentions 'dN' several places, and a
reboot brings it up as /dev/md/d-0. Make this consistent
by ensuring that the character immediately following 'd' is
a digit during creation.
NeilBrown [Tue, 23 Oct 2012 05:27:15 +0000 (16:27 +1100)]
Add support for --replace and --with
--replace can be used to replace a device without completely failing
it. Once the replacement completes the device will be failed.
--with can indicate which of several spares to use.
NeilBrown [Mon, 22 Oct 2012 21:48:00 +0000 (08:48 +1100)]
super0: allow creation of array on 2TB+ devices.
As 'info->size' is signed, it cannot even hold values above
2TB.
But it isn't used much. sb->size is the important value and it
is unsigned.
So use that to check for overflow of size.
NeilBrown [Mon, 22 Oct 2012 06:23:11 +0000 (17:23 +1100)]
Assemble: split out "start_array()" function.
Apart from code movement, there is a small functional change here.
If the array is not successfully started, it is stopped.
Previously we would sometimes leave the array in a partially-assembled
but inactive state.
This just causes confusion.
"--incremental" can be used to partially assemble arrays.
Michael Tokarev [Sat, 20 Oct 2012 11:44:14 +0000 (15:44 +0400)]
Trivial bugfix and spelling fixes.
And here's another trivial bugfix, now for spelling mistakes in various
places, authred by Sergey Kirpichev (Cc'ed) and carried in debian mdadm
package.
Michael Tokarev [Sat, 20 Oct 2012 11:40:02 +0000 (15:40 +0400)]
mdadm: super0: do not override uuid with homehost
When --uuid is specified in the command line, even for v0.90
superblock we override last portion of uuid with data from
--homehost, which is wrong (and disagrees with the manpage).
Only use homehost in super0 if no uuid is specified.
Signed-off-By: Michael Tokarev <mjt@tls.msk.ru> Signed-off-by: NeilBrown <neilb@suse.de>
NeilBrown [Thu, 18 Oct 2012 05:39:49 +0000 (16:39 +1100)]
Assemble: split out load_devices() functionality.
Once we have found the devices we want, we need to load the
metadata from them and store it. This new function extracts that
functionality out of Assemble()
NeilBrown [Thu, 18 Oct 2012 04:31:20 +0000 (15:31 +1100)]
Assemble: split out select_devices function.
Assemble() is way too big.
This patch starts cleaning it up by pulling the 'select_devices()'
function. This examines the device to make sure they all belong to
one array, or select those that do (depending on exact use case).
NeilBrown [Thu, 11 Oct 2012 06:15:55 +0000 (17:15 +1100)]
Fix open_container
open_container should open a container which contains the device,
but sometimes it would open another volume which contains the
device. Be more careful in 'holder' selection.
NeilBrown [Wed, 10 Oct 2012 07:27:32 +0000 (18:27 +1100)]
Fix up interactions between --assemble and --incremental
If --incremental has partly assembled an array and
--assemble is asked to assemble it, the just finds remaining
devices and makes a new array. Not good.
So:
1/ modify locking policy so that assemble can be sure that
no --incremental is running once it locks the map file
2/ Assemble() checks the map file for a duplicate and adds to
that array instead of creating a new one.
NeilBrown [Thu, 4 Oct 2012 06:34:21 +0000 (16:34 +1000)]
Grow/raid10: support reducing the devices in a RAID10.
When reducing the number of devices in a RAID10, we increase the
data offset to avoid the need for backup area.
If there is no room at the end of the device to allow this, we need
to first reduce the component size of each device. However if there
is room, we don't want to insist on that, otherwise growing then
shrinking the array would not be idempotent.
So find the min before/after space before analysing a RAID10 for
reshape, and if the after space is insufficient, reduce the total size
of the array and the component size accordingly.
NeilBrown [Thu, 4 Oct 2012 06:34:21 +0000 (16:34 +1000)]
New RESHAPE_NO_BACKUP flag to track when backup action is needed.
Some arrays (raid10) never need a backup file, so during assembly
we can avoid the whole Grow_continue check in that case.
Achieve this using a flag set by the metadata handler.
Also get "mdadm -I" to fail if a backup process would be
needed. It currently does fail as the kernel rejects things,
but it is nicer to have this explicit.
NeilBrown [Thu, 4 Oct 2012 06:34:21 +0000 (16:34 +1000)]
Grow: add raid10 reshape.
RAID10 reshape requires that data_offset be changed.
So we only allow it if the new_data_offset attribute is available,
and we compute a suitable change in data offset.
NeilBrown [Thu, 4 Oct 2012 06:34:21 +0000 (16:34 +1000)]
Add --data-offset flag for Create and Grow
This can be used to over-ride the automatic assignment of
data offset.
For --create, it is useful to re-create old arrays where different
defaults applied.
For --grow it may be able to force a reshape in the reverse direction.
NeilBrown [Thu, 4 Oct 2012 06:34:20 +0000 (16:34 +1000)]
Allow parse_size to return 0.
We will shortly introduce --data-offset= which is allowed to
be zero. We will want to use parse_size() so it needs to be
able to return '0' without it being an error.
So define INVALID_SECTORS to be an impossible value (currently '1')
and return and test for it consistently.
NeilBrown [Thu, 4 Oct 2012 06:34:20 +0000 (16:34 +1000)]
Handles spaces in array names better.
1/ When printing the "name=" entry for --brief output,
enclose name in quotes if it contains spaces etc.
Quotes are already supported for reading mdadm.conf
2/ When a name is used as a device name, translate spaces
and tabs to '_', as well as the current translation of
'/' to '-'.
imsm: Allow to specify controller for --detail-platform.
Usually, 'mdadm --detail-platform -e imsm' scans all the controllers
looking for IMSM capabilities. This patch provides the possibility
to specify a controller to scan, enabling custom usage by other
processes - especially with the --export switch.
$ mdadm --detail-platform
Platform : Intel(R) Matrix Storage Manager
Version : 9.5.0.1037
RAID Levels : raid0 raid1 raid10 raid5
Chunk Sizes : 4k 8k 16k 32k 64k 128k
2TB volumes : supported
2TB disks : not supported
Max Disks : 7
Max Volumes : 2 per array, 4 per controller
I/O Controller : /sys/devices/pci0000:00/0000:00:1f.2 (SATA)
$ mdadm --detail-platform /sys/devices/pci0000:00/0000:00:1f.2
Platform : Intel(R) Matrix Storage Manager
Version : 9.5.0.1037
RAID Levels : raid0 raid1 raid10 raid5
Chunk Sizes : 4k 8k 16k 32k 64k 128k
2TB volumes : supported
2TB disks : not supported
Max Disks : 7
Max Volumes : 2 per array, 4 per controller
I/O Controller : /sys/devices/pci0000:00/0000:00:1f.2 (SATA)
$ mdadm --detail-platform /sys/devices/pci0000:00/0000:00:1f.0 # This isn't an IMSM-capable controller
mdadm: no active Intel(R) RAID controller found under /sys/devices/pci0000:00/0000:00:1f.0
Signed-off-by: Maciej Naruszewicz <maciej.naruszewicz@intel.com> Signed-off-by: NeilBrown <neilb@suse.de>
NeilBrown [Wed, 3 Oct 2012 04:41:31 +0000 (14:41 +1000)]
Grow - be careful about 'delayed' reshapes.
If multiple reshapes are activated on the same devices (different
partitions) then one might be forced to wait for the other to
complete.
As reshaping suspends access to small sections of the array
at time, this cause a region to be suspended for a long time,
which isn't good.
To try to detect this and don't start suspending until
the reshape is actually happening.
This is only effective on 3.7 and later as prior kernels
don't report when the delayed reshape can progress. For
the earlier kernels, just give a warning.
NeilBrown [Wed, 3 Oct 2012 03:53:46 +0000 (13:53 +1000)]
Fix 'enough' function for RAID10.
The 'enough' function is written to work with 'near' arrays only
in that is implicitly assumes that the offset from one 'group' of
devices to the next is the same as the number of copies.
In reality it is the number of 'near' copies.
So change it to make this number explicit.
Reported-by: Jakub Husák <jakub@gooseman.cz> Signed-off-by: NeilBrown <neilb@suse.de>
NeilBrown [Wed, 3 Oct 2012 03:34:15 +0000 (13:34 +1000)]
Replace sha1.h with slightly older version.
sha1.h claims GPL3+, while sha1.c claims GPL2+. This is
inconsistent and technically prevents the whole from being
distributed under GPL2.
So replace sha1.h with a version from the GCC sources from before
Tue Apr 20 08:36:39 2010
when the copyright notice was updated.
Display size with human_size_brief with a chosen prefix
When using human_size_brief, only IEC prefixes were supported. Now
it's possible to specify which format we want to see - either IEC
(kibi, mibi, gibi) or JEDEC (kilo, mega, giga).
Signed-off-by: Maciej Naruszewicz <maciej.naruszewicz@intel.com> Signed-off-by: NeilBrown <neilb@suse.de>
Synchronize size calculation in human_size and human_size_brief
It would be better if two size-calculating methods had the same
calculating algorithm. The human_size way of calculation seems
more readable, so let's use it for both methods.
Signed-off-by: Maciej Naruszewicz <maciej.naruszewicz@intel.com> Signed-off-by: NeilBrown <neilb@suse.de>
Inappriopriate error messages (e.g. mdadm: platform does not support
raid5 with 0 disk) have been displayed when too small size was given.
This patch fixes it.
fix: adjust parse_size() to the unsigned size variable
An error in parse_size() should be reported by 0, not -1,
because -1 is changed to the max value of unsigned long long
during calculations of size (e.g. at mdadm.c:412).
A negative value of size should be reported as error
(e.g. size equal -1 has been changed to the max value of
unsigned long long so far).
Robert Buchholz [Mon, 10 Sep 2012 07:28:21 +0000 (17:28 +1000)]
raid6check: Auto-repair mode
When calling raid6check in regular scanning mode, specifiying
"autorepair" as the last positional parameter will cause it
to automatically repair any single slot failes it identifies.
Robert Buchholz [Mon, 10 Sep 2012 07:25:27 +0000 (17:25 +1000)]
raid6check: Repair mode used geo_map incorrectly
In repair mode, the data block indices to be repaired were calculated
using geo_map() which returns the disk slot for a data block index
and not the reverse. Now we simply store the reverse of that calculation
when we do it anyway.
NeilBrown [Mon, 20 Aug 2012 00:37:21 +0000 (10:37 +1000)]
mdmon: allow --takeover when original was started with --offroot
As --offroot causes ARGV[0] to be changed, we need to be more
lenient when checking that the mdmon we are about to kill really
is mdmon. i.e. allow name to be "@dmon" instead.
NeilBrown [Wed, 15 Aug 2012 00:07:26 +0000 (10:07 +1000)]
ddf: hack to fix container recognition.
When adding a spare to a DDF there is some confusion about the
'level' of the container. It is reported by kernel as unknown
-1000000.
I don't know why this broke but until I figure out why and fix it,
this hack gets us going again.
NeilBrown [Tue, 14 Aug 2012 23:59:55 +0000 (09:59 +1000)]
ddf: allow a non-spare to be used to recovery a missing device.
If a DDF has two arrays sharing devices and one device fails, then
as soon as the spare is used to recover one of the arrays it isn't
spare any more and so is not chosen for the other array.
Work around this for now by allowing a non-spare to be used if it has
enough space.
Reported-by: Albert Pauw <albert.pauw@gmail.com> Signed-off-by: NeilBrown <neilb@suse.de>
NeilBrown [Tue, 14 Aug 2012 23:51:20 +0000 (09:51 +1000)]
Manage: zero metadata before adding to 'external' array.
'external' arrays don't support --re-add yet so old metadata is no
value, and 'ddf' gets confusing in mdmon if old metadata is found.
So for now, zero out any old metadata found before adding a spare to
an externally-managed array.
Reported-by: Albert Pauw <albert.pauw@gmail.com> Signed-off-by: NeilBrown <neilb@suse.de>
Lukasz Dorau [Mon, 13 Aug 2012 09:56:19 +0000 (11:56 +0200)]
Manage.c: fix make everything compilation error
This patch fixes the following make everything compilation error:
Manage.c: In function ‘Manage_add’:
Manage.c:538: error: ‘dev_st’ may be used uninitialized in this function
make: *** [mdadm.Os] Error 1
Mike Frysinger [Sun, 12 Aug 2012 19:24:15 +0000 (15:24 -0400)]
fix handling of CPPFLAGS
The current Makefile ends up ignoring the system CPPFLAGS settings,
so make sure we append the variable. Also, the old metadata logic
has a typo with the flag name.
Signed-off-by: Mike Frysinger <vapier@gentoo.org> Signed-off-by: NeilBrown <neilb@suse.de>
Lukasz Dorau [Fri, 10 Aug 2012 14:06:34 +0000 (16:06 +0200)]
Grow.c: change size to be unsigned and use '0' in case of 'no change'
The 'size' has been changed to be unsigned recently.
Analogous changes should be made to reshape_super().
'0' should be used in case of 'no change' now.
Harald Hoyer [Sun, 12 Aug 2012 22:00:21 +0000 (08:00 +1000)]
udev-rules: prevent systemd from mount devices before they are ready.
In the "add" uevent, ATTR{md/array_state} does not exist, so the next
rule does not kick in.
When an array is assembled incrementally, systemd might see it
before it is ready, try to mount it, fail, and give up.
Result is that array doesn't get mounted.
If we ask udev to tell systemd that it isn't ready yet in this
case, systemd waits until it is ready, and all are happy.
NeilBrown [Sun, 12 Aug 2012 22:00:21 +0000 (08:00 +1000)]
tests/03r5assemV1: reduce sync speed further.
This test is quite sensitive to resync speed - if the resync happens
to quickly it fails because it sees aan optimal array when it expects
a degraded array.
1000 is often slow enough but now always, so slow it down even more.
This requires reducing speed_limit_min also as kernel ignores 'max'
when speed is below 'min'.
NeilBrown [Sun, 12 Aug 2012 22:00:20 +0000 (08:00 +1000)]
Manage_subdev: give 'st' a better name and narrower focus.
'st' is use to examine the metadata on the device being added
to see if a 're-add' is possible. However it is loaded long before
the 're-add' attempt is made.
So move the 'load_super' closer to were it is used - allowing us to
discard a number of 'free_super' call - and rename it to 'dev_st'
to emphasize that it related to the current device.
Robert Buchholz [Mon, 9 Jul 2012 07:22:45 +0000 (17:22 +1000)]
Repair mode for raid6
In repair mode, raid6check will rewrite one single stripe
by regenerating the data (or parity) of two raid devices that
are specified via the command line.
If you need to rewrite just one slot, pick any other slot
at random.
Note that the repair option will change data on the disks
directly, so both the md layer above as well as any layers
above md (such as filesystems) may be accessing the stripe
data from cached buffers. Either instruct the kernels
to drop the caches or reassemble the raid after repair.