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
10 # A full copy of the text of the CDDL should have accompanied this
11 # source. A copy of the CDDL is also available via the Internet at
12 # http://www.illumos.org/license/CDDL.
18 # Copyright (c) 2019 by Lawrence Livermore National Security, LLC.
22 # Verify the hostid file can reside on a ZFS dataset.
25 # 1. Create a non-redundant pool
26 # 2. Create an 'etc' dataset containing a valid hostid file
27 # 3. Create a file so the pool will have some contents
28 # 4. Verify multihost cannot be enabled until the /etc/hostid is linked
29 # 5. Verify vdevs may be attached and detached
30 # 6. Verify normal, cache, log and special vdevs can be added
31 # 7. Verify normal, cache, and log vdevs can be removed
34 . $STF_SUITE/include/libtest.shlib
35 . $STF_SUITE/tests/functional/mmp/mmp.cfg
36 . $STF_SUITE/tests/functional/mmp/mmp.kshlib
38 verify_runnable "both"
42 default_cleanup_noexit
43 log_must rm $MMP_DIR/file.{0,1,2,3,4,5}
44 log_must rmdir $MMP_DIR
45 log_must mmp_clear_hostid
46 if [[ -L $HOSTID_FILE ]]; then
51 log_assert "Verify hostid file can reside on a ZFS dataset"
54 log_must mkdir -p $MMP_DIR
55 log_must truncate -s $MINVDEVSIZE $MMP_DIR/file.{0,1,2,3,4,5}
57 # 1. Create a non-redundant pool
58 log_must zpool create $MMP_POOL $MMP_DIR/file.0
60 # 2. Create an 'etc' dataset containing a valid hostid file; caching is
61 # disabled on the dataset to force the hostid to be read from disk.
62 log_must zfs create -o primarycache=none -o secondarycache=none $MMP_POOL/etc
63 mntpnt_etc=$(get_prop mountpoint $MMP_POOL/etc)
64 log_must mmp_set_hostid $HOSTID1
65 log_must mv $HOSTID_FILE $mntpnt_etc/hostid
67 # 3. Create a file so the pool will have some contents
68 log_must zfs create $MMP_POOL/fs
69 mntpnt_fs=$(get_prop mountpoint $MMP_POOL/fs)
70 log_must mkfile 1M $mntpnt_fs/file
72 # 4. Verify multihost cannot be enabled until the /etc/hostid is linked
73 log_mustnot zpool set multihost=on $MMP_POOL
74 log_mustnot ls -l $HOSTID_FILE
75 log_must ln -s $mntpnt_etc/hostid $HOSTID_FILE
76 log_must zpool set multihost=on $MMP_POOL
78 # 5. Verify vdevs may be attached and detached
79 log_must zpool attach $MMP_POOL $MMP_DIR/file.0 $MMP_DIR/file.1
80 log_must zpool detach $MMP_POOL $MMP_DIR/file.1
82 # 6. Verify normal, cache, log and special vdevs can be added
83 log_must zpool add $MMP_POOL $MMP_DIR/file.1
84 log_must zpool add $MMP_POOL $MMP_DIR/file.2
85 log_must zpool add $MMP_POOL cache $MMP_DIR/file.3
86 log_must zpool add $MMP_POOL log $MMP_DIR/file.4
87 log_must zpool add $MMP_POOL special $MMP_DIR/file.5
89 # 7. Verify normal, cache, and log vdevs can be removed
90 log_must zpool remove $MMP_POOL $MMP_DIR/file.2
91 log_must zpool remove $MMP_POOL $MMP_DIR/file.3
92 log_must zpool remove $MMP_POOL $MMP_DIR/file.4
94 log_pass "Verify hostid file can reside on a ZFS dataset."