overlay: run unionmount testsuite test cases
[xfstests-dev.git] / tests / xfs / 440
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2018 Oracle, Inc.  All Rights Reserved.
4 #
5 # FS QA Test No. 440
6 #
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.
10 #
11 seq=`basename $0`
12 seqres=$RESULT_DIR/$seq
13 echo "QA output created by $seq"
14
15 here=`pwd`
16 tmp=/tmp/$$
17 status=1        # failure is the default!
18 trap "_cleanup; exit \$status" 0 1 2 3 15
19
20 _cleanup()
21 {
22         cd /
23         rm -f $tmp.*
24 }
25
26 # get standard environment, filters and checks
27 . ./common/rc
28 . ./common/reflink
29 . ./common/quota
30 . ./common/filter
31
32 # Modify as appropriate.
33 _supported_fs xfs
34 _supported_os Linux
35
36 _require_quota
37 _require_scratch_reflink
38 _require_cp_reflink
39 _require_user
40
41 rm -f $seqres.full
42
43 echo "Format and mount"
44 _scratch_mkfs > "$seqres.full" 2>&1
45 _scratch_mount "-o usrquota,grpquota" >> "$seqres.full" 2>&1
46
47 echo "Create files"
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"
54
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"
60
61 echo "Sync"
62 sync
63 _report_quota_blocks "-u $SCRATCH_MNT"
64
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"
69
70 echo "Remount"
71 _scratch_unmount
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"
75
76 # success, all done
77 status=0
78 exit