2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (C) 2020 SUSE Linux Products GmbH. All Rights Reserved.
5 # FS QA Test No. ceph/002
7 # Test bug found while testing copy_file_range.
9 # This bug was an issue with how the OSDs handled the truncate_seq, copying it
10 # from the original object into the destination object. This test ensures the
11 # kernel client correctly handles fixed/non-fixed OSDs.
13 # The bug was tracked here:
15 # https://tracker.ceph.com/issues/37378
17 # The most relevant commits are:
19 # ceph OSD: dcd6a99ef9f5 ("osd: add new 'copy-from2' operation")
20 # linux kernel: 78beb0ff2fec ("ceph: use copy-from2 op in copy_file_range")
23 seqres=$RESULT_DIR/$seq
24 echo "QA output created by $seq"
28 status=1 # failure is the default!
29 trap "_cleanup; exit \$status" 0 1 2 3 15
37 # get standard environment
42 # real QA test starts here
45 _require_xfs_io_command "copy_range"
49 workdir=$TEST_DIR/test-$seq
56 file="$workdir/file-$objsz"
57 dest="$workdir/dest-$objsz"
59 # object_size has to be a multiple of stripe_unit
60 _ceph_create_file_layout $file $objsz 1 $objsz
61 _ceph_create_file_layout $dest $objsz 1 $objsz
63 # Create a 3 objects size files
64 $XFS_IO_PROG -c "pwrite -S 0x61 0 $objsz" $file >> $seqres.full 2>&1
65 $XFS_IO_PROG -c "pwrite -S 0x62 $objsz $objsz" $file >> $seqres.full 2>&1
66 $XFS_IO_PROG -c "pwrite -S 0x63 $(($objsz * 2)) $objsz" $file >> $seqres.full 2>&1
68 $XFS_IO_PROG -c "pwrite -S 0x64 0 $(($objsz * 3))" $dest >> $seqres.full 2>&1
69 # Truncate the destination file (messing up with the truncate_seq)
70 $XFS_IO_PROG -c "truncate 0" $dest >> $seqres.full 2>&1
72 # copy the whole file over
73 $XFS_IO_PROG -c "copy_range -s 0 -d 0 -l $(($objsz * 3)) $file" "$dest"