]>
git.proxmox.com Git - mirror_zfs.git/blob - tests/zfs-tests/tests/functional/cli_root/zfs_send/zfs_send_sparse.ksh
3 # This file and its contents are supplied under the terms of the
4 # Common Development and Distribution License ("CDDL"), version 1.0.
5 # You may only use this file in accordance with the terms of version
8 # A full copy of the text of the CDDL should have accompanied this
9 # source. A copy of the CDDL is also available via the Internet at
10 # http://www.illumos.org/license/CDDL.
14 # Copyright 2017, loli10K <ezomori.nozomu@gmail.com>. All rights reserved.
17 .
$STF_SUITE/include
/libtest.shlib
21 # 'zfs send' should be able to send (big) sparse files correctly.
24 # 1. Create sparse files of various size
25 # 2. Snapshot and send these sparse files
26 # 3. Verify these files are received correctly and we don't trigger any issue
27 # like the one described in https://github.com/zfsonlinux/zfs/pull/6760
30 verify_runnable
"both"
34 datasetexists
$SENDFS && log_must zfs destroy
-r $SENDFS
35 datasetexists
$RECVFS && log_must zfs destroy
-r $RECVFS
39 # Write 1 random byte at $offset of "source" file in $sendfs dataset
40 # Snapshot and send $sendfs dataset to $recvfs
41 # Compare the received file with its source
43 function write_compare_files
# <sendfs> <recvfs> <offset>
49 # create source filesystem
50 log_must zfs create
$sendfs
52 sendfile
="$(get_prop mountpoint $sendfs)/data.bin"
53 log_must
dd if=/dev
/urandom of
=$sendfile bs
=1 count
=1 seek
=$offset
54 # send/receive the file
55 log_must zfs snapshot
$sendfs@snap
56 log_must
eval "zfs send $sendfs@snap | zfs receive $recvfs"
57 # compare sparse files
58 recvfile
="$(get_prop mountpoint $recvfs)/data.bin"
59 log_must
cmp $sendfile $recvfile $offset $offset
60 sendsz
=$
(stat_size
$sendfile)
61 recvsz
=$
(stat_size
$recvfile)
62 if [[ $sendsz -ne $recvsz ]]; then
63 log_fail
"$sendfile ($sendsz) and $recvfile ($recvsz) differ."
66 log_must zfs destroy
-r $sendfs
67 log_must zfs destroy
-r $recvfs
70 log_assert
"'zfs send' should be able to send (big) sparse files correctly."
73 SENDFS
="$TESTPOOL/sendfs"
74 RECVFS
="$TESTPOOL/recvfs"
75 OFF_T_MAX
="$(echo '2 ^ 40 * 8 - 1' | bc)"
78 offset
=$
(echo "2 ^ $i" |
bc)
79 [[ is_32bit
]] && [[ $offset -ge $OFF_T_MAX ]] && continue;
80 write_compare_files
$SENDFS $RECVFS $offset
83 log_pass
"'zfs send' sends (big) sparse files correctly."