]> git.proxmox.com Git - mirror_zfs.git/blame - tests/zfs-tests/tests/functional/block_cloning/block_cloning_copyfilerange_fallback_same_txg.ksh
tests/block_cloning: sync before write in fallback test
[mirror_zfs.git] / tests / zfs-tests / tests / functional / block_cloning / block_cloning_copyfilerange_fallback_same_txg.ksh
CommitLineData
92f095a9
RN
1#!/bin/ksh -p
2#
3# CDDL HEADER START
4#
5# The contents of this file are subject to the terms of the
6# Common Development and Distribution License (the "License").
7# You may not use this file except in compliance with the License.
8#
9# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10# or https://opensource.org/licenses/CDDL-1.0.
11# See the License for the specific language governing permissions
12# and limitations under the License.
13#
14# When distributing Covered Code, include this CDDL HEADER in each
15# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16# If applicable, add the following below this CDDL HEADER, with the
17# fields enclosed by brackets "[]" replaced with your own identifying
18# information: Portions Copyright [yyyy] [name of copyright owner]
19#
20# CDDL HEADER END
21#
22
23#
24# Copyright (c) 2023, Klara Inc.
25# Copyright (c) 2023, Rob Norris <robn@despairlabs.com>
26#
27
28. $STF_SUITE/include/libtest.shlib
29. $STF_SUITE/tests/functional/block_cloning/block_cloning.kshlib
30
31verify_runnable "global"
32
33if [[ $(linux_version) -lt $(linux_version "4.5") ]]; then
34 log_unsupported "copy_file_range not available before Linux 4.5"
35fi
36
37claim="copy_file_range will fall back to copy when cloning on same txg"
38
39log_assert $claim
40
41typeset timeout=$(get_tunable TXG_TIMEOUT)
42
43function cleanup
44{
45 datasetexists $TESTPOOL && destroy_pool $TESTPOOL
46 set_tunable64 TXG_TIMEOUT $timeout
47}
48
49log_onexit cleanup
50
92f095a9
RN
51log_must set_tunable64 TXG_TIMEOUT 5000
52
8526b12f
PD
53log_must zpool create -o feature@block_cloning=enabled $TESTPOOL $DISKS
54
bf54da84
RN
55log_must sync_pool $TESTPOOL true
56
92f095a9
RN
57log_must dd if=/dev/urandom of=/$TESTPOOL/file bs=128K count=4
58log_must clonefile -f /$TESTPOOL/file /$TESTPOOL/clone 0 0 524288
59
60log_must sync_pool $TESTPOOL
61
62log_must have_same_content /$TESTPOOL/file /$TESTPOOL/clone
63
084ff4ab 64typeset blocks=$(get_same_blocks $TESTPOOL file $TESTPOOL clone)
92f095a9
RN
65log_must [ "$blocks" = "" ]
66
67log_pass $claim
68