summaryrefslogtreecommitdiff
path: root/tests/xfs/441
blob: 82654bf3322f6bf9a86de0194816ae5dbe2cca33 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#! /bin/bash
# SPDX-License-Identifier: GPL-2.0
# Copyright (c) 2018 Oracle, Inc.  All Rights Reserved.
#
# FS QA Test No. 441
#
# Regression test for a quota accounting bug when reflinking across EOF
# of a file in which we forgot dq_attach.
#
. ./common/preamble
_begin_fstest auto quick clone quota

# Import common functions.
. ./common/reflink
. ./common/quota
. ./common/filter

# Modify as appropriate.
_supported_fs xfs

_require_quota
_require_scratch_reflink
_require_cp_reflink
_require_user

check_quota() {
	du_total="$(du -ksc $SCRATCH_MNT/a $SCRATCH_MNT/b | tail -n 1 | awk '{print $1}')"
	qu_total="$(_report_quota_blocks "-u $SCRATCH_MNT" | grep $qa_user | awk '{print $2}')"
	echo "du: $du_total; quota: $qu_total"
}

echo "Format and mount (noquota)"
_scratch_mkfs > "$seqres.full" 2>&1
_scratch_mount "-o noquota" >> $seqres.full 2>&1

echo "Create files"
_pwrite_byte 0x58 0 1m $SCRATCH_MNT/a >> $seqres.full
_pwrite_byte 0x58 0 1m $SCRATCH_MNT/b >> $seqres.full
chown $qa_user $SCRATCH_MNT/a $SCRATCH_MNT/b
check_quota 2>&1 | _filter_scratch

echo "Mount (usrquota) and check quota"
_scratch_unmount
_scratch_mount "-o usrquota,grpquota" >> "$seqres.full" 2>&1
check_quota

echo "Reflink and check quota again"
_reflink_range $SCRATCH_MNT/a 256k $SCRATCH_MNT/b 384k 128k >> $seqres.full
_reflink_range $SCRATCH_MNT/a 256k $SCRATCH_MNT/b 960k 128k >> $seqres.full
check_quota

echo "Force quotacheck"
_check_quota_usage

# success, all done
status=0
exit