]> git.ipfire.org Git - thirdparty/mdadm.git/log
thirdparty/mdadm.git
13 years agoAssemble: call remove_partitions later.
NeilBrown [Tue, 30 Nov 2010 05:56:01 +0000 (16:56 +1100)] 
Assemble: call remove_partitions later.

We shouldn't call remove_partitions until we have made a really firm
decision to include the device into the array.

Signed-off-by: NeilBrown <neilb@suse.de>
13 years agomdmon: don't copy an invalid chunk_size
NeilBrown [Tue, 30 Nov 2010 07:35:36 +0000 (18:35 +1100)] 
mdmon: don't copy an invalid chunk_size

As chunk_size in mdstat_ent is never set, we shouldn't copy
it into a->info.array.
In fact, it is safest to get rid of the field altogether.

Reported-by: "Kwolek, Adam" <adam.kwolek@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
13 years agoddf: fail creation of new subarray with same name as old.
NeilBrown [Tue, 30 Nov 2010 22:55:35 +0000 (09:55 +1100)] 
ddf: fail creation of new subarray with same name as old.

Signed-off-by: NeilBrown <neilb@suse.de>
13 years agoCreate: report failure if array cannot be started.
NeilBrown [Wed, 1 Dec 2010 00:03:28 +0000 (11:03 +1100)] 
Create: report failure if array cannot be started.

We weren't checking the result of writing 'active' to array_state

Signed-off-by: NeilBrown <neilb@suse.de>
13 years agoGrow: disallow placing backup file on array being reshaped.
NeilBrown [Wed, 1 Dec 2010 00:58:32 +0000 (11:58 +1100)] 
Grow: disallow placing backup file on array being reshaped.

the tests here aren't perfect, but they could catch some cases.

Signed-off-by: NeilBrown <neilb@suse.de>
13 years agoCreate/grow: improve checks on number of devices.
NeilBrown [Wed, 1 Dec 2010 03:51:27 +0000 (14:51 +1100)] 
Create/grow: improve checks on number of devices.

Check on upper limit of number of devices was in the wrong place.
Result was could not create array with more than 27 devices without
explicitly setting metadata, even though default metadata allows more.

Fixed, and also perform check when growing an array.

Signed-off-by: NeilBrown <neilb@suse.de>
13 years agoerror check reading of 'degraded' from sysfs.
NeilBrown [Thu, 20 Jan 2011 21:59:00 +0000 (08:59 +1100)] 
error check reading of 'degraded' from sysfs.

I'm seen mdadm spinning while failing to read 'degraded'.
This doesn't really fix it, but is a reminder that it needs to be
fixed.

Signed-off-by: NeilBrown <neilb@suse.de>
13 years agoFIX: Reset disk state if disk is missing
Krzysztof Wojcik [Thu, 10 Mar 2011 06:07:04 +0000 (17:07 +1100)] 
FIX: Reset disk state if disk is missing

If we can't read actual disk state, it shoud be initiated
to 0.
Overwise it may be out of date value resulting false action
later in code (e.g. set disk to improper state).

Signed-off-by: Krzysztof Wojcik <krzysztof.wojcik@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
13 years agoopen_mddev: open RDONLY if RDWR doesn't work.
NeilBrown [Thu, 10 Mar 2011 06:07:04 +0000 (17:07 +1100)] 
open_mddev: open RDONLY if RDWR doesn't work.

If an array is read-only then "mdadm -S"
cannot open it to stop it without this fix.

Signed-off-by: NeilBrown <neilb@suse.de>
13 years agoInitialise all of file when opening backup file for reshape.
NeilBrown [Thu, 10 Mar 2011 06:06:59 +0000 (17:06 +1100)] 
Initialise all of file when opening backup file for reshape.

Due to a miscalculation we didn't initialise the whole file.
There is 4K (8 sectors) for the metadata, then the data.

Signed-off-by: NeilBrown <neilb@suse.de>
13 years agomdadm.man add encouragement to shrink filesystem before shrinking array.
NeilBrown [Tue, 15 Feb 2011 01:40:21 +0000 (12:40 +1100)] 
mdadm.man add encouragement to shrink filesystem before shrinking array.

Before resizing an array with --size or --array-size, then filesystem
should be resized.  mdadm cannot do this so the user should.

Reported-by: Gavin Flower <gavinflower@yahoo.com>
Signed-off-by: NeilBrown <neilb@suse.de>
13 years agoDetail: report subarrays of a container properly.
NeilBrown [Wed, 9 Mar 2011 07:22:27 +0000 (18:22 +1100)] 
Detail: report subarrays of a container properly.

Due to the wrong variable being used, this part of --detail
wasn't working at all.

Signed-off-by: NeilBrown <neilb@suse.de>
13 years agodev_open should always open read-only.
NeilBrown [Thu, 10 Mar 2011 00:41:21 +0000 (11:41 +1100)] 
dev_open should always open read-only.

When opening an array to manipulate it we never need to write to the
array and  sometimes it might be read-only so the open for write will
fail.
So always open read-only.

Reported-by: Adam Kwolek <adam.kwolek@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
13 years agoddf: exclude failed devices from container_content
NeilBrown [Wed, 2 Mar 2011 22:04:42 +0000 (09:04 +1100)] 
ddf: exclude failed devices from container_content

If a device is failed, then don't include it in the reported
container_content, else it might get included in the array.

Reported-by: Albert Pauw <albert.pauw@gmail.com>
Signed-off-by: NeilBrown <neilb@suse.de>
13 years agomdadm.man: remove duplicate documentation for --array-size
NeilBrown [Wed, 2 Mar 2011 00:34:49 +0000 (11:34 +1100)] 
mdadm.man: remove duplicate documentation for --array-size

We somehow got to version of documentation for --array-size.
So merge them it one.

Reported-by: Ville Skyttä <ville.skytta@iki.fi>
Signed-off-by: NeilBrown <neilb@suse.de>
13 years agoFIX: ReadMe.c -Y option missing in short_options
Albert Pauw [Sun, 27 Feb 2011 04:56:54 +0000 (15:56 +1100)] 
FIX: ReadMe.c -Y option missing in short_options

