[patch] dmflakey: filter out 'dax' from mount options

[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]



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@xxxxxxxxxx>

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()
--
To unsubscribe from this list: send the line "unsubscribe fstests" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux Filesystems Development]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux