From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from imap.thunk.org ([74.207.234.97]:36000 "EHLO imap.thunk.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751343AbcBKF41 (ORCPT ); Thu, 11 Feb 2016 00:56:27 -0500 From: "Theodore Ts'o" Subject: [PATCH 02/13] common: _scratch_mkfs_sized() for tmpfs Date: Thu, 11 Feb 2016 00:56:11 -0500 Message-Id: <1455170182-32587-3-git-send-email-tytso@mit.edu> In-Reply-To: <1455170182-32587-1-git-send-email-tytso@mit.edu> References: <1455170182-32587-1-git-send-email-tytso@mit.edu> Sender: fstests-owner@vger.kernel.org To: fstests@vger.kernel.org Cc: hughd@google.com, Junho Ryu , Theodore Ts'o List-ID: From: Hugh Dickins Enable _scratch_mkfs_sized() for use with tmpfs, so that tests which use this helper can now run. Signed-off-by: Hugh Dickins Signed-off-by: Junho Ryu Signed-off-by: Theodore Ts'o --- common/rc | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/common/rc b/common/rc index 76e02e4..10aaf35 100644 --- a/common/rc +++ b/common/rc @@ -783,6 +783,12 @@ _scratch_pool_mkfs() esac } +# Return the amount of free memory available on the system +_free_memory_bytes() +{ + free -b | grep ^Mem | awk '{print $4}' +} + # Create fs of certain size on scratch device # _scratch_mkfs_sized [optional blocksize] _scratch_mkfs_sized() @@ -813,7 +819,7 @@ _scratch_mkfs_sized() blocks=`expr $fssize / $blocksize` - if [ "$HOSTOS" == "Linux" ]; then + if [ "$HOSTOS" == "Linux" -a -b "$SCRATCH_DEV" ]; then devsize=`blockdev --getsize64 $SCRATCH_DEV` [ "$fssize" -gt "$devsize" ] && _notrun "Scratch device too small" fi @@ -849,6 +855,13 @@ _scratch_mkfs_sized() sector_size=`blockdev --getss $SCRATCH_DEV` $MKFS_F2FS_PROG $MKFS_OPTIONS $SCRATCH_DEV `expr $fssize / $sector_size` ;; + tmpfs) + free_mem=`_free_memory_bytes` + if [ "$free_mem" -lt "$fssize" ] ; then + _notrun "Not enough memory ($free_mem) for tmpfs with $fssize bytes" + fi + export MOUNT_OPTIONS="-o size=$fssize $TMPFS_MOUNT_OPTIONS" + ;; *) _notrun "Filesystem $FSTYP not supported in _scratch_mkfs_sized" ;; -- 2.5.0