summaryrefslogtreecommitdiff
path: root/tests/ext4/034
blob: b656e54d83620a68e77e5a41fbdc941a8d70312b (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
58
59
60
61
62
63
#! /bin/bash
# SPDX-License-Identifier: GPL-2.0
# Copyright (c) 2018 Liu Bo, Alibaba.  All Rights Reserved.
#
# FS QA Test 034
#
# Regression test for a ENOSPC warning when both quota and
# "-o dioread_nolock,nodelalloc" is used.
#
# The bug was fixed by commit
# "ext4: make sure enough credits are reserved for dioread_nolock writes"
#
. ./common/preamble
_begin_fstest auto quick quota fiemap prealloc

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

# real QA test starts here

# Modify as appropriate.
_supported_fs ext4
_require_scratch
_require_quota
_require_nobody
_require_xfs_io_command "falloc"
_require_xfs_io_command "fiemap"
_require_xfs_io_command "syncfs"

echo "Format and mount"
_scratch_mkfs "-O quota" > $seqres.full 2>&1
_scratch_mount "-o dioread_nolock,nodelalloc" > $seqres.full 2>&1

echo "Create the original file"
touch $SCRATCH_MNT/foobar >> $seqres.full
chown nobody $SCRATCH_MNT/foobar >> $seqres.full

echo "Set hard quota"
setquota -u nobody 0 10M 0 0 $SCRATCH_MNT
_report_quota_blocks $SCRATCH_MNT >> $seqres.full

echo "Create 2 level extent tree (btree) for foobar with a unwritten extent"
$XFS_IO_PROG -f -c "pwrite 0 4k" -c "falloc 4k 4k" -c "pwrite 8k 4k" \
	     -c "pwrite 20k 4k"  -c "pwrite 28k 4k" -c "pwrite 36k 4k" \
	     -c "fsync" $SCRATCH_MNT/foobar >> $seqres.full

$XFS_IO_PROG -c "fiemap -v" $SCRATCH_MNT/foobar >> $seqres.full

echo "Convert unwritten extent to written and collapse extent tree to inode"
$XFS_IO_PROG -c "pwrite 4k 4k" $SCRATCH_MNT/foobar >> $seqres.full

echo "Create a new file and do fsync to force a jbd2 commit"
$XFS_IO_PROG -f -c "pwrite 0 4k" -c "fsync" $SCRATCH_MNT/dummy >> $seqres.full

# Use 'syncfs' instead of 'sync' here as 'sync' could have dirtied quota files
# ahead of writeback and could not reproduce the bug.
echo "sync $SCRATCH_MNT to writeback" | _filter_scratch
$XFS_IO_PROG -c "syncfs" $SCRATCH_MNT >> $seqres.full

# success, all done
status=0
exit