blktests: New loop tests
cover blktests: New loop tests
Hello,
these two patches create two new tests for blktests as regression tests for my recently posted loopback device fixes. More details in individual patches.
Honza
PATCH 1/2 loop/006: Add test for setting partscan flag
Add test for setting partscan flag.
--- src/Makefile | 3 ++- src/loop_set_status_partscan.c | 45 ++++++++++++++++++++++++++++++++++++++++++ tests/loop/006 | 33 +++++++++++++++++++++++++++++++ tests/loop/006.out | 2 ++ 4 files changed, 82 insertions(+), 1 deletion(-) create mode 100644 src/loop_set_status_partscan.c create mode 100755 tests/loop/006 create mode 100644 tests/loop/006.out
src/Makefile +2 -1
@@ -4,7 +4,8 @@ C_TARGETS := \ openclose \ sg/dxfer-from-dev \ sg/syzkaller1 \ - nbdsetsize + nbdsetsize \ + loop_set_status_partscan CXX_TARGETS := \ discontiguous-io
src/loop_set_status_partscan.c new file +45 -0
45 lines not on this page · raw message
tests/loop/006 new file +33 -0
@@ -0,0 +1,33 @@ +#!/bin/bash +# SPDX-License-Identifier: GPL-3.0+ +# Copyright (C) 2018 Jan Kara +# +# Regression test for patch "loop: Fix deadlock when calling +# blkdev_reread_part()". We check whether setting partscan flag +# and thus forcing partition reread won't trigger lockdep warning. +# + +. tests/loop/rc + +DESCRIPTION="check for partition rereading deadlock" + +QUICK=1 + +requires() { + _have_src_program loop_set_status_partscan +} + +test() { + local loop_dev + echo "Running ${TEST_NAME}" + + truncate -s 1M "$TMPDIR/file" + if ! loop_dev="$(losetup -f --show "$TMPDIR/file")"; then + return 1 + fi + + src/loop_set_status_partscan "$loop_dev" + losetup -d "$loop_dev" + + echo "Test complete" +}
tests/loop/006.out new file +2 -0
@@ -0,0 +1,2 @@ +Running loop/006 +Test complete
Signature · 1 line
2.16.4
Re: [PATCH 1/2] loop/006: Add test for setting partscan flag
Looks good,
Signature · 6 lines
Johannes Thumshirn SUSE Labs [email protected] +49 911 74053 689 SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg GF: Felix Imendörffer, Jane Smithard, Graham Norton HRB 21284 (AG Nürnberg) Key fingerprint = EC38 9CAB C2C4 F25D 8600 D0D0 0393 969D 2D76 0850
Re: [PATCH 1/2] loop/006: Add test for setting partscan flag
In reply to Jan KaraQuoted 3 lines · Jan Kara
Add test for setting partscan flag.
Signed-off-by Jan Kara <[email protected]>
Sorry I didn't notice this earlier, but loop/001 already does a partition rescan (via losetup -P). Does that cover this test case?
Quoted 55 lines
--- src/Makefile | 3 ++- src/loop_set_status_partscan.c | 45 ++++++++++++++++++++++++++++++++++++++++++ tests/loop/006 | 33 +++++++++++++++++++++++++++++++ tests/loop/006.out | 2 ++ 4 files changed, 82 insertions(+), 1 deletion(-) create mode 100644 src/loop_set_status_partscan.c create mode 100755 tests/loop/006 create mode 100644 tests/loop/006.outsrc/Makefile +2
-1@@ -4,7 +4,8 @@ C_TARGETS := \ openclose \ sg/dxfer-from-dev \ sg/syzkaller1 \ - nbdsetsize + nbdsetsize \ + loop_set_status_partscan CXX_TARGETS := \ discontiguous-iosrc/loop_set_status_partscan.c new file +25
-0@@ -0,0 +1,45 @@ +#include <errno.h> +#include <fcntl.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <unistd.h> +#include <sys/ioctl.h> +#include <sys/stat.h> +#include <sys/types.h> +#include <linux/loop.h> + +void usage (const char *progname) +{ +fprintf (stderr,"usage: %s PATH\n" , progname); +exit (EXIT_FAILURE ); +} + +int main (int argc,char **argv) +{ +int ret; +int fd; +struct loop_info64 info; + +if (argc !=2 ) +usage (argv[0 ]);
src/loop_set_status_partscan.c line 35
Quoted 10 lines
src/loop_set_status_partscan.c new file +10
-0+ + fd =open (argv[1 ],O_RDONLY ); +if (fd ==-1 ) { +perror ("open" ); +return EXIT_FAILURE ; + } + +memset (&info,0 ,sizeof (info)); + info.lo_flags =LO_FLAGS_PARTSCAN ; +memcpy (info.lo_file_name,"part" ,5 );
What's the significance of this file name?
Quoted 9 lines
src/loop_set_status_partscan.c new file +9
-0+ ret =ioctl (fd,LOOP_SET_STATUS64 , &info); +if (ret ==-1 ) { +perror ("ioctl" ); +close (fd); +return EXIT_FAILURE ; + } +close (fd); +return EXIT_SUCCESS ; +}
[snip]
Re: [PATCH 1/2] loop/006: Add test for setting partscan flag
Quoted 7 lines · Omar Sandoval
Quoted 3 lines · Jan Kara
Add test for setting partscan flag.
Signed-off-by Jan Kara <[email protected]>Sorry I didn't notice this earlier, but loop/001 already does a partition rescan (via losetup -P). Does that cover this test case?
Yes I know. But the partition rescanning on device creation has been handled properly while partition rescanning as a result of LOOP_SET_STATUS was buggy. That's why I've added this test.
Quoted 12 lines
Quoted 12 lines
src/loop_set_status_partscan.c new file +12
-0+int main (int argc,char **argv) +{ +int ret; +int fd; +struct loop_info64 info; + +if (argc !=2 ) +usage (argv[0 ]); + + fd =open (argv[1 ],O_RDONLY ); +if (fd ==-1 ) { +perror ("open" );
Quoted 8 lines
src/loop_set_status_partscan.c line 35
Quoted 6 lines
src/loop_set_status_partscan.c new file +6
-0+return EXIT_FAILURE ; + } + +memset (&info,0 ,sizeof (info)); + info.lo_flags =LO_FLAGS_PARTSCAN ; +memcpy (info.lo_file_name,"part" ,5 );What's the significance of this file name?
Probably none, I guess I can just delete it. I think I've just copy-pasted it from some other test excercising LOOP_SET_STATUS...
Honza
Signature · 2 lines
Jan Kara <[email protected]> SUSE Labs, CR
Re: [PATCH 1/2] loop/006: Add test for setting partscan flag
Quoted 4 lines · Jan Kara
Quoted 3 lines · Omar Sandoval
Quoted 2 lines · Jan Kara
Add test for setting partscan flag.
Quoted 8 lines
Quoted 4 lines
Quoted 1 line
Signed-off-by Jan Kara <[email protected]>Sorry I didn't notice this earlier, but loop/001 already does a partition rescan (via losetup -P). Does that cover this test case?
Yes I know. But the partition rescanning on device creation has been handled properly while partition rescanning as a result of
LOOP_SET_STATUSwas buggy. That's why I've added this test.
At least here, losetup -P does a LOOP_SET_STATUS:
$ sudo strace -e ioctl losetup -f --show -P test.img
ioctl(3, LOOP_CTL_GET_FREE) = 0
ioctl(4, LOOP_SET_FD, 3) = 0
ioctl(4, LOOP_SET_STATUS64, {lo_offset=0, lo_number=0, lo_flags=LO_FLAGS_PARTSCAN, lo_file_name="/home/osandov/test.img", ...}) = 0
/dev/loop0
+++ exited with 0 +++Re: [PATCH 1/2] loop/006: Add test for setting partscan flag
Quoted 14 lines · Omar Sandoval
Quoted 4 lines · Jan Kara
Quoted 3 lines · Omar Sandoval
Quoted 2 lines · Jan Kara
Add test for setting partscan flag.
Quoted 8 lines
Quoted 4 lines
Quoted 1 line
Signed-off-by Jan Kara <[email protected]>Sorry I didn't notice this earlier, but loop/001 already does a partition rescan (via losetup -P). Does that cover this test case?
Yes I know. But the partition rescanning on device creation has been handled properly while partition rescanning as a result of
LOOP_SET_STATUSwas buggy. That's why I've added this test.
Quoted 8 lines
At least here, losetup -P does a
LOOP_SET_STATUS:$ sudo strace -e ioctl losetup -f --show -P test.img ioctl(3, LOOP_CTL_GET_FREE) = 0 ioctl(4, LOOP_SET_FD, 3) = 0 ioctl(4, LOOP_SET_STATUS64, {lo_offset=0, lo_number=0, lo_flags=LO_FLAGS_PARTSCAN, lo_file_name="/home/osandov/test.img", ...}) = 0 /dev/loop0 +++ exited with 0 +++
Right, my bad. Just discard this test then. Thanks for noticing this!
Honza
Signature · 2 lines
Jan Kara <[email protected]> SUSE Labs, CR
PATCH 2/2 loop/007: Add test for oops during backing file verification
In reply to Jan KaraAdd regression test for patch "block/loop: Use global lock for ioctl() operation." where we can oops while traversing list of loop devices backing newly created device.
--- src/Makefile | 3 ++- src/loop_change_fd.c | 48 +++++++++++++++++++++++++++++++++ tests/loop/007 | 75 ++++++++++++++++++++++++++++++++++++++++++++++++++++ tests/loop/007.out | 2 ++ 4 files changed, 127 insertions(+), 1 deletion(-) create mode 100644 src/loop_change_fd.c create mode 100755 tests/loop/007 create mode 100644 tests/loop/007.out
src/Makefile +2 -1
@@ -5,7 +5,8 @@ C_TARGETS := \ sg/dxfer-from-dev \ sg/syzkaller1 \ nbdsetsize \ - loop_set_status_partscan + loop_set_status_partscan \ + loop_change_fd CXX_TARGETS := \ discontiguous-io
src/loop_change_fd.c new file +48 -0
48 lines not on this page · raw message
tests/loop/007 new file +75 -0
75 lines not on this page · raw message
tests/loop/007.out new file +2 -0
@@ -0,0 +1,2 @@ +Running loop/007 +Test complete
Signature · 1 line
2.16.4
Re: [PATCH 2/2] loop/007: Add test for oops during backing file verification
Looks good,
Signature · 6 lines
Johannes Thumshirn SUSE Labs [email protected] +49 911 74053 689 SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg GF: Felix Imendörffer, Jane Smithard, Graham Norton HRB 21284 (AG Nürnberg) Key fingerprint = EC38 9CAB C2C4 F25D 8600 D0D0 0393 969D 2D76 0850
Re: [PATCH 2/2] loop/007: Add test for oops during backing file verification
In reply to Jan KaraQuoted 5 lines · Jan Kara
Add regression test for patch "block/loop: Use global lock for
ioctl()operation." where we can oops while traversing list of loop devices backing newly created device.Signed-off-by Jan Kara <[email protected]>
Looks good, sans a missing addition to src/.gitignore. I can fix that and apply this once I hear back regarding the other test.
Quoted 6 lines · Jan Kara
Hello,
these two patches create two new tests for blktests as regression tests for my recently posted loopback device fixes. More details in individual patches.
Thanks, Jan, I applied 007 renamed to 006.