thirdparty/mdadm.git
10 years agoHaving single function to read mdmon pid file.
NeilBrown [Thu, 4 Feb 2010 05:47:21 +0000 (16:47 +1100)] 
Having single function to read mdmon pid file.

We don't need three.
One (signal_mdmon) wasn't even being used.

Signed-off-by: NeilBrown <neilb@suse.de>
10 years agomdmon: discard test_pidfile()
NeilBrown [Thu, 4 Feb 2010 03:49:32 +0000 (14:49 +1100)] 
mdmon: discard test_pidfile()

devname2mdmon() can be used just as easily and doing so saves us from
some duplicate code.
Also tidy up some related logic.

Signed-off-by: NeilBrown <neilb@suse.de>
10 years agomdmon: don't mkdir /var/run
NeilBrown [Fri, 29 Jan 2010 01:20:11 +0000 (12:20 +1100)] 
mdmon: don't mkdir /var/run

Creating /var/run in mdmon is really not justifiable.

If /var/run doesn't exist, then it is either deliberate and it should
be left that way to make sure the mapfile gets created in /dev, or
it is a configuration error and not our problem to fix.

Signed-off-by: NeilBrown <neilb@suse.de>
10 years agomdmon: improve switchroot handling.
NeilBrown [Fri, 29 Jan 2010 01:14:17 +0000 (12:14 +1100)] 
mdmon: improve switchroot handling.

The change to get mdmon to re-exec itself from the switchroot
filesystem broken switchroot in various ways.  This fixes it.

If the switchroot path is not '/', mdmon will find the pid and
socket for the monitor, chroot to the new root, and exec mdmon
passing the pid in argv[2] and the socket in stdin.

If the switchroot path is actually a number, mdmon will not chroot,
but will kill that pid before taking over the array.

Signed-off-by: NeilBrown <neilb@suse.de>
10 years agomdmon: simplify try_kill_monitor
NeilBrown [Fri, 29 Jan 2010 00:33:01 +0000 (11:33 +1100)] 
mdmon: simplify try_kill_monitor

After we SIGTERM the monitor we need to wait for it to finish up.
Rather than the complexity of waiting for every md array to be clean,
we can simply read from the sock connected to the monitor.
When the monitor dies, we will get EOF.  Before then we will block.

Signed-off-by: NeilBrown <neilb@suse.de>
10 years agomdmon: remove scan variable from mdmon()
NeilBrown [Thu, 28 Jan 2010 23:40:07 +0000 (10:40 +1100)] 
mdmon: remove scan variable from mdmon()

It is redundant as each place that it is used, it can only
have one possible value.
Also change the related arg to mdmon() to have a more meaningful
name.
And make mdmon() static.

Signed-off-by: NeilBrown <neilb@suse.de>
10 years agoAssemble: fix --force assembly of v1.x arrays which are recovering.
NeilBrown [Thu, 4 Feb 2010 01:02:09 +0000 (12:02 +1100)] 
Assemble: fix --force assembly of v1.x arrays which are recovering.

1.x metadata allows a device to be a member of the array while it
is still recoverying.  So it is a working member, but is not
completely in-sync.

mdadm/assemble does not understand this distinction and assumes that a
work member is fully in-sync for the purpose of determining if there
are enough in-sync devices for the array to be functional.

So collect the 'recovery_start' value from the metadata and use it in
assemble when determining how useful a given device is.

Reported-by: Mikael Abrahamsson <swmike@swm.pp.se>
Signed-off-by: NeilBrown <neilb@suse.de>
10 years agoCreate: Improve warning message about booting from v1.x
NeilBrown [Sun, 31 Jan 2010 23:37:58 +0000 (10:37 +1100)] 
Create: Improve warning message about booting from v1.x

Suggesting that if your boot loaded doesn't support v1.x, then use
  --metadata=1.0
doesn't make a lot of sense.
Also, '/', isn't really important, it is /boot that matters.
Hopefully people who have /boot on '/' realise that /boot is
on '/' ....

Signed-off-by: NeilBrown <neilb@suse.de>
10 years agoAdd test for "are we running as root".
NeilBrown [Sun, 31 Jan 2010 23:22:38 +0000 (10:22 +1100)] 
Add test for "are we running as root".

Most operations require root access.  Rather than ensure we generate
the right error message when something fails because we aren't root,
check early.
Note that "--examine" does not necessarily require root, so test
for that first.

Resolves-Debian-bug: 396570
Signed-off-by: NeilBrown <neilb@suse.de>
10 years agosuper-intel.c: use %zu specifier for printf of size_t
Luca Berra [Sat, 30 Jan 2010 09:59:29 +0000 (10:59 +0100)] 
super-intel.c: use %zu specifier for printf of size_t

Fix compile warning when size_t is not a long.

Acked-by: Dan Williams <dan.j.williams@intel.com>
Signed-off-by: Luca Berra <bluca@vodka.it>
Signed-off-by: NeilBrown <neilb@suse.de>
10 years agomdadm-3.1.1 segfaults when mdadm -G -Z is used.
Luca Berra [Sat, 30 Jan 2010 09:56:11 +0000 (10:56 +0100)] 
mdadm-3.1.1 segfaults when mdadm -G -Z is used.

