Commit Graph

1206 Commits

Author SHA1 Message Date
NeilBrown af7ca33487 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>
2010-02-04 12:04:16 +11:00
NeilBrown 3e7312a96c 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>
2010-02-04 12:04:15 +11:00
NeilBrown 921d9e164f 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>
2010-02-04 12:02:09 +11:00
NeilBrown cc86f89c85 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>
2010-02-01 10:37:58 +11:00
NeilBrown ac5678dd9b 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>
2010-02-01 10:22:38 +11:00
Luca Berra cf1be220e2 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>
2010-02-01 09:15:35 +11:00
Luca Berra c3e1a50fcb 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>
2010-02-01 09:12:31 +11:00
Artur Wojcik 4c619b292f 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>
2010-01-29 20:53:24 +11:00
NeilBrown fc7e81e54e 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>
2010-01-29 16:20:08 +11:00
NeilBrown d998adc316 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>
2010-01-29 15:46:23 +11:00
NeilBrown a1331cc406 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>
2010-01-29 15:46:17 +11:00
NeilBrown c93e9d68d0 md.4: various improvements to new section on scrubbing.
Signed-off-by: NeilBrown <neilb@suse.de>
2010-01-29 10:21:56 +11:00
NeilBrown 417a4b046d 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>
2010-01-29 10:15:15 +11:00
NeilBrown 0c8675cbed 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>
2010-01-28 16:55:28 +11:00
NeilBrown 1cc44574b2 md.4: add section on scrubbing and mismatch counts.
This relates to debian bug 405919

Signed-off-by: NeilBrown <neilb@suse.de>
2010-01-28 13:09:58 +11:00
NeilBrown 39bbb39202 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>
2010-01-28 11:48:03 +11:00
NeilBrown 9f22b13fe1 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>
2010-01-28 09:02:21 +11:00
NeilBrown 080fd00521 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>
2010-01-28 08:55:18 +11:00
Doug Ledford 4d0b563b5b 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>
2010-01-19 10:50:26 +13:00
Doug Ledford 6e48d593c1 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>
2010-01-19 10:45:28 +13:00
Doug Ledford 9ef5dbff4a 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>
2010-01-19 10:39:39 +13:00
Michael Evan 6acad4811b 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>
2009-12-30 13:51:11 +11:00
NeilBrown 8409bc51e8 Merge branch 'klockwork' of git://github.com/djbw/mdadm
Conflicts:
	super-intel.c
2009-12-30 13:46:52 +11:00
NeilBrown c1e3ab8c1e Merge branch 'master' of git://github.com/djbw/mdadm 2009-12-30 13:42:37 +11:00
NeilBrown 076515ba50 DDF: fix incorrect header magic number.
I was using the wrong magic number when creating an array.

Signed-off-by: NeilBrown <neilb@suse.de>
2009-12-30 13:42:27 +11:00
Dan Williams 1e5c69836d 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>
2009-12-21 17:54:32 -07:00
Dan Williams 2904b26f05 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>
2009-12-21 12:51:57 -07:00
Dan Williams d23534e464 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>
2009-12-21 11:26:21 -07:00
Dan Williams b7528a20cc 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>
2009-12-21 10:23:26 -07:00
Dan Williams e1516be1db 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>
2009-12-21 10:06:14 -07:00
Dan Williams b7941fd68d 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>
2009-12-14 12:57:55 -07:00
Dan Williams 071cfc4258 mdmon: cleanup manage_member() leak
free() the results of activate_spare().

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2009-12-12 14:10:01 -07:00
Dan Williams 8655a7b194 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>
2009-12-12 13:57:28 -07:00
Dan Williams 1f0769d768 util: fix devnum2devname for devnum == 0
devnum 0 is md0 no md_d-1

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2009-12-12 13:57:28 -07:00
Dan Williams ecf408e914 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>
2009-12-12 13:57:25 -07:00
Dan Williams ac6449bee9 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>
2009-12-10 15:03:34 -07:00
Dan Williams 6592ce37ee 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>
2009-12-10 15:03:31 -07:00
Dan Williams dd9bb2fbed imsm: prune dead code in validate_geometry_imsm
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2009-12-10 12:03:40 -07:00
Artur Wojcik 33a6535d00 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>
2009-12-10 12:03:40 -07:00
Artur Wojcik 922f66a935 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>
2009-12-10 12:03:40 -07:00
Artur Wojcik 5dbb8c8d76 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>
2009-12-10 12:03:40 -07:00
Artur Wojcik 37f0e1e025 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>
2009-12-10 12:03:40 -07:00
Artur Wojcik 389508223e 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>
2009-12-10 12:03:40 -07:00
Artur Wojcik 1602d52c99 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>
2009-12-10 12:03:40 -07:00
Artur Wojcik e207da2f1b 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>
2009-12-10 12:03:40 -07:00
Artur Wojcik 4e5e717d72 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>
2009-12-10 12:03:40 -07:00
Artur Wojcik d362da3dfe 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>
2009-12-10 12:03:40 -07:00
Artur Wojcik 4e9d21862d 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>
2009-12-10 12:03:39 -07:00
Dan Williams c3ca5f6028 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>
2009-12-10 12:03:39 -07:00
Artur Wojcik 7a6ecd5544 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>
2009-12-10 12:03:39 -07:00