4 # Ensure that quota charges us for reflnking a file and that we're not
5 # charged for buffered copy on write. Same test as g/305, but we get to
8 #-----------------------------------------------------------------------
9 # Copyright (c) 2016, Oracle and/or its affiliates. All Rights Reserved.
11 # This program is free software; you can redistribute it and/or
12 # modify it under the terms of the GNU General Public License as
13 # published by the Free Software Foundation.
15 # This program is distributed in the hope that it would be useful,
16 # but WITHOUT ANY WARRANTY; without even the implied warranty of
17 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 # GNU General Public License for more details.
20 # You should have received a copy of the GNU General Public License
21 # along with this program; if not, write the Free Software Foundation,
22 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
23 #-----------------------------------------------------------------------
26 seqres=$RESULT_DIR/$seq
27 echo "QA output created by $seq"
31 status=1 # failure is the default!
32 trap "_cleanup; exit \$status" 0 1 2 3 15
40 # get standard environment, filters and checks
46 # real QA test starts here
49 _require_scratch_reflink
54 _require_xfs_io_command "cowextsize"
57 repquota $SCRATCH_MNT | egrep '^(fsgqa|root|nobody)'
61 echo "Format and mount"
62 _scratch_mkfs > $seqres.full 2>&1
63 export MOUNT_OPTIONS="-o usrquota,grpquota $MOUNT_OPTIONS"
64 _scratch_mount >> $seqres.full 2>&1
65 quotacheck -u -g $SCRATCH_MNT 2> /dev/null
66 quotaon $SCRATCH_MNT 2> /dev/null
68 testdir=$SCRATCH_MNT/test-$seq
73 echo "Create the original files"
74 $XFS_IO_PROG -c "cowextsize $((sz/2))" $testdir >> $seqres.full
75 $XFS_IO_PROG -f -c "pwrite -S 0x61 -b $sz 0 $sz" $testdir/file1 >> $seqres.full
76 _cp_reflink $testdir/file1 $testdir/file2 >> $seqres.full
77 _cp_reflink $testdir/file1 $testdir/file3 >> $seqres.full
79 chown nobody $testdir/urk
81 chown fsgqa $testdir/erk
85 echo "Change file ownership"
86 chown fsgqa $testdir/file1
87 chown fsgqa $testdir/file2
88 chown fsgqa $testdir/file3
91 echo "CoW one of the files"
92 $XFS_IO_PROG -f -c "pwrite -S 0x63 -b $blksz $((sz - blksz)) $blksz" -c "fsync" $testdir/file2 >> $seqres.full
95 echo "Remount the FS to see if accounting changes"
99 echo "Chown one of the files"
100 chown nobody $testdir/file3