Skip to contentSkip to conversation

ext4/021: make sure the fdatasync subprocess exits

PATCH In review zhangyi (F) 2 participants 2 messages Feb 26, 2020 – Mar 6, 2020

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 ext4/021: make sure the fdatasync subprocess exits

Now we just kill fdatasync_work process and wait nothing after the test, so a busy unmount failure may appear if the fdatasync syscall doesn't return in time.

umount: /tmp/scratch: target is busy.
mount: /tmp/scratch: /dev/sdb already mounted on /tmp/scratch. !!! failed to remount /dev/sdb on /tmp/scratch

This patch wait the xfs_io fdatasync subprocess exit to make sure _check_scratch_fs success.

---
 tests/ext4/021 | 5 +++++
 1 file changed, 5 insertions(+)
tests/ext4/021 +5 -0
index 519737e1..3fc38e89 100755
@@ -80,6 +80,10 @@ _scratch_mount
 
 do_fdatasync_work()
 {
+	# Wait for running subcommand before exitting so that
+	# mountpoint is not busy when we try to unmount it
+	trap "wait; exit" SIGTERM
+
 	while [ 1 ]; do
 		$XFS_IO_PROG -f -c "fdatasync" $SCRATCH_MNT/testfile
 	done
@@ -89,6 +93,7 @@ do_fdatasync_work &
 datasync_work_pid=$!
 sleep 10
 kill $datasync_work_pid >/dev/null 2>&1
+wait
 
 # success, all done
 status=0
Signature · 1 line
2.17.2
Reviewed-by on v2 1/1
#1 lore raw
Quoted 4 lines · zhangyi (F)

Now we just kill fdatasync_work process and wait nothing after the test, so a busy unmount failure may appear if the fdatasync syscall doesn't return in time.

Quoted 8 lines

umount: /tmp/scratch: target is busy.
mount: /tmp/scratch: /dev/sdb already mounted on /tmp/scratch. !!! failed to remount /dev/sdb on /tmp/scratch

This patch wait the xfs_io fdatasync subprocess exit to make sure _check_scratch_fs success.

Looks good, thanks!