Hi Neil,

I noticed that the -Y option, as in mdadm -D -Y /dev/md0, doesn't work
but used as --export it works.

So I made a little patch to fix it, but it is simply sticking a Y in the
list of short_options in ReadMe.c.

Signed-off-by: NeilBrown <neilb@suse.de>
13 years agoTeach --assemble --force to handle reshapes a little better.
NeilBrown [Mon, 21 Feb 2011 00:41:01 +0000 (11:41 +1100)] 
Teach --assemble --force to handle reshapes a little better.

When we force-assemble an array which is in the middle of a reshape,
we should repeat the reshape of any parts that aren't recorded in
the oldest superblock.

This is unlikely to make a significant difference, but could make
a small difference, and is safer.

Signed-off-by: NeilBrown <neilb@suse.de>
13 years agoFix regression with removing 'failed' and 'detached' devices.
NeilBrown [Mon, 14 Feb 2011 23:45:01 +0000 (10:45 +1100)] 
Fix regression with removing 'failed' and 'detached' devices.

If a request to remove all 'failed' or 'detached' devices chooses to
remove the first device, it will not actually try the removal and will
skip any following devices.

This fixes it.

Reported-by: Rémi Rérolle <rrerolle@lacie.com>
Tested-by: Rémi Rérolle <rrerolle@lacie.com>
Signed-off-by: NeilBrown <neilb@suse.de>
13 years agofix extended partition detection
Dan Williams [Tue, 25 Jan 2011 02:54:06 +0000 (18:54 -0800)] 
fix extended partition detection

# mdadm --detail --export /dev/md127p1

Before:
MD_LEVEL=raid5
MD_DEVICES=4
MD_METADATA=0.90

After:
MD_LEVEL=raid5
MD_DEVICES=4
MD_CONTAINER=/dev/md0
MD_MEMBER=0
MD_UUID=55746a20:925d24a7:4f9bd7e2:9c9a411f

We parse the symlink target with a format:

../../block/mdXXX/mdXXXpYY

...and need the second '/' from the end of the string to read detect a
'md' device.

Reported-by: Krzysztof Wasilewski <krzysztof.wasilewski@intel.com>
Cc: Przemyslaw Czarnowski <przemyslaw.hawrylewicz.czarnowski@intel.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
13 years agosegfault in imsm create with wrong arguments
Luca Berra [Sun, 12 Dec 2010 10:33:55 +0000 (11:33 +0100)] 
segfault in imsm create with wrong arguments

When calling mdadm -C --metadata=imsm -l 1 /dev/sd..
mdadm segfaults in default_chunk_imsm()
above syntax is incorrect, but mdadm should error instead of segfaulting

Signed-off-by: Luca Berra <bluca@comedia.it>
Signed-off-by: NeilBrown <neilb@suse.de>
13 years agomdadm.8: man page improvements concerning reshape and metadata types.
John Robinson [Wed, 3 Nov 2010 03:08:00 +0000 (23:08 -0400)] 
mdadm.8: man page improvements concerning reshape and metadata types.

- other differences between 0.90 and 1.x metadata explained
- reshape text enhanced to properly acknowledge shrinks and in-place
  reshapes, particularly in the context of --backup-file.

Signed-off-by: NeilBrown <neilb@suse.de>
13 years agoFix byte-order conversion in update_super1("assemble")
NeilBrown [Thu, 16 Sep 2010 10:58:31 +0000 (20:58 +1000)] 
Fix byte-order conversion in update_super1("assemble")

This code is wrong is several ways, and failed on big-endian machines.
Put in correct endian coversions: 'want' is cpu-order, dev_roles[] is little-endian,
16 bit.

Reported-by: Doug Nazar <nazard.michi@gmail.com>
Signed-off-by: NeilBrown <neilb@suse.de>
13 years agoFix compile error on non-x86 systems.
NeilBrown [Fri, 3 Sep 2010 03:33:29 +0000 (13:33 +1000)] 
Fix compile error on non-x86 systems.

-z is not an option for 'gcc', it is an option for the loader!!

Reported-by: Debian build system
Signed-off-by: NeilBrown <neilb@suse.de>
13 years agoRelease mdadm-3.1.4 mdadm-3.1.4
NeilBrown [Tue, 31 Aug 2010 05:41:12 +0000 (15:41 +1000)] 
Release mdadm-3.1.4

bugfix/stability.

Signed-off-by: NeilBrown <neilb@suse.de>
13 years agoFix spare migration.
NeilBrown [Tue, 31 Aug 2010 07:20:58 +0000 (17:20 +1000)] 
Fix spare migration.

Spare migration uses major:minor device names.
When we added support for kernel style names, we broke that.

Signed-off-by: NeilBrown <neilb@suse.de>
13 years agoDon't remove md devices with standard names.
NeilBrown [Tue, 31 Aug 2010 05:21:40 +0000 (15:21 +1000)] 
Don't remove md devices with standard names.

If udev is not in use, we create device in /dev when assembling
arrays and remove them when stopping the array.

However it may not always be correct to remove the device.  If
the array was started with kernel auto-detect, them mdadm didn't
create anything and so shouldn't remove anything.

We don't record whether we created things, so just don't remove
anything with a 'standard' name.  Only remove symlinks to the
standard name as we almost certainly created those.

Reported-by: Petre Rodan <petre.rodan@avira.com>
Signed-off-by: NeilBrown <neilb@suse.de>
13 years agoAllow dev_open to work on read-only /dev
NeilBrown [Sun, 29 Aug 2010 22:48:48 +0000 (08:48 +1000)] 
Allow dev_open to work on read-only /dev

/dev could be read-only in which case we cannot make devices
there.
So dev_open should first try to use an existing device name,
and if that doesn't work try creating a node in /dev or /tmp.

Reported-by: Paweł Sikora <pluto@agmk.net>
Signed-off-by: NeilBrown <neilb@suse.de>
13 years agoAllow --incremental to add spares to an array.
NeilBrown [Thu, 12 Aug 2010 01:41:41 +0000 (11:41 +1000)] 
Allow --incremental to add spares to an array.

