• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/bin/bash
2
3################################################################################
4##                                                                            ##
5## Copyright (c) 2009 FUJITSU LIMITED                                         ##
6##                                                                            ##
7## This program is free software;  you can redistribute it and#or modify      ##
8## it under the terms of the GNU General Public License as published by       ##
9## the Free Software Foundation; either version 2 of the License, or          ##
10## (at your option) any later version.                                        ##
11##                                                                            ##
12## This program is distributed in the hope that it will be useful, but        ##
13## WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY ##
14## or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License   ##
15## for more details.                                                          ##
16##                                                                            ##
17## You should have received a copy of the GNU General Public License          ##
18## along with this program;  if not, write to the Free Software Foundation,   ##
19## Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA           ##
20##                                                                            ##
21## Author: Li Zefan <lizf@cn.fujitsu.com>                                     ##
22##         Miao Xie <miaox@cn.fujitsu.com>                                    ##
23##                                                                            ##
24################################################################################
25
26export TCID="ext4-persistent-preallocation"
27export TST_TOTAL=2
28
29. ext4_funcs.sh
30
31# Use ltp's syscall/fallocate to test this feature
32# $1: 1024 or 4096
33ext4_test_persist_prealloc()
34{
35	mkfs.ext4 -I 256 -b $1 $EXT4_DEV >/dev/null 2>&1
36	if [ $? -ne 0 ]; then
37		tst_resm TFAIL "failed to create ext4 filesystem"
38		return
39	fi
40
41	mount -t ext4 $EXT4_DEV mnt_point
42	if [ $? -ne 0 ]; then
43		tst_resm TFAIL "failed to mount ext4 filesystem"
44		return
45	fi
46
47	for ((i = 1; i <= 3; i++))
48	{
49		if ! command -v fallocate0${i} > /dev/null 2>&1; then
50			tst_resm TFAIL "file - fallocate0${i} doesn't exist. Please \
51				check whether it was compiled and installed.\
52				(Path: LTPROOT/testcases/kernel/syscalls/fallocate)"
53			umount mnt_point
54			return
55		fi
56
57		temp_tmpdir=$TMPDIR
58		TMPDIR=${PWD}/mnt_point; fallocate0${i} > /dev/null 2>&1
59		ret=$?
60		TMPDIR=$temp_tmpdir
61
62		if [ $ret -ne 0 ]; then
63			tst_resm TFAIL "fallocate's return value is not expected"
64			umount mnt_point
65			return
66		fi
67	}
68
69	umount mnt_point
70	if [ $? -ne 0 ]; then
71		tst_resm TFAIL "failed to umount ext4 filesystem"
72		return
73	fi
74
75	e2fsck -p $EXT4_DEV >/dev/null 2>&1
76	if [ $? -ne 0 ]; then
77		tst_resm TFAIL "fsck returned failure"
78		return
79	fi
80
81	tst_resm TPASS "ext4 persistent preallocation test pass"
82}
83
84# main
85ext4_setup
86
87ext4_test_persist_prealloc 1024
88ext4_test_persist_prealloc 4096
89
90tst_exit
91