Signed-off-by: Luca Berra <bluca@vodka.it>
Signed-off-by: NeilBrown <neilb@suse.de>
10 years agoKill: fix when zeroing busy devices.
Artur Wojcik [Thu, 28 Jan 2010 15:48:44 +0000 (16:48 +0100)] 
Kill: fix when zeroing busy devices.

mdadm should not wait indefinitely when it trys to reset
superblock on device which is busy (cannot be opened).

Acked-by: Andre Noll <maan@systemlinux.org>
Signed-off-by: Artur Wojcik <artur.wojcik@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
10 years agomapfile: fix locking.
NeilBrown [Fri, 29 Jan 2010 05:20:08 +0000 (16:20 +1100)] 
mapfile: fix locking.

The current locking uses lockf, and is completely broken.
When you hold a lockf lock, any close of any fd on that file will
release the lock.  So map_read() call which is made as soon as we get
the lock, will immediately drop the lock.

So change to flock locking which isn't so badly designed.

Signed-off-by: NeilBrown <neilb@suse.de>
10 years agoDetail: Report state of FAILED when an array has too few devices to work.
NeilBrown [Fri, 29 Jan 2010 04:45:36 +0000 (15:45 +1100)] 
Detail:  Report state of FAILED when an array has too few devices to work.

We already have a call to 'enough' in Detail which is the check for
"do we have enough devices".  We just need to calculate the required
data a bit earlier, then use the same 'enough' call to possibly
print FAILED.