Commit 3a6ec29ad56 stopped us from adding apparently-working devices
to an active array with --incremental as there is a good chance that they
are actually old/failed devices.

Unfortunately it also stopped spares from being added to an active
array, which is wrong.  This patch refines the test to be more
careful.

Reported-by: <fibreraid@gmail.com>
Analysed-by: Dan Williams <dan.j.williams@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
13 years agoIncremental: accept '--no-degraded' as a deprecated option
Dan Williams [Mon, 9 Aug 2010 17:26:24 +0000 (10:26 -0700)] 
Incremental: accept '--no-degraded' as a deprecated option

Commit 3288b419 (Revert "Incremental: honor --no-degraded to delay assembly")
killed the --no-degraded flag since commit 97b4d0e9 (Incremental: honor
an 'enough' flag from external handlers) made this the default behavior
of -I, and brought -I usage for external/container formats in line with
native metadata.  However, this breaks existing usages of '-I
--no-degraded', so allow it as a deprecated option.

Starting a degraded container, like the native metadata case, requires -R.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
Reported-by: Ignacy Kasperowicz <ignacy.kasperowicz@intel.com>
13 years agoIncremental: return success in 'container not enough' case
Dan Williams [Tue, 10 Aug 2010 15:44:45 +0000 (08:44 -0700)] 
Incremental: return success in 'container not enough' case

Commit 97b4d0e9 "Incremental: honor an 'enough' flag from external
handlers" introduced a regression in that it changed the error return
code for successful invocations.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
Reported-by: Ignacy Kasperowicz <ignacy.kasperowicz@intel.com>
13 years agoDon't link mdadm with pthreads
NeilBrown [Fri, 6 Aug 2010 10:11:43 +0000 (20:11 +1000)] 
Don't link mdadm with pthreads

Only mdmon needs pthreads, so link accordingly.

Signed-off-by: NeilBrown <neilb@suse.de>
Reported-by: martin f krafft <madduck@madduck.net>
13 years agoFix compiler warning concering bad use of snprintf.
NeilBrown [Fri, 6 Aug 2010 10:10:48 +0000 (20:10 +1000)] 
Fix compiler warning concering bad use of snprintf.

Signed-off-by: NeilBrown <neilb@suse.de>
Reported-by: Mikael Abrahamsson <swmike@swm.pp.se>
13 years agoRelease mdadm-3.1.3 mdadm-3.1.3
NeilBrown [Fri, 6 Aug 2010 06:55:23 +0000 (16:55 +1000)] 
Release mdadm-3.1.3

Signed-off-by: NeilBrown <neilb@suse.de>
13 years agomapfile: just have one place to store the mapfile
NeilBrown [Fri, 6 Aug 2010 04:54:10 +0000 (14:54 +1000)] 
mapfile: just have one place to store the mapfile

Having multiple possible locations and guessing where best to put the
file is too messy, confusing and makes locking problematic.

So just keep it in /dev/.mdadm/map.  It is a horrible place but it is
really all we have.  System integrators can change this easily at
build time.

Signed-off-by: NeilBrown <neilb@suse.de>
13 years agoGrow: use raid_disks, not nr_disks
NeilBrown [Fri, 6 Aug 2010 04:40:53 +0000 (14:40 +1000)] 
Grow: use raid_disks, not nr_disks

nr_disks is just wrong here - the arrays need room for all disk slots,
even if some are empty, plus spares, plus a possible backup file.
So raid_disks is correct.

Signed-off-by: NeilBrown <neilb@suse.de>
13 years agoFix writing of second backup superblock during grow
NeilBrown [Thu, 5 Aug 2010 11:39:17 +0000 (21:39 +1000)] 
Fix writing of second backup superblock during grow

There 'rv' tests were confused and sometimes wrong.
This resulted in not writing the second bsb.

Also fix the test script so the the critical section is long enough
that we have some hope of interrupting it.

Signed-off-by: NeilBrown <neilb@suse.de>
13 years agoudevadm settle in autodetect test
NeilBrown [Thu, 5 Aug 2010 06:50:03 +0000 (16:50 +1000)] 
udevadm settle in autodetect test

some udev activity was interfering with the partitioning.

Signed-off-by: NeilBrown <neilb@suse.de>
13 years agoCompile with -Wextra by default
NeilBrown [Thu, 5 Aug 2010 03:13:02 +0000 (13:13 +1000)] 
Compile with -Wextra by default

This produced lots of warning, some of which pointed to actual bugs.

Signed-off-by: NeilBrown <neilb@suse.de>
13 years agoDetail: clean up handing of the 'info' we load from superblock.
NeilBrown [Thu, 5 Aug 2010 02:10:57 +0000 (12:10 +1000)] 
Detail: clean up handing of the 'info' we load from superblock.

The loop for loading it was hard to follow, so restructure that
and avoid a theoretical use-before-set error.

Also there was a second 'info' structure which hid the first and was
pointless.

Signed-off-by: NeilBrown <neilb@suse.de>
13 years agoFix test for imsm prodigal member scenario
NeilBrown [Thu, 5 Aug 2010 01:44:26 +0000 (11:44 +1000)] 
Fix test for imsm prodigal member scenario

The 'container_enough' changes fliped the default from assembling
an array as soon as we possibly could, to assembling only when all
expected devices are present.
This broken 09imsm-assemble which expects the original default.
So change from "-I" to "-IR" to restore the expected behaviour.

Signed-off-by: NeilBrown <neilb@suse.de>
13 years agoFix tests/layouts
NeilBrown [Thu, 29 Jul 2010 04:20:35 +0000 (14:20 +1000)] 
Fix tests/layouts

some attributes files now return "new (old)", so allow for that when
reading the attr file.

Signed-off-by: NeilBrown <neilb@suse.de>
13 years agoFix restarting of reshaping arrays.
NeilBrown [Thu, 29 Jul 2010 03:50:15 +0000 (13:50 +1000)] 
Fix restarting of reshaping arrays.

We cannot get stripe_cache_size until after the array have
been activated!!

Signed-off-by: NeilBrown <neilb@suse.de>
13 years agoRestore assembling of ddf containers.
NeilBrown [Thu, 29 Jul 2010 03:26:26 +0000 (13:26 +1000)] 
Restore assembling of ddf containers.

