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 reflinking a file and that we're not
8 # charged for directio copy on write.
11 _begin_fstest auto quick clone
13 # Import common functions.
18 # real QA test starts here
19 _require_scratch_reflink
21 _require_xfs_io_command "fiemap"
27 echo "Format and mount"
28 _scratch_mkfs > $seqres.full 2>&1
29 export MOUNT_OPTIONS="-o usrquota,grpquota $MOUNT_OPTIONS"
30 _scratch_mount >> $seqres.full 2>&1
31 quotacheck -u -g $SCRATCH_MNT 2> /dev/null
32 quotaon $SCRATCH_MNT 2> /dev/null
34 testdir=$SCRATCH_MNT/test-$seq
38 echo "Create the original files"
39 $XFS_IO_PROG -f -c "pwrite -S 0x61 -b $sz 0 $sz" $testdir/file1 >> $seqres.full
40 _cp_reflink $testdir/file1 $testdir/file2 >> $seqres.full
41 _cp_reflink $testdir/file1 $testdir/file3 >> $seqres.full
43 chown nobody $testdir/urk
45 chown $qa_user $testdir/erk
46 _report_quota_blocks $SCRATCH_MNT
49 echo "Change file ownership"
50 chown $qa_user $testdir/file1
51 chown $qa_user $testdir/file2
52 chown $qa_user $testdir/file3
53 _report_quota_blocks $SCRATCH_MNT
55 echo "CoW one of the files"
56 $XFS_IO_PROG -d -f -c "pwrite -S 0x63 -b $((sz/2)) 0 $((sz/2))" -c "fsync" $testdir/file2 >> $seqres.full
57 _report_quota_blocks $SCRATCH_MNT
59 echo "Remount the FS to see if accounting changes"
61 _report_quota_blocks $SCRATCH_MNT
63 echo "Chown one of the files"
64 chown nobody $testdir/file3
65 _report_quota_blocks $SCRATCH_MNT