]> git.ipfire.org Git - thirdparty/mdadm.git/log
thirdparty/mdadm.git
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 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 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>
13 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>
13 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>
13 years agoIMSM/DDF: don't recognised these metadata on partitions.
NeilBrown [Thu, 29 Apr 2010 06:09:59 +0000 (16:09 +1000)] 
IMSM/DDF: don't recognised these metadata on partitions.

These metadata are not expected on partitions, and they have
no way of differentiation whether which is correct if they
are found both on the device and on the last partition.

So if the device is a partition, refuse to read the metadata.

Signed-off-by: NeilBrown <neilb@suse.de>
14 years agoCreate: cleanup after failed create in duplicated array member case
Dan Williams [Mon, 19 Apr 2010 05:28:07 +0000 (15:28 +1000)] 
Create: cleanup after failed create in duplicated array member case

mdadm prevents creation when device names are duplicated on the command
line, but leaves the partially created array intact.  Detect this case
in the error code from add_to_super() and cleanup the partially created
array.  The imsm handler is updated to report this conflict in
add_to_super_imsm_volume().

Note that since neither mdmon, nor userspace for that matter, ever saw an
active array we only need to perform a subset of the cleanup actions.
So call ioctl(STOP_ARRAY) directly and arrange for Create() to cleanup
the map file rather than calling Manage_runstop().

Reported-by: Krzysztof Wojcik <krzysztof.wojcik@intel.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
14 years agoFixup default definitions of VAR_RUN and ALT_RUN
Dan Williams [Wed, 14 Apr 2010 18:53:56 +0000 (11:53 -0700)] 
Fixup default definitions of VAR_RUN and ALT_RUN

I suspect commit c132678b wanted VAR_RUN and ALT_RUN to be suffixed by
'/mdadm' to match the defaults in mdadm.h.

Cc: Luca Berra <bluca@comedia.it>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
14 years agopowerpc compile fix
Doug Ledford [Tue, 6 Apr 2010 18:04:30 +0000 (14:04 -0400)] 
powerpc compile fix

Signed-off-by: Doug Ledford <dledford@redhat.com>
Signed-off-by: NeilBrown <neilb@suse.de>
14 years agoDon't attempt to create or read bitmaps where the metadata doesn't support it.
NeilBrown [Wed, 24 Mar 2010 00:57:42 +0000 (11:57 +1100)] 
Don't attempt to create or read bitmaps where the metadata doesn't support it.

In particular, if the relevant bitmap method is NULL, don't try to
call it, print an error instead.

Signed-off-by: NeilBrown <neilb@suse.de>
14 years agoMerge branch 'HEAD'; commit 'a4b93c9ce4f15217afb8'
NeilBrown [Tue, 6 Apr 2010 23:17:13 +0000 (09:17 +1000)] 
Merge branch 'HEAD'; commit 'a4b93c9ce4f15217afb8'

14 years agoAdd ANNOUNCE-3.1.2 mdadm-3.1.2a
NeilBrown [Tue, 6 Apr 2010 23:13:16 +0000 (09:13 +1000)] 
Add ANNOUNCE-3.1.2