The container_enough code change broke ddf as ddf never claimed
'enough' devices.  So change it to always claim 'enough' to
restore previous behaviour.

Signed-off-by: NeilBrown <neilb@suse.de>
13 years agoFix use of rv in Grow_reshape
NeilBrown [Thu, 29 Jul 2010 03:16:01 +0000 (13:16 +1000)] 
Fix use of rv in Grow_reshape

1/ and extra local var was declared, which causes rv setting
   to be lost
2/ a -ve rv was left -ve while we should be return 1 on err.

Signed-off-by: NeilBrown <neilb@suse.de>
13 years agoSome fixes to the mapfile code.
NeilBrown [Wed, 28 Jul 2010 07:24:13 +0000 (17:24 +1000)] 
Some fixes to the mapfile code.

- Update the comments
- use some defined names instead of magic numbers.
- restore /var/run/mdadm/map to have priority over /dev/.mdadm/map

Signed-off-by: NeilBrown <neilb@suse.de>
13 years agoUpdate man page info about files used by mdmon
NeilBrown [Wed, 28 Jul 2010 07:12:35 +0000 (17:12 +1000)] 
Update man page info about files used by mdmon

A recent patch changed the location of files used by
mdmon, so update man page to match.

Signed-off-by: NeilBrown <neilb@suse.de>
13 years agoSwitch from /lib/init/rw to /dev for early-boot files.
NeilBrown [Wed, 28 Jul 2010 07:04:42 +0000 (17:04 +1000)] 
Switch from /lib/init/rw to /dev for early-boot files.

It turns out that /lib/init/rw doesn't exist in early boot
like I thought.  So give up on that idea and just use
/dev/.mdadm/ for files that must persist from early-boot
to regular boot.

Signed-off-by: NeilBrown <neilb@suse.de>
13 years agoBugfix: mapfile locking is broken/racy
NeilBrown [Wed, 28 Jul 2010 07:40:54 +0000 (17:40 +1000)] 
Bugfix: mapfile locking is broken/racy

While we attempt to use a lockfile to grant exclusive access to the
mapfile, our implementation is buggy.  Specifically, we create a lockfile,
then lock it, at which point new instances can open the lockfile and
attempt to lock it, which will cause them to block.  However, when we are
ready to unlock it, we unlink the file.  This causes existing lock waiters
to get a lock on an unlinked inode while a different instance may now
create a new lockfile and get an exclusive lock on it.

There are several possible fixes.  The chosen one is to test if
->s_nlink is zero after we get the lock and to retry if it isn't.
This means:
  - failing to unlink a file doesn't leave a stale lock
  - we can block waiting to get a lock rather than busy-waiting
  - we don't need to leave a lock file permanently in place.

Reported-by: Doug Ledford <dledford@redhat.com>
Signed-off-by: NeilBrown <neilb@suse.de>
13 years agoAdd warnings if we ever fail to get a lock on the mapfile.
Doug Ledford [Tue, 20 Jul 2010 21:42:26 +0000 (17:42 -0400)] 
Add warnings if we ever fail to get a lock on the mapfile.

Signed-off-by: Doug Ledford <dledford@redhat.com>
13 years agoBugfix: don't issue a read larger than the buffer to hold it
Doug Ledford [Tue, 20 Jul 2010 21:35:27 +0000 (17:35 -0400)] 
Bugfix: don't issue a read larger than the buffer to hold it

Signed-off-by: Doug Ledford <dledford@redhat.com>
13 years agoudev rules: add watch option
Doug Ledford [Tue, 20 Jul 2010 16:18:12 +0000 (12:18 -0400)] 
udev rules: add watch option

The watch option to udev tells udev to watch our mdadm device file for
close events and on a close it rechecks the device.  This means that if,
for example, we use mdadm to --grow the array from a 4 disk to 5 disk
array, when mdadm closes the array, udev will re-read the superblock and
update its internal database with the new information.  This can also be
used to cause udev to create new device special files if, for example, a
partitioning program is used to modify the partition table on the actual
md device and that program does not call the syscall to reread the
partition table.

Signed-off-by: Doug Ledford <dledford@redhat.com>
13 years agoTwo Minor bug fixes to incremental support
Doug Ledford [Tue, 20 Jul 2010 16:17:20 +0000 (12:17 -0400)] 
Two Minor bug fixes to incremental support

One: a single character typo (of instead of or in an error printout)
Two: Audited usage of tfd file descriptor.  Make sure that the tfd file
is always closed after usage, and that the tfd variable is reset to -1
if we are going to continue in our loop (not necessary if we know we
will return from our function without going through the dv loop again).

Signed-off-by: Doug Ledford <dledford@redhat.com>
13 years agoFix all the confusion over directories once and for all.
Doug Ledford [Tue, 20 Jul 2010 16:15:37 +0000 (12:15 -0400)] 
Fix all the confusion over directories once and for all.

We now have 3 directory definitions: mdmon directory for its pid and
sock files (compile time define, not changable at run time), mdmonitor
directory which is for the mdadm monitor mode pid file (can only be
passed in via command line at the time mdadm is invoked in monitor mode),
and the directory for the mdadm incremental assembly map file (compile
time define, not changable at run time).  Only the mdadm map file still
hunts multiple locations, and the number of locations has been reduced
to /var/run and the compile time specified location.  Re-use of similar
sounding defines that actually didn't denote their actual usage at
compile time made it more difficult for a person to know what affect
changing the compile time defines would have on the resulting programs.

This patch renames the various defines to clearly identify which item
the define affects.  It also reduces the number of various directories
which will be searched for these files as this has lead to confusion
in mdadm and mdmon in terms of which files should take precedence when
files exist in multiple locations, etc.  It's best if the person
compiling the program intentionally and with planning selects the
right directories to be used for the various purposes.  Which directory
is right depends on which items you are talking about and what boot
loader your system uses and what initramfs generation program your
system uses.  Because of the inter-dependency of all these items it
would typically be up to the distribution that mdadm is being integrated
into to select the correct values for these defines.

