2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2018 Oracle, Inc. All Rights Reserved.
7 # Regression test for a quota accounting bug when changing the owner of
8 # a file that has CoW reservations and no dirty pages. The reservations
9 # should shift over to the new owner, but they do not.
12 _begin_fstest auto quick clone quota
14 # Import common functions.
19 # Modify as appropriate.
23 _require_scratch_reflink
27 echo "Format and mount"
28 _scratch_mkfs > "$seqres.full" 2>&1
29 _scratch_mount "-o usrquota,grpquota" >> "$seqres.full" 2>&1
32 $XFS_IO_PROG -c "cowextsize 1m" $SCRATCH_MNT
33 touch $SCRATCH_MNT/a $SCRATCH_MNT/force_fsgqa
34 chown $qa_user $SCRATCH_MNT/a $SCRATCH_MNT/force_fsgqa
35 _pwrite_byte 0x58 0 64k $SCRATCH_MNT/a >> $seqres.full
36 $XFS_IO_PROG -c 'stat -r' $SCRATCH_MNT/a | grep stat.size >> $seqres.full
37 _report_quota_blocks "-u $SCRATCH_MNT"
39 echo "Reflink and CoW"
40 _cp_reflink $SCRATCH_MNT/a $SCRATCH_MNT/b
41 _pwrite_byte 0x59 0 64k $SCRATCH_MNT/a >> $seqres.full
42 $XFS_IO_PROG -c 'stat -r' $SCRATCH_MNT/a | grep stat.size >> $seqres.full
43 _report_quota_blocks "-u $SCRATCH_MNT"
47 _report_quota_blocks "-u $SCRATCH_MNT"
49 echo "Chown and check quota"
50 chown root $SCRATCH_MNT/a
51 $XFS_IO_PROG -c 'stat -r' $SCRATCH_MNT/a | grep stat.size >> $seqres.full
52 _report_quota_blocks "-u $SCRATCH_MNT"
56 _scratch_mount "-o usrquota,grpquota" >> "$seqres.full" 2>&1
57 $XFS_IO_PROG -c 'stat -r' $SCRATCH_MNT/a | grep stat.size >> $seqres.full
58 _report_quota_blocks "-u $SCRATCH_MNT"