]> git.proxmox.com Git - mirror_zfs.git/blob - tests/zfs-tests/tests/functional/rsend/send_realloc_dnode_size.ksh
Fix problems receiving reallocated dnodes
[mirror_zfs.git] / tests / zfs-tests / tests / functional / rsend / send_realloc_dnode_size.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 incremental receive properly handles objects with changed
24 # dnode slot count.
25 #
26 # Strategy:
27 # 1. Populate a dataset with 1k byte dnodes and snapshot
28 # 2. Remove objects, set dnodesize=legacy, and remount dataset so new objects
29 # get recycled numbers and formerly "interior" dnode slots get assigned
30 # to new objects
31 # 3. Remove objects, set dnodesize=2k, and remount dataset so new objects
32 # overlap with recently recycled and formerly "normal" dnode slots get
33 # assigned to new objects
34 # 4. Generate initial and incremental streams
35 # 5. Verify initial and incremental streams can be received
36 #
37
38 verify_runnable "both"
39
40 log_assert "Verify incremental receive handles objects with changed dnode size"
41
42 function cleanup
43 {
44 rm -f $BACKDIR/fs-dn-legacy
45 rm -f $BACKDIR/fs-dn-1k
46 rm -f $BACKDIR/fs-dn-2k
47
48 if datasetexists $POOL/fs ; then
49 log_must zfs destroy -rR $POOL/fs
50 fi
51
52 if datasetexists $POOL/newfs ; then
53 log_must zfs destroy -rR $POOL/newfs
54 fi
55 }
56
57 log_onexit cleanup
58
59 # 1. Populate a dataset with 1k byte dnodes and snapshot
60 log_must zfs create -o dnodesize=1k $POOL/fs
61 log_must mk_files 200 262144 0 $POOL/fs
62 log_must zfs snapshot $POOL/fs@a
63
64 # 2. Remove objects, set dnodesize=legacy, and remount dataset so new objects
65 # get recycled numbers and formerly "interior" dnode slots get assigned
66 # to new objects
67 rm /$POOL/fs/*
68
69 log_must zfs unmount $POOL/fs
70 log_must zfs set dnodesize=legacy $POOL/fs
71 log_must zfs mount $POOL/fs
72
73 log_must mk_files 200 262144 0 $POOL/fs
74 log_must zfs snapshot $POOL/fs@b
75
76 # 3. Remove objects, set dnodesize=2k, and remount dataset so new objects
77 # overlap with recently recycled and formerly "normal" dnode slots get
78 # assigned to new objects
79 rm /$POOL/fs/*
80
81 log_must zfs unmount $POOL/fs
82 log_must zfs set dnodesize=2k $POOL/fs
83 log_must zfs mount $POOL/fs
84
85 mk_files 200 262144 0 $POOL/fs
86 log_must zfs snapshot $POOL/fs@c
87
88 # 4. Generate initial and incremental streams
89 log_must eval "zfs send $POOL/fs@a > $BACKDIR/fs-dn-1k"
90 log_must eval "zfs send -i $POOL/fs@a $POOL/fs@b > $BACKDIR/fs-dn-legacy"
91 log_must eval "zfs send -i $POOL/fs@b $POOL/fs@c > $BACKDIR/fs-dn-2k"
92
93 # 5. Verify initial and incremental streams can be received
94 log_must eval "zfs recv $POOL/newfs < $BACKDIR/fs-dn-1k"
95 log_must eval "zfs recv $POOL/newfs < $BACKDIR/fs-dn-legacy"
96 log_must eval "zfs recv $POOL/newfs < $BACKDIR/fs-dn-2k"
97
98 log_pass "Verify incremental receive handles objects with changed dnode size"