summaryrefslogtreecommitdiffstats
path: root/mdadm.h (follow)
Commit message (Collapse)AuthorAgeFilesLines
...
* mdadm: define is_devname_ignore()Mariusz Tkaczyk2023-05-081-0/+1
| | | | | | | Use function instead of direct checks across code. Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com> Signed-off-by: Jes Sorensen <jes@trained-monkey.org>
* mdadm: define DEV_NUM_PREFMariusz Tkaczyk2023-05-081-0/+8
| | | | | | | Use define instead of inlines. Add _LEN define. Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com> Signed-off-by: Jes Sorensen <jes@trained-monkey.org>
* mdadm: define DEV_MD_DIRMariusz Tkaczyk2023-05-081-0/+8
| | | | | | | | It is used many times. Additionally define _LEN to avoid repeated strlen() calls when length is needed. Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com> Signed-off-by: Jes Sorensen <jes@trained-monkey.org>
* Improvements for IMSM_NO_PLATFORM testing.NeilBrown2023-03-201-0/+2
| | | | | | | | | | | | | | | Factor out IMSM_NO_PLATFORM testing into a single function that caches the result. Allow mdmon to explicitly set the result to "1" so that we don't need the ENV var in the unit file Check if the kernel command line contains "mdadm.imsm.test=1" and in that case assert NO_PLATFORM. This simplifies testing in a virtual machine. Signed-off-by: NeilBrown <neilb@suse.de> Signed-off-by: Jes Sorensen <jes@trained-monkey.org>
* mdmon: Improve switchroot interactions.NeilBrown2023-03-191-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* mdadm: Add --write-zeros option for CreateLogan Gunthorpe2023-03-131-0/+5
| | | | | | | | | | | | | | | | | | | | | Add the --write-zeros option for Create which will send a write zeros request to all the disks before assembling the array. After zeroing the array, the disks will be in a known clean state and the initial sync may be skipped. Writing zeroes is best used when there is a hardware offload method to zero the data. But even still, zeroing can take several minutes on a large device. Because of this, all disks are zeroed in parallel using their own forked process and a message is printed to the user. The main process will proceed only after all the zeroing processes have completed successfully. Signed-off-by: Logan Gunthorpe <logang@deltatee.com> Acked-by: Kinga Tanska <kinga.tanska@linux.intel.com> Reviewed-by: Xiao Ni <xni@redhat.com> Reviewed-by: Chaitanya Kulkarni <kch@nvidia.com> Acked-by: Coly Li <colyli@suse.de> Signed-off-by: Jes Sorensen <jes@trained-monkey.org>
* mdadm: Introduce pr_info()Logan Gunthorpe2023-03-131-0/+2
| | | | | | | | | | | | | | | | | | | | | Feedback was given to avoid informational pr_err() calls that print to stderr, even though that's done all through out the code. Using printf() directly doesn't maintain the same format (an "mdadm" prefix on every line. So introduce pr_info() which prints to stdout with the same format and use it for a couple informational pr_err() calls in Create(). Future work can make this call used in more cases. Signed-off-by: Logan Gunthorpe <logang@deltatee.com> Acked-by: Kinga Tanska <kinga.tanska@linux.intel.com> Reviewed-by: Xiao Ni <xni@redhat.com> Reviewed-by: Chaitanya Kulkarni <kch@nvidia.com> Acked-by: Coly Li <colyli@suse.de> Acked-by: Paul Menzel <pmenzel@molgen.mpg.de> Signed-off-by: Jes Sorensen <jes@trained-monkey.org>
* Add helpers to determine whether directories or files are soft linksMateusz Grzonka2023-03-021-0/+2
| | | | | | Signed-off-by: Mateusz Grzonka <mateusz.grzonka@intel.com> Acked-by: Coly Li <colyli@suse.de> Signed-off-by: Jes Sorensen <jes@trained-monkey.org>
* Change char* to enum in context->update & refactor codeMateusz Kusiak2023-01-041-1/+1
| | | | | | | | | | | Storing update option in string is bad for frequent comparisons and error prone. Replace char array with enum so already existing enum is passed around instead of string. Adapt code to changes. Signed-off-by: Mateusz Kusiak <mateusz.kusiak@intel.com> Signed-off-by: Jes Sorensen <jes@trained-monkey.org>
* Manage&Incremental: code refactor, string to enumMateusz Kusiak2023-01-041-2/+2
| | | | | | | | | 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-3/+9
| | | | | | | | | | 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>
* Add code specific update options to enum.Mateusz Kusiak2023-01-041-0/+15
| | | | | | | | | Some of update options aren't taken from user input, but are hard-coded as strings. Include those options in enum. Signed-off-by: Mateusz Kusiak <mateusz.kusiak@intel.com> Signed-off-by: Jes Sorensen <jes@trained-monkey.org>
* mdadm: Add option validation for --update-subarrayMateusz Kusiak2023-01-041-1/+31
| | | | | | | | | Subset of options available for "--update" is not same as for "--update-subarray". Define maps and enum for update options and use them instead of direct comparisons. Add proper error message. Signed-off-by: Mateusz Kusiak <mateusz.kusiak@intel.com> Signed-off-by: Jes Sorensen <jes@trained-monkey.org>
* mdadm: create ident_init()Mariusz Tkaczyk2022-12-281-2/+5
| | | | | | | | Add a wrapper for repeated initializations in mdadm.c and config.c. Move includes up. Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com> Signed-off-by: Jes Sorensen <jes@trained-monkey.org>
* mdadm: replace container level checking with inlineKinga Tanska2022-09-291-0/+14
| | | | | | | | | 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-0/+1
| | | | | | | | | | 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: Don't open md device for CREATE and ASSEMBLELogan Gunthorpe2022-08-231-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The mdadm command tries to open the md device for most modes, first thing, no matter what. When running to create or assemble an array, in most cases, the md device will not exist, the open call will fail and everything will proceed correctly. However, when running tests, a create or assembly command may be run shortly after stopping an array and the old md device file may still be around. Then, if create_on_open is set in the kernel, a new md device will be created when mdadm does its initial open. When mdadm gets around to creating the new device with the new_array parameter it issues this error: mdadm: Fail to create md0 when using /sys/module/md_mod/parameters/new_array, fallback to creation via node This is because an mddev was already created by the kernel with the earlier open() call and thus the new one being created will fail with EEXIST. The mdadm command will still successfully be created due to falling back to the node creation method. However, the error message itself will fail any test that's running it. This issue is a race condition that is very rare, but a recent change in the kernel caused this to happen more frequently: about 1 in 50 times. To fix this, don't bother trying to open the md device for CREATE, ASSEMBLE and BUILD commands, as the file descriptor will never be used anyway even if it is successfully openned. The mdfd has not been used for these commands since: 7f91af49ad09 ("Delay creation of array devices for assemble/build/create") The checks that were done on the open device can be changed to being done with stat. Side note: it would be nice to disable create_on_open as well to help solve this, but it seems the work for this was never finished. By default, mdadm will create using the old node interface when a name is specified unless the user specifically puts names=yes in a config file, which doesn't seem to be common or desirable to require this.. Signed-off-by: Logan Gunthorpe <logang@deltatee.com> Signed-off-by: Jes Sorensen <jsorensen@fb.com>
* mdadm: move data_offset to struct shapeMariusz Tkaczyk2022-08-231-3/+2
| | | | | | | | 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: remove symlink optionMariusz Tkaczyk2022-08-231-2/+0
| | | | | | | The option is not used. Remove it from code. 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-0/+4
| | | | | | | | | 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: Fix mdadm -r remove option regressionLogan Gunthorpe2022-08-071-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The commit noted below globally adds a parameter to the -r option but missed the fact that -r is used for another purpose: --remove. After that commit, a command such as: mdadm /dev/md0 -r /dev/loop0 will do nothing seeing the device parameter will be consumed as a argument to the -r option; thus, there will only be one device seen one the command line, devs_found will only be 1 and nothing will happen. This caused the 01r5integ and 01raid6integ tests to hang indefinitely as mdadm did not remove the failed device. With the device not removed, it would not be readded. Then the loop waiting for the array status to change would loop forever. This commit was recently reverted, but the legitimate fix for the monitor operations was still not fixed. So add specific monitor short ops to re-fix the --monitor -r option. Fixes: 546047688e1c ("mdadm: fix coredump of mdadm --monitor -r") Fixes: 190dc029b141 ("Revert "mdadm: fix coredump of mdadm --monitor -r"") Cc: Wu Guanghao <wuguanghao3@huawei.com> Cc: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.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-0/+11
| | | | | | | | | | | | 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>
* Mdmonitor: Fix segfaultKinga Tanska2022-06-141-0/+1
| | | | | | | | | | | | Mdadm with "--monitor" parameter requires md device as an argument to be monitored. If given argument is not a md device, error shall be returned. Previously it was not checked and invalid argument caused segmentation fault. This commit adds checking that devices passed to mdmonitor are md devices. Signed-off-by: Kinga Tanska <kinga.tanska@intel.com> Signed-off-by: Jes Sorensen <jsorensen@fb.com>
* mdadm: add map_num_s()Mariusz Tkaczyk2022-04-051-1/+1
| | | | | | | | | | | | | | 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>
* Create, Build: use default_layout()Mariusz Tkaczyk2022-04-051-0/+1
| | | | | | | | | | | This code is duplicated for Build mode so make default_layout() extern and use it. Simplify the function structure. It introduced change for Build mode, now for raid0 RAID0_ORIG_LAYOUT will be returned same as for Create. 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-0/+22
| | | | | | | | | | | | 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>
* mdadm: block creation with long namesBlazej Kucman2021-12-081-0/+5
| | | | | | | | | | This fixes buffer overflows in create_mddev(). It prohibits creation with not supported names for DDF and native. For IMSM, mdadm will do silent cut to 16 later. Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com> Signed-off-by: Blazej Kucman <blazej.kucman@intel.com> Signed-off-by: Jes Sorensen <jsorensen@fb.com>
* imsm: introduce helpers to manage file descriptorsMariusz Tkaczyk2021-11-021-0/+25
| | | | | | | | | | | | | | To avoid direct comparisions define dedicated inlines. This patch propagates them in super-intel.c. They are declared globally for future usage outside IMSM. Additionally, it adds fd check in save_backup_imsm() to remove code vulnerability and simplifies targets array implementation. It also propagates pr_vrb() macro instead if (verbose) condidtion. Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com> Signed-off-by: Jes Sorensen <jsorensen@fb.com>
* mdadm/lib: Define a new helper function is_dev_alivedXiao Ni2021-11-021-0/+2
| | | | | | | | The function is used to check if one member disk is alive. Signed-off-by: Xiao Ni <xni@redhat.com> Acked-by: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com> Signed-off-by: Jes Sorensen <jsorensen@fb.com>
* Refactor parse_num and use it to parse optarg.Mateusz Grzonka2021-10-081-2/+2
| | | | | | | | Use parse_num instead of atoi to parse optarg. Replace atoi by strtol. Move inst to int conversion into manage_new. Add better error handling. Signed-off-by: Mateusz Grzonka <mateusz.grzonka@intel.com> Signed-off-by: Jes Sorensen <jsorensen@fb.com>
* Add monitor delay parameter to mdadm.confoshchirs2021-08-021-0/+1
| | | | | | | | | | Add possibility to configure delay for mdadm in monitoring mode using mdadm.conf. --delay command line argument takes precedence over config file. Signed-off-by: Oleksandr Shchirskyi <oleksandr.shchirskyi@intel.com> Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com> Signed-off-by: Jes Sorensen <jsorensen@fb.com>
* Enable bitmap support for external metadataJakub Radtke2021-03-091-0/+3
| | | | | | | | | | | The patch enables the implementation of a write-intent bitmap for external metadata. Configuration of the internal bitmaps for non-native metadata requires the extension in superswitch to perform an additional sysfs setup before the array is activated. Signed-off-by: Jakub Radtke <jakub.radtke@intel.com> Signed-off-by: Jes Sorensen <jsorensen@fb.com>
* imsm: add verbose flag to compare_superMariusz Tkaczyk2021-03-081-1/+2
| | | | | | | | | | | IMSM does more than comparing metadata and errors reported directly from compare_super_imsm can be useful. Add verbose flag to compare_super method and make all not critical error printing configurable. Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com> Signed-off-by: Jes Sorensen <jsorensen@fb.com>
* mdadm/Detail: show correct state for clustered arrayZhao Heming2020-11-261-0/+1
| | | | | | | | | | | | After kernel md module commit 480523feae581, in clustered env, mddev->in_sync always zero, it will make array.state never set up MD_SB_CLEAN. it causes "mdadm -D /dev/mdX" show state 'active' all the time. bitmap.c: add a new API IsBitmapDirty() to support inquiry bitmap dirty or clean. Signed-off-by: Zhao Heming <heming.zhao@suse.com>
* mdadm: Unify forks behaviourMariusz Tkaczyk2020-11-261-0/+10
| | | | | | | | | | | | | | 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>
* mdmonitor: set small delay onceBlazej Kucman2020-10-141-1/+1
| | | | | | | | | If mdmonitor is awakened by event, set small delay once to deal with udev and mdadm. Signed-off-by: Blazej Kucman <blazej.kucman@intel.com> Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@intel.com> Signed-off-by: Jes Sorensen <jsorensen@fb.com>
* Detail: adding sync status for cluster deviceLidong Zhong2020-04-271-1/+2
| | | | | | | | | | | | | | | | | | | On the node with /proc/mdstat is Personalities : [raid1] md0 : active raid1 sdb[4] sdc[3] sdd[2] 1046528 blocks super 1.2 [3/2] [UU_] recover=REMOTE bitmap: 1/1 pages [4KB], 65536KB chunk Let's change the 'State' of 'mdadm -Q -D' accordingly State : clean, degraded With this patch, it will be State : clean, degraded, recovering (REMOTE) Signed-off-by: Lidong Zhong <lidong.zhong@suse.com> Acked-by: Guoqing Jiang <guoqing.jiang@cloud.ionos.com> Signed-off-by: Jes Sorensen <jsorensen@fb.com>
* imsm: pass subarray id to kill_subarray functionBlazej Kucman2020-02-241-1/+2
| | | | | | | | | | | After patch b6180160f ("imsm: save current_vol number") current_vol for imsm is not set and kill_subarray() cannot determine which volume has to be deleted. Volume has to be passed as "subarray_id". The parameter affects only IMSM metadata. Signed-off-by: Blazej Kucman <blazej.kucman@intel.com> Signed-off-by: Jes Sorensen <jsorensen@fb.com>
* Create: add support for RAID0 layouts.NeilBrown2019-12-021-1/+7
| | | | | | | | | | | | | | Since Linux 5.4 a layout is needed for RAID0 arrays with varying device sizes. This patch makes the layout of an array visible (via --examine) and sets the layout on newly created arrays. --layout=dangerous can be used to avoid setting a layout so that they array can be used on older kernels. Tested-by: dann frazier <dann.frazier@canonical.com> Signed-off-by: NeilBrown <neilb@suse.de> Signed-off-by: Jes Sorensen <jsorensen@fb.com>
* imsm: return correct uuid for volume in detailBlazej Kucman2019-12-021-2/+3
| | | | | | | | | | | Fixes the side effect of the patch b6180160f ("imsm: save current_vol number") - wrong UUID is printed in detail for each volume. New parameter "subarray" is added to determine what info should be extracted from metadata (subarray or container). The parameter affects only IMSM metadata. Signed-off-by: Blazej Kucman <blazej.kucman@intel.com> Signed-off-by: Jes Sorensen <jsorensen@fb.com>
* mdadm: Introduce new array state 'broken' for raid0/linearGuilherme G. Piccoli2019-09-301-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Currently if a md raid0/linear array gets one or more members removed while being mounted, kernel keeps showing state 'clean' in the 'array_state' sysfs attribute. Despite udev signaling the member device is gone, 'mdadm' cannot issue the STOP_ARRAY ioctl successfully, given the array is mounted. Nothing else hints that something is wrong (except that the removed devices don't show properly in the output of mdadm 'detail' command). There is no other property to be checked, and if user is not performing reads/writes to the array, even kernel log is quiet and doesn't give a clue about the missing member. This patch is the mdadm counterpart of kernel new array state 'broken'. The 'broken' state mimics the state 'clean' in every aspect, being useful only to distinguish if an array has some member missing. All necessary paths in mdadm were changed to deal with 'broken' state, and in case the tool runs in a kernel that is not updated, it'll work normally, i.e., it doesn't require the 'broken' state in order to work. Also, this patch changes the way the array state is showed in the 'detail' command (for raid0/linear only) - now it takes the 'array_state' sysfs attribute into account instead of only rely in the MD_SB_CLEAN flag. Cc: Jes Sorensen <jes.sorensen@gmail.com> Cc: NeilBrown <neilb@suse.de> Cc: Song Liu <songliubraving@fb.com> Signed-off-by: Guilherme G. Piccoli <gpiccoli@canonical.com> Signed-off-by: Jes Sorensen <jsorensen@fb.com>
* mdadm: add --no-devices to avoid component devices detail informationColy Li2019-08-121-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When people assemble a md raid device with a large number of component deivces (e.g. 1500 DASD disks), the raid device detail information generated by 'mdadm --detail --export $devnode' is very large. It is because the detail information contains information of all the component disks (even the missing/failed ones). In such condition, when udev-md-raid-arrays.rules is triggered and internally calls "mdadm --detail --no-devices --export $devnode", user may observe systemd error message ""invalid message length". It is because the following on-stack raw message buffer in systemd code is not big enough, systemd/src/libudev/libudev-monitor.c _public_ struct udev_device *udev_monito ... struct ucred *cred; union { struct udev_monitor_netlink_header nlh; char raw[8192]; } buf; Even change size of raw[] from 8KB to larger size, it may still be not enough for detail message of a md raid device with much larger number of component devices. To fix this problem, an extra option '--no-devices' is added (the original idea is proposed by Neil Brown). When printing detailed information of a md raid device, if '--no-devices' is specified, then all component devices information will not be printed, then the output message size can be restricted to a small number, even with the systemd only has 8KB on-disk raw buffer, the md raid array udev rules can work correctly without failure message. Signed-off-by: Coly Li <colyli@suse.de> Reviewed-by: NeilBrown <neilb@suse.com> Signed-off-by: Jes Sorensen <jsorensen@fb.com>
* mdadm.h: include sysmacros.h unconditionallyBaruch Siach2019-08-121-2/+0
| | | | | | | | | | musl libc now also requires sys/sysmacros.h for the major/minor macros. All supported libc implementations carry sys/sysmacros.h, including diet-libc, klibc, and uclibc-ng. Cc: Hauke Mehrtens <hauke@hauke-m.de> Signed-off-by: Baruch Siach <baruch@tkos.co.il> Signed-off-by: Jes Sorensen <jsorensen@fb.com>
* mdadm: load default sysfs attributes after assemblationMariusz Dabrowski2019-07-101-0/+3
| | | | | | | | | | | | Added new type of line to mdadm.conf which allows to specify values of sysfs attributes for MD devices that should be loaded after the array is assembled. Each line is interpreted as list of structures containing sysname of MD device (md126 etc.) and list of sysfs attributes and their values. Signed-off-by: Mariusz Dabrowski <mariusz.dabrowski@intel.com> Signed-off-by: Krzysztof Smolinski <krzysztof.smolinski@intel.com> Signed-off-by: Jes Sorensen <jsorensen@fb.com>
* mdadm.h: Introduced unaligned {get,put}_unaligned{16,32}()Jes Sorensen2019-07-091-0/+30
| | | | | | We need these to avoid gcc9 going all crazy on us. Signed-off-by: Jes Sorensen <jsorensen@fb.com>
* mdmon: fix wrong array state when disk fails during mdmon startupArtur Paszkiewicz2019-05-201-0/+1
| | | | | | | | | | | | | | | | | | | | | | If a member drive disappears and is set faulty by the kernel during mdmon startup, after ss->load_container() but before manage_new(), mdmon will try to readd the faulty drive to the array and start rebuilding. Metadata on the active drive is updated, but the faulty drive is not removed from the array and is left in a "blocked" state and any write request to the array will block. If the faulty drive reappears in the system e.g. after a reboot, the array will not assemble because metadata on the drives will be incompatible (at least on imsm). Fix this by adding a new option for sysfs_read(): "GET_DEVS_ALL". This is an extension for the "GET_DEVS" option and causes all member devices to be returned, even if the associated block device has been removed. Use this option in manage_new() to include the faulty device on the active_array's devices list. Mdmon will then properly remove the faulty device from the array and update the metadata to reflect the degraded state. Signed-off-by: Artur Paszkiewicz <artur.paszkiewicz@intel.com> Signed-off-by: Jes Sorensen <jsorensen@fb.com>
* policy: support devices with multiple paths.NeilBrown2018-12-061-1/+1
| | | | | | | | | | | | | | | As new releases of Linux some time change the name of a path, some distros keep "legacy" names as well. This is useful, but confuses mdadm which assumes each device has precisely one path. So change this assumption: allow a disk to have several paths, and allow any to match when looking for a policy which matches a disk. Reported-and-tested-by: Mariusz Tkaczyk <mariusz.tkaczyk@intel.com> Signed-off-by: NeilBrown <neilb@suse.com> Signed-off-by: Jes Sorensen <jsorensen@fb.com>
* imsm: Do not require MDADM_EXPERIMENTAL flag anymoreMichal Zylowski2018-05-311-1/+0
| | | | | | | | | | | | | | Grow feature for IMSM metadata is currently fully supported and tested. Reshape operation is not in experimental state anymore, so usage of this flag is unnecessary. Do not require MDADM_EXPERIMENTAL flag and remove obsolete information from manual. Signed-off-by: Michal Zylowski <michal.zylowski@intel.com> Acked-by: Mariusz Dabrowski <mariusz.dabrowski@intel.com> Acked-by: Roman Sobanski <roman.sobanski@intel.com> Signed-off-by: Jes Sorensen <jsorensen@fb.com>
* mdadm: improve the dlm locking mechanism for clustered raidGuoqing Jiang2018-03-081-5/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Previously, the dlm locking only protects several functions which writes to superblock (update_super, add_to_super and store_super), and we missed other funcs such as add_internal_bitmap. We also need to call the funcs which read superblock under the locking protection to avoid consistent issue. So let's remove the dlm stuffs from super1.c, and provide the locking mechanism to the main() except assemble mode which will be handled in next commit. And since we can identify it is a clustered raid or not based on check the different conditions of each mode, so the change should not have effect on native array. And we improve the existed locking stuffs as follows: 1. replace ls_unlock with ls_unlock_wait since we should return when unlock operation is complete. 2. inspired by lvm, let's also try to use the existed lockspace first before creat a lockspace blindly if the lockspace not released for some reason. 3. try more times before quit if EAGAIN happened for locking. Note: for MANAGE mode, we do not need to get lock if node just want to confirm device change, otherwise we can't add a disk to cluster since all nodes are compete for the lock. Reviewed-by: NeilBrown <neilb@suse.com> Signed-off-by: Guoqing Jiang <gqjiang@suse.com> Signed-off-by: Jes Sorensen <jsorensen@fb.com>
* Monitor/msg: Don't print error message if mdmon doesn't runMariusz Tkaczyk2017-11-211-1/+1
| | | | | | | | | | | | | | | | Commit 4515fb28a53a ("Add detail information when can not connect monitor") was added to warn about failed connection to monitor in WaitClean function (see link below). Mdmon runs for IMSM containers when they have array with redundancy so if mdmon doesn't run, mdadm prints this error. This is misleading and unnecessary. Just print it in WaitClean function. The sock in WaitClean is deprecated so it is removed. Link: https://bugzilla.redhat.com/show_bug.cgi?id=1375002 Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@intel.com> Signed-off-by: Jes Sorensen <jsorensen@fb.com>