|
| 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 | +. $STF_SUITE/include/libtest.shlib |
| 24 | +. $STF_SUITE/tests/functional/block_cloning/block_cloning.kshlib |
| 25 | + |
| 26 | +# |
| 27 | +# DESCRIPTION: |
| 28 | +# Verify that cloning a file at a large offset is possible. |
| 29 | +# |
| 30 | +# STRATEGY: |
| 31 | +# 1. Create dataset. |
| 32 | +# 2. Populate the source file with 1024 blocks at 1024 block offset. |
| 33 | +# 3. Clone 1024 blocks at a 1024-block offset. |
| 34 | +# 4. Compare the cloned file with the original file. |
| 35 | +# |
| 36 | + |
| 37 | +verify_runnable "global" |
| 38 | + |
| 39 | +if is_linux && [[ $(linux_version) -lt $(linux_version "4.5") ]]; then |
| 40 | + log_unsupported "copy_file_range not available before Linux 4.5" |
| 41 | +fi |
| 42 | + |
| 43 | +claim="The first clone at a large offset is functional" |
| 44 | + |
| 45 | +log_assert $claim |
| 46 | + |
| 47 | +function cleanup |
| 48 | +{ |
| 49 | + datasetexists $TESTPOOL && destroy_pool $TESTPOOL |
| 50 | +} |
| 51 | + |
| 52 | +log_onexit cleanup |
| 53 | + |
| 54 | +# |
| 55 | +# 1. Create dataset. |
| 56 | +# |
| 57 | +log_must zpool create -o feature@block_cloning=enabled $TESTPOOL $DISKS |
| 58 | +sync_pool $TESTPOOL |
| 59 | + |
| 60 | +# |
| 61 | +# 2. Populate the source file with 1024 blocks at 1024 block offset. |
| 62 | +# |
| 63 | +log_must dd if=/dev/urandom of=/$TESTPOOL/file1 \ |
| 64 | + oflag=sync bs=128k count=1024 seek=1024 |
| 65 | +sync_pool $TESTPOOL |
| 66 | + |
| 67 | +# |
| 68 | +# 3. Clone 1024 blocks at a 1024-block offset. |
| 69 | +# |
| 70 | +log_must clonefile -f /$TESTPOOL/file1 /$TESTPOOL/file2 134217728 134217728 \ |
| 71 | + 134217728 |
| 72 | +sync_pool $TESTPOOL |
| 73 | + |
| 74 | +# |
| 75 | +# 4. Compare the cloned file with the original file. |
| 76 | +# |
| 77 | +log_must have_same_content /$TESTPOOL/file1 /$TESTPOOL/file2 |
| 78 | +typeset blocks=$(get_same_blocks $TESTPOOL file1 $TESTPOOL file2) |
| 79 | + |
| 80 | +# FreeBSD's seq(1) leaves a trailing space, remove it with sed(1). |
| 81 | +log_must [ "$blocks" = "$(seq -s " " 0 1023 | sed 's/ $//')" ] |
| 82 | + |
| 83 | +log_pass $claim |
0 commit comments