summaryrefslogtreecommitdiffstats
Commit message (Collapse)AuthorAgeFilesLines
...
* 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>
* mdadm/test: Convert code format to use TabZhilong Liu2017-06-091-324/+378
| | | | | | | | In case to make codes neat, this commit didn't change any codes, just tidy up and use Tab as code format. Signed-off-by: Zhilong Liu <zlliu@suse.com> Signed-off-by: Jes Sorensen <jsorensen@fb.com>
* Grow: don't allow to enable PPL when reshape is in progressTomasz Majchrzak2017-06-091-0/+12
| | | | | | | | Don't allow to enable PPL consistency policy when reshape is in progress. Current PPL implementation doesn't work when reshape is taking place. Signed-off-by: Tomasz Majchrzak <tomasz.majchrzak@intel.com> Signed-off-by: Jes Sorensen <jsorensen@fb.com>
* Grow: don't allow array geometry change with ppl enabledTomasz Majchrzak2017-06-091-0/+7
| | | | | | | | | Don't allow array geometry change (size expand, disk adding) when PPL consistency policy is enabled. Current PPL implementation doesn't work when reshape is taking place. Signed-off-by: Tomasz Majchrzak <tomasz.majchrzak@intel.com> Signed-off-by: Jes Sorensen <jsorensen@fb.com>
* Get failed disk count from array stateTomasz Majchrzak2017-06-056-26/+17
| | | | | | | | | | | | | | | | | | | | Recent commit has changed the way failed disks are counted. It breaks recovery for external metadata arrays as failed disks are not part of the array and have no corresponding entries is sysfs (they are only reported for containers) so degraded arrays show no failed disks. Recent commit overwrites GET_DEGRADED result prior to GET_STATE and it is not set again if GET_STATE has not been requested. As GET_STATE provides the same information as GET_DEGRADED, the latter is not needed anymore. Remove GET_DEGRADED option and replace it with GET_STATE option. Don't count number of failed disks looking at sysfs entries but calculate it at the end. Do it only for arrays as containers report no disks, just spares. Signed-off-by: Tomasz Majchrzak <tomasz.majchrzak@intel.com> Signed-off-by: Jes Sorensen <jsorensen@fb.com>
* Grow: set component size prior to array sizeTomasz Majchrzak2017-06-051-0/+2
| | | | | | | | | | | It is a partial revert of commit 758b327cf5a7 ("Grow: Remove unnecessary optimization"). For native metadata component size is set in kernel for entire disk space. As external metadata supports multiple arrays within one disk, the component size is set to array size. If component size is not updated prior to array size update, the grow operation fails. Signed-off-by: Tomasz Majchrzak <tomasz.majchrzak@intel.com> Signed-off-by: Jes Sorensen <jsorensen@fb.com>
* md_u: Remove unused ioctl declaration of START_ARRAYZhilong Liu2017-06-021-1/+0
| | | | | | | | | START_ARRAY is no longer used in the code, so get rid of it. MD commit: fbedac04fa11 ("[PATCH] md: the scheduled removal of the START_ARRAY ioctl for md") merged in the year 2006. Signed-off-by: Zhilong Liu <zlliu@suse.com> Signed-off-by: Jes Sorensen <jsorensen@fb.com>