]> git.neil.brown.name Git - mdadm.git/log
mdadm.git
11 years agoRelease 3.2.6 - stability release mdadm-3.2.x mdadm-3.2.6
NeilBrown [Thu, 25 Oct 2012 06:16:51 +0000 (17:16 +1100)]
Release 3.2.6 - stability release

11 years agoQuery: allow member of non-0.90 arrays to be better reported.
NeilBrown [Thu, 25 Oct 2012 05:38:11 +0000 (16:38 +1100)]
Query: allow member of non-0.90 arrays to be better reported.

Currently if a member of a 1.x array is queries, mdadm will
fail to find the name of the active md array if there is one.

Change the lookup to use the mapfile - now it works.

Signed-off-by: NeilBrown <neilb@suse.de>
11 years agoQuery: don't be confused by partition tables.
NeilBrown [Thu, 25 Oct 2012 05:32:00 +0000 (16:32 +1100)]
Query: don't be confused by partition tables.

Now that we recognise partition tables as a sort of metadata
we need to be careful in --query not to say that a device
with a partition table looks like a device in an array.

Testing ->compare_super for NULL is an easy way to do that.

Signed-off-by: NeilBrown <neilb@suse.de>
11 years agoMonitor: don't complain about non-monitorable arrays in mdadm.conf
NeilBrown [Wed, 24 Oct 2012 02:09:09 +0000 (13:09 +1100)]
Monitor: don't complain about non-monitorable arrays in mdadm.conf

If we are asked to monitor a RAID0 or Linear - which cannot be
monitored - we complain with "Device Disappeared .... Wrong-Level".

However if the RAID0 or Linear is being requested because it is
in mdadm.conf then the message is inappropriate and confusing.

So track which arrays are added from the config file, and suppress
that message in that case.

Reported-by: "Johnson Yan" <johnson_yan@usish.com>
Signed-off-by: NeilBrown <neilb@suse.de>
11 years agoCreate new md devices consistently
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.

Signed-off-by: NeilBrown <neilb@suse.de>
11 years agosuper0: allow creation of array on 2TB+ devices.
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.

Reported-by: Eugene San <eugenesan@gmail.com>
11 years agoDetail: don't report a faulty device as 'spare' or 'rebuilding'.
NeilBrown [Sun, 21 Oct 2012 22:34:49 +0000 (09:34 +1100)]
Detail: don't report a faulty device as 'spare' or 'rebuilding'.

If a device is faulty, then that is all there is too it.
Even if it isn't 'removed' yet, it shouldn't be reported as 'spare'
or 'rebuilding'.

Signed-off-by: NeilBrown <neilb@suse.de>
11 years agoTrivial bugfix and spelling fixes.
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.

Signed-off-by: NeilBrown <neilb@suse.de>
11 years agomdadm: super0: do not override uuid with homehost
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>
11 years agoFix open_container
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.

