Commit Graph

339 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 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 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 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 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 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 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 4dd2df0966 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>
2013-02-21 17:05:23 +11:00
NeilBrown fdcad551e9 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>
2013-02-21 17:02:21 +11:00
NeilBrown 3920235ea2 Grow: disallow --size changes on RAID0 and Linear.
These aren't meaningful and must be disabled.

Signed-off-by: NeilBrown <neilb@suse.de>
2013-02-21 14:51:11 +11:00
NeilBrown ae0dcfbdb2 Grow: fix bug when multiple arrays present.
commit 1f9b0e2845
    Grow - be careful about 'delayed' reshapes.

Introduced a bug where a list of devices longer than 1
would cause an infinite loop.  Oops.

Signed-off-by: NeilBrown <neilb@suse.de>
2012-11-22 08:57:25 +11:00
Lukasz Dorau f3f09a520f Grow.c: fix uninitialized variables compilation-time error
It fixes the following uninitialized variables compilation-time error:
WARN  - Grow.c: In function ‘reshape_array’:
WARN  - Grow.c:2413:21: error: ‘min_space_after’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
WARN  - Grow.c:2376:39: note: ‘min_space_after’ was declared here
WARN  - Grow.c:2414:22: error: ‘min_space_before’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
WARN  - Grow.c:2376:21: note: ‘min_space_before’ was declared here
WARN  - cc1: all warnings being treated as errors
WARN  - make: *** [Grow.o] Error 1
It occurs during compilation of mdadm on Fedora 17.

Signed-off-by: Lukasz Dorau <lukasz.dorau@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
2012-11-20 12:12:03 +11:00
NeilBrown 6a67848ab6 Grow: fix reshape from RAID5 to RAID1.
Commit 5da9ab9874
       Grow_reshape re-factor
in mdadm-3.2 broke conversion from RAID5 and RAID1 - and we
never noticed.

This fixes it.

Signed-off-by: NeilBrown <neilb@suse.de>
2012-11-20 12:06:34 +11:00
NeilBrown 869523878e Grow: fix a couple of typos with --assume-clean usage
Signed-off-by: NeilBrown <neilb@suse.de>
2012-10-11 11:35:41 +11:00
NeilBrown e0ab37a3ae Grow: allow --grow --continue to work for native metadata.
As it was the code would crash due to "mdstat" being NULL.
Code is now more sane, but hasn't been tested on an array that
needs to grow.

Signed-off-by: NeilBrown <neilb@suse.de>
2012-10-09 13:54:59 +11:00
NeilBrown ee2429e0bc Grow/raid10: support reducing the devices in a RAID10.
When reducing the number of devices in a RAID10, we increase the
data offset to avoid the need for backup area.

If there is no room at the end of the device to allow this, we need
to first reduce the component size of each device.  However if there
is room, we don't want to insist on that, otherwise growing then
shrinking the array would not be idempotent.

So find the min before/after space before analysing a RAID10 for
reshape, and if the after space is insufficient, reduce the total size
of the array and the component size accordingly.

Signed-off-by: NeilBrown <neilb@suse.de>
2012-10-04 16:34:21 +10:00
NeilBrown 19ceb16daf Grow: add raid10 reshape.
RAID10 reshape requires that data_offset be changed.
So we only allow it if the new_data_offset attribute is available,
and we compute a suitable change in data offset.

Signed-off-by: NeilBrown <neilb@suse.de>
2012-10-04 16:34:21 +10:00
NeilBrown b48e2e25c4 Split 'GCD' out into a separate function.
It is neater that way.

Signed-off-by: NeilBrown <neilb@suse.de>
2012-10-04 16:34:21 +10:00
NeilBrown 40c9a66a5c Add --data-offset flag for Create and Grow
This can be used to over-ride the automatic assignment of
data offset.
For --create, it is useful to re-create old arrays where different
   defaults applied.
For --grow it may be able to force a reshape in the reverse direction.

Signed-off-by: NeilBrown <neilb@suse.de>
2012-10-04 16:34:21 +10:00
NeilBrown 676ab3120b Grow: make warning about old metadata more explicit.
Don't print it just when --verbose is set, and explain how
to over-ride it.

