]> git.ipfire.org Git - thirdparty/mdadm.git/log
thirdparty/mdadm.git
10 years agoRemove lots of unnecessary white space.
NeilBrown [Wed, 19 Jun 2013 02:31:45 +0000 (12:31 +1000)] 
Remove lots of unnecessary white space.

Now that I am using white-space mode in Emacs I can see all of this,
and I don't like it :-)

Signed-off-by: NeilBrown <neilb@suse.de>
10 years agoManage: allow "--stop" on kernel names.
NeilBrown [Wed, 19 Jun 2013 01:39:14 +0000 (11:39 +1000)] 
Manage: allow "--stop" on kernel names.

e.g.
   mdadm --stop md4

This works even if udev has become confused or killed.

Signed-off-by: NeilBrown <neilb@suse.de>
10 years agoManage: split Manage_runstop into Manage_run and Manage_stop
NeilBrown [Wed, 19 Jun 2013 01:23:44 +0000 (11:23 +1000)] 
Manage: split Manage_runstop into Manage_run and Manage_stop

The two branches have virtually nothing in common, so it is simpler if
they are separate.

Signed-off-by: NeilBrown <neilb@suse.de>
10 years agoAssemble: when forcing a single-degraded RAID6 array, trigger a 'repair'.
NeilBrown [Wed, 19 Jun 2013 01:09:33 +0000 (11:09 +1000)] 
Assemble: when forcing a single-degraded RAID6 array, trigger a 'repair'.

When an active/degraded RAID6 array is force-started we clear the
'active' flag, but it is still possible that some parity is
no in sync.  This is because there are two parity block.
It would be nice to be able to tell the kernel "P is OK, Q maybe not".
But that is not possible.

So when we force-assemble such an array, trigger a 'repair' to fix up
any errant Q blocks.

This is not ideal as a restart during the repair will not be continued
after the restart, but it is the best we can do without kernel help.

Signed-off-by: NeilBrown <neilb@suse.de>
10 years agoDetail: add device information to --detail --export
NeilBrown [Wed, 19 Jun 2013 00:35:23 +0000 (10:35 +1000)] 
Detail: add device information to --detail --export

We may well want more per-device information here, but this
is a start.

Signed-off-by: NeilBrown <neilb@suse.de>
10 years agosysfs_read: return devices in same order as in filesystem.
NeilBrown [Wed, 19 Jun 2013 00:33:47 +0000 (10:33 +1000)] 
sysfs_read: return devices in same order as in filesystem.

When we read devices from sysfs (../md/dev-*), store them in the same
order that they appear.  That makes more sense when exposed to a
human (as the next patch will).

Signed-off-by: NeilBrown <neilb@suse.de>
10 years agoraid6check: Check return value of lseek64()
Bernd Schubert [Tue, 18 Jun 2013 09:09:41 +0000 (11:09 +0200)] 
raid6check: Check return value of lseek64()

If lseek64() failed it was still writing to the disks, which would introduce
data corruption.

Signed-off-by: Bernd Schubert <bernd.schubert@fastmail.fm>
Signed-off-by: NeilBrown <neilb@suse.de>
10 years agoraid6check: Fix compiler warnings.
Bernd Schubert [Tue, 18 Jun 2013 09:09:36 +0000 (11:09 +0200)] 
raid6check: Fix compiler warnings.

Fix some compiler warnings appearing with optimization levels.

Signed-off-by: Bernd Schubert <bernd.schubert@fastmail.fm>
Signed-off-by: NeilBrown <neilb@suse.de>
10 years agoraid6check: Use enums for repair type
Bernd Schubert [Tue, 18 Jun 2013 09:09:31 +0000 (11:09 +0200)] 
raid6check: Use enums for repair type

Using hard coded numbers is error prone and hard to read by humans.

Signed-off-by: Bernd Schubert <bernd.schubert@fastmail.fm>
Signed-off-by: NeilBrown <neilb@suse.de>
10 years agoraid6check: Fix memory leaks detected by valgrind
Bernd Schubert [Tue, 18 Jun 2013 09:09:26 +0000 (11:09 +0200)] 
raid6check: Fix memory leaks detected by valgrind

==2389947== 24 bytes in 1 blocks are definitely lost in loss record 1 of 10
==2389947==    at 0x4C2B3F8: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==2389947==    by 0x408067: xmalloc (xmalloc.c:36)
==2389947==    by 0x401B19: check_stripes (raid6check.c:151)
==2389947==    by 0x4030C6: main (raid6check.c:521)
==2389947==
==2389947== 24 bytes in 1 blocks are definitely lost in loss record 2 of 10
==2389947==    at 0x4C2B3F8: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==2389947==    by 0x408067: xmalloc (xmalloc.c:36)
==2389947==    by 0x401B67: check_stripes (raid6check.c:155)
==2389947==    by 0x4030C6: main (raid6check.c:521)
==2389947==

Signed-off-by: Bernd Schubert <bernd.schubert@fastmail.fm>
Signed-off-by: NeilBrown <neilb@suse.de>
10 years agoraid6check: Fix build of raid6check
Bernd Schubert [Tue, 18 Jun 2013 09:09:16 +0000 (11:09 +0200)] 
raid6check: Fix build of raid6check

After recent git pull 'make raid6check' did not work anymore, as
sysfs_read() was called with a wrong argument and as check_env()
was used by use_udev(), but not defined.

Replace sysfs_read(..., -1, ...) by sysfs_read(..., NULL, ...)

Move check_env() from util.c to lib.c