Signed-off-by: Doug Ledford <dledford@redhat.com>
13 years agoMerge branch 'master' of git://github.com/djbw/mdadm
NeilBrown [Thu, 22 Jul 2010 07:43:35 +0000 (17:43 +1000)] 
Merge branch 'master' of git://github.com/djbw/mdadm

13 years agoDon't report Used Dev Size for RAID0.
NeilBrown [Thu, 22 Jul 2010 05:45:18 +0000 (15:45 +1000)] 
Don't report Used Dev Size for RAID0.

This number isn't meaningful for RAID0 as a different amount of space
might be used from each device.
It isn't meaningful for linear either, but already was not reported
for linear.
Detail doesn't report it either.
So make --examine not report it.

Signed-off-by: NeilBrown <neilb@suse.de>
Reported-by: Mario 'BitKoenig' Holbe <Mario.Holbe@TU-Ilmenau.DE>
13 years agoCast to long long before left-shifting too much.
NeilBrown [Thu, 22 Jul 2010 05:28:15 +0000 (15:28 +1000)] 
Cast to long long before left-shifting too much.

When left-shifting we must be sure that the value being
shifted is large enough to not lose bits.
The 'chunkssize' in CreateBitmap is only 'long' so it
can overflow.  So cast to 'long long' first.

Also fix a similar issue in Detail even though it isn't currently
being compiled.

Signed-off-by: NeilBrown <neilb@suse.de>
Reported-by: Tomasz Chmielewski <mangoo@wpkg.org>
13 years agoIncremental: restore assembly for inactive containers, block active
Dan Williams [Mon, 19 Jul 2010 21:59:25 +0000 (14:59 -0700)] 
Incremental: restore assembly for inactive containers, block active

GET_ARRAY_INFO always succeeds on an inactive container, so we need to
be a bit more diligent about adding a disk to an active container.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
13 years agosuper-0.90: don't write bitmap larger than 60K
NeilBrown [Wed, 7 Jul 2010 11:09:23 +0000 (21:09 +1000)] 
super-0.90: don't write bitmap larger than 60K

The 4K superblock can be as close as 64K from the end
of the device.  As the bitmap (with header) lives after
the superblock (with 0.90 metadata) there could be as
little as 60K of space.
So limit the bitmaps to 59.5K, and only write 60K including
the header.

The bug fixed here means that bitmaps cannot be created
on devices which are exact multiples of 64K in size

Signed-off-by: NeilBrown <neilb@suse.de>
13 years agoImprove --re-add documentation
NeilBrown [Wed, 7 Jul 2010 03:35:07 +0000 (13:35 +1000)] 
Improve --re-add documentation

and add the fact that --test can now be used with --manage
operations.

Signed-off-by: NeilBrown <neilb@suse.de>
13 years agoimsm: fix a -O2 build warning
Dan Williams [Tue, 6 Jul 2010 19:48:59 +0000 (12:48 -0700)] 
imsm: fix a -O2 build warning

super-intel.c: In function ‘imsm_add_spare’:
super-intel.c:4833: error: ‘array_start’ may be used uninitialized in this function
super-intel.c:4834: error: ‘array_end’ may be used uninitialized in this function

This is valid, if we don't find a spare candidate then array_{start,end}
will be uninitialized.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
13 years agomdmon: satisfy glibc tls abi requirements with pthreads
Dan Williams [Tue, 6 Jul 2010 19:48:56 +0000 (12:48 -0700)] 
mdmon: satisfy glibc tls abi requirements with pthreads

Setting up a proper tls descriptor is required to conform to the abi
[1].  Until it can be implemented in mdmon use pthreads instead of
clone(2) to let glibc handle the details.  The old behaviour can be had
by un-defining USE_PTHREADS.

Note, the "O2" builds need LDFLAGS now to pick up the '-pthread' option.

[1]: http://people.redhat.com/drepper/tls.pdf

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
13 years agoFix the count of member devices in mdstat_read function.
Marcin Labun [Tue, 6 Jul 2010 07:49:37 +0000 (17:49 +1000)] 
Fix the count of member devices in mdstat_read function.

Correction of the number of container or volume member devices (devcnt
in struct mdstat_ent). The number after the last devices was counted
towards member of devices.

Signed-off-by: Marcin Labun <marcin.labun@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
13 years agofix: IncrementalRemove leaves open handle
Przemyslaw Czarnowski [Tue, 6 Jul 2010 06:47:02 +0000 (16:47 +1000)] 
fix: IncrementalRemove leaves open handle

Signed-off-by: Przemyslaw Czarnowski <przemyslaw.hawrylewicz.czarnowski@intel.com<mailto:przemyslaw.hawrylewicz.czarnowski@intel.com>>
13 years agoMerge branch 'master' of git://github.com/djbw/mdadm
NeilBrown [Tue, 6 Jul 2010 04:46:47 +0000 (14:46 +1000)] 
Merge branch 'master' of git://github.com/djbw/mdadm

13 years agoAdd --test option to --re-add and similar
NeilBrown [Tue, 6 Jul 2010 01:46:04 +0000 (11:46 +1000)] 
Add --test option to --re-add and similar

--test can be given in Manage mode.
This can be used when there is an attempt to fail or remove 'faulty',
'failed' or 'detached' devices, or to re-add 'missing' devices.
If no devices were failed, removed, or re-added, then mdadm will
exit with status '2'.

Signed-off-by: NeilBrown <neilb@suse.de>
13 years agoAdd support for "--re-add missing"
NeilBrown [Mon, 5 Jul 2010 05:06:27 +0000 (15:06 +1000)] 
Add support for "--re-add missing"

If the device name "missing" is given for --re-add, then mdadm will
attempt to find any device which should be a member of the array but
currently isn't and will --re-add it to the array.
This can be useful if a device disappeared due to a cabling problem,
and was then re-connected.
The appropriate sequence would be
  mdadm /dev/mdX --fail detached
  mdadm /dev/mdX --remove detached
  mdadm /dev/mdX --re-add missing

Signed-off-by: NeilBrown <neilb@suse.de>
13 years agoDon't let incremental add devices to active arrays.
NeilBrown [Tue, 6 Jul 2010 02:04:40 +0000 (12:04 +1000)] 
Don't let incremental add devices to active arrays.