Signed-off-by: NeilBrown <neilb@suse.de>
2012-10-03 14:44:20 +10:00
NeilBrown 1f9b0e2845 Grow - be careful about 'delayed' reshapes.
If multiple reshapes are activated on the same devices (different
partitions) then one might be forced to wait for the other to
complete.
As reshaping suspends access to small sections of the array
at time, this cause a region to be suspended for a long time,
which isn't good.

To try to detect this and don't start suspending until
the reshape is actually happening.

This is only effective on 3.7 and later as prior kernels
don't report when the delayed reshape can progress.  For
the earlier kernels, just give a warning.

Signed-off-by; NeilBrown <neilb@suse.de>
2012-10-03 14:41:31 +10:00
NeilBrown 887a7a9e98 grow: fix typo : MAX_DISKS -> MAX_SIZE
oopps.

Signed-off-by: NeilBrown <neilb@suse.de>
2012-09-20 11:32:39 +10:00
Lukasz Dorau 7ec0996cf6 Grow.c: change size to be unsigned and use '0' in case of 'no change'
The 'size' has been changed to be unsigned recently.
Analogous changes should be made to reshape_super().
'0' should be used in case of 'no change' now.

Signed-off-by: Lukasz Dorau <lukasz.dorau@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
2012-08-13 08:07:01 +10:00
NeilBrown ca3b669603 Minor cosmetic fixes in various files.
Signed-off-by: NeilBrown <neilb@suse.de>
2012-08-13 08:00:21 +10:00
NeilBrown 0a8b92a6f6 Fix default size calculations that were recently broken.
commit d04f65f48c
    Change the values for "max size" from -1 to 1.

Messed up 's->size' - leaving it as '1' (MAX_SIZE) in some cases and
causing the array reshape to fail.

Signed-off-by: NeilBrown <neilb@suse.de>
2012-08-13 08:00:18 +10:00
NeilBrown 50f01ba5a1 Use new struct context and struct shape for Grow_addbitmap
Signed-off-by: NeilBrown <neilb@suse.de>
2012-07-09 17:22:12 +10:00
NeilBrown 32754b7d84 Use new struct context and struct shape in Grow_reshape
Signed-off-by: NeilBrown <neilb@suse.de>
2012-07-09 17:22:09 +10:00
NeilBrown d04f65f48c Change the values for "max size" from -1 to 1.
Both are impossible, and '1' allows size to be unsigned,
which is neater.
Also #define MAX_SIZE to be '1' to make it all more explicit.

Signed-off-by: NeilBrown <neilb@suse.de>
2012-07-09 17:20:32 +10:00
NeilBrown ba728be72f Convert 'quiet' to 'not verbose' in various places.
If we change some functions to accept 'verbose', where <0 means to be
quiet, in place of 'quiet', then we will be able to merge
'quiet' and 'verbose' together for simplicity.

Signed-off-by: NeilBrown <neilb@suse.de>
2012-07-09 17:18:09 +10:00
NeilBrown 503975b9d5 Remove scattered checks for malloc success.
malloc should never fail, and if it does it is unlikely
that anything else useful can be done.  Best approach is to
abort and let some super-daemon restart.

So define xmalloc, xcalloc, xrealloc, xstrdup which don't
fail but just print a message and exit.  Then use those
removing all the tests for failure.

Also replace all "malloc;memset" sequences with 'xcalloc'.

Signed-off-by: NeilBrown <neilb@suse.de>
2012-07-09 17:14:16 +10:00
NeilBrown e7b84f9d50 Introduce pr_err for printing error messages.
'pr_err("' is a lot shorter than 'fprintf(stderr, Name ": '
cont_err() is also available.

Signed-off-by: NeilBrown <neilb@suse.de>
2012-07-09 17:14:16 +10:00
NeilBrown c456301a05 Grow: don't print message if unfreezing fails.
This is most likely to happen if the array has been stopped,
in which case the error is pointless.

Reported-by: Patrik Horník <patrik@dsl.sk>
Signed-off-by: NeilBrown <neilb@suse.de>
2012-05-15 12:12:58 +10:00