summaryrefslogtreecommitdiff
path: root/tests/xfs/062
blob: 0a1c6742a32e15b3bce4dc65ae6b96aa45a7c228 (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
78
79
80
#! /bin/bash
# SPDX-License-Identifier: GPL-2.0
# Copyright (c) 2014 Red Hat, Inc.  All Rights Reserved.
#
# FS QA Test No. 062
#
# Use the bstat utility to verify bulkstat finds all inodes in a filesystem.
# Test under various inode counts, inobt record layouts and bulkstat batch
# sizes.
#
. ./common/preamble
_begin_fstest auto ioctl quick

# print the number of inodes counted by bulkstat
_bstat_count()
{
	batchsize=$1
	$here/src/bstat $SCRATCH_MNT $batchsize | grep ino | wc -l
}

# print bulkstat counts using varied batch sizes
_bstat_test()
{
	expect=`find $SCRATCH_MNT -print | wc -l`
	echo "expect $expect"

	_bstat_count 4096
	_bstat_count 32
	_bstat_count 1
}

# Import common functions.
. ./common/filter

_require_scratch

# real QA test starts here

_supported_fs xfs

DIRCOUNT=8
INOCOUNT=$((2048 / DIRCOUNT))

_scratch_mkfs "-d agcount=$DIRCOUNT" >> $seqres.full 2>&1 || _fail "mkfs failed"
_scratch_mount

# create a set of directories and fill each with a fixed number of files
for dir in $(seq 1 $DIRCOUNT); do
	mkdir -p $SCRATCH_MNT/$dir
	for i in $(seq 1 $INOCOUNT); do
		touch $SCRATCH_MNT/$dir/$i
	done
done
_bstat_test

# remove every other file from each dir
for dir in $(seq 1 $DIRCOUNT); do
	for i in $(seq 2 2 $INOCOUNT); do
		rm -f $SCRATCH_MNT/$dir/$i
	done
done
_bstat_test

# remove the entire second half of files
for dir in $(seq 1 $DIRCOUNT); do
	for i in $(seq $((INOCOUNT / 2)) $INOCOUNT); do
		rm -f $SCRATCH_MNT/$dir/$i
	done
done
_bstat_test

# remove all regular files
for dir in $(seq 1 $DIRCOUNT); do
	rm -f $SCRATCH_MNT/$dir/*
done
_bstat_test

# success, all done
status=0
exit