Adding devices to active arrays in --incremental is a bit dubious.

Normally the array won't be activated until all expected devices are
present, so this situation would mean that the given device is not
expected, so is probably failed.  In that case it should only be added
by explicit sysadmin request.

However if --run was given, then quite possibly the array was
assembled earlier when not complete, so it is less clear whether it is
wrong to add this device or not.  In that case add it as that is
generally safest.

It would be nice to allow policy for this to be explicitly given by
sysadmin.

Signed-off-by: NeilBrown <neilb@suse.de>
13 years agoAssemble: Fix honouring of 'auto' config line
NeilBrown [Tue, 6 Jul 2010 01:57:09 +0000 (11:57 +1000)] 
Assemble: Fix honouring of 'auto' config line

commit 1ff98339283645a20c980d540f6c4d82693e7daf
broke the checking of metadata types via the 'auto' line.

Be moving 'load_super" before "conf_test_metadata" we left
tst->sb set even if conf_test_metadata fails, so the device will
actually be accepted and used.

So if we decide to reject the device, free the superblock so it is
clear that it is rejected.

Signed-off-by: NeilBrown <neilb@suse.de>
13 years agoMerge branch 'fixes' into for-neil
Dan Williams [Fri, 2 Jul 2010 00:36:11 +0000 (17:36 -0700)] 
Merge branch 'fixes' into for-neil

13 years agoMerge branch 'subarray' into for-neil
Dan Williams [Fri, 2 Jul 2010 00:36:05 +0000 (17:36 -0700)] 
Merge branch 'subarray' into for-neil

Conflicts:
mdadm.h
super-intel.c

13 years agomdmon: prevent allocations due to late binding
Dan Williams [Fri, 2 Jul 2010 00:28:14 +0000 (17:28 -0700)] 
mdmon: prevent allocations due to late binding

Current versions of glibc do not provide a useable interface to clone(2) as it
inflicts hidden dependencies on setting up a glibc specific tls
descriptor.  The dynamic linker trips this dependency and causes mdmon
to intermittently fail to load.  Resolving all dynamic linking prior to
starting the monitor thread appears to mitigate the issue but there is no
guarantee that another tls dependency will bite us later.

However, while the debate continues with the glibc maintainers it seems
prudent to keep this change.  It ensures that we do not get into a
situation where the monitor thread needs to make a late allocation to
resolve a symbol.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
13 years agoAvoid skipping devices where removing all faulty/detached devices.
NeilBrown [Wed, 30 Jun 2010 07:20:38 +0000 (17:20 +1000)] 
Avoid skipping devices where removing all faulty/detached devices.

When using 0.90 metadata, devices can be renumbered when
earlier devices are removed.
So when iterating all devices looking for 'failed' or 'detached'
devices, we need to re-check the same slot we checked last time
to see if maybe it has a different device now.

Reported-by: Jim Paris <jim@jtan.com>
Resolves-Debian-Bug: 587550
Signed-off-by: NeilBrown <neilb@suse.de>
13 years agoUpdate udev rules for hotplug support.
NeilBrown [Wed, 30 Jun 2010 06:55:17 +0000 (16:55 +1000)] 
Update udev rules for hotplug support.

- split the rules for handling components of array to be clearly
  separate from rules for handling the arrays themselves.
- add call to "-If" when removing a device
- uncomment the --incremental call when adding a device.

Signed-off-by: NeilBrown <neilb@suse.de>
13 years agoAdd -fail support to --incremental
NeilBrown [Wed, 30 Jun 2010 06:55:17 +0000 (16:55 +1000)] 
Add -fail support to --incremental

This can be used for hot-unplug.  When a device has been remove,
udev can call
   mdadm --incremental --fail sda

and mdadm will find the array holding sda and remove sda from
the array.

Based on code from  Doug Ledford <dledford@redhat.com>

Signed-off-by: NeilBrown <neilb@suse.de>
13 years agoSupport fail/remove using kernel name
NeilBrown [Wed, 30 Jun 2010 06:55:17 +0000 (16:55 +1000)] 
Support fail/remove using kernel name

Allow kernel names like "sda" and "hdb1" to be used to
fail/remove devices from an array.

This is useful as after a device has been removed it can be difficult
to get the major/minor number.

Signed-off-by: NeilBrown <neilb@suse.de>
13 years agoAdd mdstat_by_component
NeilBrown [Wed, 30 Jun 2010 06:55:17 +0000 (16:55 +1000)] 
Add mdstat_by_component

This allows finding the array which contains a given component.
Components are named using the kernel-internal string name such
as "sda1" or "hdb".
Don't return member arrays, only the contain that contains them.

Also tidy up the parsing of 'inactive' arrays in /proc/mdstat.
If we see 'inactive' we need to set 'in_devs' immediately as there
is no level coming.

Signed-off-by: NeilBrown <neilb@suse.de>
13 years agoCorrect documentation for --rebuild-map
NeilBrown [Wed, 30 Jun 2010 06:52:54 +0000 (16:52 +1000)] 
Correct documentation for --rebuild-map

In some places it is referred to as "--rebuild", and while
that works due to getopt allowing prefixes, it could appear
confusing (rebuild means other things too) and being explicit
is some safeguard if we want to add e.g. --rebuild-foo later.

Reported-by: Doug Ledford <dledford@redhat.com>
Signed-off-by: NeilBrown <neilb@suse.de>
13 years agoFix parsing of inactive arrays in /proc/mdstat
Jeff DeFouw [Tue, 29 Jun 2010 06:42:48 +0000 (16:42 +1000)] 
Fix parsing of inactive arrays in /proc/mdstat

They don't have a level, so we should not expect one, and should
expect devices instead.

Signed-off-by: NeilBrown <neilb@suse.de>
13 years agoRename subarray v2
Dan Williams [Tue, 22 Jun 2010 23:30:59 +0000 (16:30 -0700)] 
Rename subarray v2

Allow the name of the array stored in the metadata to be updated.  In
some cases the metadata format may not be able to support this rename
without modifying the UUID.  In these cases the request will be blocked.
Otherwise we allow the rename to take place, even for active arrays.
This assumes that the user understands the difference between the kernel
node name, the device node symlink name, and the metadata specific name.

