]> git.ipfire.org Git - thirdparty/mdadm.git/log
thirdparty/mdadm.git
11 years agoReplace a lot of leading spaces with tabs.
NeilBrown [Wed, 10 Oct 2012 07:33:26 +0000 (18:33 +1100)] 
Replace a lot of leading spaces with tabs.

Signed-off-by: NeilBrown <neilb@suse.de>
11 years agoFix up interactions between --assemble and --incremental
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.

Signed-off-by: NeilBrown <neilb@suse.de>
11 years agoGrow: allow --grow --continue to work for native metadata.
NeilBrown [Tue, 9 Oct 2012 02:54:59 +0000 (13:54 +1100)] 
Grow: allow --grow --continue to work for native metadata.

As it was the code would crash due to "mdstat" being NULL.
Code is now more sane, but hasn't been tested on an array that
needs to grow.

Signed-off-by: NeilBrown <neilb@suse.de>
11 years agoimsm: allow --assume-clean to work.
NeilBrown [Thu, 4 Oct 2012 06:51:22 +0000 (16:51 +1000)] 
imsm: allow --assume-clean to work.

We must avoid setting IMSM_T_STATE_UNINITIALIZED if the
array was declared to be clean due to --assume-clean.

Signed-off-by: NeilBrown <neilb@suse.de>
11 years agoAllow data-offset to be specified per-device for create
NeilBrown [Thu, 4 Oct 2012 06:34:21 +0000 (16:34 +1000)] 
Allow data-offset to be specified per-device for create

 mdadm --create /dev/md0 .... /dev/sda1:1024 /dev/sdb1:2048 ...

The size is in K unless a suffix: K M G is given.
The suffix 's' means sectors.

Signed-off-by: NeilBrown <neilb@suse.de>
11 years agoGrow/raid10: support reducing the devices in a RAID10.
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.

Signed-off-by: NeilBrown <neilb@suse.de>
11 years agosuper1: reserve at least 2 chunks for reshape headroom.
NeilBrown [Thu, 4 Oct 2012 06:34:21 +0000 (16:34 +1000)] 
super1: reserve  at least 2 chunks for reshape headroom.

sometimes 0.1% isn't enough, though mostly only in testing.

We need one chunk for a successful reshape, so reserve 2.

Signed-off-by: NeilBrown <neilb@suse.de>
11 years agoNew RESHAPE_NO_BACKUP flag to track when backup action is needed.
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.

Signed-off-by: NeilBrown <neilb@suse.de>
11 years agoGrow: add raid10 reshape.
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.

Signed-off-by: NeilBrown <neilb@suse.de>
11 years agoSplit 'GCD' out into a separate function.
NeilBrown [Thu, 4 Oct 2012 06:34:21 +0000 (16:34 +1000)] 
Split 'GCD' out into a separate function.

It is neater that way.

Signed-off-by: NeilBrown <neilb@suse.de>
11 years agoGrow: set new_data_offset if appropriate
NeilBrown [Thu, 4 Oct 2012 06:34:21 +0000 (16:34 +1000)] 
Grow: set new_data_offset if appropriate

11 years agoAdd space_before/space_after fields to mdinfo
NeilBrown [Thu, 4 Oct 2012 06:34:21 +0000 (16:34 +1000)] 
Add space_before/space_after fields to mdinfo

These will be needed to guide changes to data_offset during reshape.
Only set them for super1 for now.

Signed-off-by: NeilBrown <neilb@suse.de>
11 years agosuper1: add new_offset field.
NeilBrown [Thu, 4 Oct 2012 06:34:21 +0000 (16:34 +1000)] 
super1: add new_offset field.

The 'new_offset' is used for reshaping to avoid the need
for a backup file.

For now we only report the value when it is set.

Signed-off-by: NeilBrown <neilb@suse.de>
11 years agoAdd --data-offset flag for Create and Grow
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.

Signed-off-by: NeilBrown <neilb@suse.de>
11 years agoAdd data_offset arg to ->init_super and use it in super1.c
NeilBrown [Thu, 4 Oct 2012 06:34:20 +0000 (16:34 +1000)] 
Add data_offset arg to ->init_super and use it in super1.c

So if ->data_offset is already set, use that rather than
computing one.