Signed-off-by: Bernd Schubert <bernd.schubert@itwm.fraunhofer.de>
Signed-off-by: NeilBrown <neilb@suse.de>
10 years agoMakefile: add "-O3" to WARN_UNUSED options.
NeilBrown [Wed, 19 Jun 2013 00:02:17 +0000 (10:02 +1000)] 
Makefile: add "-O3" to WARN_UNUSED options.

This finds more errors

Also remove some trailing spaces.

Signed-off-by: NeilBrown <neilb@suse.de>
10 years agoGrow: fix up recent changes to set_new_data_offset.
NeilBrown [Tue, 18 Jun 2013 23:58:02 +0000 (09:58 +1000)] 
Grow: fix up recent changes to set_new_data_offset.

The second 'info2' wasn't being initialised.  So don't use it.

Reported by -O3

Signed-off-by: NeilBrown <neilb@suse.de>
10 years agosuper0: set uninitialized variable.
NeilBrown [Tue, 18 Jun 2013 23:51:01 +0000 (09:51 +1000)] 
super0: set uninitialized variable.

Reported by -O3

Signed-off-by: NeilBrown <neilb@suse.de>
10 years agoAssemble/Incr: Don't include spares with too-high event count.
NeilBrown [Mon, 17 Jun 2013 06:55:31 +0000 (16:55 +1000)] 
Assemble/Incr: Don't include spares with too-high event count.

Some failure scenarios can leave a spare with a higher event count
than an in-sync device.  Assembling an array like this will confuse
the kernel.
So detect spares with event counts higher than the best non-spare
event count and exclude them from the array.

Reported-by: Alexander Lyakas <alex.bolshoy@gmail.com>
Signed-off-by: NeilBrown <neilb@suse.de>
10 years agomdadm.h: add little bits of doco for 'struct superswitch'.
NeilBrown [Mon, 17 Jun 2013 06:04:59 +0000 (16:04 +1000)] 
mdadm.h: add little bits of doco for 'struct superswitch'.

Signed-off-by: NeilBrown <neilb@suse.de>
10 years agoMake sure NOFILE resource limit is big enough.
NeilBrown [Thu, 30 May 2013 04:31:09 +0000 (14:31 +1000)] 
Make sure NOFILE resource limit is big enough.

Some people want to create truely enormous arrays.
As we sometimes need to hold one file descriptor for each
device, this can hit  the NOFILE limit.

So raise the limit if it ever looks like it might be a problem.

Signed-off-by: NeilBrown <neilb@suse.de>
10 years agoIncremental: allow --quiet to silence from errors from "-If"
NeilBrown [Tue, 28 May 2013 23:13:25 +0000 (09:13 +1000)] 
Incremental: allow --quiet to silence from errors from "-If"

-q is currently ineffective on "mdadm -If".   Messages that are not
usage errors should be suppressed.

Signed-off-by: NeilBrown <neilb@suse.de>
10 years agoGrow_continue: handle RESHAPE_NO_BACKUP correctly.
NeilBrown [Mon, 27 May 2013 05:37:30 +0000 (15:37 +1000)] 
Grow_continue: handle RESHAPE_NO_BACKUP correctly.

If the reshape does not require a backup, Grow_continue can
abort early.

Signed-off-by: NeilBrown <neilb@suse.de>
10 years agosuper1: set RESHAPE_NO_BACKUP based on new_offset.
NeilBrown [Mon, 27 May 2013 05:18:07 +0000 (15:18 +1000)] 
super1: set RESHAPE_NO_BACKUP based on new_offset.

We need to check for a backup iff the data_offset has changed.
Testing against level==10 was an effective but short-sighted approach.

Signed-off-by: NeilBrown <neilb@suse.de>
10 years agoGrow: allow for different sized devices when updating data_offset.
NeilBrown [Mon, 27 May 2013 05:09:38 +0000 (15:09 +1000)] 
Grow: allow for different sized devices when updating data_offset.

It is possible that the devices in an array have different sizes, and
different data_offsets.  So the 'before_space' and 'after_space' may
be different from drive to drive.
Any decisions about how much to change the data_offset must work on
all devices, so must be based on the minimum available space on
any devices.

So find this minimum first, then do the calculation.

Signed-off-by: NeilBrown <neilb@suse.de>
10 years agoAssemble: allow --update=revert-reshape
NeilBrown [Thu, 23 May 2013 05:48:48 +0000 (15:48 +1000)] 
Assemble: allow --update=revert-reshape

This will cause a reshape to start going backwards.

10 years agoAssemble: --update=metadata converts v0.90 to v1.0
NeilBrown [Thu, 23 May 2013 04:41:29 +0000 (14:41 +1000)] 
Assemble: --update=metadata converts v0.90 to v1.0

This allows the smooth conversion of legacy 0.90 arrays
to 1.0 metadata.
Old metadata is likely to remain but will be ignored.
It can be removed with
  mdadm --zero-superblock --metadata=0.90 /dev/whatever

Signed-off-by: NeilBrown <neilb@suse.de>
10 years agosuper1: fix some casts of signed superblock fields.
NeilBrown [Tue, 28 May 2013 06:43:03 +0000 (16:43 +1000)] 
super1: fix some casts  of signed superblock fields.

These need to be cast to uint32_t before being cast to 'long', else
sign extension doesn't happen on 64bit hosts.

And bitmap_offset is le32, not le64 !!

Signed-off-by: NeilBrown <neilb@suse.de>
10 years agoExamine/super1 - report Unused space, before and after.
NeilBrown [Wed, 22 May 2013 06:37:19 +0000 (16:37 +1000)] 
Examine/super1 - report Unused space, before and after.

Might be confusing, or might be useful when reshaping.