This is motivated by Debian bug 495755.
The other request in that bug is not practical.

    It would be very nice if output of `mdadm' is more clear in case of a
    broken array.

    Currently the only hint you get from `mdadm' that your array is broken
    is this:

    # mdadm -A /dev/md0 /dev/sdc1 /dev/sdd1 /dev/sde1 /dev/sdf1
    mdadm: /dev/md0 assembled from 1 drive and 3 spares - not enough to start the
    array.

    It could say something like `Your array is broken, you can't use it anymore'

It is not valid to report that array as 'broken' if the user hasn't
listed all the devices, which could be the case here.

Resolves-Debian-Bug: 495755
Signed-off-by: NeilBrown <neilb@suse.de>
10 years agoTidy up some argument parsing, particularly for -b
NeilBrown [Fri, 29 Jan 2010 03:54:55 +0000 (14:54 +1100)] 
Tidy up some argument parsing, particularly for -b

-b only means --brief in MISC mode, elsewhere it is --bitmap.

Resolves-debian-bug: 427777
Signed-off-by: NeilBrown <neilb@suse.de>
10 years agomd.4: various improvements to new section on scrubbing.
NeilBrown [Thu, 28 Jan 2010 23:21:56 +0000 (10:21 +1100)] 
md.4: various improvements to new section on scrubbing.

Signed-off-by: NeilBrown <neilb@suse.de>
10 years agomdmon: fix fd leak and possible buffer overrun.
NeilBrown [Thu, 28 Jan 2010 23:15:15 +0000 (10:15 +1100)] 
mdmon: fix fd leak and possible buffer overrun.

We normally wouldn't close 'fd', and as 'buf' might not have
had a nul, strstr could have overrun it.

Signed-off-by: NeilBrown <neilb@suse.de>
10 years agoCorrectly parse -N command line option.
NeilBrown [Thu, 28 Jan 2010 05:55:28 +0000 (16:55 +1100)] 
Correctly parse -N command line option.

'N' wasn't listed in the sort options, so you
had to use --name :-)

Resolved-Debian-Bug: 564004
Signed-off-by: NeilBrown <neilb@suse.de>
10 years agomd.4: add section on scrubbing and mismatch counts.
NeilBrown [Thu, 28 Jan 2010 02:09:58 +0000 (13:09 +1100)] 
md.4: add section on scrubbing and mismatch counts.

This relates to debian bug 405919

Signed-off-by: NeilBrown <neilb@suse.de>
10 years agoGrow: If bitmap interferes with grow, report this.
NeilBrown [Thu, 28 Jan 2010 00:48:03 +0000 (11:48 +1100)] 
Grow: If bitmap interferes with grow, report this.

If a bitmap exists on an array, then current kernels cannot grow
that array.
So when we try to grow an array, test for EBUSY and if a bitmap is
present, report that the bitmap needs to be removed.

Resolves-Debian-Bug: 534571
Signed-off-by: NeilBrown <neilb@suse.de>
10 years agoAssemble: error-check ->load_super
NeilBrown [Wed, 27 Jan 2010 22:01:36 +0000 (09:01 +1100)] 
Assemble: error-check ->load_super

Once load_super has succeeded, it should continue to succeed.  However
devices can disappear etc so it is prudent to always check the return
status of load_super.

Signed-off-by: NeilBrown <neilb@suse.de>
10 years agoRemove stray debugging printfs
NeilBrown [Wed, 27 Jan 2010 21:55:18 +0000 (08:55 +1100)] 
Remove stray debugging printfs

These were never supposed to be released, and due
to a type issue they cause compile problems on
some architectures.

Resolves-Debian-Bug: 567167
Signed-off-by: NeilBrown <neilb@suse.de>
10 years agoFix segfault when the AUTO keyword is used in the config file
Doug Ledford [Mon, 11 Jan 2010 20:38:14 +0000 (15:38 -0500)] 
Fix segfault when the AUTO keyword is used in the config file

Signed-off-by: Doug Ledford <dledford@redhat.com>
Signed-off-by: NeilBrown <neilb@suse.de>
10 years agoDon't use %02d as a metadata format specifier for metadata numbers.
Doug Ledford [Mon, 11 Jan 2010 20:38:12 +0000 (15:38 -0500)] 
Don't use %02d as a metadata format specifier for metadata numbers.

It confuses us when we read the output back later

Signed-off-by: Doug Ledford <dledford@redhat.com>
Signed-off-by: NeilBrown <neilb@suse.de>
10 years agoMake the IMSM_DEVNAME_AS_SERIAL option work when creating containers.
Doug Ledford [Mon, 11 Jan 2010 20:38:10 +0000 (15:38 -0500)] 
Make the IMSM_DEVNAME_AS_SERIAL option work when creating containers.

This allows a person to testing using loopback devices that don't
support serial number queries.

Signed-off-by: Doug Ledford <dledford@redhat.com>
Signed-off-by: NeilBrown <neilb@suse.de>
10 years agoDocument validity of --assume-clean when all devices are zeroed.
Michael Evan [Thu, 10 Dec 2009 05:52:18 +0000 (21:52 -0800)] 
Document validity of --assume-clean when all devices are zeroed.

>>
>> When I assemble an array I tend to have checked the devices before
>> hand; it would not be difficult to make the final pass a zeroing pass
>> if I knew I could vastly speed up post-assembly performance. ¬†As I
>> stated, it's merely a lack of clarity in the documentation.
>
> If you would like to create a patch against the man page, I would be happy to
> accept it.
>
> NeilBrown

Signed-off-by: NeilBrown <neilb@suse.de>
10 years agoMerge branch 'klockwork' of git://github.com/djbw/mdadm
NeilBrown [Wed, 30 Dec 2009 02:46:52 +0000 (13:46 +1100)] 
Merge branch 'klockwork' of git://github.com/djbw/mdadm

Conflicts:
super-intel.c

10 years agoMerge branch 'master' of git://github.com/djbw/mdadm
NeilBrown [Wed, 30 Dec 2009 02:42:37 +0000 (13:42 +1100)] 
Merge branch 'master' of git://github.com/djbw/mdadm

10 years agoDDF: fix incorrect header magic number.
NeilBrown [Wed, 30 Dec 2009 02:42:27 +0000 (13:42 +1100)] 
DDF: fix incorrect header magic number.

I was using the wrong magic number when creating an array.

Signed-off-by: NeilBrown <neilb@suse.de>
10 years agoimsm: add support for checkpointing via 'curr_migr_unit'
Dan Williams [Tue, 22 Dec 2009 00:54:32 +0000 (17:54 -0700)] 
imsm: add support for checkpointing via 'curr_migr_unit'

Unlike native md checkpointing some data about the geometry and type of
the migration process is coded into curr_migr_unit.  Provide logic to
convert between md/{resync_start|recovery_start} and imsm/curr_migr_unit.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
10 years agoSupport external metadata recovery-resume
Dan Williams [Mon, 21 Dec 2009 19:51:57 +0000 (12:51 -0700)] 
Support external metadata recovery-resume

Minimal changes needed to permit reassembling partially recovered
external metadata arrays.  The biggest logical change is that
->container_content() can now surface partially rebuilt members rather
than omitting them from the disk list.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
10 years agoTeach sysfs_add_disk() callers to use ->recovery_start versus 'insync' parameter
Dan Williams [Mon, 21 Dec 2009 18:26:21 +0000 (11:26 -0700)] 
Teach sysfs_add_disk() callers to use ->recovery_start versus 'insync' parameter

Also fixup 'in_sync' versus 'insync' typo.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
10 years agoIntroduce MaxSector
Dan Williams [Mon, 21 Dec 2009 17:23:26 +0000 (10:23 -0700)] 
Introduce MaxSector

Replace occurrences of ~0ULL to make it clear we are talking about maximal
resync/recovery position.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
10 years agoAdd scaffolding for handling md/dev-XXX/recovery_start
Dan Williams [Mon, 21 Dec 2009 17:06:14 +0000 (10:06 -0700)] 
Add scaffolding for handling md/dev-XXX/recovery_start

Prepare the code to handle saving a recovery checkpoint.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
10 years agomdmon: cleanup resync_start
Dan Williams [Mon, 14 Dec 2009 19:57:55 +0000 (12:57 -0700)] 
mdmon: cleanup resync_start

We don't need to sprinkle reads of this attribute all over the place,
just once at the entry of read_and_act().  Also, the mdinfo structure
for the array already has a 'resync_start' member, so just reuse that.
Finally, rename get_resync_start() to read_resync_start to make it
consistent with the other sysfs accessors in monitor.c.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
10 years agomdmon: cleanup manage_member() leak
Dan Williams [Sat, 12 Dec 2009 21:10:01 +0000 (14:10 -0700)] 
mdmon: cleanup manage_member() leak

free() the results of activate_spare().

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
10 years agoimsm: cleanup print_imsm_dev()
Dan Williams [Sat, 12 Dec 2009 20:57:28 +0000 (13:57 -0700)] 
imsm: cleanup print_imsm_dev()

When printing the migration state there is no need to print "migrating".
The fact that the state is non-idle should be enough indication.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
10 years agoutil: fix devnum2devname for devnum == 0
Dan Williams [Sat, 12 Dec 2009 20:57:28 +0000 (13:57 -0700)] 
util: fix devnum2devname for devnum == 0

devnum 0 is md0 no md_d-1

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
10 years agoimsm: fix thunderdome segfault
Dan Williams [Sat, 12 Dec 2009 20:57:25 +0000 (13:57 -0700)] 
imsm: fix thunderdome segfault

disk_list_get() can return NULL if:
1/ A formerly missing disk is re-added
2/ The original array has not been rebuilt, so the family number of the
   missing disk still matches
3/ The metadata record of the in-sync disks are read before the missing
   disk

This will result in the missing disk not adding its own serial number to
the disk_list, only its truncated value will be present.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
10 years agoimsm: fix spare promotion
Dan Williams [Thu, 10 Dec 2009 22:03:34 +0000 (15:03 -0700)] 
imsm: fix spare promotion

When associating a spare take on the target's metadata version number to
satisfy future compare_super checks.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
10 years agoimsm: honor orom constraints for auto-layout
Dan Williams [Thu, 10 Dec 2009 22:03:31 +0000 (15:03 -0700)] 
imsm: honor orom constraints for auto-layout

Factor out the orom checking bits to validate_geometry_imsm_orom() and
share it between validate_geometry_imsm_volume() and the entry path to
reserve_space().

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
10 years agoimsm: prune dead code in validate_geometry_imsm
Dan Williams [Thu, 10 Dec 2009 19:03:40 +0000 (12:03 -0700)] 
imsm: prune dead code in validate_geometry_imsm

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
10 years agoFix required to enable RAID arrays on SAS disks.
Artur Wojcik [Thu, 10 Dec 2009 19:03:40 +0000 (12:03 -0700)] 
Fix required to enable RAID arrays on SAS disks.

The patch increases the capacity of buffers used to store
sysfs path names. Originally the buffers were too small to
hold the canonical representation of sysfs path (in case
of a SAS device, especially a device installed behind an
expander).

Signed-off-by: Artur Wojcik <artur.wojcik@intel.com>
Reviewed-by: Andre Noll <maan@systemlinux.org>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
10 years agoFix for resource leak on error path.
Artur Wojcik [Thu, 10 Dec 2009 19:03:40 +0000 (12:03 -0700)] 
Fix for resource leak on error path.

Make sure opened file descriptors are cleaned up
in the exit path when error occured.

Signed-off-by: Artur Wojcik <artur.wojcik@intel.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
10 years agoFix for buffer overflow defect.
Artur Wojcik [Thu, 10 Dec 2009 19:03:40 +0000 (12:03 -0700)] 
Fix for buffer overflow defect.

Array index of 'path' may be out of bounds. Array
'path' of size 256 may use index value(s) 0..284.

Signed-off-by: Artur Wojcik <artur.wojcik@intel.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
10 years agoFix for buffer overflow error.
Artur Wojcik [Thu, 10 Dec 2009 19:03:40 +0000 (12:03 -0700)] 
Fix for buffer overflow error.

Array index of 'device' may be out of bounds. Array 'device'
of size 40 may use index value(s) 0..43.

Signed-off-by: Artur Wojcik <artur.wojcik@intel.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
10 years agoFix for memory leak defect.
Artur Wojcik [Thu, 10 Dec 2009 19:03:40 +0000 (12:03 -0700)] 
Fix for memory leak defect.

Possible memory leak. Dynamic memory stored in 'dev' and 'dev' allocated
through function 'malloc' can be lost on exit path.

Signed-off-by: Artur Wojcik <artur.wojcik@intel.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
10 years agoFix for memory leak defect.
Artur Wojcik [Thu, 10 Dec 2009 19:03:40 +0000 (12:03 -0700)] 
Fix for memory leak defect.

Possible memory leak. Dynamic memory stored in 'sra' allocated through
function 'sysfs_read' at line 2484 can be lost at lines 2491, 2560 and
2571.

Signed-off-by: Artur Wojcik <artur.wojcik@intel.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
10 years agoFix for memory leak defect.
Artur Wojcik [Thu, 10 Dec 2009 19:03:40 +0000 (12:03 -0700)] 
Fix for memory leak defect.

Dynamic memory stored in 'devnum2devname(st->container_dev)' allocated
through function 'devnum2devname' at line 1274 is lost at line 1278.

Signed-off-by: Artur Wojcik <artur.wojcik@intel.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
10 years agoFix for NULL pointer dereference defect.
Artur Wojcik [Thu, 10 Dec 2009 19:03:40 +0000 (12:03 -0700)] 
Fix for NULL pointer dereference defect.

Pointer 'c' returned from call to function 'strchr' at line 954 may
be NULL and will be dereferenced at line 955.

Signed-off-by: Artur Wojcik <artur.wojcik@intel.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
10 years agoFix for NULL pointer dereference defect.
Artur Wojcik [Thu, 10 Dec 2009 19:03:40 +0000 (12:03 -0700)] 
Fix for NULL pointer dereference defect.

Pointer 'disk' returned from call to function '_get_imsm_disk' at line
700 may be NULL and will be dereferenced at line 710.

Signed-off-by: Artur Wojcik <artur.wojcik@intel.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
10 years agoFix for NULL pointer dereference defect.
Artur Wojcik [Thu, 10 Dec 2009 19:03:39 +0000 (12:03 -0700)] 
Fix for NULL pointer dereference defect.

Pointer 'st' returned from call to function 'malloc' at line 320 may
be NULL and it will be dereferenced at line 321.

Signed-off-by: Artur Wojcik <artur.wojcik@intel.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
10 years agoimsm: no need to report the component device name from container_content
Dan Williams [Thu, 10 Dec 2009 19:03:39 +0000 (12:03 -0700)] 
imsm: no need to report the component device name from container_content

sysfs_add_disk() regenerates the name from major:minor, so we can drop a
strcpy that the static analysis checker does not like.

Reported-by: Artur Wojcik <artur.wojcik@intel.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
10 years agoFix for buffer overflow defect.
Artur Wojcik [Thu, 10 Dec 2009 19:03:39 +0000 (12:03 -0700)] 
Fix for buffer overflow defect.

Buffer overflow, array index of 'nm' may be out of bounds.

Signed-off-by: Artur Wojcik <artur.wojcik@intel.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
10 years agoFix for NULL pointer dereference.
Artur Wojcik [Thu, 10 Dec 2009 19:03:39 +0000 (12:03 -0700)] 
Fix for NULL pointer dereference.

Pointers '_dev' and '_disk' returned from call to function '_get_imsm_dev'
and '_get_imsm_disk' may be NULL and will be dereferenced at lines
2933 and 2934, respectively.

Signed-off-by: Artur Wojcik <artur.wojcik@intel.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
10 years agoFix for NULL pointer dereference.
Artur Wojcik [Thu, 10 Dec 2009 19:03:39 +0000 (12:03 -0700)] 
Fix for NULL pointer dereference.

Suspicious dereference of pointer 'super' before NULL check at
line 3429.

Signed-off-by: Artur Wojcik <artur.wojcik@intel.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
10 years agoFix for memory and resource leak.
Artur Wojcik [Thu, 10 Dec 2009 19:03:39 +0000 (12:03 -0700)] 
Fix for memory and resource leak.

Make sure opened file descriptor is cleaned up on exit
path. Also make sure allocated memory for 'sra' is released
on exit path, too.

Signed-off-by: Artur Wojcik <artur.wojcik@intel.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
10 years agoFix for possible NULL pointer dereference.
Artur Wojcik [Thu, 10 Dec 2009 19:03:37 +0000 (12:03 -0700)] 
Fix for possible NULL pointer dereference.

Pointer 'this' returned from call to function 'malloc' at line 3795
may be NULL and will be dereferenced at line 3796.

Artur Wojcik <artur.wojcik@intel.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
10 years agoFix for buffer overflow defect in 'link'.
Artur Wojcik [Thu, 10 Dec 2009 18:52:23 +0000 (11:52 -0700)] 
Fix for buffer overflow defect in 'link'.

Potential buffer overflow of 'link' caused by user input may occur,
due to non null-terminated string 'link'.

Signed-off-by: Artur Wojcik <artur.wojcik@intel.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
10 years agoDon't attempt a re-add if the device is marked as faulty.
NeilBrown [Tue, 8 Dec 2009 06:26:31 +0000 (17:26 +1100)] 
Don't attempt a re-add if the device is marked as faulty.

If a device is marked as faulty, then a re-add will cause it to be
added as a faulty drive, which is not what it wanted.
So just refuse to try to re-add a device which is marked 'faulty'.

Signed-off-by: NeilBrown <neilb@suse.de>
10 years agoCheck partition tables when creating array.
Trela, Maciej [Tue, 8 Dec 2009 05:07:47 +0000 (16:07 +1100)] 
Check partition tables when creating array.

When creating an array, check if the devices have partition
tables and print a warning if the table or the partitions might be
destroyed by array creation.

Signed-off-by: NeilBrown <neilb@suse.de>
10 years agoimsm: catch attempt to auto-layout zero-length arrays
Dan Williams [Tue, 1 Dec 2009 23:04:06 +0000 (16:04 -0700)] 
imsm: catch attempt to auto-layout zero-length arrays

When -z is omitted reserve_space() looks to satisfy a zero length
allocation which lo and behold is equal to the amount of free space on a
full disk.  So, catch maxsize == 0 and simplify the return value from
merge_extents() to always equal amount of free space (no benefit to
having a special case ~0ULL == error).

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
10 years agoGrow: be more careful when using array.size
NeilBrown [Thu, 26 Nov 2009 05:28:35 +0000 (16:28 +1100)] 
Grow: be more careful when using array.size

As array.size is 32bit we need to prefer the 'component_size'
read from sysfs when that is available.
Grow wasn't always suitably careful.

Signed-off-by: NeilBrown <neilb@suse.de>
10 years agoGrow: avoid truncation error when checking size of array.
NeilBrown [Thu, 26 Nov 2009 03:19:26 +0000 (14:19 +1100)] 
Grow: avoid truncation error when checking size of array.

array.size is only 32bit so it is not safe to multiply it
up before casting to (long long).
Actually, we shouldn't be using array.size here at all, but that
will get fixed in a subsequent patch.

Reported-by: Andrew Burgess <aab@cichlid.com>
Signed-off-by: NeilBrown <neilb@suse.de>
10 years agoVarious fixes for --kill
NeilBrown [Tue, 24 Nov 2009 05:32:01 +0000 (16:32 +1100)] 
Various fixes for --kill

- When --kill-superblock is used with --metadata, find every
  different superblock if there are several and kill them all.
- When creating a new array, kill off any old metadata.  The code
  to do this was already present but has become broken over time.

Signed-off-by: NeilBrown <neilb@suse.de>
10 years agoRelease mdadm-3.1.1 devel-3.1 mdadm-3.1.1
NeilBrown [Thu, 19 Nov 2009 05:10:58 +0000 (16:10 +1100)] 
Release mdadm-3.1.1

bugfix over 3.1, but changes to some significant defaults.

10 years agoMerge branch 'master' into devel-3.1
NeilBrown [Thu, 19 Nov 2009 05:10:07 +0000 (16:10 +1100)] 
Merge branch 'master' into devel-3.1

10 years agoAssemble: fix testing of 'verbose' flag.
NeilBrown [Thu, 19 Nov 2009 04:55:59 +0000 (15:55 +1100)] 
Assemble: fix testing of 'verbose' flag.

The 'verbose' flag can be negative, meaning 'quiet'.
So never check for != 0.

Signed-off-by: NeilBrown <neilb@suse.de>
10 years agoCreate: warn when creating a raid1 using default metadata.
NeilBrown [Thu, 19 Nov 2009 04:54:49 +0000 (15:54 +1100)] 
Create: warn when creating a raid1 using default metadata.

As a some/most bootloaders don't understand md metadata, it might
be difficult to boot off an array with the default 1.0 metadata.
So if this is used for a RAID1, ask for confirmation.

Signed-Off-By: NeilBrown <neilb@suse.de>
10 years agoDon't silently map --re-add to --add
NeilBrown [Tue, 17 Nov 2009 02:15:34 +0000 (13:15 +1100)] 
Don't silently map --re-add to --add

As --add can destroy important data on a disk, and
--re-add is not suppose to, it is wrong to silently
try --add if --re-add fails.
So print a message and abort instead.

Signed-off-by: NeilBrown <neilb@suse.de>
10 years agoImprove error messages when metadata handler does not support request.
NeilBrown [Tue, 17 Nov 2009 02:15:34 +0000 (13:15 +1100)] 
Improve error messages when metadata handler does not support request.

->validate_geometry is called to validate overall parameters,
and to validate each individual device.
If it ever fails, it needs to report the reason, as common code
cannot possible know.

Signed-off-by: NeilBrown <neilb@suse.de>
10 years agoSet default bitmap-chunksize for internal bitmaps to at least 64Meg
NeilBrown [Tue, 17 Nov 2009 02:15:34 +0000 (13:15 +1100)] 
Set default bitmap-chunksize for internal bitmaps to at least 64Meg

A small bitmap-chunksize hurts performance without helping
resync speed much - particularly on internal bitmaps.

So set the default to at least 64Meg.

Signed-off-by: NeilBrown <neilb@suse.de>
10 years agoGrow: various fixes to recent breakages.
NeilBrown [Tue, 17 Nov 2009 02:15:33 +0000 (13:15 +1100)] 
Grow: various fixes to recent breakages.

- I forgot to write the send backup-super-block on spares.
- I wasn't adding the data_offset to an offset

Signed-off-by: NeilBrown <neilb@suse.de>
10 years agoChange default metadata from 0.90 to 1.1
NeilBrown [Tue, 17 Nov 2009 02:15:32 +0000 (13:15 +1100)] 
Change default metadata from 0.90 to 1.1

1.1 is more flexible in a number of ways and is safer.
0.90 is still fully supported.
1.0 should possibly be used for RAID1 arrays that you
want to boot off, depending on your boot loader.

Signed-off-by: NeilBrown <neilb@suse.de>
10 years agoIncrease default chunk size to 512K
NeilBrown [Tue, 17 Nov 2009 02:08:55 +0000 (13:08 +1100)] 
Increase default chunk size to 512K

This seems more appropriate for current (and recent) model drives than
64K.
64K is still the default for '--build' as changing that could corrupt
data.
64K is also the default rounding for 'linear' on kernels older than
2.6.16.

Signed-off-by: NeilBrown <neilb@suse.de>
10 years agoReplace all relevant occurrences of -4 with LEVEL_MULTIPATH
NeilBrown [Tue, 17 Nov 2009 01:31:12 +0000 (12:31 +1100)] 
Replace all relevant occurrences of -4 with LEVEL_MULTIPATH

Also -1 -> LEVEL_LINEAR.

Signed-off-by: NeilBrown <neilb@suse.de>
10 years agoAssemble/super0: allow non-in-sync devices to be assembled without complaint.
NeilBrown [Tue, 17 Nov 2009 01:31:10 +0000 (12:31 +1100)] 
Assemble/super0: allow non-in-sync devices to be assembled without complaint.

Other metadata formats already did not worry about whether 'sync' was
missing or not.  super0 needs that now, but only for 0.91 metadata
that is undergoing reshape.

Signed-off-by: NeilBrown <neilb@suse.de>
10 years agoAssemble: include ACTIVE but not in-sync devices as non-spares.
NeilBrown [Tue, 17 Nov 2009 01:30:54 +0000 (12:30 +1100)] 
Assemble: include ACTIVE but not  in-sync devices as non-spares.

Previously such things did not exist: ACTIVE and SYNC were either both
set or both clear.   Recent changes with reshape means that a device
can be ACTIVE but not yet fully in-sync, so they need to be handled
and included in the array as active devices.

Signed-off-by: NeilBrown <neilb@suse.de>
10 years agoGrow: data_offset is in sectors, offsets[] is in bytes - convert
NeilBrown [Mon, 16 Nov 2009 00:06:44 +0000 (11:06 +1100)] 
Grow: data_offset is in sectors, offsets[] is in bytes - convert

Another missed sectors->bytes conversion.

Signed-off-by: NeilBrown <neilb@suse.de>
10 years agoGrow: do not allow size changes with other changes.
NeilBrown [Fri, 6 Nov 2009 06:26:47 +0000 (17:26 +1100)] 
Grow: do not allow size changes with other changes.

A change the reduces the size of an array always happens
before any other change.  So it can cause data to be lost.
By themselves these changes are reversible.  But once another
change has started, the data would be permanently lost.
So recommend data integrity be checked between a size change
and any other change.

Signed-off-by: NeilBrown <neilb@suse.de>
10 years agoGrow: goto release rather than just return
NeilBrown [Fri, 6 Nov 2009 04:22:14 +0000 (15:22 +1100)] 
Grow: goto release rather than just return

otherwise we exit with the array frozen.

Signed-off-by: NeilBrown <neilb@suse.de>
10 years agoGrow: restrict to 2.6.32
NeilBrown [Fri, 6 Nov 2009 04:19:39 +0000 (15:19 +1100)] 
Grow: restrict to 2.6.32

2.6.31 has a bug which can lead to unsafe reshaping.
So only allow a reshape with 2.6.32.
When the required fixed get into 2.6.31.y, this can be relaxed
slightly

Signed-off-by: NeilBrown <neilb@suse.de>
10 years agoGrow: use large block count and make sure stripe cache can hold it.
NeilBrown [Fri, 6 Nov 2009 03:48:10 +0000 (14:48 +1100)] 
Grow: use large block count and make sure stripe cache can hold it.

The bigger the backup is, the fast it goes to some extend.

16Meg is fairly arbitrary

Signed-off-by: NeilBrown <neilb@suse.de>
10 years agoGrow: get component_size before using it.
NeilBrown [Fri, 6 Nov 2009 03:18:49 +0000 (14:18 +1100)] 
Grow: get component_size before using it.

We were using ->component_size while it hadn't been set.
This effectively meant that 'blocks' wasn't multiplied by
16 and reshape was even slower than it should have been.

Signed-off-by: NeilBrown <neilb@suse.de>
10 years agoGrow: handle array going degraded during reshape.
NeilBrown [Fri, 6 Nov 2009 02:56:05 +0000 (13:56 +1100)] 
Grow: handle array going degraded during reshape.

If an array goes degraded during reshape, we need to
adjust the devices we read from so as not to back up
stale data.

Signed-off-by: NeilBrown <neilb@suse.de>
10 years agoGrow: restore backup to proper location.
NeilBrown [Fri, 6 Nov 2009 02:38:43 +0000 (13:38 +1100)] 
Grow: restore backup to proper location.

The 'arraystart' is in sectors while restore_stripes requires
bytes, so we need a conversion.

Without this, backups get restored to the wrong offset.

Reported-by: "KueiHuan Chen" <kueihuan.chen@gmail.com>
Signed-off-by: NeilBrown <neilb@suse.de>
10 years agovol_id was removed by the udev upstream maintainer in May 2009.
Marco d'Itri [Wed, 28 Oct 2009 23:14:43 +0000 (10:14 +1100)] 
vol_id was removed by the udev upstream maintainer in May 2009.

One should use
  /sbin/blkid -o udev -p ...
(from util-linux >> 2.16) instead of
  vol_id --export ...

Author: Marco d'Itri <md@linux.it>
Bug-Debian: http://bugs.debian.org/541884
Reviewed-by: martin f. krafft <madduck@debian.org>
Signed-off-by: NeilBrown <neilb@suse.de>
10 years agoRemove bogus warnings from man page.
NeilBrown [Wed, 28 Oct 2009 23:11:01 +0000 (10:11 +1100)] 
Remove bogus warnings from man page.

LANG=C man --warnings -l mdadm.8 > /dev/null

complains that '.XX' is an invalid macro.
This is not correct.  The sequence

   .ig XX
   anything can go here
   .XX

is correct and is ignored (see 'info groff' and the 'ig' index
entry).

However the same can be achieved with
   .ig
   anything can go there
   ..

and this produces no warnings, so use that instead.

Signed-off-by: NeilBrown <neilb@suse.de>
10 years agoDetail: report new-layout for RAID6 arrays
NeilBrown [Wed, 28 Oct 2009 23:02:24 +0000 (10:02 +1100)] 
Detail: report new-layout for RAID6 arrays

We were only reporting it for RAID5 and RAID10.

Signed-off-by: NeilBrown <neilb@suse.de>
10 years agoRelease 3.1 mdadm-3.1
NeilBrown [Thu, 22 Oct 2009 03:07:05 +0000 (14:07 +1100)] 
Release 3.1

New functionality in --grow.

Signed-off-by: NeilBrown <neilb@suse.de>
10 years agoMerge branch 'master' into devel-3.1
NeilBrown [Thu, 22 Oct 2009 02:57:54 +0000 (13:57 +1100)] 
Merge branch 'master' into devel-3.1

10 years agoRelease 3.0.3 mdadm-3.0.3
NeilBrown [Thu, 22 Oct 2009 01:05:22 +0000 (12:05 +1100)] 
Release 3.0.3

Signed-off-by: NeilBrown <neilb@suse.de>
10 years agoMerge branch 'master' into devel-3.1
NeilBrown [Thu, 22 Oct 2009 00:13:13 +0000 (11:13 +1100)] 
Merge branch 'master' into devel-3.1

10 years agoFree some malloced memory that wasn't being freed.
NeilBrown [Thu, 22 Oct 2009 00:00:56 +0000 (11:00 +1100)] 
Free some malloced memory that wasn't being freed.

As mdadm is normally a short-lived program it isn't always necessary
to free memory that was allocated, as the 'exit()' call will
automatically free everything.  But it is more obviously correct if
the 'free' is there.
So this patch add a few calls to 'free'

Signed-off-by: NeilBrown <neilb@suse.de>
10 years agoGrow: update backup-metadata mtime every time we write it.
NeilBrown [Wed, 21 Oct 2009 23:42:06 +0000 (10:42 +1100)] 
Grow: update backup-metadata mtime every time we write it.

Originally the backup-metadata was only written once at the
start of a raid5 reshape that made the array bigger.  So we only
set the mtime once.

Now that we can be writing metadata continually during an in-place
reshape, we need to update the mtime more often.

Also, allow the metadata mtime to be slightly in advance of the
array mtime.  Normally the difference will be less than a second,
so 10 minutes should be plenty.  This guards against an old backup
file being used to restart an array.  but starting two reshapes in the
10 minutes is sufficiently unlikely, and the possibility of an
accident is already sufficiently small, that 10 minutes is probably
fine.

Thanks to Guy Martin <gmsoft@tuxicoman.be> for discovering and
reporting that .mtime wasn't being updated properly.

Signed-off-by: NeilBrown <neilb@suse.de>
10 years agoCompile fixes for mdassemble
NeilBrown [Tue, 20 Oct 2009 05:53:43 +0000 (16:53 +1100)] 
Compile fixes for mdassemble

Signed-off-by: NeilBrown <neilb@suse.de>
10 years agoGrow: reject raid-disks reduction in RAID5 etc before 2.6.32
NeilBrown [Tue, 20 Oct 2009 05:36:03 +0000 (16:36 +1100)] 
Grow: reject raid-disks reduction in RAID5 etc before 2.6.32

2.6.31 has some bugs with restarting a RAID5 reduction, so
refuse to try unless at least 2.6.32.

Signed-off-by: NeilBrown <neilb@suse.de>
10 years agoAssemble: print more verbose messages about restarting a reshape
NeilBrown [Tue, 20 Oct 2009 05:23:45 +0000 (16:23 +1100)] 
Assemble: print more verbose messages about restarting a reshape

Signed-off-by: NeilBrown <neilb@suse.de>
10 years agoAdd missing 'continue' in Grow_restart.
NeilBrown [Tue, 20 Oct 2009 04:36:49 +0000 (15:36 +1100)] 
Add missing 'continue' in Grow_restart.

Thus we weren't checking the uuid properly.

Signed-off-by: NeilBrown <neilb@suse.de>
10 years agosuper-intel: Fix compilation of mdassemble.
NeilBrown [Tue, 20 Oct 2009 02:50:23 +0000 (13:50 +1100)] 
super-intel:  Fix compilation of mdassemble.

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