mdadm-CI for-jes/20220728: patches for merge
cover mdadm-CI for-jes/20220728: patches for merge
Hi Jes,
The following patches are reviewed by Mariusz and me, and the non-test patches pass roughly testing by array (with/without imsm) array creation/stop.
All the patches are pushed to for-jes/20220728 branch of my mdadm-CI tree, for patchwork to trace them more conveniently I post them all in this email threads.
Please consider to take them to mdadm upstream.
Thanks.
Coly Li
---
Hannes Reinecke (1):
mdadm: enable Intel Alderlake RSTe configuration
Kinga Tanska (2):
Assemble: check if device is container before scheduling force-clean
update
mdadm: replace container level checking with inline
Logan Gunthorpe (11):
Makefile: Don't build static build with everything and everything-test
DDF: Cleanup validate_geometry_ddf_container()
DDF: Fix NULL pointer dereference in validate_geometry_ddf() mdadm/Grow: Fix use after close bug by closing after fork
monitor: Avoid segfault when calling NULL get_bad_blocks
mdadm: Fix mdadm -r remove option regression
mdadm: Fix optional --write-behind parameter
mdadm/test: Add a mode to repeat specified tests mdadm/test: Mark and ignore broken test failures
tests: Add broken files for all broken tests tests/00readonly: Run udevadm settle before setting ro
Mariusz Tkaczyk (3):
tests: add test for names
mdadm: remove symlink option
mdadm: move data_offset to struct shape
Mateusz Kusiak (1):
Grow: Split Grow_reshape into helper function
NeilBrown (1):
super1: report truncated device
Sudhakar Panneerselvam (4):
tests/00raid0: add a test that validates raid0 with layout fails for
0.9
tests: fix raid0 tests for 0.90 metadata tests/04update-metadata: avoid passing chunk size to raid1 tests/02lineargrow: clear the superblock at every iteration
Assemble.c | 10 +- Create.c | 22 ++-- Grow.c | 142 +++++++++++---------- Incremental.c | 4 +- Makefile | 4 +- ReadMe.c | 2 +- config.c | 7 +- mdadm.8.in | 9 -- mdadm.c | 46 ++----- mdadm.conf.5.in | 15 --- mdadm.h | 24 +++- monitor.c | 3 + platform-intel.c | 8 +- super-ddf.c | 98 +++++++------- super-intel.c | 4 +- super0.c | 2 +- super1.c | 36 ++++-- sysfs.c | 2 +- test | 71 +++++++++-- tests/00createnames | 93 ++++++++++++++ tests/00raid0 | 10 +- tests/00readonly | 5 + tests/01r5integ.broken | 7 + tests/01raid6integ.broken | 7 + tests/02lineargrow | 2 + tests/03r0assem | 6 +- tests/04r0update | 4 +- tests/04r5swap.broken | 7 + tests/04update-metadata | 8 +- tests/07autoassemble.broken | 8 ++ tests/07autodetect.broken | 5 + tests/07changelevelintr.broken | 9 ++ tests/07changelevels.broken | 9 ++ tests/07reshape5intr.broken | 45 +++++++ tests/07revert-grow.broken | 31 +++++ tests/07revert-shrink.broken | 9 ++ tests/07testreshape5.broken | 12 ++ tests/09imsm-assemble.broken | 6 + tests/09imsm-create-fail-rebuild.broken | 5 + tests/09imsm-overlap.broken | 7 + tests/10ddf-assemble-missing.broken | 6 + tests/10ddf-fail-create-race.broken | 7 + tests/10ddf-fail-two-spares.broken | 5 + tests/10ddf-incremental-wrong-order.broken | 9 ++ tests/14imsm-r1_2d-grow-r1_3d.broken | 5 + tests/14imsm-r1_2d-takeover-r0_2d.broken | 6 + tests/18imsm-r10_4d-takeover-r0_2d.broken | 5 + tests/18imsm-r1_2d-takeover-r0_1d.broken | 6 + tests/19raid6auto-repair.broken | 5 + tests/19raid6repair.broken | 5 + util.c | 14 ++ 51 files changed, 626 insertions(+), 251 deletions(-) create mode 100644 tests/00createnames create mode 100644 tests/01r5integ.broken create mode 100644 tests/01raid6integ.broken create mode 100644 tests/04r5swap.broken create mode 100644 tests/07autoassemble.broken create mode 100644 tests/07autodetect.broken create mode 100644 tests/07changelevelintr.broken create mode 100644 tests/07changelevels.broken create mode 100644 tests/07reshape5intr.broken create mode 100644 tests/07revert-grow.broken create mode 100644 tests/07revert-shrink.broken create mode 100644 tests/07testreshape5.broken create mode 100644 tests/09imsm-assemble.broken create mode 100644 tests/09imsm-create-fail-rebuild.broken create mode 100644 tests/09imsm-overlap.broken create mode 100644 tests/10ddf-assemble-missing.broken create mode 100644 tests/10ddf-fail-create-race.broken create mode 100644 tests/10ddf-fail-two-spares.broken create mode 100644 tests/10ddf-incremental-wrong-order.broken create mode 100644 tests/14imsm-r1_2d-grow-r1_3d.broken create mode 100644 tests/14imsm-r1_2d-takeover-r0_2d.broken create mode 100644 tests/18imsm-r10_4d-takeover-r0_2d.broken create mode 100644 tests/18imsm-r1_2d-takeover-r0_1d.broken create mode 100644 tests/19raid6auto-repair.broken create mode 100644 tests/19raid6repair.broken
Signature · 1 line
2.35.3
PATCH 1/23 Makefile: Don't build static build with everything and everything-test
From: Logan Gunthorpe <[email protected]>
Running the test suite requires building everything, but it seems to be difficult to build the static version of mdadm now seeing there is no readily available static udev library.
The test suite doesn't need the static binary so just don't build it with the everything or everything-test targets.
Leave the mdadm.static and install-static targets in place in case someone still has a use case for the static binary.
--- Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
Makefile +2 -2
@@ -182,9 +182,9 @@ check_rundir: echo "***** or set CHECK_RUN_DIR=0"; exit 1; \ fi -everything: all mdadm.static swap_super test_stripe raid6check \ +everything: all swap_super test_stripe raid6check \ mdadm.Os mdadm.O2 man -everything-test: all mdadm.static swap_super test_stripe \ +everything-test: all swap_super test_stripe \ mdadm.Os mdadm.O2 man # mdadm.uclibc doesn't work on x86-64 # mdadm.tcc doesn't work..
Signature · 1 line
2.35.3
PATCH 2/23 DDF: Cleanup validate_geometry_ddf_container()
In reply to Coly LiFrom: Logan Gunthorpe <[email protected]>
Move the function up so that the function declaration is not necessary and remove the unused arguments to the function.
No functional changes are intended but will help with a bug fix in the next patch.
--- super-ddf.c | 88 ++++++++++++++++++++++++----------------------------- 1 file changed, 39 insertions(+), 49 deletions(-)
super-ddf.c +39 -49
@@ -503,13 +503,6 @@ struct ddf_super {static int load_super_ddf_all (struct supertype *st,int fd,void **sbp,char *devname);static int get_svd_state (const struct ddf_super *,const struct vcl *); -static int -validate_geometry_ddf_container (struct supertype *st, -int level,int layout,int raiddisks, -int chunk,unsigned long long size, -unsigned long long data_offset, -char *dev,unsigned long long *freesize, -int verbose); static int validate_geometry_ddf_bvd(struct supertype *st, int level, int layout, int raiddisks,
@@ -3322,6 +3315,42 @@ static int reserve_space(struct supertype *st, int raiddisks,return 1 ; } +static int +validate_geometry_ddf_container (struct supertype *st, +int level,int raiddisks, +unsigned long long data_offset, +char *dev,unsigned long long *freesize, +int verbose) +{ +int fd; +unsigned long long ldsize; + +if (level !=LEVEL_CONTAINER ) +return 0 ; +if (!dev) +return 1 ; + + fd =dev_open (dev,O_RDONLY |O_EXCL ); +if (fd <0 ) { +if (verbose) +pr_err ("ddf: Cannot open %s: %s\n" , + dev,strerror (errno)); +return 0 ; + } +if (!get_dev_size (fd, dev, &ldsize)) { +close (fd); +return 0 ; + } +close (fd); +if (freesize) { + *freesize =avail_size_ddf (st, ldsize >>9 ,INVALID_SECTORS ); +if (*freesize ==0 ) +return 0 ; + } + +return 1 ; +} + static int validate_geometry_ddf(struct supertype *st, int level, int layout, int raiddisks, int *chunk, unsigned long long size,
@@ -3347,11 +3376,9 @@ static int validate_geometry_ddf(struct supertype *st, level =LEVEL_CONTAINER ;if (level ==LEVEL_CONTAINER ) {/* Must be a fresh device to add to a container */ -return validate_geometry_ddf_container (st, level, layout, - raiddisks, *chunk, - size, data_offset, dev, - freesize, - verbose); +return validate_geometry_ddf_container (st, level, raiddisks, + data_offset, dev, + freesize, verbose); }if (!dev) {
@@ -3449,43 +3476,6 @@ static int validate_geometry_ddf(struct supertype *st,return 1 ; } -static int -validate_geometry_ddf_container (struct supertype *st, -int level,int layout,int raiddisks, -int chunk,unsigned long long size, -unsigned long long data_offset, -char *dev,unsigned long long *freesize, -int verbose) -{ -int fd; -unsigned long long ldsize; - -if (level !=LEVEL_CONTAINER ) -return 0 ; -if (!dev) -return 1 ; - - fd =dev_open (dev,O_RDONLY |O_EXCL ); -if (fd <0 ) { -if (verbose) -pr_err ("ddf: Cannot open %s: %s\n" , - dev,strerror (errno)); -return 0 ; - } -if (!get_dev_size (fd, dev, &ldsize)) { -close (fd); -return 0 ; - } -close (fd); -if (freesize) { - *freesize =avail_size_ddf (st, ldsize >>9 ,INVALID_SECTORS ); -if (*freesize ==0 ) -return 0 ; - } - -return 1 ; -} - static int validate_geometry_ddf_bvd(struct supertype *st, int level, int layout, int raiddisks, int *chunk, unsigned long long size,
Signature · 1 line
2.35.3
PATCH 3/23 DDF: Fix NULL pointer dereference in validate_geometry_ddf()
In reply to Coly LiFrom: Logan Gunthorpe <[email protected]>
A relatively recent patch added a call to validate_geometry() in Manage_add() that has level=LEVEL_CONTAINER and chunk=NULL.
This causes some ddf tests to segfault which aborts the test suite.
To fix this, avoid dereferencing chunk when the level is LEVEL_CONTAINER or LEVEL_NONE.
--- super-ddf.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
super-ddf.c +3 -3
@@ -3369,9 +3369,6 @@ static int validate_geometry_ddf(struct supertype *st,* If given BVDs, we make an SVD, changing all the GUIDs in the process. */ -if (*chunk == UnSet) - *chunk =DEFAULT_CHUNK ; -if (level ==LEVEL_NONE ) level =LEVEL_CONTAINER ;if (level ==LEVEL_CONTAINER ) {
@@ -3381,6 +3378,9 @@ static int validate_geometry_ddf(struct supertype *st, freesize, verbose); } +if (*chunk == UnSet) + *chunk =DEFAULT_CHUNK ; +if (!dev) {mdu_array_info_t array = { .level = level,
Signature · 1 line
2.35.3
PATCH 4/23 mdadm/Grow: Fix use after close bug by closing after fork
In reply to Coly LiFrom: Logan Gunthorpe <[email protected]>
The test 07reshape-grow fails most of the time. But it succeeds around 1 in 5 times. When it does succeed, it causes the tests to die because mdadm has segfaulted.
The segfault was caused by mdadm attempting to repoen a file descriptor that was already closed. The backtrace of the segfault was:
#0 __strncmp_avx2 () at ../sysdeps/x86_64/multiarch/strcmp-avx2.S:101
#1 0x000056146e31d44b in devnm2devid (devnm=0x0) at util.c:956
#2 0x000056146e31dab4 in open_dev_flags (devnm=0x0, flags=0)
at util.c:1072
#3 0x000056146e31db22 in open_dev (devnm=0x0) at util.c:1079
#4 0x000056146e3202e8 in reopen_mddev (mdfd=4) at util.c:2244
#5 0x000056146e329f36 in start_array (mdfd=4,
mddev=0x7ffc55342450 "/dev/md0", content=0x7ffc55342860,
st=0x56146fc78660, ident=0x7ffc55342f70, best=0x56146fc6f5d0,
bestcnt=10, chosen_drive=0, devices=0x56146fc706b0, okcnt=5,
sparecnt=0, rebuilding_cnt=0, journalcnt=0, c=0x7ffc55342e90,
clean=1, avail=0x56146fc78720 "\001\001\001\001\001",
start_partial_ok=0, err_ok=0, was_forced=0)
at Assemble.c:1206
#6 0x000056146e32c36e in Assemble (st=0x56146fc78660,
mddev=0x7ffc55342450 "/dev/md0", ident=0x7ffc55342f70,
devlist=0x56146fc6e2d0, c=0x7ffc55342e90)
at Assemble.c:1914
#7 0x000056146e312ac9 in main (argc=11, argv=0x7ffc55343238)
at mdadm.c:1510The file descriptor was closed early in Grow_continue(). The noted commit moved the close() call to close the fd above the fork which caused the parent process to return with a closed fd.
This meant reshape_array() and Grow_continue() would return in the parent with the fd forked. The fd would eventually be passed to reopen_mddev() which returned an unhandled NULL from fd2devnm() which would then be dereferenced in devnm2devid.
Fix this by moving the close() call below the fork. This appears to fix the 07revert-grow test. While we're at it, switch to using close_fd() to invalidate the file descriptor.
--- Grow.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
Grow.c +3 -1
@@ -3514,7 +3514,6 @@ started:return 0 ; } -close (fd);/* Now we just need to kick off the reshape and watch, while * handling backups of the data... * This is all done by a forked background process.
@@ -3535,6 +3534,9 @@ started:break ; } +/* Close unused file descriptor in the forked process */ +close_fd (&fd); +/* If another array on the same devices is busy, the * reshape will wait for them. This would mean that * the first section that we suspend will stay suspended
Signature · 1 line
2.35.3
PATCH 5/23 monitor: Avoid segfault when calling NULL get_bad_blocks
In reply to Coly LiFrom: Logan Gunthorpe <[email protected]>
Not all struct superswitch implement a get_bad_blocks() function, yet mdmon seems to call it without checking for NULL and thus occasionally segfaults in the test 10ddf-geometry.
Fix this by checking for NULL before calling it.
--- monitor.c | 3 +++ 1 file changed, 3 insertions(+)
monitor.c +3 -0
@@ -311,6 +311,9 @@ static int check_for_cleared_bb(struct active_array *a, struct mdinfo *mdi)struct md_bb *bb;int i; +if (!ss->get_bad_blocks) +return -1 ; +/* * Get a list of bad blocks for an array, then read list of * acknowledged bad blocks from kernel and compare it against metadata
Signature · 1 line
2.35.3
PATCH 6/23 mdadm: Fix mdadm -r remove option regression
In reply to Coly LiFrom: Logan Gunthorpe <[email protected]>
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 read. 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.
[Coly Li fixes the typo in commit log from 'readded' to 'read']
--- ReadMe.c | 1 + mdadm.c | 1 + mdadm.h | 1 + 3 files changed, 3 insertions(+)
ReadMe.c +1 -0
@@ -82,6 +82,7 @@ char Version[] = "mdadm - v" VERSION " - " VERS_DATE EXTRAVERSION "\n";*/ char short_options[]="-ABCDEFGIQhVXYWZ:vqbc:i:l:p:m:n:x:u:c:d:z:U:N:sarfRSow1tye:k:" ; +char short_monitor_options[]="-ABCDEFGIQhVXYWZ:vqbc:i:l:p:m:r:n:x:u:c:d:z:U:N:safRSow1tye:k:" ;char short_bitmap_options[]="-ABCDEFGIQhVXYWZ:vqb:c:i:l:p:m:n:x:u:c:d:z:U:N:sarfRSow1tye:k:" ; char short_bitmap_auto_options[]=
mdadm.c +1 -0
@@ -227,6 +227,7 @@ int main(int argc, char *argv[]) shortopt = short_bitmap_auto_options;break ;case 'F' : newmode =MONITOR ; + shortopt = short_monitor_options;break ;case 'G' : newmode =GROW ; shortopt = short_bitmap_options;
mdadm.h +1 -0
@@ -419,6 +419,7 @@ enum mode { };extern char short_options[]; +extern char short_monitor_options[];extern char short_bitmap_options[];extern char short_bitmap_auto_options[];extern struct option long_options[];
Signature · 1 line
2.35.3
PATCH 7/23 mdadm: Fix optional --write-behind parameter
In reply to Coly LiFrom: Logan Gunthorpe <[email protected]>
The commit noted below changed the behaviour of --write-behind to require an argument. This broke the 06wrmostly test with the error:
mdadm: Invalid value for maximum outstanding write-behind writes: (null).
Must be between 0 and 16383.
To fix this, check if optarg is NULL before parising it, as the original code did.
[Coly Li fixes the typo in commit log from 'origial' to 'original'.]
--- mdadm.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
mdadm.c +3 -2
@@ -1201,8 +1201,9 @@ int main(int argc, char *argv[])case O (BUILD , WriteBehind):case O (CREATE , WriteBehind): s.write_behind =DEFAULT_MAX_WRITE_BEHIND ; -if (parse_num (&s.write_behind, optarg) !=0 || - s.write_behind <0 || s.write_behind >16383 ) { +if (optarg && + (parse_num (&s.write_behind, optarg) !=0 || + s.write_behind <0 || s.write_behind >16383 )) {pr_err ("Invalid value for maximum outstanding write-behind writes: %s.\n\tMust be between 0 and 16383.\n" , optarg);exit (2 );
Signature · 1 line
2.35.3
PATCH 8/23 tests/00raid0: add a test that validates raid0 with layout fails for 0.9
In reply to Coly LiFrom: Sudhakar Panneerselvam <[email protected]>
329dfc28debb disallows the creation of raid0 with layouts for 0.9 metadata. This test confirms the new behavior.
--- tests/00raid0 | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
tests/00raid0 +2 -4
@@ -6,11 +6,9 @@ check raid0 testdev $md0 3 $mdsize2_l 512 mdadm -S $md0 -# now with version-0.90 superblock +# verify raid0 with layouts fail for 0.90 mdadm -CR $md0 -e0.90 -l0 -n4 $dev0 $dev1 $dev2 $dev3 -check raid0 -testdev $md0 4 $mdsize0 512 -mdadm -S $md0 +check opposite_result # now with no superblock mdadm -B $md0 -l0 -n5 $dev0 $dev1 $dev2 $dev3 $dev4
Signature · 1 line
2.35.3
PATCH 9/23 tests: fix raid0 tests for 0.90 metadata
In reply to Coly LiFrom: Sudhakar Panneerselvam <[email protected]>
Some of the test cases fail because raid0 creation fails with the error, "0.90 metadata does not support layouts for RAID0" added by commit, 329dfc28debb. Fix some of the test cases by switching from raid0 to linear level for 0.9 metadata where possible.
--- tests/00raid0 | 4 ++-- tests/00readonly | 4 ++++ tests/03r0assem | 6 +++--- tests/04r0update | 4 ++-- tests/04update-metadata | 2 +- 5 files changed, 12 insertions(+), 8 deletions(-)
tests/00raid0 +2 -2
@@ -20,8 +20,8 @@ mdadm -S $md0 # now same again with different chunk size for chunk in 4 32 256 do - mdadm -CR $md0 -e0.90 -l raid0 --chunk $chunk -n3 $dev0 $dev1 $dev2 - check raid0 + mdadm -CR $md0 -e0.90 -l linear --chunk $chunk -n3 $dev0 $dev1 $dev2 + check linear testdev $md0 3 $mdsize0 $chunk mdadm -S $md0
tests/00readonly +4 -0
@@ -4,6 +4,10 @@ for metadata in 0.9 1.0 1.1 1.2 do for level in linear raid0 raid1 raid4 raid5 raid6 raid10 do + if [[ $metadata == "0.9" && $level == "raid0" ]]; + then + continue + fi mdadm -CR $md0 -l $level -n 4 --metadata=$metadata \ $dev1 $dev2 $dev3 $dev4 --assume-clean check nosync
tests/03r0assem +3 -3
@@ -68,9 +68,9 @@ mdadm -S $md2 ### Now for version 0... mdadm --zero-superblock $dev0 $dev1 $dev2 -mdadm -CR $md2 -l0 --metadata=0.90 -n3 $dev0 $dev1 $dev2 -check raid0 -tst="testdev $md2 3 $mdsize0 512" +mdadm -CR $md2 -llinear --metadata=0.90 -n3 $dev0 $dev1 $dev2 +check linear +tst="testdev $md2 3 $mdsize0 1" $tst uuid=`mdadm -Db $md2 | sed 's/.*UUID=//'`
tests/04r0update +2 -2
@@ -1,7 +1,7 @@ # create a raid0, re-assemble with a different super-minor -mdadm -CR -e 0.90 $md0 -l0 -n3 $dev0 $dev1 $dev2 -testdev $md0 3 $mdsize0 512 +mdadm -CR -e 0.90 $md0 -llinear -n3 $dev0 $dev1 $dev2 +testdev $md0 3 $mdsize0 1 minor1=`mdadm -E $dev0 | sed -n -e 's/.*Preferred Minor : //p'` mdadm -S /dev/md0
tests/04update-metadata +1 -1
@@ -8,7 +8,7 @@ set -xe dlist="$dev0 $dev1 $dev2 $dev3" -for ls in raid0/4 linear/4 raid1/1 raid5/3 raid6/2 +for ls in linear/4 raid1/1 raid5/3 raid6/2 do s=${ls#*/} l=${ls%/*} mdadm -CR --assume-clean -e 0.90 $md0 --level $l -n 4 -c 64 $dlist
Signature · 1 line
2.35.3
PATCH 10/23 tests/04update-metadata: avoid passing chunk size to raid1
In reply to Coly LiFrom: Sudhakar Panneerselvam <[email protected]>
'04update-metadata' test fails with error, "specifying chunk size is forbidden for this level" added by commit, 5b30a34aa4b5e. Hence, correcting the test to ignore passing chunk size to raid1.
--- tests/04update-metadata | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
tests/04update-metadata +5 -1
@@ -11,7 +11,11 @@ dlist="$dev0 $dev1 $dev2 $dev3" for ls in linear/4 raid1/1 raid5/3 raid6/2 do s=${ls#*/} l=${ls%/*} - mdadm -CR --assume-clean -e 0.90 $md0 --level $l -n 4 -c 64 $dlist + if [[ $l == 'raid1' ]]; then + mdadm -CR --assume-clean -e 0.90 $md0 --level $l -n 4 $dlist + else + mdadm -CR --assume-clean -e 0.90 $md0 --level $l -n 4 -c 64 $dlist + fi testdev $md0 $s 19904 64 mdadm -S $md0 mdadm -A $md0 --update=metadata $dlist
Signature · 1 line
2.35.3
PATCH 11/23 tests/02lineargrow: clear the superblock at every iteration
In reply to Coly LiFrom: Sudhakar Panneerselvam <[email protected]>
This fixes 02lineargrow test as prior metadata causes --add operation to misbehave.
--- tests/02lineargrow | 2 ++ 1 file changed, 2 insertions(+)
tests/02lineargrow +2 -0
@@ -20,4 +20,6 @@ do testdev $md0 3 $sz 1 mdadm -S $md0 + mdadm --zero /dev/loop2 + mdadm --zero /dev/loop3 done
Signature · 1 line
2.35.3
PATCH 12/23 mdadm/test: Add a mode to repeat specified tests
In reply to Coly LiFrom: Logan Gunthorpe <[email protected]>
Many tests fail infrequently or rarely. To help find these, add an option to run the tests multiple times by specifying --loop=N.
If --loop=0 is specified, the test will be looped forever.
--- test | 36 ++++++++++++++++++++++++------------ 1 file changed, 24 insertions(+), 12 deletions(-)
test +24 -12
@@ -10,6 +10,7 @@ devlist= savelogs=0 exitonerror=1 +loop=1 prefix='[0-9][0-9]' # use loop devices by default if doesn't specify --dev
@@ -117,6 +118,7 @@ do_help() { --logdir=directory Directory to save all logfiles in --save-logs Usually use with --logdir together --keep-going | --no-error Don't stop on error, ie. run all tests + --loop=N Run tests N times (0 to run forever) --dev=loop|lvm|ram|disk Use loop devices (default), LVM, RAM or disk --disks= Provide a bunch of physical devices for test --volgroup=name LVM volume group for LVM test
@@ -211,6 +213,9 @@ parse_args() { --keep-going | --no-error ) exitonerror=0 ;; + --loop=* ) + loop="${i##*=}" + ;; --disable-multipath ) unset MULTIPATH ;;
@@ -263,19 +268,26 @@ main() { echo "Testing on linux-$(uname -r) kernel" [ "$savelogs" == "1" ] && echo "Saving logs to $logdir" - if [ "x$TESTLIST" != "x" ] - then - for script in ${TESTLIST[@]} - do - do_test $testdir/$script - done - else - for script in $testdir/$prefix $testdir/$prefix*[^~] - do - do_test $script - done - fi + while true; do + if [ "x$TESTLIST" != "x" ] + then + for script in ${TESTLIST[@]} + do + do_test $testdir/$script + done + else + for script in $testdir/$prefix $testdir/$prefix*[^~] + do + do_test $script + done + fi + + let loop=$loop-1 + if [ "$loop" == "0" ]; then + break + fi + done exit 0 }
Signature · 1 line
2.35.3
PATCH 13/23 mdadm/test: Mark and ignore broken test failures
In reply to Coly LiFrom: Logan Gunthorpe <[email protected]>
Add functionality to continue if a test marked as broken fails.
To mark a test as broken, a file with the same name but with the suffix '.broken' should exist. The first line in the file will be printed with a KNOWN BROKEN message; the rest of the file can describe the how the test is broken.
Also adds --skip-broken and --skip-always-broken to skip all the tests that have a .broken file or to skip all tests whose .broken file's first line contains the keyword always.
--- test | 37 +++++++++++++++++++++++++++++++++++-- 1 file changed, 35 insertions(+), 2 deletions(-)
test +35 -2
@@ -10,6 +10,8 @@ devlist= savelogs=0 exitonerror=1 +ctrl_c_error=0 +skipbroken=0 loop=1 prefix='[0-9][0-9]'
@@ -36,6 +38,7 @@ die() { ctrl_c() { exitonerror=1 + ctrl_c_error=1 } # mdadm always adds --quiet, and we want to see any unexpected messages
@@ -80,8 +83,21 @@ mdadm() { do_test() { _script=$1 _basename=`basename $_script` + _broken=0 + if [ -f "$_script" ] then + if [ -f "${_script}.broken" ]; then + _broken=1 + _broken_msg=$(head -n1 "${_script}.broken" | tr -d '\n') + if [ "$skipbroken" == "all" ]; then + return + elif [ "$skipbroken" == "always" ] && + [[ "$_broken_msg" == *always* ]]; then + return + fi + fi + rm -f $targetdir/stderr # this might have been reset: restore the default. echo 2000 > /proc/sys/dev/raid/speed_limit_max
@@ -98,10 +114,15 @@ do_test() { else save_log fail _fail=1 + if [ "$_broken" == "1" ]; then + echo " (KNOWN BROKEN TEST: $_broken_msg)" + fi fi [ "$savelogs" == "1" ] && mv -f $targetdir/log $logdir/$_basename.log - [ "$_fail" == "1" -a "$exitonerror" == "1" ] && exit 1 + [ "$ctrl_c_error" == "1" ] && exit 1 + [ "$_fail" == "1" -a "$exitonerror" == "1" \ + -a "$_broken" == "0" ] && exit 1 fi }
@@ -119,6 +140,8 @@ do_help() { --save-logs Usually use with --logdir together --keep-going | --no-error Don't stop on error, ie. run all tests --loop=N Run tests N times (0 to run forever) + --skip-broken Skip tests that are known to be broken + --skip-always-broken Skip tests that are known to always fail --dev=loop|lvm|ram|disk Use loop devices (default), LVM, RAM or disk --disks= Provide a bunch of physical devices for test --volgroup=name LVM volume group for LVM test
@@ -216,6 +239,12 @@ parse_args() { --loop=* ) loop="${i##*=}" ;; + --skip-broken ) + skipbroken=all + ;; + --skip-always-broken ) + skipbroken=always + ;; --disable-multipath ) unset MULTIPATH ;;
@@ -279,7 +308,11 @@ main() { else for script in $testdir/$prefix $testdir/$prefix*[^~] do - do_test $script + case $script in + *.broken) ;; + *) + do_test $script + esac done fi
Signature · 1 line
2.35.3
PATCH 14/23 tests: Add broken files for all broken tests
In reply to Coly LiFrom: Logan Gunthorpe <[email protected]>
Each broken file contains the rough frequency of brokenness as well as a brief explanation of what happens when it breaks. Estimates of failure rates are not statistically significant and can vary run to run.
This is really just a view from my window. Tests were done on a small VM with the default loop devices, not real hardware. We've seen different kernel configurations can cause bugs to appear as well (ie. different block schedulers). It may also be that different race conditions will be seen on machines with different performance characteristics.
These annotations were done with the kernel currently in md/md-next:
facef3b96c5b ("md: Notify sysfs sync_completed in md_reap_sync_thread()")
[Coly Li fixes the typo in commit log from 'brokeness' to 'brokenness'.]
--- tests/01r5integ.broken | 7 ++++ tests/01raid6integ.broken | 7 ++++ tests/04r5swap.broken | 7 ++++ tests/07autoassemble.broken | 8 ++++ tests/07autodetect.broken | 5 +++ tests/07changelevelintr.broken | 9 +++++ tests/07changelevels.broken | 9 +++++ tests/07reshape5intr.broken | 45 ++++++++++++++++++++++ tests/07revert-grow.broken | 31 +++++++++++++++ tests/07revert-shrink.broken | 9 +++++ tests/07testreshape5.broken | 12 ++++++ tests/09imsm-assemble.broken | 6 +++ tests/09imsm-create-fail-rebuild.broken | 5 +++ tests/09imsm-overlap.broken | 7 ++++ tests/10ddf-assemble-missing.broken | 6 +++ tests/10ddf-fail-create-race.broken | 7 ++++ tests/10ddf-fail-two-spares.broken | 5 +++ tests/10ddf-incremental-wrong-order.broken | 9 +++++ tests/14imsm-r1_2d-grow-r1_3d.broken | 5 +++ tests/14imsm-r1_2d-takeover-r0_2d.broken | 6 +++ tests/18imsm-r10_4d-takeover-r0_2d.broken | 5 +++ tests/18imsm-r1_2d-takeover-r0_1d.broken | 6 +++ tests/19raid6auto-repair.broken | 5 +++ tests/19raid6repair.broken | 5 +++ 24 files changed, 226 insertions(+) create mode 100644 tests/01r5integ.broken create mode 100644 tests/01raid6integ.broken create mode 100644 tests/04r5swap.broken create mode 100644 tests/07autoassemble.broken create mode 100644 tests/07autodetect.broken create mode 100644 tests/07changelevelintr.broken create mode 100644 tests/07changelevels.broken create mode 100644 tests/07reshape5intr.broken create mode 100644 tests/07revert-grow.broken create mode 100644 tests/07revert-shrink.broken create mode 100644 tests/07testreshape5.broken create mode 100644 tests/09imsm-assemble.broken create mode 100644 tests/09imsm-create-fail-rebuild.broken create mode 100644 tests/09imsm-overlap.broken create mode 100644 tests/10ddf-assemble-missing.broken create mode 100644 tests/10ddf-fail-create-race.broken create mode 100644 tests/10ddf-fail-two-spares.broken create mode 100644 tests/10ddf-incremental-wrong-order.broken create mode 100644 tests/14imsm-r1_2d-grow-r1_3d.broken create mode 100644 tests/14imsm-r1_2d-takeover-r0_2d.broken create mode 100644 tests/18imsm-r10_4d-takeover-r0_2d.broken create mode 100644 tests/18imsm-r1_2d-takeover-r0_1d.broken create mode 100644 tests/19raid6auto-repair.broken create mode 100644 tests/19raid6repair.broken
tests/01r5integ.broken new file +7 -0
@@ -0,0 +1,7 @@ +fails rarely + +Fails about 1 in every 30 runs with a sha mismatch error: + + c49ab26e1b01def7874af9b8a6d6d0c29fdfafe6 /dev/md0 does not match + 15dc2f73262f811ada53c65e505ceec9cf025cb9 /dev/md0 with /dev/loop3 + missing
tests/01raid6integ.broken new file +7 -0
@@ -0,0 +1,7 @@ +fails infrequently + +Fails about 1 in 5 with a sha mismatch: + + 8286c2bc045ae2cfe9f8b7ae3a898fa25db6926f /dev/md0 does not match + a083a0738b58caab37fd568b91b177035ded37df /dev/md0 with /dev/loop2 and + /dev/loop3 missing
tests/04r5swap.broken new file +7 -0
@@ -0,0 +1,7 @@ +always fails + +Fails with errors: + + mdadm: /dev/loop0 has no superblock - assembly aborted + + ERROR: no recovery happening
tests/07autoassemble.broken new file +8 -0
@@ -0,0 +1,8 @@ +always fails + +Prints lots of messages, but the array doesn't assemble. Error +possibly related to: + + mdadm: /dev/md/1 is busy - skipping + mdadm: no recogniseable superblock on /dev/md/testing:0 + mdadm: /dev/md/2 is busy - skipping
tests/07autodetect.broken new file +5 -0
@@ -0,0 +1,5 @@ +always fails + +Fails with error: + + ERROR: no resync happening
tests/07changelevelintr.broken new file +9 -0
@@ -0,0 +1,9 @@ +always fails + +Fails with errors: + + mdadm: this change will reduce the size of the array. + use --grow --array-size first to truncate array. + e.g. mdadm --grow /dev/md0 --array-size 56832 + + ERROR: no reshape happening
tests/07changelevels.broken new file +9 -0
@@ -0,0 +1,9 @@ +always fails + +Fails with errors: + + mdadm: /dev/loop0 is smaller than given size. 18976K < 19968K + metadata + mdadm: /dev/loop1 is smaller than given size. 18976K < 19968K + metadata + mdadm: /dev/loop2 is smaller than given size. 18976K < 19968K + metadata + + ERROR: /dev/md0 isn't a block device.
tests/07reshape5intr.broken new file +45 -0
45 lines not on this page · raw message
tests/07revert-grow.broken new file +31 -0
@@ -0,0 +1,31 @@ +always fails + +This patch, recently added to md-next causes the test to always fail: + +7e6ba434cc60 ("md: don't unregister sync_thread with reconfig_mutex held") + +The errors are: + + mdadm: No active reshape to revert on /dev/loop0 + ERROR: active raid5 not found + +Before the patch, the error seen is below. + +-- + +fails rarely + +Fails about 1 in every 30 runs with errors: + + mdadm: Merging with already-assembled /dev/md/0 + mdadm: backup file /tmp/md-backup inaccessible: No such file or directory + mdadm: failed to add /dev/loop1 to /dev/md/0: Invalid argument + mdadm: failed to add /dev/loop2 to /dev/md/0: Invalid argument + mdadm: failed to add /dev/loop3 to /dev/md/0: Invalid argument + mdadm: failed to add /dev/loop0 to /dev/md/0: Invalid argument + mdadm: /dev/md/0 assembled from 1 drive - need all 5 to start it + (use --run to insist). + + grep: /sys/block/md*/md/sync_action: No such file or directory + + ERROR: active raid5 not found
tests/07revert-shrink.broken new file +9 -0
@@ -0,0 +1,9 @@ +always fails + +Fails with errors: + + mdadm: this change will reduce the size of the array. + use --grow --array-size first to truncate array. + e.g. mdadm --grow /dev/md0 --array-size 53760 + + ERROR: active raid5 not found
tests/07testreshape5.broken new file +12 -0
@@ -0,0 +1,12 @@ +always fails + +Test seems to run 'test_stripe' at $dir directory, but $dir is never +set. If $dir is adjusted to $PWD, the test still fails with: + + mdadm: /dev/loop2 is not suitable for this array. + mdadm: create aborted + ++ return 1 + ++ cmp -s -n 8192 /dev/md0 /tmp/RandFile + ++ echo cmp failed + cmp failed + ++ exit 2
tests/09imsm-assemble.broken new file +6 -0
@@ -0,0 +1,6 @@ +fails infrequently + +Fails roughly 1 in 10 runs with errors: + + mdadm: /dev/loop2 is still in use, cannot remove. + /dev/loop2 removal from /dev/md/container should have succeeded
tests/09imsm-create-fail-rebuild.broken new file +5 -0
@@ -0,0 +1,5 @@ +always fails + +Fails with error: + + **Error**: Array size mismatch - expected 3072, actual 16384
tests/09imsm-overlap.broken new file +7 -0
@@ -0,0 +1,7 @@ +always fails + +Fails with errors: + + **Error**: Offset mismatch - expected 15360, actual 0 + **Error**: Offset mismatch - expected 15360, actual 0 + /dev/md/vol3 failed check
tests/10ddf-assemble-missing.broken new file +6 -0
@@ -0,0 +1,6 @@ +always fails + +Fails with errors: + + ERROR: /dev/md/vol0 has unexpected state on /dev/loop10 + ERROR: unexpected number of online disks on /dev/loop10
tests/10ddf-fail-create-race.broken new file +7 -0
@@ -0,0 +1,7 @@ +usually fails + +Fails about 9 out of 10 times with many errors: + + mdadm: cannot open MISSING: No such file or directory + ERROR: non-degraded array found + ERROR: disk 0 not marked as failed in meta data
tests/10ddf-fail-two-spares.broken new file +5 -0
@@ -0,0 +1,5 @@ +fails infrequently + +Fails roughly 1 in 3 with error: + + ERROR: /dev/md/vol1 should be optimal in meta data
tests/10ddf-incremental-wrong-order.broken new file +9 -0
@@ -0,0 +1,9 @@ +always fails + +Fails with errors: + ERROR: sha1sum of /dev/md/vol0 has changed + ERROR: /dev/md/vol0 has unexpected state on /dev/loop10 + ERROR: unexpected number of online disks on /dev/loop10 + ERROR: /dev/md/vol0 has unexpected state on /dev/loop8 + ERROR: unexpected number of online disks on /dev/loop8 + ERROR: sha1sum of /dev/md/vol0 has changed
tests/14imsm-r1_2d-grow-r1_3d.broken new file +5 -0
@@ -0,0 +1,5 @@ +always fails + +Fails with error: + + mdadm/tests/func.sh: line 325: dvsize/chunk: division by 0 (error token is "chunk")
tests/14imsm-r1_2d-takeover-r0_2d.broken new file +6 -0
@@ -0,0 +1,6 @@ +always fails + +Fails with error: + + tests/func.sh: line 325: dvsize/chunk: division by 0 (error token + is "chunk")
tests/18imsm-r10_4d-takeover-r0_2d.broken new file +5 -0
@@ -0,0 +1,5 @@ +fails rarely + +Fails about 1 run in 100 with message: + + ERROR: size is wrong for /dev/md/vol0: 2 * 5120 (chunk=128) = 20480, not 0
tests/18imsm-r1_2d-takeover-r0_1d.broken new file +6 -0
@@ -0,0 +1,6 @@ +always fails + +Fails with error: + + tests/func.sh: line 325: dvsize/chunk: division by 0 (error token + is "chunk")
tests/19raid6auto-repair.broken new file +5 -0
@@ -0,0 +1,5 @@ +always fails + +Fails with: + + "should detect errors"
tests/19raid6repair.broken new file +5 -0
@@ -0,0 +1,5 @@ +always fails + +Fails with: + + "should detect errors"
Signature · 1 line
2.35.3
PATCH 15/23 Grow: Split Grow_reshape into helper function
In reply to Coly LiFrom: Mateusz Kusiak <[email protected]>
Grow_reshape should be split into helper functions given its size.
- Add helper function for preparing reshape on external metadata.
- Close cfd file descriptor.
--- Grow.c | 125 ++++++++++++++++++++++++++++++-------------------------- mdadm.h | 1 + util.c | 14 +++++++ 3 files changed, 81 insertions(+), 59 deletions(-)
Grow.c +66 -59
@@ -1773,6 +1773,65 @@ static int reshape_container(char *container, char *devname, char *backup_file, int verbose, int forked, int restart, int freeze_reshape); +/** +* prepare_external_reshape() - prepares update on external metadata if supported. +* @devname: Device name. +* @subarray: Subarray. +* @st: Supertype. +* @container: Container. +* @cfd: Container file descriptor. +* +* Function checks that the requested reshape is supported on external metadata, +* and performs an initial check that the container holds the pre-requisite +* spare devices (mdmon owns final validation). +* +* Return: 0 on success, else 1 +*/ +static int prepare_external_reshape (char *devname,char *subarray, +struct supertype *st,char *container, +const int cfd) +{ +struct mdinfo *cc =NULL ; +struct mdinfo *content =NULL ; + +if (st->ss->load_container (st, cfd,NULL )) { +pr_err ("Cannot read superblock for %s\n" , devname); +return 1 ; + } + +if (!st->ss->container_content) +return 1 ; + + cc = st->ss->container_content (st, subarray); +for (content = cc; content ; content = content->next) { +/* +* check if reshape is allowed based on metadata +* indications stored in content.array.status +*/ +if (is_bit_set (&content->array.state,MD_SB_BLOCK_VOLUME ) || +is_bit_set (&content->array.state,MD_SB_BLOCK_CONTAINER_RESHAPE )) { +pr_err ("Cannot reshape arrays in container with unsupported metadata: %s(%s)\n" , + devname, container); + goto error; + } +if (content->consistency_policy ==CONSISTENCY_POLICY_PPL ) { +pr_err ("Operation not supported when ppl consistency policy is enabled\n" ); + goto error; + } +if (content->consistency_policy ==CONSISTENCY_POLICY_BITMAP ) { +pr_err ("Operation not supported when write-intent bitmap consistency policy is enabled\n" ); + goto error; + } + } +sysfs_free (cc); +if (mdmon_running (container)) + st->update_tail = &st->updates; +return 0 ; +error: +sysfs_free (cc); +return 1 ; +} + int Grow_reshape(char *devname, int fd, struct mddev_dev *devlist, unsigned long long data_offset,
@@ -1800,7 +1859,7 @@ int Grow_reshape(char *devname, int fd,struct supertype *st;char *subarray =NULL ; -int frozen; +int frozen =0 ;int changed =0 ;char *container =NULL ;int cfd =-1 ;
@@ -1809,7 +1868,7 @@ int Grow_reshape(char *devname, int fd,int added_disks;struct mdinfo info; -struct mdinfo *sra; +struct mdinfo *sra =NULL ;if (md_get_array_info (fd, &array) <0 ) { pr_err("%s is not an active md array - aborting\n",
@@ -1866,13 +1925,7 @@ int Grow_reshape(char *devname, int fd, } } -/* in the external case we need to check that the requested reshape is -* supported, and perform an initial check that the container holds the -* pre-requisite spare devices (mdmon owns final validation) -*/ if (st->ss->external) { -int retval; -if (subarray) { container = st->container_devnm; cfd =open_dev_excl (st->container_devnm);
@@ -1888,13 +1941,12 @@ int Grow_reshape(char *devname, int fd,return 1 ; } - retval = st->ss->load_container (st, cfd,NULL ); - -if (retval) { -pr_err ("Cannot read superblock for %s\n" , devname); -close (cfd); + rv =prepare_external_reshape (devname, subarray, st, + container, cfd); +if (rv >0 ) {free (subarray); -return 1 ; +close (cfd); + goto release; }if (s->raiddisks && subarray) {
@@ -1903,51 +1955,6 @@ int Grow_reshape(char *devname, int fd,free (subarray);return 1 ; } - -/* check if operation is supported for metadata handler */ -if (st->ss->container_content) { -struct mdinfo *cc =NULL ; -struct mdinfo *content =NULL ; - - cc = st->ss->container_content (st, subarray); -for (content = cc; content ; content = content->next) { -int allow_reshape =1 ; - -/* check if reshape is allowed based on metadata -* indications stored in content.array.status -*/ -if (content->array.state & - (1 <<MD_SB_BLOCK_VOLUME )) - allow_reshape =0 ; -if (content->array.state & - (1 <<MD_SB_BLOCK_CONTAINER_RESHAPE )) - allow_reshape =0 ; -if (!allow_reshape) { -pr_err ("cannot reshape arrays in container with unsupported metadata: %s(%s)\n" , - devname, container); -sysfs_free (cc); -free (subarray); -return 1 ; - } -if (content->consistency_policy == -CONSISTENCY_POLICY_PPL ) { -pr_err ("Operation not supported when ppl consistency policy is enabled\n" ); -sysfs_free (cc); -free (subarray); -return 1 ; - } -if (content->consistency_policy == -CONSISTENCY_POLICY_BITMAP ) { -pr_err ("Operation not supported when write-intent bitmap is enabled\n" ); -sysfs_free (cc); -free (subarray); -return 1 ; - } - } -sysfs_free (cc); - } -if (mdmon_running (container)) - st->update_tail = &st->updates; } added_disks =0 ;
mdadm.h +1 -0
@@ -1542,6 +1542,7 @@ extern int stat_is_blkdev(char *devname, dev_t *rdev);extern bool is_dev_alive (char *path);extern int get_mdp_major (void );extern int get_maj_min (char *dev,int *major,int *minor); +extern bool is_bit_set (int *val,unsigned char index);extern int dev_open (char *dev,int flags);extern int open_dev (char *devnm);extern void reopen_mddev (int mdfd);
util.c +14 -0
@@ -1027,6 +1027,20 @@ int get_maj_min(char *dev, int *major, int *minor) *e == 0); } +/** +* is_bit_set() - get bit value by index. +* @val: value. +* @index: index of the bit (LSB numbering). +* +* Return: bit value. +*/ +bool is_bit_set (int *val,unsigned char index) +{ +if ((*val) & (1 << index)) +return true; +return false; +} +int dev_open (char *dev,int flags) {/* like 'open', but if 'dev' matches %d:%d, create a temp
Signature · 1 line
2.35.3
PATCH 16/23 super1: report truncated device
In reply to Coly LiFrom: NeilBrown <[email protected]>
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
--- super1.c | 34 +++++++++++++++++++++++++++------- 1 file changed, 27 insertions(+), 7 deletions(-)
super1.c +27 -7
@@ -406,12 +406,18 @@ static void examine_super1(struct supertype *st, char *homehost) st->ss->getinfo_super (st, &info,NULL );if (info.space_after !=1 && - !(__le32_to_cpu (sb->feature_map) &MD_FEATURE_NEW_OFFSET )) -printf (" Unused Space : before=%llu sectors, after=%llu sectors\n" , - info.space_before, info.space_after); - -printf (" State : %s\n" , - (__le64_to_cpu (sb->resync_offset)+1 )?"active" :"clean" ); + !(__le32_to_cpu (sb->feature_map) &MD_FEATURE_NEW_OFFSET )) { +printf (" Unused Space : before=%llu sectors, " , + info.space_before); +if (info.space_after <INT64_MAX ) +printf ("after=%llu sectors\n" , info.space_after); +else +printf ("after=-%llu sectors DEVICE TOO SMALL\n" , +UINT64_MAX - info.space_after); + } +printf (" State : %s%s\n" , + (__le64_to_cpu (sb->resync_offset)+1 )?"active" :"clean" , + info.space_after >INT64_MAX ?" TRUNCATED DEVICE" :"" );printf (" Device UUID : " );for (i=0 ; i<16 ; i++) {if ((i&3 )==0 && i !=0 )
@@ -2206,6 +2212,7 @@ static int load_super1(struct supertype *st, int fd, char *devname) tst.ss = &super1;for (tst.minor_version =0 ; tst.minor_version <=2 ; tst.minor_version++) { + tst.ignore_hw_compat = st->ignore_hw_compat;switch (load_super1 (&tst, fd, devname)) {case 0 : super = tst.sb; if (bestvers == -1 ||
@@ -2312,7 +2319,6 @@ static int load_super1(struct supertype *st, int fd, char *devname)free (super);return 2 ; } - st->sb = super; bsb = (struct bitmap_super_s *)(((char *)super)+MAX_SB_SIZE );
@@ -2322,6 +2328,20 @@ static int load_super1(struct supertype *st, int fd, char *devname)if (st->data_offset ==INVALID_SECTORS ) st->data_offset =__le64_to_cpu (super->data_offset); +if (st->minor_version >=1 && + st->ignore_hw_compat ==0 && + (__le64_to_cpu (super->data_offset) + +__le64_to_cpu (super->size) > dsize || +__le64_to_cpu (super->data_offset) + +__le64_to_cpu (super->data_size) > dsize)) { +if (devname) +pr_err ("Device %s is not large enough for data described in superblock\n" , + devname); +free (super); +return 2 ; + } + st->sb = super; +/* Now check on the bitmap superblock */ if ((__le32_to_cpu (super->feature_map)&MD_FEATURE_BITMAP_OFFSET ) ==0 )return 0 ;
Signature · 1 line
2.35.3
PATCH 17/23 Assemble: check if device is container before scheduling force-clean update
In reply to Coly LiFrom: Kinga Tanska <[email protected]>
When assemble is used with --force flag and array is not clean then "force-clean" update is scheduled. Containers are considered as not clean because this field is not set for them. To exclude them from meaningless update (it is ignored quietly) check if the device is a container first.
--- Assemble.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
Assemble.c +2 -3
@@ -1809,10 +1809,9 @@ try_again: }#endif } -if (c->force && !clean && +if (c->force && !clean && content->array.level !=LEVEL_CONTAINER && !enough (content->array.level, content->array.raid_disks, - content->array.layout, clean, - avail)) { + content->array.layout, clean, avail)) { change += st->ss->update_super (st, content,"force-array" , devices[chosen_drive].devname, c->verbose,0 ,NULL );
Signature · 1 line
2.35.3
PATCH 18/23 mdadm: replace container level checking with inline
In reply to Coly LiFrom: Kinga Tanska <[email protected]>
To unify all containers checks in code, is_container() function is added and propagated.
[Coly Li adds a newline at the end of mdadm.h]
--- Assemble.c | 5 ++--- Create.c | 6 +++--- Grow.c | 6 +++--- Incremental.c | 4 ++-- mdadm.h | 15 +++++++++++++++ super-ddf.c | 6 +++--- super-intel.c | 4 ++-- super0.c | 2 +- super1.c | 2 +- sysfs.c | 2 +- 10 files changed, 33 insertions(+), 19 deletions(-)
Assemble.c +2 -3
@@ -1120,7 +1120,7 @@ static int start_array(int mdfd, i/2, mddev); } -if (content->array.level ==LEVEL_CONTAINER ) { +if (is_container (content->array.level)) {sysfs_rules_apply (mddev, content);if (c->verbose >=0 ) { pr_err("Container %s has been assembled with %d drive%s",
@@ -1549,8 +1549,7 @@ try_again:*/ trustworthy =LOCAL ; -if (name[0 ] ==0 && - content->array.level ==LEVEL_CONTAINER ) { +if (!name[0 ] &&is_container (content->array.level)) { name = content->text_version; trustworthy =METADATA ; }
Create.c +3 -3
@@ -487,7 +487,7 @@ int Create(struct supertype *st, char *mddev, st->minor_version >= 1)/* metadata at front */ warn |=check_partitions (fd, dname,0 ,0 ); - else if (s->level == 1 || s->level == LEVEL_CONTAINER || + else if (s->level == 1 || is_container(s->level) || (s->level == 0 && s->raiddisks == 1)) /* partitions could be meaningful */ warn |= check_partitions(fd, dname, freesize*2, s->size*2);
@@ -997,7 +997,7 @@ int Create(struct supertype *st, char *mddev,* again returns container info. */ st->ss->getinfo_super (st, &info_new,NULL ); -if (st->ss->external && s->level !=LEVEL_CONTAINER && +if (st->ss->external && !is_container (s->level) && !same_uuid (info_new.uuid, info.uuid,0 )) { map_update(&map, fd2devnm(mdfd), info_new.text_version,
@@ -1040,7 +1040,7 @@ int Create(struct supertype *st, char *mddev,map_unlock (&map);free (infos); -if (s->level ==LEVEL_CONTAINER ) { +if (is_container (s->level)) {/* No need to start. But we should signal udev to * create links */ sysfs_uevent (&info,"change" );
Grow.c +3 -3
@@ -2176,7 +2176,7 @@ size_change_error: devname, s->size); } changed =1 ; - }else if (array.level !=LEVEL_CONTAINER ) { + }else if (!is_container (array.level)) { s->size =get_component_size (fd)/2 ;if (s->size ==0 ) s->size = array.size;
@@ -2232,7 +2232,7 @@ size_change_error: info.component_size = s->size*2 ; info.new_level = s->level; info.new_chunk = s->chunk *1024 ; -if (info.array.level ==LEVEL_CONTAINER ) { +if (is_container (info.array.level)) { info.delta_disks = UnSet; info.array.raid_disks = s->raiddisks; }else if (s->raiddisks)
@@ -2345,7 +2345,7 @@ size_change_error:printf ("layout for %s set to %d\n" , devname, array.layout); } - }else if (array.level ==LEVEL_CONTAINER ) { + }else if (is_container (array.level)) {/* This change is to be applied to every array in the * container. This is only needed when the metadata imposes * restraints of the various arrays in the container.
Incremental.c +2 -2
@@ -244,7 +244,7 @@ int Incremental(struct mddev_dev *devlist, struct context *c, c->autof = ci->autof; name_to_use = info.name; -if (name_to_use[0 ] ==0 && info.array.level ==LEVEL_CONTAINER ) { +if (name_to_use[0 ] ==0 &&is_container (info.array.level)) { name_to_use = info.text_version; trustworthy =METADATA ; }
@@ -472,7 +472,7 @@ int Incremental(struct mddev_dev *devlist, struct context *c,/* 7/ Is there enough devices to possibly start the array? */ /* 7a/ if not, finish with success. */ -if (info.array.level ==LEVEL_CONTAINER ) { +if (is_container (info.array.level)) {char devnm[32 ];/* Try to assemble within the container */ sysfs_uevent (sra,"change" );
mdadm.h +15 -0
@@ -1922,3 +1922,18 @@ enum r0layout {* This is true for native and DDF, IMSM allows 16. */ #define MD_NAME_MAX 32 + +/** +* is_container() - check if @level is &LEVEL_CONTAINER +* @level: level value +* +* return: +* 1 if level is equal to &LEVEL_CONTAINER, 0 otherwise. +*/ +static inline int is_container (const int level) +{ +if (level ==LEVEL_CONTAINER ) +return 1 ; +return 0 ; +} +
super-ddf.c +3 -3
@@ -3325,7 +3325,7 @@ validate_geometry_ddf_container(struct supertype *st,int fd;unsigned long long ldsize; -if (level !=LEVEL_CONTAINER ) +if (!is_container (level))return 0 ;if (!dev)return 1 ;
@@ -3371,7 +3371,7 @@ static int validate_geometry_ddf(struct supertype *st,if (level ==LEVEL_NONE ) level =LEVEL_CONTAINER ; -if (level ==LEVEL_CONTAINER ) { +if (is_container (level)) {/* Must be a fresh device to add to a container */ return validate_geometry_ddf_container(st, level, raiddisks, data_offset, dev,
@@ -3488,7 +3488,7 @@ static int validate_geometry_ddf_bvd(struct supertype *st,struct dl *dl;unsigned long long maxsize;/* ddf/bvd supports lots of things, but not containers */ -if (level ==LEVEL_CONTAINER ) { +if (is_container (level)) {if (verbose)pr_err ("DDF cannot create a container within an container\n" );return 0 ;
super-intel.c +2 -2
@@ -6727,7 +6727,7 @@ static int validate_geometry_imsm_container(struct supertype *st, int level,struct intel_super *super =NULL ;int rv =0 ; -if (level !=LEVEL_CONTAINER ) +if (!is_container (level))return 0 ;if (!dev)return 1 ;
@@ -7692,7 +7692,7 @@ static int validate_geometry_imsm(struct supertype *st, int level, int layout,* if given unused devices create a container * if given given devices in a container create a member volume */ -if (level ==LEVEL_CONTAINER ) +if (is_container (level))/* Must be a fresh device to add to a container */ return validate_geometry_imsm_container(st, level, raiddisks, data_offset, dev,
super0.c +1 -1
@@ -1273,7 +1273,7 @@ static int validate_geometry0(struct supertype *st, int level,if (get_linux_version () <3001000 ) tbmax =2 ; -if (level ==LEVEL_CONTAINER ) { +if (is_container (level)) {if (verbose)pr_err ("0.90 metadata does not support containers\n" );return 0 ;
super1.c +1 -1
@@ -2829,7 +2829,7 @@ static int validate_geometry1(struct supertype *st, int level,unsigned long long overhead;int fd; -if (level ==LEVEL_CONTAINER ) { +if (is_container (level)) {if (verbose)pr_err ("1.x metadata does not support containers\n" );return 0 ;
sysfs.c +1 -1
@@ -763,7 +763,7 @@ int sysfs_add_disk(struct mdinfo *sra, struct mdinfo *sd, int resume) rv =sysfs_set_num (sra, sd,"offset" , sd->data_offset); rv |=sysfs_set_num (sra, sd,"size" , (sd->component_size+1 ) /2 ); -if (sra->array.level !=LEVEL_CONTAINER ) { +if (!is_container (sra->array.level)) {if (sra->consistency_policy ==CONSISTENCY_POLICY_PPL ) { rv |=sysfs_set_num (sra, sd,"ppl_sector" , sd->ppl_sector); rv |=sysfs_set_num (sra, sd,"ppl_size" , sd->ppl_size);
Signature · 1 line
2.35.3
PATCH 19/23 mdadm: enable Intel Alderlake RSTe configuration
In reply to Coly LiFrom: Hannes Reinecke <[email protected]>
Alderlake has a slightly different RST configuration; the UEFI variable is name 'RstVmdV', and the AHCI controller shows up as a child device of the VMD bridge, but continues to use the 'AHCI HBA' PCI class (and not the RAID class as RSTe would normally do).
--- platform-intel.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
platform-intel.c +6 -2
@@ -512,12 +512,14 @@ static const struct imsm_orom *find_imsm_hba_orom(struct sys_dev *hba)#define AHCI_PROP "RstSataV"#define AHCI_SSATA_PROP "RstsSatV"#define AHCI_TSATA_PROP "RsttSatV" +#define AHCI_RST_PROP "RstVmdV"#define VMD_PROP "RstUefiV"#define VENDOR_GUID \ EFI_GUID(0x193dfefa, 0xa445, 0x4302, 0x99, 0xd8, 0xef, 0x3a, 0xad, 0x1a, 0x04, 0xc6)#define PCI_CLASS_RAID_CNTRL 0x010400 +#define PCI_CLASS_SATA_HBA 0x010601static int read_efi_var (void *buffer,ssize_t buf_size,const char *variable_name,struct efi_guid guid)
@@ -604,7 +606,8 @@ const struct imsm_orom *find_imsm_efi(struct sys_dev *hba)struct imsm_orom orom;struct orom_entry *ret;static const char *const sata_efivars[] = {AHCI_PROP ,AHCI_SSATA_PROP , -AHCI_TSATA_PROP }; +AHCI_TSATA_PROP , +AHCI_RST_PROP };unsigned long i;if (check_env ("IMSM_TEST_AHCI_EFI" ) ||check_env ("IMSM_TEST_SCU_EFI" ))
@@ -622,7 +625,8 @@ const struct imsm_orom *find_imsm_efi(struct sys_dev *hba)return NULL ;case SYS_DEV_SATA : -if (hba->class !=PCI_CLASS_RAID_CNTRL ) +if (hba->class !=PCI_CLASS_RAID_CNTRL && + hba->class !=PCI_CLASS_SATA_HBA )return NULL ;for (i =0 ; i <ARRAY_SIZE (sata_efivars); i++) {
Signature · 1 line
2.35.3
Re: [PATCH 19/23] mdadm: enable Intel Alderlake RSTe configuration
Quoted 45 lines · On Thu, 28 Jul 2022 20:20:57 +0800 Coly Li <[email protected]> wrote:
From: Hannes Reinecke <[email protected]>
Alderlake has a slightly different RST configuration; the UEFI variable is name 'RstVmdV', and the AHCI controller shows up as a child device of the VMD bridge, but continues to use the 'AHCI HBA' PCI class (and not the RAID class as RSTe would normally do).
Signed-off-by Hannes Reinecke <[email protected]>Acked-by Coly Li <[email protected]>--- platform-intel.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)platform-intel.c +2
-0@@ -512,12 +512,14 @@ static const struct imsm_orom *find_imsm_hba_orom(struct sys_dev *hba) #define AHCI_PROP "RstSataV"#define AHCI_SSATA_PROP "RstsSatV"#define AHCI_TSATA_PROP "RsttSatV" +#define AHCI_RST_PROP "RstVmdV"#define VMD_PROP "RstUefiV"#define VENDOR_GUID \ EFI_GUID(0x193dfefa, 0xa445, 0x4302, 0x99, 0xd8, 0xef, 0x3a, 0xad, 0x1a, 0x04, 0xc6)#define PCI_CLASS_RAID_CNTRL 0x010400 +#define PCI_CLASS_SATA_HBA 0x010601static int read_efi_var (void *buffer,ssize_t buf_size, const char *variable_name, struct efi_guidguid) @@ -604,7 +606,8 @@ const struct
imsm_orom*find_imsm_efi(structsys_dev*hba) structimsm_oromorom;platform-intel.c +0
-0struct orom_entry *ret;static const char *const sata_efivars[] = {AHCI_PROP ,
AHCI_SSATA_PROP,platform-intel.c +2
-1- AHCI_TSATA_PROP}; +AHCI_TSATA_PROP , + AHCI_RST_PROP};unsigned long i; if (check_env("IMSM_TEST_AHCI_EFI") ||
check_env("IMSM_TEST_SCU_EFI")) @@ -622,7 +625,8 @@ const structimsm_orom*find_imsm_efi(structsys_dev*hba)
platform-intel.c const struct imsm_orom *find_imsm_efi(struct sys_dev *hba) · line 632
Quoted 8 lines
platform-intel.c +2
-1return NULL ;case SYS_DEV_SATA : -if (hba->class !=PCI_CLASS_RAID_CNTRL ) +if (hba->class !=PCI_CLASS_RAID_CNTRL && + hba->class !=PCI_CLASS_SATA_HBA )return NULL ;for (i =0 ; i <ARRAY_SIZE (sata_efivars); i++) {
Hi,
This patch causes a regression. I've checked how SATA controllers will be visible in --detail-platform output for IMSM. If RAID mode will be turned on for one of the SATA controllers, rest of them will be also visible as supported ones.
Please analyze this scenario.
Regards,
Kinga Tanska
PATCH 20/23 tests: add test for names
In reply to Coly LiFrom: Mariusz Tkaczyk <[email protected]>
Current behavior is not documented and tested. This test is a base for future improvements. It is enough to test it only with native metadata, because it is generic code. Generated properties are passed to metadata handler.
--- tests/00createnames | 93 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 93 insertions(+) create mode 100644 tests/00createnames
tests/00createnames new file +93 -0
@@ -0,0 +1,93 @@ +set -x -e + +# Test how <devname> and --name= are handled for create mode. +# We need to check three properties, generated from those parameters: +# - devnode name +# - link in /dev/md/ (MD_DEVNAME property from --detail --export) +# - name in metadata (MD_NAME property from --examine --export) + +function _verify() { + local DEVNODE_NAME="$1" + local WANTED_LINK="$2" + local WANTED_NAME="$3" + + local RES="$(mdadm -D --export $DEVNODE_NAME | grep MD_DEVNAME)" + if [[ "$?" != "0" ]]; then + echo "Cannot get details for $DEVNODE_NAME - unexpected devnode." + exit 1 + fi + + if [[ "$WANTED_LINK" != "empty" ]]; then + local EXPECTED="MD_DEVNAME=$WANTED_LINK" + if [[ "$RES" != "$EXPECTED" ]]; then + echo "$RES doesn't match $EXPECTED." + exit 1 + fi + fi + + + local RES="$(mdadm -E --export $dev0 | grep MD_NAME)" + if [[ "$?" != "0" ]]; then + echo "Cannot get metadata from $dev0." + exit 1 + fi + + local EXPECTED="MD_NAME=$(hostname):$WANTED_NAME" + if [[ "$RES" != "$EXPECTED" ]]; then + echo "$RES doesn't match $EXPECTED." + exit 1 + fi +} + +function _create() { + local DEVNAME=$1 + local NAME=$2 + + if [[ -z "$NAME" ]]; then + mdadm -CR "$DEVNAME" -l0 -n 1 $dev0 --force + else + mdadm -CR "$DEVNAME" --name="$NAME" -l0 -n 1 $dev0 --force + fi + + if [[ "$?" != "0" ]]; then + echo "Cannot create device." + exit 1 + fi +} + +# The most trivial case. +_create "/dev/md/name" +_verify "/dev/md127" "name" "name" +mdadm -S "/dev/md127" + +_create "name" +_verify "/dev/md127" "name" "name" +mdadm -S "/dev/md127" + +# Use 'mdX' as name. +_create "/dev/md/md0" +_verify "/dev/md127" "md0" "md0" +mdadm -S "/dev/md127" + +_create "md0" +_verify "/dev/md127" "md0" "md0" +mdadm -S "/dev/md127" + +# <devnode> is used to create MD_DEVNAME but, name is used to create MD_NAME. +_create "/dev/md/devnode" "name" +_verify "/dev/md127" "devnode" "name" +mdadm -S "/dev/md127" + +_create "devnode" "name" +_verify "/dev/md127" "devnode" "name" +mdadm -S "/dev/md127" + +# Devnode points to /dev/ directory. MD_DEVNAME doesn't exist. +_create "/dev/md0" +_verify "/dev/md0" "empty" "0" +mdadm -S "/dev/md0" + +# Devnode points to /dev/ directory and name is set. +_create "/dev/md0" "name" +_verify "/dev/md0" "empty" "name" +mdadm -S "/dev/md0"
Signature · 1 line
2.35.3
PATCH 21/23 mdadm: remove symlink option
In reply to Coly LiFrom: Mariusz Tkaczyk <[email protected]>
The option is not used. Remove it from code.
--- ReadMe.c | 1 - config.c | 7 +------ mdadm.8.in | 9 --------- mdadm.c | 20 -------------------- mdadm.conf.5.in | 15 --------------- mdadm.h | 2 -- 6 files changed, 1 insertion(+), 53 deletions(-)
ReadMe.c +0 -1
@@ -147,7 +147,6 @@ struct option long_options[] = { {"nofailfast",0, 0, NoFailFast}, {"re-add", 0, 0, ReAdd}, {"homehost", 1, 0, HomeHost}, - {"symlinks", 1, 0, Symlinks}, {"data-offset",1, 0, DataOffset}, {"nodes",1, 0, Nodes}, /* also for --assemble */ {"home-cluster",1, 0, ClusterName},
config.c +1 -6
@@ -194,7 +194,6 @@ struct mddev_dev *load_containers(void)struct createinfo createinfo = { .autof =2 ,/* by default, create devices with standard names */ - .symlinks =1 , .names =0 ,/* By default, stick with numbered md devices. */ .bblist =1 ,/* Use a bad block list by default */ #ifdef DEBIAN
@@ -310,11 +309,7 @@ static void createline(char *line)if (!createinfo.supertype)pr_err ("metadata format %s unknown, ignoring\n" , w+9 ); - }else if (strncasecmp (w,"symlinks=yes" ,12 ) ==0 ) - createinfo.symlinks =1 ; -else if (strncasecmp (w,"symlinks=no" ,11 ) ==0 ) - createinfo.symlinks =0 ; -else if (strncasecmp (w,"names=yes" ,12 ) ==0 ) + }else if (strncasecmp (w,"names=yes" ,12 ) ==0 ) createinfo.names =1 ;else if (strncasecmp (w,"names=no" ,11 ) ==0 ) createinfo.names =0 ;
mdadm.8.in +0 -9
@@ -1048,11 +1048,6 @@ simultaneously. If not specified, this defaults to 4. Specify journal device for the RAID-4/5/6 array. The journal device should be a SSD with reasonable lifetime. -.TP -.BR \-\-symlinks -Auto creation of symlinks in /dev to /dev/md, option --symlinks must -be 'no' or 'yes' and work with --create and --build. - .TP .BR \-k ", " \-\-consistency\-policy= Specify how the array maintains consistency in case of unexpected shutdown.
@@ -1405,10 +1400,6 @@ Reshape can be continued later using the .B \-\-continue option for the grow command. -.TP -.BR \-\-symlinks -See this option under Create and Build options. - .SH For Manage mode: .TP
mdadm.c +0 -20
@@ -59,7 +59,6 @@ int main(int argc, char *argv[])struct mddev_dev *dv;mdu_array_info_t array;int devs_found =0 ; -char *symlinks =NULL ;int grow_continue =0 ;/* autof indicates whether and how to create device node. * bottom 3 bits are style. Rest (when shifted) are number of parts
@@ -663,13 +662,6 @@ int main(int argc, char *argv[])case O (ASSEMBLE ,Auto):/* auto-creation of device node */ c.autof =parse_auto (optarg,"--auto flag" ,0 );continue ; - -case O (CREATE ,Symlinks): -case O (BUILD ,Symlinks): -case O (ASSEMBLE ,Symlinks):/* auto creation of symlinks in /dev to /dev/md */ - symlinks = optarg; -continue ; -case O (BUILD ,'f' ):/* force honouring '-n 1' */ case O (BUILD ,Force):/* force honouring '-n 1' */ case O (GROW ,'f' ):/* ditto */
@@ -1325,18 +1317,6 @@ int main(int argc, char *argv[])exit (2 ); } -if (symlinks) { -struct createinfo *ci =conf_get_create_info (); - -if (strcasecmp (symlinks,"yes" ) ==0 ) - ci->symlinks =1 ; -else if (strcasecmp (symlinks,"no" ) ==0 ) - ci->symlinks =0 ; -else { -pr_err ("option --symlinks must be 'no' or 'yes'\n" ); -exit (2 ); - } - }/* Ok, got the option parsing out of the way * hopefully it's mostly right but there might be some stuff * missing
mdadm.conf.5.in +0 -15
@@ -338,21 +338,6 @@ missing device entries should be created. The name of the metadata format to use if none is explicitly given. This can be useful to impose a system-wide default of version-1 superblocks. -.TP -.B symlinks=no -Normally when creating devices in -.B /dev/md/ -.I mdadm -will create a matching symlink from -.B /dev/ -with a name starting -.B md -or -.BR md_ . -Give -.B symlinks=no -to suppress this symlink creation. - .TP .B names=yes Since Linux 2.6.29 it has been possible to create
mdadm.h +0 -2
@@ -394,7 +394,6 @@ struct createinfo {int gid;int autof;int mode; -int symlinks;int names;int bblist;struct supertype *supertype;
@@ -442,7 +441,6 @@ enum special_options { BackupFile, HomeHost, AutoHomeHost, - Symlinks, AutoDetect, Waitclean, DetailPlatform,
Signature · 1 line
2.35.3
PATCH 22/23 mdadm: move data_offset to struct shape
In reply to Coly LiFrom: Mariusz Tkaczyk <[email protected]>
Data offset is a shape property so move it there to remove additional parameter from some functions.
--- Create.c | 16 ++++++++-------- Grow.c | 7 +++---- mdadm.c | 20 +++++++++----------- mdadm.h | 5 ++--- 4 files changed, 22 insertions(+), 26 deletions(-)
Create.c +8 -8
@@ -95,7 +95,7 @@ int Create(struct supertype *st, char *mddev, char *name, int *uuid, int subdevs, struct mddev_dev *devlist, struct shape *s, - struct context *c, unsigned long long data_offset) + struct context *c) {/* * Create a new raid array.
@@ -288,7 +288,7 @@ int Create(struct supertype *st, char *mddev, newsize = s->size *2 ;if (st && ! st->ss->validate_geometry (st, s->level, s->layout, s->raiddisks, &s->chunk, s->size*2 , - data_offset,NULL , + s->data_offset,NULL , &newsize, s->consistency_policy, c->verbose >=0 ))return 1 ;
@@ -323,10 +323,10 @@ int Create(struct supertype *st, char *mddev, info.array.working_disks =0 ; dnum =0 ;for (dv = devlist; dv; dv = dv->next) -if (data_offset ==VARIABLE_OFFSET ) +if (s->data_offset ==VARIABLE_OFFSET ) dv->data_offset =INVALID_SECTORS ;else - dv->data_offset = data_offset; + dv->data_offset = s->data_offset;for (dv=devlist; dv && !have_container; dv=dv->next, dnum++) {char *dname = dv->devname;
@@ -342,7 +342,7 @@ int Create(struct supertype *st, char *mddev, missing_disks ++;continue ; } -if (data_offset ==VARIABLE_OFFSET ) { +if (s->data_offset ==VARIABLE_OFFSET ) { doff =strchr (dname,':' );if (doff) { *doff++ =0 ;
@@ -350,7 +350,7 @@ int Create(struct supertype *st, char *mddev, }else dv->data_offset =INVALID_SECTORS ; }else - dv->data_offset = data_offset; + dv->data_offset = s->data_offset; dfd =open (dname,O_RDONLY );if (dfd <0 ) {
@@ -535,7 +535,7 @@ int Create(struct supertype *st, char *mddev,if (!st->ss->validate_geometry (st, s->level, s->layout, s->raiddisks, &s->chunk, minsize*2 , - data_offset, + s->data_offset,NULL ,NULL , s->consistency_policy,0 )) {pr_err ("devices too large for RAID level %d\n" , s->level);
@@ -754,7 +754,7 @@ int Create(struct supertype *st, char *mddev, } }if (!st->ss->init_super (st, &info.array, s, name, c->homehost, uuid, - data_offset)) + s->data_offset)) goto abort_locked; total_slots = info.array.nr_disks;
Grow.c +3 -4
@@ -1834,7 +1834,6 @@ error:int Grow_reshape (char *devname,int fd,struct mddev_dev *devlist, -unsigned long long data_offset,struct context *c,struct shape *s) {/* Make some changes in the shape of an array.
@@ -1880,7 +1879,7 @@ int Grow_reshape(char *devname, int fd,return 1 ; } -if (data_offset !=INVALID_SECTORS && array.level !=10 && +if (s->data_offset !=INVALID_SECTORS && array.level !=10 && (array.level <4 || array.level >6 )) {pr_err ("--grow --data-offset not yet supported\n" );return 1 ;
@@ -2186,7 +2185,7 @@ size_change_error:if ((s->level == UnSet || s->level == array.level) && (s->layout_str ==NULL ) && (s->chunk ==0 || s->chunk == array.chunk_size) && - data_offset ==INVALID_SECTORS && + s->data_offset ==INVALID_SECTORS && (s->raiddisks ==0 || s->raiddisks == array.raid_disks)) {/* Nothing more to do */ if (!changed && c->verbose >=0 )
@@ -2386,7 +2385,7 @@ size_change_error: }sync_metadata (st); rv =reshape_array (container, fd, devname, st, &info, c->force, - devlist, data_offset, c->backup_file, + devlist, s->data_offset, c->backup_file, c->verbose,0 ,0 ,0 ); frozen =0 ; }
mdadm.c +9 -11
@@ -49,7 +49,6 @@ int main(int argc, char *argv[])int i;unsigned long long array_size =0 ; -unsigned long long data_offset =INVALID_SECTORS ;struct mddev_ident ident;char *configfile =NULL ;int devmode =0 ;
@@ -79,6 +78,7 @@ int main(int argc, char *argv[]) .layout = UnSet, .bitmap_chunk = UnSet, .consistency_policy = CONSISTENCY_POLICY_UNKNOWN, + .data_offset = INVALID_SECTORS, };char sys_hostname[256 ];
@@ -479,15 +479,15 @@ int main(int argc, char *argv[])case O (CREATE ,DataOffset):case O (GROW ,DataOffset): -if (data_offset !=INVALID_SECTORS ) { +if (s.data_offset !=INVALID_SECTORS ) {pr_err ("data-offset may only be specified one. Second value is %s.\n" , optarg);exit (2 ); }if (mode ==CREATE &&strcmp (optarg,"variable" ) ==0 ) - data_offset =VARIABLE_OFFSET ; + s.data_offset =VARIABLE_OFFSET ;else - data_offset =parse_size (optarg); -if (data_offset ==INVALID_SECTORS ) { + s.data_offset =parse_size (optarg); +if (s.data_offset ==INVALID_SECTORS ) {pr_err ("invalid data-offset: %s\n" , optarg);exit (2 );
@@ -1416,7 +1416,7 @@ int main(int argc, char *argv[])exit (1 ); } -if (c.backup_file && data_offset !=INVALID_SECTORS ) { +if (c.backup_file && s.data_offset !=INVALID_SECTORS ) {pr_err ("--backup-file and --data-offset are incompatible\n" );exit (2 ); }
@@ -1587,8 +1587,7 @@ int main(int argc, char *argv[]) rv =Create (ss, devlist->devname, ident.name, ident.uuid_set ? ident.uuid :NULL , - devs_found-1 , devlist->next, - &s, &c, data_offset); + devs_found -1 , devlist->next, &s, &c);break ;case MISC :if (devmode =='E' ) {
@@ -1706,10 +1705,9 @@ int main(int argc, char *argv[]) c.verbose); else if (s.size > 0 || s.raiddisks || s.layout_str || s.chunk != 0 || s.level != UnSet || - data_offset != INVALID_SECTORS) { + s.data_offset != INVALID_SECTORS) { rv =Grow_reshape (devlist->devname, mdfd, - devlist->next, - data_offset, &c, &s); + devlist->next, &c, &s); } else if (s.consistency_policy != CONSISTENCY_POLICY_UNKNOWN) { rv =Grow_consistency_policy (devlist->devname, mdfd, &c, &s); } else if (array_size == 0)
mdadm.h +2 -3
@@ -595,6 +595,7 @@ struct shape {int assume_clean;int write_behind;unsigned long long size; +unsigned long long data_offset;int consistency_policy; };
@@ -1431,7 +1432,6 @@ extern int Grow_addbitmap(char *devname, int fd, struct context *c, struct shape *s);extern int Grow_reshape (char *devname,int fd,struct mddev_dev *devlist, -unsigned long long data_offset,struct context *c,struct shape *s);extern int Grow_restart (struct supertype *st,struct mdinfo *info,int *fdlist,int cnt,char *backup_file,int verbose);
@@ -1462,8 +1462,7 @@ extern int Create(struct supertype *st, char *mddev, char *name, int *uuid, int subdevs, struct mddev_dev *devlist, struct shape *s, - struct context *c, - unsigned long long data_offset); + struct context *c);extern int Detail (char *dev,struct context *c);extern int Detail_Platform (struct superswitch *ss,int scan,int verbose,int export,char *controller_path);
Signature · 1 line
2.35.3
PATCH 23/23 tests/00readonly: Run udevadm settle before setting ro
In reply to Coly LiFrom: Logan Gunthorpe <[email protected]>
In some recent kernel versions, 00readonly fails with:
mdadm: failed to set readonly for /dev/md0: Device or resource busy
ERROR: array is not read-only!
This was traced down to a race condition with udev holding a reference to the block device at the same time as trying to set it read only.
To fix this, call udevadm settle before setting the array read only.
--- tests/00readonly | 1 + 1 file changed, 1 insertion(+)
tests/00readonly +1 -0
@@ -12,6 +12,7 @@ do $dev1 $dev2 $dev3 $dev4 --assume-clean check nosync check $level + udevadm settle mdadm -ro $md0 check readonly state=$(cat /sys/block/md0/md/array_state)
Signature · 1 line
2.35.3