diff options
author | LOLi <[email protected]> | 2017-10-27 01:58:38 +0200 |
---|---|---|
committer | Brian Behlendorf <[email protected]> | 2017-10-26 16:58:38 -0700 |
commit | ee45fbd89465f12b39e97173a088175d4b712b5f (patch) | |
tree | 811bc8bc132c6aef42e6d18f2a6ffde9abe20f7b /tests/zfs-tests | |
parent | 88f9c9396bcce596db56dc880260f95c49a51d67 (diff) |
ZFS send fails to dump objects larger than 128PiB
When dumping objects larger than 128PiB it's possible for do_dump() to
miscalculate the FREE_RECORD offset due to an integer overflow
condition: this prevents the receiving end from correctly restoring
the dumped object.
Reviewed-by: Brian Behlendorf <[email protected]>
Signed-off-by: Fabian Grünbichler <[email protected]>
Signed-off-by: loli10K <[email protected]>
Closes #6760
Diffstat (limited to 'tests/zfs-tests')
-rw-r--r-- | tests/zfs-tests/tests/functional/cli_root/zfs_send/Makefile.am | 3 | ||||
-rwxr-xr-x | tests/zfs-tests/tests/functional/cli_root/zfs_send/zfs_send_sparse.ksh | 83 |
2 files changed, 85 insertions, 1 deletions
diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_send/Makefile.am b/tests/zfs-tests/tests/functional/cli_root/zfs_send/Makefile.am index 08ab72a3d..e82df61c7 100644 --- a/tests/zfs-tests/tests/functional/cli_root/zfs_send/Makefile.am +++ b/tests/zfs-tests/tests/functional/cli_root/zfs_send/Makefile.am @@ -11,4 +11,5 @@ dist_pkgdata_SCRIPTS = \ zfs_send_006_pos.ksh \ zfs_send_007_pos.ksh \ zfs_send_encrypted.ksh \ - zfs_send_raw.ksh + zfs_send_raw.ksh \ + zfs_send_sparse.ksh diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_send/zfs_send_sparse.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_send/zfs_send_sparse.ksh new file mode 100755 index 000000000..735430506 --- /dev/null +++ b/tests/zfs-tests/tests/functional/cli_root/zfs_send/zfs_send_sparse.ksh @@ -0,0 +1,83 @@ +#!/bin/ksh -p +# +# This file and its contents are supplied under the terms of the +# Common Development and Distribution License ("CDDL"), version 1.0. +# You may only use this file in accordance with the terms of version +# 1.0 of the CDDL. +# +# A full copy of the text of the CDDL should have accompanied this +# source. A copy of the CDDL is also available via the Internet at +# http://www.illumos.org/license/CDDL. +# + +# +# Copyright 2017, loli10K <[email protected]>. All rights reserved. +# + +. $STF_SUITE/include/libtest.shlib + +# +# DESCRIPTION: +# 'zfs send' should be able to send (big) sparse files correctly. +# +# STRATEGY: +# 1. Create sparse files of various size +# 2. Snapshot and send these sparse files +# 3. Verify these files are received correctly and we don't trigger any issue +# like the one described in https://github.com/zfsonlinux/zfs/pull/6760 +# + +verify_runnable "both" + +function cleanup +{ + datasetexists $SENDFS && log_must zfs destroy -r $SENDFS + datasetexists $RECVFS && log_must zfs destroy -r $RECVFS +} + +# +# Write 1 random byte at $offset of "source" file in $sendfs dataset +# Snapshot and send $sendfs dataset to $recvfs +# Compare the received file with its source +# +function write_compare_files # <sendfs> <recvfs> <offset> +{ + typeset sendfs="$1" + typeset recvfs="$2" + typeset offset="$3" + + # create source filesystem + log_must zfs create $sendfs + # write sparse file + sendfile="$(get_prop mountpoint $sendfs)/data.bin" + log_must dd if=/dev/urandom of=$sendfile bs=1 count=1 seek=$offset + # send/receive the file + log_must zfs snapshot $sendfs@snap + log_must eval "zfs send $sendfs@snap | zfs receive $recvfs" + # compare sparse files + recvfile="$(get_prop mountpoint $recvfs)/data.bin" + log_must cmp $sendfile $recvfile $offset $offset + sendsz=$(stat -c '%s' $sendfile) + recvsz=$(stat -c '%s' $recvfile) + if [[ $sendsz -ne $recvsz ]]; then + log_fail "$sendfile ($sendsz) and $recvfile ($recvsz) differ." + fi + # cleanup + log_must zfs destroy -r $sendfs + log_must zfs destroy -r $recvfs +} + +log_assert "'zfs send' should be able to send (big) sparse files correctly." +log_onexit cleanup + +SENDFS="$TESTPOOL/sendfs" +RECVFS="$TESTPOOL/recvfs" +OFF_T_MAX="$(echo '2 ^ 40 * 8 - 1' | bc)" + +for i in {1..60}; do + offset=$(echo "2 ^ $i" | bc) + [[ is_32bit ]] && [[ $offset -ge $OFF_T_MAX ]] && continue; + write_compare_files $SENDFS $RECVFS $offset +done + +log_pass "'zfs send' sends (big) sparse files correctly." |