]> git.apps.os.sepia.ceph.com Git - xfstests-dev.git/commit
common/rc: destroy loop dev before fallback recreation
authorBrian Foster <bfoster@redhat.com>
Fri, 26 Sep 2025 12:12:49 +0000 (08:12 -0400)
committerZorro Lang <zlang@kernel.org>
Sun, 28 Sep 2025 13:48:11 +0000 (21:48 +0800)
commit986a4cc1f5a716e435b8aaf241e63e76bdb96340
tree6ac701c6d02b6d82981094cae19c367067914276
parentc3b7b05756d6e2860f8937d077db8d134843d126
common/rc: destroy loop dev before fallback recreation

When running fstests on an s390x box I observed failure to unmount
filesystem errors due to stale loop devices being left around. This
root caused down to generic/361 leaving around an attached loop0
device. On further inspection, the test actually created two loop
devices (loop0 and loop1), and executed on and cleaned up the
latter.

The origin of the former appears to be that the initial losetup
command in _create_loop_device() fails due to $dio_args in this
environment, but still creates the loop device. For example:

 # losetup --direct-io=on -f --show /mnt/scratch/fs.img
 /dev/loop0
 losetup: /dev/loop0: set direct io failed: Invalid argument
 # losetup -a
 /dev/loop0: [64771]:131 (/mnt/scratch/fs.img)

The helper then goes on to create loop1, but it or the test never
deals with loop0. To avoid this problem, detach any old loop device
if one was set up before the fallback losetup command.

Signed-off-by: Brian Foster <bfoster@redhat.com>
Reviewed-by: "Darrick J. Wong" <djwong@kernel.org>
Reviewed-by: Zorro Lang <zlang@redhat.com>
Signed-off-by: Zorro Lang <zlang@kernel.org>
common/rc