File: dmstats-filemap.sh

package info (click to toggle)
lvm2 2.03.31-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 15,920 kB
  • sloc: ansic: 180,675; sh: 42,231; python: 6,554; makefile: 2,079; cpp: 1,258; ruby: 66; awk: 20
file content (81 lines) | stat: -rw-r--r-- 1,892 bytes parent folder | download
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
81
#!/usr/bin/env bash

# Copyright (C) 2023 Red Hat, Inc. All rights reserved.
#
# This copyrighted material is made available to anyone wishing to use,
# modify, copy, or redistribute it subject to the terms and conditions
# of the GNU General Public License v.2.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software Foundation,
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA

SKIP_WITH_LVMPOLLD=1
SKIP_WITH_LVMLOCKD=1

. lib/inittest

which mkfs.xfs || skip

# Don't attempt to test stats with driver < 4.33.00
aux driver_at_least 4 33 || skip

# ensure we can create devices (uses dmsetup, etc)
aux prepare_devs 1 2048

mount_dir="mnt"
hist_bounds="10ms,20ms,30ms"
file_size="100m"

test ! -d "$mount_dir" && mkdir "$mount_dir"

cleanup_mounted_and_teardown()
{
	umount "$mount_dir" 2>/dev/null || true
	aux teardown
}

trap 'cleanup_mounted_and_teardown' EXIT

mkfs.xfs "$dev1"
mount "$dev1" "$mount_dir"

test_filemap()
{
	local map_file="$1"
	local use_precise="$2"
	local use_bounds="$3"
	if [[ $use_precise == 1 ]]; then
		precise="--precise"
	else
		precise=""
	fi
	if [[ $use_bounds == 1 ]]; then
		bounds="--bounds $hist_bounds"
	else
		bounds=""
	fi
	fallocate -l "$file_size" "$mount_dir/$map_file"
	dmstats create ${precise} ${bounds} --filemap "$mount_dir/$map_file"
	dmstats list -ostats_name,precise |& tee out
	grep "$map_file" out
	if [[ $use_precise == 1 ]]; then
		grep "1" out
	fi
	if [[ $use_bounds == 1 ]]; then
		dmstats list -ostats_name,hist_bounds |& tee out
		grep "$hist_bounds" out
	fi
	dmstats delete --allregions --alldevices
	rm -f "$mount_dir/$map_file"
}

for file in "filenospace" "File With Spaces" "$(echo -ne 'file\twith\ttabs')"; do
	for precise in 0 1; do
		for bounds in 0 1; do
			test_filemap "$file" "$precise" "$bounds"
		done
	done
done

sleep .5