9bc728fd2e18692ec55267144c31c0e82c171475
[xfstests-dev.git] / tests / ceph / 002
1 #!/bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (C) 2020 SUSE Linux Products GmbH. All Rights Reserved.
4 #
5 # FS QA Test No. ceph/002
6 #
7 # Test bug found while testing copy_file_range.
8 #
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.
12 #
13 # The bug was tracked here:
14 #
15 #   https://tracker.ceph.com/issues/37378
16 #
17 # The most relevant commits are:
18 #
19 #   ceph OSD:     dcd6a99ef9f5 ("osd: add new 'copy-from2' operation")
20 #   linux kernel: 78beb0ff2fec ("ceph: use copy-from2 op in copy_file_range")
21 #
22 . ./common/preamble
23 _begin_fstest auto quick copy_range
24
25 # get standard environment
26 . common/filter
27 . common/attr
28
29 # real QA test starts here
30 _supported_fs ceph
31
32 _require_xfs_io_command "copy_range"
33 _require_attrs
34 _require_test
35
36 workdir=$TEST_DIR/test-$seq
37 rm -rf $workdir
38 mkdir $workdir
39
40 # Use 4M object size
41 objsz=4194304
42 file="$workdir/file-$objsz"
43 dest="$workdir/dest-$objsz"
44
45 # object_size has to be a multiple of stripe_unit
46 _ceph_create_file_layout $file $objsz 1 $objsz
47 _ceph_create_file_layout $dest $objsz 1 $objsz
48
49 # Create a 3 objects size files
50 $XFS_IO_PROG -c "pwrite -S 0x61 0 $objsz" $file >> $seqres.full 2>&1
51 $XFS_IO_PROG -c "pwrite -S 0x62 $objsz $objsz" $file >> $seqres.full 2>&1
52 $XFS_IO_PROG -c "pwrite -S 0x63 $(($objsz * 2)) $objsz" $file >> $seqres.full 2>&1
53
54 $XFS_IO_PROG -c "pwrite -S 0x64 0 $(($objsz * 3))" $dest >> $seqres.full 2>&1
55 # Truncate the destination file (messing up with the truncate_seq)
56 $XFS_IO_PROG -c "truncate 0" $dest >> $seqres.full 2>&1
57
58 # copy the whole file over
59 $XFS_IO_PROG -c "copy_range -s 0 -d 0 -l $(($objsz * 3)) $file" "$dest"
60
61 hexdump $dest
62
63 #success, all done
64 status=0
65 exit