-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_delete.sh
89 lines (79 loc) · 1.9 KB
/
test_delete.sh
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
82
83
84
85
86
87
88
89
#!/bin/sh
MNT="/mnt"
DEV="/dev/sda9"
TRACE_PATH="/sys/kernel/debug/tracing"
TRACE_FILTER=$TRACE_PATH/set_ftrace_filter
RESULT=/home/wangsl/btrfs_vs_ext4.txt
touch $RESULT
_fail()
{
echo $1
exit 1;
}
test_prepare()
{
df -Th | grep $DEV && umount $DEV
if [ $1 = "btrfs" ];then
mkfs.btrfs -f $DEV || _fail "mkfs btrfs fails"
fi
if [ $1 = "ext4" ];then
mkfs.ext4 $DEV || _fail "mkfs ext4 fails"
fi
mount $DEV $MNT
#disable other cpu
echo 0 > /sys/devices/system/cpu/cpu1/online
echo 0 > /sys/devices/system/cpu/cpu2/online
echo 0 > /sys/devices/system/cpu/cpu3/online
}
add_btrfs_delete_filter()
{
echo __unlink_start_trans >> $TRACE_FILTER
echo btrfs_orphan_add >> $TRACE_FILTER
echo btrfs_unlink_inode >> $TRACE_FILTER
echo btrfs_end_transaction >> $TRACE_FILTER
echo btrfs_block_rsv_add >> $TRACE_FILTER
echo btrfs_commit_transaction >> $TRACE_FILTER
}
add_ext4_delete_filter()
{
echo ext4_find_entry >> $TRACE_FILTER
echo __ext4_journal_start_sb >> $TRACE_FILTER
echo ext4_orphan_add >> $TRACE_FILTER
echo ext4_delete_entry >> $TRACE_FILTER
echo ext4_mark_inode_dirty >> $TRACE_FILTER
}
function enable_ftrace()
{
# echo function >> $TRACE_PATH/current_tracer
echo 1 > /sys/kernel/debug/tracing/tracing_on
echo 1 > /sys/kernel/debug/tracing/function_profile_enabled
}
disable_ftrace()
{
echo 0 > $TRACE_PATH/function_profile_enabled
echo 0 > $TRACE_PATH/tracing_on
}
#btrfs
date >> $RESULT
test_prepare "btrfs"
add_btrfs_delete_filter
mkdir -p $MNT/btrfs
~/creat_unlink -i 100000 1 $MNT/btrfs
sync
#we only trace file removal
enable_ftrace
~/creat_unlink -r 100000 1 $MNT/btrfs >> $RESULT
#some options here
#disable_ftrace
#ext4
test_prepare "ext4"
add_ext4_delete_filter
mkdir -p $MNT/ext4
~/creat_unlink -i 100000 1 $MNT/ext4
sync
#we only trace file removal
enable_ftrace
~/creat_unlink -r 100000 1 $MNT/ext4 >> $RESULT
cat $TRACE_PATH/trace_stat/function0 >> $RESULT
#some options here
disable_ftrace