]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - tests/zfs-tests/tests/functional/rsend/send_freeobjects.ksh
Update OpenZFS to 2.0.0-rc3-gbd565f
[FreeBSD/FreeBSD.git] / tests / zfs-tests / tests / functional / rsend / send_freeobjects.ksh
1 #!/bin/ksh
2
3 #
4 # This file and its contents are supplied under the terms of the
5 # Common Development and Distribution License ("CDDL"), version 1.0.
6 # You may only use this file in accordance with the terms of version
7 # 1.0 of the CDDL.
8 #
9 # A full copy of the text of the CDDL should have accompanied this
10 # source.  A copy of the CDDL is also available via the Internet at
11 # http://www.illumos.org/license/CDDL.
12 #
13
14 #
15 # Copyright (c) 2017 by Lawrence Livermore National Security, LLC.
16 #
17
18 . $STF_SUITE/include/libtest.shlib
19 . $STF_SUITE/tests/functional/rsend/rsend.kshlib
20
21 #
22 # Description:
23 # Verify FREEOBJECTS record frees sequential objects (See
24 # https://github.com/openzfs/zfs/issues/6694)
25 #
26 # Strategy:
27 # 1. Create three files with sequential object numbers, f1 f2 and f3
28 # 2. Delete f2
29 # 3. Take snapshot A
30 # 4. Delete f3
31 # 5. Take snapshot B
32 # 6. Receive a full send of A
33 # 7. Receive an incremental send of B
34 # 8. Fail test if f3 exists on received snapshot B
35 #
36
37 verify_runnable "both"
38
39 log_assert "Verify FREEOBJECTS record frees sequential objects"
40
41 sendds=sendfo
42 recvds=recvfo
43 f1=/$POOL/$sendds/f1
44 f2=/$POOL/$sendds/f2
45 f3=/$POOL/$sendds/f3
46
47 #
48 # We need to set xattr=sa and dnodesize=legacy to guarantee sequential
49 # object numbers for this test. Otherwise, if we used directory-based
50 # xattrs, SELinux extended attributes might consume intervening object
51 # numbers.
52 #
53 log_must zfs create -o xattr=sa -o dnodesize=legacy $POOL/$sendds
54
55 tries=100
56 for ((i=0; i<$tries; i++)); do
57         touch $f1 $f2 $f3
58         o1=$(ls -li $f1 | awk '{print $1}')
59         o2=$(ls -li $f2 | awk '{print $1}')
60         o3=$(ls -li $f3 | awk '{print $1}')
61
62         if [[ $o2 -ne $(( $o1 + 1 )) ]] || [[ $o3 -ne $(( $o2 + 1 )) ]]; then
63                 rm -f $f1 $f2 $f3
64         else
65                 break
66         fi
67 done
68
69 if [[ $i -eq $tries ]]; then
70         log_fail "Failed to create three sequential objects"
71 fi
72
73 log_must rm $f2
74 log_must zfs snap $POOL/$sendds@A
75 log_must rm $f3
76 log_must zfs snap $POOL/$sendds@B
77 log_must eval "zfs send $POOL/$sendds@A | zfs recv $POOL/$recvds"
78 log_must eval "zfs send -i $POOL/$sendds@A $POOL/$sendds@B |" \
79         "zfs recv $POOL/$recvds"
80 log_mustnot zdb $POOL/$recvds@B $o3
81 log_pass "Verify FREEOBJECTS record frees sequential objects"