Signed-off-by: NeilBrown <neilb@suse.de>
11 years agoGrow: fix a couple of typos with --assume-clean usage
NeilBrown [Thu, 11 Oct 2012 00:35:41 +0000 (11:35 +1100)]
Grow: fix a couple of typos with --assume-clean usage

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 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 agoAdd zlib license to crc32.c
Jes Sorensen [Thu, 18 Oct 2012 04:38:41 +0000 (15:38 +1100)]
Add zlib license to crc32.c

Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
Signed-off-by: NeilBrown <neilb@suse.de>
11 years agoReplace sha1.h with slightly older version.
NeilBrown [Thu, 18 Oct 2012 04:38:36 +0000 (15:38 +1100)]
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 agoGrow: make warning about old metadata more explicit.
NeilBrown [Thu, 18 Oct 2012 04:38:34 +0000 (15:38 +1100)]
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 agoUse --offroot flag when assembling md arrays via --incrmental
NeilBrown [Thu, 27 Sep 2012 06:58:45 +0000 (16:58 +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 agoFix 'enough' function for RAID10.
NeilBrown [Thu, 27 Sep 2012 06:58:44 +0000 (16:58 +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 agofix segfaults in Detail()
Lukasz Dorau [Thu, 27 Sep 2012 06:58:44 +0000 (16:58 +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 agomapfile: fix mapfile rebuild for containers
NeilBrown [Thu, 27 Sep 2012 06:58:42 +0000 (16:58 +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 [Thu, 27 Sep 2012 06:57:09 +0000 (16:57 +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 [Thu, 27 Sep 2012 06:57:09 +0000 (16:57 +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 agoManage: zero metadata before adding to 'external' array.
NeilBrown [Thu, 27 Sep 2012 06:57:08 +0000 (16:57 +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 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 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 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 agomdmon: fix arg parsing.
NeilBrown [Mon, 9 Jul 2012 06:50:22 +0000 (16:50 +1000)]
mdmon: fix arg parsing.

-t aka --takeover should not be setting container_name.
It sets it to NULL which causes failure when you try
  mdmon --all --takeover

Signed-off-by: NeilBrown <neilb@suse.de>
11 years agoMonitor: fix reporting for Fail vs FailSpare etc.
NeilBrown [Mon, 4 Jun 2012 02:57:52 +0000 (12:57 +1000)]
Monitor: fix reporting for Fail vs FailSpare etc.

The tests here were specific to 0.90 metadata and didn't
work properly for 1.x metadata, where a device's "number"
doesn't change.

By checking if this is a new array we can avoid some
corner cases.  Then we test mostly based on state and
not based on 'number' at all.

Signed-off-by: NeilBrown <neilb@suse.de>
11 years agoMonitor: Report NewArray when an array the disappeared, reappears.
NeilBrown [Mon, 4 Jun 2012 02:52:36 +0000 (12:52 +1000)]
Monitor: Report NewArray when an array the disappeared, reappears.

Signed-off-by: NeilBrown <neilb@suse.de>
11 years agoMonitor: fix inconsistencies in values for ->percent
NeilBrown [Mon, 4 Jun 2012 02:31:40 +0000 (12:31 +1000)]
Monitor: fix inconsistencies in values for ->percent

->percent sometimes stores negative values recording states
like 'pending' or 'delayed'.
The value '-2' means both 'delayed' and in Monitor, 'unknown'.
Also, '-1' has a meaning but not #define.

So change the #defines to be prefixed with "RESYNC_", instead
of "PROCESS_", add new "_NONE" and "_UNKNOWN", and use correct
value in each location.

Signed-off-by: NeilBrown <neilb@suse.de>
11 years agoimsm: fix: correct checking volume's degradation
Lukasz Dorau [Fri, 25 May 2012 13:06:41 +0000 (15:06 +0200)]
imsm: fix: correct checking volume's degradation

We do not check the return value of sysfs_get_ll() now. It is wrong.
If reading of the sysfs "degraded" key does not succeed,
the "new_degraded" variable will not be initiated
and accidentally it can have the value of "degraded" variable.
In that case the change of degradation will not be checked.

It happens if mdadm is compiled with gcc's "-fstack-protector" option
when one tries to stop a volume under reshape (e.g. OLCE).
Reshape seems to be finished then (metadata is in normal/clean state)
but it is not finished, it is broken and data are corrupted.

Now we always check the return value of sysfs_get_ll().
Even if reading of the sysfs "degraded" key does not succeed
(rv == -1) the change of degradation will be checked.

Signed-off-by: Lukasz Dorau <lukasz.dorau@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
11 years agomdadm: Fix Segmentation fault.
majianpeng [Mon, 28 May 2012 23:21:51 +0000 (09:21 +1000)]
mdadm: Fix Segmentation fault.

In function write_init_super1():
If "rv = store_super1(st, di->fd)" return error and the di is the last.
Then the di = NULL && rv > 0, so exec:
if (rv)
    fprintf(stderr, Name ": Failed to write metadata to%s\n",
       di->devname);
will be segmentation fault.

Signed-off-by: majianpeng <majianpeng@gmail.com>
Signed-off-by: NeilBrown <neilb@suse.de>
11 years agoudev-rules: prevent systemd from mount devices before they are ready.
NeilBrown [Thu, 24 May 2012 01:49:49 +0000 (11:49 +1000)]
udev-rules: prevent systemd from mount devices before they are ready.

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>
12 years agoCreate new release: 3.2.5 mdadm-3.2.5
NeilBrown [Fri, 18 May 2012 06:21:41 +0000 (16:21 +1000)]
Create new release: 3.2.5

Fix a serious regression in 3.2.4 which caused "--add" to often
fail.  Other minor fixes included.

Signed-off-by: NeilBrown <neilb@suse.de>
12 years agoUpdate some device sizes for self tests.
NeilBrown [Fri, 18 May 2012 07:08:28 +0000 (17:08 +1000)]
Update some device sizes for self tests.

A recent change means that devices smaller than
1Gig no longer have 1Meg wasted at the start.
So we must adjust some sizes again.

Signed-off-by: NeilBrown <neilb@suse.de>
12 years agoimsm: fix: check if size of expansion is not larger than maximum
Lukasz Dorau [Thu, 17 May 2012 14:14:00 +0000 (16:14 +0200)]
imsm: fix: check if size of expansion is not larger than maximum

We do not check if requested size of expansion is larger than maximum
available size now. If it is larger the output message is a bit misleading,
for example:
   mdadm: Cannot set size on array members.
   mdadm: Cannot set device size for /dev/md/vol: Device or resource busy
Now we check if requested size of expansion is larger than maximum
available size and the appropriate output message was added.

Signed-off-by: Lukasz Dorau <lukasz.dorau@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
12 years agoimsm: fix a typo in fprintf message
Lukasz Dorau [Thu, 17 May 2012 13:37:24 +0000 (15:37 +0200)]
imsm: fix a typo in fprintf message

Signed-off-by: Lukasz Dorau <lukasz.dorau@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
12 years agomdadm.conf.5: typo: of -> or
NeilBrown [Fri, 18 May 2012 02:29:29 +0000 (12:29 +1000)]
mdadm.conf.5: typo: of -> or

Addresses-Debian-bug: 673344
Reported-by: Robert Henney <robh@rut.org>
Signed-off-by: NeilBrown <neilb@suse.de>
12 years agoRebuildMap: check that container_content returns a valid 'info'.
NeilBrown [Thu, 17 May 2012 05:46:09 +0000 (15:46 +1000)]
RebuildMap: check that container_content returns a valid 'info'.

If it doesn't, just skip that entry.

Reported-by: Maciej Naruszewicz <maciej.naruszewicz@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
12 years agoDon't consider disks with a valid recovery offset as candidates for bumping up event...
Alexander Lyakas [Sun, 13 May 2012 07:10:43 +0000 (10:10 +0300)]
Don't consider disks with a valid recovery offset as candidates for bumping up event count

When we are looking for a candidate disk to bump up the event count,
we consider only disks that have recovery_start==MaxSector.
However, after we find one such disk, we agree to accept more disks
having same event count, regardless of their recovery_start.
Be consistent and don't accept disks with a valid recovery_start at all.

Signed-off-by: NeilBrown <neilb@suse.de>
12 years agoGrow: don't print message if unfreezing fails.
NeilBrown [Tue, 15 May 2012 02:12:58 +0000 (12:12 +1000)]
Grow: don't print message if unfreezing fails.

This is most likely to happen if the array has been stopped,
in which case the error is pointless.

Reported-by: Patrik Horník <patrik@dsl.sk>
Signed-off-by: NeilBrown <neilb@suse.de>
12 years agoGrow: fix --layout=preserve to match man page.
NeilBrown [Tue, 15 May 2012 01:59:40 +0000 (11:59 +1000)]
Grow: fix --layout=preserve to match man page.

I think there was some confusion about what --layout=preserve
actually means, but in any case it wasn't doing what the man
page says it should.
So add some case analysis and make sure it does the right thing,
or complains if it cannot.

Reported-by: Patrik Horník <patrik@dsl.sk>
Signed-off-by: NeilBrown <neilb@suse.de>
12 years agosuper1: fix choice of data_offset.
NeilBrown [Mon, 14 May 2012 23:51:03 +0000 (09:51 +1000)]
super1: fix choice of data_offset.

While it is nice to set a high data_offset to leave plenty of head
room it is much more important to leave enough space to allow
of the data of the array.
So after we check that sb->size is still available, only reduce the
'reserved', don't increase it.

This fixes a bug where --adding a spare fails because it does not have
enough space in it.

Reported-by: nowhere <nowhere@hakkenden.ath.cx>
Signed-off-by: NeilBrown <neilb@suse.de>
12 years agoNew sha1.c and sha1.h
NeilBrown [Mon, 14 May 2012 10:09:47 +0000 (20:09 +1000)]
New sha1.c and sha1.h

These are from:
  http://gcc.gnu.org/svn/gcc/branches/cilkplus/include/sha1.h
and
  http://gcc.gnu.org/svn/gcc/branches/cilkplus/libiberty/sha1.c

and hopefully avoid aliasing issues.

Signed-off-by: NeilBrown <neilb@suse.de>
12 years agoCreate new release: 3.2.4 mdadm-3.2.4
NeilBrown [Tue, 8 May 2012 23:42:57 +0000 (09:42 +1000)]
Create new release: 3.2.4

Bugfix release

Signed-off-by: NeilBrown <neilb@suse.de>
12 years agosuper-intel.c: Fix resource leak from opendir()
Jes Sorensen [Fri, 4 May 2012 11:41:22 +0000 (13:41 +0200)]
super-intel.c: Fix resource leak from opendir()

Use closedir() on dirp from opendir() to avoid resource leaking.

Acked-by: Dan Williams <dan.j.williams@intel.com>
Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
Signed-off-by: NeilBrown <neilb@suse.de>
12 years agosuper-intel.c: Don't try to close negative fd
Jes Sorensen [Fri, 4 May 2012 11:41:21 +0000 (13:41 +0200)]
super-intel.c: Don't try to close negative fd

This should be harmless, but lets be consistent and not try to close a
negative file descripter.

Acked-by: Dan Williams <dan.j.williams@intel.com>
Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
Signed-off-by: NeilBrown <neilb@suse.de>
12 years agoGrow: failing the set the per-device size is not an error.
NeilBrown [Thu, 3 May 2012 06:18:22 +0000 (16:18 +1000)]
Grow: failing the set the per-device size is not an error.

Signed-off-by: NeilBrown <neilb@suse.de>
12 years agotest: don't worry too much about array size.
NeilBrown [Thu, 3 May 2012 05:29:04 +0000 (15:29 +1000)]
test: don't worry too much about array size.

With different amounts of space being reserved for metadata
it is hard for the script to know how big the array should be.
So allow a bit of slack.

Signed-off-by: NeilBrown <neilb@suse.de>
12 years agoAdjust to new standard of /run
NeilBrown [Thu, 3 May 2012 04:16:56 +0000 (14:16 +1000)]
Adjust to new standard of /run

Now that /run seems to be a good standard, make that
the default for storing various run-time files, rather than
/var/run or /dev/.mdadm.

Signed-off-by: NeilBrown <neilb@suse.de>
12 years agoUpdate test for "is udev active".
NeilBrown [Thu, 3 May 2012 04:16:51 +0000 (14:16 +1000)]
Update test for "is udev active".

Newer udev doesn't use /dev/.udev any more. it used
/run/udev instead.
So test for that as well.

Signed-off-by: NeilBrown <neilb@suse.de>
12 years agoimsm: fix: thunderdome may drop 2tb attribute
Czarnowska, Anna [Mon, 2 Apr 2012 20:59:03 +0000 (20:59 +0000)]
imsm: fix: thunderdome may drop 2tb attribute

Spare superblock doesn't depend on other spares in container.
When loading container metadata thunderdome
may pick a small disk for the champion. This will result in incorrect
interpretation of sizes of other disks in container when joint superblock
is returned. If any disk in container has the 2TB attribute set, the result
must have it set too.

Signed-off-by: Anna Czarnowska <anna.czarnowska@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
12 years agoIntroduce sysfs_set_num_signed() and use it to set bitmap/offset
Jes Sorensen [Thu, 26 Apr 2012 15:12:57 +0000 (17:12 +0200)]
Introduce sysfs_set_num_signed() and use it to set bitmap/offset

mdinfo->bitmap_offset is a signed long and needs to be treated as
such when passed to the kernel.

This resolves the problem with adding internal bitmaps to a 1.0 array.

Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
Signed-off-by: NeilBrown <neilb@suse.de>
12 years agoFix sign extension of bitmap_offset in super1.c
Jes Sorensen [Thu, 26 Apr 2012 15:12:56 +0000 (17:12 +0200)]
Fix sign extension of bitmap_offset in super1.c

fbdef49811c9e2b54e2064d9af68cfffa77c6e77 incorrectly tried to fix sign
extension of the bitmap offset. However mdinfo->bitmap_offset is a u32
and needs to be converted to a 32 bit signed integer before the sign
extension.

Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
Signed-off-by: NeilBrown <neilb@suse.de>
12 years agofix: correct extending size of raid0 array
Lukasz Dorau [Fri, 20 Apr 2012 09:00:25 +0000 (11:00 +0200)]
fix: correct extending size of raid0 array

Setting "sync_action" to "idle" while extending size of raid0 array
is racy and sometimes fails.
"sync_action" should be set to "frozen" instead.

Signed-off-by: Lukasz Dorau <lukasz.dorau@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
12 years agoimsm: fix: rebuild does not continue after reboot
Lukasz Dorau [Fri, 20 Apr 2012 11:45:02 +0000 (13:45 +0200)]
imsm: fix: rebuild does not continue after reboot

If system is rebooted during rebuild, md driver changes sync_action
from 'recover' to 'idle' (during stopping all md devices).
If mdmon is still running then, it detects the change of sync_action state,
finishes rebuild and writes metadata to disks. After computer's restart
the RAID volume is in Normal state in OROM and rebuild seems to be finished.
After system's start-up RAID volume is in auto-read-only state
and metadata is in Dirty state. Rebuild seems to be finished but it is not.
Data is inconsistent (out-of-sync).

When mdmon detects the change of sync_action from 'recover' to 'idle',
it has to check if rebuild is really finished. Appropriate test was added.
Now mdmon examines each volume's member if it is being rebuilt.

Signed-off-by: Lukasz Dorau <lukasz.dorau@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
12 years agoRelax restrictions on when --add is permitted.
NeilBrown [Wed, 18 Apr 2012 04:19:49 +0000 (14:19 +1000)]
Relax restrictions on when --add is permitted.

The restriction that --add was not allowed on a device which
looked like a recent member of an array was overly harsh.

The real requirement was to avoid using --add when the array had
failed, and the device being added might contain necessary
information which can only be incorporated by stopping and
re-assembling with --force.

So change the test to reflect the need.

Reported-by: Doug Ledford <dledford@redhat.com>
Signed-off-by: NeilBrown <neilb@suse.de>
12 years agoAdd --prefer option for --detail and --monitor
NeilBrown [Wed, 18 Apr 2012 01:00:07 +0000 (11:00 +1000)]
Add --prefer option for --detail and --monitor

Both --detail and --monitor can report the names of member
devices on an array, and do so by searching /dev and finding
the shortest name that matches.

If
   --prefer=foo
is given, they will instead prefer a name that contain /foo/.
So
   mdadm --detail /dev/md0 --prefer=by-path

will list the component devices via their /dev/disk/by-path/xxx
names.

Signed-off-by: NeilBrown <neilb@suse.de>
12 years agoRaid limit of 1024 when scanning for devices.
NeilBrown [Tue, 17 Apr 2012 23:06:02 +0000 (09:06 +1000)]
Raid limit of 1024 when scanning for devices.

When we can for devices using GET_DISK_INFO we currently
limit to 1024.  But some arrays can have more than this.
So raise it to 4096 and make the constant a #define.

Signed-off-by: NeilBrown <neilb@suse.de>
12 years agoFIX: resolve make everything compilation error
Lukasz Dorau [Mon, 16 Apr 2012 14:12:55 +0000 (16:12 +0200)]
FIX: resolve make everything compilation error

When mdadm is compiled using e.g. 'everything' option, mdassemble
compilation is broken.

Change code to enable mdassemble compilation.

Signed-off-by: Lukasz Dorau <lukasz.dorau@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
12 years agoFIX: Assembled second array is in read only state during reshape
Adam Kwolek [Fri, 13 Apr 2012 14:52:08 +0000 (16:52 +0200)]
FIX: Assembled second array is in read only state during reshape

When arrays using external metadata are assembled, and one of array
in container is under reshape, second array will remain in read only
state (not auto read only). It is caused by array fact that array
is frozen and mdmon doesn't has opportunity to switch array in r/w mode.

Freezing not reshaped array just after it is being assembled allows mdmon
to enable it for writing.

Signed-off-by: Adam Kwolek <adam.kwolek@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
12 years agoFIX: Size change is possible as standalone change only
Adam Kwolek [Fri, 13 Apr 2012 14:52:07 +0000 (16:52 +0200)]
FIX: Size change is possible as standalone change only

Size change is possible as standalone change only. To make sure size change
is not requested pass '-1' as size parameter.

Signed-off-by: Adam Kwolek <adam.kwolek@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
12 years agoimsm: FIX: Component size alignment check
Adam Kwolek [Fri, 13 Apr 2012 14:52:06 +0000 (16:52 +0200)]
imsm: FIX: Component size alignment check

Put currently existing code for alignment correction in to function
imsm_component_size_aligment_check() and use it for align component size
to chunk size during volume size expansion operation.

Signed-off-by: Adam Kwolek <adam.kwolek@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
12 years agoimsm: Support setting max size for size change operation
Adam Kwolek [Fri, 13 Apr 2012 14:52:05 +0000 (16:52 +0200)]
imsm: Support setting max size for size change operation

Add support for setting max size for size change operation using
imsm_get_free_size() function for computing maximum available space.

Signed-off-by: Adam Kwolek <adam.kwolek@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
12 years agoimsm: Add function imsm_get_free_size()
Adam Kwolek [Fri, 13 Apr 2012 14:52:04 +0000 (16:52 +0200)]
imsm: Add function imsm_get_free_size()

Add function imsm_imsm_get_free_size() using part of code from function
reserve_space().

Signed-off-by: Adam Kwolek <adam.kwolek@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
12 years agoFIX: Detect error and rollback metadata
Adam Kwolek [Fri, 13 Apr 2012 14:52:03 +0000 (16:52 +0200)]
FIX: Detect error and rollback metadata

Some setting size error cases were not detected.
When error occurs, stop setting new size action and rollback metadata
changes.

Signed-off-by: Adam Kwolek <adam.kwolek@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
12 years agoFIX: Respect metadata size limitations
Adam Kwolek [Fri, 13 Apr 2012 14:52:02 +0000 (16:52 +0200)]
FIX: Respect metadata size limitations

When reshape_super() updates metadata with new size, due to some metadata
limitations saved value can be different than requested value by user.
Update size (read it from metadata) for setting it in md.

Signed-off-by: Adam Kwolek <adam.kwolek@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
12 years agoFIX: Extend size of raid0 array
Adam Kwolek [Fri, 13 Apr 2012 14:52:01 +0000 (16:52 +0200)]
FIX: Extend size of raid0 array

For raid0, takeover operation is required for size change.
Add takeover to degraded raid4 before size change and back to raid0 after.
Array information has to be read again from md after takeover.

Signed-off-by: Adam Kwolek <adam.kwolek@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
12 years agoimsm: FIX: Support metadata changes rollback
Adam Kwolek [Fri, 13 Apr 2012 14:52:00 +0000 (16:52 +0200)]
imsm: FIX: Support metadata changes rollback

Add metadata rollback specific code for imsm.
Let reshape_super() ability to differentiate metadata apply and rollback
actions.

Signed-off-by: Adam Kwolek <adam.kwolek@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
12 years agoFIX: Support metadata changes rollback
Adam Kwolek [Fri, 13 Apr 2012 14:51:59 +0000 (16:51 +0200)]
FIX: Support metadata changes rollback

Function reshape_super() guards metadata changes.
It is used to apply changes rollback in error case also.
As change (apply and rollback) can be not bi-directional reshape_super()
has to know if current action is metadata change that should be guarded
using metadata restrictions, or this is metadata rollback change
executed due to error occurrence.

In second case change has to be unconditional.

Signed-off-by: Adam Kwolek <adam.kwolek@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
12 years agoimsm: Execute size change for external metatdata
Adam Kwolek [Fri, 13 Apr 2012 14:51:58 +0000 (16:51 +0200)]
imsm: Execute size change for external metatdata

For external metatdata ioctl doesn't set new size. Set new size using sysfs.
Put code for size change in to function to re-use the same code as during
On-line Capacity Expansion

Signed-off-by: Adam Kwolek <adam.kwolek@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
12 years agoimsm: Add new metadata update for volume size expansion
Adam Kwolek [Fri, 13 Apr 2012 14:51:57 +0000 (16:51 +0200)]
imsm: Add new metadata update for volume size expansion

Add new meatdata update type imsm_update_size_change, and update metadata
for volume size expansion operation.

Signed-off-by: Adam Kwolek <adam.kwolek@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
12 years agoimsm: FIX: Add volume size expand support to imsm_analyze_change()
Adam Kwolek [Fri, 13 Apr 2012 14:51:56 +0000 (16:51 +0200)]
imsm: FIX: Add volume size expand support to imsm_analyze_change()

Patch adds ability to function imsm_analyze_change() for:
1. Detect size change request for volume operation.
2. Check and correct size for change.
3. Set new change kind to CH_ARRAY_SIZE

Signed-off-by: Adam Kwolek <adam.kwolek@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
12 years agoimsm: FIX: Update function imsm_num_data_members() for Raid1/10
Adam Kwolek [Fri, 13 Apr 2012 14:51:55 +0000 (16:51 +0200)]
imsm: FIX: Update function imsm_num_data_members() for Raid1/10

Function imsm_num_data_members() returns wrong value for raid 1 and 10.
It returns all data member but it should return number of unique data
members (excluding mirror devices)

Signed-off-by: Adam Kwolek <adam.kwolek@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
12 years agoimsm: display maximum volumes per controller and array
Labun, Marcin [Tue, 17 Apr 2012 02:30:50 +0000 (12:30 +1000)]
imsm: display maximum volumes per controller and array

Display maximum volumes per array and per controller
in --detail-platform command.

Signed-off-by: Marcin Labun <marcin.labun@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
12 years agomdadm man page: fix typo
CoolCold [Thu, 12 Apr 2012 02:11:19 +0000 (06:11 +0400)]
mdadm man page: fix typo

manpage for mdadm(8) contains typo - missing "d" at the end of "describe" word.

Signed-off-by: Roman Ovchinnikov <coolthecold@gmail.com>
Signed-off-by: NeilBrown <neilb@suse.de>
12 years agoFix two typos in fprintf messages
Lukasz Dorau [Thu, 5 Apr 2012 10:26:41 +0000 (12:26 +0200)]
Fix two typos in fprintf messages

Signed-off-by: Lukasz Dorau <lukasz.dorau@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
12 years agosuper1: leave more space in front of data by default.
NeilBrown [Wed, 4 Apr 2012 04:00:40 +0000 (14:00 +1000)]
super1: leave more space in front of data by default.

The kernel is growing the ability to avoid the need for a
backup file during reshape by being able to change the data offset.

For this to be useful we need plenty of free space before the
data so the data offset can be reduced.

So for v1.1 and v1.2 metadata make the default data_offset much
larger.  Aim for 128Meg, but keep a power of 2 and don't use more
than 0.1% of each device.

Don't change v1.0 as that is used when the data_offset is required to
be zero.

Signed-off-by: NeilBrown <neilb@suse.de>
12 years agoBitmap_offset is a signed number
NeilBrown [Wed, 4 Apr 2012 04:00:42 +0000 (14:00 +1000)]
Bitmap_offset is a signed number

As the bitmap can be before the superblock, bitmap_offset is signed.
But some of the code didn't honour that :-(

Signed-off-by: NeilBrown <neilb@suse.de>
12 years agoparse_size: distinguish between 0 and error.
NeilBrown [Tue, 3 Apr 2012 18:00:42 +0000 (04:00 +1000)]
parse_size: distinguish between 0 and error.

It isn't sufficient to use '0' for 'error' as well will
later have fields that can validly be '0'.

So return "-1" on error.

Also fix parsing of --bitmap_check so that '0' is treated
as an error: we don't support 512B anyway.

Signed-off-by: NeilBrown <neilb@suse.de>
12 years agoFix typo: wan -> want
NeilBrown [Tue, 3 Apr 2012 18:00:41 +0000 (04:00 +1000)]
Fix typo: wan -> want

Signed-off-by: NeilBrown <neilb@suse.de>
12 years agoimsm: set 2tb disk attribute for spare
Czarnowska, Anna [Mon, 2 Apr 2012 00:19:04 +0000 (10:19 +1000)]
imsm: set 2tb disk attribute for spare

This patch ensures metadata attribute is set correctly also for spares.

Signed-off-by: Anna Czarnowska <anna.czarnowska@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
12 years agocheck that no disk over 2TB is used to create container when no support
Czarnowska, Anna [Mon, 2 Apr 2012 00:18:37 +0000 (10:18 +1000)]
check that no disk over 2TB is used to create container when no support

Creation of a container using disks over 2TB should be allowed only when orom supports large disks

Signed-off-by: Anna Czarnowska <anna.czarnowska@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
12 years agocheck volume size in validate_geometry_imsm_orom
Czarnowska, Anna [Mon, 2 Apr 2012 00:17:55 +0000 (10:17 +1000)]
check volume size in validate_geometry_imsm_orom

When orom does not support volumes over 2TB the creation should be disallowed

Signed-off-by: Anna Czarnowska <anna.czarnowska@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
12 years agoshow 2TB volumes/disks support in --detail-platform
Czarnowska, Anna [Mon, 2 Apr 2012 00:17:25 +0000 (10:17 +1000)]
show 2TB volumes/disks support in --detail-platform

Signed-off-by: Anna Czarnowska <anna.czarnowska@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
12 years agosimplify calculating array_blocks
Czarnowska, Anna [Mon, 2 Apr 2012 00:16:04 +0000 (10:16 +1000)]
simplify calculating array_blocks

no point calling info_to_blocks_per_member when it just returns size*2 for level==1
calc_array_size can be used for all levels

Signed-off-by: Anna Czarnowska <anna.czarnowska@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
12 years agoclear hi bits if not used after loading metadata from disk
Czarnowska, Anna [Mon, 2 Apr 2012 00:15:08 +0000 (10:15 +1000)]
clear hi bits if not used after loading metadata from disk

Functions retrieving sizes from metadata do not need to check
2TB attribute only when we can guarantee the hi bits are always
clear when the MPB_ATTR_2TB_DISK attribute is not set.

Therefore the following fields are cleared on metadata load
when not in use according to attribute:
struct imsm_disk.total_blocks_hi
struct imsm_map.pba_of_lba0_hi
struct imsm_map.blocks_per_member_hi
struct imsm_map.num_data_stripes_hi

Signed-off-by: Anna Czarnowska <anna.czarnowska@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
12 years agoimsm: avoid overflows for disks over 1TB
Czarnowska, Anna [Mon, 2 Apr 2012 00:15:03 +0000 (10:15 +1000)]
imsm: avoid overflows for disks over 1TB

Calculating array_blocks using info->size causes error on activation of
volume using disks over 1 TB. unsigned long long size parameter
is used instead.

total_blocks, pba_of_lba0, blocks_per_member and num_data_stripes overflow
when using disks over 2TB.

Part of fillers in metadata is used to contain hi bits of the numbers
that are likely to go over 32 bit limit.
Functions are added to get and set such fields as the hi bits are not
adjacent with low bits in the structures.

Acked-by: Dan Williams <dan.j.williams@intel.com>
Signed-off-by: Anna Czarnowska <anna.czarnowska@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
12 years agosysfs: fixed sysfs_freeze_array array to work properly with Manage_subdevs.
NeilBrown [Wed, 28 Mar 2012 06:29:37 +0000 (17:29 +1100)]
sysfs: fixed sysfs_freeze_array array to work properly with Manage_subdevs.

If the array is already frozen when Manage_subdevs is called we don't
want it to unfreeze the array.
This is because Grow calls Manage_subdevs to add devices to an array
being reshaped, and the array must stay frozen over this call.

So if sysfs_freeze_array find the array to be frozen it returns '0',
meaning that it didn't and cannot freeze it.  Then the caller will not
try to unfreeze, which is good.

Signed-off-by: NeilBrown <neilb@suse.de>
12 years agoFix the new ROUND_UP macro.
NeilBrown [Thu, 22 Mar 2012 08:40:38 +0000 (19:40 +1100)]
Fix the new ROUND_UP macro.

It was missing a "- 1".

Signed-off-by: NeilBrown <neilb@suse.de>
12 years agoFix tests/05r1-re-add-nosupper
NeilBrown [Thu, 22 Mar 2012 06:30:07 +0000 (17:30 +1100)]
Fix tests/05r1-re-add-nosupper

This shouldn't have been changed when we size of RAID1
arrays was changed, as this uses 'build', not 'create'

Signed-off-by: NeilBrown <neilb@suse.de>
12 years agoGrow: print useful error when converting RAID1->RAID5 will fail.
NeilBrown [Thu, 22 Mar 2012 06:00:57 +0000 (17:00 +1100)]
Grow: print useful error when converting RAID1->RAID5 will fail.

RAID1 can only be converted to RAID0 or RAID5 if the size is
a multiple of 4K as we cannot have chunks smaller than 4K.

If this might happen, report a useful error message.

Signed-off-by: NeilBrown <neilb@suse.de>
12 years agoCreate: round off size for RAID1 arrays.
NeilBrown [Thu, 22 Mar 2012 05:53:51 +0000 (16:53 +1100)]
Create: round off size for RAID1 arrays.

RAID1 arrays don't have a chunk size, but if you ever convert
one to RAID5 you will need at least a small one >= 4K.
So round of size to a multiple of 64K.

This only affect Create, not "--grow --size=max".  The latter
is too hard and with smaller returns.

Signed-off-by: NeilBrown <neilb@suse.de>
12 years agoManage: freeze recovery while adding multiple devices.
NeilBrown [Thu, 22 Mar 2012 05:15:03 +0000 (16:15 +1100)]
Manage: freeze recovery while adding multiple devices.

If the kernel supports it, freeze recovery over multiple adds,
so that they can all be added to the array at the same time and
be recovered in parallel.

Signed-off-by: NeilBrown <neilb@suse.de>
12 years agoManage: replace 'return 1' with 'goto abort'.
NeilBrown [Thu, 22 Mar 2012 05:07:02 +0000 (16:07 +1100)]
Manage: replace 'return 1' with 'goto abort'.

This will allow exit processing in next patch

Signed-off-by: NeilBrown <neilb@suse.de>
12 years agoIncremental: fix adding devices with --incremental
NeilBrown [Thu, 22 Mar 2012 04:53:53 +0000 (15:53 +1100)]
Incremental: fix adding devices with --incremental

We should use 'info' here, not 'info2'.
info2 refers to some other device (There may not even be one).l
info is *this* disk.

This is particularly important for getting info.disk.state
correct, which the kernel depends on to get 're-add' functionality
correct.

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