summaryrefslogtreecommitdiffstats
path: root/super1.c (follow)
Commit message (Collapse)AuthorAgeFilesLines
* 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/super1: fix coverity issue RESOURCE_LEAKXiao Ni2024-08-051-0/+3
| | | | | | | Fix resource leak problems in super1.c Signed-off-by: Xiao Ni <xni@redhat.com> Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>
* mdadm/super1: fix coverity issue EVALUATION_ORDERXiao Ni2024-08-051-2/+5
| | | | | | | Fix evaluation order problems in super1.c Signed-off-by: Xiao Ni <xni@redhat.com> Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>
* mdadm/super1: fix coverity issue DEADCODEXiao Ni2024-08-051-2/+0
| | | | | | | optimal_space is at most 2046. So space can't be larger than UINT16_MAX. Signed-off-by: Xiao Ni <xni@redhat.com> Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>
* mdadm/super1: fix coverity issue CHECKED_RETURNXiao Ni2024-08-051-4/+16
| | | | | | | It needs to check return value when functions return value. Signed-off-by: Xiao Ni <xni@redhat.com> Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>
* Remove all "if zeros" pt.2Mateusz Kusiak2024-03-221-11/+0
| | | | | | | | | | 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>
* super1: check fd before passing to get_dev_size() in add_to_super1()Mateusz Kusiak2024-02-231-1/+4
| | | | | | | | Check if file descriptor is valid before passing it to get_dev_size() in add_to_super(). Signed-off-by: Mateusz Kusiak <mateusz.kusiak@intel.com> Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>
* mdadm: fix update=resync regressionMariusz Tkaczyk2024-02-131-0/+4
| | | | | | | | | | | | | mdadm --assemble --update=resync started failing with the error "mdadm: --update=resync not understood for 1.x metadata". It is a regression. Add omitted branch to fix error. Resubmitted, original author is not responding. https://lore.kernel.org/linux-raid/ZZqJlCToUS3Qrl4J@bianca.dpss.psy.unipd.it/ Fixes: 7e8daba8b793 ("super1: refactor the code for enum") Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>
* super1: remove support for name= in configMariusz Tkaczyk2024-02-091-8/+0
| | | | | | | | | | | | | | | | | | | | | | | Only super1 provides "name=" to config. It is recoreded in metadata so there is no need to duplicate same information. UUID is our main key. It is not used by Incremental and Assemble handles empty name well because other supertypes don't set it in conf. Expectation that the name in config is same as in metadata is bug prone. Config should be the place where use can define customized settings. Remove printing "name=" from mdadm config creation commands. Ignore the name in config file to keep backward compatibility. Remove description from man mdadm.conf. Update 00conftest because "name" is no longer accepted. As the name is ignored, error for mdadm --detail is not printed. Reported-by: Stefan Fleischmann <sfle@kth.se> Fixes: e2eb503bd797 ("mdadm: Follow POSIX Portable Character Set") Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>
* Remove all "if zeros"Mateusz Kusiak2023-12-191-20/+0
| | | | | | | | No more random encounters of "if zeros". Remove all "if 0" code blocks. Signed-off-by: Mateusz Kusiak <mateusz.kusiak@intel.com> Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>
* mdadm/super1: Add MD_FEATURE_RAID0_LAYOUT if kernel>=5.4Xiao Ni2023-10-261-3/+16
| | | | | | | | | | | | | | | | | After and include kernel v5.4, it adds one feature bit MD_FEATURE_RAID0_LAYOUT. It must need to specify a layout for raid0 with more than one zone. But for raid0 with one zone, in fact it also has a defalut layout. Now for raid0 with one zone, *unknown* layout can be seen when running mdadm -D command. It's the reason that mdadm doesn't set MD_FEATURE_RAID0_LAYOUT for raid0 with one zone. Then in kernel space, super_1_validate sets mddev->layout to -1 because of no MD_FEATURE_RAID0_LAYOUT. In fact, in raid0 io path, it uses the default layout. Set raid0_need_layout to true if kernel_version<=v5.4. Fixes: 329dfc28debb ('Create: add support for RAID0 layouts.') Signed-off-by: Xiao Ni <xni@redhat.com> Reviewed-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-2/+1
| | | | | | | | 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>
* Bump minimum kernel version to 2.6.32Jes Sorensen2023-04-101-5/+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>
* Fix some cases eyesore formattingJes Sorensen2023-04-101-57/+60
| | | | | | Summary: No functional change .... just make it more readable. Signed-off-by: Jes Sorensen <jes@trained-monkey.org>
* super1: fix truncation check for journal deviceHristo Venev2023-04-101-2/+3
| | | | | | | | The journal device can be smaller than the component devices. Fixes: 171e9743881e ("super1: report truncated device") Signed-off-by: Hristo Venev <hristo@venev.name> Signed-off-by: Jes Sorensen <jes@trained-monkey.org>
* Change update to enum in update_super and update_subarrayMateusz Kusiak2023-01-041-9/+8
| | | | | | | | | | 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>
* super1: refactor the code for enumMateusz Kusiak2023-01-041-61/+91
| | | | | | | | It prepares update_super1 for change context->update to enum. Change if else statements into switch. Signed-off-by: Mateusz Kusiak <mateusz.kusiak@intel.com> Signed-off-by: Jes Sorensen <jes@trained-monkey.org>
* mdadm: replace container level checking with inlineKinga Tanska2022-09-291-1/+1
| | | | | | | | | 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>
* super1: report truncated deviceNeilBrown2022-08-291-7/+28
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When the metadata is at the start of the device, it is possible that it describes a device large than the one it is actually stored on. When this happens, report it loudly in --examine. .... Unused Space : before=1968 sectors, after=-2047 sectors DEVICE TOO SMALL State : clean TRUNCATED DEVICE .... Also report in --assemble so that the failure which the kernel will report will be explained. mdadm: Device /dev/sdb is not large enough for data described in superblock mdadm: no RAID superblock on /dev/sdb mdadm: /dev/sdb has no superblock - assembly aborted Scenario can be demonstrated as follows: mdadm: Note: this array has metadata at the start and may not be suitable as a boot device. If you plan to store '/boot' on this device please ensure that your boot-loader understands md/v1.x metadata, or use --metadata=0.90 mdadm: Defaulting to version 1.2 metadata mdadm: array /dev/md/test started. mdadm: stopped /dev/md/test Unused Space : before=1968 sectors, after=-2047 sectors DEVICE TOO SMALL State : clean TRUNCATED DEVICE Unused Space : before=1968 sectors, after=-2047 sectors DEVICE TOO SMALL State : clean TRUNCATED DEVICE Signed-off-by: NeilBrown <neilb@suse.de> Signed-off-by: Jes Sorensen <jsorensen@fb.com>
* mdadm: block update=ppl for non raid456 levelsLukasz Florczak2022-06-241-2/+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>
* mdadm/super1: restore commit 45a87c2f31335 to fix clustered slot issueHeming Zhao2022-06-241-1/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Commit 9d67f6496c71 ("mdadm:check the nodes when operate clustered array") modified assignment logic for st->nodes in write_bitmap1(), which introduced bitmap slot issue: load_super1 didn't set up supertype.nodes, which made spare disk only have one slot info. Then it triggered kernel md_bitmap_load_sb to get wrong bitmap slot data. For fixing this issue, there are two methods: 1> revert the related code of commit 9d67f6496c71. and restore the code from former commit 45a87c2f31335 ("super1: add more checks for NodeNumUpdate option"). st->nodes value would be 0 & 1 under current code logic. i.e. When adding a spare disk, there is no place to init st->nodes, and the value is ZERO. 2> keep 9d67f6496c71, add additional ->nodes handling in load_super1(), let load_super1 to set st->nodes when bitmap is BITMAP_MAJOR_CLUSTERED. Under current mdadm code logic, load_super1 will be called many times, any new code in load_super1 will cost mdadm running more time. And more reason is I prefer as much as possible to limit clustered code spreading in every corner. So I used method <1> to fix this issue. How to trigger: dd if=/dev/zero bs=1M count=1 oflag=direct of=/dev/sda dd if=/dev/zero bs=1M count=1 oflag=direct of=/dev/sdb dd if=/dev/zero bs=1M count=1 oflag=direct of=/dev/sdc mdadm -C /dev/md0 -b clustered -e 1.2 -n 2 -l mirror /dev/sda /dev/sdb mdadm -a /dev/md0 /dev/sdc mdadm /dev/md0 --fail /dev/sda mdadm /dev/md0 --remove /dev/sda mdadm -Ss mdadm -A /dev/md0 /dev/sdb /dev/sdc the output of current "mdadm -X /dev/sdc": (there should be (by default) 4 slot info for correct output) ``` Filename : /dev/sdc Magic : 6d746962 Version : 5 UUID : a74642f8:a6b1fba8:58e1f8db:cfe7b082 Events : 29 Events Cleared : 0 State : OK Chunksize : 64 MB Daemon : 5s flush period Write Mode : Normal Sync Size : 306176 (299.00 MiB 313.52 MB) Bitmap : 5 bits (chunks), 5 dirty (100.0%) ``` And mdadm later operations will trigger kernel output error message: (triggered by "mdadm -A /dev/md0 /dev/sdb /dev/sdc") ``` kernel: md0: invalid bitmap file superblock: bad magic kernel: md_bitmap_copy_from_slot can't get bitmap from slot 1 kernel: md-cluster: Could not gather bitmaps from slot 1 kernel: md0: invalid bitmap file superblock: bad magic kernel: md_bitmap_copy_from_slot can't get bitmap from slot 2 kernel: md-cluster: Could not gather bitmaps from slot 2 kernel: md0: invalid bitmap file superblock: bad magic kernel: md_bitmap_copy_from_slot can't get bitmap from slot 3 kernel: md-cluster: Could not gather bitmaps from slot 3 kernel: md-cluster: failed to gather all resyn infos kernel: md0: detected capacity change from 0 to 612352 ``` Acked-by: Coly Li <colyli@suse.de> Signed-off-by: Heming Zhao <heming.zhao@suse.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>
* mdadm/super1: It needs to specify int32 for bitmap_offsetXiao Ni2021-07-161-1/+1
| | | | | | | | For super1.0 bitmap offset is -16. So it needs to use int type for bitmap offset. Fixes: 1fe2e1007310 (mdadm/bitmap: locate bitmap calcuate bitmap position wrongly) Signed-off-by: Xiao Ni <xni@redhat.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>
* super1.c: avoid useless sync when bitmap switches from clustered to noneZhao Heming2021-03-031-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | With kernel commit 480523feae58 ("md: only call set_in_sync() when it is expected to succeed."), mddev->in_sync in clustered array is always zero. It makes metadata resync_offset to always zero. When assembling a clusterd array with "-U no-bitmap" option, kernel md layer "mddev->resync_offset == 0" and "mddev->bitmap == NULL" will trigger raid1 do sync on every bitmap chunk. the sync action is useless, we should avoid it. Related kernel flow: ``` md_do_sync mddev->pers->sync_request raid1_sync_request md_bitmap_start_sync(mddev->bitmap, sector_nr, &sync_blocks, 1) __bitmap_start_sync(bitmap, offset,&blocks1, degraded) if (bitmap == NULL) {/* FIXME or bitmap set as 'failed' */ *blocks = 1024; return 1; /* always resync if no bitmap */ } ``` Reprodusible steps: ``` node1 # mdadm -C /dev/md0 -b clustered -e 1.2 -n 2 -l mirror /dev/sd{a,b} node1 # mdadm -Ss (in another shell, executing & watching: watch -n 1 'cat /proc/mdstat') node1 # mdadm -A -U no-bitmap /dev/md0 /dev/sd{a,b} ``` Signed-off-by: Zhao Heming <heming.zhao@suse.com> Signed-off-by: Jes Sorensen <jsorensen@fb.com>
* super1: fix Floating point exceptionZhao Heming2021-03-031-1/+4
| | | | | | | | | | | | | | | | write_bitmap1 didn't check return value of locate_bitmap1, which will operate bitmap area under invalid bitmap info. mdadm core dumped when doing below steps: ``` node1 # mdadm -C /dev/md0 -b none -e 1.2 -n 2 -l mirror /dev/sda /dev/sdb node1 # mdadm -Ss node1 # mdadm -A -U home-cluster --home-cluster=abc /dev/md0 /dev/sda /dev/sdb Floating point exception (core dumped) ``` Signed-off-by: Zhao Heming <heming.zhao@suse.com> Signed-off-by: Jes Sorensen <jsorensen@fb.com>
* Grow: be careful of corrupt dev_roles listNeilBrown2021-03-031-10/+38
| | | | | | | | | | | | | | | | | | 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/bitmap: locate bitmap calcuate bitmap position wronglyXiao Ni2021-03-031-3/+9
| | | | | | | | Now it only adds bitmap offset based on cluster nodes. It's not right. It needs to add per node bitmap space to find next node bitmap position. Signed-off-by: Xiao Ni <xni@redhat.com> Signed-off-by: Jes Sorensen <jsorensen@fb.com>
* Super1: allow RAID0 layout setting to be removed.NeilBrown2020-10-141-1/+5
| | | | | | | | | | | | | | | | Once the RAID0 layout has been set, the RAID0 array cannot be assembled on an older kernel which doesn't understand layouts. This is an intentional safety feature, but sometimes people need the ability to roll-back to a previously working configuration. So add "--update=layout-unspecified" to remove RAID0 layout information from the superblock. Running "--assemble --update=layout-unspecified" will cause the assembly the fail when run on a newer kernel, but will allow it to work on an older kernel. Signed-off-by: NeilBrown <neilb@suse.de> Signed-off-by: Jes Sorensen <jsorensen@fb.com>
* Detect too-small device: error rather than underflow/crashDavid Favro2020-06-051-5/+14
| | | | | | | | | | | | | | For 1.x metadata, when the user requested creation of an array on component devices that were too small even to hold the superblock, an undetected integer wraparound (underflow) resulted in an enormous computed size which resulted in various follow-on errors such as floating-point exception. This patch detects this condition, prints a reasonable diagnostic message, and refuses to continue. Signed-off-by: David Favro <dfavro@meta-dynamic.com> Signed-off-by: Jes Sorensen <jsorensen@fb.com>
* Assemble: add support for RAID0 layouts.NeilBrown2019-12-021-1/+11
| | | | | | | | | | | | | If you have a RAID0 array with varying sized devices on a kernel before 5.4, you cannot assembling it on 5.4 or later without explicitly setting the layout. This is now possible with --update=layout-original (For 3.13 and earlier kernels) or --update=layout-alternate (for 3.14 and later kernels) Signed-off-by: NeilBrown <neilb@suse.de> Signed-off-by: Jes Sorensen <jsorensen@fb.com>
* Create: add support for RAID0 layouts.NeilBrown2019-12-021-1/+29
| | | | | | | | | | | | | | 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/+2
| | | | | | | | | | | 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>
* add missing units to --examineCorey Hickey2019-02-281-3/+3
| | | | | | | | | | | | | | | | | | | | | | | Within the output of "mdadm --examine", there are three sizes reported on adjacent lines. For example: $ sudo mdadm --examine /dev/md3 [...] Avail Dev Size : 17580545024 (8383.06 GiB 9001.24 GB) Array Size : 17580417024 (16765.99 GiB 18002.35 GB) Used Dev Size : 11720278016 (5588.66 GiB 6000.78 GB) [...] This can be confusing, since the first and third line are in 512-byte sectors, and the second is in KiB. Add units to avoid ambiguity. (I don't particularly like the "KiB" notation, but it is at least unambiguous.) Signed-off-by: Corey Hickey <bugfood-c@fatooh.org> Signed-off-by: Jes Sorensen <jsorensen@fb.com>
* super1: Fix cases triggering gcc-8.1 strncpy truncate warningJes Sorensen2018-05-311-4/+18
| | | | | | | Find the string length, copy it, and zero out the rest, instead of relying on strncpy cleaning up for us. Signed-off-by: Jes Sorensen <jsorensen@fb.com>
* mdadm: improve the dlm locking mechanism for clustered raidGuoqing Jiang2018-03-081-42/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* Zeroout whole ppl space during creation/force assemblePawel Baldysiak2017-10-021-0/+5
| | | | | | | | | | | 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>
* 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>
* mdadm: fixes some trivial typos in commentsZhilong Liu2017-10-021-4/+4
| | | | | | | fix some trivial typos in comments. Signed-off-by: Zhilong Liu <zlliu@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>
* 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>
* super1: fix sb->max_dev when adding a new disk in linear arrayLidong Zhong2017-05-261-1/+6
| | | | | | | | | | | | | | | | | | | The value of sb->max_dev will always be increased by 1 when adding a new disk in linear array. It causes an inconsistence between each disk in the array and the "Array State" value of "mdadm --examine DISK" is wrong. For example, when adding the first new disk into linear array it will be: Array State : RAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA ('A' == active, '.' == missing, 'R' == replacing) Adding the second disk into linear array it will be Array State : .AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA ('A' == active, '.' == missing, 'R' == replacing) Signed-off-by: Lidong Zhong <lzhong@suse.com> Signed-off-by: Jes Sorensen <jsorensen@fb.com>
* super1: Clean up various style abusesJes Sorensen2017-04-111-140/+223
| | | | | | | | Code is 80 characters wide, so lets try to respect that. In addition, we should never have one-line 'if () action()' statements. Fixup various whitespace abuse. Signed-off-by: Jes Sorensen <jsorensen@fb.com>
* Retire mdassembleJes Sorensen2017-04-111-18/+3
| | | | | | | | mdassemble doesn't handle container based arrays, no support for sysfs, etc. It has not been actively maintained for years, so time to send it off to retirement. Signed-off-by: Jes Sorensen <jsorensen@fb.com>
* super1: replace hard-coded values with bit definitionsGioh Kim2017-03-291-3/+4
| | | | | | | | Some hard-coded values for disk status are replaced with bit definitions. Signed-off-by: Gioh Kim <gi-oh.kim@profitbricks.com> Signed-off-by: Jes Sorensen <Jes.Sorensen@gmail.com>
* Add 'ppl' and 'no-ppl' options for --update=Artur Paszkiewicz2017-03-291-0/+49
| | | | | | | | This can be used with --assemble for super1 and with --update-subarray for imsm to enable or disable PPL in the metadata. Signed-off-by: Artur Paszkiewicz <artur.paszkiewicz@intel.com> Signed-off-by: Jes Sorensen <Jes.Sorensen@gmail.com>
* super1: PPL supportArtur Paszkiewicz2017-03-291-18/+132
| | | | | | | | | | | | | | | | Enable creating and assembling raid5 arrays with PPL for 1.x metadata. When creating, reserve enough space for PPL and store its size and location in the superblock and set MD_FEATURE_PPL bit. Write an initial empty header in the PPL area on each device. PPL is stored in the metadata region reserved for internal write-intent bitmap, so don't allow using bitmap and PPL together. While at it, fix two endianness issues in write_empty_r5l_meta_block() and write_init_super1(). Signed-off-by: Artur Paszkiewicz <artur.paszkiewicz@intel.com> Signed-off-by: Jes Sorensen <Jes.Sorensen@gmail.com>
* Detail: show consistency policyArtur Paszkiewicz2017-03-291-4/+5
| | | | | | | | | Show the currently enabled consistency policy in the output from --detail. Add 3 spaces to all existing items in Detail output to align with "Consistency Policy : ". Signed-off-by: Artur Paszkiewicz <artur.paszkiewicz@intel.com> Signed-off-by: Jes Sorensen <Jes.Sorensen@gmail.com>
* Generic support for --consistency-policy and PPLArtur Paszkiewicz2017-03-291-3/+3
| | | | | | | | | | | | | Add a new parameter to mdadm: --consistency-policy=. It determines how the array maintains consistency in case of unexpected shutdown. This maps to the md sysfs attribute 'consistency_policy'. It can be used to create a raid5 array using PPL. Add the necessary plumbing to pass this option to metadata handlers. The write journal and bitmap functionalities are treated as different policies, which are implicitly selected when using --write-journal or --bitmap options. Signed-off-by: Artur Paszkiewicz <artur.paszkiewicz@intel.com> Signed-off-by: Jes Sorensen <Jes.Sorensen@gmail.com>
* super1: ignore failfast flag for setting device roleGioh Kim2017-03-281-3/+5
| | | | | | | | | | There is corner case for setting device role, if new device has failfast flag. The failfast flag should be ignored. Signed-off-by: Gioh Kim <gi-oh.kim@profitbricks.com> Signed-off-by: Jack Wang <jinpu.wang@profitbricks.com> Signed-off-by: Jes Sorensen <Jes.Sorensen@gmail.com>