FS/XFS testing framework
 help / color / mirror / Atom feed
* [patch] dmflakey: filter out 'dax' from mount options
@ 2015-12-02 16:11 Jeff Moyer
  2015-12-02 20:04 ` Dave Chinner
  0 siblings, 1 reply; 3+ messages in thread
From: Jeff Moyer @ 2015-12-02 16:11 UTC (permalink / raw)
  To: fstests

Hi,

In testing with MOUNT_OPTIONS="-o dax" ./check ..., I ran into issues
with every single test that uses dmflakey.  The problem is that the
mount will fail, since we're layering a stacking driver on top of the
pmem device, and that stacking driver does not support direct access.
To fix that, I decided to filter out the dax mount option from dmflakey
mounts.  If there are suggestions for a better approach, I'm all ears.

Signed-off-by: Jeff Moyer <jmoyer@redhat.com>

diff --git a/common/dmflakey b/common/dmflakey
index e55aefd..693d231 100644
--- a/common/dmflakey
+++ b/common/dmflakey
@@ -21,6 +21,47 @@
 FLAKEY_ALLOW_WRITES=0
 FLAKEY_DROP_WRITES=1
 
+_filter_mount_opt()
+{
+	local opts=''
+	local old_opts=$1
+	local filter=$2
+
+	# If there are no options, or if the filter isn't present,
+	# just return.
+	if [ -z "$old_opts" ]; then
+		echo -n ""
+		return
+	fi
+
+	echo $old_opts | grep -q $filter
+	if [ $? -ne 0 ]; then
+		echo -n $old_opts
+		return
+	fi
+
+	# -o, --options opts
+	#      Options are specified with a -o flag followed by a  comma  sepa-
+	#      rated string of options. For example:
+	#             mount LABEL=mydisk -o noatime,nouser
+	#
+	# There are several cases we have to handle:
+	# -o dax; -o,dax
+	# -o,ro,dax; -o,dax,ro
+	# -o,ro,dax,discard
+	#
+	opts=$(echo $old_opts | sed -e "s/$filter//g")
+	opts=$(echo $opts | sed -e 's/,,/,/g')
+	opts=$(echo $opts | sed -e 's/ ,/ /g')
+	# get rid of trailing whitespace or comma
+	opts=$(echo $opts | sed -e 's/[[:space:]]$//g')
+	opts=$(echo $opts | sed -e 's/,$//g')
+	# finally, if there's nothing left, get rid of the -o
+	opts=$(echo $opts | sed -e 's/-o$//g')
+
+	echo -n $opts
+}
+
 _init_flakey()
 {
 	local BLK_DEV_SIZE=`blockdev --getsz $SCRATCH_DEV`
@@ -34,7 +75,8 @@ _init_flakey()
 
 _mount_flakey()
 {
-	mount -t $FSTYP $MOUNT_OPTIONS $FLAKEY_DEV $SCRATCH_MNT
+	mount_options=$(_filter_mount_opt "$MOUNT_OPTIONS" dax)
+	mount -t $FSTYP $mount_options $FLAKEY_DEV $SCRATCH_MNT
 }
 
 _unmount_flakey()

^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2015-12-02 21:41 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-12-02 16:11 [patch] dmflakey: filter out 'dax' from mount options Jeff Moyer
2015-12-02 20:04 ` Dave Chinner
2015-12-02 21:41   ` Jeff Moyer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox