[LTP] [PATCH v5 2/3] ioctl_loop01.c: Add new support .needs_cmds
Petr Vorel
pvorel@suse.cz
Tue Nov 11 12:14:37 CET 2025
Hi Wei,
Reviewed-by: Petr Vorel <pvorel@suse.cz>
> +++ b/testcases/kernel/syscalls/ioctl/ioctl_loop01.c
> @@ -78,23 +78,6 @@ static void check_loop_value(int set_flag, int get_flag, int autoclear_field)
> static void verify_ioctl_loop(void)
> {
> - int ret;
> - const char *const cmd_parted[] = {"parted", "-s", dev_path, "mklabel", "msdos", "mkpart",
> - "primary", "ext4", "1M", "10M", NULL};
> -
> - tst_fill_file("test.img", 0, 1024 * 1024, 10);
> - tst_attach_device(dev_path, "test.img");
> -
> - ret = tst_cmd(cmd_parted, NULL, NULL, TST_CMD_PASS_RETVAL);
> - if (!ret)
> - parted_sup = 1;
> - else if (ret == 255)
> - tst_res(TCONF, "parted binary not installed or failed");
> - else
> - tst_res(TCONF, "parted exited with %i", ret);
> -
> - attach_flag = 1;
> -
> TST_ASSERT_INT(partscan_path, 0);
> TST_ASSERT_INT(autoclear_path, 0);
> TST_ASSERT_STR(backing_path, backing_file_path);
> @@ -113,10 +96,23 @@ static void verify_ioctl_loop(void)
> static void setup(void)
> {
> + parted_sup = tst_cmd_present("parted");
> +
> + const char *const cmd_parted[] = {"parted", "-s", dev_path, "mklabel", "msdos", "mkpart",
> + "primary", "ext4", "1M", "10M", NULL};
FYI unfortunately I'm still able to trigger loop failure on SLES 5.14 based kernel
when looping ioctl_loop01 and ioctl_ficlone02 for a while on both current master
and with this patch (which does not handle the problem).
dmesg:
[ 1101.501003] ioctl_loop01
[ 1101.519346] loop0: detected capacity change from 0 to 20480
[ 1101.664879] loop_reread_partitions: partition scan of loop0 () failed (rc=-16)
[ 1101.705931] blk_update_request: I/O error, dev loop0, sector 20352 op 0x0:(READ) flags 0x80700 phys_seg 1 prio class 0
[ 1101.710398] blk_update_request: I/O error, dev loop0, sector 20352 op 0x0:(READ) flags 0x0 phys_seg 1 prio class 0
[ 1101.710423] __loop_clr_fd: partition scan of loop0 failed (rc=-16)
[ 1101.713612] Buffer I/O error on dev loop0p1, logical block 2288, async page read
[ 1101.774843] blk_update_request: I/O error, dev loop0, sector 20352 op 0x0:(READ) flags 0x80700 phys_seg 1 prio class 0
[ 1101.783014] blk_update_request: I/O error, dev loop0, sector 20352 op 0x0:(READ) flags 0x0 phys_seg 1 prio class 0
[ 1101.787585] Buffer I/O error on dev loop0p1, logical block 2288, async page read
[ 1101.824974] ioctl_ficlone02
[ 1101.827315] loop0: detected capacity change from 0 to 614400
[ 1101.861851] /dev/zero: Can't open blockdev
[ 1101.968916] EXT4-fs (loop0): mounting ext2 file system using the ext4 subsystem
[ 1101.975954] EXT4-fs (loop0): mounted filesystem without journal. Opts: (null). Quota mode: none.
[ 1102.156957] EXT4-fs (loop0): mounting ext3 file system using the ext4 subsystem
[ 1102.163452] EXT4-fs (loop0): mounted filesystem with ordered data mode. Opts: (null). Quota mode: none.
[ 1102.268502] EXT4-fs (loop0): mounted filesystem with ordered data mode. Opts: (null). Quota mode: none.
Fortunately Martin is working on a patch for LTP library that'll check for
leftover partitions after loop device release and clear them, with appropriate
TWARN message.
Kind regards,
Petr
> +
> dev_num = tst_find_free_loopdev(dev_path, sizeof(dev_path));
> if (dev_num < 0)
> tst_brk(TBROK, "Failed to find free loop device");
> + tst_fill_file("test.img", 0, 1024 * 1024, 10);
> +
> + tst_attach_device(dev_path, "test.img");
> + attach_flag = 1;
> +
> + if (parted_sup)
> + SAFE_CMD(cmd_parted, NULL, NULL);
> +
> sprintf(partscan_path, "/sys/block/loop%d/loop/partscan", dev_num);
> sprintf(autoclear_path, "/sys/block/loop%d/loop/autoclear", dev_num);
> sprintf(backing_path, "/sys/block/loop%d/loop/backing_file", dev_num);
> @@ -148,5 +144,9 @@ static struct tst_test test = {
> {"linux-git", "6ac92fb5cdff"},
> {}
> },
> + .needs_cmds = (struct tst_cmd[]) {
> + {.cmd = "parted", .optional = 1},
> + {}
> + },
More information about the ltp
mailing list