2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2016, Oracle and/or its affiliates. All Rights Reserved.
7 # Ensure that quota charges us for reflnking a file and that we're not
8 # charged for directio copy on write. Same as g/326, but we get to play
12 seqres=$RESULT_DIR/$seq
13 echo "QA output created by $seq"
17 status=1 # failure is the default!
18 trap "_cleanup; exit \$status" 0 1 2 3 15
26 # get standard environment, filters and checks
32 # real QA test starts here
35 _require_scratch_reflink
37 _require_xfs_io_command "fiemap"
40 _require_xfs_io_command "cowextsize"
46 echo "Format and mount"
47 _scratch_mkfs > $seqres.full 2>&1
48 export MOUNT_OPTIONS="-o usrquota,grpquota $MOUNT_OPTIONS"
49 _scratch_mount >> $seqres.full 2>&1
50 quotacheck -u -g $SCRATCH_MNT 2> /dev/null
51 quotaon $SCRATCH_MNT 2> /dev/null
53 testdir=$SCRATCH_MNT/test-$seq
58 echo "Create the original files"
59 $XFS_IO_PROG -c "cowextsize $((sz/2))" $testdir >> $seqres.full
60 $XFS_IO_PROG -f -c "pwrite -S 0x61 -b $sz 0 $sz" $testdir/file1 >> $seqres.full
61 _cp_reflink $testdir/file1 $testdir/file2 >> $seqres.full
62 _cp_reflink $testdir/file1 $testdir/file3 >> $seqres.full
64 chown nobody $testdir/urk
66 chown $qa_user $testdir/erk
67 _report_quota_blocks $SCRATCH_MNT
70 echo "Change file ownership"
71 chown $qa_user $testdir/file1
72 chown $qa_user $testdir/file2
73 chown $qa_user $testdir/file3
74 _report_quota_blocks $SCRATCH_MNT
76 echo "CoW one of the files"
77 $XFS_IO_PROG -d -f -c "pwrite -S 0x63 -b $blksz $((sz - blksz)) $blksz" -c "fsync" $testdir/file2 >> $seqres.full
78 _report_quota_blocks $SCRATCH_MNT
80 echo "Remount the FS to see if accounting changes"
82 _report_quota_blocks $SCRATCH_MNT
84 echo "Chown one of the files"
85 chown nobody $testdir/file3
86 _report_quota_blocks $SCRATCH_MNT