summaryrefslogtreecommitdiff
path: root/tests/ext4/046
blob: 5c2100ce92538193098a2cf8b847417c6faf392e (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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#! /bin/bash
# SPDX-License-Identifier: GPL-2.0
# Copyright (c) 2020 IBM Corporation. All Rights Reserved.
#
# FS QA Test No. ext4/046
#
# Test writes to falloc file with filesize > 4GB and make sure to verify
# the file checksum both before and after mount.
# This test is to check whether unwritten extents gets properly converted
# to written extent on a filesystem with bs < ps with dioread_nolock.
#
. ./common/preamble
_begin_fstest auto prealloc quick

# Import common functions.
. ./common/filter

_require_check_dmesg
_supported_fs ext4
_require_scratch
_require_xfs_io_command "falloc"
_require_scratch_size $((6 * 1024 * 1024)) #kB

_scratch_mkfs >> $seqres.full 2>&1
if ! _try_scratch_mount "-o dioread_nolock" >> $seqres.full 2>&1; then
	err_str="can't mount with dioread_nolock if block size != PAGE_SIZE"
	_check_dmesg_for ${err_str}
	if [ $? -eq 0 ]; then
		_notrun "mount failed, ext4 doesn't support bs < ps with dioread_nolock"
	else
		_fail "mount failed with dioread_nolock"
	fi
fi

# Get blksz
blksz=$(_get_file_block_size $SCRATCH_MNT)

testfile=$SCRATCH_MNT/testfile-$seq

# Fallocate testfile with size > 4G
fsize=$((5 * 1024 * 1024 * 1024))
$XFS_IO_PROG -f -c "falloc 0 $fsize" $testfile >> $seqres.full 2>&1

# First write at offset < 4G (at few alternative blks)
off=$((3 * 1024 * 1024 * 1024))
for i in 1 2 3 4; do
	$XFS_IO_PROG -f \
		-c "pwrite $off $blksz" \
		$testfile >> $seqres.full 2>&1
	off=$(($off + (2*$blksz)))
done

# Then write at offset > 4G (at few alternative blks) to check
# any 32bit overflow case in map.m_lblk
off=$((4 * 1024 * 1024 * 1024))
for i in 1 2 3 4; do
	$XFS_IO_PROG -f \
		-c "pwrite $off $blksz" \
		$testfile >> $seqres.full 2>&1
	off=$(($off + (2*$blksz)))
done

# ==== Pre-Remount ===
md5_pre=`md5sum $testfile | cut -d' ' -f1`
echo "Pre-Remount md5sum of $testfile = $md5_pre" >> $seqres.full

_scratch_cycle_mount

# ==== Post-Remount ===
md5_post=`md5sum $testfile | cut -d' ' -f1`
echo "Post-Remount md5sum of $testfile = $md5_post" >> $seqres.full
test $md5_pre != $md5_post && echo "md5sum mismatch"

# success, all done
echo "Silence is golden"
status=0
exit