tests/ceph: add Makefile
[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 seq=`basename $0`
23 seqres=$RESULT_DIR/$seq
24 echo "QA output created by $seq"
25
26 here=`pwd`
27 tmp=/tmp/$$
28 status=1    # failure is the default!
29 trap "_cleanup; exit \$status" 0 1 2 3 15
30
31 _cleanup()
32 {
33         cd /
34         rm -rf $tmp.*
35 }
36
37 # get standard environment
38 . common/rc
39 . common/filter
40 . common/attr
41
42 # real QA test starts here
43 _supported_fs ceph
44
45 _require_xfs_io_command "copy_range"
46 _require_attrs
47 _require_test
48
49 workdir=$TEST_DIR/test-$seq
50 rm -rf $workdir
51 mkdir $workdir
52 rm -f $seqres.full
53
54 # Use 4M object size
55 objsz=4194304
56 file="$workdir/file-$objsz"
57 dest="$workdir/dest-$objsz"
58
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
62
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
67
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
71
72 # copy the whole file over
73 $XFS_IO_PROG -c "copy_range -s 0 -d 0 -l $(($objsz * 3)) $file" "$dest"
74
75 hexdump $dest
76
77 #success, all done
78 status=0
79 exit