]> git.proxmox.com Git - mirror_zfs-debian.git/blob - tests/zfs-tests/tests/functional/cli_root/zfs_mount/zfs_multi_mount.ksh
New upstream version 0.7.9
[mirror_zfs-debian.git] / tests / zfs-tests / tests / functional / cli_root / zfs_mount / zfs_multi_mount.ksh
1 #!/bin/ksh -p
2 #
3 # CDDL HEADER START
4 #
5 # This file and its contents are supplied under the terms of the
6 # Common Development and Distribution License ("CDDL"), version 1.0.
7 # You may only use this file in accordance with the terms of version
8 # 1.0 of the CDDL.
9 #
10 # A full copy of the text of the CDDL should have accompanied this
11 # source. A copy is of the CDDL is also available via the Internet
12 # at http://www.illumos.org/license/CDDL.
13 #
14 # CDDL HEADER END
15 #
16
17 #
18 # Copyright(c) 2018 Datto Inc.
19 #
20
21 . $STF_SUITE/include/libtest.shlib
22
23 #
24 # DESCRIPTION:
25 # Verify multi mount functionality
26 #
27 # STRATEGY:
28 # 1. Create fs
29 # 2. Create and hold open file in filesystem
30 # 3. Lazy unmount
31 # 4. Verify remounting fs that was lazily unmounted is possible
32 # 5. Verify multiple mounts of the same dataset are possible
33 # 6. Verify bind mount doesn't prevent rename
34 #
35
36 verify_runnable "both"
37
38 function cleanup
39 {
40 ismounted $MNTPFS && log_must umount $MNTPFS
41 ismounted $MNTPFS2 && log_must umount $MNTPFS2
42 ismounted $MNTPFS3 && log_must umount $MNTPFS3
43 ismounted $MNTPFS4 && log_must umount $MNTPFS4
44 ismounted $RENAMEMNT && log_must umount $RENAMEMNT
45 datasetexists $TESTDS && log_must destroy_dataset "$TESTDS" "-f"
46 }
47 log_onexit cleanup
48
49 log_assert "Verify multiple mounts into one namespace are possible"
50
51 # 1. Create fs
52 TESTDS="$TESTPOOL/multi-mount-test"
53 log_must zfs create $TESTDS
54
55 # 2. Create and hold open file in filesystem
56 MNTPFS="$(get_prop mountpoint $TESTDS)"
57 FILENAME="$MNTPFS/file"
58 log_must mkfile 128k $FILENAME
59 log_must exec 9<> $FILENAME # open file
60
61 # 3. Lazy umount
62 log_must umount -l $MNTPFS
63 if [ -f $FILENAME ]; then
64 log_fail "Lazy unmount failed"
65 fi
66
67 # 4. Verify remounting fs that was lazily unmounted is possible
68 log_must zfs mount $TESTDS
69 if [ ! -f $FILENAME ]; then
70 log_fail "Lazy remount failed"
71 fi
72 log_must exec 9>&- # close fd
73
74 # 5. Verify multiple mounts of the same dataset are possible
75 MNTPFS2="$MNTPFS-second"
76 FILENAME="$MNTPFS2/file"
77 log_must mkdir $MNTPFS2
78 log_must mount -t zfs -o zfsutil $TESTDS $MNTPFS2
79 if [ ! -f $FILENAME ]; then
80 log_fail "First multi mount failed"
81 fi
82
83 MNTPFS3="$MNTPFS-third"
84 FILENAME="$MNTPFS3/file"
85 log_must mkdir $MNTPFS3
86 log_must mount -t zfs -o zfsutil $TESTDS $MNTPFS3
87 if [ ! -f $FILENAME ]; then
88 log_fail "Second multi mount failed"
89 fi
90
91 # 6. Verify bind mount doesn't prevent rename
92 RENAMEFS="$TESTDS-newname"
93 MNTPFS4="$MNTPFS-fourth"
94 log_must mkdir $MNTPFS4
95 log_must mount --bind $MNTPFS $MNTPFS4
96 log_must zfs rename $TESTDS $RENAMEFS
97 RENAMEMNT="$(get_prop mountpoint $RENAMEFS)"
98 FILENAME="$RENAMEMNT/file"
99 if [ ! -f $FILENAME ]; then
100 log_fail "Rename failed"
101 fi
102 log_must zfs rename $RENAMEFS $TESTDS
103
104 log_pass "Multiple mounts are possible"