diff options
author | Alexander Bluhm <bluhm@cvs.openbsd.org> | 2018-01-15 23:58:44 +0000 |
---|---|---|
committer | Alexander Bluhm <bluhm@cvs.openbsd.org> | 2018-01-15 23:58:44 +0000 |
commit | fb105dff466b63b1b9e1cb5b4aaeacfe4ed6b179 (patch) | |
tree | 69cfa8a36c8e9db1fb9ebb4b20ad153f891466ea | |
parent | 0e71be3db35e3c2c4031ec255b0e84ff41e72d51 (diff) |
Add tests that unmount a file system while it is busy. On a vnd
device "cp -r" and "rm -rf" are working in the background while
"umount -f" or "mount -ur" are executed. Then "fsck -f" is used
to verify that the file system is clean.
Currently this triggers a bug quite reliably. After the mount point
has been changed to read-only, the file system check shows that not
everything was flushed and synced properly.
-rw-r--r-- | regress/sys/kern/mount/Makefile | 76 | ||||
-rw-r--r-- | regress/sys/kern/mount/disktemplate | 2 |
2 files changed, 61 insertions, 17 deletions
diff --git a/regress/sys/kern/mount/Makefile b/regress/sys/kern/mount/Makefile index eb877ef1574..bb5cf66f39c 100644 --- a/regress/sys/kern/mount/Makefile +++ b/regress/sys/kern/mount/Makefile @@ -1,19 +1,14 @@ -# $OpenBSD: Makefile,v 1.4 2017/04/12 14:46:31 bluhm Exp $ +# $OpenBSD: Makefile,v 1.5 2018/01/15 23:58:43 bluhm Exp $ -# This regress test uses a disk template to create 15 partitions on -# a vnd device. All are initialized with a ffs file system. Then -# they are mounted nestedly in /mnt, see disktemplate for the tree -# layout. The unmount-nested test uses umount -f to unmount /mnt, -# without -f it does not work. It is checked that the kernel does -# the unmount recursively. There must be no dangling mount points. -# The whole tests have to be run as root. +# This regress test uses a vnd device to run mount and unmount. +# All tests have to be run as root. -CLEANFILES= diskimage stamp-* +CLEANFILES= diskimage *.log .PHONY: disk mount unconfig clean disk: unconfig - dd if=/dev/zero of=diskimage bs=100k count=16 + dd if=/dev/null of=diskimage bs=1m seek=1100 vnconfig vnd0 diskimage disklabel -wA -T ${.CURDIR}/disktemplate vnd0 disklabel vnd0 @@ -26,6 +21,8 @@ disk: unconfig mount: disk mkdir -p /mnt/regress-mount mount /dev/vnd0a /mnt/regress-mount + +mount-nested: mount mkdir /mnt/regress-mount/b mount /dev/vnd0b /mnt/regress-mount/b f=/mnt/regress-mount; for p in d e f g h i j k l m n o p;\ @@ -34,24 +31,71 @@ mount: disk [ `mount | grep -c '/dev/vnd0. on /mnt/regress-mount\>'` -eq 15 ] unconfig: + @echo '\n======== $@ ========' -umount -f /dev/vnd0a 2>/dev/null || true -rmdir /mnt/regress-mount 2>/dev/null || true -vnconfig -u vnd0 2>/dev/null || true - -rm -f stamp-setup -stamp-setup: - @echo '\n======== $@ ========' - ${.MAKE} -C ${.CURDIR} mount - date >$@ +# The unmount-nested test uses a disk template to create 15 partitions +# on a vnd device. All are initialized with a ffs file system. +# Then they are mounted nestedly in /mnt, see disktemplate for the +# tree layout. The unmount-nested test uses umount -f to unmount +# /mnt, without -f it does not work. It is checked that the kernel +# does the unmount recursively. There must be no dangling mount +# points. REGRESS_TARGETS+= run-regress-unmount-nested -run-regress-unmount-nested: stamp-setup +run-regress-unmount-nested: mount-nested @echo '\n======== $@ ========' ! umount /mnt/regress-mount umount -f /mnt/regress-mount mount [ `mount | grep -c '/dev/vnd0. on /mnt/regress-mount\>'` -eq 0 ] +# Create a 1 GB vnd partition and fill the ffs file system it with +# cp -r. After 15 seconds clean it with rm -rf. While this is +# running, unmount with -f. Run fsck -f to see that everything is +# clean. + +REGRESS_TARGETS+= run-regress-unmount-busy +run-regress-unmount-busy: mount + @echo '\n======== $@ ========' + cp -r /usr /mnt/regress-mount & + sleep 5 + sync + sleep 10 + rm -rf /mnt/regress-mount/usr & + sleep .1 + umount -f /mnt/regress-mount + fsck -f -y /dev/rvnd0a 2>&1 | tee fsck.log + ! egrep 'yes|FILE SYSTEM WAS MODIFIED|MARKING FILE SYSTEM CLEAN' \ + fsck.log + +# Create a 1 GB vnd partition and fill the ffs file system it with +# cp -r. After 15 seconds clean it with rm -rf. While this is +# running, remount read-only with -ur. Unmount the partition and +# run fsck -f to see that everything is clean. + +REGRESS_TARGETS+= run-regress-mount-readonly +run-regress-mount-readonly: mount + @echo '\n======== $@ ========' + cp -r /usr /mnt/regress-mount & + sleep 5 + sync + sleep 10 + rm -rf /mnt/regress-mount/usr & + sleep .1 + mount -f -ur /mnt/regress-mount + # XXX mount -ur should not return before it is done + for i in `jot 20`; do \ + pgrep -xf 'cp -r /usr' || \ + pgrep -xf 'rm -rf /mnt/regress-mount/usr' || \ + break; sleep 1; done + umount /mnt/regress-mount + fsck -f -y /dev/rvnd0a 2>&1 | tee fsck.log + ! egrep 'yes|FILE SYSTEM WAS MODIFIED|MARKING FILE SYSTEM CLEAN' \ + fsck.log + REGRESS_TARGETS+= run-regress-cleanup run-regress-cleanup: @echo '\n======== $@ ========' diff --git a/regress/sys/kern/mount/disktemplate b/regress/sys/kern/mount/disktemplate index 9199795373b..eeca0403c52 100644 --- a/regress/sys/kern/mount/disktemplate +++ b/regress/sys/kern/mount/disktemplate @@ -1,4 +1,4 @@ -/mnt 100k +/mnt 1G /mnt/b 100k /mnt/d 100k /mnt/d/e 100k |