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 buffered copy on write.
11 seqres=$RESULT_DIR/$seq
12 echo "QA output created by $seq"
16 status=1 # failure is the default!
17 trap "_cleanup; exit \$status" 0 1 2 3 15
25 # get standard environment, filters and checks
31 # real QA test starts here
32 _require_scratch_reflink
34 _require_xfs_io_command "fiemap"
41 echo "Format and mount"
42 _scratch_mkfs > $seqres.full 2>&1
43 export MOUNT_OPTIONS="-o usrquota,grpquota $MOUNT_OPTIONS"
44 _scratch_mount >> $seqres.full 2>&1
45 quotacheck -u -g $SCRATCH_MNT 2> /dev/null
46 quotaon $SCRATCH_MNT 2> /dev/null
48 testdir=$SCRATCH_MNT/test-$seq
52 echo "Create the original files"
53 $XFS_IO_PROG -f -c "pwrite -S 0x61 -b $sz 0 $sz" $testdir/file1 >> $seqres.full
54 _cp_reflink $testdir/file1 $testdir/file2 >> $seqres.full
55 _cp_reflink $testdir/file1 $testdir/file3 >> $seqres.full
57 chown nobody $testdir/urk
59 chown $qa_user $testdir/erk
60 _report_quota_blocks $SCRATCH_MNT
63 echo "Change file ownership"
64 chown $qa_user $testdir/file1
65 chown $qa_user $testdir/file2
66 chown $qa_user $testdir/file3
67 _report_quota_blocks $SCRATCH_MNT
69 echo "CoW one of the files"
70 $XFS_IO_PROG -f -c "pwrite -S 0x63 -b $((sz/2)) 0 $((sz/2))" -c "fsync" $testdir/file2 >> $seqres.full
71 _report_quota_blocks $SCRATCH_MNT
73 echo "Remount the FS to see if accounting changes"
75 _report_quota_blocks $SCRATCH_MNT
77 echo "Chown one of the files"
78 chown nobody $testdir/file3
79 _report_quota_blocks $SCRATCH_MNT