]> www.infradead.org Git - users/hch/blktests.git/commitdiff
loop: Add test for changing capacity when filesystem is mounted
authorJan Kara <jack@suse.cz>
Mon, 21 Jan 2019 12:02:03 +0000 (13:02 +0100)
committerOmar Sandoval <osandov@fb.com>
Wed, 23 Jan 2019 00:00:27 +0000 (16:00 -0800)
Add test for changing capacity of a loop device when a filesystem with
non-default block size is mounted on it. This is a regression test for
"blockdev: Fix livelocks on loop device".

Signed-off-by: Jan Kara <jack@suse.cz>
Reviewed-by: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>
[Omar: mount under $TMPDIR]
Signed-off-by: Omar Sandoval <osandov@fb.com>
tests/loop/007 [new file with mode: 0755]
tests/loop/007.out [new file with mode: 0644]

diff --git a/tests/loop/007 b/tests/loop/007
new file mode 100755 (executable)
index 0000000..861b6b3
--- /dev/null
@@ -0,0 +1,39 @@
+#!/bin/bash
+# SPDX-License-Identifier: GPL-3.0+
+# Copyright (C) 2019 Jan Kara
+#
+# Test loop device capacity change handling with filesystem mounted on top.
+#
+# Regression test for commit 04906b2f542c "blockdev: Fix livelocks on loop
+# device".
+#
+
+. tests/loop/rc
+
+DESCRIPTION="update loop device capacity with filesystem"
+QUICK=1
+
+requires() {
+       _have_program mkfs.ext4
+}
+
+test() {
+       echo "Running ${TEST_NAME}"
+
+       local mount_dir="$TMPDIR/mnt"
+
+       truncate -s 1G "$TMPDIR/img"
+       mkdir -p "$mount_dir"
+       local loop_device
+       loop_device="$(losetup -P -f --show "$TMPDIR/img")"
+       mkfs.ext4 -b 1024 "$loop_device" &>/dev/null
+       mount -t ext4 "$loop_device" "$mount_dir"
+       losetup -c "$loop_device"
+       # This hangs if rereading capacity changed block size
+       ls -l "$mount_dir" >/dev/null
+       umount "$mount_dir"
+       losetup -d "$loop_device"
+       rm -fr "$mount_dir" "$TMPDIR/img"
+
+       echo "Test complete"
+}
diff --git a/tests/loop/007.out b/tests/loop/007.out
new file mode 100644 (file)
index 0000000..3275293
--- /dev/null
@@ -0,0 +1,2 @@
+Running loop/007
+Test complete