Skip to content

Commit cca4be9

Browse files
committed
behlendorf
1 parent cda7b99 commit cca4be9

File tree

4 files changed

+18
-5
lines changed

4 files changed

+18
-5
lines changed

cmd/zstream/zstream_redup.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,6 @@
2626
#include <libzfs.h>
2727
#include <libzutil.h>
2828
#include <stddef.h>
29-
#include <stddef.h>
30-
#include <stdio.h>
3129
#include <stdio.h>
3230
#include <stdlib.h>
3331
#include <strings.h>
@@ -63,7 +61,7 @@ int
6361
highbit64(uint64_t i)
6462
{
6563
if (i == 0)
66-
return (0);
64+
return (0);
6765

6866
return (NBBY * sizeof (uint64_t) - __builtin_clzll(i));
6967
}
@@ -220,7 +218,8 @@ zfs_redup_stream(int infd, int outfd, boolean_t verbose)
220218
if (!ISP2(numbuckets))
221219
numbuckets = 1ULL << highbit64(numbuckets);
222220

223-
rdt.redup_hash_array = calloc(numbuckets, sizeof (redup_entry_t *));
221+
rdt.redup_hash_array =
222+
safe_calloc(numbuckets * sizeof (redup_entry_t *));
224223
rdt.ddecache = umem_cache_create("rde", sizeof (redup_entry_t), 0,
225224
NULL, NULL, NULL, NULL, NULL, 0);
226225
rdt.numhashbits = highbit64(numbuckets) - 1;

cmd/zstreamdump/zstreamdump

100644100755
File mode changed.

tests/zfs-tests/tests/functional/cli_root/zfs_receive/zfs_receive_013_pos.ksh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,8 @@ zfs snapshot $src_fs@snap3
6767

6868
log_must eval "zfs send -D -R $src_fs@snap3 > $streamfile"
6969
log_must eval "zfs receive -v $dst_fs < $streamfile"
70+
log_must zfs destroy -r $dst_fs
71+
log_must eval "zstream redup $streamfile | zfs receive -v $dst_fs"
7072

7173
cleanup
7274

tests/zfs-tests/tests/functional/rsend/send-cD.ksh

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,14 +64,26 @@ typeset size0=$(stat_size $stream0)
6464
typeset size1=$(stat_size $stream1)
6565
within_percent $size0 $size1 90 || log_fail "$size0 and $size1"
6666

67-
# Finally, make sure the receive works correctly.
67+
# make sure the receive works correctly.
6868
log_must eval "zfs send -D -c -i snap0 $sendfs@snap1 >$inc"
6969
log_must eval "zfs recv -d $recvfs <$stream0"
7070
log_must eval "zfs recv -d $recvfs <$inc"
7171
cmp_ds_cont $sendfs $recvfs
7272

73+
# check receive with redup.
74+
log_must zfs destroy -r $recvfs
75+
log_must zfs create -o compress=lz4 $recvfs
76+
log_must eval "zstream redup $stream0 | zfs recv -d $recvfs"
77+
log_must eval "zstream redup $inc | zfs recv -d $recvfs"
78+
cmp_ds_cont $sendfs $recvfs
79+
7380
# The size of the incremental should be the same as the initial send.
7481
typeset size2=$(stat_size $inc)
7582
within_percent $size0 $size2 90 || log_fail "$size0 and $size1"
7683

84+
# The redup'ed size should be 4x
85+
typeset size3=$(zstream redup $inc | wc -c)
86+
let size4=size0*4
87+
within_percent $size4 $size3 90 || log_fail "$size4 and $size3"
88+
7789
log_pass "The -c and -D flags do not interfere with each other"

0 commit comments

Comments
 (0)