Signed-off-by: NeilBrown <neilb@suse.de>
11 years agoAdd data_offset arg to ->validate_geometry.
NeilBrown [Thu, 4 Oct 2012 06:34:20 +0000 (16:34 +1000)] 
Add data_offset arg to ->validate_geometry.

This is needed to return correct available size.  It isn't
really used yet.

Signed-off-by: NeilBrown <neilb@suse.de>
11 years agoAdd data_offset arg to ->avail_size
NeilBrown [Thu, 4 Oct 2012 06:34:20 +0000 (16:34 +1000)] 
Add data_offset arg to ->avail_size

This is currently only useful for 1.x metadata and will allow an
explicit --data-offset request on command line.

Signed-off-by: NeilBrown <neilb@suse.de>
11 years agoAllow parse_size to return 0.
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.

Signed-off-by: NeilBrown <neilb@suse.de>
11 years agoHandles spaces in array names better.
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 '-'.

Signed-off-by: NeilBrown <neilb@suse.de>
11 years agoimsm: Allow to specify controller for --detail-platform.
Maciej Naruszewicz [Thu, 4 Oct 2012 06:34:11 +0000 (16:34 +1000)] 
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.2 --export
MD_FIRMWARE_TYPE=imsm
IMSM_VERSION=9.5.0.1037
IMSM_SUPPORTED_RAID_LEVELS=raid0 raid1 raid10 raid5
IMSM_SUPPORTED_CHUNK_SIZES=4k 8k 16k 32k 64k 128k
IMSM_2TB_VOLUMES=yes
IMSM_2TB_DISKS=no
IMSM_MAX_DISKS=7
IMSM_MAX_VOLUMES_PER_ARRAY=2
IMSM_MAX_VOLUMES_PER_CONTROLLER=4

$ 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>
11 years agoAdd zlib license to crc32.c
Jes Sorensen [Wed, 3 Oct 2012 08:00:34 +0000 (10:00 +0200)] 
Add zlib license to crc32.c

Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
Signed-off-by: NeilBrown <neilb@suse.de>
11 years agosuper1: ensure bitmap doesn't overlap bad block log.
NeilBrown [Wed, 3 Oct 2012 07:07:20 +0000 (17:07 +1000)] 
super1: ensure bitmap doesn't overlap bad block log.

If a bad block log already exists when adding a bitmap,
make sure the bitmap stays before the log.

Signed-off-by: NeilBrown <neilb@suse.de>
11 years agoAllow --update to add or remove space for a bad block list.
NeilBrown [Wed, 3 Oct 2012 07:07:13 +0000 (17:07 +1000)] 
Allow --update to add or remove space for a bad block list.

--update=bbl will add a bad block list to each device.
--update=no-bblk will remove the bad block list providing that it
is empty.

Signed-off-by: NeilBrown <neilb@suse.de>
11 years agoBad block log
NeilBrown [Wed, 3 Oct 2012 07:07:11 +0000 (17:07 +1000)] 
Bad block log

11 years agoGrow: make warning about old metadata more explicit.
NeilBrown [Wed, 3 Oct 2012 04:44:20 +0000 (14:44 +1000)] 
Grow: make warning about old metadata more explicit.

Don't print it just when --verbose is set, and explain how
to over-ride it.

Signed-off-by: NeilBrown <neilb@suse.de>
11 years agoGrow - be careful about 'delayed' reshapes.
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.

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

11 years agoUse --offroot flag when assembling md arrays via --incrmental
NeilBrown [Wed, 3 Oct 2012 03:54:03 +0000 (13:54 +1000)] 
Use --offroot flag when assembling md arrays via --incrmental

This ensures that mdmon won't be killed by systemd.
Signed-off-by: NeilBrown <neilb@suse.de>
11 years agoDetail/raid10: don't report 'set' names for 'far' and 'offset' raid10.
NeilBrown [Wed, 3 Oct 2012 03:53:54 +0000 (13:53 +1000)] 
Detail/raid10: don't report 'set' names for 'far' and 'offset' raid10.

The 'set' concept is only meaningful for 'near' arrays, so only
use it there.

Signed-off-by: NeilBrown <neilb@suse.de>
11 years agoFix 'enough' function for RAID10.
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>
11 years agoReplace sha1.h with slightly older version.
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.

