Blob Blame History Raw
From c858a0817715a5ce43928806ad6a5e41c0dcb851 Mon Sep 17 00:00:00 2001
From: "Luis R. Rodriguez" <mcgrof@suse.com>
Date: Fri, 25 May 2018 15:05:24 -0700
Subject: [PATCH] xfs: add option to mount with barrier=0 or barrier=1
Patch-mainline: Never, SLE-specific
References: bsc#1093839

Commit 2e74af0e118 ("xfs: convert mount option parsing to tokens")
used the generic kernel tokenizer for mount options instead of open
coding them. In doing so a few mount options lost the ability to
suppor the option for setting value to 1 or 0 when they were intended
to just be setters.

We have old userspace tools which still use the barrier optiona as follows:

 # mount -t xfs -o barrier=0 /dev/loop16 /mnt

Note that commit 4cf4573d899 ("xfs: deprecate barrier/nobarrier mount
option") clarifies that we now always always perform integrity operations now
and so the barrier options don't do anything anymore.

We just provide backward compatibility.

Signed-off-by: Luis R. Rodriguez <mcgrof@suse.com>
---
 fs/xfs/xfs_super.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/fs/xfs/xfs_super.c b/fs/xfs/xfs_super.c
index 6fd948774f2c..d20552fac671 100644
--- a/fs/xfs/xfs_super.c
+++ b/fs/xfs/xfs_super.c
@@ -82,6 +82,7 @@ enum {
 	Opt_wsync, Opt_noalign, Opt_swalloc, Opt_sunit, Opt_swidth, Opt_nouuid,
 	Opt_mtpt, Opt_grpid, Opt_nogrpid, Opt_bsdgroups, Opt_sysvgroups,
 	Opt_allocsize, Opt_norecovery, Opt_barrier, Opt_nobarrier,
+	Opt_barrierl,
 	Opt_inode64, Opt_inode32, Opt_ikeep, Opt_noikeep,
 	Opt_largeio, Opt_nolargeio, Opt_attr2, Opt_noattr2, Opt_filestreams,
 	Opt_quota, Opt_noquota, Opt_usrquota, Opt_grpquota, Opt_prjquota,
@@ -141,6 +142,7 @@ static const match_table_t tokens = {
 	{Opt_barrier,	"barrier"},	/* use writer barriers for log write and
 					 * unwritten extent conversion */
 	{Opt_nobarrier,	"nobarrier"},	/* .. disable */
+	{Opt_barrierl,	"barrier=%u"},	/* legacy support for old interface */
 
 	{Opt_err,	NULL},
 };
@@ -201,6 +203,7 @@ xfs_parseargs(
 	int			dswidth = 0;
 	int			iosize = 0;
 	uint8_t			iosizelog = 0;
+	int			barrierl = 0;
 
 	/*
 	 * set up the mount name first so all the errors will refer to the
@@ -384,6 +387,15 @@ xfs_parseargs(
 			xfs_warn(mp, "%s option is deprecated, ignoring.", p);
 			mp->m_flags &= ~XFS_MOUNT_BARRIER;
 			break;
+		case Opt_barrierl:
+			if (match_int(args, &barrierl))
+				return -EINVAL;
+			xfs_warn(mp, "%s option is deprecated, ignoring.", p);
+			if (barrierl)
+				mp->m_flags |= XFS_MOUNT_BARRIER;
+			else
+				mp->m_flags &= ~XFS_MOUNT_BARRIER;
+			break;
 		default:
 			xfs_warn(mp, "unknown mount option [%s].", p);
 			return -EINVAL;
@@ -1269,6 +1269,7 @@
 	substring_t		args[MAX_OPT_ARGS];
 	char			*p;
 	int			error;
+	int			barrierl = 0;
 
 	/* First, check for complete junk; i.e. invalid options */
 	error = xfs_test_remount_options(sb, mp, options);
@@ -1292,6 +1293,15 @@
 			xfs_warn(mp, "%s option is deprecated, ignoring.", p);
 			mp->m_flags &= ~XFS_MOUNT_BARRIER;
 			break;
+		case Opt_barrierl:
+			if (match_int(args, &barrierl))
+				return -EINVAL;
+			xfs_warn(mp, "%s option is deprecated, ignoring.", p);
+			if (barrierl)
+				mp->m_flags |= XFS_MOUNT_BARRIER;
+			else
+				mp->m_flags &= ~XFS_MOUNT_BARRIER;
+			break;
 		case Opt_inode64:
 			mp->m_flags &= ~XFS_MOUNT_SMALL_INUMS;
 			mp->m_maxagi = xfs_set_inode_alloc(mp, sbp->sb_agcount);