-
Notifications
You must be signed in to change notification settings - Fork 202
/
ext4-frags
executable file
·39 lines (35 loc) · 1.13 KB
/
ext4-frags
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
#!/bin/sh
# Author: Theodore Ts'o <[email protected]>
#
# For future reference, there are a couple of things that are of
# interest to ext4 developers when trying to create repro's:
#
# 1) The use of mounting with ext2 to speed up the setup.
#
# 2) The first two "seq ... | xargs ..." commands to create a very
# fragmented file system.
#
# 3) Using a 1k block size file system to stress the extent tree code
# and htree directory (since its easier to make larger tree structure).
#
# 4) The use of the mount option commit=10000 to test what happens when
# the journal is full (without using a nice, fast device such as RAID array
# or without burning write cycles on an expensive flash device.)
[ $nr_partitions -ge 1 ] || exit
partition=${partitions%% *}
mnt=/mnt
mkdir -p $mnt
mke2fs -t ext4 -b 1024 -J size=1 -q $partition
mount -t ext2 $partition $mnt 2>/dev/null ||
mount -t ext4 $partition $mnt || exit
mkdir $mnt/a
cd $mnt/a
seq 1 210000 | xargs -n 1 fallocate -l 1m
seq 1 2 210000 | xargs /bin/rm
mkdir $mnt/b
cd $mnt/b
seq 1 103 | xargs -n 1 fallocate -l 1g
cd /
umount $mnt
mount -t ext4 -o commit=10000 $partition $mnt
rm -rf $mnt/b