Signed-off-by: NeilBrown <neilb@suse.de>
10 years agosuper1: don't put the bblog at the end of the free space.
NeilBrown [Wed, 22 May 2013 06:00:21 +0000 (16:00 +1000)] 
super1: don't put the bblog at the end of the free space.

It seems like a nice location, but it means that we cannot
decrease the data_offset during a reshape.

So put it just after the bitmap, leaving 32K.

Signed-off-by: NeilBrown <neilb@suse.de>
10 years agoGrow: allow a reshape which only changes --data-offset
NeilBrown [Tue, 21 May 2013 06:50:55 +0000 (16:50 +1000)] 
Grow: allow a reshape which only changes --data-offset

Sometimes, that is all we want to do.

Signed-off-by: NeilBrown <neilb@suse.de>
10 years agoGrow: E2BIG should be reporte differently if --data-offset was requested.
NeilBrown [Tue, 21 May 2013 06:50:05 +0000 (16:50 +1000)] 
Grow: E2BIG should be reporte differently if --data-offset was requested.

In that case the problem is almost certainly that --data-offset is too big.

Signed-off-by: NeilBrown <neilb@suse.de>
10 years agoGrow: --backup-file and --data-offset are incompatible.
NeilBrown [Tue, 21 May 2013 06:40:23 +0000 (16:40 +1000)] 
Grow: --backup-file and --data-offset are incompatible.

So report if both are given, and if --backup-file is given,
don't try to update data-offset.

Signed-off-by: NeilBrown <neilb@suse.de>
10 years agoGrow: handle E2BIG from new_offset changes more gracefully.
NeilBrown [Tue, 21 May 2013 06:35:29 +0000 (16:35 +1000)] 
Grow: handle E2BIG from new_offset changes more gracefully.

If new_offset change is too big, just do the reshape the old way.

Signed-off-by: NeilBrown <neilb@suse.de>
10 years agoGrow: allow --data-offset to be specified for raid4/5/6
NeilBrown [Tue, 21 May 2013 06:33:56 +0000 (16:33 +1000)] 
Grow: allow --data-offset to be specified for raid4/5/6

Previously it was rejected for non-RAID10.

Signed-off-by: NeilBrown <neilb@suse.de>
10 years agoGrow: allow metadata to indicate that changing data_offset not supported.
NeilBrown [Tue, 21 May 2013 06:32:00 +0000 (16:32 +1000)] 
Grow: allow metadata to indicate that changing data_offset not supported.

If space_after and space_before are zero (the default) then assume that
metadata doesn't support changing data_offset.

Signed-off-by: NeilBrown <neilb@suse.de>
10 years agoGrow: use new_data_offset instead of backups for raid4/5/6 reshape.
NeilBrown [Tue, 21 May 2013 06:28:23 +0000 (16:28 +1000)] 
Grow: use new_data_offset instead of backups for raid4/5/6 reshape.

If we can modify the data_offset, we can avoid doing any backups at all.
If we can't fall back on old approach - but not if --data-offset
 was requested.

Signed-off-by: NeilBrown <neilb@suse.de>
10 years agoGrow: introduce min_offset_change to struct reshape.
NeilBrown [Wed, 22 May 2013 02:17:32 +0000 (12:17 +1000)] 
Grow: introduce min_offset_change to struct reshape.

raid10 currently uses the 'backup_blocks' field to store something
else: a minimum offset change.
This is bad practice, we will shortly need to have both for RAID5/6,
so make a separate field.

Signed-off-by: NeilBrown <neilb@suse.de>
10 years agoGrow: have analyse_change zero the reshape structure first.
NeilBrown [Wed, 22 May 2013 01:51:43 +0000 (11:51 +1000)] 
Grow: have analyse_change zero the reshape structure first.

This is generally safer and means we can remove lots of zero
assignments.

Signed-off-by: NeilBrown <neilb@suse.de>
10 years agoGrow.c: split impose_reshape out as a function.
NeilBrown [Tue, 21 May 2013 06:11:08 +0000 (16:11 +1000)] 
Grow.c: split impose_reshape out as a function.

It will be useful soon.
Signed-off-by: NeilBrown <neilb@suse.de>
10 years agoGrow.c: split out update_cache_size() function.
NeilBrown [Tue, 21 May 2013 05:59:11 +0000 (15:59 +1000)] 
Grow.c: split out update_cache_size() function.

Make this a separate function as I might want to call it from another
location.

Signed-off-by: NeilBrown <neilb@suse.de>
10 years agoGrow.c remove some pointless casts on 'data_offset'.
NeilBrown [Tue, 21 May 2013 05:41:25 +0000 (15:41 +1000)] 
Grow.c remove some pointless casts on 'data_offset'.

'data_offset' is 'unsigned long long' so the cast is pointless.

Signed-off-by: NeilBrown <neilb@suse.de>
10 years agosuper1: improve calculation of space_before/space_after
NeilBrown [Tue, 21 May 2013 05:38:49 +0000 (15:38 +1000)] 
super1: improve calculation of space_before/space_after

1/ these must allow for bad-block-list
2/ they must match the kernel, which has a 32k buffer after the
   superblock.

Signed-off-by: NeilBrown <neilb@suse.de>
10 years agoExamine/super1: don't report "New Offset" when feature not set.
NeilBrown [Tue, 21 May 2013 05:37:20 +0000 (15:37 +1000)] 
Examine/super1: don't report "New Offset" when feature not set.

The "new_offset" field may be non-zero, but if the feature flag is not
set, it should be ignored.

