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 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 # Modify as appropriate.
37 _require_scratch_reflink
43 echo "Format and mount"
44 _scratch_mkfs > "$seqres.full" 2>&1
45 _scratch_mount "-o usrquota,grpquota" >> "$seqres.full" 2>&1
48 $XFS_IO_PROG -c "cowextsize 1m" $SCRATCH_MNT
49 touch $SCRATCH_MNT/a $SCRATCH_MNT/force_fsgqa
50 chown $qa_user $SCRATCH_MNT/a $SCRATCH_MNT/force_fsgqa
51 _pwrite_byte 0x58 0 64k $SCRATCH_MNT/a >> $seqres.full
52 $XFS_IO_PROG -c 'stat -r' $SCRATCH_MNT/a | grep stat.size >> $seqres.full
53 _report_quota_blocks "-u $SCRATCH_MNT"
55 echo "Reflink and CoW"
56 _cp_reflink $SCRATCH_MNT/a $SCRATCH_MNT/b
57 _pwrite_byte 0x59 0 64k $SCRATCH_MNT/a >> $seqres.full
58 $XFS_IO_PROG -c 'stat -r' $SCRATCH_MNT/a | grep stat.size >> $seqres.full
59 _report_quota_blocks "-u $SCRATCH_MNT"
63 _report_quota_blocks "-u $SCRATCH_MNT"
65 echo "Chown and check quota"
66 chown root $SCRATCH_MNT/a
67 $XFS_IO_PROG -c 'stat -r' $SCRATCH_MNT/a | grep stat.size >> $seqres.full
68 _report_quota_blocks "-u $SCRATCH_MNT"
72 _scratch_mount "-o usrquota,grpquota" >> "$seqres.full" 2>&1
73 $XFS_IO_PROG -c 'stat -r' $SCRATCH_MNT/a | grep stat.size >> $seqres.full
74 _report_quota_blocks "-u $SCRATCH_MNT"