blob: 0f181621e824a13fab1cf404edbef03447326e2c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
|
#!/bin/ksh -p
#
# CDDL HEADER START
#
# This file and its contents are supplied under the terms of the
# Common Development and Distribution License ("CDDL"), version 1.0.
# You may only use this file in accordance with the terms of version
# 1.0 of the CDDL.
#
# A full copy of the text of the CDDL should have accompanied this
# source. A copy of the CDDL is also available via the Internet at
# http://www.illumos.org/license/CDDL.
#
# CDDL HEADER END
#
#
# Copyright 2020 Joyent, Inc.
#
. $STF_SUITE/include/libtest.shlib
#
# DESCRIPTION:
# 'zfs mount' should not get EBUSY due to inotify(5) watching a directory
#
# STRATEGY:
# 1. Create a directory
# 2. Start watching the directory with inotify(5).
# 3. Create a filesystem
# 4. Mount the filesystem at the directory created in step 1
# 5. Destroy the filesystem
# 6. Remove the directory
# 7. Verify the watcher saw the directory removal
#
verify_runnable "both"
function cleanup
{
datasetexists $TESTPOOL/$TESTFS1 && \
log_must zfs destroy -f $TESTPOOL/$TESTFS1
log_must rm -rf "$TESTDIR/mntpt" "$TESTDIR/watch_dir.log"
}
log_onexit cleanup
log_assert "'zfs mount' should not get EBUSY due to inotify(5) watching a directory"
# 1. Create a directory.
log_must mkdir -p "$TESTDIR/mntpt"
# 2. Start watching the directory with inotify(5).
watch_dir inotify $TESTDIR/mntpt > $TESTDIR/watch_dir.log &
# 3. Create a filesystem
log_must zfs create $TESTPOOL/$TESTFS1
# 4. Mount the file system at the directory created in step 1
log_must zfs set mountpoint=$TESTDIR/mntpt $TESTPOOL/$TESTFS1
# 5. Destroy the filesystem
log_must zfs destroy $TESTPOOL/$TESTFS1
# 6. Remove the directory. The corresponding inotify event will cause the
# watcher to exit.
log_must rmdir $TESTDIR/mntpt
# 7. Verify the watcher saw the directory removal. This ensures that the watcher
# was watching the directory we are interested in.
wait
log_must grep -q DELETE_SELF $TESTDIR/watch_dir.log
log_pass "'zfs mount' should not get EBUSY due to inotify(5) watching a directory"
|