Patchwork [1/4] large-fs: fix large_fs space detection

login
register
mail settings
Submitter Dmitri Monakho
Date July 9, 2013, 11:05 a.m.
Message ID <1373367918-7516-1-git-send-email-dmonakhov@openvz.org>
Download mbox | patch
Permalink /patch/257698/
State Not Applicable
Headers show

Comments

Dmitri Monakho - July 9, 2013, 11:05 a.m.
Currenly large_fs check compare $SCRATCH_DEV_EMPTY_SPACE and $fs_size
which is not correct because total empty size required is $SCRATCH_DEV_EMPTY_SPACE + 50Gb
This path fix space detection, so check becomes valid for all situations.

Signed-off-by: Dmitry Monakhov <dmonakhov@openvz.org>
---
 common/rc |   27 +++++++++++++++------------
 1 files changed, 15 insertions(+), 12 deletions(-)
Dave Chinner - July 11, 2013, 12:54 a.m.
On Tue, Jul 09, 2013 at 03:05:15PM +0400, Dmitry Monakhov wrote:
> Currenly large_fs check compare $SCRATCH_DEV_EMPTY_SPACE and $fs_size
> which is not correct because total empty size required is $SCRATCH_DEV_EMPTY_SPACE + 50Gb
> This path fix space detection, so check becomes valid for all situations.

I'm not sure what problem you're fixing from this description?

It's takenme a few minutes to work out that:

"If SCRATCH_DEV_EMPTY_SPACE + 50GB is larger than the filesystem
size being tested, then the configuration being tested is invalid
and should fail. Currently we only check that
SCRATCH_DEV_EMPTY_SPACE is greater than the the filesystem size. Fix
it to check the combined empty space fits in the filesystem being
tested."

Otherwise the change looks good.

Reviewed-by: Dave Chinner <dchinner@redhat.com>

Patch

diff --git a/common/rc b/common/rc
index fe6bbfc..c44acea 100644
--- a/common/rc
+++ b/common/rc
@@ -306,16 +306,17 @@  _setup_large_xfs_fs()
 {
 	fs_size=$1
 	local tmp_dir=/tmp/
+	# Default free space in the FS is 50GB, but you can specify more via
+	# SCRATCH_DEV_EMPTY_SPACE
+	fs_empty_space=$((50*1024*1024*1024))
 
 	[ "$LARGE_SCRATCH_DEV" != yes ] && return 0
-	[ -z "$SCRATCH_DEV_EMPTY_SPACE" ] && SCRATCH_DEV_EMPTY_SPACE=0
-	[ $SCRATCH_DEV_EMPTY_SPACE -ge $fs_size ] && return 0
+	[ -z "$SCRATCH_DEV_EMPTY_SPACE" ] && SCRATCH_DEV_EMPTY_SPACE=0	
+	fs_empty_space=$((fs_empty_space + $SCRATCH_DEV_EMPTY_SPACE))
+	[ $fs_empty_space -ge $fs_size ] && return 0
 
 	# calculate the size of the file we need to allocate.
-	# Default free space in the FS is 50GB, but you can specify more via
-	# SCRATCH_DEV_EMPTY_SPACE
-	file_size=$(($fs_size - 50*1024*1024*1024))
-	file_size=$(($file_size - $SCRATCH_DEV_EMPTY_SPACE))
+	file_size=$(($fs_size - $fs_empty_space))
 
 	# mount the filesystem, create the file, unmount it
 	_scratch_mount 2>&1 >$tmp_dir/mnt.err
@@ -434,15 +435,17 @@  _setup_large_ext4_fs()
 {
 	fs_size=$1
 	local tmp_dir=/tmp/
-
-	[ "$LARGE_SCRATCH_DEV" != yes ] && return 0
-	[ -z "$SCRATCH_DEV_EMPTY_SPACE" ] && SCRATCH_DEV_EMPTY_SPACE=0
-	[ $SCRATCH_DEV_EMPTY_SPACE -ge $fs_size ] && return 0
-
 	# Default free space in the FS is 50GB, but you can specify more via
 	# SCRATCH_DEV_EMPTY_SPACE
-	space_to_consume=$(($fs_size - 50*1024*1024*1024 - $SCRATCH_DEV_EMPTY_SPACE))
+	fs_empty_space=$((50*1024*1024*1024))
 
+	[ "$LARGE_SCRATCH_DEV" != yes ] && return 0
+	[ -z "$SCRATCH_DEV_EMPTY_SPACE" ] && SCRATCH_DEV_EMPTY_SPACE=0	
+	fs_empty_space=$((fs_empty_space + $SCRATCH_DEV_EMPTY_SPACE))
+	[ $fs_empty_space -ge $fs_size ] && return 0
+
+	# calculate the size of the file we need to allocate.
+	space_to_consume=$(($fs_size - $fs_empty_space))
 	# mount the filesystem and create 16TB - 4KB files until we consume
 	# all the necessary space.
 	_scratch_mount 2>&1 >$tmp_dir/mnt.err