summaryrefslogtreecommitdiff
path: root/tests/xfs/216
blob: f981151cef46d5f0c18c6b96065aaaa18ceebb46 (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
#! /bin/bash
# SPDX-License-Identifier: GPL-2.0
# Copyright (c) 2008 Silicon Graphics, Inc.  All Rights Reserved.
#
# FS QA Test No. 216
#
# log size mkfs test - ensure the log size scaling works for small filesystems
#
. ./common/preamble
_begin_fstest log metadata auto quick

# Import common functions.
. ./common/filter

# real QA test starts here
_supported_fs xfs

_require_scratch
_scratch_mkfs_xfs >/dev/null 2>&1
_scratch_mount

_require_loop
LOOP_DEV=$SCRATCH_MNT/test_fs
LOOP_MNT=$SCRATCH_MNT/test_fs_dir

loop_mkfs_opts=
$MKFS_XFS_PROG 2>&1 | grep -q rmapbt && \
	loop_mkfs_opts="$loop_mkfs_opts -m rmapbt=0"
$MKFS_XFS_PROG 2>&1 | grep -q reflink && \
	loop_mkfs_opts="$loop_mkfs_opts -m reflink=0"

# Decide which golden output file we're using.  Starting with mkfs.xfs 5.15,
# the default minimum log size was raised to 64MB for all cases, so we detect
# that by test-formatting with a 512M filesystem.  This is a little handwavy,
# but it's the best we can do.
choose_golden_output() {
	local seqfull=$1
	local file=$2

	if $MKFS_XFS_PROG -f -b size=4096 -l version=2 \
			-d name=$file,size=512m $loop_mkfs_opts | \
			grep -q 'log.*blocks=16384'; then
		_link_out_file_named $seqfull.out "64mblog"
	else
		_link_out_file_named $seqfull.out "classic"
	fi
}

_do_mkfs()
{
	for i in $*; do
		echo -n "fssize=${i}g "
		$MKFS_XFS_PROG -f -b size=4096 -l version=2 \
			-d name=$LOOP_DEV,size=${i}g $loop_mkfs_opts |grep log
		mount -o loop -t xfs $LOOP_DEV $LOOP_MNT
		echo "test write" > $LOOP_MNT/test
		umount $LOOP_MNT > /dev/null 2>&1
	done
}
# make large holey file
$XFS_IO_PROG -f -c "truncate 256g" $LOOP_DEV

choose_golden_output $0 $LOOP_DEV

#make loopback mount dir
mkdir $LOOP_MNT

# walk over standard sizes (up to 256GB)
_do_mkfs 1 2 4 8 16 32 64 128 256

status=0
exit