Reported-by: Jes Sorensen <Jes.Sorensen@redhat.com>
Signed-off-by: NeilBrown <neilb@suse.de>
11 years agoAdd MD_ARRAY_SIZE for --examine --export
Maciej Naruszewicz [Tue, 2 Oct 2012 06:42:25 +0000 (16:42 +1000)] 
Add MD_ARRAY_SIZE for --examine --export

An additional pair of key=value for --examine --export.

Signed-off-by: Maciej Naruszewicz <maciej.naruszewicz@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
11 years agoDisplay size with human_size_brief with a chosen prefix
Maciej Naruszewicz [Tue, 2 Oct 2012 06:41:13 +0000 (16:41 +1000)] 
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>
11 years agoSynchronize size calculation in human_size and human_size_brief
Maciej Naruszewicz [Tue, 2 Oct 2012 06:40:11 +0000 (16:40 +1000)] 
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>
11 years agoFix return code for --detail-platform
Maciej Naruszewicz [Tue, 2 Oct 2012 06:37:48 +0000 (16:37 +1000)] 
Fix return code for --detail-platform

Variable 'err' is initially set to 1, so changing its value with
'|=' won't set it to 0 even if the operation is successful.

Signed-off-by: Maciej Naruszewicz <maciej.naruszewicz@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
11 years agoimsm: Add --export option for --detail-platform
Maciej Naruszewicz [Tue, 2 Oct 2012 06:28:30 +0000 (16:28 +1000)] 
imsm: Add --export option for --detail-platform

This option will provide most of information we can get via
mdadm --detail-platform [-e format] in the key=value format.
Example output:

$ 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 --export
MD_FIRMWARE_TYPE=imsm
IMSM_VERSION=9.5.0.1037
IMSM_SUPPORTED_RAID_LEVELS=raid0 raid1 raid10 raid5
IMSM_SUPPORTED_CHUNK_SIZES=4k 8k 16k 32k 64k 128k
IMSM_2TB_VOLUMES=yes
IMSM_2TB_DISKS=no
IMSM_MAX_DISKS=7
IMSM_MAX_VOLUMES_PER_ARRAY=2
IMSM_MAX_VOLUMES_PER_CONTROLLER=4

Signed-off-by: Maciej Naruszewicz <maciej.naruszewicz@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
11 years agoManage: fix checks for removal from a container.
NeilBrown [Mon, 24 Sep 2012 02:26:03 +0000 (12:26 +1000)] 
Manage: fix checks for removal from a container.

We must only remove from a container if the device isn't a
member of any member array.
To check we look at the 'holders' directory in sysfs.

We currently skip that check if ->devname is "detached", however
that can never be true since the change that introduced
add_detached().

Also sysfs_unique_holder returns status in 'errno' which isn't
entirely safe as e.g. closedir() is probably allowed to clear it.

So make sysfs_unique_holder return an unambigious value, and us
it to decide what to report.

Signed-off-by: NeilBrown <neilb@suse.de>
11 years agofix: imsm: do not accept too small sizes
Lukasz Dorau [Fri, 14 Sep 2012 14:20:31 +0000 (16:20 +0200)] 
fix: imsm: do not accept too small sizes

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.

Signed-off-by: Lukasz Dorau <lukasz.dorau@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
11 years agofix: adjust parse_size() to the unsigned size variable
Lukasz Dorau [Fri, 14 Sep 2012 14:12:45 +0000 (16:12 +0200)] 
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).

Signed-off-by: Lukasz Dorau <lukasz.dorau@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
11 years agofix: imsm: re-enable size expansion to the max value
Lukasz Dorau [Fri, 14 Sep 2012 14:04:08 +0000 (16:04 +0200)] 
fix: imsm: re-enable size expansion to the max value

Size expansion to the 'max' value has been broken since
the following patch:

    commit d04f65f48c93e7e57cc3c1d70dd07d094dece717
    Change the values for "max size" from -1 to 1.

This patch re-enables it.

Signed-off-by: Lukasz Dorau <lukasz.dorau@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
11 years agogrow: fix typo : MAX_DISKS -> MAX_SIZE
NeilBrown [Thu, 20 Sep 2012 01:32:39 +0000 (11:32 +1000)] 
grow: fix typo : MAX_DISKS -> MAX_SIZE

oopps.

Signed-off-by: NeilBrown <neilb@suse.de>
11 years agofix segfaults in Detail()
Lukasz Dorau [Thu, 20 Sep 2012 01:06:25 +0000 (11:06 +1000)] 
fix segfaults in Detail()