Forgot to git-add this for the release :-(

Signed-off-by: NeilBrown <neil@suse.de>
14 years agoOnly signal a udev change event if we actually write a mapfile in RebuildMap
Doug Ledford [Wed, 17 Mar 2010 13:28:07 +0000 (09:28 -0400)] 
Only signal a udev change event if we actually write a mapfile in RebuildMap

Signed-off-by: Doug Ledford <dledford@redhat.com>
14 years agomapfile: if we putting the mapfile in a custom location via ALT_RUN, allow
Doug Ledford [Wed, 17 Mar 2010 14:52:22 +0000 (10:52 -0400)] 
mapfile: if we putting the mapfile in a custom location via ALT_RUN, allow
a custom filename too.

Signed-off-by: Doug Ledford <dledford@redhat.com>
14 years agoCreate directory to contain mapfile (Assuming parent exists and
Doug Ledford [Wed, 17 Mar 2010 03:00:11 +0000 (23:00 -0400)] 
Create directory to contain mapfile (Assuming parent exists and
filesystem is writable).
This particularly keeps udev happy if VAR_RUN is set to /dev/md.

Signed-off-by: Doug Ledford <dledford@redhat.com>
Signed-off-by: NeilBrown <neilb@suse.de>
14 years ago(no commit message)
NeilBrown [Tue, 23 Mar 2010 22:07:02 +0000 (09:07 +1100)] 

14 years agoRelease mdadm-3.1.2 mdadm-3.1.2
NeilBrown [Wed, 10 Mar 2010 04:58:46 +0000 (15:58 +1100)] 
Release mdadm-3.1.2

14 years agotests: adjust sizes for new defaults
NeilBrown [Tue, 9 Mar 2010 20:53:16 +0000 (07:53 +1100)] 
tests: adjust sizes for new defaults

Default metadata type is now 1.2, and we sometimes
add extra alignment before the data section,
so adjust tests for these changes.

Signed-off-by: NeilBrown <neilb@suse.de>
14 years agoddf/intel: zero out old metadata before creating a container.
NeilBrown [Wed, 10 Mar 2010 04:55:47 +0000 (15:55 +1100)] 
ddf/intel: zero out old metadata before creating a container.

Matching the functionality already in super0 and super1, when
we first create a container, remove any other recognisable metadata to
ensure it doesn't cause confusion.

Signed-off-by: NeilBrown <neilb@suse.de>
14 years agoGrow: fix recent breakage - lseek return status.
NeilBrown [Wed, 10 Mar 2010 04:21:18 +0000 (15:21 +1100)] 
Grow: fix recent breakage - lseek return status.

Recent fix to check lseek64 return status got it badly wrong.
It doesn't return 0 on success!!

Fix it.

Signed-off-by: NeilBrown <neilb@suse.de>
14 years agoAssemble: fix some recently introduced bugs.
NeilBrown [Wed, 10 Mar 2010 00:21:26 +0000 (11:21 +1100)] 
Assemble: fix some recently introduced bugs.

Found during testing:
 - cannot check metadata for homehost before loading metadata.
 - As 1.x metadata can has a state 'rebuilding' between
   'spare' and 'ok', we need to include that in our calculations.

Signed-off-by: NeilBrown <neilb@suse.de>
14 years agoMerge branch 'master' of git://github.com/djbw/mdadm
NeilBrown [Tue, 9 Mar 2010 20:54:03 +0000 (07:54 +1100)] 
Merge branch 'master' of git://github.com/djbw/mdadm

14 years agoStop: done stop a container which still have members active.
NeilBrown [Tue, 9 Mar 2010 05:32:04 +0000 (16:32 +1100)] 
Stop: done stop a container which still have members active.

Doing that is just confusing...

Signed-off-by: NeilBrown <neilb@suse.de>
14 years agoMake sure reshape_active is cleared by getinfo_super
NeilBrown [Tue, 9 Mar 2010 05:15:29 +0000 (16:15 +1100)] 
Make sure reshape_active is cleared by getinfo_super

There were cases where --detail would report phantom reshapes.

Signed-off-by: NeilBrown <neilb@suse.de>
14 years agomdmon.8: minor manpage update
NeilBrown [Tue, 9 Mar 2010 03:34:03 +0000 (14:34 +1100)] 
mdmon.8: minor manpage update

Signed-off-by: NeilBrown <neilb@suse.de>
14 years agomdadm.8: improve hosthost documentation
NeilBrown [Tue, 9 Mar 2010 03:22:39 +0000 (14:22 +1100)] 
mdadm.8: improve hosthost documentation

Signed-off-by: NeilBrown <neilb@suse.de>
14 years agoGrow: fix problem with validating chunk size
NeilBrown [Tue, 9 Mar 2010 03:14:39 +0000 (14:14 +1100)] 
Grow: fix problem with validating chunk size

When checking if the new chunk size fit in the component size
we were confusing sectors and K, and so getting it wrong.

Signed-off-by: NeilBrown <neilb@suse.de>
14 years agoImprove partition table code.
NeilBrown [Mon, 8 Mar 2010 23:57:57 +0000 (10:57 +1100)] 
Improve partition table code.

Code to check partition tables used some needless casts
and was broken, using a u8 when a u32 was wanted.

So create structure describing the tables rather than using offset,
and read into those tables instead.

Signed-off-by: NeilBrown <neilb@suse.de>
14 years agomdadm.8: correct typo: pairty
Ryo Fujita [Mon, 8 Mar 2010 04:47:33 +0000 (15:47 +1100)] 
mdadm.8: correct typo: pairty

Signed-off-by: NeilBrown <neilb@suse.de>
14 years agoimsm: kill ->creating_imsm flag
Dan Williams [Wed, 3 Mar 2010 07:03:04 +0000 (00:03 -0700)] 
imsm: kill ->creating_imsm flag

It is an unused holdover from long since removed functionality.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
14 years agoRevert "Make the IMSM_DEVNAME_AS_SERIAL option work when creating containers."
Dan Williams [Wed, 3 Mar 2010 07:03:04 +0000 (00:03 -0700)] 
Revert "Make the IMSM_DEVNAME_AS_SERIAL option work when creating containers."

This reverts commit 9ef5dbff4adc7979102e71efe8efd83d8e0dc775 as it is
duplicating the check that is done internal to imsm_read_serial().

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
14 years agosuper1: encourage data alignment on 1Meg boundary
NeilBrown [Wed, 3 Mar 2010 04:22:56 +0000 (15:22 +1100)] 
super1: encourage data alignment on 1Meg boundary

For 1.1 and 1.2 metadata where data_offset is not zero,
it is important to align the data_offset to underlying
block size.

We don't currently have access to the particular device
in avail_size so just try to force to a 1Meg boundary.

Also default 1.x metadata to 1.2 as documented.

Signed-off-by: NeilBrown <neilb@suse.de>
14 years agoconfig: add 'homehost' option to 'AUTO' line.
NeilBrown [Wed, 3 Mar 2010 03:33:55 +0000 (14:33 +1100)] 
config: add 'homehost' option to 'AUTO' line.

This allows basing auto-assembly decisions on whether
the array is recorded as belonging to this host or not.

Signed-off-by: NeilBrown <neilb@suse.de>
14 years agoManage: fix regression on removing detached devices.
NeilBrown [Wed, 3 Mar 2010 02:16:24 +0000 (13:16 +1100)] 
Manage: fix regression on removing detached devices.

If /dev is static, a name may remain there after the
device has been detached from the system.
Using 'mdadm' to remove such a device from the array
should still work (even though "mdadm --remove detached"
might be preferred).

So when processing a device for '-r', don't insist on
being able to open the device.

Signed-off-by: NeilBrown <neilb@suse.de>
14 years agoallow redefinition of VAR_RUN
Luca Berra [Sun, 28 Feb 2010 14:46:16 +0000 (15:46 +0100)] 
allow redefinition of VAR_RUN

having mdmon socket under var is painful at shutdown time

Signed-off-by: Luca Berra <bluca@comedia.it>
Signed-off-by: NeilBrown <neilb@suse.de>
14 years agomdmon: Check both RUN directories to find running mdmon
NeilBrown [Sun, 28 Feb 2010 14:43:40 +0000 (15:43 +0100)] 
mdmon: Check both RUN directories to find running mdmon

If mdmon is run without "--takeover", it should still
check both *_RUN directories for a valid 'pid' file
to guard against having two mdmons running at the same time.

Suggested-by: Luca Berra <bluca@comedia.it>
Signed-off-by: NeilBrown <neilb@suse.de>
14 years agomdmon: check select a writable pid_dir
Luca Berra [Sun, 28 Feb 2010 14:42:57 +0000 (15:42 +0100)] 
mdmon: check select a writable pid_dir

Check that either VAR_DIR or ALT_DIR is actually writable before
selecting it.

Signed-off-by: Luca Berra <bluca@comedia.it>
Signed-off-by: NeilBrown <neilb@suse.de>
14 years agofix mdmon takeover
Luca Berra [Sat, 27 Feb 2010 15:07:51 +0000 (16:07 +0100)] 
fix mdmon takeover

- when we waited for the old mdmon to exit, we didn't look
  for the socket in the right place

- when we failed to find a pid file, we returned the wrong
  value (code expected <0, but got ==0).

Signed-off-by: Luca Berra <bluca@comedia.it>
Signed-off-by: NeilBrown <neilb@suse.de>
14 years agofix mdmon option parsing
Luca Berra [Sat, 27 Feb 2010 15:07:04 +0000 (16:07 +0100)] 
fix mdmon option parsing

running mdmon --takeover --all resulted in a segfault.

Also allow "--all" to be longer so that e.g. md_d127 can
successfully over-write it in the argument list visible
to 'ps'.

Signed-off-by: Luca Berra <bluca@comedia.it>
Signed-off-by: NeilBrown <neilb@suse.de>
14 years agoAdd _FORTIFY_SOURCE to mdadm.O2 build.
NeilBrown [Tue, 2 Mar 2010 23:54:17 +0000 (10:54 +1100)] 
Add _FORTIFY_SOURCE to mdadm.O2 build.

When building mdadm.O2, set _FORTIFY_SOURCE to get more
warnings, and also build mdmon.O2 to find warnings in that
code too.
Then fix the warnings.

Suggested-by: Luca Berra <bluca@comedia.it>
Signed-off-by: NeilBrown <neilb@suse.de>
14 years agoFix warning about unused variable.
NeilBrown [Tue, 2 Mar 2010 23:29:24 +0000 (10:29 +1100)] 
Fix warning about unused variable.

Warning only appears with -O2, but is invalid.

Signed-off-by: NeilBrown <neilb@suse.de>
14 years agofix gcc warnings about strict-aliasing rules
NeilBrown [Tue, 2 Mar 2010 23:17:41 +0000 (10:17 +1100)] 
fix gcc warnings about strict-aliasing rules

Original-by: Luca Berra <bluca@comedia.it>
Signed-off-by: NeilBrown <neilb@suse.de>
14 years agoAssemble: clean up properly if we cannot add the bitmap file.
NeilBrown [Wed, 24 Feb 2010 01:17:17 +0000 (12:17 +1100)] 
Assemble: clean up properly if we cannot add the bitmap file.

If we find we cannot add the requested bitmap file when
assembling the array, then make sure to clean up properly
and don't leave a half-configured array.

Signed-off-by: NeilBrown <neilb@suse.de>
14 years agoCreate: change default metadata type to 1.2
NeilBrown [Wed, 24 Feb 2010 01:03:27 +0000 (12:03 +1100)] 
Create: change default metadata type to 1.2

Change default - again, sorry.

v1.1 causes problems as the conflicts with a boot sector, whether on
the whole device or in a partition.  I guess the rule is they you
aren't allowed to use the first sector in general.

v1.2 is mostly just as good and avoid boot-sector problems so default
to that instead.

Signed-off-by: NeilBrown <neilb@suse.de>
14 years agoGrow: be more relaxed about timestamp mismatches on backup file.
NeilBrown [Wed, 24 Feb 2010 00:59:11 +0000 (11:59 +1100)] 
Grow: be more relaxed about timestamp mismatches on backup file.

As backup file has a timestamp which is updated quite separately
from the metadata timestamp.  They should be largely in-sync but
sometimes are not.
So be more generous in the check, and allow it to be over-ridden
by an environment variable.

Signed-off-by: NeilBrown <neilb@suse.de>
14 years agoAssemble: check inargv before complaining about stray arguments.
NeilBrown [Wed, 24 Feb 2010 00:43:59 +0000 (11:43 +1100)] 
Assemble: check inargv before complaining about stray arguments.

If --assemble is given a container and some other devices to assemble
an array from, it complains with an error because that doesn't make
sense.
However it currently also complains if the list of devices was extract
from the config file rather than being given on the command line.
That is not appropriate.

So add an '&& inargv' test to ensure that we are really complaining
about the right thing.

Signed-off-by: NeilBrown <neilb@suse.de>
Acked-by: Dan Williams <dan.j.williams@intel.com>
14 years agosuper1: put bitmap on a 4K boundary when possible.
NeilBrown [Wed, 24 Feb 2010 00:31:48 +0000 (11:31 +1100)] 
super1: put bitmap on a 4K boundary when possible.

Some devices have 4K sector sizes.  So try to align the bitmap
on a 4K boundary.
This isn't possible when hot-adding a bitmap, but will be once
we add support for configuring the bitmap via sysfs.

Signed-off-by: NeilBrown <neilb@suse.de>
14 years agoAssemble: Handle assembling from config file which is out of order.
NeilBrown [Wed, 24 Feb 2010 00:16:41 +0000 (11:16 +1100)] 
Assemble: Handle assembling from config file which is out of order.

Currently "mdadm -As" will process the entries in the config
file in order.  If any array is a component or member of a preceding
array, that array will not be assembled.

So if there are any failures during assembly, retry those arrays,
and look until everything is assembled, or nothing more can
be assembled.

Signed-off-by: NeilBrown <neilb@suse.de>
14 years agomdmon: Document startup/shutdown requirements in man page.
NeilBrown [Mon, 8 Feb 2010 03:43:51 +0000 (14:43 +1100)] 
mdmon: Document startup/shutdown requirements in man page.

Signed-off-by: NeilBrown <neilb@suse.de>
14 years agomapfile: use ALT_RUN as alternate place to store mapfile
NeilBrown [Mon, 8 Feb 2010 03:33:31 +0000 (14:33 +1100)] 
mapfile: use ALT_RUN as alternate place to store mapfile

This gives better consistency and fewer hidden '.' files.

Signed-off-by: NeilBrown <neilb@suse.de>
14 years agomdmon: insist on creating .pid file at startup.
NeilBrown [Mon, 8 Feb 2010 03:30:46 +0000 (14:30 +1100)] 
mdmon: insist on creating .pid file at startup.

Now that we don't "mdadm --takeover" until /var/run is writable
there is no need to continually try to create files in there.

So only create these files at startup and fail if they cannot be
made.  This means that to start an array with externally managed
metadata, either /var/run or ALT_RUN (e.g. /lib/init/rw) must be
writable.  To 'takeover' from a previous mdmon instance, /var/run
must be writable.

This means we don't need to worry about SIGHUP (which was once used to
tell us it was time to create .pid) and SIGALRM.

Signed-off-by: NeilBrown <neilb@suse.de>
14 years agomdmon: don't monitor /proc/mounts to decide when to create .pid file.
NeilBrown [Mon, 8 Feb 2010 03:12:46 +0000 (14:12 +1100)] 
mdmon: don't monitor /proc/mounts to decide when to create .pid file.

Monitoring /proc/mounts and creating a .pid file as soon as /var/run
is writable is racy.  Most distros clean all non-directories from
/var/run early in boot and if mdmon races with this it could
lose the files as soon as they are created.

Instead require that "mdmon --takeover" be run after /var is writable.

Signed-off-by: NeilBrown <neilb@suse.de>
14 years agomdmon: remove switch-root functionality.
NeilBrown [Mon, 8 Feb 2010 03:08:13 +0000 (14:08 +1100)] 
mdmon: remove switch-root functionality.

Using switch-root and then creating files in /var/run once
that location is writable is racing as most distro clean out
/var/run shortly after it is mounted.
This can cause the .pid and .sock files to be deleted shortly
after they are created.

This option doesn't seem to be used at all any, and the alternative
of communicating the pid etc in some preserved directory and then
restarting mdmon once all is settled seems simpler.

So remove the code for supporting switchroot and update man page
accordingly.

Signed-off-by: NeilBrown <neilb@suse.de>
14 years agomdmon: recognise --all in place of /proc/mdstat
NeilBrown [Thu, 4 Feb 2010 06:34:06 +0000 (17:34 +1100)] 
mdmon: recognise --all in place of /proc/mdstat

It seems more meaningful.
Keep the old option as well for back compatibility.

Signed-off-by: NeilBrown <neilb@suse.de>
14 years agomdmon: allow pid to be stored in different directory.
NeilBrown [Thu, 4 Feb 2010 05:31:49 +0000 (16:31 +1100)] 
mdmon: allow pid to be stored in different directory.

/var/run probably doesn't persist from early boot.
So if necessary, store in in /lib/init/rw or somewhere else
that does persist.

Signed-off-by: NeilBrown <neilb@suse.de>
14 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>
14 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>
14 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>
14 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>
14 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>
14 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>
14 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>
14 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>
14 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>
14 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>