Anticipating further need to modify subarrays in-place, introduce the
->update_subarray() superswitch method.  A future potential use
case is setting storage pool (spare-group) identifiers.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
13 years agoCreate: fix typo in RAID10 default layout message.
NeilBrown [Thu, 17 Jun 2010 10:17:10 +0000 (20:17 +1000)] 
Create: fix typo in RAID10 default layout message.

It reports "layout defaults to n1" but it means "... to n2".

Reported-by: Adrian Sandor <aditsu@yahoo.com>
Signed-off-by: NeilBrown <neilb@suse.de>
13 years agoAlways assume SKIP_GONE_DEVS behaviour and kill the flag
Dan Williams [Thu, 17 Jun 2010 00:26:04 +0000 (17:26 -0700)] 
Always assume SKIP_GONE_DEVS behaviour and kill the flag

...i.e. GET_DEVS == (GET_DEVS|SKIP_GONE_DEVS)

A null pointer dereference in Incremental.c can be triggered by
replugging a disk while the old name is in use.  When mdadm -I is called
on the new disk we fail the call to sysfs_read().  I audited all the
locations that use GET_DEVS and it appears they can tolerate missing a
drive.  So just make SKIP_GONE_DEVS the default behaviour.

Also fix up remaining unchecked usages of the sysfs_read() return value.

Reported-by: Dave Jiang <dave.jiang@intel.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
13 years agoRemove 'checkpointing' side effect of --wait-clean
Dan Williams [Wed, 16 Jun 2010 01:41:57 +0000 (18:41 -0700)] 
Remove 'checkpointing' side effect of --wait-clean

Now that mdmon records periodic checkpoints, and checkpoints every
->set_array_state() event we no longer need to 'idle' sync_action from
--wait-clean.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
13 years agomdmon: record sync_completed directly to the metadata
Dan Williams [Wed, 16 Jun 2010 01:41:57 +0000 (18:41 -0700)] 
mdmon: record sync_completed directly to the metadata

When sync_action is idle mdmon takes the latest value of md/resync_start
or md/<dev>/recovery_start to record the resync/rebuild checkpoint in
the metadata.  However, now that mdmon is reading sync_completed there
is no longer a need to wait for, or force an idle event to take a
checkpoint.

Simply update the forward progress of ->last_checkpoint at every wakeup
event and force it to be recorded at least every 1/16th array-size
interval.  It may be recorded more frequently if a ->set_array_state()
event occurs.

This also cleans up some confusion in handling the dual-rebuild case.
If more than one spare has been activated the kernel starts the rebuild
at the lowest recovery offset, so we do not need to worry about
min_recovery_start().

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
13 years agoimsm: dump each disk's view of the slot state
Dan Williams [Wed, 16 Jun 2010 01:41:57 +0000 (18:41 -0700)] 
imsm: dump each disk's view of the slot state

Allow --examine to determine which disk might have a stale view of the
per-disk out-of-sync state.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
13 years agocreate: Check with OROM limit before setting default chunk size
Dave Jiang [Wed, 16 Jun 2010 01:41:53 +0000 (18:41 -0700)] 
create: Check with OROM limit before setting default chunk size

Make create check with the appropriate meta data handler and see what the
largest chunk size is supported. The current 512K default is not supported
by existing imsm OROM.

[dan.j.williams@intel.com: trim the upper limit to 512k for future oroms]
Signed-off-by: Dave Jiang <dave.jiang@intel.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
13 years agoKill subarray v2
Dan Williams [Wed, 16 Jun 2010 00:55:41 +0000 (17:55 -0700)] 
Kill subarray v2

Support for deleting a subarray out of a container.  When all subarrays
are deleted the component devices are converted back into spares, a
--zero-superblock is still needed to kill the remaining metadata at this
point.  This operation is blocked when the subarray is active and may
also be blocked by the metadata handler when deleting the subarray might
change the uuid of other active subarrays.  For example, with imsm,
deleting subarray 'n' may change the uuid of subarrays with indexes > n.

Deleting a subarray needs to be a container wide event to ensure
disks that record the modified subarray list perceive other disks that
did not receive this change as out of date.

Notes:
The st->subarray parsing in super-intel.c and super-ddf.c is updated to
be more strict now that we are reading user supplied subarray values.

Offline container modification shares actions that mdmon typically
handles so promote is_container_member() and version_to_superswitch()
(formerly find_metadata_methods()) to generic utility functions for the
cases where mdadm performs the operation.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
13 years agomdadm.conf: fix AUTO typo
NeilBrown [Fri, 4 Jun 2010 22:02:11 +0000 (08:02 +1000)] 
mdadm.conf: fix AUTO typo

Reported-by: Marc Schiffbauer <marc@schiffbauer.net>
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
13 years agoFix man page reference to --level changes with --grow.
NeilBrown [Mon, 31 May 2010 02:51:51 +0000 (12:51 +1000)] 
Fix man page reference to --level changes with --grow.

--level can be used with --grow now, so correct man page.

Reported-by: "Leslie Rhorer" <lrhorer@satx.rr.com>
Signed-off-by: NeilBrown <neilb@suse.de>
13 years agoCompile-time switch to enable 0.9 metadata as default
martin f. krafft [Fri, 28 May 2010 12:12:41 +0000 (14:12 +0200)] 
Compile-time switch to enable 0.9 metadata as default

This commit introduces DEFAULT_OLD_METADATA as a preprocessor
definition. If defined, it causes mdadm to assume metadata version 0.9
as default. If not defined, version 1.x (currently 1.2) is used as
default.

The man page mdadm.8 is also modified to reflect the chosen default.

The selftests will not work if the old default is chosen.

This patch was requested by Debian so they could distribute a current
mdadm together with boot loaders that only understand 0.90 metadata
for md-raid.

Preferred usage is simply
   make DEFAULT_OLD_METADATA=yes