If disk has been removed, 'st' and 'info' can be NULL. It causes segfault.
'st' and 'info' should be checked against being NULL before being used.

Signed-off-by: Lukasz Dorau <lukasz.dorau@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
11 years agoraid6check: Auto-repair mode
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.

Signed-off-by: NeilBrown <neilb@suse.de>
11 years agoraid6check: Extract (un)locking into functions
Robert Buchholz [Mon, 10 Sep 2012 07:28:03 +0000 (17:28 +1000)] 
raid6check: Extract (un)locking into functions

Signed-off-by: NeilBrown <neilb@suse.de>
11 years agoraid6check: Repair mode used geo_map incorrectly
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.

Signed-off-by: NeilBrown <neilb@suse.de>
11 years agoraid6check: Fix off-by-one in argument check
Robert Buchholz [Thu, 19 Jul 2012 15:14:47 +0000 (17:14 +0200)] 
raid6check: Fix off-by-one in argument check

In repair mode, specifying a failed slot that is equal to the number of
devices in the raid could cause a segfault.

Signed-off-by: NeilBrown <neilb@suse.de>
11 years agoMove xmalloc et al into their own file
Robert Buchholz [Mon, 16 Jul 2012 21:56:54 +0000 (23:56 +0200)] 
Move xmalloc et al into their own file

This avoid code duplication for utilities that do not link to
util.c and everything that comes with it, such as test_restripe and
raid6check

Signed-off-by: NeilBrown <neilb@suse.de>
11 years agomapfile: fix mapfile rebuild for containers
NeilBrown [Mon, 20 Aug 2012 02:34:28 +0000 (12:34 +1000)] 
mapfile: fix mapfile rebuild for containers

When recreating the mapfile entry for a container we need to
use ->getinfo_super, not ->container_content, just like we
do in Detail().

Signed-off-by: NeilBrown <neilb@suse.de>
11 years agofind_free_devnum: avoid auto-using names in /etc/mdadm.conf
NeilBrown [Mon, 20 Aug 2012 00:50:42 +0000 (10:50 +1000)] 
find_free_devnum: avoid auto-using names in /etc/mdadm.conf

high-number names like "/dev/md126" shouldn't be in /etc/mdadm.conf,
but if they are they should be ignored when choosing an
unused number.

Signed-off-by: NeilBrown <neilb@suse.de>
11 years agomdmon: allow --takeover when original was started with --offroot
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.

Signed-off-by: NeilBrown <neilb@suse.de>
11 years agomdmon: fix arg processing for -a
NeilBrown [Mon, 20 Aug 2012 00:33:50 +0000 (10:33 +1000)] 
mdmon: fix arg processing for -a

'-a' was not being recognised as an abbreviation for '--all'.

Signed-off-by: NeilBrown <neilb@suse.de>
11 years agoddf: hack to fix container recognition.
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.

Signed-off-by: NeilBrown <neilb@suse.de>
11 years agoddf: allow a non-spare to be used to recovery a missing device.
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>
11 years agoddf: fix multiple white-space issues.
NeilBrown [Tue, 14 Aug 2012 23:55:40 +0000 (09:55 +1000)] 
ddf: fix multiple white-space issues.

Just general tidy-up

Signed-off-by: NeilBrown <neilb@suse.de>
11 years agoManage: zero metadata before adding to 'external' array.
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>
11 years agoManage.c: fix make everything compilation error
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

Signed-off-by: Lukasz Dorau <lukasz.dorau@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
11 years agosha1.h: remove ansidecl.h header inclusion
Lukasz Dorau [Mon, 13 Aug 2012 12:20:43 +0000 (14:20 +0200)] 
sha1.h: remove ansidecl.h header inclusion

Inclusion of the 'ansidecl.h' header requires the 'binutils-devel'
package to be installed but is not needed.

Signed-off-by: Maciej Patelczyk <maciej.patelczyk@intel.com>
Signed-off-by: Lukasz Dorau <lukasz.dorau@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
11 years agoquery udev dir via pkg-config
Samuli Suominen [Mon, 13 Aug 2012 17:44:22 +0000 (13:44 -0400)] 
query udev dir via pkg-config

Since udev is moving its internal dir around, query it via pkg-config
rather than hardcoding the old path.  This should work with new/old
versions.

