summaryrefslogtreecommitdiff
path: root/Grow.c
Commit message (Collapse)AuthorAge
* Grow: improve error message is "--grow -n2" used on Linear arrays.NeilBrown2014-07-29
| | | | | | | | | | Linear arrays don't respond to setting raid-disks, only to adding a device. Reported-by: mulhern Reported-by: Jes Sorensen <Jes.Sorensen@redhat.com> Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1122146 Signed-off-by: NeilBrown <neilb@suse.de>
* Grow: fix that preventing resize of array to 32bit size.NeilBrown2014-07-21
| | | | | | | | | | | | If the request --size to --grow an array to is 32bits (i.e. msb in bit 32) then mdadm make wrong choice and uses ioctl instead of setting component_size via sysfs and the change is ignored. This is fixed by using correct casts. Reported-and-tested-by: Killian De Volder <killian.de.volder@megasoft.be> Signed-off-by: NeilBrown <neilb@suse.de>
* Grow: Do not try to restart if reshape is runningPawel Baldysiak2014-07-17
| | | | | | | | | | | | | Grow process did not check if reshape is already started when deciding about restarting. Sync_action should be checked in this case, and if reshape is running - restart flag should not be set. Otherwise, Grow process will fail to write data to sysfs, and reshape will not be continued. Signed-off-by: Pawel Baldysiak <pawel.baldysiak@intel.com> Signed-off-by: Artur Paszkiewicz <artur.paszkiewicz@intel.com> Signed-off-by: NeilBrown <neilb@suse.de>
* Grow: fix removal of line in wrong casePawel Baldysiak2014-06-12
| | | | | | | | | | Commit 18d9bcfa33939cee345d4d7735bc6081bcc409c8 removed wrong line (in case RAID0->RAID4). This patch corrects this mistake (line should be removed in case RAID4->RAID4). Signed-off-by: Pawel Baldysiak <pawel.baldysiak@intel.com> Signed-off-by: NeilBrown <neilb@suse.de>
* Make sure "make everything" builds again.NeilBrown2014-06-05
| | | | Signed-off-by: NeilBrown <neilb@suse.de>
* Grow: Do not fork via systemd if freeze_reshape is setBaldysiak, Pawel2014-06-02
| | | | | | | | | | Mdadm should not run 'grow-continue' unit file for container if '--freeze-reshape' argument is passed. Otherwise it will be ignored, and reshape will start anyway. Signed-off-by: Pawel Baldysiak <pawel.baldysiak@intel.com> Reviewed-by: Artur Paszkiewicz <artur.paszkiewicz@intel.com> Signed-off-by: NeilBrown <neilb@suse.de>
* Grow: Use 'forked' also for reshape_container in Grow_continueBaldysiak, Pawel2014-06-02
| | | | | | | | | Similar to commit 06e293d0970e36b1ed049b9d3ccb21a870e9d2eb same thing should be done for reshape_container in Grow_continue Signed-off-by: Pawel Baldysiak <pawel.baldysiak@intel.com> Reviewed-by: Artur Paszkiewicz <artur.paszkiewicz@intel.com> Signed-off-by: NeilBrown <neilb@suse.de>
* Do not set default 'before.layout' when reshaping from RAID4 to RAID4Baldysiak, Pawel2014-06-02
| | | | | | | | | | | | | | | | | Commit fdcad551e9a54c4aa8c4b63160b76e2c539a0441 brings some changes to reshape process. Setting 'before.layout' when reshaping from RAID4 to another RAID4 is not really necessary. If reshape is restarted 'before.layout' will be compared with 'info->array.layout' in reshape_array(). Changes brought by mentioned commit will cause this comparation return as false, becouse 'array.layout' is always set to 'ALGORITHM_PARITY_N' in analyse_change() for RAID4, so reshape will not be continued after reboot/stop. This patch reverts unnecessary changes. Signed-off-by: Pawel Baldysiak pawel.baldysiak@intel.com Reviewed-by: Artur Paszkiewicz <artur.paszkiewicz@intel.com> Signed-off-by: NeilBrown <neilb@suse.de>
* mdadm: Do not reimplment offsetofCristian Rodríguez2014-05-22
| | | | | | Proper implementations have offsetof in stddef.h Signed-off-by: NeilBrown <neilb@suse.de>
* Grow: fix resent grow_continue breakage.NeilBrown2014-05-22
| | | | | | | | | | | | | | | | | Commit 5e76dce1acd906e8fc8af04973c3a129cdc77fd6 changed Grow_continue to assume a fork had already happened, so that mdadm --grow --continue didn't fork. This is good, but it means that if Grow_continue is run from Assemble, then mdadm --assemble .... can misbehave if the array was in the middle of a reshape. So introduce finer control. Grow_continue only assumes it has already forked if run from "mdadm --grow --continue". Signed-off-by: NeilBrown <neilb@suse.de>
* Reshape: use systemd to continue containers as well as native arrays.NeilBrown2014-05-20
| | | | Signed-off-by: NeilBrown <neilb@suse.de>
* Grow: split continue_via_systemd into a separate function.NeilBrown2014-05-20
| | | | | | This allows it to be used for containers too. Signed-off-by: NeilBrown <neilb@suse.de>
* Grow: add 'forked' option to reshape_container.NeilBrown2014-05-20
| | | | | | | | This is a better match for reshape_array() and means that "mdadm --grow --continue" will run in the foreground, which makes more sense. Signed-off-by: NeilBrown <neilb@suse.de>
* Grow: try to let "--grow --continue" from systemd complete a reshape.NeilBrown2014-05-15
| | | | | | | | | | | If "--assemble" or "--incremental" is started by udev, then monitoring the reshape in the background won't work. So try asking systemd to start a grow-continue. If that fails, just do it the old way. Signed-off-by: NeilBrown <neilb@suse.de>
* Grow: store a link to current backup file in /run/mdadm or similar.NeilBrown2014-05-15
| | | | | | | | | | | | | | Subsequent patch will allow the background part of "mdadm --grow" to be run from systemd. This can require the passing of a backup file name. To do this, store that name as a symlink in /run/mdadm (or MAP_DIR) and look for it when appropriate. It might be useful to also store the name across reboot, but that would be a different patch. We would need to use the uuid to identify it, and store it in stable storage. Signed-off-by: NeilBrown <neilb@suse.de>
* Grow: fix problems with prematurely aborting of reshapes.NeilBrown2014-01-20
| | | | | | | | | | 1/ when unfreezing, make sure the array is frozen first. If it isn't we might end up interrupting a reshape. 2/ When the child finishes, don't call abort_reshape() as that will interrupt the reshape. Just set suspend_* etc explicitly. Signed-off-by: NeilBrown <neilb@suse.de>
* Release mdadm-3.3NeilBrown2013-09-03
| | | | | | (and various cosmetic fixes) Signed-off-by: NeilBrown <neilb@suse.de>
* Grow: fix hang when growing a RAID5.NeilBrown2013-08-28
| | | | | | | | | | | | | | | Since: commit 84d11e6c6a3b827b2daa32e16303235ce33d49f5 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>
* Grow: exit background thread cleanly on SIGTERM.NeilBrown2013-08-01
| | | | | | | | | | | | 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>
* Avoid double close()Jes Sorensen2013-07-31
| | | | | | | | 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>
* Grow: don't hold array open while waiting for reshape.NeilBrown2013-07-24
| | | | | | | | | | | 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>
* Grow: pass INVALID_SECTORS to reshape_array, not 0.NeilBrown2013-07-11
| | | | | | | '0' means 'make it 0', which isn't what we want here. We want 'leave it unchanged'. Signed-off-by: NeilBrown <neilb@suse.de>
* Grow: use mdstat_wait to wait for delayed reshape.NeilBrown2013-07-10
| | | | | | | | | | 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>
* Grow: notice when --stop is synchronising a reshape and don't mess it up.NeilBrown2013-07-04
| | | | | | | | | | | --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>
* Grow: fix small bug when reshape interrupted.NeilBrown2013-07-04
| | | | | | | | 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>
* Assemble: improve messages when restarting a reshape.NeilBrown2013-07-02
| | | | | | | | 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>
* Manage: check alignment when stopping an array undergoing reshape.NeilBrown2013-07-01
| | | | | | | | | | | | | 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>
* New function: sysfs_waitNeilBrown2013-07-01
| | | | | | | 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>
* Grow: fix crash when restarting an array.NeilBrown2013-06-27
| | | | | | | 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>
* Grow: lack of head/tail space not fatal for RAID5 etc.NeilBrown2013-06-27
| | | | | | | | | 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>
* Grow: report better message when --grow --chunk cannot work.NeilBrown2013-06-27
| | | | | | | | | | | 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>
* Grow: chose default layout when converting from RAID0.NeilBrown2013-06-24
| | | | | | | 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>
* Grow: centralise level-change code.NeilBrown2013-06-24
| | | | | | | | | | 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>
* Grow: remove excess drives when converting to RAID0.NeilBrown2013-06-24
| | | | | | | | | 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>
* Grow: clear new_layout when we change the level.NeilBrown2013-06-24
| | | | | | | 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>
* Grow: analyse_change needs to set new_size even if nothing much is happening.NeilBrown2013-06-24
| | | | | | | 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>
* Grow: fix two problems with new_data_offsetNeilBrown2013-06-24
| | | | | | | | | 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>
* Grow: Try hard to set new_offset.NeilBrown2013-06-24
| | | | | | | | | 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>
* Grow: Make sure new data-offset is well-alignedNeilBrown2013-06-24
| | | | | | | 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>
* Grow: a data_offset should not be tested against 0.NeilBrown2013-06-19
| | | | | | It should always be tested against INVALID_SECTORS!!! Signed-off-by: NeilBrown <neilb@suse.de>
* Remove lots of unnecessary white space.NeilBrown2013-06-19
| | | | | | | 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>
* Grow: fix up recent changes to set_new_data_offset.NeilBrown2013-06-19
| | | | | | | | The second 'info2' wasn't being initialised. So don't use it. Reported by -O3 Signed-off-by: NeilBrown <neilb@suse.de>
* Make sure NOFILE resource limit is big enough.NeilBrown2013-05-30
| | | | | | | | | | 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>
* Grow_continue: handle RESHAPE_NO_BACKUP correctly.NeilBrown2013-05-28
| | | | | | | If the reshape does not require a backup, Grow_continue can abort early. Signed-off-by: NeilBrown <neilb@suse.de>
* Grow: allow for different sized devices when updating data_offset.NeilBrown2013-05-28
| | | | | | | | | | | | | 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>
* Assemble: allow --update=revert-reshapeNeilBrown2013-05-28
| | | | This will cause a reshape to start going backwards.
* Grow: allow a reshape which only changes --data-offsetNeilBrown2013-05-22
| | | | | | Sometimes, that is all we want to do. Signed-off-by: NeilBrown <neilb@suse.de>
* Grow: E2BIG should be reporte differently if --data-offset was requested.NeilBrown2013-05-22
| | | | | | In that case the problem is almost certainly that --data-offset is too big. Signed-off-by: NeilBrown <neilb@suse.de>
* Grow: --backup-file and --data-offset are incompatible.NeilBrown2013-05-22
| | | | | | | 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>
* Grow: handle E2BIG from new_offset changes more gracefully.NeilBrown2013-05-22
| | | | | | If new_offset change is too big, just do the reshape the old way. Signed-off-by: NeilBrown <neilb@suse.de>