Skip to content

Commit

Permalink
behlendorf
Browse files Browse the repository at this point in the history
  • Loading branch information
ahrens committed Apr 7, 2020
1 parent cda7b99 commit cca4be9
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 5 deletions.
7 changes: 3 additions & 4 deletions cmd/zstream/zstream_redup.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@
#include <libzfs.h>
#include <libzutil.h>
#include <stddef.h>
#include <stddef.h>
#include <stdio.h>
#include <stdio.h>
#include <stdlib.h>
#include <strings.h>
Expand Down Expand Up @@ -63,7 +61,7 @@ int
highbit64(uint64_t i)
{
if (i == 0)
return (0);
return (0);

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

rdt.redup_hash_array = calloc(numbuckets, sizeof (redup_entry_t *));
rdt.redup_hash_array =
safe_calloc(numbuckets * sizeof (redup_entry_t *));
rdt.ddecache = umem_cache_create("rde", sizeof (redup_entry_t), 0,
NULL, NULL, NULL, NULL, NULL, 0);
rdt.numhashbits = highbit64(numbuckets) - 1;
Expand Down
Empty file modified cmd/zstreamdump/zstreamdump
100644 → 100755
Empty file.
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ zfs snapshot $src_fs@snap3

log_must eval "zfs send -D -R $src_fs@snap3 > $streamfile"
log_must eval "zfs receive -v $dst_fs < $streamfile"
log_must zfs destroy -r $dst_fs
log_must eval "zstream redup $streamfile | zfs receive -v $dst_fs"

cleanup

Expand Down
14 changes: 13 additions & 1 deletion tests/zfs-tests/tests/functional/rsend/send-cD.ksh
Original file line number Diff line number Diff line change
Expand Up @@ -64,14 +64,26 @@ typeset size0=$(stat_size $stream0)
typeset size1=$(stat_size $stream1)
within_percent $size0 $size1 90 || log_fail "$size0 and $size1"

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

# check receive with redup.
log_must zfs destroy -r $recvfs
log_must zfs create -o compress=lz4 $recvfs
log_must eval "zstream redup $stream0 | zfs recv -d $recvfs"
log_must eval "zstream redup $inc | zfs recv -d $recvfs"
cmp_ds_cont $sendfs $recvfs

# The size of the incremental should be the same as the initial send.
typeset size2=$(stat_size $inc)
within_percent $size0 $size2 90 || log_fail "$size0 and $size1"

# The redup'ed size should be 4x
typeset size3=$(zstream redup $inc | wc -c)
let size4=size0*4
within_percent $size4 $size3 90 || log_fail "$size4 and $size3"

log_pass "The -c and -D flags do not interfere with each other"

0 comments on commit cca4be9

Please sign in to comment.