summaryrefslogtreecommitdiffstats
Commit message (Collapse)AuthorAgeFilesLines
...
* mdmon: get safe mode delay file descriptor earlyTomasz Majchrzak2017-10-042-3/+14
| | | | | | | | | | | | | | | | | After switch root new mdmon is started. It sends initrd mdmon a signal to terminate. initrd mdmon receives it and switches the safe mode delay to 1 ms in order to get array to clean state and flush last version of metadata. The problem is sysfs filesystem is not available to initrd mdmon after switch root so the original safe mode delay is unchanged. The delay is set to few seconds - if there is a lot of traffic on the filesystem, initrd mdmon doesn't terminate for a long time (no clean state). There are 2 instances of mdmon. initrd mdmon flushes metadata when array goes to clean state but this metadata might be already outdated. Use file descriptor obtained on mdmon start to change safe mode delay. Signed-off-by: Tomasz Majchrzak <tomasz.majchrzak@intel.com> Signed-off-by: Jes Sorensen <jsorensen@fb.com>
* imsm: Set disk slot numberMariusz Tkaczyk2017-10-031-0/+3
| | | | | | | | | | | | | | If first disk of IMSM RAID1 is failed but still present in the system, the array is not auto-assembled. Auto-assemble uses raid disk slot from metadata to index disks. As it's not set, the valid disk is seen as a replacement disk and its metadata is ignored. The problem is not observed for other RAID levels as they have more than 2 disks - replacement disks are only stored under uneven indexes so third disk metadata is used in such scenario. Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@intel.com> Reviewed-by: Tomasz Majchrzak <tomasz.majchrzak@intel.com> Signed-off-by: Jes Sorensen <jsorensen@fb.com>
* Grow: Use all 80 charactersJes Sorensen2017-10-021-220/+197
| | | | | | | Try to use the full line length and avoid breaking up lines excessively. Equally break up lines that are too long for no reason. Signed-off-by: Jes Sorensen <jsorensen@fb.com>
* imsm: write initial ppl on a disk added for rebuildArtur Paszkiewicz2017-10-021-1/+4
| | | | | | | | | When rebuild is initiated by the UEFI driver it is possible that the new disk will not contain a valid ppl header. Just write the initial ppl and don't abort assembly. Signed-off-by: Artur Paszkiewicz <artur.paszkiewicz@intel.com> Signed-off-by: Jes Sorensen <jsorensen@fb.com>
* imsm: use correct map when validating pplArtur Paszkiewicz2017-10-021-3/+3
| | | | | | | | Use the first map to get the correct disk when rebuilding and not the failed disk from the second map. Signed-off-by: Artur Paszkiewicz <artur.paszkiewicz@intel.com> Signed-off-by: Jes Sorensen <jsorensen@fb.com>
* imsm: always do ppl recovery when starting a rebuilding arrayArtur Paszkiewicz2017-10-021-0/+3
| | | | | | | | Set resync_start to 0 when starting a rebuilding array to make the kernel perform ppl recovery before the rebuild. Signed-off-by: Artur Paszkiewicz <artur.paszkiewicz@intel.com> Signed-off-by: Jes Sorensen <jsorensen@fb.com>
* imsm: Write empty PPL header if assembling regular clean array.Pawel Baldysiak2017-10-021-1/+3
| | | | | | | | | | | | | If array was initially assembled with kernel without PPL support - initial header was never written to the drive. If initial resync was completed and system is rebooted to kernel with PPL support - mdadm prevents from assembling normal clean array due to lack of valid PPL. Write empty header when assemble normal clean array, so the its assamble is no longer blocked. Signed-off-by: Pawel Baldysiak <pawel.baldysiak@intel.com> Signed-off-by: Jes Sorensen <jsorensen@fb.com>
* imsm: don't skip resync when an invalid ppl header is foundArtur Paszkiewicz2017-10-021-2/+16
| | | | | | | | | | | | | | | If validate_ppl_imsm() detects an invalid ppl header it will be overwritten with a valid, empty ppl header. But if we are assembling an array after unclean shutdown this will cause the kernel to skip resync after ppl recovery. We don't want that because if there was an invalid ppl it's best to assume that the ppl recovery is not enough to make the array consistent and a full resync should be performed. So when overwriting the invalid ppl add one ppl_header_entry with a wrong checksum. This will prevent the kernel from skipping resync after ppl recovery. Signed-off-by: Artur Paszkiewicz <artur.paszkiewicz@intel.com> Signed-off-by: Jes Sorensen <jsorensen@fb.com>
* Grow: fix switching on PPL during recoveryPawel Baldysiak2017-10-021-3/+0
| | | | | | | | | | | If raid memeber is not in sync - it is skipped during enablement of PPL. This is not correct, since the drive that we are currently recovering to does not have ppl_size and ppl_sector properly set in sysfs. Remove this skipping, so all drives are updated during turning on the PPL. Signed-off-by: Pawel Baldysiak <pawel.baldysiak@intel.com> Signed-off-by: Jes Sorensen <jsorensen@fb.com>
* imsm: switch to multiple ppls automatically during assemblePawel Baldysiak2017-10-021-0/+30
| | | | | | | | | If user has array with single ppl - update the metadata to use multiple ppls. Signed-off-by: Pawel Baldysiak <pawel.baldysiak@intel.com> Signed-off-by: Artur Paszkiewicz <artur.paszkiewicz@intel.com> Signed-off-by: Jes Sorensen <jsorensen@fb.com>
* Zeroout whole ppl space during creation/force assemblePawel Baldysiak2017-10-024-1/+61
| | | | | | | | | | | PPL area should be cleared before creation/force assemble. If the drive was used in other RAID array, it might contains PPL from it. There is a risk that mdadm recognizes those PPLs and refuses to assemble the RAID due to PPL conflict with created array. Signed-off-by: Pawel Baldysiak <pawel.baldysiak@intel.com> Signed-off-by: Jes Sorensen <jsorensen@fb.com>
* imsm: validate multiple ppls during assemblePawel Baldysiak2017-10-021-24/+47
| | | | | | | | | | | | | | | | | Change validation algorithm to check validity of multiple ppls that are stored in PPL area. If read error occurs during - treat the all PPLs as invalid - there is no guarantee that this one was not latest. If the header CRC is incorrect - assume that there are no further PPLs in PPL area. If whole PPL area was written at least once - there is a possibility that old PPL (with lower generation number) will follow the recent one (with higest generation number). Compare those generation numbers to check which PPL is latest. Signed-off-by: Pawel Baldysiak <pawel.baldysiak@intel.com> Signed-off-by: Jes Sorensen <jsorensen@fb.com>
* imsm: Add support for multiple pplsPawel Baldysiak2017-10-021-10/+27
| | | | | | | | | | Add interpreting new rwh_policy bits. Set PPL size as 1MB. If new array with ppl is created - use new implementation of ppl by default. Signed-off-by: Pawel Baldysiak <pawel.baldysiak@intel.com> Signed-off-by: Artur Paszkiewicz <artur.paszkiewicz@intel.com> Signed-off-by: Jes Sorensen <jsorensen@fb.com>
* super1: Add support for multiple-pplsPawel Baldysiak2017-10-021-28/+37
| | | | | | | | | | | Add support for super1 with multiple ppls. Extend ppl area size to 1MB. Use 1MB as default during creation. Always start array as single ppl - if kernel is capable of multiple ppls and there is enough space reserved - it will switch the policy during first metadata update. Signed-off-by: Pawel Baldysiak <pawel.baldysiak@intel.com> Signed-off-by: Artur Paszkiewicz <artur.paszkiewicz@intel.com> Signed-off-by: Jes Sorensen <jsorensen@fb.com>
* Don't abort starting the array if kernel does not support pplArtur Paszkiewicz2017-10-023-9/+12
| | | | | | | | | | | | | | | | | | | Change the behavior of assemble and create for consistency-policy=ppl for external metadata arrays. If the kernel does not support ppl, don't abort but print a warning and start the array without ppl (consistency-policy=resync). No change for native md arrays because the kernel will not allow starting the array if it finds an unsupported feature bit in the superblock. In sysfs_add_disk() check consistency_policy in the mdinfo structure that represents the array, not the disk and read the current consistency policy from sysfs in mdmon's manage_member(). This is necessary to make sysfs_add_disk() honor the actual consistency policy and not what is in the metadata. Also remove all the places where consistency_policy is set for a disk's mdinfo - it is a property of the array, not the disk. Signed-off-by: Artur Paszkiewicz <artur.paszkiewicz@intel.com> Signed-off-by: Jes Sorensen <jsorensen@fb.com>
* mdadm: fixes some trivial typos in commentsZhilong Liu2017-10-022-5/+5
| | | | | | | fix some trivial typos in comments. Signed-off-by: Zhilong Liu <zlliu@suse.com> Signed-off-by: Jes Sorensen <jsorensen@fb.com>
* mdadm/manpage: disable bitmap_resize for external file bitmapZhilong Liu2017-10-021-0/+5
| | | | | | | | | Update the manpage in "SIZE CHANGES" against the md commit. Commit: e8a27f836f165c26f867ece7f31eb5c811692319 (md/bitmap: disable bitmap_resize for file-backed bitmaps.) Signed-off-by: Zhilong Liu <zlliu@suse.com> Signed-off-by: Jes Sorensen <jsorensen@fb.com>
* mdadm/grow: Component size must be larger than chunk sizeZhilong Liu2017-10-021-0/+6
| | | | | | | | | Grow: Changing component size must be larger than current chunk size against stripe raids, otherwise Grow_reshape() would set s->size to '0'. Signed-off-by: Zhilong Liu <zlliu@suse.com> Signed-off-by: Jes Sorensen <jsorensen@fb.com>
* Monitor: Check redundancy for arraysMariusz Tkaczyk2017-10-021-4/+4
| | | | | | | | | GET_MISMATCH option doesn't exist for RAID arrays without redundancy so sysfs_read fails if this information is requested. Set options according to the device using information from /proc/mdstat. Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@intel.com> Signed-off-by: Jes Sorensen <jsorensen@fb.com>
* imsm: New disk controller domainsMariusz Tkaczyk2017-10-021-0/+4
| | | | | | | | Add disk controller domain for nvme and vmd devices to prevent moving spares between different domains. Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@intel.com> Signed-off-by: Jes Sorensen <jsorensen@fb.com>
* Grow: stop previous reshape process firstTomasz Majchrzak2017-10-021-2/+2
| | | | | | | | | | | | | | | If array is stopped during reshape and assembled again straight away, reshape process in a background might still be running. systemd doesn't start a new service if one already exists. If there is a race, previous process might terminate and new one is not created. Reshape doesn't continue after assemble. Tell systemd to restart the service rather than just start it. It will assure previous service is stopped first. If it's not running, stopping has no effect and only new process is started. Signed-off-by: Tomasz Majchrzak <tomasz.majchrzak@intel.com> Signed-off-by: Jes Sorensen <jsorensen@fb.com>
* Close mdfd before returning main functionXiao Ni2017-10-021-0/+2
| | | | | Signed-off-by: Xiao Ni <xni@redhat.com> Signed-off-by: Jes Sorensen <jsorensen@fb.com>
* util: Code is 80 characters wideJes Sorensen2017-09-301-12/+21
| | | | | | Lets not make things uglier than they need to be. Signed-off-by: Jes Sorensen <jsorensen@fb.com>
* Manage_subdevs(): Use a dev_tJes Sorensen2017-09-301-1/+1
| | | | | | Use the correct type for rdev Signed-off-by: Jes Sorensen <jsorensen@fb.com>
* sysfs_init_dev - take a dev_t argumentJes Sorensen2017-09-302-2/+2
| | | | | | Be consistent and use the correct type. Signed-off-by: Jes Sorensen <jsorensen@fb.com>
* lib: devid2kname() should take a dev_tJes Sorensen2017-09-292-4/+3
| | | | | | Make devid2kname() and devid2devnm() consistent in their APIs Signed-off-by: Jes Sorensen <jsorensen@fb.com>
* mdopen: call "modprobe md_mod" if it might be needed.NeilBrown2017-09-271-0/+4
| | | | | | | | | | | | | | | | | | Creating an array by opening a block-device with major number of 9 will transparently load the md module if needed. Creating an array by opening /sys/module/md_mod/parameters/new_array and writing to it won't, it will just fail if md_mod isn't loaded. So when opening that file fails with ENOENT, run "modprobe md_mod" and try again. This fixes a bug whereby if you have "CREATE names=yes" in mdadm.conf, and the md modules isn't loaded, then creating or assembling an array will not honor the "names=yes" configuration. Signed-off-by: NeilBrown <neilb@suse.com> Signed-off-by: Jes Sorensen <jsorensen@fb.com>
* mdadm/test: add new testcase for testing readonly/readwriteZhilong Liu2017-09-011-0/+22
| | | | | | | | | This is a test case for testing --readonly and --readwrite feature, it covers common metadata versions and raid levels. Signed-off-by: Zhilong Liu <zlliu@suse.com> Signed-off-by: Jes Sorensen <jsorensen@fb.com>
* mdadm/test: get rid of tests/checkZhilong Liu2017-09-011-35/+0
| | | | | | | | The tests/check can be removed due to check() in new 'test' has covered various checking. Signed-off-by: Zhilong Liu <zlliu@suse.com> Signed-off-by: Jes Sorensen <jsorensen@fb.com>
* mdadm/test: get rid of the tests/testdevZhilong Liu2017-09-011-13/+0
| | | | | | | | It's time to get rid of the tests/testdev due to it has covered by testdev() in new 'test'. Signed-off-by: Zhilong Liu <zlliu@suse.com> Signed-off-by: Jes Sorensen <jsorensen@fb.com>
* mdadm/test: use the first element of array as parsing conditionZhilong Liu2017-09-011-1/+1
| | | | | | | | | | it would complain "too many arguments" when array[] has few members, it's proper to check whether or not array[0] is null. Reported-by: Xiao Ni <xni@redhat.com> Signed-off-by: Zhilong Liu <zlliu@suse.com> Signed-off-by: Jes Sorensen <jsorensen@fb.com>
* mdadm/bitmap: examine-bitmap failed when bitmap is external modeZhilong Liu2017-09-011-5/+7
| | | | | | | | | | | | --examine-bitmap: the bitmap_file_open() shouldn't omit the regular file descriptor when the bitmap is external mode. Such as: ./mdadm -X /mnt/3 This commit is partial revert of commit 0a6bff09d416 (mdadm/util: unify fstat checking blkdev into function) Signed-off-by: Zhilong Liu <zlliu@suse.com> Signed-off-by: Jes Sorensen <jsorensen@fb.com>
* mdadm: set journal_clean after scanning all disksSong Liu2017-09-011-2/+6
| | | | | | | | | | | | | | | | | Summary: In Incremental.c:count_active(), max_events is tracked to show to which devices are up to date. If a device has events==max_events+1, getinfo_super() is called to reload the superblock from this device. getinfo_super1() blindly set journal_clean to 0, which is wrong. This patch fixes this by tracking max_journal_events for all the disks. After scanning all disks, journal_clean is set if max_journal_events >= max_events-1. Signed-off-by: Song Liu <songliubraving@fb.com> Reviewed-by: NeilBrown <neilb@suse.com> Signed-off-by: Jes Sorensen <jsorensen@fb.com>
* mdadm: install two more udev rules in mdadm.specSong Liu2017-08-291-0/+2
| | | | | | | To avoid rpmbuild error. Signed-off-by: Song Liu <songliubraving@fb.com> Signed-off-by: Jes Sorensen <jsorensen@fb.com>
* Detail: differentiate between container and inactive arraysMariusz Tkaczyk2017-08-231-5/+11
| | | | | | | | | | | | Containers used to be handled as active arrays because GET_ARRAY_INFO ioctl returns valid structure for them. As containers appear as inactive in sysfs, the output for detail command has changed. Stop relying on inactive state for containers. Make the output look the same as in mdadm 4.0. Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@intel.com> Signed-off-by: Jes Sorensen <jsorensen@fb.com>
* Monitor: Include containers in spare migrationMariusz Tkaczyk2017-08-161-1/+1
| | | | | | | | | | | | | Spare migration doesn't work for external metadata. mdadm skips a container with spare device because it is inactive. It used to work because GET_ARRAY_INFO ioctl returned valid structure for a container and mdadm treated such response as active container. Current implementation checks it in sysfs where container is shown as inactive. Adapt sysfs implementation to work the same way as ioctl. Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@intel.com> Signed-off-by: Jes Sorensen <jsorensen@fb.com>
* Monitor: containers don't have the same sysfs properties as arraysMariusz Tkaczyk2017-08-161-18/+28
| | | | | | | | | GET_MISMATCH option doesn't exist for containers so sysfs_read fails if this information is requested. Set options according to the device using information from /proc/mdstat. Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@intel.com> Signed-off-by: Jes Sorensen <jsorensen@fb.com>
* Don't use exit(ERANGE)NeilBrown2017-08-161-1/+1
| | | | | | | | | mdadm uses smaller exit codes like 0,1,2,3,4. Using ERANGE is inconsistent and not helpful. So change it to a more consistent number. Signed-off-by: NeilBrown <neilb@suse.com> Signed-off-by: Jes Sorensen <jsorensen@fb.com>
* super1: only set clustered flag when bitmap is presentNeilBrown2017-08-161-2/+2
| | | | | | | | | | | | If no bitmap is present, then the test if (__le32_to_cpu(bsb->nodes) > 1) accesses uninitialised memory. So move that test inside a test for a bitmap being present. Signed-off-by: NeilBrown <neilb@suse.com> Signed-off-by: Jes Sorensen <jsorensen@fb.com>
* Use correct syntax for passing DEVLINKS to mdadm from udevNeilBrown2017-08-162-2/+2
| | | | | | | | | | | | ${DEVLINKS} is not valid udev syntax, and is passed through uninterpreted. $env{DEVLINKS} or %e{DEVLINKS} is correct. Signed-off-by: NeilBrown <neilb@suse.com> Signed-off-by: Jes Sorensen <jsorensen@fb.com>
* Error messages should end with a newline character.NeilBrown2017-08-164-6/+6
| | | | | | | | Add "\n" to the end of error messages which don't already have one. Also spell "opened" correctly. Signed-off-by: NeilBrown <neilb@suse.com> Signed-off-by: Jes Sorensen <jsorensen@fb.com>
* imsm: rebuild from 2-disk RAID10Tomasz Majchrzak2017-08-161-10/+67
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When RAID10 loses 2 disks and it is still operational, it cannot be rebuilt. The rebuild process starts for the first disk and completes, however completion is not recorded in metadata. There is an assumption that rebuild completion corresponds to transition from degraded to normal state. It's not the case for 2-disk RAID10 as it's still degraded after rebuild to first disk completes. Check if disk rebuild flag is set in the second map and clear it. So far it has been checked only in the first map (where it was not set). The flag in the second map has not been cleared but rebuild completion dropped second map so the problem was not visible. If rebuild completion is notified and array still has failed disks and is in degraded state, check first if rebuild position is really unset (the same check as for array in normal state). If so, mark migration as done but don't change array state (it should remain degraded). Update failed disk number. On rebuild start don't clear the rebuild flag in the destination map for all the drives because failed state is lost for one of them. Just do a copy of a map and clear the flag in the destination map for the disk that goes into rebuild. Similarily preserve the rebuild flag in the map during disk removal. If the disk is missing on array start and migration has been in progress, don't just cancel it. Check first if maybe one of the disks was not under rebuild (rebuild flag present both in source and destination map). If so, rebuild was running despite of failed disk so there is no need to cancel migration. Signed-off-by: Tomasz Majchrzak <tomasz.majchrzak@intel.com> Signed-off-by: Jes Sorensen <jsorensen@fb.com>
* Detail: correct output for active arraysMariusz Tkaczyk2017-08-163-14/+17
| | | | | | | | | | | | The check for inactive array is incorrect as it compares it against active array. Introduce a new function md_is_array_active so the check is consistent across the code. As the output contains list of disks in the array include this information in sysfs read. Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@intel.com> Signed-off-by: Jes Sorensen <jsorensen@fb.com>
* udev rules: introduce rules for cluster-md to confirm deviceGuoqing Jiang2017-08-022-2/+25
| | | | | | | | | | | For cluster scenario, add device is different with native raid. When a node issues adds a device, then the node will broadcast a message with UUID to other nodes in the cluster. If receiving node can find the device with the specific UUID, it must confirm the device, otherwise reports it is missing. Signed-off-by: Guoqing Jiang <gqjiang@suse.com> Signed-off-by: Jes Sorensen <jsorensen@fb.com>
* mdadm/r5cache: allow adding journal to array without journalSong Liu2017-08-022-9/+2
| | | | | | | | | | | | Currently, --add-journal can be only used to recreate broken journal for arrays with journal since creation. As the kernel code getting more mature, this constraint is no longer necessary. This patch allows --add-journal to add journal to array without journal. Signed-off-by: Song Liu <songliubraving@fb.com> Signed-off-by: Jes Sorensen <jsorensen@fb.com>
* super1: Always round data offset to 1MPawel Baldysiak2017-07-271-2/+1
| | | | | | | | | | Currently if metadata requires more then 1M, data offset will be rounded down to closest MB. This is not correct, since less then required space is reserved. Always round data offset up to multiple of 1M. Signed-off-by: Pawel Baldysiak <pawel.baldysiak@intel.com> Signed-off-by: Jes Sorensen <jsorensen@fb.com>
* Monitor: don't assume mdadm parameter is a block deviceTomasz Majchrzak2017-07-101-2/+11
| | | | | | | | | | | If symlink (e.g. /dev/md/raid) is passed as a parameter to mdadm --wait, it fails as it's not able to find a corresponding entry in /proc/mdstat output. Get parameter file major:minor and look for block device name in sysfs. This commit is partial revert of commit 9e04ac1c43e6 ("mdadm/util: unify stat checking blkdev into function"). Signed-off-by: Tomasz Majchrzak <tomasz.majchrzak@intel.com> Signed-off-by: Jes Sorensen <jsorensen@fb.com>
* mdadm/test: Add '--disks=' to support testing phsical devicesZhilong Liu2017-07-101-5/+32
| | | | | | | | | | | | | | If test mode has set as '--dev=disk', then users can specify the argument of "--disks" to test a bunch of physical devices. For example: ./test --dev=disk --disks=/dev/sda{2..15} could execute all test cases on physical devices. Currently, the --dev=disk mode would confilct with testdev() in current test cases, thus ignore testing testdev() if has set --dev=disk mode. Signed-off-by: Zhilong Liu <zlliu@suse.com> Signed-off-by: Jes Sorensen <jsorensen@fb.com>
* mdadm/test: Add '--raidtype=' to run different raidlevel casesZhilong Liu2017-07-101-0/+31
| | | | | | | | | | | It supports to specify the argument of "--raidtype" to run the different raid level cases. Details refer to the do_help() usage. For example: ./test --raidtype=raid1 could execute all the raid1 test cases under tests/. Signed-off-by: Zhilong Liu <zlliu@suse.com> Signed-off-by: Jes Sorensen <jsorensen@fb.com>
* mdadm/test: Refactor and revamp 'test' scriptZhilong Liu2017-07-101-180/+228
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Adding functions: die() uniform the abnormal situations that have to abort. check_env() do various basic checking before running test suite. save_log() collect array infos, include of dmesg, superblock, bitmap and /proc/mdstat. main() the core function of this script. Improve functions: cleanup() clear dmesg and remove the /var/tmp/mdtest* files. mdadm() clear superblock once creating or building arrays every time, because it's always creating arrays many times in a test case. check() just tidy up with die(), didn't change code meanings. testdev() add checking $1 must be a block device, add 'return 0' in final because this function exists in last line of test case, such as tests/05r6tor0. do_test() add checking abnormal dmesg and changing log management. do_help() just recommend a better way to print Usage. parse_args() revamp and improve. Delete function: fast_sync() It's no longer used, so get rid of it. Signed-off-by: Zhilong Liu <zlliu@suse.com> Signed-off-by: Jes Sorensen <jsorensen@fb.com>