summaryrefslogtreecommitdiffstats
path: root/Grow.c (follow)
Commit message (Collapse)AuthorAgeFilesLines
* [PATCH] mdadm: Grow.c distinguish takeover vs reshape on grow operationNigel Croxon2024-10-281-1/+2
| | | | | | | | Correcting the terminology on the output when doing a takeover vs a reshape. Signed-off-by: Nigel Croxon <ncroxon@redhat.com> Signed-off-by: Heinz Mauelshagen <heinzm@redhat.com>
* mdadm/Grow: Check new_level interface rather than kernel versionXiao Ni2024-10-181-1/+1
| | | | | | | | Different os distributions have different kernel version themselves. Check new_level sysfs interface rather than kernel version. Signed-off-by: Xiao Ni <xni@redhat.com> Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>
* mdadm: add xmalloc.hMariusz Tkaczyk2024-09-271-0/+2
| | | | | | | | | | Move memory declaration helpers outside mdadm.h. They seems to be useful so keep them but include separatelly. Rework them to not reffer to Name[] declared internally in mdadm/mdmon. This is first step to start decomplexing mdadm.h. Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>
* mdadm/Grow: sleep a while after removing disk in impose_levelXiao Ni2024-09-231-0/+7
| | | | | | | | | | | It needs to remove disks when reshaping from raid456 to raid0. In kernel space it sets MD_RECOVERY_RUNNING. And it will fail to change level. So wait sometime to let md thread to clear this flag. This is found by test case 05r6tor0. Signed-off-by: Xiao Ni <xni@redhat.com> Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>
* mdadm/Grow: Can't open raid when running --grow --continueXiao Ni2024-09-231-3/+6
| | | | | | | | It passes 'array' as devname in Grow_continue. So it fails to open raid device. Use mdinfo to open raid device. Signed-off-by: Xiao Ni <xni@redhat.com> Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>
* mdadm/Grow: Update reshape_progress to need_back after reshape finishesXiao Ni2024-09-231-4/+10
| | | | | | | | | | | It tries to update data offset when kicking off reshape. If it can't change data offset, it needs to use child_monitor to monitor reshape progress and do back up job. And it needs to update reshape_progress to need_back when reshape finishes. If not, it will be in a infinite loop. Signed-off-by: Xiao Ni <xni@redhat.com> Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>
* mdadm/Grow: Update new level when starting reshapeXiao Ni2024-09-231-0/+9
| | | | | | | | | | | | | | | Reshape needs to specify a backup file when it can't update data offset of member disks. For this situation, first, it starts reshape and then it kicks off mdadm-grow-continue service which does backup job and monitors the reshape process. The service is a new process, so it needs to read superblock from member disks to get information. But in the first step, it doesn't update new level in superblock. So it can't change level after reshape finishes, because the new level is not right. So records the new level in the first step. Signed-off-by: Xiao Ni <xni@redhat.com> Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>
* Grow_reshape: set only component_size for size growKinga Stefaniuk2024-08-061-12/+7
| | | | | | | | | | | | Component_size couldn't be set using ioctl when new drive size is big (e.g. 5TB). Command value is bigger than 32 bits and error is reported - it is known ioctl limitation. Remove updating array properties using ioctl, use sysfs instead. Sysfs was introduced in 3.10, so now it is old enough to be safely used. Array_size in sysfs should be set for every size change for external metadata, when grow is performed without errors. Signed-off-by: Kinga Stefaniuk <kinga.stefaniuk@intel.com>
* mdadm/Grow: fix coverity issue STRING_OVERFLOWXiao Ni2024-08-051-1/+1
| | | | | | | Fix string overflow problems in Grow.c Signed-off-by: Xiao Ni <xni@redhat.com> Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>
* mdadm/Grow: fix coverity issue RESOURCE_LEAKXiao Ni2024-08-051-11/+31
| | | | | | | Fix some resource leak problems. Signed-off-by: Xiao Ni <xni@redhat.com> Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>
* mdadm/Grow: fix coverity issue CHECKED_RETURNXiao Ni2024-08-051-7/+36
| | | | | | | It needs to check return value when functions have return value. Signed-off-by: Xiao Ni <xni@redhat.com> Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>
* Don't control reshape speed in daemonXiao Ni2024-05-241-7/+0
| | | | | | | | It tries to set the max sync speed in reshape. This should be done by administrators by control interfaces /proc/sys/dev/raid/speed_limit_max/min. Signed-off-by: Xiao Ni <xni@redhat.com> Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>
* add checking of return status on fstat callsNigel Croxon2024-05-211-4/+8
| | | | | | | | There are a few places we don't check the return status when calling fstat for success. Clean up the calls by adding a check before continuing. Signed-off-by: Nigel Croxon <ncroxon@redhat.com>
* Wait for mdmon when it is stared via systemdKinga Stefaniuk2024-05-141-3/+4
| | | | | | | | | When mdmon is being started it may need few seconds to start. For now, we didn't wait for it. Introduce wait_for_mdmon() function, which waits up to 5 seconds for mdmon to start completely. Signed-off-by: Kinga Stefaniuk <kinga.stefaniuk@intel.com> Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>
* mdadm: use struct context in reshape_super()Mateusz Kusiak2024-05-071-25/+68
| | | | | | | | | | | | | | reshape_super() takes too many arguments. Change passing params in favor of single struct. Add devname pointer and change direction members to struct shape and use it for reshape_super(). Create reshape_array_size() and reshape_array_non_size() to handle reshape_super() calls. Signed-off-by: Mateusz Kusiak <mateusz.kusiak@intel.com> Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>
* mdadm: pass struct context for external reshapesMateusz Kusiak2024-05-071-40/+28
| | | | | | | | | | | | This patch alters mutiple functions calls so the context is passed to external reshape functions. There are two main reasons behind it: - reduces number of arguments passed and unifies them, - imsm code will make use of context in incoming patches. Signed-off-by: Mateusz Kusiak <mateusz.kusiak@intel.com> Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>
* Remove all "if zeros" pt.2Mateusz Kusiak2024-03-221-12/+1
| | | | | | | | | | Commit e15e8b00cbce ("Remove all "if zeros"") did not remove all "if 0" code blocks. This commit is cleanup for that commit. Signed-off-by: Mateusz Kusiak <mateusz.kusiak@intel.com> Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>
* Grow: remove dead condition in Grow_reshape()Mateusz Kusiak2024-02-231-5/+1
| | | | | | | | Remove dead "if" condition from Grow_reshape(). Sysfs read check is performed earlier in the code. Signed-off-by: Mateusz Kusiak <mateusz.kusiak@intel.com> Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>
* Grow: Move update_tail assign to Grow_reshape()Mateusz Kusiak2024-02-201-6/+7
| | | | | | | | | | | | | | Due to e919fb0af245 ("FIX: Enable metadata updates for raid0") code can't enter super-intel.c:3415, resulting in checkpoint not being saved to metadata for second volume in matrix raid array. This results in checkpoint being stuck at last value for the first volume. Move st->update_tail to Grow_reshape() so it is assigned for each volume. Signed-off-by: Mateusz Kusiak <mateusz.kusiak@intel.com> Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>
* Replace "none" with macroMateusz Kusiak2024-01-241-8/+7
| | | | | | | | | | | String "none" is used many times throughout the code. Replace "none" strings with predefined macro. Add str_is_none() for comparing strings with "none". Replace str(n)cmp calls with function. Signed-off-by: Mateusz Kusiak <mateusz.kusiak@intel.com> Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>
* Define sysfs max buffer sizeMateusz Kusiak2024-01-241-18/+18
| | | | | | | | | | | sysfs_get_str() usages have inconsistant buffer size. This results in wild buffer declarations and redundant memory usage. Define maximum buffer size for sysfs strings. Replace wild sysfs string buffer sizes for globaly defined value. Signed-off-by: Mateusz Kusiak <mateusz.kusiak@intel.com> Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>
* Bump minimum kernel version to 2.6.32Jes Sorensen2023-04-101-16/+0
| | | | | | | Summary: At this point it probably is reasonable to drop support for anything prior to 3.10. Signed-off-by: Jes Sorensen <jes@trained-monkey.org>
* mdmon: Improve switchroot interactions.NeilBrown2023-03-191-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We need a new mdmon@mdfoo instance to run in the root filesystem after switch root, as /sys and /dev are removed from the initrd. systemd will not start a new unit with the same name running while the old unit is still active, and we want the two mdmon processes to overlap in time to avoid any risk of deadlock, which can happen when a write is attempted with no mdmon running. So we need a different unit name in the initrd than in the root. Apart from the name, everything else should be the same. This is easily achieved using a different instance name as the mdmon@.service unit file already supports multiple instances (for different arrays). So start "mdmon@mdfoo.service" from root, but "mdmon@initrd-mdfoo.service" from the initrd. udev can tell which circumstance is the case by looking for /etc/initrd-release. continue_from_systemd() is enhanced so that the "initrd-" prefix can be requested. Teach mdmon that a container name like "initrd/foo" should be treated just like "foo". Note that systemd passes the instance name "initrd-foo" as "initrd/foo". We don't need a similar mechanism at shutdown because dracut runs "mdmon --takeover --all" when appropriate. Signed-off-by: NeilBrown <neilb@suse.de> Signed-off-by: Jes Sorensen <jes@trained-monkey.org>
* Grow: fix can't change bitmap type from none to clustered.Heming Zhao2023-02-231-1/+1
| | | | | | | | | | | | | | | | | | | | | | Commit a042210648ed ("disallow create or grow clustered bitmap with writemostly set") introduced this bug. We should use 'true' logic not '== 0' to deny setting up clustered array under WRITEMOSTLY condition. How to trigger ``` ~/mdadm # ./mdadm -Ss && ./mdadm --zero-superblock /dev/sd{a,b} ~/mdadm # ./mdadm -C /dev/md0 -l mirror -b clustered -e 1.2 -n 2 \ /dev/sda /dev/sdb --assume-clean mdadm: array /dev/md0 started. ~/mdadm # ./mdadm --grow /dev/md0 --bitmap=none ~/mdadm # ./mdadm --grow /dev/md0 --bitmap=clustered mdadm: /dev/md0 disks marked write-mostly are not supported with clustered bitmap ``` Signed-off-by: Heming Zhao <heming.zhao@suse.com> Acked-by: Coly Li <colyli@suse.de> Signed-off-by: Jes Sorensen <jes@trained-monkey.org>
* Manage&Incremental: code refactor, string to enumMateusz Kusiak2023-01-041-4/+4
| | | | | | | | | Prepare Manage and Incremental for later changing context->update to enum. Change update from string to enum in multiple functions and pass enum where already possible. Signed-off-by: Mateusz Kusiak <mateusz.kusiak@intel.com> Signed-off-by: Jes Sorensen <jes@trained-monkey.org>
* Change update to enum in update_super and update_subarrayMateusz Kusiak2023-01-041-4/+5
| | | | | | | | | | Use already existing enum, change update_super and update_subarray update to enum globally. Refactor function references also. Remove code specific options from update_options. Signed-off-by: Mateusz Kusiak <mateusz.kusiak@intel.com> Signed-off-by: Jes Sorensen <jes@trained-monkey.org>
* Grow: fix possible memory leak.Blazej Kucman2022-12-281-1/+4
| | | | | Signed-off-by: Blazej Kucman <blazej.kucman@intel.com> Signed-off-by: Jes Sorensen <jes@trained-monkey.org>
* mdadm: replace container level checking with inlineKinga Tanska2022-09-291-3/+3
| | | | | | | | | To unify all containers checks in code, is_container() function is added and propagated. Signed-off-by: Kinga Tanska <kinga.tanska@intel.com> Acked-by: Coly Li <colyli@suse.de> Signed-off-by: Jes Sorensen <jsorensen@fb.com>
* Grow: Split Grow_reshape into helper functionMateusz Kusiak2022-08-241-59/+66
| | | | | | | | | | Grow_reshape should be split into helper functions given its size. - Add helper function for preparing reshape on external metadata. - Close cfd file descriptor. Signed-off-by: Mateusz Kusiak <mateusz.kusiak@intel.com> Acked-by: Coly Li <colyli@suse.de> Signed-off-by: Jes Sorensen <jsorensen@fb.com>
* mdadm: move data_offset to struct shapeMariusz Tkaczyk2022-08-231-4/+3
| | | | | | | | Data offset is a shape property so move it there to remove additional parameter from some functions. Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com> Signed-off-by: Jes Sorensen <jsorensen@fb.com>
* mdadm: Replace obsolete usleep with nanosleepMateusz Grzonka2022-08-221-2/+2
| | | | | | | | | According to POSIX.1-2001, usleep is considered obsolete. Replace it with a wrapper that uses nanosleep, as recommended in man. Add handy macros for conversions between msec, usec and nsec. Signed-off-by: Mateusz Grzonka <mateusz.grzonka@intel.com> Signed-off-by: Jes Sorensen <jsorensen@fb.com>
* mdadm/Grow: Fix use after close bug by closing after forkLogan Gunthorpe2022-08-071-1/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The test 07reshape-grow fails most of the time. But it succeeds around 1 in 5 times. When it does succeed, it causes the tests to die because mdadm has segfaulted. The segfault was caused by mdadm attempting to repoen a file descriptor that was already closed. The backtrace of the segfault was: #0 __strncmp_avx2 () at ../sysdeps/x86_64/multiarch/strcmp-avx2.S:101 #1 0x000056146e31d44b in devnm2devid (devnm=0x0) at util.c:956 #2 0x000056146e31dab4 in open_dev_flags (devnm=0x0, flags=0) at util.c:1072 #3 0x000056146e31db22 in open_dev (devnm=0x0) at util.c:1079 #4 0x000056146e3202e8 in reopen_mddev (mdfd=4) at util.c:2244 #5 0x000056146e329f36 in start_array (mdfd=4, mddev=0x7ffc55342450 "/dev/md0", content=0x7ffc55342860, st=0x56146fc78660, ident=0x7ffc55342f70, best=0x56146fc6f5d0, bestcnt=10, chosen_drive=0, devices=0x56146fc706b0, okcnt=5, sparecnt=0, rebuilding_cnt=0, journalcnt=0, c=0x7ffc55342e90, clean=1, avail=0x56146fc78720 "\001\001\001\001\001", start_partial_ok=0, err_ok=0, was_forced=0) at Assemble.c:1206 #6 0x000056146e32c36e in Assemble (st=0x56146fc78660, mddev=0x7ffc55342450 "/dev/md0", ident=0x7ffc55342f70, devlist=0x56146fc6e2d0, c=0x7ffc55342e90) at Assemble.c:1914 #7 0x000056146e312ac9 in main (argc=11, argv=0x7ffc55343238) at mdadm.c:1510 The file descriptor was closed early in Grow_continue(). The noted commit moved the close() call to close the fd above the fork which caused the parent process to return with a closed fd. This meant reshape_array() and Grow_continue() would return in the parent with the fd forked. The fd would eventually be passed to reopen_mddev() which returned an unhandled NULL from fd2devnm() which would then be dereferenced in devnm2devid. Fix this by moving the close() call below the fork. This appears to fix the 07revert-grow test. While we're at it, switch to using close_fd() to invalidate the file descriptor. Fixes: 77b72fa82813 ("mdadm/Grow: prevent md's fd from being occupied during delayed time") Cc: Alex Wu <alexwu@synology.com> Cc: BingJing Chang <bingjingc@synology.com> Cc: Danny Shih <dannyshih@synology.com> Cc: ChangSyun Peng <allenpeng@synology.com> Signed-off-by: Logan Gunthorpe <logang@deltatee.com> Acked-by: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com> Signed-off-by: Jes Sorensen <jes@trained-monkey.org>
* mdadm: block update=ppl for non raid456 levelsLukasz Florczak2022-06-241-1/+1
| | | | | | | | | | | | Option ppl should be used only for raid levels 4, 5 and 6. Cancel update for other levels. Applied globally for imsm and ddf format. Additionally introduce is_level456() helper function. Signed-off-by: Lukasz Florczak <lukasz.florczak@linux.intel.com> Signed-off-by: Jes Sorensen <jsorensen@fb.com>
* Grow: block -n on external volumes.Mateusz Kusiak2022-06-101-0/+8
| | | | | | | | | | | | | Performing --raid-devices on external metadata volume should be blocked as it causes unwanted behaviour. Eg. Performing mdadm -G /dev/md/volume -l10 -n4 on r0_d2 inside 4 disk container, returns mdadm: Need 2 spares to avoid degraded array, only have 0. Signed-off-by: Mateusz Kusiak <mateusz.kusiak@intel.com> Signed-off-by: Jes Sorensen <jsorensen@fb.com>
* mdadm: add map_num_s()Mariusz Tkaczyk2022-04-051-8/+8
| | | | | | | | | | | | | | map_num() returns NULL if key is not defined. This patch adds alternative, non NULL version for cases where NULL is not expected. There are many printf() calls where map_num() is called on variable without NULL verification. It works, even if NULL is passed because gcc is able to ignore NULL argument quietly but the behavior is undefined. For safety reasons such usages will use map_num_s() now. It is a potential point of regression. Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com> Signed-off-by: Jes Sorensen <jsorensen@fb.com>
* Replace error prone signal() with sigaction()Lukasz Florczak2022-04-041-2/+2
| | | | | | | | | | | | Up to this date signal() was used which implementation could vary [1]. Sigaction() call is preferred. This commit introduces replacement from signal() to sigaction() by the use of signal_s() wrapper. Also remove redundant signal.h header includes. [1] https://man7.org/linux/man-pages/man2/signal.2.html Signed-off-by: Lukasz Florczak <lukasz.florczak@linux.intel.com> Signed-off-by: Jes Sorensen <jsorensen@fb.com>
* Grow_reshape: Add r0 grow size error message and update manMateusz Kusiak2022-03-311-0/+6
| | | | | | | | Grow size on r0 is not supported for imsm and native metadata. Add proper error message. Update man for proper use of --size. Signed-off-by: Mateusz Kusiak <mateusz.kusiak@intel.com> Signed-off-by: Jes Sorensen <jsorensen@fb.com>
* Unify error message.Lukasz Florczak2022-03-151-2/+2
| | | | | | | Provide the same error message for the same error that can occur in Grow.c and super-intel.c. Signed-off-by: Lukasz Florczak <lukasz.florczak@linux.intel.com> Signed-off-by: Jes Sorensen <jsorensen@fb.com>
* Correct checking if file descriptors are validMateusz Grzonka2021-11-241-4/+1
| | | | | | | | In some cases file descriptors equal to 0 are treated as invalid. Fix it. Signed-off-by: Mateusz Grzonka <mateusz.grzonka@intel.com> Signed-off-by: Jes Sorensen <jsorensen@fb.com>
* disallow create or grow clustered bitmap with writemostly setNigel Croxon2021-10-081-0/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | Do not support creating an MD array on a clustered system (--bitmap=clustered) and disks with the write mostly (--write-mostly) flag set. Or do not grow an MD array on a non-clustered bitmap to a clustered bitmap with disks having the write mostly flag set. The actual results is the MD array is created successfully. But the expected results should be a failure with an error message stating: Can not set --write-mostly with a clustered bitmap. and disks marked write-mostly are not supported with clustered bitmap. V2: Added the device name in the error message during creation: mdadm -CR /dev/md0 -l1 --raid-devices=2 /dev/sda --write-mostly /dev/sdb --bitmap=clustered mdadm: Can not set /dev/sdb --write-mostly with a clustered bitmap. Added the array name in the error message when growing: mdadm --grow /dev/md0 --bitmap=clustered mdadm: /dev/md0 disks marked write-mostly are not supported with clustered bitmap Signed-off-by: Nigel Croxon <ncroxon@redhat.com> Signed-off-by: Jes Sorensen <jsorensen@fb.com>
* mdadm: fix growing containersNigel Croxon2021-04-061-8/+11
| | | | | | | | | | | | | | This fixes growing containers which was broken with commit 4ae96c802203ec3c (mdadm: fix reshape from RAID5 to RAID6 with backup file) The issue being that containers use the function wait_for_reshape_isms and expect a number value and not a string value of "max". The change is to test for external before setting the correct value. Signed-off-by: Nigel Croxon <ncroxon@redhat.com> Signed-off-by: Jes Sorensen <jsorensen@fb.com>
* Grow: Block reshape when external metadata and write-intent bitmapJakub Radtke2021-03-091-9/+15
| | | | | | | | | Current kernel sysfs interface for the bitmap is limited. It allows the applying of the bitmap on non-active volumes only. The reshape operation for a volume with a bitmap should be blocked. Signed-off-by: Jakub Radtke <jakub.radtke@intel.com> Signed-off-by: Jes Sorensen <jsorensen@fb.com>
* Grow: be careful of corrupt dev_roles listNeilBrown2021-03-031-3/+12
| | | | | | | | | | | | | | | | | | I've seen a case where the dev_roles list of a linear array was corrupt. ->max_dev was > 128 and > raid_disks, and the extra slots were '0', not 0xFFFE or 0xFFFF. This caused problems when a 128th device was added. So: 1/ make Grow_Add_device more robust so that if numbers look wrong, it fails-safe. 2/ make examine_super1() report details if the dev_roles array is corrupt. Signed-off-by: NeilBrown <neilb@suse.de> Signed-off-by: Jes Sorensen <jsorensen@fb.com>
* mdadm: fix reshape from RAID5 to RAID6 with backup fileNigel Croxon2021-03-031-2/+5
| | | | | | | | | | | | | Reshaping a 3-disk RAID5 to 4-disk RAID6 will cause a hang of the resync after the grow. Adding a spare disk to avoid degrading the array when growing is successful, but not successful when supplying a backup file on the command line. If the reshape job is not already running, set the sync_max value to max. Signed-off-by: Nigel Croxon <ncroxon@redhat.com> Signed-off-by: Jes Sorensen <jsorensen@fb.com>
* mdadm: Unify forks behaviourMariusz Tkaczyk2020-11-261-45/+7
| | | | | | | | | | | | | | If mdadm is run by udev or systemd, it gets a pipe as each stream. Forks in the background may run after an event or service has been processed when udev is detached from pipe. As a result process fails quietly if any message is written. To prevent from it, each fork has to close all parent streams. Leave stderr and stdout opened only for debug purposes. Unify it across all forks. Introduce other descriptors detection by scanning /proc/self/fd directory. Add generic method for managing systemd services. Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@intel.com>
* mdadm/Grow: prevent md's fd from being occupied during delayed timeallenpeng2020-06-181-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | If we start reshaping on md which shares sub-devices with another resyncing md, it may be forced to wait for others to complete. mdadm occupies the md's fd during this time, which causes the md can not be stopped and the filesystem can not be mounted on the md. We can close md's fd earlier to solve this problem. Reproducible Steps: 1. create two partitions on sda, sdb, sdc, sdd 2. create raid1 with sda1, sdb1 mdadm -C /dev/md1 --assume-clean -l1 -n2 /dev/sda1 /dev/sdb1 3. create raid5 with sda2, sdb2, sdc2 mdadm -C /dev/md2 --assume-clean -l5 -n3 /dev/sda2 /dev/sdb2 /dev/sdc2 4. start resync at md1 echo repair > /sys/block/md1/md/sync_action 5. reshape raid5 to raid6 mdadm -a /dev/md2 /dev/sdd2 mdadm --grow /dev/md2 -n4 -l6 --backup-file=/root/md2-backup Now mdadm is occupying the fd of md2, causing md2 unable to be stopped 6.Try to stop md2, an error message shows mdadm -S /dev/md2 mdadm: Cannot get exclusive access to /dev/md3:Perhaps a running process, mounted filesystem or active volume group? Reviewed-by: Alex Wu <alexwu@synology.com> Reviewed-by: BingJing Chang <bingjingc@synology.com> Reviewed-by: Danny Shih <dannyshih@synology.com> Signed-off-by: ChangSyun Peng <allenpeng@synology.com> Signed-off-by: Jes Sorensen <jsorensen@fb.com>
* Fix reshape for decreasing data offsetCorey Hickey2019-02-131-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | ...when not changing the number of disks. This patch needs context to explain. These are the relevant parts of the original code (condensed and annotated): if (dir > 0) { /* Increase data offset (reshape backwards) */ if (data_offset < sd->data_offset + min) { pr_err("--data-offset too small on %s\n", dn); goto release; } } else { /* Decrease data offset (reshape forwards) */ if (data_offset < sd->data_offset - min) { pr_err("--data-offset too small on %s\n", dn); goto release; } } When this code is reached, mdadm has already decided on a reshape direction. When increasing the data offset, the reshape runs backwards (dir==1); when decreasing the data offset, the reshape runs forwards (dir==-1). The conditional within the backwards reshape is correct: the requested offset must be larger than the old offset plus a minimum delta; thus the reshape has room to work. For the forwards reshape, the requested offset needs to be smaller than the old offset minus a minimum delta; to do this correctly, the comparison must be reversed. Also update the error message. Note: I have tested this change on a RAID 5 on Linux 4.18.0 and verified that there were no errors from the kernel and that the device data remained intact. I do not know if there are considerations for different RAID levels. Signed-off-by: Corey Hickey <bugfood-c@fatooh.org> Signed-off-by: Jes Sorensen <jsorensen@fb.com>
* Fix spelling typos.Dimitri John Ledkov2019-02-111-3/+3
| | | | | Signed-off-by: Dimitri John Ledkov <xnox@ubuntu.com> Signed-off-by: Jes Sorensen <jsorensen@fb.com>
* Grow: report correct new chunk size.NeilBrown2018-12-061-1/+1
| | | | | | | | When using "--grow --chunk=" to change chunk size, the old chunksize is reported instead of the new. Signed-off-by: NeilBrown <neilb@suse.com> Signed-off-by: Jes Sorensen <jsorensen@fb.com>
* Grow: avoid overflow in compute_backup_blocks()NeilBrown2018-12-061-1/+2
| | | | | | | | | | | With a chunk size of 16Meg and data drive count of 8, this calculate can easily overflow the 'int' type that is used for the multiplications. So force it to use "long" instead. Reported-and-tested-by: Ed Spiridonov <edo.rus@gmail.com> Signed-off-by: NeilBrown <neilb@suse.com> Signed-off-by: Jes Sorensen <jsorensen@fb.com>