overlay: run unionmount testsuite test cases
[xfstests-dev.git] / tests / xfs / 441
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. 441
6 #
7 # Regression test for a quota accounting bug when reflinking across EOF
8 # of a file in which we forgot dq_attach.
9 #
10 seq=`basename $0`
11 seqres=$RESULT_DIR/$seq
12 echo "QA output created by $seq"
13
14 here=`pwd`
15 tmp=/tmp/$$
16 status=1        # failure is the default!
17 trap "_cleanup; exit \$status" 0 1 2 3 15
18
19 _cleanup()
20 {
21         cd /
22         rm -f $tmp.*
23 }
24
25 # get standard environment, filters and checks
26 . ./common/rc
27 . ./common/reflink
28 . ./common/quota
29 . ./common/filter
30
31 # Modify as appropriate.
32 _supported_fs xfs
33 _supported_os Linux
34
35 _require_quota
36 _require_scratch_reflink
37 _require_cp_reflink
38 _require_user
39
40 rm -f $seqres.full
41
42 check_quota() {
43         du_total="$(du -ksc $SCRATCH_MNT/a $SCRATCH_MNT/b | tail -n 1 | awk '{print $1}')"
44         qu_total="$(_report_quota_blocks "-u $SCRATCH_MNT" | grep $qa_user | awk '{print $2}')"
45         echo "du: $du_total; quota: $qu_total"
46 }
47
48 echo "Format and mount (noquota)"
49 _scratch_mkfs > "$seqres.full" 2>&1
50 _scratch_mount "-o noquota" >> $seqres.full 2>&1
51
52 echo "Create files"
53 _pwrite_byte 0x58 0 1m $SCRATCH_MNT/a >> $seqres.full
54 _pwrite_byte 0x58 0 1m $SCRATCH_MNT/b >> $seqres.full
55 chown $qa_user $SCRATCH_MNT/a $SCRATCH_MNT/b
56 check_quota 2>&1 | _filter_scratch
57
58 echo "Mount (usrquota) and check quota"
59 _scratch_unmount
60 _scratch_mount "-o usrquota,grpquota" >> "$seqres.full" 2>&1
61 check_quota
62
63 echo "Reflink and check quota again"
64 _reflink_range $SCRATCH_MNT/a 256k $SCRATCH_MNT/b 384k 128k >> $seqres.full
65 _reflink_range $SCRATCH_MNT/a 256k $SCRATCH_MNT/b 960k 128k >> $seqres.full
66 check_quota
67
68 echo "Force quotacheck"
69 _check_quota_usage
70
71 # success, all done
72 status=0
73 exit