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