Signed-off-by: Samuli Suominen <ssuominen@gentoo.org>
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Signed-off-by: NeilBrown <neilb@suse.de>
11 years agomdassemble: split dietlibc logic into dedicated target
Mike Frysinger [Sun, 12 Aug 2012 19:24:16 +0000 (15:24 -0400)] 
mdassemble: split dietlibc logic into dedicated target

This lets people run `make mdassemble` and get a sane build by default.

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Signed-off-by: NeilBrown <neilb@suse.de>
11 years agofix handling of CPPFLAGS
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>
11 years agoGrow.c: change size to be unsigned and use '0' in case of 'no change'
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.

Signed-off-by: Lukasz Dorau <lukasz.dorau@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
11 years agoudev-rules: prevent systemd from mount devices before they are ready.
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.

Signed-off-by: NeilBrown <neilb@suse.de>
11 years ago07reshape5intr: Set speed_limit_min to be able to reduce resync speed below 1000
Jes Sorensen [Sun, 12 Aug 2012 22:00:21 +0000 (08:00 +1000)] 
07reshape5intr: Set speed_limit_min to be able to reduce resync speed below 1000

We need to set speed_limit_min accordingly, otherwise setting
speed_limit_max below 1000 will have no effect.

Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
Signed-off-by: NeilBrown <neilb@suse.de>
11 years agoMinor cosmetic fixes in various files.
NeilBrown [Sun, 12 Aug 2012 22:00:21 +0000 (08:00 +1000)] 
Minor cosmetic fixes in various files.

Signed-off-by: NeilBrown <neilb@suse.de>
11 years agotests/03r5assemV1: reduce sync speed further.
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'.

Reported-by: Jes Sorensen <Jes.Sorensen@redhat.com>
Signed-off-by: NeilBrown <neilb@suse.de>
11 years agoManage_subdevs: factor out Manage_delete
NeilBrown [Sun, 12 Aug 2012 22:00:21 +0000 (08:00 +1000)] 
Manage_subdevs: factor out Manage_delete

Now Manage_subdevs is now small enough to be manageable.

Signed-off-by: NeilBrown <neilb@suse.de>
11 years agoManage_subdevs: split most of 'add' handling into Manage_add.
NeilBrown [Sun, 12 Aug 2012 22:00:21 +0000 (08:00 +1000)] 
Manage_subdevs: split most of 'add' handling into Manage_add.

This makes Manage_subdevs smaller, and makes the error-path handling
for Manage_add much cleaner and probably less buggy.

Signed-off-by: NeilBrown <neilb@suse.de>
11 years agoManage: split out attempt_re_add.
NeilBrown [Sun, 12 Aug 2012 22:00:21 +0000 (08:00 +1000)] 
Manage: split out attempt_re_add.

The indent level is way too deep here, and this is a well defined
task, so split it out to a separate function.

Signed-off-by: NeilBrown <neilb@suse.de>
11 years agoManage_subdev: give 'st' a better name and narrower focus.
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.

Signed-off-by: NeilBrown <neilb@suse.de>
11 years agoManage: minor cosmetic fixes.
NeilBrown [Sun, 12 Aug 2012 22:00:20 +0000 (08:00 +1000)] 
Manage: minor cosmetic fixes.

Signed-off-by: NeilBrown <neilb@suse.de>
11 years agoFix default size calculations that were recently broken.
NeilBrown [Sun, 12 Aug 2012 22:00:18 +0000 (08:00 +1000)] 
Fix default size calculations that were recently broken.

commit d04f65f48c93e7e57cc3c1d70dd07d094dece717
    Change the values for "max size" from -1 to 1.

Messed up 's->size' - leaving it as '1' (MAX_SIZE) in some cases and
causing the array reshape to fail.

Signed-off-by: NeilBrown <neilb@suse.de>
11 years agoRepair mode for raid6
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.

Signed-off-by: NeilBrown <neilb@suse.de>
11 years agoMake test a bash script (as it is)
Robert Buchholz [Mon, 9 Jul 2012 07:22:43 +0000 (17:22 +1000)] 
Make test a bash script (as it is)

Signed-off-by: NeilBrown <neilb@suse.de>
11 years agoExtract function to generate zeroes and expose xor function
Robert Buchholz [Mon, 9 Jul 2012 07:22:38 +0000 (17:22 +1000)] 
Extract function to generate zeroes and expose xor function

