Commit Graph

2605 Commits

Author SHA1 Message Date
NeilBrown 1011e8344a 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>
2013-06-19 12:31:45 +10:00
NeilBrown e6dd89da86 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>
2013-06-19 11:39:14 +10:00
NeilBrown fe7e0e64b0 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>
2013-06-19 11:23:44 +10:00
NeilBrown 8cde842b18 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>
2013-06-19 11:09:33 +10:00
NeilBrown 54def20f8b 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>
2013-06-19 10:39:36 +10:00
NeilBrown 64e103fe19 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>
2013-06-19 10:33:47 +10:00
Bernd Schubert 2161adce8f 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>
2013-06-19 10:05:38 +10:00
Bernd Schubert 2c7b668df7 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>
2013-06-19 10:04:43 +10:00
Bernd Schubert 635b5861c3 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>
2013-06-19 10:04:18 +10:00
Bernd Schubert 3a89d75488 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>
2013-06-19 10:03:44 +10:00
Bernd Schubert f8fcf7a1c5 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>
2013-06-19 10:03:12 +10:00
NeilBrown 7506f86012 Makefile: add "-O3" to WARN_UNUSED options.
This finds more errors

Also remove some trailing spaces.

Signed-off-by: NeilBrown <neilb@suse.de>
2013-06-19 10:02:54 +10:00
NeilBrown c0f0d8128a 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>
2013-06-19 09:58:02 +10:00
NeilBrown f69bb60857 super0: set uninitialized variable.
Reported by -O3

Signed-off-by: NeilBrown  <neilb@suse.de>
2013-06-19 09:51:01 +10:00
NeilBrown f80057aec5 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>
2013-06-17 16:55:31 +10:00
NeilBrown e2f408a4c0 mdadm.h: add little bits of doco for 'struct superswitch'.
Signed-off-by: NeilBrown <neilb@suse.de>
2013-06-17 16:04:59 +10:00
NeilBrown a7dec3fd92 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>
2013-05-30 14:31:09 +10:00
NeilBrown 041b815f17 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>
2013-05-29 09:13:25 +10:00
NeilBrown 8ecf12b9f8 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>
2013-05-28 16:58:18 +10:00
NeilBrown 26bf55874d 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>
2013-05-28 16:58:18 +10:00
NeilBrown f9b08fecd8 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>
2013-05-28 16:58:18 +10:00
NeilBrown 199f1a1fad Assemble: allow --update=revert-reshape
This will cause a reshape to start going backwards.
2013-05-28 16:44:23 +10:00
NeilBrown afa368f49a 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>
2013-05-28 16:44:22 +10:00
NeilBrown d6e4b44fdb 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>
2013-05-28 16:43:03 +10:00
NeilBrown 5e1863d49d Examine/super1 - report Unused space, before and after.
Might be confusing, or might be useful when reshaping.

Signed-off-by: NeilBrown <neilb@suse.de>
2013-05-22 16:37:19 +10:00
NeilBrown f79bbf4f69 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>
2013-05-22 16:00:21 +10:00
NeilBrown 8876bf0bb6 Grow: allow a reshape which only changes --data-offset
Sometimes, that is all we want to do.

Signed-off-by: NeilBrown <neilb@suse.de>
2013-05-22 12:27:40 +10:00
NeilBrown d7e1f52bb8 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>
2013-05-22 12:27:35 +10:00
NeilBrown 8192902ff7 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>
2013-05-22 12:26:35 +10:00
NeilBrown 9ad2a640fe 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>
2013-05-22 12:26:35 +10:00
NeilBrown 4abcbc21b9 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>
2013-05-22 12:26:35 +10:00
NeilBrown c4b26c643d 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>
2013-05-22 12:26:19 +10:00
NeilBrown 63c12c89d4 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>
2013-05-22 12:22:36 +10:00
NeilBrown 89ecd3cfe4 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>
2013-05-22 12:20:39 +10:00
NeilBrown 6b2fc3c162 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>
2013-05-22 12:20:31 +10:00
NeilBrown 77afa056f2 Grow.c: split impose_reshape out as a function.
It will be useful soon.
Signed-off-by: NeilBrown <neilb@suse.de>
2013-05-21 16:16:31 +10:00
NeilBrown 434d167e93 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>
2013-05-21 15:59:11 +10:00
NeilBrown ec787874d9 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>
2013-05-21 15:41:25 +10:00
NeilBrown cc3130a786 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>
2013-05-21 15:38:49 +10:00
NeilBrown 8772113ab2 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>
2013-05-21 15:37:20 +10:00
NeilBrown a88e119f6f pr_err for mdmon.
Signed-off-by: NeilBrown <neilb@suse.de>
2013-05-21 12:58:02 +10:00
NeilBrown e12b3daab7 More conversion to pr_err
Signed-off-by: NeilBrown <neilb@suse.de>
2013-05-21 12:54:52 +10:00
NeilBrown d33f151842 Change some fprintf(stderrs to cont_err()
Signed-off-by: NeilBrown <neilb@suse.de>
2013-05-21 12:51:33 +10:00
NeilBrown ed503f89e4 Change some "fprintf(stderr,"s to pr_err.
They just keep slipping in..

Signed-off-by: NeilBrown <neilb@suse.de>
2013-05-21 12:42:57 +10:00
NeilBrown 93f174b986 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>
2013-05-21 12:34:24 +10:00
NeilBrown 033d0929ad comment typo 2013-05-21 12:25:21 +10:00
NeilBrown 50a4962f0f 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>
2013-05-21 11:55:44 +10:00
NeilBrown 13bbb145cd 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>
2013-05-21 11:53:43 +10:00
NeilBrown 5582b118c6 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>
2013-05-21 11:32:57 +10:00
NeilBrown 74db60b00a 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>
2013-05-16 15:07:16 +10:00