Commit Graph

363 Commits

Author SHA1 Message Date
NeilBrown 6f02172d2e Release mdadm-3.3
(and  various cosmetic fixes)

Signed-off-by: NeilBrown <neilb@suse.de>
2013-09-03 14:47:47 +10:00
NeilBrown 2cdd5ce0e7 Grow: fix hang when growing a RAID5.
Since:

commit 84d11e6c6a
Author: NeilBrown <neilb@suse.de>
Date:   Thu Aug 1 11:16:14 2013 +1000

    Grow: exit background thread cleanly on SIGTERM.

removed the setting of "sync_max" from abort_reshape() we need
to do it explicitly here.

Signed-off-by: NeilBrown <neilb@suse.de>
2013-08-28 17:00:53 +10:00
NeilBrown 84d11e6c6a Grow: exit background thread cleanly on SIGTERM.
If the mdadm thread that monitors a reshape gets SIGTERM it should
exit cleanly and clear the 'suspended' region of the array.
However it mustn't clear 'sync_max' as that would allow the
reshape to continue unmonitored.

If the thread ever does get killed, the array should really be
shutdown soon after if possible.

Signed-off-by: NeilBrown <neilb@suse.de>
2013-08-01 13:58:10 +10:00
Jes Sorensen 364a48c992 Avoid double close()
Coverity discovered a possible double close(fd2) in Grow.c. Avoided by
invalidating fd2 after the first close.

Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
Signed-off-by: NeilBrown <neilb@suse.de>
2013-07-31 08:51:16 +10:00
NeilBrown 3377ee4248 Grow: don't hold array open while waiting for reshape.
If we will need to change array level when a reshape completes, a copy
of mdadm waits in the background.
Currently this copy hold the device (/dev/mdX) open.  This prevents
the array from being stopped.

So close the file descriptor and re-open after the reshape completes.

Signed-off-by: NeilBrown <neilb@suse.de>
2013-07-24 12:21:10 +10:00
NeilBrown ca36d70735 Grow: pass INVALID_SECTORS to reshape_array, not 0.
'0' means 'make it 0', which isn't what we want here.
We want 'leave it unchanged'.

Signed-off-by: NeilBrown  <neilb@suse.de>
2013-07-11 12:42:12 +10:00
NeilBrown a7a0d8a116 Grow: use mdstat_wait to wait for delayed reshape.
Having a fix time for a wait is clumsy and can make us
wait much too long.
So use mdstat_wait and keep the mdstat_fd open.
This requires an 'mdstat_close' so it doesn't stay open
forever.

Signed-off-by: NeilBrown <neilb@suse.de>
2013-07-10 11:10:54 +10:00
NeilBrown a6b2d86c62 Grow: notice when --stop is synchronising a reshape and don't mess it up.
--stop now tries to wait for a reshape to be at just the right spot.
However for a reducing reshape, mdadm will be running in the
background watching, and might adjust sync_max and mess things up.

So teach "progress_reshape" to notice when "sync_max" is modified, and
leave it alone.

Signed-off-by: NeilBrown <neilb@suse.de>
2013-07-04 17:18:24 +10:00
NeilBrown 737f8574cd Grow: fix small bug when reshape interrupted.
progress_reshape() may not set reshape_completed if the reshape is
interrupted, so we need to initialize it to the current value before
hand, so the value used afterwards is credible.

Signed-off-by: NeilBrown <neilb@suse.de>
2013-07-04 17:10:37 +10:00
NeilBrown be7c26b48c Assemble: improve messages when restarting a reshape.
If the restarted reshape needs a backup file and we don't have one,
that should be reported before we try to start the array.
Also we shouldn't say the "Cannot grow" but "cannot complete".

Signed-off-by: NeilBrown <neilb@suse.de>
2013-07-02 13:09:07 +10:00
NeilBrown 2eba849621 Manage: check alignment when stopping an array undergoing reshape.
To be able to revert-reshape of raid4/5/6 which is changing
the number of devices, the reshape must has been stopped on a multiple
of the old and new stripe sizes.

The kernel only enforces the new stripe size multiple.

So we enforce the old-stripe-size multiple by careful use of
"sync_max" and monitoring "reshape_position".

Signed-off-by: NeilBrown <neilb@suse.de>
2013-07-01 15:10:05 +10:00
NeilBrown efc67e8e9f New function: sysfs_wait
We have several places that wait for activity on a sysfs
file.  Combine most of these into a single 'sysfs_wait' function.

Signed-off-by: NeilBrown <neilb@suse.de>
2013-07-01 13:28:13 +10:00
NeilBrown dfa4d769f0 Grow: fix crash when restarting an array.
After the 'started' label it is assumed that 'sra' is set, so better
set it when jumping there.

Signed-off-by: NeilBrown <neilb@suse.de>
2013-06-27 13:10:44 +10:00
NeilBrown 6a23fb9d0d Grow: lack of head/tail space not fatal for RAID5 etc.
For RAID10, we must have head/tail space for reshape.
For RAID4/5/6 we can use a spare or a backup file.

So make that distinction.

Signed-off-by: NeilBrown <neilb@suse.de>
2013-06-27 12:58:16 +10:00
NeilBrown a73b00811c Grow: report better message when --grow --chunk cannot work.
When changing the chunksize of an array, the new chunksize must
divide the device size.
If it doesn't we report a very brief message.
Make this message a bit longer and suggest a way forward be reducing
the size of the array.

Reported-by: Mark Knecht <markknecht@gmail.com>
Signed-off-by: NeilBrown <neilb@suse.de>
2013-06-27 10:12:31 +10:00
NeilBrown e5ba75ce03 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>
2013-06-24 16:06:21 +10:00
NeilBrown 97e3a6a0e0 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>
2013-06-24 15:27:07 +10:00
NeilBrown 6fb8746e4a 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>
2013-06-24 14:08:41 +10:00
NeilBrown 9030d55ff2 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>
2013-06-24 13:08:13 +10:00
NeilBrown ddbf2ebb0e 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>
2013-06-24 13:06:32 +10:00
NeilBrown b397d7f3e0 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>
2013-06-24 13:04:38 +10:00
NeilBrown a6a78630ac 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>
2013-06-24 13:02:35 +10:00
NeilBrown 534f543296 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>
2013-06-24 12:55:41 +10:00
NeilBrown e09233d048 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>
2013-06-19 16:55:35 +10:00
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