public inbox for linux-xfs@vger.kernel.org
 help / color / mirror / Atom feed
From: ranto.boris@gmail.com
To: xfs@oss.sgi.com
Cc: Boris Ranto <ranto.boris@gmail.com>
Subject: [PATCH 1/3] xfstests: Add tmpfs support
Date: Thu,  2 May 2013 16:03:57 +0200	[thread overview]
Message-ID: <1367503439-12827-2-git-send-email-ranto.boris@gmail.com> (raw)
In-Reply-To: <1367503439-12827-1-git-send-email-ranto.boris@gmail.com>

From: Boris Ranto <ranto.boris@gmail.com>

This is just a simple patch to get the tmpfs working as a target file
system. The patch copies the way nfs is handled in xfstests.

I didn't change the xfstests logic to recognize a proper SCRATCH_DEV.
Hence, the SCRATCH_DEV for tmpfs should be in nfs form (with ':' sign
in it) in order for this to work properly.

Signed-off-by: Boris Ranto <ranto.boris@gmail.com>
---
 check     |    2 ++
 common/rc |   55 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 57 insertions(+), 0 deletions(-)

diff --git a/check b/check
index 966fbe5..fc335ec 100755
--- a/check
+++ b/check
@@ -76,6 +76,7 @@ check options
     -xfs                test XFS (default)
     -udf                test UDF
     -nfs                test NFS
+    -tmpfs              test TMPFS
     -l			line mode diff
     -udiff		show unified diff (default)
     -n			show me, do not run tests
@@ -162,6 +163,7 @@ while [ $# -gt 0 ]; do
 	-udf)	FSTYP=udf ;;
 	-xfs)	FSTYP=xfs ;;
 	-nfs)	FSTYP=nfs ;;
+	-tmpfs)	FSTYP=tmpfs ;;
 
 	-g)	group=$2 ; shift ;
 		group_list=$(get_group_list $group)
diff --git a/common/rc b/common/rc
index 8e37368..4825371 100644
--- a/common/rc
+++ b/common/rc
@@ -97,6 +97,10 @@ _mount_opts()
 	# acls aren't turned on by default on gfs2
 	export MOUNT_OPTIONS="-o acl $GFS2_MOUNT_OPTIONS"
 	;;
+    tmpfs)
+	# We need to specify the size at mount, use 512 MB by default
+	export MOUNT_OPTIONS="-o size=512M $TMPFS_MOUNT_OPTIONS"
+	;;
     *)
 	;;
     esac
@@ -125,6 +129,9 @@ _mkfs_opts()
     jfs)
 	export MKFS_OPTIONS="$JFS_MKFS_OPTIONS -q"
 	;;
+    tmpfs)
+	export MKFS_OPTIONS="$TMPFS_MKFS_OPTIONS"
+	;;
     *)
 	;;
     esac
@@ -520,6 +527,9 @@ _scratch_mkfs()
     ext4)
 	_scratch_mkfs_ext4 $*
 	;;
+    tmpfs)
+	# do nothing for tmpfs
+	;;
     *)
 	yes | $MKFS_PROG -t $FSTYP -- $MKFS_OPTIONS $* $SCRATCH_DEV
 	;;
@@ -930,6 +940,12 @@ _require_scratch()
 		     _notrun "this test requires a valid \$SCRATCH_DEV"
 		 fi
 		 ;;
+	tmpfs)
+		if [ -z "$SCRATCH_DEV" -o ! -d "$SCRATCH_MNT" ];
+		then
+		    _notrun "this test requires a valid \$SCRATCH_MNT and unique $SCRATCH_DEV"
+		fi
+		;;
 	*)
 		 if [ -z "$SCRATCH_DEV" -o "`_is_block_dev $SCRATCH_DEV`" = "" ]
 		 then
@@ -1626,6 +1642,9 @@ _check_test_fs()
     btrfs)
 	_check_btrfs_filesystem $TEST_DEV
 	;;
+    tmpfs)
+	# no way to check the consistency of tmpfs
+	;;
     *)
 	_check_generic_filesystem $TEST_DEV
 	;;
@@ -1655,6 +1674,9 @@ _check_scratch_fs()
     btrfs)
 	_check_btrfs_filesystem $SCRATCH_DEV
 	;;
+    tmpfs)
+	# No way to check the consistency of tmpfs
+	;;
     *)
 	_check_generic_filesystem $SCRATCH_DEV
 	;;
@@ -1743,6 +1765,32 @@ _setup_nfs_scratchdir()
     testdir=$SCRATCH_MNT
 }
 
+_setup_tmpfs_scratchdir()
+{
+    [ "$FSTYP" != "tmpfs" ] \
+        && _fail "setup_tmpfs_testdir: \$FSTYP is not tmpfs"
+    [ -z "$SCRATCH_DEV" ] \
+	&& _notrun "this test requires a valid host fs for \$SCRATCH_DEV"
+    [ -z "$SCRATCH_MNT" ] \
+	&& _notrun "this test requires a valid \$SCRATCH_MNT"
+
+    # mounted?
+    if _mount | grep -q $SCRATCH_DEV
+    then
+        # if it's mounted, make sure its on $SCRATCH_MNT
+        if ! _mount | grep $SCRATCH_DEV | grep -q $SCRATCH_MNT
+        then
+            _fail "\$SCRATCH_DEV is mounted but not on \$SCRATCH_MNT - aborting"
+        fi
+        $UMOUNT_PROG $SCRATCH_DEV
+    fi
+
+    _scratch_mkfs
+    _scratch_mount
+
+    testdir=$SCRATCH_MNT
+}
+
 #
 # Warning for UDF and NFS:
 # this function calls _setup_udf_scratchdir and _setup_udf_scratchdir
@@ -1761,6 +1809,9 @@ _setup_testdir()
     nfs*)
 	_setup_nfs_scratchdir
 	;;
+    tmpfs)
+	_setup_tmpfs_scratchdir
+	;;
     *)
 	testdir=$TEST_DIR
 	;;
@@ -1778,6 +1829,10 @@ _cleanup_testdir()
 	# umount testdir as it is $SCRATCH_MNT which could be used by xfs next
 	[ -n "$testdir" ] && $UMOUNT_PROG $testdir
 	;;
+    tmpfs)
+	# umount testdir since it is actually a scrath mount
+	[ -n "$testdir" ] && $UMOUNT_PROG $testdir
+	;;
     *)
 	# do nothing, testdir is $TEST_DIR
 	:
-- 
1.7.1

_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

  reply	other threads:[~2013-05-02 14:04 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-05-02 14:03 [PATCH 0/3] Tmpfs support and fixes for tmpfs/nfs ranto.boris
2013-05-02 14:03 ` ranto.boris [this message]
2013-05-02 14:03 ` [PATCH 2/3] xfstests: Do not fail on non-existing tests/FSTYP directory ranto.boris
2013-05-02 14:03 ` [PATCH 3/3] xfstests: Do not fail on empty exclude groups ranto.boris
2013-05-13 12:57 ` [PATCH 0/3] Tmpfs support and fixes for tmpfs/nfs Boris Ranto

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1367503439-12827-2-git-send-email-ranto.boris@gmail.com \
    --to=ranto.boris@gmail.com \
    --cc=xfs@oss.sgi.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox