Fix issues with raw sends of spill blocks

This patch fixes 2 issues in how spill blocks are processed during
raw sends. The first problem is that compressed spill blocks were
using the logical length rather than the physical length to
determine how much data to dump into the send stream. The second
issue is a typo that caused the spill record's object number to be
used where the objset's ID number was required. Both issues have
been corrected, and the payload_size is now printed in zstreamdump
for future debugging.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Tom Caputi <tcaputi@datto.com>
Closes #7378 
Closes #7432
This commit is contained in:
Tom Caputi 2018-04-17 14:19:03 -04:00 committed by Brian Behlendorf
parent e14a32b1c8
commit b0ee5946aa
3 changed files with 20 additions and 7 deletions

View File

@ -614,6 +614,9 @@ main(int argc, char *argv[])
BSWAP_64(drrs->drr_compressed_size); BSWAP_64(drrs->drr_compressed_size);
drrs->drr_type = BSWAP_32(drrs->drr_type); drrs->drr_type = BSWAP_32(drrs->drr_type);
} }
payload_size = DRR_SPILL_PAYLOAD_SIZE(drrs);
if (verbose) { if (verbose) {
sprintf_bytes(salt, drrs->drr_salt, sprintf_bytes(salt, drrs->drr_salt,
ZIO_DATA_SALT_LEN); ZIO_DATA_SALT_LEN);
@ -626,19 +629,21 @@ main(int argc, char *argv[])
"length = %llu flags = %u " "length = %llu flags = %u "
"compression type = %u " "compression type = %u "
"compressed_size = %llu " "compressed_size = %llu "
"payload_size = %llu "
"salt = %s iv = %s mac = %s\n", "salt = %s iv = %s mac = %s\n",
(u_longlong_t)drrs->drr_object, (u_longlong_t)drrs->drr_object,
(u_longlong_t)drrs->drr_length, (u_longlong_t)drrs->drr_length,
drrs->drr_flags, drrs->drr_flags,
drrs->drr_compressiontype, drrs->drr_compressiontype,
(u_longlong_t)drrs->drr_compressed_size, (u_longlong_t)drrs->drr_compressed_size,
(u_longlong_t)payload_size,
salt, salt,
iv, iv,
mac); mac);
} }
(void) ssread(buf, drrs->drr_length, &zc); (void) ssread(buf, payload_size, &zc);
if (dump) { if (dump) {
print_block(buf, drrs->drr_length); print_block(buf, payload_size);
} }
break; break;
case DRR_WRITE_EMBEDDED: case DRR_WRITE_EMBEDDED:

View File

@ -422,6 +422,7 @@ dump_spill(dmu_sendarg_t *dsp, const blkptr_t *bp, uint64_t object, void *data)
{ {
struct drr_spill *drrs = &(dsp->dsa_drr->drr_u.drr_spill); struct drr_spill *drrs = &(dsp->dsa_drr->drr_u.drr_spill);
uint64_t blksz = BP_GET_LSIZE(bp); uint64_t blksz = BP_GET_LSIZE(bp);
uint64_t payload_size = blksz;
if (dsp->dsa_pending_op != PENDING_NONE) { if (dsp->dsa_pending_op != PENDING_NONE) {
if (dump_record(dsp, NULL, 0) != 0) if (dump_record(dsp, NULL, 0) != 0)
@ -446,9 +447,10 @@ dump_spill(dmu_sendarg_t *dsp, const blkptr_t *bp, uint64_t object, void *data)
drrs->drr_compressed_size = BP_GET_PSIZE(bp); drrs->drr_compressed_size = BP_GET_PSIZE(bp);
zio_crypt_decode_params_bp(bp, drrs->drr_salt, drrs->drr_iv); zio_crypt_decode_params_bp(bp, drrs->drr_salt, drrs->drr_iv);
zio_crypt_decode_mac_bp(bp, drrs->drr_mac); zio_crypt_decode_mac_bp(bp, drrs->drr_mac);
payload_size = drrs->drr_compressed_size;
} }
if (dump_record(dsp, data, blksz) != 0) if (dump_record(dsp, data, payload_size) != 0)
return (SET_ERROR(EINTR)); return (SET_ERROR(EINTR));
return (0); return (0);
} }
@ -3395,7 +3397,7 @@ receive_read_record(struct receive_arg *ra)
ra->byteswap; ra->byteswap;
abuf = arc_loan_raw_buf(dmu_objset_spa(ra->os), abuf = arc_loan_raw_buf(dmu_objset_spa(ra->os),
drrs->drr_object, byteorder, drrs->drr_salt, dmu_objset_id(ra->os), byteorder, drrs->drr_salt,
drrs->drr_iv, drrs->drr_mac, drrs->drr_type, drrs->drr_iv, drrs->drr_mac, drrs->drr_type,
drrs->drr_compressed_size, drrs->drr_length, drrs->drr_compressed_size, drrs->drr_length,
drrs->drr_compressiontype); drrs->drr_compressiontype);

View File

@ -15,7 +15,7 @@
# #
# #
# Copyright (c) 2017 by Datto Inc. All rights reserved. # Copyright (c) 2018 by Datto Inc. All rights reserved.
# #
. $STF_SUITE/tests/functional/rsend/rsend.kshlib . $STF_SUITE/tests/functional/rsend/rsend.kshlib
@ -33,8 +33,9 @@
# 6. Add a file truncated to 4M to the filesystem # 6. Add a file truncated to 4M to the filesystem
# 7. Add a sparse file with metadata compression disabled to the filesystem # 7. Add a sparse file with metadata compression disabled to the filesystem
# 8. Add and remove 1000 empty files to the filesystem # 8. Add and remove 1000 empty files to the filesystem
# 9. Snapshot the filesystem # 9. Add a file with a large xattr value
# 10. Send and receive the filesystem, ensuring that it can be mounted # 10. Snapshot the filesystem
# 11. Send and receive the filesystem, ensuring that it can be mounted
# #
verify_runnable "both" verify_runnable "both"
@ -79,6 +80,11 @@ for i in {1..1000}; do
done done
sync sync
# ZoL issue #7432
log_must zfs set compression=on xattr=sa $TESTPOOL/$TESTFS2
log_must touch /$TESTPOOL/$TESTFS2/attrs
log_must eval "python -c 'print \"a\" * 4096' | attr -s bigval /$TESTPOOL/$TESTFS2/attrs"
log_must zfs snapshot $TESTPOOL/$TESTFS2@now log_must zfs snapshot $TESTPOOL/$TESTFS2@now
log_must eval "zfs send -wR $TESTPOOL/$TESTFS2@now > $sendfile" log_must eval "zfs send -wR $TESTPOOL/$TESTFS2@now > $sendfile"