Signed-off-by: martin f. krafft <madduck@debian.org>
Signed-off-by: NeilBrown <neilb@suse.de>
13 years agoRevert change to handling of -empty-string- metadata.
NeilBrown [Mon, 31 May 2010 02:08:02 +0000 (12:08 +1000)] 
Revert change to handling of -empty-string- metadata.

If the metadata is an empty string, it means the array in question
does not use metadata.  This comes from sysfs_read finding "none" in
"metadata_version", then super_by_fd noticing the vers == -1, and so
just using the ->text_version (which is empty).

In this case we want to use the super0 metadata handler routines
because that is what we always used to do before

 commit 7d5c3964ccfaace123f7b75e15d38c2650e013d8

And that commit was wrong because "" doesn't mean "default" and so
should not have been changed at the same time.

Reported-by: martin f. krafft <madduck@debian.org>
Signed-off-by: NeilBrown <neilb@suse.de>
13 years agoMerge commit '3288b419b988b20a53a2b12eb8e5f9f536228db4'; commit '4363fd80bcc9f85ed824...
NeilBrown [Mon, 31 May 2010 01:34:14 +0000 (11:34 +1000)] 
Merge commit '3288b419b988b20a53a2b12eb8e5f9f536228db4'; commit '4363fd80bcc9f85ed824228dee5e6350a8d73e18'; commit '63b4aae33ebf00d443378daf313622630f2336c0'

* commit '3288b419b988b20a53a2b12eb8e5f9f536228db4':
  Revert "Incremental: honor --no-degraded to delay assembly"
  Incremental: honor an 'enough' flag from external handlers

* commit '4363fd80bcc9f85ed824228dee5e6350a8d73e18':
  imsm: robustify recovery-start detection
  fix: memory leak in mdmon_pid()

* commit '63b4aae33ebf00d443378daf313622630f2336c0':
  mdmon: fix missing open of md/<dev>/recovery_start

13 years agoimsm: robustify recovery-start detection
Dan Williams [Wed, 26 May 2010 20:33:43 +0000 (13:33 -0700)] 
imsm: robustify recovery-start detection

update_recovery_start() assumed that the out-of-sync disk would always be
marked as IMSM_ORD_REBUILD in the disk_ord_tbl, but the segmentation
fault reported by Andy proves otherwise.  This might also be explained by
an interrupted rebuild and the disk has not yet been marked missing.

https://bugzilla.redhat.com/show_bug.cgi?id=592030

Reported-by: Andy Lutomirski <luto@mit.edu>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
13 years agoRevert "Incremental: honor --no-degraded to delay assembly"
Dan Williams [Wed, 26 May 2010 20:25:47 +0000 (13:25 -0700)] 
Revert "Incremental: honor --no-degraded to delay assembly"

This reverts commit fdb482f99b9ad2ef8cd1724902fdfeedaa8796a1.

Now that containers can report state for ->container_enough we can
automatically determine when the array can be started, and no longer
need the --no-degraded hammer.

Conflicts:

Incremental.c

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
13 years agoIncremental: honor an 'enough' flag from external handlers
Dan Williams [Wed, 26 May 2010 20:22:36 +0000 (13:22 -0700)] 
Incremental: honor an 'enough' flag from external handlers

This is needed for imsm where:
1/ we want to report raid_disks as zero to allow mdadm -As to
   incorporate all spares
2/ we can't determine stale disks by looking at the event counts.
3/ we can't see per-subarray expectations with the info returned from
   the container level ->getinfo_super()

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
13 years agoMonitor: don't report the disappearance of a faulty device as SpareActive.
NeilBrown [Tue, 18 May 2010 02:31:29 +0000 (12:31 +1000)] 
Monitor: don't report the disappearance of a faulty device as SpareActive.

Normally Monitor doesn't see faulty devices in active slots - they get
moved away too quickly.
But if it does, it reports the "faulty device disappeared" event (when
it finally does get moved away) as SpareActive due to insufficient
checking.

So add a better check.

Reported-by: Pierre Vignéras <pierre@vigneras.name>
13 years agoGrow: move error message closer to error cause.
NeilBrown [Tue, 18 May 2010 02:29:28 +0000 (12:29 +1000)] 
Grow: move error message closer to error cause.

A recent change move the sysfs_read call away from the check that it
succeeded.  This patch moves the check back next to the sysfs_read
call.

Signed-off-by: NeilBrown <neilb@suse.de>
13 years agofix: memory leak in mdmon_pid()
Przemyslaw Hawrylewicz Czarnowski [Thu, 22 Apr 2010 22:10:32 +0000 (23:10 +0100)] 
fix: memory leak in mdmon_pid()

devnum2devname() returns pointer to memory allocated with strdup.
It must be released to prevent memory leak.

Signed-off-by: Przemyslaw Czarnowski <przemyslaw.hawrylewicz.czarnowski@intel.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
13 years agomdmon: periodically checkpoint recovery
Dan Williams [Sat, 15 May 2010 00:42:49 +0000 (17:42 -0700)] 
mdmon: periodically checkpoint recovery

The kernel updates and notifies md/sync_completed when it is time to
take a checkpoint.  When this occurs (at 1/16 array size intervals)
write 'idle' to md/sync_action to have the current recovery position
updated in recovery_start and resync_start.

Requires the metadata handler to reset ->last_checkpoint when it has
determined that recovery has ended.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
14 years agomdmon: fix missing open of md/<dev>/recovery_start
Dan Williams [Thu, 29 Apr 2010 17:50:29 +0000 (10:50 -0700)] 
mdmon: fix missing open of md/<dev>/recovery_start

When activating a spare we neglect to open recovery_start and as such do
not see checkpoint events.  Move disk initialization to common routine
to mitigate recurrence.

Reported-by: Adam Kwolek <adam.kwolek@intel.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
14 years agoGrow: avoid overflow of chunk sizes.
NeilBrown [Thu, 29 Apr 2010 06:14:30 +0000 (16:14 +1000)] 
Grow: avoid overflow of chunk sizes.

Chunks aren't particularly big, but when you could them in bytes
and multiply them together (as we do for calculating the backup
size for 'grow') they can overflow a 32bit int.

So group the division by 512 more closely with the
chunk size so were would need 30Meg chunks to come close to
overflowing 32bits.

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