Signed-off-by: NeilBrown <neilb@suse.de>
10 years agopr_err for mdmon.
NeilBrown [Tue, 21 May 2013 02:58:02 +0000 (12:58 +1000)] 
pr_err for mdmon.

Signed-off-by: NeilBrown <neilb@suse.de>
10 years agoMore conversion to pr_err
NeilBrown [Tue, 21 May 2013 02:54:52 +0000 (12:54 +1000)] 
More conversion to pr_err

Signed-off-by: NeilBrown <neilb@suse.de>
10 years agoChange some fprintf(stderrs to cont_err()
NeilBrown [Tue, 21 May 2013 02:51:33 +0000 (12:51 +1000)] 
Change some fprintf(stderrs to cont_err()

Signed-off-by: NeilBrown <neilb@suse.de>
10 years agoChange some "fprintf(stderr,"s to pr_err.
NeilBrown [Tue, 21 May 2013 02:40:09 +0000 (12:40 +1000)] 
Change some "fprintf(stderr,"s to pr_err.

They just keep slipping in..

Signed-off-by: NeilBrown <neilb@suse.de>
10 years agoGrow: set_new_data_offset should report if kernel is too old.
NeilBrown [Tue, 21 May 2013 02:34:24 +0000 (12:34 +1000)] 
Grow: set_new_data_offset should report if kernel is too old.

For RAID5, not being able to set new_data_offset because of
old kernel is not a problem.  So make this fatal on for RAID10.

Also remove an unused assignment to 'rv'.

Signed-off-by: NeilBrown <neilb@suse.de>
10 years agocomment typo
NeilBrown [Tue, 21 May 2013 02:25:21 +0000 (12:25 +1000)] 
comment typo

10 years agoGrow: just pass delta_disks instead of all of 'info'.
NeilBrown [Tue, 21 May 2013 01:55:44 +0000 (11:55 +1000)] 
Grow: just pass delta_disks instead of all of 'info'.

That is all we need, so make purpose of code more obvious
by only passing delta_disks.

Signed-off-by: NeilBrown <neilb@suse.de>
10 years agoGrow: split out code for setting new_data_offset
NeilBrown [Tue, 21 May 2013 01:53:43 +0000 (11:53 +1000)] 
Grow: split out code for setting new_data_offset

This will soon be used for more than just RAID10, so
it deserves independent existence.

Signed-off-by: NeilBrown <neilb@suse.de>
10 years agoGrow: replace '1' with 'INVALID_SECTORS' where appropriate.
NeilBrown [Tue, 21 May 2013 01:32:57 +0000 (11:32 +1000)] 
Grow: replace '1' with 'INVALID_SECTORS' where appropriate.

Here are some '1's which missed the introduction of INVALID_SECTORS
as a useful #define.

Signed-off-by: NeilBrown <neilb@suse.de>
10 years agoAdd --dump / --restore functionality.
NeilBrown [Thu, 16 May 2013 05:07:16 +0000 (15:07 +1000)] 
Add --dump / --restore functionality.

This allows the metadata on a device to be saved and later restored.
This can be useful before experimenting on an array that is misbehaving.

Suggested-by: Dan Williams <dan.j.williams@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
10 years agointel,ddf: don't require partitions when ignore_hw_compat is set.
NeilBrown [Thu, 16 May 2013 03:24:07 +0000 (13:24 +1000)] 
intel,ddf: don't require partitions when ignore_hw_compat is set.

Partitions are a hw-compat issue.

This allows e.g "--examine" to be used on image files.

Signed-off-by: NeilBrown <neilb@suse.de>
10 years agoCreate: over-ride "start_ro" setting when creating an array.
NeilBrown [Wed, 15 May 2013 01:40:27 +0000 (11:40 +1000)] 
Create: over-ride "start_ro" setting when creating an array.

If module parameter start_ro is set, arrays start readonly.
This is OK when assembling, but is very surprising when creating
an array as the resync won't start.
So over-ride the setting (unless --read-only was given) make
arrays RW when created.

Signed-off-by: NeilBrown <neilb@suse.de>
10 years agoSuppress error messages from systemctl.
NeilBrown [Wed, 15 May 2013 01:10:54 +0000 (11:10 +1000)] 
Suppress error messages from systemctl.

We call systemctl to see if systemd will run mdmon for us.
If it cannot, we run mdmon directly, so we aren't interested
in the error message.
So redirect stderr to /dev/null.

Signed-off-by: NeilBrown <neilb@suse.de>
10 years agoman pages: remove references to raidtools.
NeilBrown [Wed, 15 May 2013 01:07:17 +0000 (11:07 +1000)] 
man pages: remove references to raidtools.

raidtools is so ancient now that it is uninteresting.

Signed-off-by: NeilBrown <neilb@suse.de>
10 years agocreate_mddev: add support for /dev/md_XXX non-numeric names.
NeilBrown [Wed, 15 May 2013 01:03:25 +0000 (11:03 +1000)] 
create_mddev: add support for /dev/md_XXX non-numeric names.

With the 'devnm' infrastructure fixed, it is quite easy to support
names like "md_home" for md arrays.
The currently defaults to "off" and can be enabled in mdadm.conf with
  CREATE names=yes
This is incase other tools get confused by the new names.

Signed-off-by: NeilBrown <neilb@suse.de>
10 years agoIncremental: remove partitions when assembling.
NeilBrown [Tue, 14 May 2013 02:06:27 +0000 (12:06 +1000)] 
Incremental: remove partitions when assembling.

We remove partitions for --create and --assemble, but not for
--incrmental.
So fix that ommision.

Signed-off-by: NeilBrown <neilb@suse.de>
10 years agoCreate: fix bug with --data-offset.
NeilBrown [Mon, 13 May 2013 07:26:37 +0000 (17:26 +1000)] 
Create: fix bug with --data-offset.

Test for VARIABLE_OFFSET was wrong.

Signed-off-by: NeilBrown <neilb@suse.de>
10 years agoAdd some built files to .gitignore.
NeilBrown [Mon, 13 May 2013 07:11:42 +0000 (17:11 +1000)] 
Add some built files to .gitignore.

Now everything made by "make everything" is suitably ignored.

Signed-off-by: NeilBrown <neilb@suse.de>
10 years agoAlways test return value of posix_memalign.
NeilBrown [Mon, 13 May 2013 07:09:55 +0000 (17:09 +1000)] 
Always test return value of posix_memalign.

FORTIFY_SOURCE likes this, and it is good practice.

Signed-off-by: NeilBrown <neilb@suse.de>
10 years agomdassemble - fix new compile-time problems.
NeilBrown [Mon, 13 May 2013 07:05:16 +0000 (17:05 +1000)] 
mdassemble - fix new compile-time problems.

Signed-off-by: NeilBrown <neilb@suse.de>
10 years agoDetail: report on inactive arrays.
NeilBrown [Mon, 13 May 2013 06:57:10 +0000 (16:57 +1000)] 
Detail: report on inactive arrays.

Array can be inactive when e.g. -I is in the process of assembling them.
This change allows --detail to report limited information about
these arrays.

Signed-off-by: NeilBrown <neilb@suse.de>
10 years agoDetail: fix --brief --verbose
NeilBrown [Mon, 13 May 2013 04:57:41 +0000 (14:57 +1000)] 
Detail: fix --brief --verbose

This pair of options should give a --brief listing including devices=
information.  But recent changes to flag passing broke this.
So fix it.

Signed-off-by: NeilBrown <neilb@suse.de>
10 years agoRemove open-coded use_udev().
NeilBrown [Mon, 13 May 2013 03:03:25 +0000 (13:03 +1000)] 
Remove open-coded use_udev().

Manage_runstop has an open-coded version of use_udev() which is no
longer correct.  So make it use use_udev() explicitly.

Signed-off-by: NeilBrown <neilb@suse.de>
10 years agomisc_scan: don't trust the mapping file too much for device names.
NeilBrown [Mon, 13 May 2013 02:56:38 +0000 (12:56 +1000)] 
misc_scan: don't trust the mapping file too much for device names.

misc_scan assumes that any device name found in the 'mapping' file
is usable.  Usually it is but sometimes not, such as for inactive
devices.
Depending on it isn't really robust, when a name is found, check that
it exists. If not, fall back on map_dev.

This will allow "--detail --scan" to notice inactive devices.

Signed-off-by: NeilBrown <neilb@suse.de>
10 years agoIncrmental: tell udevs to unmount when array looks to have disappeared.
NeilBrown [Mon, 13 May 2013 02:07:40 +0000 (12:07 +1000)] 
Incrmental: tell udevs to unmount when array looks to have disappeared.

If a device is removed which appears to be busy in an md array, then
it is very like the array cannot be used.
We currently try to stop it, but that could fail if udisks had
automatically mounted it.
So tell udisks to unmount it, but ignore any error.

Signed-off-by: NeilBrown <neilb@suse.de>
10 years agomdadm.conf.5: document the use of quotation characters in mdadm.conf
NeilBrown [Mon, 13 May 2013 01:28:15 +0000 (11:28 +1000)] 
mdadm.conf.5: document the use of quotation characters in mdadm.conf

single or double quotes protect spaces and double or single quotes.

Signed-off-by: NeilBrown <neilb@suse.de>
10 years agoManage: support --fail set-X and --remove set-X
NeilBrown [Tue, 5 Mar 2013 01:08:43 +0000 (12:08 +1100)] 
Manage: support --fail set-X and  --remove set-X

A RAID10 array can have 'sets' of devices which are reported by
--detail.
They can now be collectively failed or removed.

Signed-off-by: NeilBrown <neilb@suse.de>
11 years agoWait: also wait if an action is about to start.
NeilBrown [Wed, 1 May 2013 00:23:40 +0000 (10:23 +1000)] 
Wait: also wait if an action is about to start.

If a sync/recover action is about to start but hasn't actually begun
yet, /proc/mdstat won't show it, but md/sync_action will (it checks
MD_RECOVERY_NEEDED).
So when /proc/mdstat seems to say nothing is happening, double check
with md/sync_action.

Signed-off-by: NeilBrown <neilb@suse.de>
11 years agotests: zero devices before --adding them.
NeilBrown [Tue, 30 Apr 2013 23:24:11 +0000 (09:24 +1000)] 
tests: zero devices before --adding them.

Linux 3.10 will allow more "--add" to be handled as "--re-add".
To be sure the tests work correctly we sometimes need to zero
the device to ensure it really is an --add that happens.

Signed-off-by: NeilBrown <neilb@suse.de>
11 years agomdmon: Add missing option documentation to --help output
Jes Sorensen [Thu, 25 Apr 2013 15:24:36 +0000 (17:24 +0200)] 
mdmon: Add missing option documentation to --help output

Document that -a is equivalent to --all, as well as --foreground / -F

Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
Signed-off-by: NeilBrown <neilb@suse.de>
11 years agoDDF: fix bug in compare_super_ddf
mwilck@arcor.de [Tue, 23 Apr 2013 18:10:16 +0000 (20:10 +0200)] 
DDF: fix bug in compare_super_ddf

Fix bug in previous patch
"DDF: compare_super_ddf: merge local info of other superblock"

Just discovered this bug in my last patch set - unfortunately, just after
you committed it.

Signed-off-by: Martin Wilck <mwilck@arcor.de>
Signed-off-by: NeilBrown <neilb@suse.de>
11 years agotests/10ddf-create: omit log output check
mwilck@arcor.de [Fri, 25 Oct 2013 10:07:39 +0000 (12:07 +0200)] 
tests/10ddf-create: omit log output check

The test script was counting output lines - its expectations
don't match the current code any more. Remove this pointless
test.

Signed-off-by: Martin Wilck <mwilck@arcor.de>
Signed-off-by: NeilBrown <neilb@suse.de>
11 years agomonitor: treat unreadable array_state as clean
mwilck@arcor.de [Fri, 25 Oct 2013 10:07:38 +0000 (12:07 +0200)] 
monitor: treat unreadable array_state as clean

Failure to read array_state can only mean the array has been
deleted by the kernel; it is not an indication that the array
is dirty.

Signed-off-by: Martin Wilck <mwilck@arcor.de>
Signed-off-by: NeilBrown <neilb@suse.de>
11 years agomonitor: read_and_act: handle race conditions for resync_start
mwilck@arcor.de [Fri, 25 Oct 2013 10:07:37 +0000 (12:07 +0200)] 
monitor: read_and_act: handle race conditions for resync_start

When arrays are stopped, sysfs attributes may be deleted by
the kernel, and attempts to read these attributes will fail.

Setting resync_start to 0 is wrong in this case, because it
may make is_resync_complete() erroneously return
FALSE for a clean array. It is better to leave resync_start
untouched (the previously read value for this array).

Otherwise set_array_state() will pass thewrong state information
to the metadata handler, which will write it to disk, and at
the next restart an unnecessary recovery is started for the
array.

It is also possible that resync_start is actually *not* deleted
yet when read_and_act is running, and an apparently valid
value of "0" is read from it, with the same effect as described
above. This happens if the kernel has already called md_clean()
on the array (setting recovery_cp = 0), but the delayed removal
of "resync_start" hasn't happened yet. Therefore, in "clear"
state, "resync_start" shouldn't be read at all.

Signed-off-by: Martin Wilck <mwilck@arcor.de>
Signed-off-by: NeilBrown <neilb@suse.de>
11 years agomonitor: don't call pselect() on deleted sysfs files
mwilck@arcor.de [Fri, 25 Oct 2013 10:07:36 +0000 (12:07 +0200)] 
monitor: don't call pselect() on deleted sysfs files

It makes no sense to listen for events on files that have
been deleted. This happens when arrays are stopped and the
kernel removes the associated sysfs structures.

Calling pselect() on the deleted attributes may cause a storm
of wake events.

Signed-off-by: Martin Wilck <mwilck@arcor.de>
Signed-off-by: NeilBrown <neilb@suse.de>
11 years agoDDF: add code to debug state changes
mwilck@arcor.de [Fri, 25 Oct 2013 10:07:35 +0000 (12:07 +0200)] 
DDF: add code to debug state changes

The 10ddf-create test case fails sporadically because wrong meta
data is written, making the array appear inconsistent when it's
restarted. Added code to aid debugging this.

Signed-off-by: Martin Wilck <mwilck@arcor.de>
Signed-off-by: NeilBrown <neilb@suse.de>
11 years agoDDF: brief_detail_super_ddf: print correct UUID for subarrays
mwilck@arcor.de [Fri, 25 Oct 2013 10:07:34 +0000 (12:07 +0200)] 
DDF: brief_detail_super_ddf: print correct UUID for subarrays

Commit c1ea5a98 caused brief_detail_super_ddf() to be called
for subarrays. But the UUID printed was always the one of the
container. This is wrong and actually worse than printing no UUID
at all, and causes the DDF test case (10ddf-create) to fail.

This patch adds code to determine the MD UUID of a subarray correctly.
The hard part is to figure out for which subarray the function is
called. Moved that to an extra function.

Signed-off-by: Martin Wilck <mwilck@arcor.de>
Signed-off-by: NeilBrown <neilb@suse.de>
11 years agoDDF: __write_init_super_ddf: just use seq number of active header
mwilck@arcor.de [Fri, 25 Oct 2013 10:07:33 +0000 (12:07 +0200)] 
DDF: __write_init_super_ddf: just use seq number of active header

It's not necessary to check for 0xffffffff, which is a valid
sequential number.

Signed-off-by: Martin Wilck <mwilck@arcor.de>
Signed-off-by: NeilBrown <neilb@suse.de>
11 years agoDDF: __write_ddf_structure: Fix wrong reference to ddf->primary
mwilck@arcor.de [Fri, 25 Oct 2013 10:07:32 +0000 (12:07 +0200)] 
DDF: __write_ddf_structure: Fix wrong reference to ddf->primary

Should reference "header" instead here.

Signed-off-by: Martin Wilck <mwilck@arcor.de>
Signed-off-by: NeilBrown <neilb@suse.de>
11 years agoManage_runstop: call flush_mdmon if O_EXCL fails on stopping mdmon array.
NeilBrown [Mon, 22 Apr 2013 07:05:33 +0000 (17:05 +1000)] 
Manage_runstop: call flush_mdmon if O_EXCL fails on stopping mdmon array.

When stopping an mdmon array, at reshape might be being aborted
which inhibets O_EXCL.  So if that is possible, call flush_mdmon
to make sure mdmon isn't still busy.

Reported-by: Pawel Baldysiak <pawel.baldysiak@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
11 years agoimsm: monitor: do not finish migration if there are no failed disks
Przemyslaw Czarnowski [Thu, 18 Apr 2013 08:51:37 +0000 (10:51 +0200)] 
imsm: monitor: do not finish migration if there are no failed disks

Transition from "degraded" to "recovery" made in OROM is slightly different
than the same transision in mdadm. Missing disk is not removed from list of
raid devices, but just from map. Therefore mdadm should not end migration
basing on existence of list of missing disks but should rely on count of
failed disks.

Signed-off-by: Przemyslaw Czarnowski <przemyslaw.hawrylewicz.czarnowski@intel.com>
Tested-by: Pawel Baldysiak <pawel.baldysiak@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
11 years agoAdd updating component_size to manager thread of mdmon
Pawel Baldysiak [Wed, 3 Apr 2013 01:43:42 +0000 (12:43 +1100)] 
Add updating component_size to manager thread of mdmon

Mdmon does not update component_size now. It is wrong because in case
of size's expansion component_size is changed by mdadm but mdmon does not
reread its new value and uses a wrong, old one. As a result the metadata
is incorrect during size's expansion. It contains no information that
resync is in progress (there is no checkpoint too). The metadata is
as if resync has already been finished but it has not.

Component_size will be set to match information in sysfs. This value
will be updated by manager thread in manage_member() function.
Now mdmon uses the correct, current value of component_size and the
correct metadata (containing information about resync and checkpoint)
is written.

Signed-off-by: Pawel Baldysiak <pawel.baldysiak@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
11 years agoEnsure mddev_dev struct always zeroed on allocation.
NeilBrown [Tue, 5 Mar 2013 00:53:51 +0000 (11:53 +1100)] 
Ensure mddev_dev struct always zeroed on allocation.

There are a number of fields which should not
be left uninitialised.  e.g. attempt_re_add can get
confused if ->writemostly is not set correctly.

Signed-off-by: NeilBrown <neilb@suse.de>
11 years agoCreate: default to bitmap=internal for large arrays.
NeilBrown [Mon, 4 Mar 2013 23:36:21 +0000 (10:36 +1100)] 
Create: default to bitmap=internal for large arrays.

Here, "large" means components are 100G or more.  It is
usually beneficial to have write-intent bitmaps on such arrays.
They can be suppressed with --bitmap=none

Signed-off-by: NeilBrown <neilb@suse.de>
11 years agoEnhance incremental removal.
NeilBrown [Mon, 4 Mar 2013 22:46:34 +0000 (09:46 +1100)] 
Enhance incremental removal.

When asked to incrementally-remove a device, try marking the array
read-auto first.  That will delay recording the failure in the
metadata until it is really relevant.
This way, if the device are just unplugged when the array is not
really in use, the metadata will remain clean.

If marking the default as faulty fails because it is EBUSY, that
implies that the array would be failed without the device.  As the
device has (presumably gone) - that means the array is dead.  So try
to stop it.  If that fails because it is in use, send a uevent to
report that it is gone.  Hopefully whoever mounted it will now let go.

This means that if  you plug in some devices and they are
auto-assembled, then unplugging them will auto-deassemble relatively
cleanly.

To be complete, we really need the kernel to disassemble the array
after the last close somehow.  Maybe if a REMOVE has failed and a STOP
has failed and nothing else much has happened, it could safely stop
the array on last close.

Signed-off-by: NeilBrown <neilb@suse.de>
11 years agomdadm.8: Detail use for IMSM_NO_PLATFORM environment variable.
NeilBrown [Mon, 4 Mar 2013 06:25:36 +0000 (17:25 +1100)] 
mdadm.8: Detail use for IMSM_NO_PLATFORM environment variable.

Suggested-by: Marcin Tomczak <marcin.tomczak@intel.com>
11 years agoDetail.c: call load_container for container subarrays
mwilck@arcor.de [Fri, 1 Mar 2013 22:28:33 +0000 (23:28 +0100)] 
Detail.c: call load_container for container subarrays

Without calling load_container at this point, the
info structure may be missing some important information.
In particular, information about secondary DDF RAID levels
may be wrong if information is only read from a single disk.

If this fails, fall back to the previous code.

Signed-off-by: Martin Wilck <mwilck@arcor.de>
Signed-off-by: NeilBrown <neilb@suse.de>
11 years agoDDF: compare_super_ddf: merge local info of other superblock
mwilck@arcor.de [Fri, 1 Mar 2013 22:28:32 +0000 (23:28 +0100)] 
DDF: compare_super_ddf: merge local info of other superblock

If a match is found in compare_super_ddf, check the other SB
for local DDF information (VD config records, physical disk data)
which is not available in the current superblock, and add it
if needed.

This is important for the mdmon - when disks are added to a
auto read-only array, they must be present in the DDF structure
in order to guarantee consistent writeback of metadata to all
disks.

Signed-off-by: Martin Wilck <mwilck@arcor.de>
Signed-off-by: NeilBrown <neilb@suse.de>
11 years agoDDF: add sanity checks in compare_super_ddf
mwilck@arcor.de [Fri, 1 Mar 2013 22:28:31 +0000 (23:28 +0100)] 
DDF: add sanity checks in compare_super_ddf

Besides container GUID, also check seqnum, physical and virtual
disk numbers, and check match between local and global sections.

Signed-off-by: Martin Wilck <mwilck@arcor.de>
Signed-off-by: NeilBrown <neilb@suse.de>
11 years agoDDF: __write_init_super_ddf: use correct VD conf
mwilck@arcor.de [Fri, 1 Mar 2013 22:28:30 +0000 (23:28 +0100)] 
DDF: __write_init_super_ddf: use correct VD conf

When writing back the DDF structure, make sure that on each disk
we write the configs that include this disk even if a secondary
RAID level is present. Otherwise the secondary RAID will not be
read correctly any more when we open the device next time.

Signed-off-by: Martin Wilck <mwilck@arcor.de>
Signed-off-by: NeilBrown <neilb@suse.de>
11 years agoDDF: container_content_ddf: handle RAID layout for RAID10
mwilck@arcor.de [Fri, 1 Mar 2013 22:28:29 +0000 (23:28 +0100)] 
DDF: container_content_ddf: handle RAID layout for RAID10

This patch adds basic handling for the special case of RAID10.

Signed-off-by: Martin Wilck <mwilck@arcor.de>
Signed-off-by: NeilBrown <neilb@suse.de>
11 years agoDDF: container_content_ddf: check for secondary RAID
mwilck@arcor.de [Fri, 1 Mar 2013 22:28:28 +0000 (23:28 +0100)] 
DDF: container_content_ddf: check for secondary RAID

Check for supportable secondary RAID configurations.
There is currently only one: RAID 10, if the stripe
sizes and Basic volume sizes are all equal.

With this patch, mdadm will not try to start unsupported
secondary RAID level configurations any more.

Signed-off-by: Martin Wilck <mwilck@arcor.de>
Signed-off-by: NeilBrown <neilb@suse.de>
11 years agoDDF: container_content_ddf: change array disk search loop
mwilck@arcor.de [Fri, 1 Mar 2013 22:28:27 +0000 (23:28 +0100)] 
DDF: container_content_ddf: change array disk search loop

When searching for container elements, loop over the known phys
disks rather than the elements of the current configuration.

This patch changes nothing in the logic or return value of the code.
It just prepares extended logic for handling RAID10.

Signed-off-by: Martin Wilck <mwilck@arcor.de>
Signed-off-by: NeilBrown <neilb@suse.de>
11 years agoDDF: load_ddf_local: store VD conf for other BVDs
mwilck@arcor.de [Fri, 1 Mar 2013 22:28:26 +0000 (23:28 +0100)] 
DDF: load_ddf_local: store VD conf for other BVDs

Store VD config for other BVDs in the other_bvds array.
This allows handling secondary RAID levels in container_content_ddf.

Signed-off-by: Martin Wilck <mwilck@arcor.de>
Signed-off-by: NeilBrown <neilb@suse.de>
11 years agoDDF: added other_bvd to struct vcl
mwilck@arcor.de [Fri, 1 Mar 2013 22:28:25 +0000 (23:28 +0100)] 
DDF: added other_bvd to struct vcl

The VD config structures of different BVDs in the same SVD may be
different. This pointer stores the other BVDs.

Signed-off-by: Martin Wilck <mwilck@arcor.de>
Signed-off-by: NeilBrown <neilb@suse.de>
11 years agoDDF: increase seq number when writing meta data
mwilck@arcor.de [Fri, 1 Mar 2013 22:28:24 +0000 (23:28 +0100)] 
DDF: increase seq number when writing meta data

Cleanly increase the seq number when the DDF structures are
written, instead of always setting it back to 1.

Also, make sure that the sequential number of all headers and
VD conf records is the same.

Signed-off-by: Martin Wilck <mwilck@arcor.de>
Signed-off-by: NeilBrown <neilb@suse.de>
11 years agoDDF: use existing locations for primary and secondary DDF structure
mwilck@arcor.de [Fri, 1 Mar 2013 22:28:23 +0000 (23:28 +0100)] 
DDF: use existing locations for primary and secondary DDF structure

Some RAID BIOSes apparently use hard-coded LBA offsets (presumably
from the end of the disk) for the primary and secondary DDF
structure, ignoring the values given in the DDF anchor. This is
broken BIOS behavior, but it will cause any changes made by MD
(e.g. setting the init_state flag after a full initialization)
to be "forgotten" after the next reboot.

This patch fixes this by using the exiting LBA locations if
available. Verified that this fixes MD+LSI Mega Software RAID
BIOS.

Signed-off-by: Martin Wilck <mwilck@arcor.de>
Signed-off-by: NeilBrown <neilb@suse.de>
11 years agoDDF: cleanly save the secondary DDF structure
mwilck@arcor.de [Fri, 1 Mar 2013 22:28:22 +0000 (23:28 +0100)] 
DDF: cleanly save the secondary DDF structure

So far, mdadm only saved the header of the secondary structure.
With this patch, the full secondary DDF structure is saved
consistently, too. Some vendor DDF implementations need it.

Signed-off-by: Martin Wilck <mwilck@arcor.de>
Signed-off-by: NeilBrown <neilb@suse.de>
11 years agoDiscard devnum in favour of devnm
NeilBrown [Thu, 1 Nov 2012 05:14:01 +0000 (16:14 +1100)] 
Discard devnum in favour of devnm

We widely use a "devnum" which is 0 or +ve for md%d devices
and -ve for md_d%d devices.
But I want to be able to use md_%s device names.

So get rid of devnum (a number) and use devnm (a 32char string).
eg.
  md0
  md_d2
  md_home

Signed-off-by: NeilBrown <neilb@suse.de>
11 years agoGrow: fix problem with reshaping RAID4 to RAID0.
NeilBrown [Thu, 21 Feb 2013 06:02:21 +0000 (17:02 +1100)] 
Grow: fix problem with reshaping RAID4 to RAID0.

As 'layout' doesn't map neatly from RAID4 to RAID5, we need to
set it correctly for RAID4.
Also, when no reshape is needed we should set re->level to the final
desired level.

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