Signed-off-by: NeilBrown <neilb@suse.de>
11 years agoManage: simplify device searches in Manage_subdevs
NeilBrown [Mon, 9 Jul 2012 07:22:16 +0000 (17:22 +1000)] 
Manage: simplify device searches in Manage_subdevs

We currently have rather hard-to-follow loop to iterate
through all the matches for 'missing' or 'faulty' or 'detached'.

Simplify it by creating a list of possible devices for each
of those and splicing the new list into the device list.

This removes the need for 'jnext' and 'next' and various other hacks.

Signed-off-by: NeilBrown <neilb@suse.de>
11 years agoUse new struct context and struct shape for Grow_addbitmap
NeilBrown [Mon, 9 Jul 2012 07:22:12 +0000 (17:22 +1000)] 
Use new struct context and struct shape for Grow_addbitmap

Signed-off-by: NeilBrown <neilb@suse.de>
11 years agoUse new struct context and struct shape in Grow_reshape
NeilBrown [Mon, 9 Jul 2012 07:22:09 +0000 (17:22 +1000)] 
Use new struct context and struct shape in Grow_reshape

Signed-off-by: NeilBrown <neilb@suse.de>
11 years agoUse new 'struct shape' to pass args to Create
NeilBrown [Mon, 9 Jul 2012 07:22:05 +0000 (17:22 +1000)] 
Use new 'struct shape' to pass args to Create

Signed-off-by: NeilBrown <neilb@suse.de>
11 years agoUse new 'struct shape' to pass args to Build
NeilBrown [Mon, 9 Jul 2012 07:21:57 +0000 (17:21 +1000)] 
Use new 'struct shape' to pass args to Build

Signed-off-by: NeilBrown <neilb@suse.de>
11 years agoFix --build on 2.2 kernels :-)
NeilBrown [Mon, 9 Jul 2012 07:21:50 +0000 (17:21 +1000)] 
Fix --build on 2.2 kernels :-)

This code has clearly never been used because it isn't right.
But let's fix it anyway.

Signed-off-by: NeilBrown <neilb@suse.de>
11 years agoCreate new 'struct shape' to pass around array details.
NeilBrown [Mon, 9 Jul 2012 07:21:38 +0000 (17:21 +1000)] 
Create new 'struct shape' to pass around array details.

This collects to together many of the args given to
create/build/grow

Signed-off-by: NeilBrown <neilb@suse.de>
11 years agoCreate: Remove unnecessary cast from 'size'.
NeilBrown [Mon, 9 Jul 2012 07:21:27 +0000 (17:21 +1000)] 
Create: Remove unnecessary cast from 'size'.

'size' is already unsigned long long, so no need to cast it.

Signed-off-by: NeilBrown <neilb@suse.de>
11 years agochange array_size to be unsigned and use the new MAX_SIZE
NeilBrown [Mon, 9 Jul 2012 07:21:06 +0000 (17:21 +1000)] 
change array_size to be unsigned and use the new MAX_SIZE

Signed-off-by: NeilBrown <neilb@suse.de>
11 years agoChange the values for "max size" from -1 to 1.
NeilBrown [Mon, 9 Jul 2012 07:20:32 +0000 (17:20 +1000)] 
Change the values for "max size" from -1 to 1.

Both are impossible, and '1' allows size to be unsigned,
which is neater.
Also #define MAX_SIZE to be '1' to make it all more explicit.

Signed-off-by: NeilBrown <neilb@suse.de>
11 years agoAssemble: don't leak memory with fdlist.
NeilBrown [Mon, 9 Jul 2012 07:20:25 +0000 (17:20 +1000)] 
Assemble: don't leak memory with fdlist.

We should free fdlist when finished with it.

Signed-off-by: NeilBrown <neilb@suse.de>
11 years agoChange Incremental and related functions to take struct context
NeilBrown [Mon, 9 Jul 2012 07:20:22 +0000 (17:20 +1000)] 
Change Incremental and related functions to take struct context

Signed-off-by: NeilBrown <neilb@suse.de>
11 years agoChange Monitor to take a struct context
NeilBrown [Mon, 9 Jul 2012 07:20:19 +0000 (17:20 +1000)] 
Change Monitor to take a struct context

