• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1FSCK_OPT=-fn
2OUT=$test_name.log
3EXP=$test_dir/expect
4CONF=$TMPFILE.conf
5
6if [ $(uname -s) = "Darwin" ]; then
7	# creates a 4TB filesystem
8	echo "$test_name: $DESCRIPTION: skipped for HFS+ (no sparse files)"
9	return 0
10fi
11
12if [ $(uname -s) = "FreeBSD" ]; then
13	# creates a 4TB filesystem
14	echo "$test_name: $DESCRIPTION: skipped for FreeBSD (no sparse files)"
15	return 0
16fi
17
18cat > $CONF << ENDL
19[fs_types]
20	hugefile = {
21		features = extent,huge_file,flex_bg,uninit_bg,dir_nlink,extra_isize,^resize_inode,sparse_super2
22		hash_alg = half_md4
23		num_backup_sb = 0
24		packed_meta_blocks = 1
25		make_hugefiles = 1
26		inode_ratio = 4194304
27		hugefiles_dir = /store
28		hugefiles_name = big-data
29		hugefiles_digits = 0
30		hugefiles_size = 0
31		hugefiles_align = 256M
32		num_hugefiles = 1
33		zero_hugefiles = false
34		flex_bg_size = 262144
35	}
36ENDL
37
38echo "mke2fs -F -T hugefile test.img 4T" > $OUT
39MKE2FS_CONFIG=$CONF $MKE2FS -F -T hugefile $TMPFILE 4T >> $OUT 2>&1
40rm -f $CONF
41
42# check the file system if we get this far, we succeeded...
43$FSCK $FSCK_OPT -N test_filesys $TMPFILE >> $OUT 2>&1
44status=$?
45echo Exit status is $status >> $OUT
46
47echo 'debugfs -R "extents /store/big-data" test.img' >> $OUT
48
49$DEBUGFS -R "extents /store/big-data" $TMPFILE 2>&1 | tr / " " | tr -d - | awk '
50BEGIN {
51	expected_logical_start = 0;
52	expected_physical_start = 0;
53}
54{
55	if (NR != 1) {
56		level = $1;
57		total_levels = $2;
58
59		if (level == total_levels) {
60			logical_start=$5;
61			logical_end=$6;
62			physical_start=$7;
63			physical_end=$8;
64			len = $9;
65
66			if (logical_end + 1 - logical_start != len) {
67				print logical_end + 1 - logical_start, len;
68				print "UNEXPECTED LENGTH for extent", $0;
69			}
70			if (physical_end + 1 - physical_start != len) {
71				print physical_end + 1 - physical_start, len;
72				print "UNEXPECTED LENGTH for extent", $0;
73			}
74
75			if (logical_start != expected_logical_start) {
76				print "UNEXPECTED LOGICAL DISCONTINUITY between extents:";
77				print "\t", prev;
78				print "\t", $0;
79			}
80			if (physical_start != expected_physical_start &&
81				expected_logical_start != 0) {
82				print "PHYSICAL DISCONTINUITY between extents:";
83				print "\t", prev;
84				print "\t", $0;
85			}
86
87			expected_logical_start = logical_end + 1;
88			expected_physical_start = physical_end + 1;
89		}
90	}
91	prev=$0;
92}
93END {
94    print "Last logical block:", expected_logical_start-1;
95    print "Last physical block:", expected_physical_start-1;
96}
97' >> $OUT 2>&1
98
99rm $TMPFILE
100
101#
102# Do the verification
103#
104
105sed -f $cmd_dir/filter.sed $OUT > $OUT.new
106mv $OUT.new $OUT
107
108cmp -s $OUT $EXP
109status=$?
110
111if [ "$status" = 0 ] ; then
112	echo "$test_name: $test_description: ok"
113	touch $test_name.ok
114else
115	echo "$test_name: $test_description: failed"
116	diff $DIFF_OPTS $EXP $OUT > $test_name.failed
117fi
118
119unset IMAGE FSCK_OPT OUT EXP CONF
120