]> git.ipfire.org Git - thirdparty/mdadm.git/log
thirdparty/mdadm.git
10 years agoMake: CXFLAGS should be conditionally assigned. mdadm-3.3-rc1
NeilBrown [Mon, 24 Jun 2013 06:59:37 +0000 (16:59 +1000)] 
Make: CXFLAGS should be conditionally assigned.

As the Makefile encourages users to set CXFLAGS for extra flags,
we should only conditionally set it.
That way it can be over-ridden in the environment as well as on
the command line.

Suggested-by: Bernd Schubert <bernd.schubert@itwm.fraunhofer.de>
Signed-off-by: NeilBrown <neilb@suse.de>
10 years agoDetail: deterministic ordering in --brief --verbose
mwilck@arcor.de [Thu, 20 Jun 2013 20:21:05 +0000 (22:21 +0200)] 
Detail: deterministic ordering in --brief --verbose

Have mdadm --Detail --brief --verbose print the list of devices in
alphabetical order.

This is useful for debugging purposes. E.g. the test script
10ddf-create compares the output of two mdadm -Dbv calls which
may be different if the order is not deterministic.

(I confess: I use a modified "test" script that always runs
"mdadm --verbose" rather than "mdadm --quiet", otherwise this
wouldn't happen in 10ddf-create).

Signed-off-by: Martin Wilck <mwilck@arcor.de>
Signed-off-by: NeilBrown <neilb@suse.de>
10 years agosuper1: fix space_{before,after} for RAID0
NeilBrown [Mon, 24 Jun 2013 06:24:08 +0000 (16:24 +1000)] 
super1: fix space_{before,after} for RAID0

For RAID0 we need to use 'data_size', no 'size' as later is 0.

Signed-off-by: NeilBrown <neilb@suse.de>
10 years agoGrow: allow "--add" with "--grow --level=??"
NeilBrown [Mon, 24 Jun 2013 06:13:00 +0000 (16:13 +1000)] 
Grow: allow "--add" with "--grow --level=??"

This is useful for reshaping a RAID0 to a higher level.
The recovery will happen at the same time as the reshape.

Signed-off-by: NeilBrown <neilb@suse.de>
10 years agoGrow: chose default layout when converting from RAID0.
NeilBrown [Mon, 24 Jun 2013 06:06:21 +0000 (16:06 +1000)] 
Grow: chose default layout when converting from RAID0.

If we don't do this explicitly, we end up keeping the "current"
layout, which is meaningless for RAID0.

Signed-off-by: NeilBrown <neilb@suse.de>
10 years agotests: add test for converting levels to raid0 and back.
NeilBrown [Mon, 24 Jun 2013 05:57:58 +0000 (15:57 +1000)] 
tests: add test for converting levels to raid0 and back.

Now that I have this mostly working, I should make sure
it doesn't break...

Signed-off-by: NeilBrown <neilb@suse.de>
10 years agotest/00names: use appropriate mdadm.conf
NeilBrown [Mon, 24 Jun 2013 05:44:36 +0000 (15:44 +1000)] 
test/00names: use appropriate mdadm.conf

Using non-numeric names needs an mdadm.conf setting,
so make sure we have one.

Signed-off-by: NeilBrown <neilb@suse.de>
10 years agoGrow: centralise level-change code.
NeilBrown [Mon, 24 Jun 2013 05:27:07 +0000 (15:27 +1000)] 
Grow: centralise level-change code.

There are now 3 places which change level.
And they all do it slightly differently with different
messages etc.

Make a single function for this and use it.

Signed-off-by: NeilBrown <neilb@suse.de>
10 years agoGrow: remove excess drives when converting to RAID0.
NeilBrown [Mon, 24 Jun 2013 04:08:41 +0000 (14:08 +1000)] 
Grow: remove excess drives when converting to RAID0.

When converting to RAID0, all spares and non-data drives
need to be removed first.
It is possible that the first HOT_REMOVE_DISK will fail because the
personality hasn't let go of it yet, so retry a few times.

Signed-off-by: NeilBrown <neilb@suse.de>
10 years agoGrow: clear new_layout when we change the level.
NeilBrown [Mon, 24 Jun 2013 03:08:13 +0000 (13:08 +1000)] 
Grow: clear new_layout when we change the level.

After changing the level, the meaning of layout numbers changes,
so we will keeping a new_layout value around can cause later confusion.

Signed-off-by: NeilBrown <neilb@suse.de>
10 years agoGrow: analyse_change needs to set new_size even if nothing much is happening.
NeilBrown [Mon, 24 Jun 2013 03:06:32 +0000 (13:06 +1000)] 
Grow: analyse_change needs to set new_size even if nothing much is happening.

This means it will be set for a "--data-offset" only reshape so that
case doesn't complain that the array is getting smaller.

Signed-off-by: NeilBrown <neilb@suse.de>
10 years agoGrow: fix two problems with new_data_offset
NeilBrown [Mon, 24 Jun 2013 03:04:38 +0000 (13:04 +1000)] 
Grow: fix two problems with new_data_offset

1/ ignore failed devices - obviously
2/ We need to tell the kernel which direction the reshape should
   progress even if we didn't choose the particular data_offset
   to use.

Signed-off-by: NeilBrown <neilb@suse.de>
10 years agoGrow: Try hard to set new_offset.
NeilBrown [Mon, 24 Jun 2013 03:02:35 +0000 (13:02 +1000)] 
Grow: Try hard to set new_offset.

Setting new_offset can fail if the v1.x "data_size" is too small.
So if that happens, try increasing it first by writing "0".
That can fail on spare devices due to a kernel bug, so if it doesn't
try writing the correct number of sectors.

Signed-off-by: NeilBrown <neilb@suse.de>
10 years agoGrow: Make sure new data-offset is well-aligned
NeilBrown [Mon, 24 Jun 2013 02:55:41 +0000 (12:55 +1000)] 
Grow: Make sure new data-offset is well-aligned

If we choose a new data-offset, make sure it is rounded to a largest
power of to possible, up to 1Meg

Signed-off-by: NeilBrown <neilb@suse.de>
10 years agoGrow: a data_offset should not be tested against 0.
NeilBrown [Wed, 19 Jun 2013 06:55:35 +0000 (16:55 +1000)] 
Grow: a data_offset should not be tested against 0.

It should always be tested against INVALID_SECTORS!!!

Signed-off-by: NeilBrown <neilb@suse.de>
10 years agotests: add test for non-numeric device names
NeilBrown [Wed, 19 Jun 2013 06:44:18 +0000 (16:44 +1000)] 
tests: add test for non-numeric device names

Signed-off-by: NeilBrown <neilb@suse.de>
10 years agoAdd test for interaction of --assemble with --incr
NeilBrown [Wed, 19 Jun 2013 06:33:55 +0000 (16:33 +1000)] 
Add test for interaction of --assemble with --incr

and fix the bug that it found.  The refactor of start_array()
missed a test.

Signed-off-by: NeilBrown <neilb@suse.de>
10 years agoAdd test for --update=metadata and fix bug it found.
NeilBrown [Wed, 19 Jun 2013 06:28:05 +0000 (16:28 +1000)] 
Add test for --update=metadata and fix bug it found.

We were not setting device size correctly for raid0.

Signed-off-by: NeilBrown <neilb@suse.de>
10 years agotests: rearrange sometest groupings.
NeilBrown [Wed, 19 Jun 2013 03:46:53 +0000 (13:46 +1000)] 
tests: rearrange sometest groupings.

All 'update' tests in 04
More imsm tests in 09

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