Signed-off-by: NeilBrown <neilb@suse.de>
11 years agoChange Detail and misc_scan to take a struct context
NeilBrown [Mon, 9 Jul 2012 07:20:16 +0000 (17:20 +1000)] 
Change Detail and misc_scan to take a struct context

Signed-off-by: NeilBrown <neilb@suse.de>
11 years agoChange name of 'c' variable in Detail
NeilBrown [Mon, 9 Jul 2012 07:20:05 +0000 (17:20 +1000)] 
Change name of 'c' variable in Detail

I want to use 'c' uniformly as a 'struct context', so
in Detail change 'c' to 'str'.

Signed-off-by: NeilBrown <neilb@suse.de>
11 years agochange Examine to take a struct context
NeilBrown [Mon, 9 Jul 2012 07:20:00 +0000 (17:20 +1000)] 
change Examine to take a struct context

Signed-off-by: NeilBrown <neilb@suse.de>
11 years agoExamine: split 'verbose' out from 'brief'.
NeilBrown [Mon, 9 Jul 2012 07:19:48 +0000 (17:19 +1000)] 
Examine: split 'verbose' out from 'brief'.

The value of 'verbose' is sometimes mixed into 'brief', particularly
for Examine.
This is messy and confusing.  So keep them separate.
'brief' still gets assumed when 'scan' is set, unless we are very
verbose.

Signed-off-by: NeilBrown <neilb@suse.de>
11 years agoChange Create to take a struct context
NeilBrown [Mon, 9 Jul 2012 07:19:24 +0000 (17:19 +1000)] 
Change Create to take a struct context

Signed-off-by: NeilBrown <neilb@suse.de>
11 years agoChange Build to take a struct context
NeilBrown [Mon, 9 Jul 2012 07:19:21 +0000 (17:19 +1000)] 
Change Build to take a struct context

Signed-off-by: NeilBrown <neilb@suse.de>
11 years agoChange misc_list to take struct context
NeilBrown [Mon, 9 Jul 2012 07:19:17 +0000 (17:19 +1000)] 
Change misc_list to take struct context

Signed-off-by: NeilBrown <neilb@suse.de>
11 years agoConvert Assemble() to take a context rather than a list of options.
NeilBrown [Mon, 9 Jul 2012 07:19:07 +0000 (17:19 +1000)] 
Convert Assemble() to take a context rather than a list of options.

Signed-off-by: NeilBrown <neilb@suse.de>
11 years agoDiscard 'quiet' context variable.
NeilBrown [Mon, 9 Jul 2012 07:18:48 +0000 (17:18 +1000)] 
Discard 'quiet' context variable.

Just use negative verbose, now that we are ready for that.

Signed-off-by: NeilBrown <neilb@suse.de>
11 years agoConvert 'quiet' to 'not verbose' in various places.
NeilBrown [Mon, 9 Jul 2012 07:18:09 +0000 (17:18 +1000)] 
Convert 'quiet' to 'not verbose' in various places.

If we change some functions to accept 'verbose', where <0 means to be
quiet, in place of 'quiet', then we will be able to merge
'quiet' and 'verbose' together for simplicity.

Signed-off-by: NeilBrown <neilb@suse.de>
11 years agoCreate 'struct context' for ad hoc context option.
NeilBrown [Mon, 9 Jul 2012 07:17:33 +0000 (17:17 +1000)] 
Create 'struct context' for ad hoc context option.

Rather than passing a long list of little flags etc to various
functions we will soon pass a small collection of structures.

This first step combines a collection of variables local to
'main' into a single structure.

Signed-off-by: NeilBrown <neilb@suse.de>
11 years agoCreate parse_num() function.
NeilBrown [Mon, 9 Jul 2012 07:14:17 +0000 (17:14 +1000)] 
Create parse_num() function.

Instead of open-coding this several times, just do it once.

The frees up the name 'c' which I'm about to use.

Signed-off-by: NeilBrown <neilb@suse.de>
11 years agoCreate: support --readonly flag.
NeilBrown [Mon, 9 Jul 2012 07:14:17 +0000 (17:14 +1000)] 
Create: support --readonly flag.

Allow array to be created read-only

Signed-off-by: NeilBrown <neilb@suse.de>
11 years agoAssemble: allow arrays to be assembled read-only.
NeilBrown [Mon, 9 Jul 2012 07:14:16 +0000 (17:14 +1000)] 
Assemble: allow arrays to be assembled read-only.

The option was there, but never used.

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