All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] xfs: cleanup the mount options
@ 2012-06-27 16:57 Wanlong Gao
  2012-06-27 17:44 ` Christoph Hellwig
  2012-06-29 18:06 ` [PATCH 1/2 V2] " Wanlong Gao
  0 siblings, 2 replies; 31+ messages in thread
From: Wanlong Gao @ 2012-06-27 16:57 UTC (permalink / raw)
  To: xfs; +Cc: hch, bpm, Wanlong Gao

remove the mount options macro, use tokens instead.
Futher cleanup will use xfs_*_opt in xfs instead,
but it may be hard to be merged in one patch.

Signed-off-by: Wanlong Gao <gaowanlong@cn.fujitsu.com>
---
 fs/xfs/xfs_mount.h |    3 +
 fs/xfs/xfs_super.c |  605 ++++++++++++++++++++++++++++------------------------
 2 files changed, 330 insertions(+), 278 deletions(-)

diff --git a/fs/xfs/xfs_mount.h b/fs/xfs/xfs_mount.h
index 8724336..af6b52e0 100644
--- a/fs/xfs/xfs_mount.h
+++ b/fs/xfs/xfs_mount.h
@@ -251,6 +251,9 @@ typedef struct xfs_mount {
 						   allocator */
 #define XFS_MOUNT_NOATTR2	(1ULL << 25)	/* disable use of attr2 format */
 
+#define xfs_set_opt(o, opt)	((o)->m_flags |= XFS_MOUNT_##opt)
+#define xfs_clear_opt(o, opt)	((o)->m_flags &= ~XFS_MOUNT_##opt)
+#define xfs_test_opt(o, opt)	((o)->m_flags & XFS_MOUNT_##opt)
 
 /*
  * Default minimum read and write sizes.
diff --git a/fs/xfs/xfs_super.c b/fs/xfs/xfs_super.c
index 0d9de41..3da1090 100644
--- a/fs/xfs/xfs_super.c
+++ b/fs/xfs/xfs_super.c
@@ -66,66 +66,74 @@ static const struct super_operations xfs_super_operations;
 static kmem_zone_t *xfs_ioend_zone;
 mempool_t *xfs_ioend_pool;
 
-#define MNTOPT_LOGBUFS	"logbufs"	/* number of XFS log buffers */
-#define MNTOPT_LOGBSIZE	"logbsize"	/* size of XFS log buffers */
-#define MNTOPT_LOGDEV	"logdev"	/* log device */
-#define MNTOPT_RTDEV	"rtdev"		/* realtime I/O device */
-#define MNTOPT_BIOSIZE	"biosize"	/* log2 of preferred buffered io size */
-#define MNTOPT_WSYNC	"wsync"		/* safe-mode nfs compatible mount */
-#define MNTOPT_NOALIGN	"noalign"	/* turn off stripe alignment */
-#define MNTOPT_SWALLOC	"swalloc"	/* turn on stripe width allocation */
-#define MNTOPT_SUNIT	"sunit"		/* data volume stripe unit */
-#define MNTOPT_SWIDTH	"swidth"	/* data volume stripe width */
-#define MNTOPT_NOUUID	"nouuid"	/* ignore filesystem UUID */
-#define MNTOPT_MTPT	"mtpt"		/* filesystem mount point */
-#define MNTOPT_GRPID	"grpid"		/* group-ID from parent directory */
-#define MNTOPT_NOGRPID	"nogrpid"	/* group-ID from current process */
-#define MNTOPT_BSDGROUPS    "bsdgroups"    /* group-ID from parent directory */
-#define MNTOPT_SYSVGROUPS   "sysvgroups"   /* group-ID from current process */
-#define MNTOPT_ALLOCSIZE    "allocsize"    /* preferred allocation size */
-#define MNTOPT_NORECOVERY   "norecovery"   /* don't run XFS recovery */
-#define MNTOPT_BARRIER	"barrier"	/* use writer barriers for log write and
-					 * unwritten extent conversion */
-#define MNTOPT_NOBARRIER "nobarrier"	/* .. disable */
-#define MNTOPT_64BITINODE   "inode64"	/* inodes can be allocated anywhere */
-#define MNTOPT_IKEEP	"ikeep"		/* do not free empty inode clusters */
-#define MNTOPT_NOIKEEP	"noikeep"	/* free empty inode clusters */
-#define MNTOPT_LARGEIO	   "largeio"	/* report large I/O sizes in stat() */
-#define MNTOPT_NOLARGEIO   "nolargeio"	/* do not report large I/O sizes
-					 * in stat(). */
-#define MNTOPT_ATTR2	"attr2"		/* do use attr2 attribute format */
-#define MNTOPT_NOATTR2	"noattr2"	/* do not use attr2 attribute format */
-#define MNTOPT_FILESTREAM  "filestreams" /* use filestreams allocator */
-#define MNTOPT_QUOTA	"quota"		/* disk quotas (user) */
-#define MNTOPT_NOQUOTA	"noquota"	/* no quotas */
-#define MNTOPT_USRQUOTA	"usrquota"	/* user quota enabled */
-#define MNTOPT_GRPQUOTA	"grpquota"	/* group quota enabled */
-#define MNTOPT_PRJQUOTA	"prjquota"	/* project quota enabled */
-#define MNTOPT_UQUOTA	"uquota"	/* user quota (IRIX variant) */
-#define MNTOPT_GQUOTA	"gquota"	/* group quota (IRIX variant) */
-#define MNTOPT_PQUOTA	"pquota"	/* project quota (IRIX variant) */
-#define MNTOPT_UQUOTANOENF "uqnoenforce"/* user quota limit enforcement */
-#define MNTOPT_GQUOTANOENF "gqnoenforce"/* group quota limit enforcement */
-#define MNTOPT_PQUOTANOENF "pqnoenforce"/* project quota limit enforcement */
-#define MNTOPT_QUOTANOENF  "qnoenforce"	/* same as uqnoenforce */
-#define MNTOPT_DELAYLOG    "delaylog"	/* Delayed logging enabled */
-#define MNTOPT_NODELAYLOG  "nodelaylog"	/* Delayed logging disabled */
-#define MNTOPT_DISCARD	   "discard"	/* Discard unused blocks */
-#define MNTOPT_NODISCARD   "nodiscard"	/* Do not discard unused blocks */
-
 /*
  * Table driven mount option parser.
- *
- * Currently only used for remount, but it will be used for mount
- * in the future, too.
  */
 enum {
-	Opt_barrier, Opt_nobarrier, Opt_err
+	Opt_logbufs, Opt_logbsize, Opt_logdev, Opt_rtdev, Opt_biosize,
+	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_inode64, Opt_ikeep, Opt_noikeep, Opt_largeio,
+	Opt_nolargeio, Opt_attr2, Opt_noattr2, Opt_filestreams, Opt_quota,
+	Opt_noquota, Opt_usrquota, Opt_grpquota, Opt_prjquota, Opt_uquota,
+	Opt_gquota, Opt_pquota, Opt_uqnoenf, Opt_gqnoenf, Opt_pqnoenf,
+	Opt_qnoenf, Opt_delaylog, Opt_nodelaylog, Opt_discard, Opt_nodiscard,
+	Opt_ihashsize, Opt_osyncisdsync, Opt_osyncisosync, Opt_irixsgid,
+	Opt_err
 };
 
 static const match_table_t tokens = {
-	{Opt_barrier, "barrier"},
-	{Opt_nobarrier, "nobarrier"},
+	{Opt_logbufs, "logbufs=%d"},	/* number of XFS log buffers */
+	{Opt_logbsize, "logbsize=%s"},	/* size of XFS log buffers */
+	{Opt_logdev, "logdev=%s"},	/* log device */
+	{Opt_rtdev, "rtdev=%s"},	/* realtime I/O device */
+	{Opt_biosize, "biosize=%d"},	/* log2 of preferred buffered io size */
+	{Opt_wsync, "wsync"},		/* safe-mode nfs compatible mount */
+	{Opt_noalign, "noalign"},	/* turn off stripe alignment */
+	{Opt_swalloc, "swalloc"},	/* turn on stripe width allocation */
+	{Opt_sunit, "sunit=%d"},	/* data volume stripe unit */
+	{Opt_swidth, "swidth=%d"},	/* data volume stripe width */
+	{Opt_nouuid, "nouuid"},		/* ignore filesystem UUID */
+	{Opt_mtpt, "mtpt"},		/* filesystem mount point */
+	{Opt_grpid, "grpid"},		/* group-ID from parent directory */
+	{Opt_nogrpid, "nogrpid"},	/* group-ID from current process */
+	{Opt_bsdgroups, "bsdgroups"},	/* group-ID from parent directory */
+	{Opt_sysvgroups, "sysvgroups"},	/* group-ID from current process */
+	{Opt_allocsize, "allocsize=%s"},/* preferred allocation size */
+	{Opt_norecovery, "norecovery"},	/* do not run XFS recovery */
+	{Opt_barrier, "barrier"},	/* use writer barrier for log write and
+					 * unwritten extent conversation */
+	{Opt_nobarrier, "nobarrier"},	/* .. disable */
+	{Opt_inode64, "inode64"},	/* inodes can be allocated anywhere */
+	{Opt_ikeep, "ikeep"},		/* do not free empty inode clusters */
+	{Opt_noikeep, "noikeep"},	/* free empty inode clusters */
+	{Opt_largeio, "largeio"},	/* report large I/O sizes in start() */
+	{Opt_nolargeio, "nolargeio"},	/* do not report large I/O sizes
+					 * in start() */
+	{Opt_attr2, "attr2"},		/* do use attr2 attribute format */
+	{Opt_noattr2, "noattr2"},	/* do not use attr2 attribute format */
+	{Opt_filestreams, "filestreams"}, /* use filestreams allocator */
+	{Opt_quota, "quota"},		/* disk quotas (user) */
+	{Opt_noquota, "noquota"},	/* no quotas */
+	{Opt_usrquota, "usrquota"},	/* user quota enabled */
+	{Opt_grpquota, "grpquota"},	/* group quota enabled */
+	{Opt_prjquota, "prjquota"},	/* project quota enabled */
+	{Opt_uquota, "uquota"},		/* user quota (IRIX variant) */
+	{Opt_gquota, "gquota"},		/* group quota (IRIX variant) */
+	{Opt_pquota, "pquota"},		/* project quota (IRIX variant) */
+	{Opt_uqnoenf, "uqnoenforce"},	/* user quota limit enforcement */
+	{Opt_gqnoenf, "gqnoenforce"},	/* group quota limit enforcement */
+	{Opt_pqnoenf, "pqnoenforce"},	/* project quota limit enforcement */
+	{Opt_qnoenf, "qnoenforce"},	/* same as uqnoenforce */
+	{Opt_delaylog, "delaylog"},	/* deprecated */
+	{Opt_nodelaylog, "nodelaylog"},	/* deprecated */
+	{Opt_discard, "discard"},	/* Discard unused blocks */
+	{Opt_nodiscard, "nodiscard"},	/* Do not discard unused blocks */
+	{Opt_ihashsize, "ihashsize"},	/* deprecated */
+	{Opt_osyncisdsync, "osyncisdsync"}, /* deprecated */
+	{Opt_osyncisosync, "osyncisosync"}, /* deprecated */
+	{Opt_irixsgid, "irixsgid"},	/* deprecated */
 	{Opt_err, NULL}
 };
 
@@ -166,11 +174,14 @@ xfs_parseargs(
 	char			*options)
 {
 	struct super_block	*sb = mp->m_super;
-	char			*this_char, *value, *eov;
+	char			*p, *string, *eov;
 	int			dsunit = 0;
 	int			dswidth = 0;
-	int			iosize = 0;
 	__uint8_t		iosizelog = 0;
+	int			intarg;
+	substring_t		args[MAX_OPT_ARGS];
+	char			*orig = NULL;
+	int			ret = 0;
 
 	/*
 	 * set up the mount name first so all the errors will refer to the
@@ -185,19 +196,19 @@ xfs_parseargs(
 	 * Copy binary VFS mount flags we are interested in.
 	 */
 	if (sb->s_flags & MS_RDONLY)
-		mp->m_flags |= XFS_MOUNT_RDONLY;
+		xfs_set_opt(mp, RDONLY);
 	if (sb->s_flags & MS_DIRSYNC)
-		mp->m_flags |= XFS_MOUNT_DIRSYNC;
+		xfs_set_opt(mp, DIRSYNC);
 	if (sb->s_flags & MS_SYNCHRONOUS)
-		mp->m_flags |= XFS_MOUNT_WSYNC;
+		xfs_set_opt(mp, WSYNC);
 
 	/*
 	 * Set some default flags that could be cleared by the mount option
 	 * parsing.
 	 */
-	mp->m_flags |= XFS_MOUNT_BARRIER;
-	mp->m_flags |= XFS_MOUNT_COMPAT_IOSIZE;
-	mp->m_flags |= XFS_MOUNT_SMALL_INUMS;
+	xfs_set_opt(mp, BARRIER);
+	xfs_set_opt(mp, COMPAT_IOSIZE);
+	xfs_set_opt(mp, SMALL_INUMS);
 
 	/*
 	 * These can be overridden by the mount option parsing.
@@ -208,185 +219,233 @@ xfs_parseargs(
 	if (!options)
 		goto done;
 
-	while ((this_char = strsep(&options, ",")) != NULL) {
-		if (!*this_char)
+	ret = ENOMEM;
+	options = kstrdup(options, GFP_NOFS);
+	if (!options)
+		goto done;
+
+	orig = options;
+
+	while ((p = strsep(&orig, ",")) != NULL) {
+		int token;
+		if (!*p)
 			continue;
-		if ((value = strchr(this_char, '=')) != NULL)
-			*value++ = 0;
-
-		if (!strcmp(this_char, MNTOPT_LOGBUFS)) {
-			if (!value || !*value) {
-				xfs_warn(mp, "%s option requires an argument",
-					this_char);
-				return EINVAL;
-			}
-			mp->m_logbufs = simple_strtoul(value, &eov, 10);
-		} else if (!strcmp(this_char, MNTOPT_LOGBSIZE)) {
-			if (!value || !*value) {
-				xfs_warn(mp, "%s option requires an argument",
-					this_char);
-				return EINVAL;
-			}
-			mp->m_logbsize = suffix_strtoul(value, &eov, 10);
-		} else if (!strcmp(this_char, MNTOPT_LOGDEV)) {
-			if (!value || !*value) {
-				xfs_warn(mp, "%s option requires an argument",
-					this_char);
-				return EINVAL;
-			}
-			mp->m_logname = kstrndup(value, MAXNAMELEN, GFP_KERNEL);
+
+		token = match_token(p, tokens, args);
+		switch (token) {
+		case Opt_logbufs:
+			intarg = 0;
+			ret = EINVAL;
+			match_int(args, &intarg);
+			if (!intarg)
+				goto free_orig;
+			mp->m_logbufs = intarg;
+			break;
+		case Opt_logbsize:
+			ret = ENOMEM;
+			string = match_strdup(args);
+			if (!string)
+				goto free_orig;
+			ret = EINVAL;
+			intarg = suffix_strtoul(string, &eov, 0);
+			if (!intarg)
+				goto free_string;
+			mp->m_logbsize = intarg;
+			break;
+		case Opt_logdev:
+			ret = ENOMEM;
+			string = match_strdup(args);
+			if (!string)
+				goto free_orig;
+
+			mp->m_logname = kstrndup(string, MAXNAMELEN, GFP_KERNEL);
 			if (!mp->m_logname)
-				return ENOMEM;
-		} else if (!strcmp(this_char, MNTOPT_MTPT)) {
-			xfs_warn(mp, "%s option not allowed on this system",
-				this_char);
-			return EINVAL;
-		} else if (!strcmp(this_char, MNTOPT_RTDEV)) {
-			if (!value || !*value) {
-				xfs_warn(mp, "%s option requires an argument",
-					this_char);
-				return EINVAL;
-			}
-			mp->m_rtname = kstrndup(value, MAXNAMELEN, GFP_KERNEL);
+				goto free_string;
+			break;
+		case Opt_mtpt:
+			ret = EINVAL;
+			xfs_warn(mp, "%s option not allowed on this system", p);
+			goto free_orig;
+		case Opt_rtdev:
+			ret = ENOMEM;
+			string = match_strdup(args);
+			if (!string)
+				goto free_orig;
+			mp->m_rtname = kstrndup(string, MAXNAMELEN, GFP_KERNEL);
 			if (!mp->m_rtname)
-				return ENOMEM;
-		} else if (!strcmp(this_char, MNTOPT_BIOSIZE)) {
-			if (!value || !*value) {
-				xfs_warn(mp, "%s option requires an argument",
-					this_char);
-				return EINVAL;
-			}
-			iosize = simple_strtoul(value, &eov, 10);
-			iosizelog = ffs(iosize) - 1;
-		} else if (!strcmp(this_char, MNTOPT_ALLOCSIZE)) {
-			if (!value || !*value) {
-				xfs_warn(mp, "%s option requires an argument",
-					this_char);
-				return EINVAL;
-			}
-			iosize = suffix_strtoul(value, &eov, 10);
-			iosizelog = ffs(iosize) - 1;
-		} else if (!strcmp(this_char, MNTOPT_GRPID) ||
-			   !strcmp(this_char, MNTOPT_BSDGROUPS)) {
-			mp->m_flags |= XFS_MOUNT_GRPID;
-		} else if (!strcmp(this_char, MNTOPT_NOGRPID) ||
-			   !strcmp(this_char, MNTOPT_SYSVGROUPS)) {
-			mp->m_flags &= ~XFS_MOUNT_GRPID;
-		} else if (!strcmp(this_char, MNTOPT_WSYNC)) {
-			mp->m_flags |= XFS_MOUNT_WSYNC;
-		} else if (!strcmp(this_char, MNTOPT_NORECOVERY)) {
-			mp->m_flags |= XFS_MOUNT_NORECOVERY;
-		} else if (!strcmp(this_char, MNTOPT_NOALIGN)) {
-			mp->m_flags |= XFS_MOUNT_NOALIGN;
-		} else if (!strcmp(this_char, MNTOPT_SWALLOC)) {
-			mp->m_flags |= XFS_MOUNT_SWALLOC;
-		} else if (!strcmp(this_char, MNTOPT_SUNIT)) {
-			if (!value || !*value) {
-				xfs_warn(mp, "%s option requires an argument",
-					this_char);
-				return EINVAL;
-			}
-			dsunit = simple_strtoul(value, &eov, 10);
-		} else if (!strcmp(this_char, MNTOPT_SWIDTH)) {
-			if (!value || !*value) {
-				xfs_warn(mp, "%s option requires an argument",
-					this_char);
-				return EINVAL;
-			}
-			dswidth = simple_strtoul(value, &eov, 10);
-		} else if (!strcmp(this_char, MNTOPT_64BITINODE)) {
-			mp->m_flags &= ~XFS_MOUNT_SMALL_INUMS;
+				goto free_string;
+			break;
+		case Opt_biosize:
+			intarg = 0;
+			ret = EINVAL;
+			intarg = match_int(args, &intarg);
+			if (!intarg)
+				goto free_orig;
+			iosizelog = ffs(intarg) - 1;
+			break;
+		case Opt_allocsize:
+			ret = ENOMEM;
+			string = match_strdup(args);
+			if (!string)
+				goto free_orig;
+			ret = EINVAL;
+			intarg = suffix_strtoul(string, &eov, 0);
+			if (!intarg)
+				goto free_string;
+			iosizelog = ffs(intarg) - 1;
+			break;
+		case Opt_grpid:
+		case Opt_bsdgroups:
+			xfs_set_opt(mp, GRPID);
+			break;
+		case Opt_nogrpid:
+		case Opt_sysvgroups:
+			xfs_clear_opt(mp, GRPID);
+			break;
+		case Opt_wsync:
+			xfs_set_opt(mp, WSYNC);
+			break;
+		case Opt_norecovery:
+			xfs_set_opt(mp, NORECOVERY);
+			break;
+		case Opt_noalign:
+			xfs_set_opt(mp, NOALIGN);
+			break;
+		case Opt_swalloc:
+			xfs_set_opt(mp, SWALLOC);
+			break;
+		case Opt_sunit:
+			ret = EINVAL;
+			dsunit = match_int(args, &intarg);
+			if (!dsunit)
+				goto free_orig;
+			break;
+		case Opt_swidth:
+			ret = EINVAL;
+			dswidth = match_int(args, &intarg);
+			if (!dswidth)
+				goto free_orig;
+		case Opt_inode64:
+			xfs_clear_opt(mp, SMALL_INUMS);
 #if !XFS_BIG_INUMS
-			xfs_warn(mp, "%s option not allowed on this system",
-				this_char);
+			xfs_warn(mp, "%s options not allowed on this system", p);
 			return EINVAL;
 #endif
-		} else if (!strcmp(this_char, MNTOPT_NOUUID)) {
-			mp->m_flags |= XFS_MOUNT_NOUUID;
-		} else if (!strcmp(this_char, MNTOPT_BARRIER)) {
-			mp->m_flags |= XFS_MOUNT_BARRIER;
-		} else if (!strcmp(this_char, MNTOPT_NOBARRIER)) {
-			mp->m_flags &= ~XFS_MOUNT_BARRIER;
-		} else if (!strcmp(this_char, MNTOPT_IKEEP)) {
-			mp->m_flags |= XFS_MOUNT_IKEEP;
-		} else if (!strcmp(this_char, MNTOPT_NOIKEEP)) {
-			mp->m_flags &= ~XFS_MOUNT_IKEEP;
-		} else if (!strcmp(this_char, MNTOPT_LARGEIO)) {
-			mp->m_flags &= ~XFS_MOUNT_COMPAT_IOSIZE;
-		} else if (!strcmp(this_char, MNTOPT_NOLARGEIO)) {
-			mp->m_flags |= XFS_MOUNT_COMPAT_IOSIZE;
-		} else if (!strcmp(this_char, MNTOPT_ATTR2)) {
-			mp->m_flags |= XFS_MOUNT_ATTR2;
-		} else if (!strcmp(this_char, MNTOPT_NOATTR2)) {
-			mp->m_flags &= ~XFS_MOUNT_ATTR2;
-			mp->m_flags |= XFS_MOUNT_NOATTR2;
-		} else if (!strcmp(this_char, MNTOPT_FILESTREAM)) {
-			mp->m_flags |= XFS_MOUNT_FILESTREAMS;
-		} else if (!strcmp(this_char, MNTOPT_NOQUOTA)) {
+			break;
+		case Opt_nouuid:
+			xfs_set_opt(mp, NOUUID);
+			break;
+		case Opt_barrier:
+			xfs_set_opt(mp, BARRIER);
+			break;
+		case Opt_nobarrier:
+			xfs_clear_opt(mp, BARRIER);
+			break;
+		case Opt_ikeep:
+			xfs_set_opt(mp, IKEEP);
+			break;
+		case Opt_noikeep:
+			xfs_clear_opt(mp, IKEEP);
+			break;
+		case Opt_largeio:
+			xfs_clear_opt(mp, COMPAT_IOSIZE);
+			break;
+		case Opt_nolargeio:
+			xfs_set_opt(mp, COMPAT_IOSIZE);
+			break;
+		case Opt_attr2:
+			xfs_set_opt(mp, ATTR2);
+			break;
+		case Opt_noattr2:
+			xfs_clear_opt(mp, ATTR2);
+			xfs_set_opt(mp, NOATTR2);
+			break;
+		case Opt_filestreams:
+			xfs_set_opt(mp, FILESTREAMS);
+			break;
+		case Opt_noquota:
 			mp->m_qflags &= ~XFS_ALL_QUOTA_ACCT;
 			mp->m_qflags &= ~XFS_ALL_QUOTA_ENFD;
 			mp->m_qflags &= ~XFS_ALL_QUOTA_ACTIVE;
-		} else if (!strcmp(this_char, MNTOPT_QUOTA) ||
-			   !strcmp(this_char, MNTOPT_UQUOTA) ||
-			   !strcmp(this_char, MNTOPT_USRQUOTA)) {
+			break;
+		case Opt_quota:
+		case Opt_uquota:
+		case Opt_usrquota:
 			mp->m_qflags |= (XFS_UQUOTA_ACCT | XFS_UQUOTA_ACTIVE |
 					 XFS_UQUOTA_ENFD);
-		} else if (!strcmp(this_char, MNTOPT_QUOTANOENF) ||
-			   !strcmp(this_char, MNTOPT_UQUOTANOENF)) {
+			break;
+		case Opt_qnoenf:
+		case Opt_uqnoenf:
 			mp->m_qflags |= (XFS_UQUOTA_ACCT | XFS_UQUOTA_ACTIVE);
 			mp->m_qflags &= ~XFS_UQUOTA_ENFD;
-		} else if (!strcmp(this_char, MNTOPT_PQUOTA) ||
-			   !strcmp(this_char, MNTOPT_PRJQUOTA)) {
+			break;
+		case Opt_pquota:
+		case Opt_prjquota:
 			mp->m_qflags |= (XFS_PQUOTA_ACCT | XFS_PQUOTA_ACTIVE |
 					 XFS_OQUOTA_ENFD);
-		} else if (!strcmp(this_char, MNTOPT_PQUOTANOENF)) {
+			break;
+		case Opt_pqnoenf:
 			mp->m_qflags |= (XFS_PQUOTA_ACCT | XFS_PQUOTA_ACTIVE);
 			mp->m_qflags &= ~XFS_OQUOTA_ENFD;
-		} else if (!strcmp(this_char, MNTOPT_GQUOTA) ||
-			   !strcmp(this_char, MNTOPT_GRPQUOTA)) {
+			break;
+		case Opt_gquota:
+		case Opt_grpquota:
 			mp->m_qflags |= (XFS_GQUOTA_ACCT | XFS_GQUOTA_ACTIVE |
 					 XFS_OQUOTA_ENFD);
-		} else if (!strcmp(this_char, MNTOPT_GQUOTANOENF)) {
+			break;
+		case Opt_gqnoenf:
 			mp->m_qflags |= (XFS_GQUOTA_ACCT | XFS_GQUOTA_ACTIVE);
 			mp->m_qflags &= ~XFS_OQUOTA_ENFD;
-		} else if (!strcmp(this_char, MNTOPT_DELAYLOG)) {
+			break;
+		case Opt_delaylog:
 			xfs_warn(mp,
-	"delaylog is the default now, option is deprecated.");
-		} else if (!strcmp(this_char, MNTOPT_NODELAYLOG)) {
+		"delaylog is the default now, option is deprecated.");
+			break;
+		case Opt_nodelaylog:
 			xfs_warn(mp,
-	"nodelaylog support has been removed, option is deprecated.");
-		} else if (!strcmp(this_char, MNTOPT_DISCARD)) {
-			mp->m_flags |= XFS_MOUNT_DISCARD;
-		} else if (!strcmp(this_char, MNTOPT_NODISCARD)) {
-			mp->m_flags &= ~XFS_MOUNT_DISCARD;
-		} else if (!strcmp(this_char, "ihashsize")) {
+		"nodelaylog support has been removed, option is deprecated.");
+			break;
+		case Opt_discard:
+			xfs_set_opt(mp, DISCARD);
+			break;
+		case Opt_nodiscard:
+			xfs_clear_opt(mp, DISCARD);
+			break;
+		case Opt_ihashsize:
 			xfs_warn(mp,
-	"ihashsize no longer used, option is deprecated.");
-		} else if (!strcmp(this_char, "osyncisdsync")) {
+		"ihashsize no longer used, option is deprecated.");
+		case Opt_osyncisdsync:
 			xfs_warn(mp,
-	"osyncisdsync has no effect, option is deprecated.");
-		} else if (!strcmp(this_char, "osyncisosync")) {
+		"osyncisdsync has no effect, option is deprecated.");
+			break;
+		case Opt_osyncisosync:
 			xfs_warn(mp,
-	"osyncisosync has no effect, option is deprecated.");
-		} else if (!strcmp(this_char, "irixsgid")) {
+		"osyncisosync has no effect, option is deprecated.");
+			break;
+		case Opt_irixsgid:
 			xfs_warn(mp,
-	"irixsgid is now a sysctl(2) variable, option is deprecated.");
-		} else {
-			xfs_warn(mp, "unknown mount option [%s].", this_char);
-			return EINVAL;
+		"irixsgid is now a sysctl(2) variable, option is deprecated.");
+			break;
+		default:
+			xfs_warn(mp, "unknown mount option [%s].", p);
+			break;
 		}
+
+		kfree(string);
+		string = NULL;
 	}
 
+	kfree(orig);
+
 	/*
 	 * no recovery flag requires a read-only mount
 	 */
-	if ((mp->m_flags & XFS_MOUNT_NORECOVERY) &&
-	    !(mp->m_flags & XFS_MOUNT_RDONLY)) {
+	if (xfs_test_opt(mp, NORECOVERY) && !xfs_test_opt(mp, RDONLY)) {
 		xfs_warn(mp, "no-recovery mounts must be read-only.");
 		return EINVAL;
 	}
 
-	if ((mp->m_flags & XFS_MOUNT_NOALIGN) && (dsunit || dswidth)) {
+	if (xfs_test_opt(mp, NOALIGN) && (dsunit || dswidth)) {
 		xfs_warn(mp,
 	"sunit and swidth options incompatible with the noalign option");
 		return EINVAL;
@@ -418,7 +477,7 @@ xfs_parseargs(
 	}
 
 done:
-	if (!(mp->m_flags & XFS_MOUNT_NOALIGN)) {
+	if (!xfs_test_opt(mp, NOALIGN)) {
 		/*
 		 * At this point the superblock has not been read
 		 * in, therefore we do not know the block size.
@@ -427,7 +486,7 @@ done:
 		 */
 		if (dsunit) {
 			mp->m_dalign = dsunit;
-			mp->m_flags |= XFS_MOUNT_RETERR;
+			xfs_set_opt(mp, RETERR);
 		}
 
 		if (dswidth)
@@ -462,98 +521,97 @@ done:
 			return XFS_ERROR(EINVAL);
 		}
 
-		mp->m_flags |= XFS_MOUNT_DFLT_IOSIZE;
+		xfs_set_opt(mp, DFLT_IOSIZE);
 		mp->m_readio_log = iosizelog;
 		mp->m_writeio_log = iosizelog;
 	}
 
 	return 0;
-}
 
-struct proc_xfs_info {
-	int	flag;
-	char	*str;
-};
+free_string:
+	kfree(string);
+	string = NULL;
+free_orig:
+	kfree(orig);
+	return ret;
+}
 
 STATIC int
-xfs_showargs(
-	struct xfs_mount	*mp,
-	struct seq_file		*m)
+xfs_fs_show_options(
+	struct seq_file		*seq,
+	struct dentry		*dentry)
 {
-	static struct proc_xfs_info xfs_info_set[] = {
-		/* the few simple ones we can get from the mount struct */
-		{ XFS_MOUNT_IKEEP,		"," MNTOPT_IKEEP },
-		{ XFS_MOUNT_WSYNC,		"," MNTOPT_WSYNC },
-		{ XFS_MOUNT_NOALIGN,		"," MNTOPT_NOALIGN },
-		{ XFS_MOUNT_SWALLOC,		"," MNTOPT_SWALLOC },
-		{ XFS_MOUNT_NOUUID,		"," MNTOPT_NOUUID },
-		{ XFS_MOUNT_NORECOVERY,		"," MNTOPT_NORECOVERY },
-		{ XFS_MOUNT_ATTR2,		"," MNTOPT_ATTR2 },
-		{ XFS_MOUNT_FILESTREAMS,	"," MNTOPT_FILESTREAM },
-		{ XFS_MOUNT_GRPID,		"," MNTOPT_GRPID },
-		{ XFS_MOUNT_DISCARD,		"," MNTOPT_DISCARD },
-		{ 0, NULL }
-	};
-	static struct proc_xfs_info xfs_info_unset[] = {
-		/* the few simple ones we can get from the mount struct */
-		{ XFS_MOUNT_COMPAT_IOSIZE,	"," MNTOPT_LARGEIO },
-		{ XFS_MOUNT_BARRIER,		"," MNTOPT_NOBARRIER },
-		{ XFS_MOUNT_SMALL_INUMS,	"," MNTOPT_64BITINODE },
-		{ 0, NULL }
-	};
-	struct proc_xfs_info	*xfs_infop;
-
-	for (xfs_infop = xfs_info_set; xfs_infop->flag; xfs_infop++) {
-		if (mp->m_flags & xfs_infop->flag)
-			seq_puts(m, xfs_infop->str);
-	}
-	for (xfs_infop = xfs_info_unset; xfs_infop->flag; xfs_infop++) {
-		if (!(mp->m_flags & xfs_infop->flag))
-			seq_puts(m, xfs_infop->str);
-	}
+	struct xfs_mount	*mp = XFS_M(dentry->d_sb);
 
-	if (mp->m_flags & XFS_MOUNT_DFLT_IOSIZE)
-		seq_printf(m, "," MNTOPT_ALLOCSIZE "=%dk",
+	if (xfs_test_opt(mp, IKEEP))
+		seq_puts(seq, ",ikeep");
+	if (xfs_test_opt(mp, WSYNC))
+		seq_puts(seq, ",wsync");
+	if (xfs_test_opt(mp, NOALIGN))
+		seq_puts(seq, ",noalign");
+	if (xfs_test_opt(mp, SWALLOC))
+		seq_puts(seq, ",swalloc");
+	if (xfs_test_opt(mp, NOUUID))
+		seq_puts(seq, ",nouuid");
+	if (xfs_test_opt(mp, NORECOVERY))
+		seq_puts(seq, ",norecovery");
+	if (xfs_test_opt(mp, ATTR2))
+		seq_puts(seq, ",attr2");
+	if (xfs_test_opt(mp, FILESTREAMS))
+		seq_puts(seq, ",filestreams");
+	if (xfs_test_opt(mp, GRPID))
+		seq_puts(seq, ",grpid");
+	if (xfs_test_opt(mp, DISCARD))
+		seq_puts(seq, ",discard");
+	if (!xfs_test_opt(mp, COMPAT_IOSIZE))
+		seq_puts(seq, ",largeio");
+	if (!xfs_test_opt(mp, BARRIER))
+		seq_puts(seq, ",nobarrier");
+	if (!xfs_test_opt(mp, SMALL_INUMS))
+		seq_puts(seq, ",inode64");
+
+	if (xfs_test_opt(mp, DFLT_IOSIZE))
+		seq_printf(seq, ",allocsize=%dk",
 				(int)(1 << mp->m_writeio_log) >> 10);
 
 	if (mp->m_logbufs > 0)
-		seq_printf(m, "," MNTOPT_LOGBUFS "=%d", mp->m_logbufs);
+		seq_printf(seq, ",logbufs=%d", mp->m_logbufs);
 	if (mp->m_logbsize > 0)
-		seq_printf(m, "," MNTOPT_LOGBSIZE "=%dk", mp->m_logbsize >> 10);
+		seq_printf(seq, ",logbsize=%dk", mp->m_logbsize >> 10);
 
 	if (mp->m_logname)
-		seq_printf(m, "," MNTOPT_LOGDEV "=%s", mp->m_logname);
+		seq_printf(seq, ",logdev=%s", mp->m_logname);
 	if (mp->m_rtname)
-		seq_printf(m, "," MNTOPT_RTDEV "=%s", mp->m_rtname);
+		seq_printf(seq, ",rtdev=%s", mp->m_rtname);
 
 	if (mp->m_dalign > 0)
-		seq_printf(m, "," MNTOPT_SUNIT "=%d",
+		seq_printf(seq, ",sunit=%d",
 				(int)XFS_FSB_TO_BB(mp, mp->m_dalign));
 	if (mp->m_swidth > 0)
-		seq_printf(m, "," MNTOPT_SWIDTH "=%d",
+		seq_printf(seq, ",swidth=%d",
 				(int)XFS_FSB_TO_BB(mp, mp->m_swidth));
 
 	if (mp->m_qflags & (XFS_UQUOTA_ACCT|XFS_UQUOTA_ENFD))
-		seq_puts(m, "," MNTOPT_USRQUOTA);
+		seq_puts(seq, ",usrquota");
 	else if (mp->m_qflags & XFS_UQUOTA_ACCT)
-		seq_puts(m, "," MNTOPT_UQUOTANOENF);
+		seq_puts(seq, ",uqnoenforce");
 
 	/* Either project or group quotas can be active, not both */
 
 	if (mp->m_qflags & XFS_PQUOTA_ACCT) {
 		if (mp->m_qflags & XFS_OQUOTA_ENFD)
-			seq_puts(m, "," MNTOPT_PRJQUOTA);
+			seq_puts(seq, ",prjquota");
 		else
-			seq_puts(m, "," MNTOPT_PQUOTANOENF);
+			seq_puts(seq, ",pqnoenforce");
 	} else if (mp->m_qflags & XFS_GQUOTA_ACCT) {
 		if (mp->m_qflags & XFS_OQUOTA_ENFD)
-			seq_puts(m, "," MNTOPT_GRPQUOTA);
+			seq_puts(seq, ",grpquota");
 		else
-			seq_puts(m, "," MNTOPT_GQUOTANOENF);
+			seq_puts(seq, ",gqnoenforce");
 	}
 
 	if (!(mp->m_qflags & XFS_ALL_QUOTA_ACCT))
-		seq_puts(m, "," MNTOPT_NOQUOTA);
+		seq_puts(seq, ",noquota");
 
 	return 0;
 }
@@ -1119,10 +1177,10 @@ xfs_fs_remount(
 		token = match_token(p, tokens, args);
 		switch (token) {
 		case Opt_barrier:
-			mp->m_flags |= XFS_MOUNT_BARRIER;
+			xfs_set_opt(mp, BARRIER);
 			break;
 		case Opt_nobarrier:
-			mp->m_flags &= ~XFS_MOUNT_BARRIER;
+			xfs_clear_opt(mp, BARRIER);
 			break;
 		default:
 			/*
@@ -1152,8 +1210,8 @@ xfs_fs_remount(
 	}
 
 	/* ro -> rw */
-	if ((mp->m_flags & XFS_MOUNT_RDONLY) && !(*flags & MS_RDONLY)) {
-		mp->m_flags &= ~XFS_MOUNT_RDONLY;
+	if (xfs_test_opt(mp, RDONLY) && !(*flags & MS_RDONLY)) {
+		xfs_clear_opt(mp, RDONLY);
 
 		/*
 		 * If this is the first remount to writeable state we
@@ -1176,7 +1234,7 @@ xfs_fs_remount(
 	}
 
 	/* rw -> ro */
-	if (!(mp->m_flags & XFS_MOUNT_RDONLY) && (*flags & MS_RDONLY)) {
+	if (!xfs_test_opt(mp, RDONLY) && (*flags & MS_RDONLY)) {
 		/*
 		 * After we have synced the data but before we sync the
 		 * metadata, we need to free up the reserve block pool so that
@@ -1189,7 +1247,7 @@ xfs_fs_remount(
 		xfs_quiesce_data(mp);
 		xfs_save_resvblks(mp);
 		xfs_quiesce_attr(mp);
-		mp->m_flags |= XFS_MOUNT_RDONLY;
+		xfs_set_opt(mp, RDONLY);
 	}
 
 	return 0;
@@ -1221,14 +1279,6 @@ xfs_fs_unfreeze(
 	return 0;
 }
 
-STATIC int
-xfs_fs_show_options(
-	struct seq_file		*m,
-	struct dentry		*root)
-{
-	return -xfs_showargs(XFS_M(root->d_sb), m);
-}
-
 /*
  * This function fills in xfs_mount_t fields based on mount args.
  * Note: the superblock _has_ now been read in.
@@ -1237,7 +1287,7 @@ STATIC int
 xfs_finish_flags(
 	struct xfs_mount	*mp)
 {
-	int			ronly = (mp->m_flags & XFS_MOUNT_RDONLY);
+	int			ronly = xfs_test_opt(mp, RDONLY);
 
 	/* Fail a mount where the logbuf is smaller than the log stripe */
 	if (xfs_sb_version_haslogv2(&mp->m_sb)) {
@@ -1263,9 +1313,8 @@ xfs_finish_flags(
 	 * mkfs'ed attr2 will turn on attr2 mount unless explicitly
 	 * told by noattr2 to turn it off
 	 */
-	if (xfs_sb_version_hasattr2(&mp->m_sb) &&
-	    !(mp->m_flags & XFS_MOUNT_NOATTR2))
-		mp->m_flags |= XFS_MOUNT_ATTR2;
+	if (xfs_sb_version_hasattr2(&mp->m_sb) && !xfs_test_opt(mp, NOATTR2))
+		xfs_set_opt(mp, ATTR2);
 
 	/*
 	 * prohibit r/w mounts of read-only filesystems
-- 
1.7.9.2.323.gf051a

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

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

* Re: [PATCH] xfs: cleanup the mount options
  2012-06-27 16:57 [PATCH] xfs: cleanup the mount options Wanlong Gao
@ 2012-06-27 17:44 ` Christoph Hellwig
  2012-06-28  0:54   ` Wanlong Gao
  2012-06-29 18:06 ` [PATCH 1/2 V2] " Wanlong Gao
  1 sibling, 1 reply; 31+ messages in thread
From: Christoph Hellwig @ 2012-06-27 17:44 UTC (permalink / raw)
  To: Wanlong Gao; +Cc: hch, bpm, xfs

On Thu, Jun 28, 2012 at 12:57:23AM +0800, Wanlong Gao wrote:
> remove the mount options macro, use tokens instead.
> Futher cleanup will use xfs_*_opt in xfs instead,
> but it may be hard to be merged in one patch.

Thanks a lot!

I like the use of the option parse a lot, this has been long overdue.

But is there any good reason to add the xfs_*_opt macros?  They make
reading and especially grepping the code a lot harder, so there better
be a good reason for them.

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

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

* Re: [PATCH] xfs: cleanup the mount options
  2012-06-27 17:44 ` Christoph Hellwig
@ 2012-06-28  0:54   ` Wanlong Gao
  2012-06-28 16:01     ` Ben Myers
  0 siblings, 1 reply; 31+ messages in thread
From: Wanlong Gao @ 2012-06-28  0:54 UTC (permalink / raw)
  To: Christoph Hellwig; +Cc: bpm, xfs

On 06/28/2012 01:44 AM, Christoph Hellwig wrote:
> On Thu, Jun 28, 2012 at 12:57:23AM +0800, Wanlong Gao wrote:
>> remove the mount options macro, use tokens instead.
>> Futher cleanup will use xfs_*_opt in xfs instead,
>> but it may be hard to be merged in one patch.
> 
> Thanks a lot!
> 
> I like the use of the option parse a lot, this has been long overdue.
> 
> But is there any good reason to add the xfs_*_opt macros?  They make
> reading and especially grepping the code a lot harder, so there better
> be a good reason for them.

I think that using the macro makes code more clearly, and it's more
convenient to use the macro than the original "|=", "&=" and "&" things.
And, no more harder for reading and grepping, just omit the "XFS_MOUNT_".

BTW, these macros were borrowed from Btrfs. I myself like it, but if
you XFS guys all do not like, I can drop it.

Thanks,
Wanlong Gao

> 
> 


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

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

* Re: [PATCH] xfs: cleanup the mount options
  2012-06-28  0:54   ` Wanlong Gao
@ 2012-06-28 16:01     ` Ben Myers
  2012-06-28 16:33       ` Zach Brown
  0 siblings, 1 reply; 31+ messages in thread
From: Ben Myers @ 2012-06-28 16:01 UTC (permalink / raw)
  To: Wanlong Gao; +Cc: Christoph Hellwig, xfs

Hey Wanlong,

On Thu, Jun 28, 2012 at 08:54:19AM +0800, Wanlong Gao wrote:
> On 06/28/2012 01:44 AM, Christoph Hellwig wrote:
> > On Thu, Jun 28, 2012 at 12:57:23AM +0800, Wanlong Gao wrote:
> >> remove the mount options macro, use tokens instead.
> >> Futher cleanup will use xfs_*_opt in xfs instead,
> >> but it may be hard to be merged in one patch.
> > 
> > Thanks a lot!
> > 
> > I like the use of the option parse a lot, this has been long overdue.
> > 
> > But is there any good reason to add the xfs_*_opt macros?  They make
> > reading and especially grepping the code a lot harder, so there better
> > be a good reason for them.
> 
> I think that using the macro makes code more clearly, and it's more
> convenient to use the macro than the original "|=", "&=" and "&" things.
> And, no more harder for reading and grepping, just omit the "XFS_MOUNT_".

Granted.  It's not hard to omit 'XFS_MOUNT_'.  The difficulty is that when you
omit XFS_MOUNT_ in your grep, you may get many more unrelated hits from other
contexts to sift through.  Maybe that's what Christoph was getting at.

> BTW, these macros were borrowed from Btrfs. I myself like it, but if
> you XFS guys all do not like, I can drop it.

It's not a strong objection from me, but I do have a preference for keeping the
XFS_MOUNT_ prefix to retain context for cscope and grep.  Maybe others feel
differently.

Regards,
	Ben

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

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

* Re: [PATCH] xfs: cleanup the mount options
  2012-06-28 16:01     ` Ben Myers
@ 2012-06-28 16:33       ` Zach Brown
  2012-06-28 19:54         ` Carlos Maiolino
  2012-06-29  1:00         ` Wanlong Gao
  0 siblings, 2 replies; 31+ messages in thread
From: Zach Brown @ 2012-06-28 16:33 UTC (permalink / raw)
  To: Ben Myers; +Cc: Christoph Hellwig, Wanlong Gao, xfs


> It's not a strong objection from me, but I do have a preference for keeping the
> XFS_MOUNT_ prefix to retain context for cscope and grep.  Maybe others feel
> differently.

For what it's worth, I agree.  It's really annoying to have cscope
lookups fail and have to go poking around for things manually.

- z

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

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

* Re: [PATCH] xfs: cleanup the mount options
  2012-06-28 16:33       ` Zach Brown
@ 2012-06-28 19:54         ` Carlos Maiolino
  2012-06-29  1:00         ` Wanlong Gao
  1 sibling, 0 replies; 31+ messages in thread
From: Carlos Maiolino @ 2012-06-28 19:54 UTC (permalink / raw)
  To: xfs

On Thu, Jun 28, 2012 at 09:33:44AM -0700, Zach Brown wrote:
> 
> >It's not a strong objection from me, but I do have a preference for keeping the
> >XFS_MOUNT_ prefix to retain context for cscope and grep.  Maybe others feel
> >differently.
> 
> For what it's worth, I agree.  It's really annoying to have cscope
> lookups fail and have to go poking around for things manually.
> 
+1

-- 
--Carlos

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

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

* Re: [PATCH] xfs: cleanup the mount options
  2012-06-28 16:33       ` Zach Brown
  2012-06-28 19:54         ` Carlos Maiolino
@ 2012-06-29  1:00         ` Wanlong Gao
  2012-06-29 16:29           ` Zach Brown
  1 sibling, 1 reply; 31+ messages in thread
From: Wanlong Gao @ 2012-06-29  1:00 UTC (permalink / raw)
  To: Zach Brown; +Cc: Christoph Hellwig, Ben Myers, xfs

On 06/29/2012 12:33 AM, Zach Brown wrote:
> 
>> It's not a strong objection from me, but I do have a preference for keeping the
>> XFS_MOUNT_ prefix to retain context for cscope and grep.  Maybe others feel
>> differently.
> 
> For what it's worth, I agree.  It's really annoying to have cscope
> lookups fail and have to go poking around for things manually.

If you know XFS code, you really needn't cscope lookups on these
easy enough mount options. Don't stick to cscope lookups all the time.
Anyway, omit use xfs_*_opt can make code looks more clearly.

Thanks,
Wanlong Gao


> 
> - z
> 


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

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

* Re: [PATCH] xfs: cleanup the mount options
  2012-06-29  1:00         ` Wanlong Gao
@ 2012-06-29 16:29           ` Zach Brown
  2012-06-29 16:37             ` Wanlong Gao
  0 siblings, 1 reply; 31+ messages in thread
From: Zach Brown @ 2012-06-29 16:29 UTC (permalink / raw)
  To: gaowanlong; +Cc: Christoph Hellwig, Ben Myers, xfs


> If you know XFS code, you really needn't cscope lookups on these
> easy enough mount options. Don't stick to cscope lookups all the time.

That's nonsense.  It has nothing to do with "knowing" the identifiers,
it's about giving tools the ability to move to them quickly.

Ben stated his preference, I seconded it.  You have the data and can
chose to ignore it.  Let's move on.

- z

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

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

* Re: [PATCH] xfs: cleanup the mount options
  2012-06-29 16:29           ` Zach Brown
@ 2012-06-29 16:37             ` Wanlong Gao
  0 siblings, 0 replies; 31+ messages in thread
From: Wanlong Gao @ 2012-06-29 16:37 UTC (permalink / raw)
  To: Zach Brown; +Cc: Christoph Hellwig, Ben Myers, xfs

On 06/30/2012 12:29 AM, Zach Brown wrote:
> 
>> If you know XFS code, you really needn't cscope lookups on these
>> easy enough mount options. Don't stick to cscope lookups all the time.
> 
> That's nonsense.  It has nothing to do with "knowing" the identifiers,
> it's about giving tools the ability to move to them quickly.
> 
> Ben stated his preference, I seconded it.  You have the data and can
> chose to ignore it.  Let's move on.
> 

OK, I can drop the xfs_*_opt macros in V2, and any comments about the
parse options? I'd like to see the comments about the rest parts.

Thanks,
Wanlong Gao

> - z
> 


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

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

* [PATCH 1/2 V2] xfs: cleanup the mount options
  2012-06-27 16:57 [PATCH] xfs: cleanup the mount options Wanlong Gao
  2012-06-27 17:44 ` Christoph Hellwig
@ 2012-06-29 18:06 ` Wanlong Gao
  2012-06-29 18:06   ` [PATCH 2/2] xfs: rename xfs_fs_* to xfs_* Wanlong Gao
  2012-07-02  6:26   ` [PATCH 1/2 V2] xfs: cleanup the mount options Christoph Hellwig
  1 sibling, 2 replies; 31+ messages in thread
From: Wanlong Gao @ 2012-06-29 18:06 UTC (permalink / raw)
  To: XFS; +Cc: Christoph Hellwig, Ben Myers, Zach Brown, Wanlong Gao

remove the mount options macro, use tokens instead.

CC: Ben Myers <bpm@sgi.com>
CC: Christoph Hellwig <hch@infradead.org>
CC: Dave Chinner <david@fromorbit.com>
CC: Zach Brown <zab@zabbo.net>
Signed-off-by: Wanlong Gao <gaowanlong@cn.fujitsu.com>
---
 fs/xfs/xfs_super.c |  523 ++++++++++++++++++++++++++++------------------------
 1 file changed, 287 insertions(+), 236 deletions(-)

diff --git a/fs/xfs/xfs_super.c b/fs/xfs/xfs_super.c
index 0d9de41..36d139b 100644
--- a/fs/xfs/xfs_super.c
+++ b/fs/xfs/xfs_super.c
@@ -66,66 +66,74 @@ static const struct super_operations xfs_super_operations;
 static kmem_zone_t *xfs_ioend_zone;
 mempool_t *xfs_ioend_pool;
 
-#define MNTOPT_LOGBUFS	"logbufs"	/* number of XFS log buffers */
-#define MNTOPT_LOGBSIZE	"logbsize"	/* size of XFS log buffers */
-#define MNTOPT_LOGDEV	"logdev"	/* log device */
-#define MNTOPT_RTDEV	"rtdev"		/* realtime I/O device */
-#define MNTOPT_BIOSIZE	"biosize"	/* log2 of preferred buffered io size */
-#define MNTOPT_WSYNC	"wsync"		/* safe-mode nfs compatible mount */
-#define MNTOPT_NOALIGN	"noalign"	/* turn off stripe alignment */
-#define MNTOPT_SWALLOC	"swalloc"	/* turn on stripe width allocation */
-#define MNTOPT_SUNIT	"sunit"		/* data volume stripe unit */
-#define MNTOPT_SWIDTH	"swidth"	/* data volume stripe width */
-#define MNTOPT_NOUUID	"nouuid"	/* ignore filesystem UUID */
-#define MNTOPT_MTPT	"mtpt"		/* filesystem mount point */
-#define MNTOPT_GRPID	"grpid"		/* group-ID from parent directory */
-#define MNTOPT_NOGRPID	"nogrpid"	/* group-ID from current process */
-#define MNTOPT_BSDGROUPS    "bsdgroups"    /* group-ID from parent directory */
-#define MNTOPT_SYSVGROUPS   "sysvgroups"   /* group-ID from current process */
-#define MNTOPT_ALLOCSIZE    "allocsize"    /* preferred allocation size */
-#define MNTOPT_NORECOVERY   "norecovery"   /* don't run XFS recovery */
-#define MNTOPT_BARRIER	"barrier"	/* use writer barriers for log write and
-					 * unwritten extent conversion */
-#define MNTOPT_NOBARRIER "nobarrier"	/* .. disable */
-#define MNTOPT_64BITINODE   "inode64"	/* inodes can be allocated anywhere */
-#define MNTOPT_IKEEP	"ikeep"		/* do not free empty inode clusters */
-#define MNTOPT_NOIKEEP	"noikeep"	/* free empty inode clusters */
-#define MNTOPT_LARGEIO	   "largeio"	/* report large I/O sizes in stat() */
-#define MNTOPT_NOLARGEIO   "nolargeio"	/* do not report large I/O sizes
-					 * in stat(). */
-#define MNTOPT_ATTR2	"attr2"		/* do use attr2 attribute format */
-#define MNTOPT_NOATTR2	"noattr2"	/* do not use attr2 attribute format */
-#define MNTOPT_FILESTREAM  "filestreams" /* use filestreams allocator */
-#define MNTOPT_QUOTA	"quota"		/* disk quotas (user) */
-#define MNTOPT_NOQUOTA	"noquota"	/* no quotas */
-#define MNTOPT_USRQUOTA	"usrquota"	/* user quota enabled */
-#define MNTOPT_GRPQUOTA	"grpquota"	/* group quota enabled */
-#define MNTOPT_PRJQUOTA	"prjquota"	/* project quota enabled */
-#define MNTOPT_UQUOTA	"uquota"	/* user quota (IRIX variant) */
-#define MNTOPT_GQUOTA	"gquota"	/* group quota (IRIX variant) */
-#define MNTOPT_PQUOTA	"pquota"	/* project quota (IRIX variant) */
-#define MNTOPT_UQUOTANOENF "uqnoenforce"/* user quota limit enforcement */
-#define MNTOPT_GQUOTANOENF "gqnoenforce"/* group quota limit enforcement */
-#define MNTOPT_PQUOTANOENF "pqnoenforce"/* project quota limit enforcement */
-#define MNTOPT_QUOTANOENF  "qnoenforce"	/* same as uqnoenforce */
-#define MNTOPT_DELAYLOG    "delaylog"	/* Delayed logging enabled */
-#define MNTOPT_NODELAYLOG  "nodelaylog"	/* Delayed logging disabled */
-#define MNTOPT_DISCARD	   "discard"	/* Discard unused blocks */
-#define MNTOPT_NODISCARD   "nodiscard"	/* Do not discard unused blocks */
-
 /*
  * Table driven mount option parser.
- *
- * Currently only used for remount, but it will be used for mount
- * in the future, too.
  */
 enum {
-	Opt_barrier, Opt_nobarrier, Opt_err
+	Opt_logbufs, Opt_logbsize, Opt_logdev, Opt_rtdev, Opt_biosize,
+	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_inode64, Opt_ikeep, Opt_noikeep, Opt_largeio,
+	Opt_nolargeio, Opt_attr2, Opt_noattr2, Opt_filestreams, Opt_quota,
+	Opt_noquota, Opt_usrquota, Opt_grpquota, Opt_prjquota, Opt_uquota,
+	Opt_gquota, Opt_pquota, Opt_uqnoenf, Opt_gqnoenf, Opt_pqnoenf,
+	Opt_qnoenf, Opt_delaylog, Opt_nodelaylog, Opt_discard, Opt_nodiscard,
+	Opt_ihashsize, Opt_osyncisdsync, Opt_osyncisosync, Opt_irixsgid,
+	Opt_err
 };
 
 static const match_table_t tokens = {
-	{Opt_barrier, "barrier"},
-	{Opt_nobarrier, "nobarrier"},
+	{Opt_logbufs, "logbufs=%d"},	/* number of XFS log buffers */
+	{Opt_logbsize, "logbsize=%s"},	/* size of XFS log buffers */
+	{Opt_logdev, "logdev=%s"},	/* log device */
+	{Opt_rtdev, "rtdev=%s"},	/* realtime I/O device */
+	{Opt_biosize, "biosize=%d"},	/* log2 of preferred buffered io size */
+	{Opt_wsync, "wsync"},		/* safe-mode nfs compatible mount */
+	{Opt_noalign, "noalign"},	/* turn off stripe alignment */
+	{Opt_swalloc, "swalloc"},	/* turn on stripe width allocation */
+	{Opt_sunit, "sunit=%d"},	/* data volume stripe unit */
+	{Opt_swidth, "swidth=%d"},	/* data volume stripe width */
+	{Opt_nouuid, "nouuid"},		/* ignore filesystem UUID */
+	{Opt_mtpt, "mtpt"},		/* filesystem mount point */
+	{Opt_grpid, "grpid"},		/* group-ID from parent directory */
+	{Opt_nogrpid, "nogrpid"},	/* group-ID from current process */
+	{Opt_bsdgroups, "bsdgroups"},	/* group-ID from parent directory */
+	{Opt_sysvgroups, "sysvgroups"},	/* group-ID from current process */
+	{Opt_allocsize, "allocsize=%s"},/* preferred allocation size */
+	{Opt_norecovery, "norecovery"},	/* do not run XFS recovery */
+	{Opt_barrier, "barrier"},	/* use writer barrier for log write and
+					 * unwritten extent conversation */
+	{Opt_nobarrier, "nobarrier"},	/* .. disable */
+	{Opt_inode64, "inode64"},	/* inodes can be allocated anywhere */
+	{Opt_ikeep, "ikeep"},		/* do not free empty inode clusters */
+	{Opt_noikeep, "noikeep"},	/* free empty inode clusters */
+	{Opt_largeio, "largeio"},	/* report large I/O sizes in start() */
+	{Opt_nolargeio, "nolargeio"},	/* do not report large I/O sizes
+					 * in start() */
+	{Opt_attr2, "attr2"},		/* do use attr2 attribute format */
+	{Opt_noattr2, "noattr2"},	/* do not use attr2 attribute format */
+	{Opt_filestreams, "filestreams"}, /* use filestreams allocator */
+	{Opt_quota, "quota"},		/* disk quotas (user) */
+	{Opt_noquota, "noquota"},	/* no quotas */
+	{Opt_usrquota, "usrquota"},	/* user quota enabled */
+	{Opt_grpquota, "grpquota"},	/* group quota enabled */
+	{Opt_prjquota, "prjquota"},	/* project quota enabled */
+	{Opt_uquota, "uquota"},		/* user quota (IRIX variant) */
+	{Opt_gquota, "gquota"},		/* group quota (IRIX variant) */
+	{Opt_pquota, "pquota"},		/* project quota (IRIX variant) */
+	{Opt_uqnoenf, "uqnoenforce"},	/* user quota limit enforcement */
+	{Opt_gqnoenf, "gqnoenforce"},	/* group quota limit enforcement */
+	{Opt_pqnoenf, "pqnoenforce"},	/* project quota limit enforcement */
+	{Opt_qnoenf, "qnoenforce"},	/* same as uqnoenforce */
+	{Opt_delaylog, "delaylog"},	/* deprecated */
+	{Opt_nodelaylog, "nodelaylog"},	/* deprecated */
+	{Opt_discard, "discard"},	/* Discard unused blocks */
+	{Opt_nodiscard, "nodiscard"},	/* Do not discard unused blocks */
+	{Opt_ihashsize, "ihashsize"},	/* deprecated */
+	{Opt_osyncisdsync, "osyncisdsync"}, /* deprecated */
+	{Opt_osyncisosync, "osyncisosync"}, /* deprecated */
+	{Opt_irixsgid, "irixsgid"},	/* deprecated */
 	{Opt_err, NULL}
 };
 
@@ -166,11 +174,14 @@ xfs_parseargs(
 	char			*options)
 {
 	struct super_block	*sb = mp->m_super;
-	char			*this_char, *value, *eov;
+	char			*p, *string, *eov;
 	int			dsunit = 0;
 	int			dswidth = 0;
-	int			iosize = 0;
 	__uint8_t		iosizelog = 0;
+	int			intarg;
+	substring_t		args[MAX_OPT_ARGS];
+	char			*orig = NULL;
+	int			ret = 0;
 
 	/*
 	 * set up the mount name first so all the errors will refer to the
@@ -208,175 +219,224 @@ xfs_parseargs(
 	if (!options)
 		goto done;
 
-	while ((this_char = strsep(&options, ",")) != NULL) {
-		if (!*this_char)
+	ret = ENOMEM;
+	options = kstrdup(options, GFP_NOFS);
+	if (!options)
+		goto done;
+
+	orig = options;
+
+	while ((p = strsep(&orig, ",")) != NULL) {
+		int token;
+		if (!*p)
 			continue;
-		if ((value = strchr(this_char, '=')) != NULL)
-			*value++ = 0;
-
-		if (!strcmp(this_char, MNTOPT_LOGBUFS)) {
-			if (!value || !*value) {
-				xfs_warn(mp, "%s option requires an argument",
-					this_char);
-				return EINVAL;
-			}
-			mp->m_logbufs = simple_strtoul(value, &eov, 10);
-		} else if (!strcmp(this_char, MNTOPT_LOGBSIZE)) {
-			if (!value || !*value) {
-				xfs_warn(mp, "%s option requires an argument",
-					this_char);
-				return EINVAL;
-			}
-			mp->m_logbsize = suffix_strtoul(value, &eov, 10);
-		} else if (!strcmp(this_char, MNTOPT_LOGDEV)) {
-			if (!value || !*value) {
-				xfs_warn(mp, "%s option requires an argument",
-					this_char);
-				return EINVAL;
-			}
-			mp->m_logname = kstrndup(value, MAXNAMELEN, GFP_KERNEL);
+
+		token = match_token(p, tokens, args);
+		switch (token) {
+		case Opt_logbufs:
+			intarg = 0;
+			ret = EINVAL;
+			match_int(args, &intarg);
+			if (!intarg)
+				goto free_orig;
+			mp->m_logbufs = intarg;
+			break;
+		case Opt_logbsize:
+			ret = ENOMEM;
+			string = match_strdup(args);
+			if (!string)
+				goto free_orig;
+			ret = EINVAL;
+			intarg = suffix_strtoul(string, &eov, 0);
+			if (!intarg)
+				goto free_string;
+			mp->m_logbsize = intarg;
+			break;
+		case Opt_logdev:
+			ret = ENOMEM;
+			string = match_strdup(args);
+			if (!string)
+				goto free_orig;
+
+			mp->m_logname = kstrndup(string, MAXNAMELEN, GFP_KERNEL);
 			if (!mp->m_logname)
-				return ENOMEM;
-		} else if (!strcmp(this_char, MNTOPT_MTPT)) {
-			xfs_warn(mp, "%s option not allowed on this system",
-				this_char);
-			return EINVAL;
-		} else if (!strcmp(this_char, MNTOPT_RTDEV)) {
-			if (!value || !*value) {
-				xfs_warn(mp, "%s option requires an argument",
-					this_char);
-				return EINVAL;
-			}
-			mp->m_rtname = kstrndup(value, MAXNAMELEN, GFP_KERNEL);
+				goto free_string;
+			break;
+		case Opt_mtpt:
+			ret = EINVAL;
+			xfs_warn(mp, "%s option not allowed on this system", p);
+			goto free_orig;
+		case Opt_rtdev:
+			ret = ENOMEM;
+			string = match_strdup(args);
+			if (!string)
+				goto free_orig;
+			mp->m_rtname = kstrndup(string, MAXNAMELEN, GFP_KERNEL);
 			if (!mp->m_rtname)
-				return ENOMEM;
-		} else if (!strcmp(this_char, MNTOPT_BIOSIZE)) {
-			if (!value || !*value) {
-				xfs_warn(mp, "%s option requires an argument",
-					this_char);
-				return EINVAL;
-			}
-			iosize = simple_strtoul(value, &eov, 10);
-			iosizelog = ffs(iosize) - 1;
-		} else if (!strcmp(this_char, MNTOPT_ALLOCSIZE)) {
-			if (!value || !*value) {
-				xfs_warn(mp, "%s option requires an argument",
-					this_char);
-				return EINVAL;
-			}
-			iosize = suffix_strtoul(value, &eov, 10);
-			iosizelog = ffs(iosize) - 1;
-		} else if (!strcmp(this_char, MNTOPT_GRPID) ||
-			   !strcmp(this_char, MNTOPT_BSDGROUPS)) {
+				goto free_string;
+			break;
+		case Opt_biosize:
+			intarg = 0;
+			ret = EINVAL;
+			intarg = match_int(args, &intarg);
+			if (!intarg)
+				goto free_orig;
+			iosizelog = ffs(intarg) - 1;
+			break;
+		case Opt_allocsize:
+			ret = ENOMEM;
+			string = match_strdup(args);
+			if (!string)
+				goto free_orig;
+			ret = EINVAL;
+			intarg = suffix_strtoul(string, &eov, 0);
+			if (!intarg)
+				goto free_string;
+			iosizelog = ffs(intarg) - 1;
+			break;
+		case Opt_grpid:
+		case Opt_bsdgroups:
 			mp->m_flags |= XFS_MOUNT_GRPID;
-		} else if (!strcmp(this_char, MNTOPT_NOGRPID) ||
-			   !strcmp(this_char, MNTOPT_SYSVGROUPS)) {
+			break;
+		case Opt_nogrpid:
+		case Opt_sysvgroups:
 			mp->m_flags &= ~XFS_MOUNT_GRPID;
-		} else if (!strcmp(this_char, MNTOPT_WSYNC)) {
+			break;
+		case Opt_wsync:
 			mp->m_flags |= XFS_MOUNT_WSYNC;
-		} else if (!strcmp(this_char, MNTOPT_NORECOVERY)) {
+			break;
+		case Opt_norecovery:
 			mp->m_flags |= XFS_MOUNT_NORECOVERY;
-		} else if (!strcmp(this_char, MNTOPT_NOALIGN)) {
+			break;
+		case Opt_noalign:
 			mp->m_flags |= XFS_MOUNT_NOALIGN;
-		} else if (!strcmp(this_char, MNTOPT_SWALLOC)) {
+			break;
+		case Opt_swalloc:
 			mp->m_flags |= XFS_MOUNT_SWALLOC;
-		} else if (!strcmp(this_char, MNTOPT_SUNIT)) {
-			if (!value || !*value) {
-				xfs_warn(mp, "%s option requires an argument",
-					this_char);
-				return EINVAL;
-			}
-			dsunit = simple_strtoul(value, &eov, 10);
-		} else if (!strcmp(this_char, MNTOPT_SWIDTH)) {
-			if (!value || !*value) {
-				xfs_warn(mp, "%s option requires an argument",
-					this_char);
-				return EINVAL;
-			}
-			dswidth = simple_strtoul(value, &eov, 10);
-		} else if (!strcmp(this_char, MNTOPT_64BITINODE)) {
+			break;
+		case Opt_sunit:
+			ret = EINVAL;
+			dsunit = match_int(args, &intarg);
+			if (!dsunit)
+				goto free_orig;
+			break;
+		case Opt_swidth:
+			ret = EINVAL;
+			dswidth = match_int(args, &intarg);
+			if (!dswidth)
+				goto free_orig;
+		case Opt_inode64:
 			mp->m_flags &= ~XFS_MOUNT_SMALL_INUMS;
 #if !XFS_BIG_INUMS
-			xfs_warn(mp, "%s option not allowed on this system",
-				this_char);
+			xfs_warn(mp, "%s options not allowed on this system", p);
 			return EINVAL;
 #endif
-		} else if (!strcmp(this_char, MNTOPT_NOUUID)) {
+			break;
+		case Opt_nouuid:
 			mp->m_flags |= XFS_MOUNT_NOUUID;
-		} else if (!strcmp(this_char, MNTOPT_BARRIER)) {
+			break;
+		case Opt_barrier:
 			mp->m_flags |= XFS_MOUNT_BARRIER;
-		} else if (!strcmp(this_char, MNTOPT_NOBARRIER)) {
+			break;
+		case Opt_nobarrier:
 			mp->m_flags &= ~XFS_MOUNT_BARRIER;
-		} else if (!strcmp(this_char, MNTOPT_IKEEP)) {
+			break;
+		case Opt_ikeep:
 			mp->m_flags |= XFS_MOUNT_IKEEP;
-		} else if (!strcmp(this_char, MNTOPT_NOIKEEP)) {
+			break;
+		case Opt_noikeep:
 			mp->m_flags &= ~XFS_MOUNT_IKEEP;
-		} else if (!strcmp(this_char, MNTOPT_LARGEIO)) {
+			break;
+		case Opt_largeio:
 			mp->m_flags &= ~XFS_MOUNT_COMPAT_IOSIZE;
-		} else if (!strcmp(this_char, MNTOPT_NOLARGEIO)) {
+			break;
+		case Opt_nolargeio:
 			mp->m_flags |= XFS_MOUNT_COMPAT_IOSIZE;
-		} else if (!strcmp(this_char, MNTOPT_ATTR2)) {
+			break;
+		case Opt_attr2:
 			mp->m_flags |= XFS_MOUNT_ATTR2;
-		} else if (!strcmp(this_char, MNTOPT_NOATTR2)) {
+			break;
+		case Opt_noattr2:
 			mp->m_flags &= ~XFS_MOUNT_ATTR2;
 			mp->m_flags |= XFS_MOUNT_NOATTR2;
-		} else if (!strcmp(this_char, MNTOPT_FILESTREAM)) {
+			break;
+		case Opt_filestreams:
 			mp->m_flags |= XFS_MOUNT_FILESTREAMS;
-		} else if (!strcmp(this_char, MNTOPT_NOQUOTA)) {
+			break;
+		case Opt_noquota:
 			mp->m_qflags &= ~XFS_ALL_QUOTA_ACCT;
 			mp->m_qflags &= ~XFS_ALL_QUOTA_ENFD;
 			mp->m_qflags &= ~XFS_ALL_QUOTA_ACTIVE;
-		} else if (!strcmp(this_char, MNTOPT_QUOTA) ||
-			   !strcmp(this_char, MNTOPT_UQUOTA) ||
-			   !strcmp(this_char, MNTOPT_USRQUOTA)) {
+			break;
+		case Opt_quota:
+		case Opt_uquota:
+		case Opt_usrquota:
 			mp->m_qflags |= (XFS_UQUOTA_ACCT | XFS_UQUOTA_ACTIVE |
 					 XFS_UQUOTA_ENFD);
-		} else if (!strcmp(this_char, MNTOPT_QUOTANOENF) ||
-			   !strcmp(this_char, MNTOPT_UQUOTANOENF)) {
+			break;
+		case Opt_qnoenf:
+		case Opt_uqnoenf:
 			mp->m_qflags |= (XFS_UQUOTA_ACCT | XFS_UQUOTA_ACTIVE);
 			mp->m_qflags &= ~XFS_UQUOTA_ENFD;
-		} else if (!strcmp(this_char, MNTOPT_PQUOTA) ||
-			   !strcmp(this_char, MNTOPT_PRJQUOTA)) {
+			break;
+		case Opt_pquota:
+		case Opt_prjquota:
 			mp->m_qflags |= (XFS_PQUOTA_ACCT | XFS_PQUOTA_ACTIVE |
 					 XFS_OQUOTA_ENFD);
-		} else if (!strcmp(this_char, MNTOPT_PQUOTANOENF)) {
+			break;
+		case Opt_pqnoenf:
 			mp->m_qflags |= (XFS_PQUOTA_ACCT | XFS_PQUOTA_ACTIVE);
 			mp->m_qflags &= ~XFS_OQUOTA_ENFD;
-		} else if (!strcmp(this_char, MNTOPT_GQUOTA) ||
-			   !strcmp(this_char, MNTOPT_GRPQUOTA)) {
+			break;
+		case Opt_gquota:
+		case Opt_grpquota:
 			mp->m_qflags |= (XFS_GQUOTA_ACCT | XFS_GQUOTA_ACTIVE |
 					 XFS_OQUOTA_ENFD);
-		} else if (!strcmp(this_char, MNTOPT_GQUOTANOENF)) {
+			break;
+		case Opt_gqnoenf:
 			mp->m_qflags |= (XFS_GQUOTA_ACCT | XFS_GQUOTA_ACTIVE);
 			mp->m_qflags &= ~XFS_OQUOTA_ENFD;
-		} else if (!strcmp(this_char, MNTOPT_DELAYLOG)) {
+			break;
+		case Opt_delaylog:
 			xfs_warn(mp,
-	"delaylog is the default now, option is deprecated.");
-		} else if (!strcmp(this_char, MNTOPT_NODELAYLOG)) {
+		"delaylog is the default now, option is deprecated.");
+			break;
+		case Opt_nodelaylog:
 			xfs_warn(mp,
-	"nodelaylog support has been removed, option is deprecated.");
-		} else if (!strcmp(this_char, MNTOPT_DISCARD)) {
+		"nodelaylog support has been removed, option is deprecated.");
+			break;
+		case Opt_discard:
 			mp->m_flags |= XFS_MOUNT_DISCARD;
-		} else if (!strcmp(this_char, MNTOPT_NODISCARD)) {
+			break;
+		case Opt_nodiscard:
 			mp->m_flags &= ~XFS_MOUNT_DISCARD;
-		} else if (!strcmp(this_char, "ihashsize")) {
+			break;
+		case Opt_ihashsize:
 			xfs_warn(mp,
-	"ihashsize no longer used, option is deprecated.");
-		} else if (!strcmp(this_char, "osyncisdsync")) {
+		"ihashsize no longer used, option is deprecated.");
+		case Opt_osyncisdsync:
 			xfs_warn(mp,
-	"osyncisdsync has no effect, option is deprecated.");
-		} else if (!strcmp(this_char, "osyncisosync")) {
+		"osyncisdsync has no effect, option is deprecated.");
+			break;
+		case Opt_osyncisosync:
 			xfs_warn(mp,
-	"osyncisosync has no effect, option is deprecated.");
-		} else if (!strcmp(this_char, "irixsgid")) {
+		"osyncisosync has no effect, option is deprecated.");
+			break;
+		case Opt_irixsgid:
 			xfs_warn(mp,
-	"irixsgid is now a sysctl(2) variable, option is deprecated.");
-		} else {
-			xfs_warn(mp, "unknown mount option [%s].", this_char);
-			return EINVAL;
+		"irixsgid is now a sysctl(2) variable, option is deprecated.");
+			break;
+		default:
+			xfs_warn(mp, "unknown mount option [%s].", p);
+			break;
 		}
+
+		kfree(string);
+		string = NULL;
 	}
 
+	kfree(orig);
+
 	/*
 	 * no recovery flag requires a read-only mount
 	 */
@@ -468,92 +528,91 @@ done:
 	}
 
 	return 0;
-}
 
-struct proc_xfs_info {
-	int	flag;
-	char	*str;
-};
+free_string:
+	kfree(string);
+	string = NULL;
+free_orig:
+	kfree(orig);
+	return ret;
+}
 
 STATIC int
-xfs_showargs(
-	struct xfs_mount	*mp,
-	struct seq_file		*m)
+xfs_fs_show_options(
+	struct seq_file		*seq,
+	struct dentry		*dentry)
 {
-	static struct proc_xfs_info xfs_info_set[] = {
-		/* the few simple ones we can get from the mount struct */
-		{ XFS_MOUNT_IKEEP,		"," MNTOPT_IKEEP },
-		{ XFS_MOUNT_WSYNC,		"," MNTOPT_WSYNC },
-		{ XFS_MOUNT_NOALIGN,		"," MNTOPT_NOALIGN },
-		{ XFS_MOUNT_SWALLOC,		"," MNTOPT_SWALLOC },
-		{ XFS_MOUNT_NOUUID,		"," MNTOPT_NOUUID },
-		{ XFS_MOUNT_NORECOVERY,		"," MNTOPT_NORECOVERY },
-		{ XFS_MOUNT_ATTR2,		"," MNTOPT_ATTR2 },
-		{ XFS_MOUNT_FILESTREAMS,	"," MNTOPT_FILESTREAM },
-		{ XFS_MOUNT_GRPID,		"," MNTOPT_GRPID },
-		{ XFS_MOUNT_DISCARD,		"," MNTOPT_DISCARD },
-		{ 0, NULL }
-	};
-	static struct proc_xfs_info xfs_info_unset[] = {
-		/* the few simple ones we can get from the mount struct */
-		{ XFS_MOUNT_COMPAT_IOSIZE,	"," MNTOPT_LARGEIO },
-		{ XFS_MOUNT_BARRIER,		"," MNTOPT_NOBARRIER },
-		{ XFS_MOUNT_SMALL_INUMS,	"," MNTOPT_64BITINODE },
-		{ 0, NULL }
-	};
-	struct proc_xfs_info	*xfs_infop;
-
-	for (xfs_infop = xfs_info_set; xfs_infop->flag; xfs_infop++) {
-		if (mp->m_flags & xfs_infop->flag)
-			seq_puts(m, xfs_infop->str);
-	}
-	for (xfs_infop = xfs_info_unset; xfs_infop->flag; xfs_infop++) {
-		if (!(mp->m_flags & xfs_infop->flag))
-			seq_puts(m, xfs_infop->str);
-	}
+	struct xfs_mount	*mp = XFS_M(dentry->d_sb);
 
-	if (mp->m_flags & XFS_MOUNT_DFLT_IOSIZE)
-		seq_printf(m, "," MNTOPT_ALLOCSIZE "=%dk",
+	if ((mp->m_flags & XFS_MOUNT_IKEEP))
+		seq_puts(seq, ",ikeep");
+	if ((mp->m_flags & XFS_MOUNT_WSYNC))
+		seq_puts(seq, ",wsync");
+	if ((mp->m_flags & XFS_MOUNT_NOALIGN))
+		seq_puts(seq, ",noalign");
+	if ((mp->m_flags & XFS_MOUNT_SWALLOC))
+		seq_puts(seq, ",swalloc");
+	if ((mp->m_flags & XFS_MOUNT_NOUUID))
+		seq_puts(seq, ",nouuid");
+	if ((mp->m_flags & XFS_MOUNT_NORECOVERY))
+		seq_puts(seq, ",norecovery");
+	if ((mp->m_flags & XFS_MOUNT_ATTR2))
+		seq_puts(seq, ",attr2");
+	if ((mp->m_flags & XFS_MOUNT_FILESTREAMS))
+		seq_puts(seq, ",filestreams");
+	if ((mp->m_flags & XFS_MOUNT_GRPID))
+		seq_puts(seq, ",grpid");
+	if ((mp->m_flags & XFS_MOUNT_DISCARD))
+		seq_puts(seq, ",discard");
+	if (!(mp->m_flags & XFS_MOUNT_COMPAT_IOSIZE))
+		seq_puts(seq, ",largeio");
+	if (!(mp->m_flags & XFS_MOUNT_BARRIER))
+		seq_puts(seq, ",nobarrier");
+	if (!(mp->m_flags & XFS_MOUNT_SMALL_INUMS))
+		seq_puts(seq, ",inode64");
+
+	if ((mp->m_flags & XFS_MOUNT_DFLT_IOSIZE))
+		seq_printf(seq, ",allocsize=%dk",
 				(int)(1 << mp->m_writeio_log) >> 10);
 
 	if (mp->m_logbufs > 0)
-		seq_printf(m, "," MNTOPT_LOGBUFS "=%d", mp->m_logbufs);
+		seq_printf(seq, ",logbufs=%d", mp->m_logbufs);
 	if (mp->m_logbsize > 0)
-		seq_printf(m, "," MNTOPT_LOGBSIZE "=%dk", mp->m_logbsize >> 10);
+		seq_printf(seq, ",logbsize=%dk", mp->m_logbsize >> 10);
 
 	if (mp->m_logname)
-		seq_printf(m, "," MNTOPT_LOGDEV "=%s", mp->m_logname);
+		seq_printf(seq, ",logdev=%s", mp->m_logname);
 	if (mp->m_rtname)
-		seq_printf(m, "," MNTOPT_RTDEV "=%s", mp->m_rtname);
+		seq_printf(seq, ",rtdev=%s", mp->m_rtname);
 
 	if (mp->m_dalign > 0)
-		seq_printf(m, "," MNTOPT_SUNIT "=%d",
+		seq_printf(seq, ",sunit=%d",
 				(int)XFS_FSB_TO_BB(mp, mp->m_dalign));
 	if (mp->m_swidth > 0)
-		seq_printf(m, "," MNTOPT_SWIDTH "=%d",
+		seq_printf(seq, ",swidth=%d",
 				(int)XFS_FSB_TO_BB(mp, mp->m_swidth));
 
 	if (mp->m_qflags & (XFS_UQUOTA_ACCT|XFS_UQUOTA_ENFD))
-		seq_puts(m, "," MNTOPT_USRQUOTA);
+		seq_puts(seq, ",usrquota");
 	else if (mp->m_qflags & XFS_UQUOTA_ACCT)
-		seq_puts(m, "," MNTOPT_UQUOTANOENF);
+		seq_puts(seq, ",uqnoenforce");
 
 	/* Either project or group quotas can be active, not both */
 
 	if (mp->m_qflags & XFS_PQUOTA_ACCT) {
 		if (mp->m_qflags & XFS_OQUOTA_ENFD)
-			seq_puts(m, "," MNTOPT_PRJQUOTA);
+			seq_puts(seq, ",prjquota");
 		else
-			seq_puts(m, "," MNTOPT_PQUOTANOENF);
+			seq_puts(seq, ",pqnoenforce");
 	} else if (mp->m_qflags & XFS_GQUOTA_ACCT) {
 		if (mp->m_qflags & XFS_OQUOTA_ENFD)
-			seq_puts(m, "," MNTOPT_GRPQUOTA);
+			seq_puts(seq, ",grpquota");
 		else
-			seq_puts(m, "," MNTOPT_GQUOTANOENF);
+			seq_puts(seq, ",gqnoenforce");
 	}
 
 	if (!(mp->m_qflags & XFS_ALL_QUOTA_ACCT))
-		seq_puts(m, "," MNTOPT_NOQUOTA);
+		seq_puts(seq, ",noquota");
 
 	return 0;
 }
@@ -1221,14 +1280,6 @@ xfs_fs_unfreeze(
 	return 0;
 }
 
-STATIC int
-xfs_fs_show_options(
-	struct seq_file		*m,
-	struct dentry		*root)
-{
-	return -xfs_showargs(XFS_M(root->d_sb), m);
-}
-
 /*
  * This function fills in xfs_mount_t fields based on mount args.
  * Note: the superblock _has_ now been read in.
-- 
1.7.9.2.323.gf051a

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

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

* [PATCH 2/2] xfs: rename xfs_fs_* to xfs_*
  2012-06-29 18:06 ` [PATCH 1/2 V2] " Wanlong Gao
@ 2012-06-29 18:06   ` Wanlong Gao
  2012-07-01 23:47     ` Dave Chinner
  2012-07-02  6:26   ` [PATCH 1/2 V2] xfs: cleanup the mount options Christoph Hellwig
  1 sibling, 1 reply; 31+ messages in thread
From: Wanlong Gao @ 2012-06-29 18:06 UTC (permalink / raw)
  To: XFS; +Cc: Christoph Hellwig, Ben Myers, Wanlong Gao

s/xfs_fs_/xfs_/
This too long name is unnecessary.

CC: Ben Myers <bpm@sgi.com>
CC: Christoph Hellwig <hch@infradead.org>
CC: Dave Chinner <david@fromorbit.com>
Signed-off-by: Wanlong Gao <gaowanlong@cn.fujitsu.com>
---
 fs/xfs/Makefile       |    2 +-
 fs/xfs/xfs_export.c   |   20 +++++------
 fs/xfs/xfs_file.c     |    2 +-
 fs/xfs/xfs_fs_subr.c  |   96 -------------------------------------------------
 fs/xfs/xfs_fsops.c    |    8 ++---
 fs/xfs/xfs_fsops.h    |    8 ++---
 fs/xfs/xfs_ioctl.c    |   10 +++---
 fs/xfs/xfs_ioctl32.c  |    2 +-
 fs/xfs/xfs_log.c      |    2 +-
 fs/xfs/xfs_mount.c    |    4 +--
 fs/xfs/xfs_mount.h    |    2 +-
 fs/xfs/xfs_quotaops.c |   16 ++++-----
 fs/xfs/xfs_subr.c     |   96 +++++++++++++++++++++++++++++++++++++++++++++++++
 fs/xfs/xfs_super.c    |   76 +++++++++++++++++++--------------------
 fs/xfs/xfs_sync.c     |    4 +--
 15 files changed, 174 insertions(+), 174 deletions(-)
 delete mode 100644 fs/xfs/xfs_fs_subr.c
 create mode 100644 fs/xfs/xfs_subr.c

diff --git a/fs/xfs/Makefile b/fs/xfs/Makefile
index d2bf974..8688592 100644
--- a/fs/xfs/Makefile
+++ b/fs/xfs/Makefile
@@ -37,7 +37,7 @@ xfs-y				+= xfs_aops.o \
 				   xfs_file.o \
 				   xfs_filestream.o \
 				   xfs_fsops.o \
-				   xfs_fs_subr.o \
+				   xfs_subr.o \
 				   xfs_globals.o \
 				   xfs_iget.o \
 				   xfs_ioctl.o \
diff --git a/fs/xfs/xfs_export.c b/fs/xfs/xfs_export.c
index 4267922..0e25c37 100644
--- a/fs/xfs/xfs_export.c
+++ b/fs/xfs/xfs_export.c
@@ -51,7 +51,7 @@ static int xfs_fileid_length(int fileid_type)
 }
 
 STATIC int
-xfs_fs_encode_fh(
+xfs_encode_fh(
 	struct inode	*inode,
 	__u32		*fh,
 	int		*max_len,
@@ -159,7 +159,7 @@ xfs_nfs_get_inode(
 }
 
 STATIC struct dentry *
-xfs_fs_fh_to_dentry(struct super_block *sb, struct fid *fid,
+xfs_fh_to_dentry(struct super_block *sb, struct fid *fid,
 		 int fh_len, int fileid_type)
 {
 	struct xfs_fid64	*fid64 = (struct xfs_fid64 *)fid;
@@ -183,7 +183,7 @@ xfs_fs_fh_to_dentry(struct super_block *sb, struct fid *fid,
 }
 
 STATIC struct dentry *
-xfs_fs_fh_to_parent(struct super_block *sb, struct fid *fid,
+xfs_fh_to_parent(struct super_block *sb, struct fid *fid,
 		 int fh_len, int fileid_type)
 {
 	struct xfs_fid64	*fid64 = (struct xfs_fid64 *)fid;
@@ -204,7 +204,7 @@ xfs_fs_fh_to_parent(struct super_block *sb, struct fid *fid,
 }
 
 STATIC struct dentry *
-xfs_fs_get_parent(
+xfs_get_parent(
 	struct dentry		*child)
 {
 	int			error;
@@ -218,7 +218,7 @@ xfs_fs_get_parent(
 }
 
 STATIC int
-xfs_fs_nfs_commit_metadata(
+xfs_nfs_commit_metadata(
 	struct inode		*inode)
 {
 	struct xfs_inode	*ip = XFS_I(inode);
@@ -236,9 +236,9 @@ xfs_fs_nfs_commit_metadata(
 }
 
 const struct export_operations xfs_export_operations = {
-	.encode_fh		= xfs_fs_encode_fh,
-	.fh_to_dentry		= xfs_fs_fh_to_dentry,
-	.fh_to_parent		= xfs_fs_fh_to_parent,
-	.get_parent		= xfs_fs_get_parent,
-	.commit_metadata	= xfs_fs_nfs_commit_metadata,
+	.encode_fh		= xfs_encode_fh,
+	.fh_to_dentry		= xfs_fh_to_dentry,
+	.fh_to_parent		= xfs_fh_to_parent,
+	.get_parent		= xfs_get_parent,
+	.commit_metadata	= xfs_nfs_commit_metadata,
 };
diff --git a/fs/xfs/xfs_file.c b/fs/xfs/xfs_file.c
index c4559c6..da9c4c5 100644
--- a/fs/xfs/xfs_file.c
+++ b/fs/xfs/xfs_file.c
@@ -571,7 +571,7 @@ restart:
 
 	/*
 	 * Updating the timestamps will grab the ilock again from
-	 * xfs_fs_dirty_inode, so we have to call it after dropping the
+	 * xfs_dirty_inode, so we have to call it after dropping the
 	 * lock above.  Eventually we should look into a way to avoid
 	 * the pointless lock roundtrip.
 	 */
diff --git a/fs/xfs/xfs_fs_subr.c b/fs/xfs/xfs_fs_subr.c
deleted file mode 100644
index 652b875..0000000
--- a/fs/xfs/xfs_fs_subr.c
+++ /dev/null
@@ -1,96 +0,0 @@
-/*
- * Copyright (c) 2000-2002,2005-2006 Silicon Graphics, Inc.
- * All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write the Free Software Foundation,
- * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
- */
-#include "xfs.h"
-#include "xfs_vnodeops.h"
-#include "xfs_bmap_btree.h"
-#include "xfs_inode.h"
-#include "xfs_trace.h"
-
-/*
- * note: all filemap functions return negative error codes. These
- * need to be inverted before returning to the xfs core functions.
- */
-void
-xfs_tosspages(
-	xfs_inode_t	*ip,
-	xfs_off_t	first,
-	xfs_off_t	last,
-	int		fiopt)
-{
-	/* can't toss partial tail pages, so mask them out */
-	last &= ~(PAGE_SIZE - 1);
-	truncate_inode_pages_range(VFS_I(ip)->i_mapping, first, last - 1);
-}
-
-int
-xfs_flushinval_pages(
-	xfs_inode_t	*ip,
-	xfs_off_t	first,
-	xfs_off_t	last,
-	int		fiopt)
-{
-	struct address_space *mapping = VFS_I(ip)->i_mapping;
-	int		ret = 0;
-
-	trace_xfs_pagecache_inval(ip, first, last);
-
-	xfs_iflags_clear(ip, XFS_ITRUNCATED);
-	ret = filemap_write_and_wait_range(mapping, first,
-				last == -1 ? LLONG_MAX : last);
-	if (!ret)
-		truncate_inode_pages_range(mapping, first, last);
-	return -ret;
-}
-
-int
-xfs_flush_pages(
-	xfs_inode_t	*ip,
-	xfs_off_t	first,
-	xfs_off_t	last,
-	uint64_t	flags,
-	int		fiopt)
-{
-	struct address_space *mapping = VFS_I(ip)->i_mapping;
-	int		ret = 0;
-	int		ret2;
-
-	xfs_iflags_clear(ip, XFS_ITRUNCATED);
-	ret = -filemap_fdatawrite_range(mapping, first,
-				last == -1 ? LLONG_MAX : last);
-	if (flags & XBF_ASYNC)
-		return ret;
-	ret2 = xfs_wait_on_pages(ip, first, last);
-	if (!ret)
-		ret = ret2;
-	return ret;
-}
-
-int
-xfs_wait_on_pages(
-	xfs_inode_t	*ip,
-	xfs_off_t	first,
-	xfs_off_t	last)
-{
-	struct address_space *mapping = VFS_I(ip)->i_mapping;
-
-	if (mapping_tagged(mapping, PAGECACHE_TAG_WRITEBACK)) {
-		return -filemap_fdatawait_range(mapping, first,
-					last == -1 ? XFS_ISIZE(ip) - 1 : last);
-	}
-	return 0;
-}
diff --git a/fs/xfs/xfs_fsops.c b/fs/xfs/xfs_fsops.c
index c25b094..09c39c5 100644
--- a/fs/xfs/xfs_fsops.c
+++ b/fs/xfs/xfs_fsops.c
@@ -45,7 +45,7 @@
  */
 
 int
-xfs_fs_geometry(
+xfs_geometry(
 	xfs_mount_t		*mp,
 	xfs_fsop_geom_t		*geo,
 	int			new_version)
@@ -496,7 +496,7 @@ xfs_growfs_log(
  */
 
 int
-xfs_fs_counts(
+xfs_counts(
 	xfs_mount_t		*mp,
 	xfs_fsop_counts_t	*cnt)
 {
@@ -638,7 +638,7 @@ out:
  * and can be written back.
  */
 int
-xfs_fs_log_dummy(
+xfs_log_dummy(
 	xfs_mount_t	*mp)
 {
 	xfs_trans_t	*tp;
@@ -659,7 +659,7 @@ xfs_fs_log_dummy(
 }
 
 int
-xfs_fs_goingdown(
+xfs_goingdown(
 	xfs_mount_t	*mp,
 	__uint32_t	inflags)
 {
diff --git a/fs/xfs/xfs_fsops.h b/fs/xfs/xfs_fsops.h
index 1b6a98b..3a24888 100644
--- a/fs/xfs/xfs_fsops.h
+++ b/fs/xfs/xfs_fsops.h
@@ -18,13 +18,13 @@
 #ifndef __XFS_FSOPS_H__
 #define	__XFS_FSOPS_H__
 
-extern int xfs_fs_geometry(xfs_mount_t *mp, xfs_fsop_geom_t *geo, int nversion);
+extern int xfs_geometry(xfs_mount_t *mp, xfs_fsop_geom_t *geo, int nversion);
 extern int xfs_growfs_data(xfs_mount_t *mp, xfs_growfs_data_t *in);
 extern int xfs_growfs_log(xfs_mount_t *mp, xfs_growfs_log_t *in);
-extern int xfs_fs_counts(xfs_mount_t *mp, xfs_fsop_counts_t *cnt);
+extern int xfs_counts(xfs_mount_t *mp, xfs_fsop_counts_t *cnt);
 extern int xfs_reserve_blocks(xfs_mount_t *mp, __uint64_t *inval,
 				xfs_fsop_resblks_t *outval);
-extern int xfs_fs_goingdown(xfs_mount_t *mp, __uint32_t inflags);
-extern int xfs_fs_log_dummy(struct xfs_mount *mp);
+extern int xfs_goingdown(xfs_mount_t *mp, __uint32_t inflags);
+extern int xfs_log_dummy(struct xfs_mount *mp);
 
 #endif	/* __XFS_FSOPS_H__ */
diff --git a/fs/xfs/xfs_ioctl.c b/fs/xfs/xfs_ioctl.c
index 3a05a41..fb61ec5 100644
--- a/fs/xfs/xfs_ioctl.c
+++ b/fs/xfs/xfs_ioctl.c
@@ -702,14 +702,14 @@ xfs_ioc_fsgeometry_v1(
 	xfs_fsop_geom_t         fsgeo;
 	int			error;
 
-	error = xfs_fs_geometry(mp, &fsgeo, 3);
+	error = xfs_geometry(mp, &fsgeo, 3);
 	if (error)
 		return -error;
 
 	/*
 	 * Caller should have passed an argument of type
 	 * xfs_fsop_geom_v1_t.  This is a proper subset of the
-	 * xfs_fsop_geom_t that xfs_fs_geometry() fills in.
+	 * xfs_fsop_geom_t that xfs_geometry() fills in.
 	 */
 	if (copy_to_user(arg, &fsgeo, sizeof(xfs_fsop_geom_v1_t)))
 		return -XFS_ERROR(EFAULT);
@@ -724,7 +724,7 @@ xfs_ioc_fsgeometry(
 	xfs_fsop_geom_t		fsgeo;
 	int			error;
 
-	error = xfs_fs_geometry(mp, &fsgeo, 4);
+	error = xfs_geometry(mp, &fsgeo, 4);
 	if (error)
 		return -error;
 
@@ -1438,7 +1438,7 @@ xfs_file_ioctl(
 	case XFS_IOC_FSCOUNTS: {
 		xfs_fsop_counts_t out;
 
-		error = xfs_fs_counts(mp, &out);
+		error = xfs_counts(mp, &out);
 		if (error)
 			return -error;
 
@@ -1526,7 +1526,7 @@ xfs_file_ioctl(
 		if (get_user(in, (__uint32_t __user *)arg))
 			return -XFS_ERROR(EFAULT);
 
-		error = xfs_fs_goingdown(mp, in);
+		error = xfs_goingdown(mp, in);
 		return -error;
 	}
 
diff --git a/fs/xfs/xfs_ioctl32.c b/fs/xfs/xfs_ioctl32.c
index c4f2da0..0d6267e 100644
--- a/fs/xfs/xfs_ioctl32.c
+++ b/fs/xfs/xfs_ioctl32.c
@@ -71,7 +71,7 @@ xfs_compat_ioc_fsgeometry_v1(
 	xfs_fsop_geom_t		  fsgeo;
 	int			  error;
 
-	error = xfs_fs_geometry(mp, &fsgeo, 3);
+	error = xfs_geometry(mp, &fsgeo, 3);
 	if (error)
 		return -error;
 	/* The 32-bit variant simply has some padding at the end */
diff --git a/fs/xfs/xfs_log.c b/fs/xfs/xfs_log.c
index 7f4f937..94e7aaf 100644
--- a/fs/xfs/xfs_log.c
+++ b/fs/xfs/xfs_log.c
@@ -931,7 +931,7 @@ xfs_log_need_covered(xfs_mount_t *mp)
 	int		needed = 0;
 	struct xlog	*log = mp->m_log;
 
-	if (!xfs_fs_writable(mp))
+	if (!xfs_writable(mp))
 		return 0;
 
 	spin_lock(&log->l_icloglock);
diff --git a/fs/xfs/xfs_mount.c b/fs/xfs/xfs_mount.c
index 9536fd1..359a695 100644
--- a/fs/xfs/xfs_mount.c
+++ b/fs/xfs/xfs_mount.c
@@ -1540,7 +1540,7 @@ xfs_unmountfs(
 }
 
 int
-xfs_fs_writable(xfs_mount_t *mp)
+xfs_writable(xfs_mount_t *mp)
 {
 	return !(xfs_test_for_freeze(mp) || XFS_FORCED_SHUTDOWN(mp) ||
 		(mp->m_flags & XFS_MOUNT_RDONLY));
@@ -1561,7 +1561,7 @@ xfs_log_sbcount(xfs_mount_t *mp)
 	xfs_trans_t	*tp;
 	int		error;
 
-	if (!xfs_fs_writable(mp))
+	if (!xfs_writable(mp))
 		return 0;
 
 	xfs_icsb_sync_counters(mp, 0);
diff --git a/fs/xfs/xfs_mount.h b/fs/xfs/xfs_mount.h
index 8724336..76ce45a 100644
--- a/fs/xfs/xfs_mount.h
+++ b/fs/xfs/xfs_mount.h
@@ -383,7 +383,7 @@ extern int	xfs_mount_log_sb(xfs_mount_t *, __int64_t);
 extern struct xfs_buf *xfs_getsb(xfs_mount_t *, int);
 extern int	xfs_readsb(xfs_mount_t *, int);
 extern void	xfs_freesb(xfs_mount_t *);
-extern int	xfs_fs_writable(xfs_mount_t *);
+extern int	xfs_writable(xfs_mount_t *);
 extern int	xfs_sb_validate_fsb_count(struct xfs_sb *, __uint64_t);
 
 extern int	xfs_dev_is_read_only(struct xfs_mount *, char *);
diff --git a/fs/xfs/xfs_quotaops.c b/fs/xfs/xfs_quotaops.c
index fed504f..18f64b0 100644
--- a/fs/xfs/xfs_quotaops.c
+++ b/fs/xfs/xfs_quotaops.c
@@ -42,7 +42,7 @@ xfs_quota_type(int type)
 }
 
 STATIC int
-xfs_fs_get_xstate(
+xfs_get_xstate(
 	struct super_block	*sb,
 	struct fs_quota_stat	*fqs)
 {
@@ -54,7 +54,7 @@ xfs_fs_get_xstate(
 }
 
 STATIC int
-xfs_fs_set_xstate(
+xfs_set_xstate(
 	struct super_block	*sb,
 	unsigned int		uflags,
 	int			op)
@@ -95,7 +95,7 @@ xfs_fs_set_xstate(
 }
 
 STATIC int
-xfs_fs_get_dqblk(
+xfs_get_dqblk(
 	struct super_block	*sb,
 	int			type,
 	qid_t			id,
@@ -112,7 +112,7 @@ xfs_fs_get_dqblk(
 }
 
 STATIC int
-xfs_fs_set_dqblk(
+xfs_set_dqblk(
 	struct super_block	*sb,
 	int			type,
 	qid_t			id,
@@ -131,8 +131,8 @@ xfs_fs_set_dqblk(
 }
 
 const struct quotactl_ops xfs_quotactl_operations = {
-	.get_xstate		= xfs_fs_get_xstate,
-	.set_xstate		= xfs_fs_set_xstate,
-	.get_dqblk		= xfs_fs_get_dqblk,
-	.set_dqblk		= xfs_fs_set_dqblk,
+	.get_xstate		= xfs_get_xstate,
+	.set_xstate		= xfs_set_xstate,
+	.get_dqblk		= xfs_get_dqblk,
+	.set_dqblk		= xfs_set_dqblk,
 };
diff --git a/fs/xfs/xfs_subr.c b/fs/xfs/xfs_subr.c
new file mode 100644
index 0000000..652b875
--- /dev/null
+++ b/fs/xfs/xfs_subr.c
@@ -0,0 +1,96 @@
+/*
+ * Copyright (c) 2000-2002,2005-2006 Silicon Graphics, Inc.
+ * All Rights Reserved.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it would be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write the Free Software Foundation,
+ * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+#include "xfs.h"
+#include "xfs_vnodeops.h"
+#include "xfs_bmap_btree.h"
+#include "xfs_inode.h"
+#include "xfs_trace.h"
+
+/*
+ * note: all filemap functions return negative error codes. These
+ * need to be inverted before returning to the xfs core functions.
+ */
+void
+xfs_tosspages(
+	xfs_inode_t	*ip,
+	xfs_off_t	first,
+	xfs_off_t	last,
+	int		fiopt)
+{
+	/* can't toss partial tail pages, so mask them out */
+	last &= ~(PAGE_SIZE - 1);
+	truncate_inode_pages_range(VFS_I(ip)->i_mapping, first, last - 1);
+}
+
+int
+xfs_flushinval_pages(
+	xfs_inode_t	*ip,
+	xfs_off_t	first,
+	xfs_off_t	last,
+	int		fiopt)
+{
+	struct address_space *mapping = VFS_I(ip)->i_mapping;
+	int		ret = 0;
+
+	trace_xfs_pagecache_inval(ip, first, last);
+
+	xfs_iflags_clear(ip, XFS_ITRUNCATED);
+	ret = filemap_write_and_wait_range(mapping, first,
+				last == -1 ? LLONG_MAX : last);
+	if (!ret)
+		truncate_inode_pages_range(mapping, first, last);
+	return -ret;
+}
+
+int
+xfs_flush_pages(
+	xfs_inode_t	*ip,
+	xfs_off_t	first,
+	xfs_off_t	last,
+	uint64_t	flags,
+	int		fiopt)
+{
+	struct address_space *mapping = VFS_I(ip)->i_mapping;
+	int		ret = 0;
+	int		ret2;
+
+	xfs_iflags_clear(ip, XFS_ITRUNCATED);
+	ret = -filemap_fdatawrite_range(mapping, first,
+				last == -1 ? LLONG_MAX : last);
+	if (flags & XBF_ASYNC)
+		return ret;
+	ret2 = xfs_wait_on_pages(ip, first, last);
+	if (!ret)
+		ret = ret2;
+	return ret;
+}
+
+int
+xfs_wait_on_pages(
+	xfs_inode_t	*ip,
+	xfs_off_t	first,
+	xfs_off_t	last)
+{
+	struct address_space *mapping = VFS_I(ip)->i_mapping;
+
+	if (mapping_tagged(mapping, PAGECACHE_TAG_WRITEBACK)) {
+		return -filemap_fdatawait_range(mapping, first,
+					last == -1 ? XFS_ISIZE(ip) - 1 : last);
+	}
+	return 0;
+}
diff --git a/fs/xfs/xfs_super.c b/fs/xfs/xfs_super.c
index 36d139b..3b0ada2 100644
--- a/fs/xfs/xfs_super.c
+++ b/fs/xfs/xfs_super.c
@@ -538,7 +538,7 @@ free_orig:
 }
 
 STATIC int
-xfs_fs_show_options(
+xfs_show_options(
 	struct seq_file		*seq,
 	struct dentry		*dentry)
 {
@@ -856,7 +856,7 @@ xfs_destroy_mount_workqueues(
 
 /* Catch misguided souls that try to use this interface on XFS */
 STATIC struct inode *
-xfs_fs_alloc_inode(
+xfs_alloc_inode(
 	struct super_block	*sb)
 {
 	BUG();
@@ -868,7 +868,7 @@ xfs_fs_alloc_inode(
  * the linux inode, we can reclaim the inode.
  */
 STATIC void
-xfs_fs_destroy_inode(
+xfs_destroy_inode(
 	struct inode		*inode)
 {
 	struct xfs_inode	*ip = XFS_I(inode);
@@ -909,7 +909,7 @@ out_reclaim:
  * when freeing the inode.
  */
 STATIC void
-xfs_fs_inode_init_once(
+xfs_inode_init_once(
 	void			*inode)
 {
 	struct xfs_inode	*ip = inode;
@@ -940,7 +940,7 @@ xfs_fs_inode_init_once(
  * error handling here.
  */
 STATIC void
-xfs_fs_dirty_inode(
+xfs_dirty_inode(
 	struct inode		*inode,
 	int			flags)
 {
@@ -983,7 +983,7 @@ trouble:
 }
 
 STATIC void
-xfs_fs_evict_inode(
+xfs_evict_inode(
 	struct inode		*inode)
 {
 	xfs_inode_t		*ip = XFS_I(inode);
@@ -1023,7 +1023,7 @@ xfs_fs_evict_inode(
  * we drop the final reference on.
  */
 STATIC int
-xfs_fs_drop_inode(
+xfs_drop_inode(
 	struct inode		*inode)
 {
 	struct xfs_inode	*ip = XFS_I(inode);
@@ -1041,7 +1041,7 @@ xfs_free_fsname(
 }
 
 STATIC void
-xfs_fs_put_super(
+xfs_put_super(
 	struct super_block	*sb)
 {
 	struct xfs_mount	*mp = XFS_M(sb);
@@ -1058,7 +1058,7 @@ xfs_fs_put_super(
 }
 
 STATIC int
-xfs_fs_sync_fs(
+xfs_sync_fs(
 	struct super_block	*sb,
 	int			wait)
 {
@@ -1088,7 +1088,7 @@ xfs_fs_sync_fs(
 }
 
 STATIC int
-xfs_fs_statfs(
+xfs_statfs(
 	struct dentry		*dentry,
 	struct kstatfs		*statp)
 {
@@ -1159,7 +1159,7 @@ xfs_restore_resvblks(struct xfs_mount *mp)
 }
 
 STATIC int
-xfs_fs_remount(
+xfs_remount(
 	struct super_block	*sb,
 	int			*flags,
 	char			*options)
@@ -1260,18 +1260,18 @@ xfs_fs_remount(
  * record to dirty the log in case of a crash while frozen.
  */
 STATIC int
-xfs_fs_freeze(
+xfs_freeze(
 	struct super_block	*sb)
 {
 	struct xfs_mount	*mp = XFS_M(sb);
 
 	xfs_save_resvblks(mp);
 	xfs_quiesce_attr(mp);
-	return -xfs_fs_log_dummy(mp);
+	return -xfs_log_dummy(mp);
 }
 
 STATIC int
-xfs_fs_unfreeze(
+xfs_unfreeze(
 	struct super_block	*sb)
 {
 	struct xfs_mount	*mp = XFS_M(sb);
@@ -1331,7 +1331,7 @@ xfs_finish_flags(
 }
 
 STATIC int
-xfs_fs_fill_super(
+xfs_fill_super(
 	struct super_block	*sb,
 	void			*data,
 	int			silent)
@@ -1460,24 +1460,24 @@ out_destroy_workqueues:
 }
 
 STATIC struct dentry *
-xfs_fs_mount(
+xfs_mount(
 	struct file_system_type	*fs_type,
 	int			flags,
 	const char		*dev_name,
 	void			*data)
 {
-	return mount_bdev(fs_type, flags, dev_name, data, xfs_fs_fill_super);
+	return mount_bdev(fs_type, flags, dev_name, data, xfs_fill_super);
 }
 
 static int
-xfs_fs_nr_cached_objects(
+xfs_nr_cached_objects(
 	struct super_block	*sb)
 {
 	return xfs_reclaim_inodes_count(XFS_M(sb));
 }
 
 static void
-xfs_fs_free_cached_objects(
+xfs_free_cached_objects(
 	struct super_block	*sb,
 	int			nr_to_scan)
 {
@@ -1485,26 +1485,26 @@ xfs_fs_free_cached_objects(
 }
 
 static const struct super_operations xfs_super_operations = {
-	.alloc_inode		= xfs_fs_alloc_inode,
-	.destroy_inode		= xfs_fs_destroy_inode,
-	.dirty_inode		= xfs_fs_dirty_inode,
-	.evict_inode		= xfs_fs_evict_inode,
-	.drop_inode		= xfs_fs_drop_inode,
-	.put_super		= xfs_fs_put_super,
-	.sync_fs		= xfs_fs_sync_fs,
-	.freeze_fs		= xfs_fs_freeze,
-	.unfreeze_fs		= xfs_fs_unfreeze,
-	.statfs			= xfs_fs_statfs,
-	.remount_fs		= xfs_fs_remount,
-	.show_options		= xfs_fs_show_options,
-	.nr_cached_objects	= xfs_fs_nr_cached_objects,
-	.free_cached_objects	= xfs_fs_free_cached_objects,
+	.alloc_inode		= xfs_alloc_inode,
+	.destroy_inode		= xfs_destroy_inode,
+	.dirty_inode		= xfs_dirty_inode,
+	.evict_inode		= xfs_evict_inode,
+	.drop_inode		= xfs_drop_inode,
+	.put_super		= xfs_put_super,
+	.sync_fs		= xfs_sync_fs,
+	.freeze_fs		= xfs_freeze,
+	.unfreeze_fs		= xfs_unfreeze,
+	.statfs			= xfs_statfs,
+	.remount_fs		= xfs_remount,
+	.show_options		= xfs_show_options,
+	.nr_cached_objects	= xfs_nr_cached_objects,
+	.free_cached_objects	= xfs_free_cached_objects,
 };
 
-static struct file_system_type xfs_fs_type = {
+static struct file_system_type xfs_type = {
 	.owner			= THIS_MODULE,
 	.name			= "xfs",
-	.mount			= xfs_fs_mount,
+	.mount			= xfs_mount,
 	.kill_sb		= kill_block_super,
 	.fs_flags		= FS_REQUIRES_DEV,
 };
@@ -1586,7 +1586,7 @@ xfs_init_zones(void)
 	xfs_inode_zone =
 		kmem_zone_init_flags(sizeof(xfs_inode_t), "xfs_inode",
 			KM_ZONE_HWALIGN | KM_ZONE_RECLAIM | KM_ZONE_SPREAD,
-			xfs_fs_inode_init_once);
+			xfs_inode_init_once);
 	if (!xfs_inode_zone)
 		goto out_destroy_efi_zone;
 
@@ -1730,7 +1730,7 @@ init_xfs_fs(void)
 	if (error)
 		goto out_sysctl_unregister;
 
-	error = register_filesystem(&xfs_fs_type);
+	error = register_filesystem(&xfs_type);
 	if (error)
 		goto out_qm_exit;
 	return 0;
@@ -1759,7 +1759,7 @@ STATIC void __exit
 exit_xfs_fs(void)
 {
 	xfs_qm_exit();
-	unregister_filesystem(&xfs_fs_type);
+	unregister_filesystem(&xfs_type);
 	xfs_sysctl_unregister();
 	xfs_cleanup_procfs();
 	xfs_buf_terminate();
diff --git a/fs/xfs/xfs_sync.c b/fs/xfs/xfs_sync.c
index 1e9ee06..bc64705 100644
--- a/fs/xfs/xfs_sync.c
+++ b/fs/xfs/xfs_sync.c
@@ -314,7 +314,7 @@ xfs_quiesce_data(
 
 	/* mark the log as covered if needed */
 	if (xfs_log_need_covered(mp))
-		error2 = xfs_fs_log_dummy(mp);
+		error2 = xfs_log_dummy(mp);
 
 	return error ? error : error2;
 }
@@ -396,7 +396,7 @@ xfs_sync_worker(
 		/* dgc: errors ignored here */
 		if (mp->m_super->s_frozen == SB_UNFROZEN &&
 		    xfs_log_need_covered(mp))
-			error = xfs_fs_log_dummy(mp);
+			error = xfs_log_dummy(mp);
 		else
 			xfs_log_force(mp, 0);
 
-- 
1.7.9.2.323.gf051a

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

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

* Re: [PATCH 2/2] xfs: rename xfs_fs_* to xfs_*
  2012-06-29 18:06   ` [PATCH 2/2] xfs: rename xfs_fs_* to xfs_* Wanlong Gao
@ 2012-07-01 23:47     ` Dave Chinner
  2012-07-02  0:39       ` Wanlong Gao
  0 siblings, 1 reply; 31+ messages in thread
From: Dave Chinner @ 2012-07-01 23:47 UTC (permalink / raw)
  To: Wanlong Gao; +Cc: Christoph Hellwig, Ben Myers, XFS

On Sat, Jun 30, 2012 at 02:06:42AM +0800, Wanlong Gao wrote:
> s/xfs_fs_/xfs_/
> This too long name is unnecessary.

NACK. Not the right way to approach the problem.

Yes, there are a couple of places where this could be done, but most
of the transformations, IMO, are wrong and remove critical
information from the namespace.

Firstly, we want to get rid of the xfs_fs_subr.c wrappers and
replace them with the native linux functions, not move them around.

Secondly, transformations like xfs_fs_geometry to xfs_geometry are
incorrect - the function is returning the filesystem geometry, so
the name "fs_geometry" is actually correct. Similar for
xfs_fs_writeable, xfs_fs_show_options and so on.

Finally:

>  const struct export_operations xfs_export_operations = {
> -	.encode_fh		= xfs_fs_encode_fh,
> -	.fh_to_dentry		= xfs_fs_fh_to_dentry,
> -	.fh_to_parent		= xfs_fs_fh_to_parent,
> -	.get_parent		= xfs_fs_get_parent,
> -	.commit_metadata	= xfs_fs_nfs_commit_metadata,
> +	.encode_fh		= xfs_encode_fh,
> +	.fh_to_dentry		= xfs_fh_to_dentry,
> +	.fh_to_parent		= xfs_fh_to_parent,
> +	.get_parent		= xfs_get_parent,
> +	.commit_metadata	= xfs_nfs_commit_metadata,

....

>  static const struct super_operations xfs_super_operations = {
> -	.alloc_inode		= xfs_fs_alloc_inode,
> -	.destroy_inode		= xfs_fs_destroy_inode,
> -	.dirty_inode		= xfs_fs_dirty_inode,
> -	.evict_inode		= xfs_fs_evict_inode,
> -	.drop_inode		= xfs_fs_drop_inode,
> -	.put_super		= xfs_fs_put_super,
> -	.sync_fs		= xfs_fs_sync_fs,
> -	.freeze_fs		= xfs_fs_freeze,
> -	.unfreeze_fs		= xfs_fs_unfreeze,
> -	.statfs			= xfs_fs_statfs,
> -	.remount_fs		= xfs_fs_remount,
> -	.show_options		= xfs_fs_show_options,
> -	.nr_cached_objects	= xfs_fs_nr_cached_objects,
> -	.free_cached_objects	= xfs_fs_free_cached_objects,
> +	.alloc_inode		= xfs_alloc_inode,
> +	.destroy_inode		= xfs_destroy_inode,
> +	.dirty_inode		= xfs_dirty_inode,
> +	.evict_inode		= xfs_evict_inode,
> +	.drop_inode		= xfs_drop_inode,
> +	.put_super		= xfs_put_super,
> +	.sync_fs		= xfs_sync_fs,
> +	.freeze_fs		= xfs_freeze,
> +	.unfreeze_fs		= xfs_unfreeze,
> +	.statfs			= xfs_statfs,
> +	.remount_fs		= xfs_remount,
> +	.show_options		= xfs_show_options,
> +	.nr_cached_objects	= xfs_nr_cached_objects,
> +	.free_cached_objects	= xfs_free_cached_objects,
>  };

These should indicate that there is a valid, consistent namespacing
here to indicate layering of the the code. i.e. that xfs_fs_*
functions are typically VFS method functions of some kind. 

> -static struct file_system_type xfs_fs_type = {
> +static struct file_system_type xfs_type = {

And that is a clear demonstration of my second point....

Cheers,

Dave.
-- 
Dave Chinner
david@fromorbit.com

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

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

* Re: [PATCH 2/2] xfs: rename xfs_fs_* to xfs_*
  2012-07-01 23:47     ` Dave Chinner
@ 2012-07-02  0:39       ` Wanlong Gao
  0 siblings, 0 replies; 31+ messages in thread
From: Wanlong Gao @ 2012-07-02  0:39 UTC (permalink / raw)
  To: Dave Chinner; +Cc: Christoph Hellwig, Ben Myers, XFS

On 07/02/2012 07:47 AM, Dave Chinner wrote:
> On Sat, Jun 30, 2012 at 02:06:42AM +0800, Wanlong Gao wrote:
>> s/xfs_fs_/xfs_/
>> This too long name is unnecessary.
> 
> NACK. Not the right way to approach the problem.
> 
> Yes, there are a couple of places where this could be done, but most
> of the transformations, IMO, are wrong and remove critical
> information from the namespace.
> 
> Firstly, we want to get rid of the xfs_fs_subr.c wrappers and
> replace them with the native linux functions, not move them around.
> 
> Secondly, transformations like xfs_fs_geometry to xfs_geometry are
> incorrect - the function is returning the filesystem geometry, so
> the name "fs_geometry" is actually correct. Similar for
> xfs_fs_writeable, xfs_fs_show_options and so on.

Thank you for teaching this.

Wanlong Gao

> 
> Finally:
> 
>>  const struct export_operations xfs_export_operations = {
>> -	.encode_fh		= xfs_fs_encode_fh,
>> -	.fh_to_dentry		= xfs_fs_fh_to_dentry,
>> -	.fh_to_parent		= xfs_fs_fh_to_parent,
>> -	.get_parent		= xfs_fs_get_parent,
>> -	.commit_metadata	= xfs_fs_nfs_commit_metadata,
>> +	.encode_fh		= xfs_encode_fh,
>> +	.fh_to_dentry		= xfs_fh_to_dentry,
>> +	.fh_to_parent		= xfs_fh_to_parent,
>> +	.get_parent		= xfs_get_parent,
>> +	.commit_metadata	= xfs_nfs_commit_metadata,
> 
> ....
> 
>>  static const struct super_operations xfs_super_operations = {
>> -	.alloc_inode		= xfs_fs_alloc_inode,
>> -	.destroy_inode		= xfs_fs_destroy_inode,
>> -	.dirty_inode		= xfs_fs_dirty_inode,
>> -	.evict_inode		= xfs_fs_evict_inode,
>> -	.drop_inode		= xfs_fs_drop_inode,
>> -	.put_super		= xfs_fs_put_super,
>> -	.sync_fs		= xfs_fs_sync_fs,
>> -	.freeze_fs		= xfs_fs_freeze,
>> -	.unfreeze_fs		= xfs_fs_unfreeze,
>> -	.statfs			= xfs_fs_statfs,
>> -	.remount_fs		= xfs_fs_remount,
>> -	.show_options		= xfs_fs_show_options,
>> -	.nr_cached_objects	= xfs_fs_nr_cached_objects,
>> -	.free_cached_objects	= xfs_fs_free_cached_objects,
>> +	.alloc_inode		= xfs_alloc_inode,
>> +	.destroy_inode		= xfs_destroy_inode,
>> +	.dirty_inode		= xfs_dirty_inode,
>> +	.evict_inode		= xfs_evict_inode,
>> +	.drop_inode		= xfs_drop_inode,
>> +	.put_super		= xfs_put_super,
>> +	.sync_fs		= xfs_sync_fs,
>> +	.freeze_fs		= xfs_freeze,
>> +	.unfreeze_fs		= xfs_unfreeze,
>> +	.statfs			= xfs_statfs,
>> +	.remount_fs		= xfs_remount,
>> +	.show_options		= xfs_show_options,
>> +	.nr_cached_objects	= xfs_nr_cached_objects,
>> +	.free_cached_objects	= xfs_free_cached_objects,
>>  };
> 
> These should indicate that there is a valid, consistent namespacing
> here to indicate layering of the the code. i.e. that xfs_fs_*
> functions are typically VFS method functions of some kind. 
> 
>> -static struct file_system_type xfs_fs_type = {
>> +static struct file_system_type xfs_type = {
> 
> And that is a clear demonstration of my second point....
> 
> Cheers,
> 
> Dave.
> 


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

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

* Re: [PATCH 1/2 V2] xfs: cleanup the mount options
  2012-06-29 18:06 ` [PATCH 1/2 V2] " Wanlong Gao
  2012-06-29 18:06   ` [PATCH 2/2] xfs: rename xfs_fs_* to xfs_* Wanlong Gao
@ 2012-07-02  6:26   ` Christoph Hellwig
  2012-07-02  7:05     ` [PATCH V3] " Wanlong Gao
  1 sibling, 1 reply; 31+ messages in thread
From: Christoph Hellwig @ 2012-07-02  6:26 UTC (permalink / raw)
  To: Wanlong Gao; +Cc: Christoph Hellwig, Ben Myers, Zach Brown, XFS

On Sat, Jun 30, 2012 at 02:06:41AM +0800, Wanlong Gao wrote:
> remove the mount options macro, use tokens instead.
> 
> CC: Ben Myers <bpm@sgi.com>
> CC: Christoph Hellwig <hch@infradead.org>
> CC: Dave Chinner <david@fromorbit.com>
> CC: Zach Brown <zab@zabbo.net>
> Signed-off-by: Wanlong Gao <gaowanlong@cn.fujitsu.com>
> ---
>  fs/xfs/xfs_super.c |  523 ++++++++++++++++++++++++++++------------------------
>  1 file changed, 287 insertions(+), 236 deletions(-)

This looks pretty good, some minor comments below:

>  /*
>   * Table driven mount option parser.
>   */

This comment can go now that there is only a single mount option parser.

> +free_string:
> +	kfree(string);
> +	string = NULL;
> +free_orig:
> +	kfree(orig);
> +	return ret;
> +}

no need to set string to NULL just before returning.

> -	static struct proc_xfs_info xfs_info_set[] = {
> -		/* the few simple ones we can get from the mount struct */
> -		{ XFS_MOUNT_IKEEP,		"," MNTOPT_IKEEP },
> -		{ XFS_MOUNT_WSYNC,		"," MNTOPT_WSYNC },
> -		{ XFS_MOUNT_NOALIGN,		"," MNTOPT_NOALIGN },
> -		{ XFS_MOUNT_SWALLOC,		"," MNTOPT_SWALLOC },
> -		{ XFS_MOUNT_NOUUID,		"," MNTOPT_NOUUID },
> -		{ XFS_MOUNT_NORECOVERY,		"," MNTOPT_NORECOVERY },
> -		{ XFS_MOUNT_ATTR2,		"," MNTOPT_ATTR2 },
> -		{ XFS_MOUNT_FILESTREAMS,	"," MNTOPT_FILESTREAM },
> -		{ XFS_MOUNT_GRPID,		"," MNTOPT_GRPID },
> -		{ XFS_MOUNT_DISCARD,		"," MNTOPT_DISCARD },
> -		{ 0, NULL }
> -	};
> -	static struct proc_xfs_info xfs_info_unset[] = {
> -		/* the few simple ones we can get from the mount struct */
> -		{ XFS_MOUNT_COMPAT_IOSIZE,	"," MNTOPT_LARGEIO },
> -		{ XFS_MOUNT_BARRIER,		"," MNTOPT_NOBARRIER },
> -		{ XFS_MOUNT_SMALL_INUMS,	"," MNTOPT_64BITINODE },
> -		{ 0, NULL }
> -	};

I can't find any good reason to remove these tables, just replace the
MNTOPT_ constants with the plain strings.

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

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

* [PATCH V3] xfs: cleanup the mount options
  2012-07-02  6:26   ` [PATCH 1/2 V2] xfs: cleanup the mount options Christoph Hellwig
@ 2012-07-02  7:05     ` Wanlong Gao
  2012-07-06  3:05       ` Dave Chinner
  0 siblings, 1 reply; 31+ messages in thread
From: Wanlong Gao @ 2012-07-02  7:05 UTC (permalink / raw)
  To: xfs; +Cc: Christoph Hellwig, Ben Myers, Zach Brown, Wanlong Gao

remove the mount options macro, use tokens instead.

CC: Ben Myers <bpm@sgi.com>
CC: Christoph Hellwig <hch@infradead.org>
CC: Dave Chinner <david@fromorbit.com>
CC: Zach Brown <zab@zabbo.net>
Signed-off-by: Wanlong Gao <gaowanlong@cn.fujitsu.com>
---
 fs/xfs/xfs_super.c | 510 ++++++++++++++++++++++++++++++++---------------------
 1 file changed, 307 insertions(+), 203 deletions(-)

diff --git a/fs/xfs/xfs_super.c b/fs/xfs/xfs_super.c
index 0d9de41..021da01 100644
--- a/fs/xfs/xfs_super.c
+++ b/fs/xfs/xfs_super.c
@@ -66,66 +66,116 @@ static const struct super_operations xfs_super_operations;
 static kmem_zone_t *xfs_ioend_zone;
 mempool_t *xfs_ioend_pool;
 
-#define MNTOPT_LOGBUFS	"logbufs"	/* number of XFS log buffers */
-#define MNTOPT_LOGBSIZE	"logbsize"	/* size of XFS log buffers */
-#define MNTOPT_LOGDEV	"logdev"	/* log device */
-#define MNTOPT_RTDEV	"rtdev"		/* realtime I/O device */
-#define MNTOPT_BIOSIZE	"biosize"	/* log2 of preferred buffered io size */
-#define MNTOPT_WSYNC	"wsync"		/* safe-mode nfs compatible mount */
-#define MNTOPT_NOALIGN	"noalign"	/* turn off stripe alignment */
-#define MNTOPT_SWALLOC	"swalloc"	/* turn on stripe width allocation */
-#define MNTOPT_SUNIT	"sunit"		/* data volume stripe unit */
-#define MNTOPT_SWIDTH	"swidth"	/* data volume stripe width */
-#define MNTOPT_NOUUID	"nouuid"	/* ignore filesystem UUID */
-#define MNTOPT_MTPT	"mtpt"		/* filesystem mount point */
-#define MNTOPT_GRPID	"grpid"		/* group-ID from parent directory */
-#define MNTOPT_NOGRPID	"nogrpid"	/* group-ID from current process */
-#define MNTOPT_BSDGROUPS    "bsdgroups"    /* group-ID from parent directory */
-#define MNTOPT_SYSVGROUPS   "sysvgroups"   /* group-ID from current process */
-#define MNTOPT_ALLOCSIZE    "allocsize"    /* preferred allocation size */
-#define MNTOPT_NORECOVERY   "norecovery"   /* don't run XFS recovery */
-#define MNTOPT_BARRIER	"barrier"	/* use writer barriers for log write and
-					 * unwritten extent conversion */
-#define MNTOPT_NOBARRIER "nobarrier"	/* .. disable */
-#define MNTOPT_64BITINODE   "inode64"	/* inodes can be allocated anywhere */
-#define MNTOPT_IKEEP	"ikeep"		/* do not free empty inode clusters */
-#define MNTOPT_NOIKEEP	"noikeep"	/* free empty inode clusters */
-#define MNTOPT_LARGEIO	   "largeio"	/* report large I/O sizes in stat() */
-#define MNTOPT_NOLARGEIO   "nolargeio"	/* do not report large I/O sizes
-					 * in stat(). */
-#define MNTOPT_ATTR2	"attr2"		/* do use attr2 attribute format */
-#define MNTOPT_NOATTR2	"noattr2"	/* do not use attr2 attribute format */
-#define MNTOPT_FILESTREAM  "filestreams" /* use filestreams allocator */
-#define MNTOPT_QUOTA	"quota"		/* disk quotas (user) */
-#define MNTOPT_NOQUOTA	"noquota"	/* no quotas */
-#define MNTOPT_USRQUOTA	"usrquota"	/* user quota enabled */
-#define MNTOPT_GRPQUOTA	"grpquota"	/* group quota enabled */
-#define MNTOPT_PRJQUOTA	"prjquota"	/* project quota enabled */
-#define MNTOPT_UQUOTA	"uquota"	/* user quota (IRIX variant) */
-#define MNTOPT_GQUOTA	"gquota"	/* group quota (IRIX variant) */
-#define MNTOPT_PQUOTA	"pquota"	/* project quota (IRIX variant) */
-#define MNTOPT_UQUOTANOENF "uqnoenforce"/* user quota limit enforcement */
-#define MNTOPT_GQUOTANOENF "gqnoenforce"/* group quota limit enforcement */
-#define MNTOPT_PQUOTANOENF "pqnoenforce"/* project quota limit enforcement */
-#define MNTOPT_QUOTANOENF  "qnoenforce"	/* same as uqnoenforce */
-#define MNTOPT_DELAYLOG    "delaylog"	/* Delayed logging enabled */
-#define MNTOPT_NODELAYLOG  "nodelaylog"	/* Delayed logging disabled */
-#define MNTOPT_DISCARD	   "discard"	/* Discard unused blocks */
-#define MNTOPT_NODISCARD   "nodiscard"	/* Do not discard unused blocks */
+#define	MNTOPT_LOGBUFS		"logbufs"
+#define	MNTOPT_LOGBSIZE		"logbsize"
+#define	MNTOPT_LOGDEV		"logdev"
+#define	MNTOPT_RTDEV		"rtdev"
+#define	MNTOPT_BIOSIZE		"biosize"
+#define	MNTOPT_WSYNC		"wsync"
+#define	MNTOPT_NOALIGN		"noalign"
+#define	MNTOPT_SWALLOC		"swalloc"
+#define	MNTOPT_SUNIT		"sunit"
+#define	MNTOPT_SWIDTH		"swidth"
+#define	MNTOPT_NOUUID		"nouuid"
+#define	MNTOPT_MTPT		"mtpt"
+#define	MNTOPT_GRPID		"grpid"
+#define	MNTOPT_NOGRPID		"nogrpid"
+#define	MNTOPT_BSDGROUPS	"bsdgroups"
+#define	MNTOPT_SYSVGROUPS	"sysvgroups"
+#define	MNTOPT_ALLOCSIZE	"allocsize"
+#define	MNTOPT_NORECOVERY	"norecovery"
+#define	MNTOPT_BARRIER		"barrier"
+#define	MNTOPT_NOBARRIER	"nobarrier"
+#define	MNTOPT_64BITINODE	"inode64"
+#define	MNTOPT_IKEEP		"ikeep"
+#define	MNTOPT_NOIKEEP		"noikeep"
+#define	MNTOPT_LARGEIO		"largeio"
+#define	MNTOPT_NOLARGEIO	"nolargeio"
+#define	MNTOPT_ATTR2		"attr2"
+#define	MNTOPT_NOATTR2		"noattr2"
+#define	MNTOPT_FILESTREAM	"filestreams"
+#define	MNTOPT_QUOTA		"quota"
+#define	MNTOPT_NOQUOTA		"noquota"
+#define	MNTOPT_USRQUOTA		"usrquota"
+#define	MNTOPT_GRPQUOTA		"grpquota"
+#define	MNTOPT_PRJQUOTA		"prjquota"
+#define	MNTOPT_UQUOTA		"uquota"
+#define	MNTOPT_GQUOTA		"gquota"
+#define	MNTOPT_PQUOTA		"pquota"
+#define	MNTOPT_UQUOTANOENF	"uqnoenforce"
+#define	MNTOPT_GQUOTANOENF	"gqnoenforce"
+#define	MNTOPT_PQUOTANOENF	"pqnoenforce"
+#define	MNTOPT_QUOTANOENF	"qnoenforce"
+#define	MNTOPT_DELAYLOG		"delaylog"
+#define	MNTOPT_NODELAYLOG	"nodelaylog"
+#define	MNTOPT_DISCARD		"discard"
+#define	MNTOPT_NODISCARD	"nodiscard"
 
-/*
- * Table driven mount option parser.
- *
- * Currently only used for remount, but it will be used for mount
- * in the future, too.
- */
 enum {
-	Opt_barrier, Opt_nobarrier, Opt_err
+	Opt_logbufs, Opt_logbsize, Opt_logdev, Opt_rtdev, Opt_biosize,
+	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_inode64, Opt_ikeep, Opt_noikeep, Opt_largeio,
+	Opt_nolargeio, Opt_attr2, Opt_noattr2, Opt_filestreams, Opt_quota,
+	Opt_noquota, Opt_usrquota, Opt_grpquota, Opt_prjquota, Opt_uquota,
+	Opt_gquota, Opt_pquota, Opt_uqnoenf, Opt_gqnoenf, Opt_pqnoenf,
+	Opt_qnoenf, Opt_delaylog, Opt_nodelaylog, Opt_discard, Opt_nodiscard,
+	Opt_ihashsize, Opt_osyncisdsync, Opt_osyncisosync, Opt_irixsgid,
+	Opt_err
 };
 
 static const match_table_t tokens = {
-	{Opt_barrier, "barrier"},
-	{Opt_nobarrier, "nobarrier"},
+	{Opt_logbufs, "logbufs=%d"},	/* number of XFS log buffers */
+	{Opt_logbsize, "logbsize=%s"},	/* size of XFS log buffers */
+	{Opt_logdev, "logdev=%s"},	/* log device */
+	{Opt_rtdev, "rtdev=%s"},	/* realtime I/O device */
+	{Opt_biosize, "biosize=%d"},	/* log2 of preferred buffered io size */
+	{Opt_wsync, "wsync"},		/* safe-mode nfs compatible mount */
+	{Opt_noalign, "noalign"},	/* turn off stripe alignment */
+	{Opt_swalloc, "swalloc"},	/* turn on stripe width allocation */
+	{Opt_sunit, "sunit=%d"},	/* data volume stripe unit */
+	{Opt_swidth, "swidth=%d"},	/* data volume stripe width */
+	{Opt_nouuid, "nouuid"},		/* ignore filesystem UUID */
+	{Opt_mtpt, "mtpt"},		/* filesystem mount point */
+	{Opt_grpid, "grpid"},		/* group-ID from parent directory */
+	{Opt_nogrpid, "nogrpid"},	/* group-ID from current process */
+	{Opt_bsdgroups, "bsdgroups"},	/* group-ID from parent directory */
+	{Opt_sysvgroups, "sysvgroups"},	/* group-ID from current process */
+	{Opt_allocsize, "allocsize=%s"},/* preferred allocation size */
+	{Opt_norecovery, "norecovery"},	/* do not run XFS recovery */
+	{Opt_barrier, "barrier"},	/* use writer barrier for log write and
+					 * unwritten extent conversation */
+	{Opt_nobarrier, "nobarrier"},	/* .. disable */
+	{Opt_inode64, "inode64"},	/* inodes can be allocated anywhere */
+	{Opt_ikeep, "ikeep"},		/* do not free empty inode clusters */
+	{Opt_noikeep, "noikeep"},	/* free empty inode clusters */
+	{Opt_largeio, "largeio"},	/* report large I/O sizes in start() */
+	{Opt_nolargeio, "nolargeio"},	/* do not report large I/O sizes
+					 * in start() */
+	{Opt_attr2, "attr2"},		/* do use attr2 attribute format */
+	{Opt_noattr2, "noattr2"},	/* do not use attr2 attribute format */
+	{Opt_filestreams, "filestreams"}, /* use filestreams allocator */
+	{Opt_quota, "quota"},		/* disk quotas (user) */
+	{Opt_noquota, "noquota"},	/* no quotas */
+	{Opt_usrquota, "usrquota"},	/* user quota enabled */
+	{Opt_grpquota, "grpquota"},	/* group quota enabled */
+	{Opt_prjquota, "prjquota"},	/* project quota enabled */
+	{Opt_uquota, "uquota"},		/* user quota (IRIX variant) */
+	{Opt_gquota, "gquota"},		/* group quota (IRIX variant) */
+	{Opt_pquota, "pquota"},		/* project quota (IRIX variant) */
+	{Opt_uqnoenf, "uqnoenforce"},	/* user quota limit enforcement */
+	{Opt_gqnoenf, "gqnoenforce"},	/* group quota limit enforcement */
+	{Opt_pqnoenf, "pqnoenforce"},	/* project quota limit enforcement */
+	{Opt_qnoenf, "qnoenforce"},	/* same as uqnoenforce */
+	{Opt_delaylog, "delaylog"},	/* deprecated */
+	{Opt_nodelaylog, "nodelaylog"},	/* deprecated */
+	{Opt_discard, "discard"},	/* Discard unused blocks */
+	{Opt_nodiscard, "nodiscard"},	/* Do not discard unused blocks */
+	{Opt_ihashsize, "ihashsize"},	/* deprecated */
+	{Opt_osyncisdsync, "osyncisdsync"}, /* deprecated */
+	{Opt_osyncisosync, "osyncisosync"}, /* deprecated */
+	{Opt_irixsgid, "irixsgid"},	/* deprecated */
 	{Opt_err, NULL}
 };
 
@@ -166,11 +216,14 @@ xfs_parseargs(
 	char			*options)
 {
 	struct super_block	*sb = mp->m_super;
-	char			*this_char, *value, *eov;
+	char			*p, *string, *eov;
 	int			dsunit = 0;
 	int			dswidth = 0;
-	int			iosize = 0;
 	__uint8_t		iosizelog = 0;
+	int			intarg;
+	substring_t		args[MAX_OPT_ARGS];
+	char			*orig = NULL;
+	int			ret = 0;
 
 	/*
 	 * set up the mount name first so all the errors will refer to the
@@ -208,175 +261,224 @@ xfs_parseargs(
 	if (!options)
 		goto done;
 
-	while ((this_char = strsep(&options, ",")) != NULL) {
-		if (!*this_char)
+	ret = ENOMEM;
+	options = kstrdup(options, GFP_NOFS);
+	if (!options)
+		goto done;
+
+	orig = options;
+
+	while ((p = strsep(&orig, ",")) != NULL) {
+		int token;
+		if (!*p)
 			continue;
-		if ((value = strchr(this_char, '=')) != NULL)
-			*value++ = 0;
-
-		if (!strcmp(this_char, MNTOPT_LOGBUFS)) {
-			if (!value || !*value) {
-				xfs_warn(mp, "%s option requires an argument",
-					this_char);
-				return EINVAL;
-			}
-			mp->m_logbufs = simple_strtoul(value, &eov, 10);
-		} else if (!strcmp(this_char, MNTOPT_LOGBSIZE)) {
-			if (!value || !*value) {
-				xfs_warn(mp, "%s option requires an argument",
-					this_char);
-				return EINVAL;
-			}
-			mp->m_logbsize = suffix_strtoul(value, &eov, 10);
-		} else if (!strcmp(this_char, MNTOPT_LOGDEV)) {
-			if (!value || !*value) {
-				xfs_warn(mp, "%s option requires an argument",
-					this_char);
-				return EINVAL;
-			}
-			mp->m_logname = kstrndup(value, MAXNAMELEN, GFP_KERNEL);
+
+		token = match_token(p, tokens, args);
+		switch (token) {
+		case Opt_logbufs:
+			intarg = 0;
+			ret = EINVAL;
+			match_int(args, &intarg);
+			if (!intarg)
+				goto free_orig;
+			mp->m_logbufs = intarg;
+			break;
+		case Opt_logbsize:
+			ret = ENOMEM;
+			string = match_strdup(args);
+			if (!string)
+				goto free_orig;
+			ret = EINVAL;
+			intarg = suffix_strtoul(string, &eov, 0);
+			if (!intarg)
+				goto free_string;
+			mp->m_logbsize = intarg;
+			break;
+		case Opt_logdev:
+			ret = ENOMEM;
+			string = match_strdup(args);
+			if (!string)
+				goto free_orig;
+
+			mp->m_logname = kstrndup(string, MAXNAMELEN, GFP_KERNEL);
 			if (!mp->m_logname)
-				return ENOMEM;
-		} else if (!strcmp(this_char, MNTOPT_MTPT)) {
-			xfs_warn(mp, "%s option not allowed on this system",
-				this_char);
-			return EINVAL;
-		} else if (!strcmp(this_char, MNTOPT_RTDEV)) {
-			if (!value || !*value) {
-				xfs_warn(mp, "%s option requires an argument",
-					this_char);
-				return EINVAL;
-			}
-			mp->m_rtname = kstrndup(value, MAXNAMELEN, GFP_KERNEL);
+				goto free_string;
+			break;
+		case Opt_mtpt:
+			ret = EINVAL;
+			xfs_warn(mp, "%s option not allowed on this system", p);
+			goto free_orig;
+		case Opt_rtdev:
+			ret = ENOMEM;
+			string = match_strdup(args);
+			if (!string)
+				goto free_orig;
+			mp->m_rtname = kstrndup(string, MAXNAMELEN, GFP_KERNEL);
 			if (!mp->m_rtname)
-				return ENOMEM;
-		} else if (!strcmp(this_char, MNTOPT_BIOSIZE)) {
-			if (!value || !*value) {
-				xfs_warn(mp, "%s option requires an argument",
-					this_char);
-				return EINVAL;
-			}
-			iosize = simple_strtoul(value, &eov, 10);
-			iosizelog = ffs(iosize) - 1;
-		} else if (!strcmp(this_char, MNTOPT_ALLOCSIZE)) {
-			if (!value || !*value) {
-				xfs_warn(mp, "%s option requires an argument",
-					this_char);
-				return EINVAL;
-			}
-			iosize = suffix_strtoul(value, &eov, 10);
-			iosizelog = ffs(iosize) - 1;
-		} else if (!strcmp(this_char, MNTOPT_GRPID) ||
-			   !strcmp(this_char, MNTOPT_BSDGROUPS)) {
+				goto free_string;
+			break;
+		case Opt_biosize:
+			intarg = 0;
+			ret = EINVAL;
+			intarg = match_int(args, &intarg);
+			if (!intarg)
+				goto free_orig;
+			iosizelog = ffs(intarg) - 1;
+			break;
+		case Opt_allocsize:
+			ret = ENOMEM;
+			string = match_strdup(args);
+			if (!string)
+				goto free_orig;
+			ret = EINVAL;
+			intarg = suffix_strtoul(string, &eov, 0);
+			if (!intarg)
+				goto free_string;
+			iosizelog = ffs(intarg) - 1;
+			break;
+		case Opt_grpid:
+		case Opt_bsdgroups:
 			mp->m_flags |= XFS_MOUNT_GRPID;
-		} else if (!strcmp(this_char, MNTOPT_NOGRPID) ||
-			   !strcmp(this_char, MNTOPT_SYSVGROUPS)) {
+			break;
+		case Opt_nogrpid:
+		case Opt_sysvgroups:
 			mp->m_flags &= ~XFS_MOUNT_GRPID;
-		} else if (!strcmp(this_char, MNTOPT_WSYNC)) {
+			break;
+		case Opt_wsync:
 			mp->m_flags |= XFS_MOUNT_WSYNC;
-		} else if (!strcmp(this_char, MNTOPT_NORECOVERY)) {
+			break;
+		case Opt_norecovery:
 			mp->m_flags |= XFS_MOUNT_NORECOVERY;
-		} else if (!strcmp(this_char, MNTOPT_NOALIGN)) {
+			break;
+		case Opt_noalign:
 			mp->m_flags |= XFS_MOUNT_NOALIGN;
-		} else if (!strcmp(this_char, MNTOPT_SWALLOC)) {
+			break;
+		case Opt_swalloc:
 			mp->m_flags |= XFS_MOUNT_SWALLOC;
-		} else if (!strcmp(this_char, MNTOPT_SUNIT)) {
-			if (!value || !*value) {
-				xfs_warn(mp, "%s option requires an argument",
-					this_char);
-				return EINVAL;
-			}
-			dsunit = simple_strtoul(value, &eov, 10);
-		} else if (!strcmp(this_char, MNTOPT_SWIDTH)) {
-			if (!value || !*value) {
-				xfs_warn(mp, "%s option requires an argument",
-					this_char);
-				return EINVAL;
-			}
-			dswidth = simple_strtoul(value, &eov, 10);
-		} else if (!strcmp(this_char, MNTOPT_64BITINODE)) {
+			break;
+		case Opt_sunit:
+			ret = EINVAL;
+			dsunit = match_int(args, &intarg);
+			if (!dsunit)
+				goto free_orig;
+			break;
+		case Opt_swidth:
+			ret = EINVAL;
+			dswidth = match_int(args, &intarg);
+			if (!dswidth)
+				goto free_orig;
+		case Opt_inode64:
 			mp->m_flags &= ~XFS_MOUNT_SMALL_INUMS;
 #if !XFS_BIG_INUMS
-			xfs_warn(mp, "%s option not allowed on this system",
-				this_char);
+			xfs_warn(mp, "%s options not allowed on this system", p);
 			return EINVAL;
 #endif
-		} else if (!strcmp(this_char, MNTOPT_NOUUID)) {
+			break;
+		case Opt_nouuid:
 			mp->m_flags |= XFS_MOUNT_NOUUID;
-		} else if (!strcmp(this_char, MNTOPT_BARRIER)) {
+			break;
+		case Opt_barrier:
 			mp->m_flags |= XFS_MOUNT_BARRIER;
-		} else if (!strcmp(this_char, MNTOPT_NOBARRIER)) {
+			break;
+		case Opt_nobarrier:
 			mp->m_flags &= ~XFS_MOUNT_BARRIER;
-		} else if (!strcmp(this_char, MNTOPT_IKEEP)) {
+			break;
+		case Opt_ikeep:
 			mp->m_flags |= XFS_MOUNT_IKEEP;
-		} else if (!strcmp(this_char, MNTOPT_NOIKEEP)) {
+			break;
+		case Opt_noikeep:
 			mp->m_flags &= ~XFS_MOUNT_IKEEP;
-		} else if (!strcmp(this_char, MNTOPT_LARGEIO)) {
+			break;
+		case Opt_largeio:
 			mp->m_flags &= ~XFS_MOUNT_COMPAT_IOSIZE;
-		} else if (!strcmp(this_char, MNTOPT_NOLARGEIO)) {
+			break;
+		case Opt_nolargeio:
 			mp->m_flags |= XFS_MOUNT_COMPAT_IOSIZE;
-		} else if (!strcmp(this_char, MNTOPT_ATTR2)) {
+			break;
+		case Opt_attr2:
 			mp->m_flags |= XFS_MOUNT_ATTR2;
-		} else if (!strcmp(this_char, MNTOPT_NOATTR2)) {
+			break;
+		case Opt_noattr2:
 			mp->m_flags &= ~XFS_MOUNT_ATTR2;
 			mp->m_flags |= XFS_MOUNT_NOATTR2;
-		} else if (!strcmp(this_char, MNTOPT_FILESTREAM)) {
+			break;
+		case Opt_filestreams:
 			mp->m_flags |= XFS_MOUNT_FILESTREAMS;
-		} else if (!strcmp(this_char, MNTOPT_NOQUOTA)) {
+			break;
+		case Opt_noquota:
 			mp->m_qflags &= ~XFS_ALL_QUOTA_ACCT;
 			mp->m_qflags &= ~XFS_ALL_QUOTA_ENFD;
 			mp->m_qflags &= ~XFS_ALL_QUOTA_ACTIVE;
-		} else if (!strcmp(this_char, MNTOPT_QUOTA) ||
-			   !strcmp(this_char, MNTOPT_UQUOTA) ||
-			   !strcmp(this_char, MNTOPT_USRQUOTA)) {
+			break;
+		case Opt_quota:
+		case Opt_uquota:
+		case Opt_usrquota:
 			mp->m_qflags |= (XFS_UQUOTA_ACCT | XFS_UQUOTA_ACTIVE |
 					 XFS_UQUOTA_ENFD);
-		} else if (!strcmp(this_char, MNTOPT_QUOTANOENF) ||
-			   !strcmp(this_char, MNTOPT_UQUOTANOENF)) {
+			break;
+		case Opt_qnoenf:
+		case Opt_uqnoenf:
 			mp->m_qflags |= (XFS_UQUOTA_ACCT | XFS_UQUOTA_ACTIVE);
 			mp->m_qflags &= ~XFS_UQUOTA_ENFD;
-		} else if (!strcmp(this_char, MNTOPT_PQUOTA) ||
-			   !strcmp(this_char, MNTOPT_PRJQUOTA)) {
+			break;
+		case Opt_pquota:
+		case Opt_prjquota:
 			mp->m_qflags |= (XFS_PQUOTA_ACCT | XFS_PQUOTA_ACTIVE |
 					 XFS_OQUOTA_ENFD);
-		} else if (!strcmp(this_char, MNTOPT_PQUOTANOENF)) {
+			break;
+		case Opt_pqnoenf:
 			mp->m_qflags |= (XFS_PQUOTA_ACCT | XFS_PQUOTA_ACTIVE);
 			mp->m_qflags &= ~XFS_OQUOTA_ENFD;
-		} else if (!strcmp(this_char, MNTOPT_GQUOTA) ||
-			   !strcmp(this_char, MNTOPT_GRPQUOTA)) {
+			break;
+		case Opt_gquota:
+		case Opt_grpquota:
 			mp->m_qflags |= (XFS_GQUOTA_ACCT | XFS_GQUOTA_ACTIVE |
 					 XFS_OQUOTA_ENFD);
-		} else if (!strcmp(this_char, MNTOPT_GQUOTANOENF)) {
+			break;
+		case Opt_gqnoenf:
 			mp->m_qflags |= (XFS_GQUOTA_ACCT | XFS_GQUOTA_ACTIVE);
 			mp->m_qflags &= ~XFS_OQUOTA_ENFD;
-		} else if (!strcmp(this_char, MNTOPT_DELAYLOG)) {
+			break;
+		case Opt_delaylog:
 			xfs_warn(mp,
-	"delaylog is the default now, option is deprecated.");
-		} else if (!strcmp(this_char, MNTOPT_NODELAYLOG)) {
+		"delaylog is the default now, option is deprecated.");
+			break;
+		case Opt_nodelaylog:
 			xfs_warn(mp,
-	"nodelaylog support has been removed, option is deprecated.");
-		} else if (!strcmp(this_char, MNTOPT_DISCARD)) {
+		"nodelaylog support has been removed, option is deprecated.");
+			break;
+		case Opt_discard:
 			mp->m_flags |= XFS_MOUNT_DISCARD;
-		} else if (!strcmp(this_char, MNTOPT_NODISCARD)) {
+			break;
+		case Opt_nodiscard:
 			mp->m_flags &= ~XFS_MOUNT_DISCARD;
-		} else if (!strcmp(this_char, "ihashsize")) {
+			break;
+		case Opt_ihashsize:
 			xfs_warn(mp,
-	"ihashsize no longer used, option is deprecated.");
-		} else if (!strcmp(this_char, "osyncisdsync")) {
+		"ihashsize no longer used, option is deprecated.");
+		case Opt_osyncisdsync:
 			xfs_warn(mp,
-	"osyncisdsync has no effect, option is deprecated.");
-		} else if (!strcmp(this_char, "osyncisosync")) {
+		"osyncisdsync has no effect, option is deprecated.");
+			break;
+		case Opt_osyncisosync:
 			xfs_warn(mp,
-	"osyncisosync has no effect, option is deprecated.");
-		} else if (!strcmp(this_char, "irixsgid")) {
+		"osyncisosync has no effect, option is deprecated.");
+			break;
+		case Opt_irixsgid:
 			xfs_warn(mp,
-	"irixsgid is now a sysctl(2) variable, option is deprecated.");
-		} else {
-			xfs_warn(mp, "unknown mount option [%s].", this_char);
-			return EINVAL;
+		"irixsgid is now a sysctl(2) variable, option is deprecated.");
+			break;
+		default:
+			xfs_warn(mp, "unknown mount option [%s].", p);
+			break;
 		}
+
+		kfree(string);
+		string = NULL;
 	}
 
+	kfree(orig);
+
 	/*
 	 * no recovery flag requires a read-only mount
 	 */
@@ -468,6 +570,12 @@ done:
 	}
 
 	return 0;
+
+free_string:
+	kfree(string);
+free_orig:
+	kfree(orig);
+	return ret;
 }
 
 struct proc_xfs_info {
@@ -476,10 +584,12 @@ struct proc_xfs_info {
 };
 
 STATIC int
-xfs_showargs(
-	struct xfs_mount	*mp,
-	struct seq_file		*m)
+xfs_fs_show_options(
+	struct seq_file		*seq,
+	struct dentry		*dentry)
 {
+	struct xfs_mount	*mp = XFS_M(dentry->d_sb);
+
 	static struct proc_xfs_info xfs_info_set[] = {
 		/* the few simple ones we can get from the mount struct */
 		{ XFS_MOUNT_IKEEP,		"," MNTOPT_IKEEP },
@@ -505,58 +615,60 @@ xfs_showargs(
 
 	for (xfs_infop = xfs_info_set; xfs_infop->flag; xfs_infop++) {
 		if (mp->m_flags & xfs_infop->flag)
-			seq_puts(m, xfs_infop->str);
+			seq_puts(seq, xfs_infop->str);
 	}
 	for (xfs_infop = xfs_info_unset; xfs_infop->flag; xfs_infop++) {
 		if (!(mp->m_flags & xfs_infop->flag))
-			seq_puts(m, xfs_infop->str);
+			seq_puts(seq, xfs_infop->str);
 	}
 
 	if (mp->m_flags & XFS_MOUNT_DFLT_IOSIZE)
-		seq_printf(m, "," MNTOPT_ALLOCSIZE "=%dk",
+		seq_printf(seq, "," MNTOPT_ALLOCSIZE "=%dk",
 				(int)(1 << mp->m_writeio_log) >> 10);
 
 	if (mp->m_logbufs > 0)
-		seq_printf(m, "," MNTOPT_LOGBUFS "=%d", mp->m_logbufs);
+		seq_printf(seq, "," MNTOPT_LOGBUFS "=%d", mp->m_logbufs);
 	if (mp->m_logbsize > 0)
-		seq_printf(m, "," MNTOPT_LOGBSIZE "=%dk", mp->m_logbsize >> 10);
+		seq_printf(seq, "," MNTOPT_LOGBSIZE "=%dk",
+				mp->m_logbsize >> 10);
 
 	if (mp->m_logname)
-		seq_printf(m, "," MNTOPT_LOGDEV "=%s", mp->m_logname);
+		seq_printf(seq, "," MNTOPT_LOGDEV "=%s", mp->m_logname);
 	if (mp->m_rtname)
-		seq_printf(m, "," MNTOPT_RTDEV "=%s", mp->m_rtname);
+		seq_printf(seq, "," MNTOPT_RTDEV "=%s", mp->m_rtname);
 
 	if (mp->m_dalign > 0)
-		seq_printf(m, "," MNTOPT_SUNIT "=%d",
+		seq_printf(seq, "," MNTOPT_SUNIT "=%d",
 				(int)XFS_FSB_TO_BB(mp, mp->m_dalign));
 	if (mp->m_swidth > 0)
-		seq_printf(m, "," MNTOPT_SWIDTH "=%d",
+		seq_printf(seq, "," MNTOPT_SWIDTH "=%d",
 				(int)XFS_FSB_TO_BB(mp, mp->m_swidth));
 
 	if (mp->m_qflags & (XFS_UQUOTA_ACCT|XFS_UQUOTA_ENFD))
-		seq_puts(m, "," MNTOPT_USRQUOTA);
+		seq_puts(seq, "," MNTOPT_USRQUOTA);
 	else if (mp->m_qflags & XFS_UQUOTA_ACCT)
-		seq_puts(m, "," MNTOPT_UQUOTANOENF);
+		seq_puts(seq, "," MNTOPT_UQUOTANOENF);
 
 	/* Either project or group quotas can be active, not both */
 
 	if (mp->m_qflags & XFS_PQUOTA_ACCT) {
 		if (mp->m_qflags & XFS_OQUOTA_ENFD)
-			seq_puts(m, "," MNTOPT_PRJQUOTA);
+			seq_puts(seq, "," MNTOPT_PRJQUOTA);
 		else
-			seq_puts(m, "," MNTOPT_PQUOTANOENF);
+			seq_puts(seq, "," MNTOPT_PQUOTANOENF);
 	} else if (mp->m_qflags & XFS_GQUOTA_ACCT) {
 		if (mp->m_qflags & XFS_OQUOTA_ENFD)
-			seq_puts(m, "," MNTOPT_GRPQUOTA);
+			seq_puts(seq, "," MNTOPT_GRPQUOTA);
 		else
-			seq_puts(m, "," MNTOPT_GQUOTANOENF);
+			seq_puts(seq, "," MNTOPT_GQUOTANOENF);
 	}
 
 	if (!(mp->m_qflags & XFS_ALL_QUOTA_ACCT))
-		seq_puts(m, "," MNTOPT_NOQUOTA);
+		seq_puts(seq, "," MNTOPT_NOQUOTA);
 
 	return 0;
 }
+
 __uint64_t
 xfs_max_file_offset(
 	unsigned int		blockshift)
@@ -1221,14 +1333,6 @@ xfs_fs_unfreeze(
 	return 0;
 }
 
-STATIC int
-xfs_fs_show_options(
-	struct seq_file		*m,
-	struct dentry		*root)
-{
-	return -xfs_showargs(XFS_M(root->d_sb), m);
-}
-
 /*
  * This function fills in xfs_mount_t fields based on mount args.
  * Note: the superblock _has_ now been read in.
-- 
1.7.11.rc0

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

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

* Re: [PATCH V3] xfs: cleanup the mount options
  2012-07-02  7:05     ` [PATCH V3] " Wanlong Gao
@ 2012-07-06  3:05       ` Dave Chinner
  2012-07-08 11:36         ` [PATCH V4] " Wanlong Gao
  0 siblings, 1 reply; 31+ messages in thread
From: Dave Chinner @ 2012-07-06  3:05 UTC (permalink / raw)
  To: Wanlong Gao; +Cc: Christoph Hellwig, Ben Myers, Zach Brown, xfs

On Mon, Jul 02, 2012 at 03:05:14PM +0800, Wanlong Gao wrote:
> remove the mount options macro, use tokens instead.
> 
> CC: Ben Myers <bpm@sgi.com>
> CC: Christoph Hellwig <hch@infradead.org>
> CC: Dave Chinner <david@fromorbit.com>
> CC: Zach Brown <zab@zabbo.net>
> Signed-off-by: Wanlong Gao <gaowanlong@cn.fujitsu.com>
> ---
>  fs/xfs/xfs_super.c | 510 ++++++++++++++++++++++++++++++++---------------------
>  1 file changed, 307 insertions(+), 203 deletions(-)
....

One thing about duplication:

> +#define	MNTOPT_LOGBUFS		"logbufs"
> +#define	MNTOPT_LOGBSIZE		"logbsize"
> +#define	MNTOPT_LOGDEV		"logdev"

....

>  static const match_table_t tokens = {
> -	{Opt_barrier, "barrier"},
> -	{Opt_nobarrier, "nobarrier"},
> +	{Opt_logbufs, "logbufs=%d"},	/* number of XFS log buffers */
> +	{Opt_logbsize, "logbsize=%s"},	/* size of XFS log buffers */
> +	{Opt_logdev, "logdev=%s"},	/* log device */

You're effectively defining each string twice, which is almost
certainly going to lead to one but nothe other being updated in
future.

Can something like:

	{Opt_logbufs, MNTOPT_LOGBUFS "=%d"},	/* number of XFS log buffers */
	{Opt_logbsize,MNTOPT_LOGBSIZE "=%s"},	/* size of XFS log buffers */
	{Opt_logdev,  MNTOPT_LOGDEV "=%s"},	/* log device */

be done to avoid that duplication?

> +		token = match_token(p, tokens, args);
> +		switch (token) {
> +		case Opt_logbufs:
> +			intarg = 0;
> +			ret = EINVAL;
> +			match_int(args, &intarg);
> +			if (!intarg)
> +				goto free_orig;

Why is a value of zero an error? match_int() returns an error if it
fails....

> +			mp->m_logbufs = intarg;
> +			break;

I don't really like the "set error, call function, jump to error"
pattern. I'd prefer just to set the error value when an error
returns as it makes the code much easier and more logical to read.
i.e:

		token = match_token(p, tokens, args);
		switch (token) {
		case Opt_logbufs:
			ret = match_int(args, &intarg);
			if (ret)
				goto free_orig;
			mp->m_logbufs = intarg;
			break;

> +		case Opt_logbsize:
> +			ret = ENOMEM;
> +			string = match_strdup(args);
> +			if (!string)
> +				goto free_orig;
> +			ret = EINVAL;
> +			intarg = suffix_strtoul(string, &eov, 0);
> +			if (!intarg)
> +				goto free_string;

So this is just an open coded version of match_int() using the
suffix_strtoul() rather than simple_strtoul() directly. Please write
a "suffix_match_int()" wrapper for it, and that avoids all the messy
error handling in this code....

> +			break;
> +		case Opt_logdev:
> +			ret = ENOMEM;
> +			string = match_strdup(args);
> +			if (!string)
> +				goto free_orig;
> +
> +			mp->m_logname = kstrndup(string, MAXNAMELEN, GFP_KERNEL);
>  			if (!mp->m_logname)
> +				goto free_string;

and is consistent with this and other similar code.

> +		case Opt_biosize:
> +			intarg = 0;
> +			ret = EINVAL;
> +			intarg = match_int(args, &intarg);

That's not valid. match_int() returns either 0 or -EINVAL/-ENOMEM,
and that will overwrite whatever value match_int() writes into
intarg when it decodes it.

> +			if (!intarg)
> +				goto free_orig;

hence on a correct mount option with value, it will abort with no
error.

> +			iosizelog = ffs(intarg) - 1;

And on a bad value, it will write something bad into iosizelog and
continue.

> +		case Opt_allocsize:
> +			ret = ENOMEM;
> +			string = match_strdup(args);
> +			if (!string)
> +				goto free_orig;
> +			ret = EINVAL;
> +			intarg = suffix_strtoul(string, &eov, 0);
> +			if (!intarg)
> +				goto free_string;

Why is a value of zero an error?

....

> +		case Opt_delaylog:
>  			xfs_warn(mp,
> +		"delaylog is the default now, option is deprecated.");
> +			break;
> +		case Opt_nodelaylog:
>  			xfs_warn(mp,
> +		"nodelaylog support has been removed, option is deprecated.");

Hard coding mount options here again.....

> +			break;
> +		case Opt_discard:
>  			mp->m_flags |= XFS_MOUNT_DISCARD;
> +			break;
> +		case Opt_nodiscard:
>  			mp->m_flags &= ~XFS_MOUNT_DISCARD;
> +			break;

Move these above all the deprecated options.

Cheers,

Dave.
-- 
Dave Chinner
david@fromorbit.com

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

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

* [PATCH V4] xfs: cleanup the mount options
  2012-07-06  3:05       ` Dave Chinner
@ 2012-07-08 11:36         ` Wanlong Gao
  2012-07-09  0:22           ` Dave Chinner
  0 siblings, 1 reply; 31+ messages in thread
From: Wanlong Gao @ 2012-07-08 11:36 UTC (permalink / raw)
  To: XFS; +Cc: Christoph Hellwig, Ben Myers, Zach Brown, Wanlong Gao

remove the mount options macro, use tokens instead.

CC: Ben Myers <bpm@sgi.com>
CC: Christoph Hellwig <hch@infradead.org>
CC: Dave Chinner <david@fromorbit.com>
CC: Zach Brown <zab@zabbo.net>
Signed-off-by: Wanlong Gao <gaowanlong@cn.fujitsu.com>
---
 fs/xfs/xfs_super.c |  539 +++++++++++++++++++++++++++++++---------------------
 1 file changed, 320 insertions(+), 219 deletions(-)

diff --git a/fs/xfs/xfs_super.c b/fs/xfs/xfs_super.c
index 07f70e1..c1abd42 100644
--- a/fs/xfs/xfs_super.c
+++ b/fs/xfs/xfs_super.c
@@ -66,91 +66,146 @@ static const struct super_operations xfs_super_operations;
 static kmem_zone_t *xfs_ioend_zone;
 mempool_t *xfs_ioend_pool;
 
-#define MNTOPT_LOGBUFS	"logbufs"	/* number of XFS log buffers */
-#define MNTOPT_LOGBSIZE	"logbsize"	/* size of XFS log buffers */
-#define MNTOPT_LOGDEV	"logdev"	/* log device */
-#define MNTOPT_RTDEV	"rtdev"		/* realtime I/O device */
-#define MNTOPT_BIOSIZE	"biosize"	/* log2 of preferred buffered io size */
-#define MNTOPT_WSYNC	"wsync"		/* safe-mode nfs compatible mount */
-#define MNTOPT_NOALIGN	"noalign"	/* turn off stripe alignment */
-#define MNTOPT_SWALLOC	"swalloc"	/* turn on stripe width allocation */
-#define MNTOPT_SUNIT	"sunit"		/* data volume stripe unit */
-#define MNTOPT_SWIDTH	"swidth"	/* data volume stripe width */
-#define MNTOPT_NOUUID	"nouuid"	/* ignore filesystem UUID */
-#define MNTOPT_MTPT	"mtpt"		/* filesystem mount point */
-#define MNTOPT_GRPID	"grpid"		/* group-ID from parent directory */
-#define MNTOPT_NOGRPID	"nogrpid"	/* group-ID from current process */
-#define MNTOPT_BSDGROUPS    "bsdgroups"    /* group-ID from parent directory */
-#define MNTOPT_SYSVGROUPS   "sysvgroups"   /* group-ID from current process */
-#define MNTOPT_ALLOCSIZE    "allocsize"    /* preferred allocation size */
-#define MNTOPT_NORECOVERY   "norecovery"   /* don't run XFS recovery */
-#define MNTOPT_BARRIER	"barrier"	/* use writer barriers for log write and
-					 * unwritten extent conversion */
-#define MNTOPT_NOBARRIER "nobarrier"	/* .. disable */
-#define MNTOPT_64BITINODE   "inode64"	/* inodes can be allocated anywhere */
-#define MNTOPT_IKEEP	"ikeep"		/* do not free empty inode clusters */
-#define MNTOPT_NOIKEEP	"noikeep"	/* free empty inode clusters */
-#define MNTOPT_LARGEIO	   "largeio"	/* report large I/O sizes in stat() */
-#define MNTOPT_NOLARGEIO   "nolargeio"	/* do not report large I/O sizes
-					 * in stat(). */
-#define MNTOPT_ATTR2	"attr2"		/* do use attr2 attribute format */
-#define MNTOPT_NOATTR2	"noattr2"	/* do not use attr2 attribute format */
-#define MNTOPT_FILESTREAM  "filestreams" /* use filestreams allocator */
-#define MNTOPT_QUOTA	"quota"		/* disk quotas (user) */
-#define MNTOPT_NOQUOTA	"noquota"	/* no quotas */
-#define MNTOPT_USRQUOTA	"usrquota"	/* user quota enabled */
-#define MNTOPT_GRPQUOTA	"grpquota"	/* group quota enabled */
-#define MNTOPT_PRJQUOTA	"prjquota"	/* project quota enabled */
-#define MNTOPT_UQUOTA	"uquota"	/* user quota (IRIX variant) */
-#define MNTOPT_GQUOTA	"gquota"	/* group quota (IRIX variant) */
-#define MNTOPT_PQUOTA	"pquota"	/* project quota (IRIX variant) */
-#define MNTOPT_UQUOTANOENF "uqnoenforce"/* user quota limit enforcement */
-#define MNTOPT_GQUOTANOENF "gqnoenforce"/* group quota limit enforcement */
-#define MNTOPT_PQUOTANOENF "pqnoenforce"/* project quota limit enforcement */
-#define MNTOPT_QUOTANOENF  "qnoenforce"	/* same as uqnoenforce */
-#define MNTOPT_DELAYLOG    "delaylog"	/* Delayed logging enabled */
-#define MNTOPT_NODELAYLOG  "nodelaylog"	/* Delayed logging disabled */
-#define MNTOPT_DISCARD	   "discard"	/* Discard unused blocks */
-#define MNTOPT_NODISCARD   "nodiscard"	/* Do not discard unused blocks */
+#define	MNTOPT_LOGBUFS		"logbufs"
+#define	MNTOPT_LOGBSIZE		"logbsize"
+#define	MNTOPT_LOGDEV		"logdev"
+#define	MNTOPT_RTDEV		"rtdev"
+#define	MNTOPT_BIOSIZE		"biosize"
+#define	MNTOPT_WSYNC		"wsync"
+#define	MNTOPT_NOALIGN		"noalign"
+#define	MNTOPT_SWALLOC		"swalloc"
+#define	MNTOPT_SUNIT		"sunit"
+#define	MNTOPT_SWIDTH		"swidth"
+#define	MNTOPT_NOUUID		"nouuid"
+#define	MNTOPT_MTPT		"mtpt"
+#define	MNTOPT_GRPID		"grpid"
+#define	MNTOPT_NOGRPID		"nogrpid"
+#define	MNTOPT_BSDGROUPS	"bsdgroups"
+#define	MNTOPT_SYSVGROUPS	"sysvgroups"
+#define	MNTOPT_ALLOCSIZE	"allocsize"
+#define	MNTOPT_NORECOVERY	"norecovery"
+#define	MNTOPT_BARRIER		"barrier"
+#define	MNTOPT_NOBARRIER	"nobarrier"
+#define	MNTOPT_64BITINODE	"inode64"
+#define	MNTOPT_IKEEP		"ikeep"
+#define	MNTOPT_NOIKEEP		"noikeep"
+#define	MNTOPT_LARGEIO		"largeio"
+#define	MNTOPT_NOLARGEIO	"nolargeio"
+#define	MNTOPT_ATTR2		"attr2"
+#define	MNTOPT_NOATTR2		"noattr2"
+#define	MNTOPT_FILESTREAM	"filestreams"
+#define	MNTOPT_QUOTA		"quota"
+#define	MNTOPT_NOQUOTA		"noquota"
+#define	MNTOPT_USRQUOTA		"usrquota"
+#define	MNTOPT_GRPQUOTA		"grpquota"
+#define	MNTOPT_PRJQUOTA		"prjquota"
+#define	MNTOPT_UQUOTA		"uquota"
+#define	MNTOPT_GQUOTA		"gquota"
+#define	MNTOPT_PQUOTA		"pquota"
+#define	MNTOPT_UQUOTANOENF	"uqnoenforce"
+#define	MNTOPT_GQUOTANOENF	"gqnoenforce"
+#define	MNTOPT_PQUOTANOENF	"pqnoenforce"
+#define	MNTOPT_QUOTANOENF	"qnoenforce"
+#define	MNTOPT_DISCARD		"discard"
+#define	MNTOPT_NODISCARD	"nodiscard"
+#define	MNTOPT_DELAYLOG		"delaylog"
+#define	MNTOPT_NODELAYLOG	"nodelaylog"
+#define	MNTOPT_IHASHSIZE	"ihashsize"
+#define	MNTOPT_OSYNCISDSYNC	"osyncisdsync"
+#define	MNTOPT_OSYNCISOSYNC	"osyncisosync"
+#define	MNTOPT_IRIXSGID		"irixsgid"
 
-/*
- * Table driven mount option parser.
- *
- * Currently only used for remount, but it will be used for mount
- * in the future, too.
- */
 enum {
-	Opt_barrier, Opt_nobarrier, Opt_err
+	Opt_logbufs, Opt_logbsize, Opt_logdev, Opt_rtdev, Opt_biosize,
+	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_inode64, Opt_ikeep, Opt_noikeep, Opt_largeio,
+	Opt_nolargeio, Opt_attr2, Opt_noattr2, Opt_filestreams, Opt_quota,
+	Opt_noquota, Opt_usrquota, Opt_grpquota, Opt_prjquota, Opt_uquota,
+	Opt_gquota, Opt_pquota, Opt_uqnoenf, Opt_gqnoenf, Opt_pqnoenf,
+	Opt_qnoenf, Opt_discard, Opt_nodiscard, Opt_delaylog, Opt_nodelaylog,
+	Opt_ihashsize, Opt_osyncisdsync, Opt_osyncisosync, Opt_irixsgid,
+	Opt_err
 };
 
 static const match_table_t tokens = {
-	{Opt_barrier, "barrier"},
-	{Opt_nobarrier, "nobarrier"},
+	{Opt_logbufs, MNTOPT_LOGBUFS "=%d"},	/* number of XFS log buffers */
+	{Opt_logbsize, MNTOPT_LOGBSIZE "=%s"},	/* size of XFS log buffers */
+	{Opt_logdev, MNTOPT_LOGDEV "=%s"},	/* log device */
+	{Opt_rtdev, MNTOPT_RTDEV "=%s"},	/* realtime I/O device */
+	{Opt_biosize, MNTOPT_BIOSIZE "=%d"},	/* log2 of preferred buffered io size */
+	{Opt_wsync, MNTOPT_WSYNC},		/* safe-mode nfs compatible mount */
+	{Opt_noalign, MNTOPT_NOALIGN},		/* turn off stripe alignment */
+	{Opt_swalloc, MNTOPT_SWALLOC},		/* turn on stripe width allocation */
+	{Opt_sunit, MNTOPT_SUNIT "=%d"},	/* data volume stripe unit */
+	{Opt_swidth, MNTOPT_SWIDTH "=%d"},	/* data volume stripe width */
+	{Opt_nouuid, MNTOPT_NOUUID},		/* ignore filesystem UUID */
+	{Opt_mtpt, MNTOPT_MTPT},		/* filesystem mount point */
+	{Opt_grpid, MNTOPT_GRPID},		/* group-ID from parent directory */
+	{Opt_nogrpid, MNTOPT_NOGRPID},		/* group-ID from current process */
+	{Opt_bsdgroups, MNTOPT_BSDGROUPS},	/* group-ID from parent directory */
+	{Opt_sysvgroups, MNTOPT_SYSVGROUPS},	/* group-ID from current process */
+	{Opt_allocsize, MNTOPT_ALLOCSIZE "=%s"},/* preferred allocation size */
+	{Opt_norecovery, MNTOPT_NORECOVERY},	/* do not run XFS recovery */
+	{Opt_barrier, MNTOPT_BARRIER},		/* use writer barrier for log write and
+						 * unwritten extent conversation */
+	{Opt_nobarrier, MNTOPT_NOBARRIER},	/* .. disable */
+	{Opt_inode64, MNTOPT_64BITINODE},	/* inodes can be allocated anywhere */
+	{Opt_ikeep, MNTOPT_IKEEP},		/* do not free empty inode clusters */
+	{Opt_noikeep, MNTOPT_NOIKEEP},		/* free empty inode clusters */
+	{Opt_largeio, MNTOPT_LARGEIO},		/* report large I/O sizes in start() */
+	{Opt_nolargeio, MNTOPT_NOLARGEIO},	/* do not report large I/O sizes
+						 * in start() */
+	{Opt_attr2, MNTOPT_ATTR2},		/* do use attr2 attribute format */
+	{Opt_noattr2, MNTOPT_NOATTR2},		/* do not use attr2 attribute format */
+	{Opt_filestreams, MNTOPT_FILESTREAM}, 	/* use filestreams allocator */
+	{Opt_quota, MNTOPT_QUOTA},		/* disk quotas (user) */
+	{Opt_noquota, MNTOPT_NOQUOTA},		/* no quotas */
+	{Opt_usrquota, MNTOPT_USRQUOTA},	/* user quota enabled */
+	{Opt_grpquota, MNTOPT_GRPQUOTA},	/* group quota enabled */
+	{Opt_prjquota, MNTOPT_PRJQUOTA},	/* project quota enabled */
+	{Opt_uquota, MNTOPT_UQUOTA},		/* user quota (IRIX variant) */
+	{Opt_gquota, MNTOPT_GQUOTA},		/* group quota (IRIX variant) */
+	{Opt_pquota, MNTOPT_PQUOTA},		/* project quota (IRIX variant) */
+	{Opt_uqnoenf, MNTOPT_UQUOTANOENF},	/* user quota limit enforcement */
+	{Opt_gqnoenf, MNTOPT_GQUOTANOENF},	/* group quota limit enforcement */
+	{Opt_pqnoenf, MNTOPT_PQUOTANOENF},	/* project quota limit enforcement */
+	{Opt_qnoenf, MNTOPT_QUOTANOENF},	/* same as uqnoenforce */
+	{Opt_discard, MNTOPT_DISCARD},		/* Discard unused blocks */
+	{Opt_nodiscard, MNTOPT_NODISCARD},	/* Do not discard unused blocks */
+	{Opt_delaylog, MNTOPT_DELAYLOG},	/* deprecated */
+	{Opt_nodelaylog, MNTOPT_NODELAYLOG},	/* deprecated */
+	{Opt_ihashsize, MNTOPT_IHASHSIZE},	/* deprecated */
+	{Opt_osyncisdsync, MNTOPT_OSYNCISDSYNC},/* deprecated */
+	{Opt_osyncisosync, MNTOPT_OSYNCISOSYNC},/* deprecated */
+	{Opt_irixsgid, MNTOPT_IRIXSGID},	/* deprecated */
 	{Opt_err, NULL}
 };
 
-
-STATIC unsigned long
-suffix_strtoul(char *s, char **endp, unsigned int base)
+STATIC int
+suffix_match_int(substring_t *s, int *result)
 {
-	int	last, shift_left_factor = 0;
-	char	*value = s;
+	int ret;
+	int last, shift_left_factor = 0;
+	char *value = s->to - 1;
 
-	last = strlen(value) - 1;
-	if (value[last] == 'K' || value[last] == 'k') {
+	if (*value == 'K' || *value == 'k') {
 		shift_left_factor = 10;
-		value[last] = '\0';
+		s->to--;
 	}
-	if (value[last] == 'M' || value[last] == 'm') {
+	if (*value == 'M' || *value == 'm') {
 		shift_left_factor = 20;
-		value[last] = '\0';
+		s->to--;
 	}
-	if (value[last] == 'G' || value[last] == 'g') {
+	if (*value == 'G' || *value == 'g') {
 		shift_left_factor = 30;
-		value[last] = '\0';
+		s->to--;
 	}
 
-	return simple_strtoul((const char *)s, endp, base) << shift_left_factor;
+	ret = match_number(s, result, 0);
+	*result = *result << shift_left_factor;
+	return ret;
 }
 
 /*
@@ -166,11 +221,14 @@ xfs_parseargs(
 	char			*options)
 {
 	struct super_block	*sb = mp->m_super;
-	char			*this_char, *value, *eov;
+	char			*p, *string, *eov;
 	int			dsunit = 0;
 	int			dswidth = 0;
-	int			iosize = 0;
 	__uint8_t		iosizelog = 0;
+	int			intarg;
+	substring_t		args[MAX_OPT_ARGS];
+	char			*orig = NULL;
+	int			ret = 0;
 
 	/*
 	 * set up the mount name first so all the errors will refer to the
@@ -208,175 +266,216 @@ xfs_parseargs(
 	if (!options)
 		goto done;
 
-	while ((this_char = strsep(&options, ",")) != NULL) {
-		if (!*this_char)
+	ret = ENOMEM;
+	options = kstrdup(options, GFP_NOFS);
+	if (!options)
+		goto done;
+
+	orig = options;
+
+	while ((p = strsep(&orig, ",")) != NULL) {
+		int token;
+		if (!*p)
 			continue;
-		if ((value = strchr(this_char, '=')) != NULL)
-			*value++ = 0;
-
-		if (!strcmp(this_char, MNTOPT_LOGBUFS)) {
-			if (!value || !*value) {
-				xfs_warn(mp, "%s option requires an argument",
-					this_char);
-				return EINVAL;
-			}
-			mp->m_logbufs = simple_strtoul(value, &eov, 10);
-		} else if (!strcmp(this_char, MNTOPT_LOGBSIZE)) {
-			if (!value || !*value) {
-				xfs_warn(mp, "%s option requires an argument",
-					this_char);
-				return EINVAL;
-			}
-			mp->m_logbsize = suffix_strtoul(value, &eov, 10);
-		} else if (!strcmp(this_char, MNTOPT_LOGDEV)) {
-			if (!value || !*value) {
-				xfs_warn(mp, "%s option requires an argument",
-					this_char);
-				return EINVAL;
-			}
-			mp->m_logname = kstrndup(value, MAXNAMELEN, GFP_KERNEL);
+
+		token = match_token(p, tokens, args);
+		switch (token) {
+		case Opt_logbufs:
+			intarg = 0;
+			ret = match_int(args, &intarg);
+			if (ret)
+				goto free_orig;
+			mp->m_logbufs = intarg;
+			break;
+		case Opt_logbsize:
+			ret = suffix_match_int(args, &intarg);
+			if (ret)
+				goto free_orig;
+			mp->m_logbsize = intarg;
+			break;
+		case Opt_logdev:
+			ret = ENOMEM;
+			string = match_strdup(args);
+			if (!string)
+				goto free_orig;
+
+			mp->m_logname = kstrndup(string, MAXNAMELEN, GFP_KERNEL);
 			if (!mp->m_logname)
-				return ENOMEM;
-		} else if (!strcmp(this_char, MNTOPT_MTPT)) {
-			xfs_warn(mp, "%s option not allowed on this system",
-				this_char);
-			return EINVAL;
-		} else if (!strcmp(this_char, MNTOPT_RTDEV)) {
-			if (!value || !*value) {
-				xfs_warn(mp, "%s option requires an argument",
-					this_char);
-				return EINVAL;
-			}
-			mp->m_rtname = kstrndup(value, MAXNAMELEN, GFP_KERNEL);
+				goto free_string;
+			break;
+		case Opt_mtpt:
+			xfs_warn(mp, "%s option not allowed on this system", p);
+			ret = EINVAL;
+			goto free_orig;
+		case Opt_rtdev:
+			ret = ENOMEM;
+			string = match_strdup(args);
+			if (!string)
+				goto free_orig;
+			mp->m_rtname = kstrndup(string, MAXNAMELEN, GFP_KERNEL);
 			if (!mp->m_rtname)
-				return ENOMEM;
-		} else if (!strcmp(this_char, MNTOPT_BIOSIZE)) {
-			if (!value || !*value) {
-				xfs_warn(mp, "%s option requires an argument",
-					this_char);
-				return EINVAL;
-			}
-			iosize = simple_strtoul(value, &eov, 10);
-			iosizelog = ffs(iosize) - 1;
-		} else if (!strcmp(this_char, MNTOPT_ALLOCSIZE)) {
-			if (!value || !*value) {
-				xfs_warn(mp, "%s option requires an argument",
-					this_char);
-				return EINVAL;
-			}
-			iosize = suffix_strtoul(value, &eov, 10);
-			iosizelog = ffs(iosize) - 1;
-		} else if (!strcmp(this_char, MNTOPT_GRPID) ||
-			   !strcmp(this_char, MNTOPT_BSDGROUPS)) {
+				goto free_string;
+			break;
+		case Opt_biosize:
+			intarg = 0;
+			ret = match_int(args, &intarg);
+			if (ret)
+				goto free_orig;
+			iosizelog = ffs(intarg) - 1;
+			break;
+		case Opt_allocsize:
+			ret = suffix_match_int(args, &intarg);
+			if (ret)
+				goto free_orig;
+			iosizelog = ffs(intarg) - 1;
+			break;
+		case Opt_grpid:
+		case Opt_bsdgroups:
 			mp->m_flags |= XFS_MOUNT_GRPID;
-		} else if (!strcmp(this_char, MNTOPT_NOGRPID) ||
-			   !strcmp(this_char, MNTOPT_SYSVGROUPS)) {
+			break;
+		case Opt_nogrpid:
+		case Opt_sysvgroups:
 			mp->m_flags &= ~XFS_MOUNT_GRPID;
-		} else if (!strcmp(this_char, MNTOPT_WSYNC)) {
+			break;
+		case Opt_wsync:
 			mp->m_flags |= XFS_MOUNT_WSYNC;
-		} else if (!strcmp(this_char, MNTOPT_NORECOVERY)) {
+			break;
+		case Opt_norecovery:
 			mp->m_flags |= XFS_MOUNT_NORECOVERY;
-		} else if (!strcmp(this_char, MNTOPT_NOALIGN)) {
+			break;
+		case Opt_noalign:
 			mp->m_flags |= XFS_MOUNT_NOALIGN;
-		} else if (!strcmp(this_char, MNTOPT_SWALLOC)) {
+			break;
+		case Opt_swalloc:
 			mp->m_flags |= XFS_MOUNT_SWALLOC;
-		} else if (!strcmp(this_char, MNTOPT_SUNIT)) {
-			if (!value || !*value) {
-				xfs_warn(mp, "%s option requires an argument",
-					this_char);
-				return EINVAL;
-			}
-			dsunit = simple_strtoul(value, &eov, 10);
-		} else if (!strcmp(this_char, MNTOPT_SWIDTH)) {
-			if (!value || !*value) {
-				xfs_warn(mp, "%s option requires an argument",
-					this_char);
-				return EINVAL;
-			}
-			dswidth = simple_strtoul(value, &eov, 10);
-		} else if (!strcmp(this_char, MNTOPT_64BITINODE)) {
+			break;
+		case Opt_sunit:
+			intarg = 0;
+			ret = match_int(args, &intarg);
+			if (ret)
+				goto free_orig;
+			dsunit = intarg;
+			break;
+		case Opt_swidth:
+			intarg = 0;
+			ret = match_int(args, &intarg);
+			if (ret)
+				goto free_orig;
+			dswidth = intarg;
+			break;
+		case Opt_inode64:
 			mp->m_flags &= ~XFS_MOUNT_SMALL_INUMS;
 #if !XFS_BIG_INUMS
-			xfs_warn(mp, "%s option not allowed on this system",
-				this_char);
-			return EINVAL;
+			xfs_warn(mp, "%s options not allowed on this system", p);
+			ret = EINVAL;
+			goto free_orig;
 #endif
-		} else if (!strcmp(this_char, MNTOPT_NOUUID)) {
+			break;
+		case Opt_nouuid:
 			mp->m_flags |= XFS_MOUNT_NOUUID;
-		} else if (!strcmp(this_char, MNTOPT_BARRIER)) {
+			break;
+		case Opt_barrier:
 			mp->m_flags |= XFS_MOUNT_BARRIER;
-		} else if (!strcmp(this_char, MNTOPT_NOBARRIER)) {
+			break;
+		case Opt_nobarrier:
 			mp->m_flags &= ~XFS_MOUNT_BARRIER;
-		} else if (!strcmp(this_char, MNTOPT_IKEEP)) {
+			break;
+		case Opt_ikeep:
 			mp->m_flags |= XFS_MOUNT_IKEEP;
-		} else if (!strcmp(this_char, MNTOPT_NOIKEEP)) {
+			break;
+		case Opt_noikeep:
 			mp->m_flags &= ~XFS_MOUNT_IKEEP;
-		} else if (!strcmp(this_char, MNTOPT_LARGEIO)) {
+			break;
+		case Opt_largeio:
 			mp->m_flags &= ~XFS_MOUNT_COMPAT_IOSIZE;
-		} else if (!strcmp(this_char, MNTOPT_NOLARGEIO)) {
+			break;
+		case Opt_nolargeio:
 			mp->m_flags |= XFS_MOUNT_COMPAT_IOSIZE;
-		} else if (!strcmp(this_char, MNTOPT_ATTR2)) {
+			break;
+		case Opt_attr2:
 			mp->m_flags |= XFS_MOUNT_ATTR2;
-		} else if (!strcmp(this_char, MNTOPT_NOATTR2)) {
+			break;
+		case Opt_noattr2:
 			mp->m_flags &= ~XFS_MOUNT_ATTR2;
 			mp->m_flags |= XFS_MOUNT_NOATTR2;
-		} else if (!strcmp(this_char, MNTOPT_FILESTREAM)) {
+			break;
+		case Opt_filestreams:
 			mp->m_flags |= XFS_MOUNT_FILESTREAMS;
-		} else if (!strcmp(this_char, MNTOPT_NOQUOTA)) {
+			break;
+		case Opt_noquota:
 			mp->m_qflags &= ~XFS_ALL_QUOTA_ACCT;
 			mp->m_qflags &= ~XFS_ALL_QUOTA_ENFD;
 			mp->m_qflags &= ~XFS_ALL_QUOTA_ACTIVE;
-		} else if (!strcmp(this_char, MNTOPT_QUOTA) ||
-			   !strcmp(this_char, MNTOPT_UQUOTA) ||
-			   !strcmp(this_char, MNTOPT_USRQUOTA)) {
+			break;
+		case Opt_quota:
+		case Opt_uquota:
+		case Opt_usrquota:
 			mp->m_qflags |= (XFS_UQUOTA_ACCT | XFS_UQUOTA_ACTIVE |
 					 XFS_UQUOTA_ENFD);
-		} else if (!strcmp(this_char, MNTOPT_QUOTANOENF) ||
-			   !strcmp(this_char, MNTOPT_UQUOTANOENF)) {
+			break;
+		case Opt_qnoenf:
+		case Opt_uqnoenf:
 			mp->m_qflags |= (XFS_UQUOTA_ACCT | XFS_UQUOTA_ACTIVE);
 			mp->m_qflags &= ~XFS_UQUOTA_ENFD;
-		} else if (!strcmp(this_char, MNTOPT_PQUOTA) ||
-			   !strcmp(this_char, MNTOPT_PRJQUOTA)) {
+			break;
+		case Opt_pquota:
+		case Opt_prjquota:
 			mp->m_qflags |= (XFS_PQUOTA_ACCT | XFS_PQUOTA_ACTIVE |
 					 XFS_OQUOTA_ENFD);
-		} else if (!strcmp(this_char, MNTOPT_PQUOTANOENF)) {
+			break;
+		case Opt_pqnoenf:
 			mp->m_qflags |= (XFS_PQUOTA_ACCT | XFS_PQUOTA_ACTIVE);
 			mp->m_qflags &= ~XFS_OQUOTA_ENFD;
-		} else if (!strcmp(this_char, MNTOPT_GQUOTA) ||
-			   !strcmp(this_char, MNTOPT_GRPQUOTA)) {
+			break;
+		case Opt_gquota:
+		case Opt_grpquota:
 			mp->m_qflags |= (XFS_GQUOTA_ACCT | XFS_GQUOTA_ACTIVE |
 					 XFS_OQUOTA_ENFD);
-		} else if (!strcmp(this_char, MNTOPT_GQUOTANOENF)) {
+			break;
+		case Opt_gqnoenf:
 			mp->m_qflags |= (XFS_GQUOTA_ACCT | XFS_GQUOTA_ACTIVE);
 			mp->m_qflags &= ~XFS_OQUOTA_ENFD;
-		} else if (!strcmp(this_char, MNTOPT_DELAYLOG)) {
-			xfs_warn(mp,
-	"delaylog is the default now, option is deprecated.");
-		} else if (!strcmp(this_char, MNTOPT_NODELAYLOG)) {
-			xfs_warn(mp,
-	"nodelaylog support has been removed, option is deprecated.");
-		} else if (!strcmp(this_char, MNTOPT_DISCARD)) {
+			break;
+		case Opt_discard:
 			mp->m_flags |= XFS_MOUNT_DISCARD;
-		} else if (!strcmp(this_char, MNTOPT_NODISCARD)) {
+			break;
+		case Opt_nodiscard:
 			mp->m_flags &= ~XFS_MOUNT_DISCARD;
-		} else if (!strcmp(this_char, "ihashsize")) {
+			break;
+		case Opt_delaylog:
+			xfs_warn(mp,
+		"delaylog is the default now, option is deprecated.");
+			break;
+		case Opt_nodelaylog:
+			xfs_warn(mp,
+		"nodelaylog support has been removed, option is deprecated.");
+			break;
+		case Opt_ihashsize:
 			xfs_warn(mp,
-	"ihashsize no longer used, option is deprecated.");
-		} else if (!strcmp(this_char, "osyncisdsync")) {
+		"ihashsize no longer used, option is deprecated.");
+		case Opt_osyncisdsync:
 			xfs_warn(mp,
-	"osyncisdsync has no effect, option is deprecated.");
-		} else if (!strcmp(this_char, "osyncisosync")) {
+		"osyncisdsync has no effect, option is deprecated.");
+			break;
+		case Opt_osyncisosync:
 			xfs_warn(mp,
-	"osyncisosync has no effect, option is deprecated.");
-		} else if (!strcmp(this_char, "irixsgid")) {
+		"osyncisosync has no effect, option is deprecated.");
+			break;
+		case Opt_irixsgid:
 			xfs_warn(mp,
-	"irixsgid is now a sysctl(2) variable, option is deprecated.");
-		} else {
-			xfs_warn(mp, "unknown mount option [%s].", this_char);
-			return EINVAL;
+		"irixsgid is now a sysctl(2) variable, option is deprecated.");
+			break;
+		default:
+			xfs_warn(mp, "unknown mount option [%s].", p);
+			break;
 		}
+
+		kfree(string);
+		string = NULL;
 	}
 
+	kfree(orig);
+
 	/*
 	 * no recovery flag requires a read-only mount
 	 */
@@ -468,6 +567,12 @@ done:
 	}
 
 	return 0;
+
+free_string:
+	kfree(string);
+free_orig:
+	kfree(orig);
+	return ret;
 }
 
 struct proc_xfs_info {
@@ -476,10 +581,12 @@ struct proc_xfs_info {
 };
 
 STATIC int
-xfs_showargs(
-	struct xfs_mount	*mp,
-	struct seq_file		*m)
+xfs_fs_show_options(
+	struct seq_file		*seq,
+	struct dentry		*dentry)
 {
+	struct xfs_mount	*mp = XFS_M(dentry->d_sb);
+
 	static struct proc_xfs_info xfs_info_set[] = {
 		/* the few simple ones we can get from the mount struct */
 		{ XFS_MOUNT_IKEEP,		"," MNTOPT_IKEEP },
@@ -505,58 +612,60 @@ xfs_showargs(
 
 	for (xfs_infop = xfs_info_set; xfs_infop->flag; xfs_infop++) {
 		if (mp->m_flags & xfs_infop->flag)
-			seq_puts(m, xfs_infop->str);
+			seq_puts(seq, xfs_infop->str);
 	}
 	for (xfs_infop = xfs_info_unset; xfs_infop->flag; xfs_infop++) {
 		if (!(mp->m_flags & xfs_infop->flag))
-			seq_puts(m, xfs_infop->str);
+			seq_puts(seq, xfs_infop->str);
 	}
 
 	if (mp->m_flags & XFS_MOUNT_DFLT_IOSIZE)
-		seq_printf(m, "," MNTOPT_ALLOCSIZE "=%dk",
+		seq_printf(seq, "," MNTOPT_ALLOCSIZE "=%dk",
 				(int)(1 << mp->m_writeio_log) >> 10);
 
 	if (mp->m_logbufs > 0)
-		seq_printf(m, "," MNTOPT_LOGBUFS "=%d", mp->m_logbufs);
+		seq_printf(seq, "," MNTOPT_LOGBUFS "=%d", mp->m_logbufs);
 	if (mp->m_logbsize > 0)
-		seq_printf(m, "," MNTOPT_LOGBSIZE "=%dk", mp->m_logbsize >> 10);
+		seq_printf(seq, "," MNTOPT_LOGBSIZE "=%dk",
+				mp->m_logbsize >> 10);
 
 	if (mp->m_logname)
-		seq_printf(m, "," MNTOPT_LOGDEV "=%s", mp->m_logname);
+		seq_printf(seq, "," MNTOPT_LOGDEV "=%s", mp->m_logname);
 	if (mp->m_rtname)
-		seq_printf(m, "," MNTOPT_RTDEV "=%s", mp->m_rtname);
+		seq_printf(seq, "," MNTOPT_RTDEV "=%s", mp->m_rtname);
 
 	if (mp->m_dalign > 0)
-		seq_printf(m, "," MNTOPT_SUNIT "=%d",
+		seq_printf(seq, "," MNTOPT_SUNIT "=%d",
 				(int)XFS_FSB_TO_BB(mp, mp->m_dalign));
 	if (mp->m_swidth > 0)
-		seq_printf(m, "," MNTOPT_SWIDTH "=%d",
+		seq_printf(seq, "," MNTOPT_SWIDTH "=%d",
 				(int)XFS_FSB_TO_BB(mp, mp->m_swidth));
 
 	if (mp->m_qflags & (XFS_UQUOTA_ACCT|XFS_UQUOTA_ENFD))
-		seq_puts(m, "," MNTOPT_USRQUOTA);
+		seq_puts(seq, "," MNTOPT_USRQUOTA);
 	else if (mp->m_qflags & XFS_UQUOTA_ACCT)
-		seq_puts(m, "," MNTOPT_UQUOTANOENF);
+		seq_puts(seq, "," MNTOPT_UQUOTANOENF);
 
 	/* Either project or group quotas can be active, not both */
 
 	if (mp->m_qflags & XFS_PQUOTA_ACCT) {
 		if (mp->m_qflags & XFS_OQUOTA_ENFD)
-			seq_puts(m, "," MNTOPT_PRJQUOTA);
+			seq_puts(seq, "," MNTOPT_PRJQUOTA);
 		else
-			seq_puts(m, "," MNTOPT_PQUOTANOENF);
+			seq_puts(seq, "," MNTOPT_PQUOTANOENF);
 	} else if (mp->m_qflags & XFS_GQUOTA_ACCT) {
 		if (mp->m_qflags & XFS_OQUOTA_ENFD)
-			seq_puts(m, "," MNTOPT_GRPQUOTA);
+			seq_puts(seq, "," MNTOPT_GRPQUOTA);
 		else
-			seq_puts(m, "," MNTOPT_GQUOTANOENF);
+			seq_puts(seq, "," MNTOPT_GQUOTANOENF);
 	}
 
 	if (!(mp->m_qflags & XFS_ALL_QUOTA_ACCT))
-		seq_puts(m, "," MNTOPT_NOQUOTA);
+		seq_puts(seq, "," MNTOPT_NOQUOTA);
 
 	return 0;
 }
+
 __uint64_t
 xfs_max_file_offset(
 	unsigned int		blockshift)
@@ -1221,14 +1330,6 @@ xfs_fs_unfreeze(
 	return 0;
 }
 
-STATIC int
-xfs_fs_show_options(
-	struct seq_file		*m,
-	struct dentry		*root)
-{
-	return -xfs_showargs(XFS_M(root->d_sb), m);
-}
-
 /*
  * This function fills in xfs_mount_t fields based on mount args.
  * Note: the superblock _has_ now been read in.
-- 
1.7.9.2.323.gf051a

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

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

* Re: [PATCH V4] xfs: cleanup the mount options
  2012-07-08 11:36         ` [PATCH V4] " Wanlong Gao
@ 2012-07-09  0:22           ` Dave Chinner
  2012-07-09  9:21             ` Wanlong Gao
  0 siblings, 1 reply; 31+ messages in thread
From: Dave Chinner @ 2012-07-09  0:22 UTC (permalink / raw)
  To: Wanlong Gao; +Cc: Christoph Hellwig, Ben Myers, Zach Brown, XFS

On Sun, Jul 08, 2012 at 07:36:37PM +0800, Wanlong Gao wrote:
> remove the mount options macro, use tokens instead.
> 
> CC: Ben Myers <bpm@sgi.com>
> CC: Christoph Hellwig <hch@infradead.org>
> CC: Dave Chinner <david@fromorbit.com>
> CC: Zach Brown <zab@zabbo.net>
> Signed-off-by: Wanlong Gao <gaowanlong@cn.fujitsu.com>
> ---

A "what's changed in this version" list would be handy here.

>  fs/xfs/xfs_super.c |  539 +++++++++++++++++++++++++++++++---------------------
>  1 file changed, 320 insertions(+), 219 deletions(-)

....

> -
> -STATIC unsigned long
> -suffix_strtoul(char *s, char **endp, unsigned int base)
> +STATIC int
> +suffix_match_int(substring_t *s, int *result)

I'm not sure ints are the best unit to use here....

>  {
> -	int	last, shift_left_factor = 0;
> -	char	*value = s;
> +	int ret;
> +	int last, shift_left_factor = 0;
> +	char *value = s->to - 1;
>  
> -	last = strlen(value) - 1;
> -	if (value[last] == 'K' || value[last] == 'k') {
> +	if (*value == 'K' || *value == 'k') {
>  		shift_left_factor = 10;
> -		value[last] = '\0';
> +		s->to--;
>  	}
> -	if (value[last] == 'M' || value[last] == 'm') {
> +	if (*value == 'M' || *value == 'm') {
>  		shift_left_factor = 20;
> -		value[last] = '\0';
> +		s->to--;
>  	}
> -	if (value[last] == 'G' || value[last] == 'g') {
> +	if (*value == 'G' || *value == 'g') {
>  		shift_left_factor = 30;
> -		value[last] = '\0';
> +		s->to--;
>  	}
>  
> -	return simple_strtoul((const char *)s, endp, base) << shift_left_factor;
> +	ret = match_number(s, result, 0);
> +	*result = *result << shift_left_factor;

Because this overflows or gives the negative values for numbers like
2G far too easily. I think this function needs to return an unsigned
long.

> +	ret = ENOMEM;
> +	options = kstrdup(options, GFP_NOFS);
> +	if (!options)
> +		goto done;

I commented on this error form previously. Can you convert them all
to be consistent with the rest of the code? i.e:

	options = kstrdup(options, GFP_NOFS);
	if (!options) {
		ret = ENOMEM;
		goto done;
	}

i.e. set the error value (if necessary) in the error branch....

> +	orig = options;
> +
> +	while ((p = strsep(&orig, ",")) != NULL) {
> +		int token;
> +		if (!*p)
>  			continue;
> +
> +		token = match_token(p, tokens, args);
> +		switch (token) {
> +		case Opt_logbufs:
> +			intarg = 0;

Please move the initialisation of intarg up above the switch
statement so that it is initialised once for all cases instead of
individually in the cases that use it. That means we don't have to
remember to do it in future for new or changed mount options...

> +			ret = match_int(args, &intarg);
> +			if (ret)
> +				goto free_orig;
> +			mp->m_logbufs = intarg;
> +			break;
> +		case Opt_logbsize:
> +			ret = suffix_match_int(args, &intarg);
> +			if (ret)
> +				goto free_orig;
> +			mp->m_logbsize = intarg;
> +			break;
> +		case Opt_logdev:
> +			ret = ENOMEM;
> +			string = match_strdup(args);
> +			if (!string)
> +				goto free_orig;
> +
> +			mp->m_logname = kstrndup(string, MAXNAMELEN, GFP_KERNEL);
>  			if (!mp->m_logname)
> +				goto free_string;

This match_strdup/kstrndup pattern is repeated a couple of times,
and requires a special failure case (goto free_string) - wrapping it
in helper function is probably a good idea so that the special
failure case can be removed from this main parse loop...

> +		case Opt_biosize:
> +			intarg = 0;
> +			ret = match_int(args, &intarg);
> +			if (ret)
> +				goto free_orig;
> +			iosizelog = ffs(intarg) - 1;
> +			break;
> +		case Opt_allocsize:
> +			ret = suffix_match_int(args, &intarg);
> +			if (ret)
> +				goto free_orig;
> +			iosizelog = ffs(intarg) - 1;
> +			break;

These two can be collapsed into:

		case Opt_biosize:
		case Opt_allocsize:
			ret = suffix_match_int(args, &intarg);
			if (ret)
				goto free_orig;
			iosizelog = ffs(intarg) - 1;
			break;

Also, these two a a good example of why intarg should be initialised
to zero outside the switch statement - they both do almost exactly
the same thing, but one initialises intarg and the other doesn't. Is
that a bug? I can't tell without looking at the implementations of
match_int and suffix_match_int....

> +		case Opt_delaylog:
> +			xfs_warn(mp,
> +		"delaylog is the default now, option is deprecated.");

As preivously mentioned, duplication of the mount option is here.

Adding something like:

#define MNTOPT_DEPRECATED "has no effect, option is deprecated"

Means these can become:

		case Opt_delaylog:
			xfs_warn(mp, MNTOPT_DELAYLOG MNTOPT_DEPRECATED);
			break;

> +		case Opt_nodelaylog:
> +			xfs_warn(mp,
> +		"nodelaylog support has been removed, option is deprecated.");

			xfs_warn(mp, MNTOPT_NODELAYLOG MNTOPT_DEPRECATED);

> +			break;
> +		case Opt_ihashsize:
>  			xfs_warn(mp,
> +		"ihashsize no longer used, option is deprecated.");

			xfs_warn(mp, MNTOPT_IHASHSIZE MNTOPT_DEPRECATED);

And so on for all the deprecated options. That way we get a
consistent mesage for all deprecated options and it's easy to keep
that way in the future.

Cheers,

Dave.
-- 
Dave Chinner
david@fromorbit.com

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

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

* Re: [PATCH V4] xfs: cleanup the mount options
  2012-07-09  0:22           ` Dave Chinner
@ 2012-07-09  9:21             ` Wanlong Gao
  2012-07-11  2:26               ` Dave Chinner
  0 siblings, 1 reply; 31+ messages in thread
From: Wanlong Gao @ 2012-07-09  9:21 UTC (permalink / raw)
  To: Dave Chinner; +Cc: Christoph Hellwig, Ben Myers, Zach Brown, XFS

On 07/09/2012 08:22 AM, Dave Chinner wrote:
> On Sun, Jul 08, 2012 at 07:36:37PM +0800, Wanlong Gao wrote:
>> remove the mount options macro, use tokens instead.
>>
>> CC: Ben Myers <bpm@sgi.com>
>> CC: Christoph Hellwig <hch@infradead.org>
>> CC: Dave Chinner <david@fromorbit.com>
>> CC: Zach Brown <zab@zabbo.net>
>> Signed-off-by: Wanlong Gao <gaowanlong@cn.fujitsu.com>
>> ---
> 
> A "what's changed in this version" list would be handy here.
> 
>>  fs/xfs/xfs_super.c |  539 +++++++++++++++++++++++++++++++---------------------
>>  1 file changed, 320 insertions(+), 219 deletions(-)
> 
> ....
> 
>> -
>> -STATIC unsigned long
>> -suffix_strtoul(char *s, char **endp, unsigned int base)
>> +STATIC int
>> +suffix_match_int(substring_t *s, int *result)
> 
> I'm not sure ints are the best unit to use here....
> 
>>  {
>> -	int	last, shift_left_factor = 0;
>> -	char	*value = s;
>> +	int ret;
>> +	int last, shift_left_factor = 0;
>> +	char *value = s->to - 1;
>>  
>> -	last = strlen(value) - 1;
>> -	if (value[last] == 'K' || value[last] == 'k') {
>> +	if (*value == 'K' || *value == 'k') {
>>  		shift_left_factor = 10;
>> -		value[last] = '\0';
>> +		s->to--;
>>  	}
>> -	if (value[last] == 'M' || value[last] == 'm') {
>> +	if (*value == 'M' || *value == 'm') {
>>  		shift_left_factor = 20;
>> -		value[last] = '\0';
>> +		s->to--;
>>  	}
>> -	if (value[last] == 'G' || value[last] == 'g') {
>> +	if (*value == 'G' || *value == 'g') {
>>  		shift_left_factor = 30;
>> -		value[last] = '\0';
>> +		s->to--;
>>  	}
>>  
>> -	return simple_strtoul((const char *)s, endp, base) << shift_left_factor;
>> +	ret = match_number(s, result, 0);
>> +	*result = *result << shift_left_factor;
> 
> Because this overflows or gives the negative values for numbers like
> 2G far too easily. I think this function needs to return an unsigned
> long.

Do you mean the "result" should be "unsigned long" but not the return value?
Because the return value is a error state.

> 
>> +	ret = ENOMEM;
>> +	options = kstrdup(options, GFP_NOFS);
>> +	if (!options)
>> +		goto done;
> 
> I commented on this error form previously. Can you convert them all
> to be consistent with the rest of the code? i.e:

OK, got it, will do in next version.

> 
> 	options = kstrdup(options, GFP_NOFS);
> 	if (!options) {
> 		ret = ENOMEM;
> 		goto done;
> 	}
> 
> i.e. set the error value (if necessary) in the error branch....
> 
>> +	orig = options;
>> +
>> +	while ((p = strsep(&orig, ",")) != NULL) {
>> +		int token;
>> +		if (!*p)
>>  			continue;
>> +
>> +		token = match_token(p, tokens, args);
>> +		switch (token) {
>> +		case Opt_logbufs:
>> +			intarg = 0;
> 
> Please move the initialisation of intarg up above the switch
> statement so that it is initialised once for all cases instead of
> individually in the cases that use it. That means we don't have to
> remember to do it in future for new or changed mount options...

OK, got it.

> 
>> +			ret = match_int(args, &intarg);
>> +			if (ret)
>> +				goto free_orig;
>> +			mp->m_logbufs = intarg;
>> +			break;
>> +		case Opt_logbsize:
>> +			ret = suffix_match_int(args, &intarg);
>> +			if (ret)
>> +				goto free_orig;
>> +			mp->m_logbsize = intarg;
>> +			break;
>> +		case Opt_logdev:
>> +			ret = ENOMEM;
>> +			string = match_strdup(args);
>> +			if (!string)
>> +				goto free_orig;
>> +
>> +			mp->m_logname = kstrndup(string, MAXNAMELEN, GFP_KERNEL);
>>  			if (!mp->m_logname)
>> +				goto free_string;
> 
> This match_strdup/kstrndup pattern is repeated a couple of times,
> and requires a special failure case (goto free_string) - wrapping it
> in helper function is probably a good idea so that the special
> failure case can be removed from this main parse loop...

Thank you for this suggestion, will do.

> 
>> +		case Opt_biosize:
>> +			intarg = 0;
>> +			ret = match_int(args, &intarg);
>> +			if (ret)
>> +				goto free_orig;
>> +			iosizelog = ffs(intarg) - 1;
>> +			break;
>> +		case Opt_allocsize:
>> +			ret = suffix_match_int(args, &intarg);
>> +			if (ret)
>> +				goto free_orig;
>> +			iosizelog = ffs(intarg) - 1;
>> +			break;
> 
> These two can be collapsed into:
> 
> 		case Opt_biosize:
> 		case Opt_allocsize:
> 			ret = suffix_match_int(args, &intarg);
> 			if (ret)
> 				goto free_orig;
> 			iosizelog = ffs(intarg) - 1;
> 			break;
> 
> Also, these two a a good example of why intarg should be initialised
> to zero outside the switch statement - they both do almost exactly
> the same thing, but one initialises intarg and the other doesn't. Is
> that a bug? I can't tell without looking at the implementations of
> match_int and suffix_match_int....

Yeah, thank you.

> 
>> +		case Opt_delaylog:
>> +			xfs_warn(mp,
>> +		"delaylog is the default now, option is deprecated.");
> 
> As preivously mentioned, duplication of the mount option is here.

Sorry, will update.


Thanks,
Wanlong Gao

> 
> Adding something like:
> 
> #define MNTOPT_DEPRECATED "has no effect, option is deprecated"
> 
> Means these can become:
> 
> 		case Opt_delaylog:
> 			xfs_warn(mp, MNTOPT_DELAYLOG MNTOPT_DEPRECATED);
> 			break;
> 
>> +		case Opt_nodelaylog:
>> +			xfs_warn(mp,
>> +		"nodelaylog support has been removed, option is deprecated.");
> 
> 			xfs_warn(mp, MNTOPT_NODELAYLOG MNTOPT_DEPRECATED);
> 
>> +			break;
>> +		case Opt_ihashsize:
>>  			xfs_warn(mp,
>> +		"ihashsize no longer used, option is deprecated.");
> 
> 			xfs_warn(mp, MNTOPT_IHASHSIZE MNTOPT_DEPRECATED);
> 
> And so on for all the deprecated options. That way we get a
> consistent mesage for all deprecated options and it's easy to keep
> that way in the future.
> 
> Cheers,
> 
> Dave.
> 


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

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

* Re: [PATCH V4] xfs: cleanup the mount options
  2012-07-09  9:21             ` Wanlong Gao
@ 2012-07-11  2:26               ` Dave Chinner
  2012-07-11  6:29                 ` [PATCH V5] " Wanlong Gao
  0 siblings, 1 reply; 31+ messages in thread
From: Dave Chinner @ 2012-07-11  2:26 UTC (permalink / raw)
  To: Wanlong Gao; +Cc: Christoph Hellwig, Ben Myers, Zach Brown, XFS

On Mon, Jul 09, 2012 at 05:21:56PM +0800, Wanlong Gao wrote:
> On 07/09/2012 08:22 AM, Dave Chinner wrote:
> > On Sun, Jul 08, 2012 at 07:36:37PM +0800, Wanlong Gao wrote:
> >> remove the mount options macro, use tokens instead.
> >>
> >> CC: Ben Myers <bpm@sgi.com>
> >> CC: Christoph Hellwig <hch@infradead.org>
> >> CC: Dave Chinner <david@fromorbit.com>
> >> CC: Zach Brown <zab@zabbo.net>
> >> Signed-off-by: Wanlong Gao <gaowanlong@cn.fujitsu.com>
> >> ---
> > 
> > A "what's changed in this version" list would be handy here.
> > 
> >>  fs/xfs/xfs_super.c |  539 +++++++++++++++++++++++++++++++---------------------
> >>  1 file changed, 320 insertions(+), 219 deletions(-)
> > 
> > ....
> > 
> >> -
> >> -STATIC unsigned long
> >> -suffix_strtoul(char *s, char **endp, unsigned int base)
> >> +STATIC int
> >> +suffix_match_int(substring_t *s, int *result)
> > 
> > I'm not sure ints are the best unit to use here....
> > 
> >>  {
> >> -	int	last, shift_left_factor = 0;
> >> -	char	*value = s;
> >> +	int ret;
> >> +	int last, shift_left_factor = 0;
> >> +	char *value = s->to - 1;
> >>  
> >> -	last = strlen(value) - 1;
> >> -	if (value[last] == 'K' || value[last] == 'k') {
> >> +	if (*value == 'K' || *value == 'k') {
> >>  		shift_left_factor = 10;
> >> -		value[last] = '\0';
> >> +		s->to--;
> >>  	}
> >> -	if (value[last] == 'M' || value[last] == 'm') {
> >> +	if (*value == 'M' || *value == 'm') {
> >>  		shift_left_factor = 20;
> >> -		value[last] = '\0';
> >> +		s->to--;
> >>  	}
> >> -	if (value[last] == 'G' || value[last] == 'g') {
> >> +	if (*value == 'G' || *value == 'g') {
> >>  		shift_left_factor = 30;
> >> -		value[last] = '\0';
> >> +		s->to--;
> >>  	}
> >>  
> >> -	return simple_strtoul((const char *)s, endp, base) << shift_left_factor;
> >> +	ret = match_number(s, result, 0);
> >> +	*result = *result << shift_left_factor;
> > 
> > Because this overflows or gives the negative values for numbers like
> > 2G far too easily. I think this function needs to return an unsigned
> > long.
> 
> Do you mean the "result" should be "unsigned long" but not the return value?
> Because the return value is a error state.

result.

BTW: *result <<= shift_left_factor;

Cheers,

Dave.
-- 
Dave Chinner
david@fromorbit.com

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

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

* [PATCH V5] xfs: cleanup the mount options
  2012-07-11  2:26               ` Dave Chinner
@ 2012-07-11  6:29                 ` Wanlong Gao
  2012-07-16  8:06                   ` Wanlong Gao
  2012-07-23 23:28                   ` Dave Chinner
  0 siblings, 2 replies; 31+ messages in thread
From: Wanlong Gao @ 2012-07-11  6:29 UTC (permalink / raw)
  To: xfs; +Cc: Christoph Hellwig, Ben Myers, Zach Brown, Wanlong Gao

remove the mount options macro, use tokens instead.

change from V4: (as Dave suggested)
1. suffix_match_int avoid overflow.
2. convert the return style to be consistent with others.
3. move the "intarg" init above the switch.
4. move match_strdup to a help function.
5. collapsed Opt_biosize and Opt_allocsize.
6. make a consistent deprecated message.

CC: Ben Myers <bpm@sgi.com>
CC: Christoph Hellwig <hch@infradead.org>
CC: Dave Chinner <david@fromorbit.com>
CC: Zach Brown <zab@zabbo.net>
Signed-off-by: Wanlong Gao <gaowanlong@cn.fujitsu.com>
---
 fs/xfs/xfs_super.c | 551 +++++++++++++++++++++++++++++++----------------------
 1 file changed, 326 insertions(+), 225 deletions(-)

diff --git a/fs/xfs/xfs_super.c b/fs/xfs/xfs_super.c
index 07f70e1..3b62354 100644
--- a/fs/xfs/xfs_super.c
+++ b/fs/xfs/xfs_super.c
@@ -66,91 +66,171 @@ static const struct super_operations xfs_super_operations;
 static kmem_zone_t *xfs_ioend_zone;
 mempool_t *xfs_ioend_pool;
 
-#define MNTOPT_LOGBUFS	"logbufs"	/* number of XFS log buffers */
-#define MNTOPT_LOGBSIZE	"logbsize"	/* size of XFS log buffers */
-#define MNTOPT_LOGDEV	"logdev"	/* log device */
-#define MNTOPT_RTDEV	"rtdev"		/* realtime I/O device */
-#define MNTOPT_BIOSIZE	"biosize"	/* log2 of preferred buffered io size */
-#define MNTOPT_WSYNC	"wsync"		/* safe-mode nfs compatible mount */
-#define MNTOPT_NOALIGN	"noalign"	/* turn off stripe alignment */
-#define MNTOPT_SWALLOC	"swalloc"	/* turn on stripe width allocation */
-#define MNTOPT_SUNIT	"sunit"		/* data volume stripe unit */
-#define MNTOPT_SWIDTH	"swidth"	/* data volume stripe width */
-#define MNTOPT_NOUUID	"nouuid"	/* ignore filesystem UUID */
-#define MNTOPT_MTPT	"mtpt"		/* filesystem mount point */
-#define MNTOPT_GRPID	"grpid"		/* group-ID from parent directory */
-#define MNTOPT_NOGRPID	"nogrpid"	/* group-ID from current process */
-#define MNTOPT_BSDGROUPS    "bsdgroups"    /* group-ID from parent directory */
-#define MNTOPT_SYSVGROUPS   "sysvgroups"   /* group-ID from current process */
-#define MNTOPT_ALLOCSIZE    "allocsize"    /* preferred allocation size */
-#define MNTOPT_NORECOVERY   "norecovery"   /* don't run XFS recovery */
-#define MNTOPT_BARRIER	"barrier"	/* use writer barriers for log write and
-					 * unwritten extent conversion */
-#define MNTOPT_NOBARRIER "nobarrier"	/* .. disable */
-#define MNTOPT_64BITINODE   "inode64"	/* inodes can be allocated anywhere */
-#define MNTOPT_IKEEP	"ikeep"		/* do not free empty inode clusters */
-#define MNTOPT_NOIKEEP	"noikeep"	/* free empty inode clusters */
-#define MNTOPT_LARGEIO	   "largeio"	/* report large I/O sizes in stat() */
-#define MNTOPT_NOLARGEIO   "nolargeio"	/* do not report large I/O sizes
-					 * in stat(). */
-#define MNTOPT_ATTR2	"attr2"		/* do use attr2 attribute format */
-#define MNTOPT_NOATTR2	"noattr2"	/* do not use attr2 attribute format */
-#define MNTOPT_FILESTREAM  "filestreams" /* use filestreams allocator */
-#define MNTOPT_QUOTA	"quota"		/* disk quotas (user) */
-#define MNTOPT_NOQUOTA	"noquota"	/* no quotas */
-#define MNTOPT_USRQUOTA	"usrquota"	/* user quota enabled */
-#define MNTOPT_GRPQUOTA	"grpquota"	/* group quota enabled */
-#define MNTOPT_PRJQUOTA	"prjquota"	/* project quota enabled */
-#define MNTOPT_UQUOTA	"uquota"	/* user quota (IRIX variant) */
-#define MNTOPT_GQUOTA	"gquota"	/* group quota (IRIX variant) */
-#define MNTOPT_PQUOTA	"pquota"	/* project quota (IRIX variant) */
-#define MNTOPT_UQUOTANOENF "uqnoenforce"/* user quota limit enforcement */
-#define MNTOPT_GQUOTANOENF "gqnoenforce"/* group quota limit enforcement */
-#define MNTOPT_PQUOTANOENF "pqnoenforce"/* project quota limit enforcement */
-#define MNTOPT_QUOTANOENF  "qnoenforce"	/* same as uqnoenforce */
-#define MNTOPT_DELAYLOG    "delaylog"	/* Delayed logging enabled */
-#define MNTOPT_NODELAYLOG  "nodelaylog"	/* Delayed logging disabled */
-#define MNTOPT_DISCARD	   "discard"	/* Discard unused blocks */
-#define MNTOPT_NODISCARD   "nodiscard"	/* Do not discard unused blocks */
+#define	MNTOPT_LOGBUFS		"logbufs"
+#define	MNTOPT_LOGBSIZE		"logbsize"
+#define	MNTOPT_LOGDEV		"logdev"
+#define	MNTOPT_RTDEV		"rtdev"
+#define	MNTOPT_BIOSIZE		"biosize"
+#define	MNTOPT_WSYNC		"wsync"
+#define	MNTOPT_NOALIGN		"noalign"
+#define	MNTOPT_SWALLOC		"swalloc"
+#define	MNTOPT_SUNIT		"sunit"
+#define	MNTOPT_SWIDTH		"swidth"
+#define	MNTOPT_NOUUID		"nouuid"
+#define	MNTOPT_MTPT		"mtpt"
+#define	MNTOPT_GRPID		"grpid"
+#define	MNTOPT_NOGRPID		"nogrpid"
+#define	MNTOPT_BSDGROUPS	"bsdgroups"
+#define	MNTOPT_SYSVGROUPS	"sysvgroups"
+#define	MNTOPT_ALLOCSIZE	"allocsize"
+#define	MNTOPT_NORECOVERY	"norecovery"
+#define	MNTOPT_BARRIER		"barrier"
+#define	MNTOPT_NOBARRIER	"nobarrier"
+#define	MNTOPT_64BITINODE	"inode64"
+#define	MNTOPT_IKEEP		"ikeep"
+#define	MNTOPT_NOIKEEP		"noikeep"
+#define	MNTOPT_LARGEIO		"largeio"
+#define	MNTOPT_NOLARGEIO	"nolargeio"
+#define	MNTOPT_ATTR2		"attr2"
+#define	MNTOPT_NOATTR2		"noattr2"
+#define	MNTOPT_FILESTREAM	"filestreams"
+#define	MNTOPT_QUOTA		"quota"
+#define	MNTOPT_NOQUOTA		"noquota"
+#define	MNTOPT_USRQUOTA		"usrquota"
+#define	MNTOPT_GRPQUOTA		"grpquota"
+#define	MNTOPT_PRJQUOTA		"prjquota"
+#define	MNTOPT_UQUOTA		"uquota"
+#define	MNTOPT_GQUOTA		"gquota"
+#define	MNTOPT_PQUOTA		"pquota"
+#define	MNTOPT_UQUOTANOENF	"uqnoenforce"
+#define	MNTOPT_GQUOTANOENF	"gqnoenforce"
+#define	MNTOPT_PQUOTANOENF	"pqnoenforce"
+#define	MNTOPT_QUOTANOENF	"qnoenforce"
+#define	MNTOPT_DISCARD		"discard"
+#define	MNTOPT_NODISCARD	"nodiscard"
+#define	MNTOPT_DELAYLOG		"delaylog"
+#define	MNTOPT_NODELAYLOG	"nodelaylog"
+#define	MNTOPT_IHASHSIZE	"ihashsize"
+#define	MNTOPT_OSYNCISDSYNC	"osyncisdsync"
+#define	MNTOPT_OSYNCISOSYNC	"osyncisosync"
+#define	MNTOPT_IRIXSGID		"irixsgid"
+
+#define MNTOPT_DEPRECATED "has no effect, option is deprecated"
 
-/*
- * Table driven mount option parser.
- *
- * Currently only used for remount, but it will be used for mount
- * in the future, too.
- */
 enum {
-	Opt_barrier, Opt_nobarrier, Opt_err
+	Opt_logbufs, Opt_logbsize, Opt_logdev, Opt_rtdev, Opt_biosize,
+	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_inode64, Opt_ikeep, Opt_noikeep, Opt_largeio,
+	Opt_nolargeio, Opt_attr2, Opt_noattr2, Opt_filestreams, Opt_quota,
+	Opt_noquota, Opt_usrquota, Opt_grpquota, Opt_prjquota, Opt_uquota,
+	Opt_gquota, Opt_pquota, Opt_uqnoenf, Opt_gqnoenf, Opt_pqnoenf,
+	Opt_qnoenf, Opt_discard, Opt_nodiscard, Opt_delaylog, Opt_nodelaylog,
+	Opt_ihashsize, Opt_osyncisdsync, Opt_osyncisosync, Opt_irixsgid,
+	Opt_err
 };
 
 static const match_table_t tokens = {
-	{Opt_barrier, "barrier"},
-	{Opt_nobarrier, "nobarrier"},
+	{Opt_logbufs, MNTOPT_LOGBUFS "=%d"},	/* number of XFS log buffers */
+	{Opt_logbsize, MNTOPT_LOGBSIZE "=%s"},	/* size of XFS log buffers */
+	{Opt_logdev, MNTOPT_LOGDEV "=%s"},	/* log device */
+	{Opt_rtdev, MNTOPT_RTDEV "=%s"},	/* realtime I/O device */
+	{Opt_biosize, MNTOPT_BIOSIZE "=%d"},	/* log2 of preferred buffered io size */
+	{Opt_wsync, MNTOPT_WSYNC},		/* safe-mode nfs compatible mount */
+	{Opt_noalign, MNTOPT_NOALIGN},		/* turn off stripe alignment */
+	{Opt_swalloc, MNTOPT_SWALLOC},		/* turn on stripe width allocation */
+	{Opt_sunit, MNTOPT_SUNIT "=%d"},	/* data volume stripe unit */
+	{Opt_swidth, MNTOPT_SWIDTH "=%d"},	/* data volume stripe width */
+	{Opt_nouuid, MNTOPT_NOUUID},		/* ignore filesystem UUID */
+	{Opt_mtpt, MNTOPT_MTPT},		/* filesystem mount point */
+	{Opt_grpid, MNTOPT_GRPID},		/* group-ID from parent directory */
+	{Opt_nogrpid, MNTOPT_NOGRPID},		/* group-ID from current process */
+	{Opt_bsdgroups, MNTOPT_BSDGROUPS},	/* group-ID from parent directory */
+	{Opt_sysvgroups, MNTOPT_SYSVGROUPS},	/* group-ID from current process */
+	{Opt_allocsize, MNTOPT_ALLOCSIZE "=%s"},/* preferred allocation size */
+	{Opt_norecovery, MNTOPT_NORECOVERY},	/* do not run XFS recovery */
+	{Opt_barrier, MNTOPT_BARRIER},		/* use writer barrier for log write and
+						 * unwritten extent conversation */
+	{Opt_nobarrier, MNTOPT_NOBARRIER},	/* .. disable */
+	{Opt_inode64, MNTOPT_64BITINODE},	/* inodes can be allocated anywhere */
+	{Opt_ikeep, MNTOPT_IKEEP},		/* do not free empty inode clusters */
+	{Opt_noikeep, MNTOPT_NOIKEEP},		/* free empty inode clusters */
+	{Opt_largeio, MNTOPT_LARGEIO},		/* report large I/O sizes in start() */
+	{Opt_nolargeio, MNTOPT_NOLARGEIO},	/* do not report large I/O sizes
+						 * in start() */
+	{Opt_attr2, MNTOPT_ATTR2},		/* do use attr2 attribute format */
+	{Opt_noattr2, MNTOPT_NOATTR2},		/* do not use attr2 attribute format */
+	{Opt_filestreams, MNTOPT_FILESTREAM}, 	/* use filestreams allocator */
+	{Opt_quota, MNTOPT_QUOTA},		/* disk quotas (user) */
+	{Opt_noquota, MNTOPT_NOQUOTA},		/* no quotas */
+	{Opt_usrquota, MNTOPT_USRQUOTA},	/* user quota enabled */
+	{Opt_grpquota, MNTOPT_GRPQUOTA},	/* group quota enabled */
+	{Opt_prjquota, MNTOPT_PRJQUOTA},	/* project quota enabled */
+	{Opt_uquota, MNTOPT_UQUOTA},		/* user quota (IRIX variant) */
+	{Opt_gquota, MNTOPT_GQUOTA},		/* group quota (IRIX variant) */
+	{Opt_pquota, MNTOPT_PQUOTA},		/* project quota (IRIX variant) */
+	{Opt_uqnoenf, MNTOPT_UQUOTANOENF},	/* user quota limit enforcement */
+	{Opt_gqnoenf, MNTOPT_GQUOTANOENF},	/* group quota limit enforcement */
+	{Opt_pqnoenf, MNTOPT_PQUOTANOENF},	/* project quota limit enforcement */
+	{Opt_qnoenf, MNTOPT_QUOTANOENF},	/* same as uqnoenforce */
+	{Opt_discard, MNTOPT_DISCARD},		/* Discard unused blocks */
+	{Opt_nodiscard, MNTOPT_NODISCARD},	/* Do not discard unused blocks */
+	{Opt_delaylog, MNTOPT_DELAYLOG},	/* deprecated */
+	{Opt_nodelaylog, MNTOPT_NODELAYLOG},	/* deprecated */
+	{Opt_ihashsize, MNTOPT_IHASHSIZE},	/* deprecated */
+	{Opt_osyncisdsync, MNTOPT_OSYNCISDSYNC},/* deprecated */
+	{Opt_osyncisosync, MNTOPT_OSYNCISOSYNC},/* deprecated */
+	{Opt_irixsgid, MNTOPT_IRIXSGID},	/* deprecated */
 	{Opt_err, NULL}
 };
 
-
-STATIC unsigned long
-suffix_strtoul(char *s, char **endp, unsigned int base)
+STATIC int
+suffix_match_int(substring_t *s, unsigned long *result)
 {
-	int	last, shift_left_factor = 0;
-	char	*value = s;
+	int shift_left_factor = 0;
+	char *value = s->to - 1;
+	char *string;
 
-	last = strlen(value) - 1;
-	if (value[last] == 'K' || value[last] == 'k') {
+	if (*value == 'K' || *value == 'k') {
 		shift_left_factor = 10;
-		value[last] = '\0';
+		s->to--;
 	}
-	if (value[last] == 'M' || value[last] == 'm') {
+	if (*value == 'M' || *value == 'm') {
 		shift_left_factor = 20;
-		value[last] = '\0';
+		s->to--;
 	}
-	if (value[last] == 'G' || value[last] == 'g') {
+	if (*value == 'G' || *value == 'g') {
 		shift_left_factor = 30;
-		value[last] = '\0';
+		s->to--;
 	}
 
-	return simple_strtoul((const char *)s, endp, base) << shift_left_factor;
+	string = match_strdup(s);
+	if (!string)
+		return ENOMEM;
+
+	*result = simple_strtoul((const char *)string, NULL, 0) <<
+			shift_left_factor;
+
+	kfree(string);
+	return 0;
+}
+
+STATIC int
+match_name_strdup(substring_t *s, char *name)
+{
+	char *string;
+	string = match_strdup(s);
+	if (!string)
+		return ENOMEM;
+
+	name = kstrndup(string, MAXNAMELEN, GFP_KERNEL);
+	if (!name)
+		goto free;
+	return 0;
+free:
+	kfree(string);
+	return ENOMEM;
 }
 
 /*
@@ -166,11 +246,15 @@ xfs_parseargs(
 	char			*options)
 {
 	struct super_block	*sb = mp->m_super;
-	char			*this_char, *value, *eov;
+	char			*p;
 	int			dsunit = 0;
 	int			dswidth = 0;
-	int			iosize = 0;
 	__uint8_t		iosizelog = 0;
+	int			intarg;
+	unsigned long		ularg;
+	substring_t		args[MAX_OPT_ARGS];
+	char			*orig = NULL;
+	int			ret = 0;
 
 	/*
 	 * set up the mount name first so all the errors will refer to the
@@ -208,175 +292,192 @@ xfs_parseargs(
 	if (!options)
 		goto done;
 
-	while ((this_char = strsep(&options, ",")) != NULL) {
-		if (!*this_char)
+	options = kstrdup(options, GFP_NOFS);
+	if (!options) {
+		ret = ENOMEM;
+		goto done;
+	}
+
+	orig = options;
+
+	while ((p = strsep(&orig, ",")) != NULL) {
+		int token;
+		if (!*p)
 			continue;
-		if ((value = strchr(this_char, '=')) != NULL)
-			*value++ = 0;
-
-		if (!strcmp(this_char, MNTOPT_LOGBUFS)) {
-			if (!value || !*value) {
-				xfs_warn(mp, "%s option requires an argument",
-					this_char);
-				return EINVAL;
-			}
-			mp->m_logbufs = simple_strtoul(value, &eov, 10);
-		} else if (!strcmp(this_char, MNTOPT_LOGBSIZE)) {
-			if (!value || !*value) {
-				xfs_warn(mp, "%s option requires an argument",
-					this_char);
-				return EINVAL;
-			}
-			mp->m_logbsize = suffix_strtoul(value, &eov, 10);
-		} else if (!strcmp(this_char, MNTOPT_LOGDEV)) {
-			if (!value || !*value) {
-				xfs_warn(mp, "%s option requires an argument",
-					this_char);
-				return EINVAL;
-			}
-			mp->m_logname = kstrndup(value, MAXNAMELEN, GFP_KERNEL);
-			if (!mp->m_logname)
-				return ENOMEM;
-		} else if (!strcmp(this_char, MNTOPT_MTPT)) {
-			xfs_warn(mp, "%s option not allowed on this system",
-				this_char);
-			return EINVAL;
-		} else if (!strcmp(this_char, MNTOPT_RTDEV)) {
-			if (!value || !*value) {
-				xfs_warn(mp, "%s option requires an argument",
-					this_char);
-				return EINVAL;
-			}
-			mp->m_rtname = kstrndup(value, MAXNAMELEN, GFP_KERNEL);
-			if (!mp->m_rtname)
-				return ENOMEM;
-		} else if (!strcmp(this_char, MNTOPT_BIOSIZE)) {
-			if (!value || !*value) {
-				xfs_warn(mp, "%s option requires an argument",
-					this_char);
-				return EINVAL;
-			}
-			iosize = simple_strtoul(value, &eov, 10);
-			iosizelog = ffs(iosize) - 1;
-		} else if (!strcmp(this_char, MNTOPT_ALLOCSIZE)) {
-			if (!value || !*value) {
-				xfs_warn(mp, "%s option requires an argument",
-					this_char);
-				return EINVAL;
-			}
-			iosize = suffix_strtoul(value, &eov, 10);
-			iosizelog = ffs(iosize) - 1;
-		} else if (!strcmp(this_char, MNTOPT_GRPID) ||
-			   !strcmp(this_char, MNTOPT_BSDGROUPS)) {
+
+		token = match_token(p, tokens, args);
+		intarg = 0;
+		ularg = 0;
+		switch (token) {
+		case Opt_logbufs:
+			ret = match_int(args, &intarg);
+			if (ret)
+				goto free_orig;
+			mp->m_logbufs = intarg;
+			break;
+		case Opt_logbsize:
+			ret = suffix_match_int(args, &ularg);
+			if (ret)
+				goto free_orig;
+			mp->m_logbsize = ularg;
+			break;
+		case Opt_logdev:
+			ret = match_name_strdup(args, mp->m_logname);
+			if (ret)
+				goto free_orig;
+			break;
+		case Opt_mtpt:
+			xfs_warn(mp, "%s option not allowed on this system", p);
+			ret = EINVAL;
+			goto free_orig;
+		case Opt_rtdev:
+			ret = match_name_strdup(args, mp->m_rtname);
+			if (ret)
+				goto free_orig;
+			break;
+		case Opt_biosize:
+		case Opt_allocsize:
+			ret = suffix_match_int(args, &ularg);
+			if (ret)
+				goto free_orig;
+			iosizelog = ffs(ularg) - 1;
+			break;
+		case Opt_grpid:
+		case Opt_bsdgroups:
 			mp->m_flags |= XFS_MOUNT_GRPID;
-		} else if (!strcmp(this_char, MNTOPT_NOGRPID) ||
-			   !strcmp(this_char, MNTOPT_SYSVGROUPS)) {
+			break;
+		case Opt_nogrpid:
+		case Opt_sysvgroups:
 			mp->m_flags &= ~XFS_MOUNT_GRPID;
-		} else if (!strcmp(this_char, MNTOPT_WSYNC)) {
+			break;
+		case Opt_wsync:
 			mp->m_flags |= XFS_MOUNT_WSYNC;
-		} else if (!strcmp(this_char, MNTOPT_NORECOVERY)) {
+			break;
+		case Opt_norecovery:
 			mp->m_flags |= XFS_MOUNT_NORECOVERY;
-		} else if (!strcmp(this_char, MNTOPT_NOALIGN)) {
+			break;
+		case Opt_noalign:
 			mp->m_flags |= XFS_MOUNT_NOALIGN;
-		} else if (!strcmp(this_char, MNTOPT_SWALLOC)) {
+			break;
+		case Opt_swalloc:
 			mp->m_flags |= XFS_MOUNT_SWALLOC;
-		} else if (!strcmp(this_char, MNTOPT_SUNIT)) {
-			if (!value || !*value) {
-				xfs_warn(mp, "%s option requires an argument",
-					this_char);
-				return EINVAL;
-			}
-			dsunit = simple_strtoul(value, &eov, 10);
-		} else if (!strcmp(this_char, MNTOPT_SWIDTH)) {
-			if (!value || !*value) {
-				xfs_warn(mp, "%s option requires an argument",
-					this_char);
-				return EINVAL;
-			}
-			dswidth = simple_strtoul(value, &eov, 10);
-		} else if (!strcmp(this_char, MNTOPT_64BITINODE)) {
+			break;
+		case Opt_sunit:
+			ret = match_int(args, &intarg);
+			if (ret)
+				goto free_orig;
+			dsunit = intarg;
+			break;
+		case Opt_swidth:
+			ret = match_int(args, &intarg);
+			if (ret)
+				goto free_orig;
+			dswidth = intarg;
+			break;
+		case Opt_inode64:
 			mp->m_flags &= ~XFS_MOUNT_SMALL_INUMS;
 #if !XFS_BIG_INUMS
-			xfs_warn(mp, "%s option not allowed on this system",
-				this_char);
-			return EINVAL;
+			xfs_warn(mp, "%s options not allowed on this system", p);
+			ret = EINVAL;
+			goto free_orig;
 #endif
-		} else if (!strcmp(this_char, MNTOPT_NOUUID)) {
+			break;
+		case Opt_nouuid:
 			mp->m_flags |= XFS_MOUNT_NOUUID;
-		} else if (!strcmp(this_char, MNTOPT_BARRIER)) {
+			break;
+		case Opt_barrier:
 			mp->m_flags |= XFS_MOUNT_BARRIER;
-		} else if (!strcmp(this_char, MNTOPT_NOBARRIER)) {
+			break;
+		case Opt_nobarrier:
 			mp->m_flags &= ~XFS_MOUNT_BARRIER;
-		} else if (!strcmp(this_char, MNTOPT_IKEEP)) {
+			break;
+		case Opt_ikeep:
 			mp->m_flags |= XFS_MOUNT_IKEEP;
-		} else if (!strcmp(this_char, MNTOPT_NOIKEEP)) {
+			break;
+		case Opt_noikeep:
 			mp->m_flags &= ~XFS_MOUNT_IKEEP;
-		} else if (!strcmp(this_char, MNTOPT_LARGEIO)) {
+			break;
+		case Opt_largeio:
 			mp->m_flags &= ~XFS_MOUNT_COMPAT_IOSIZE;
-		} else if (!strcmp(this_char, MNTOPT_NOLARGEIO)) {
+			break;
+		case Opt_nolargeio:
 			mp->m_flags |= XFS_MOUNT_COMPAT_IOSIZE;
-		} else if (!strcmp(this_char, MNTOPT_ATTR2)) {
+			break;
+		case Opt_attr2:
 			mp->m_flags |= XFS_MOUNT_ATTR2;
-		} else if (!strcmp(this_char, MNTOPT_NOATTR2)) {
+			break;
+		case Opt_noattr2:
 			mp->m_flags &= ~XFS_MOUNT_ATTR2;
 			mp->m_flags |= XFS_MOUNT_NOATTR2;
-		} else if (!strcmp(this_char, MNTOPT_FILESTREAM)) {
+			break;
+		case Opt_filestreams:
 			mp->m_flags |= XFS_MOUNT_FILESTREAMS;
-		} else if (!strcmp(this_char, MNTOPT_NOQUOTA)) {
+			break;
+		case Opt_noquota:
 			mp->m_qflags &= ~XFS_ALL_QUOTA_ACCT;
 			mp->m_qflags &= ~XFS_ALL_QUOTA_ENFD;
 			mp->m_qflags &= ~XFS_ALL_QUOTA_ACTIVE;
-		} else if (!strcmp(this_char, MNTOPT_QUOTA) ||
-			   !strcmp(this_char, MNTOPT_UQUOTA) ||
-			   !strcmp(this_char, MNTOPT_USRQUOTA)) {
+			break;
+		case Opt_quota:
+		case Opt_uquota:
+		case Opt_usrquota:
 			mp->m_qflags |= (XFS_UQUOTA_ACCT | XFS_UQUOTA_ACTIVE |
 					 XFS_UQUOTA_ENFD);
-		} else if (!strcmp(this_char, MNTOPT_QUOTANOENF) ||
-			   !strcmp(this_char, MNTOPT_UQUOTANOENF)) {
+			break;
+		case Opt_qnoenf:
+		case Opt_uqnoenf:
 			mp->m_qflags |= (XFS_UQUOTA_ACCT | XFS_UQUOTA_ACTIVE);
 			mp->m_qflags &= ~XFS_UQUOTA_ENFD;
-		} else if (!strcmp(this_char, MNTOPT_PQUOTA) ||
-			   !strcmp(this_char, MNTOPT_PRJQUOTA)) {
+			break;
+		case Opt_pquota:
+		case Opt_prjquota:
 			mp->m_qflags |= (XFS_PQUOTA_ACCT | XFS_PQUOTA_ACTIVE |
 					 XFS_OQUOTA_ENFD);
-		} else if (!strcmp(this_char, MNTOPT_PQUOTANOENF)) {
+			break;
+		case Opt_pqnoenf:
 			mp->m_qflags |= (XFS_PQUOTA_ACCT | XFS_PQUOTA_ACTIVE);
 			mp->m_qflags &= ~XFS_OQUOTA_ENFD;
-		} else if (!strcmp(this_char, MNTOPT_GQUOTA) ||
-			   !strcmp(this_char, MNTOPT_GRPQUOTA)) {
+			break;
+		case Opt_gquota:
+		case Opt_grpquota:
 			mp->m_qflags |= (XFS_GQUOTA_ACCT | XFS_GQUOTA_ACTIVE |
 					 XFS_OQUOTA_ENFD);
-		} else if (!strcmp(this_char, MNTOPT_GQUOTANOENF)) {
+			break;
+		case Opt_gqnoenf:
 			mp->m_qflags |= (XFS_GQUOTA_ACCT | XFS_GQUOTA_ACTIVE);
 			mp->m_qflags &= ~XFS_OQUOTA_ENFD;
-		} else if (!strcmp(this_char, MNTOPT_DELAYLOG)) {
-			xfs_warn(mp,
-	"delaylog is the default now, option is deprecated.");
-		} else if (!strcmp(this_char, MNTOPT_NODELAYLOG)) {
-			xfs_warn(mp,
-	"nodelaylog support has been removed, option is deprecated.");
-		} else if (!strcmp(this_char, MNTOPT_DISCARD)) {
+			break;
+		case Opt_discard:
 			mp->m_flags |= XFS_MOUNT_DISCARD;
-		} else if (!strcmp(this_char, MNTOPT_NODISCARD)) {
+			break;
+		case Opt_nodiscard:
 			mp->m_flags &= ~XFS_MOUNT_DISCARD;
-		} else if (!strcmp(this_char, "ihashsize")) {
-			xfs_warn(mp,
-	"ihashsize no longer used, option is deprecated.");
-		} else if (!strcmp(this_char, "osyncisdsync")) {
-			xfs_warn(mp,
-	"osyncisdsync has no effect, option is deprecated.");
-		} else if (!strcmp(this_char, "osyncisosync")) {
-			xfs_warn(mp,
-	"osyncisosync has no effect, option is deprecated.");
-		} else if (!strcmp(this_char, "irixsgid")) {
-			xfs_warn(mp,
-	"irixsgid is now a sysctl(2) variable, option is deprecated.");
-		} else {
-			xfs_warn(mp, "unknown mount option [%s].", this_char);
-			return EINVAL;
+			break;
+		case Opt_delaylog:
+			xfs_warn(mp, MNTOPT_DELAYLOG MNTOPT_DEPRECATED);
+			break;
+		case Opt_nodelaylog:
+			xfs_warn(mp, MNTOPT_NODELAYLOG MNTOPT_DEPRECATED);
+			break;
+		case Opt_ihashsize:
+			xfs_warn(mp, MNTOPT_IHASHSIZE MNTOPT_DEPRECATED);
+		case Opt_osyncisdsync:
+			xfs_warn(mp, MNTOPT_OSYNCISDSYNC MNTOPT_DEPRECATED);
+			break;
+		case Opt_osyncisosync:
+			xfs_warn(mp, MNTOPT_OSYNCISOSYNC MNTOPT_DEPRECATED);
+			break;
+		case Opt_irixsgid:
+			xfs_warn(mp, MNTOPT_IRIXSGID MNTOPT_DEPRECATED);
+			break;
+		default:
+			xfs_warn(mp, "unknown mount option [%s].", p);
+			break;
 		}
 	}
 
+	kfree(orig);
+
 	/*
 	 * no recovery flag requires a read-only mount
 	 */
@@ -468,6 +569,10 @@ done:
 	}
 
 	return 0;
+
+free_orig:
+	kfree(orig);
+	return ret;
 }
 
 struct proc_xfs_info {
@@ -476,10 +581,12 @@ struct proc_xfs_info {
 };
 
 STATIC int
-xfs_showargs(
-	struct xfs_mount	*mp,
-	struct seq_file		*m)
+xfs_fs_show_options(
+	struct seq_file		*seq,
+	struct dentry		*dentry)
 {
+	struct xfs_mount	*mp = XFS_M(dentry->d_sb);
+
 	static struct proc_xfs_info xfs_info_set[] = {
 		/* the few simple ones we can get from the mount struct */
 		{ XFS_MOUNT_IKEEP,		"," MNTOPT_IKEEP },
@@ -505,58 +612,60 @@ xfs_showargs(
 
 	for (xfs_infop = xfs_info_set; xfs_infop->flag; xfs_infop++) {
 		if (mp->m_flags & xfs_infop->flag)
-			seq_puts(m, xfs_infop->str);
+			seq_puts(seq, xfs_infop->str);
 	}
 	for (xfs_infop = xfs_info_unset; xfs_infop->flag; xfs_infop++) {
 		if (!(mp->m_flags & xfs_infop->flag))
-			seq_puts(m, xfs_infop->str);
+			seq_puts(seq, xfs_infop->str);
 	}
 
 	if (mp->m_flags & XFS_MOUNT_DFLT_IOSIZE)
-		seq_printf(m, "," MNTOPT_ALLOCSIZE "=%dk",
+		seq_printf(seq, "," MNTOPT_ALLOCSIZE "=%dk",
 				(int)(1 << mp->m_writeio_log) >> 10);
 
 	if (mp->m_logbufs > 0)
-		seq_printf(m, "," MNTOPT_LOGBUFS "=%d", mp->m_logbufs);
+		seq_printf(seq, "," MNTOPT_LOGBUFS "=%d", mp->m_logbufs);
 	if (mp->m_logbsize > 0)
-		seq_printf(m, "," MNTOPT_LOGBSIZE "=%dk", mp->m_logbsize >> 10);
+		seq_printf(seq, "," MNTOPT_LOGBSIZE "=%dk",
+				mp->m_logbsize >> 10);
 
 	if (mp->m_logname)
-		seq_printf(m, "," MNTOPT_LOGDEV "=%s", mp->m_logname);
+		seq_printf(seq, "," MNTOPT_LOGDEV "=%s", mp->m_logname);
 	if (mp->m_rtname)
-		seq_printf(m, "," MNTOPT_RTDEV "=%s", mp->m_rtname);
+		seq_printf(seq, "," MNTOPT_RTDEV "=%s", mp->m_rtname);
 
 	if (mp->m_dalign > 0)
-		seq_printf(m, "," MNTOPT_SUNIT "=%d",
+		seq_printf(seq, "," MNTOPT_SUNIT "=%d",
 				(int)XFS_FSB_TO_BB(mp, mp->m_dalign));
 	if (mp->m_swidth > 0)
-		seq_printf(m, "," MNTOPT_SWIDTH "=%d",
+		seq_printf(seq, "," MNTOPT_SWIDTH "=%d",
 				(int)XFS_FSB_TO_BB(mp, mp->m_swidth));
 
 	if (mp->m_qflags & (XFS_UQUOTA_ACCT|XFS_UQUOTA_ENFD))
-		seq_puts(m, "," MNTOPT_USRQUOTA);
+		seq_puts(seq, "," MNTOPT_USRQUOTA);
 	else if (mp->m_qflags & XFS_UQUOTA_ACCT)
-		seq_puts(m, "," MNTOPT_UQUOTANOENF);
+		seq_puts(seq, "," MNTOPT_UQUOTANOENF);
 
 	/* Either project or group quotas can be active, not both */
 
 	if (mp->m_qflags & XFS_PQUOTA_ACCT) {
 		if (mp->m_qflags & XFS_OQUOTA_ENFD)
-			seq_puts(m, "," MNTOPT_PRJQUOTA);
+			seq_puts(seq, "," MNTOPT_PRJQUOTA);
 		else
-			seq_puts(m, "," MNTOPT_PQUOTANOENF);
+			seq_puts(seq, "," MNTOPT_PQUOTANOENF);
 	} else if (mp->m_qflags & XFS_GQUOTA_ACCT) {
 		if (mp->m_qflags & XFS_OQUOTA_ENFD)
-			seq_puts(m, "," MNTOPT_GRPQUOTA);
+			seq_puts(seq, "," MNTOPT_GRPQUOTA);
 		else
-			seq_puts(m, "," MNTOPT_GQUOTANOENF);
+			seq_puts(seq, "," MNTOPT_GQUOTANOENF);
 	}
 
 	if (!(mp->m_qflags & XFS_ALL_QUOTA_ACCT))
-		seq_puts(m, "," MNTOPT_NOQUOTA);
+		seq_puts(seq, "," MNTOPT_NOQUOTA);
 
 	return 0;
 }
+
 __uint64_t
 xfs_max_file_offset(
 	unsigned int		blockshift)
@@ -1221,14 +1330,6 @@ xfs_fs_unfreeze(
 	return 0;
 }
 
-STATIC int
-xfs_fs_show_options(
-	struct seq_file		*m,
-	struct dentry		*root)
-{
-	return -xfs_showargs(XFS_M(root->d_sb), m);
-}
-
 /*
  * This function fills in xfs_mount_t fields based on mount args.
  * Note: the superblock _has_ now been read in.
-- 
1.7.11.1.165.g299666c

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

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

* Re: [PATCH V5] xfs: cleanup the mount options
  2012-07-11  6:29                 ` [PATCH V5] " Wanlong Gao
@ 2012-07-16  8:06                   ` Wanlong Gao
  2012-07-23 20:33                     ` Ben Myers
  2012-07-23 23:28                   ` Dave Chinner
  1 sibling, 1 reply; 31+ messages in thread
From: Wanlong Gao @ 2012-07-16  8:06 UTC (permalink / raw)
  To: xfs; +Cc: Christoph Hellwig, Ben Myers, Zach Brown, Wanlong Gao

On 07/11/2012 02:29 PM, Wanlong Gao wrote:
> remove the mount options macro, use tokens instead.
> 
> change from V4: (as Dave suggested)
> 1. suffix_match_int avoid overflow.
> 2. convert the return style to be consistent with others.
> 3. move the "intarg" init above the switch.
> 4. move match_strdup to a help function.
> 5. collapsed Opt_biosize and Opt_allocsize.
> 6. make a consistent deprecated message.
> 

Any more comments?

Thanks,
Wanlong Gao

> CC: Ben Myers <bpm@sgi.com>
> CC: Christoph Hellwig <hch@infradead.org>
> CC: Dave Chinner <david@fromorbit.com>
> CC: Zach Brown <zab@zabbo.net>
> Signed-off-by: Wanlong Gao <gaowanlong@cn.fujitsu.com>
> ---
>  fs/xfs/xfs_super.c | 551 +++++++++++++++++++++++++++++++----------------------
>  1 file changed, 326 insertions(+), 225 deletions(-)
> 
> diff --git a/fs/xfs/xfs_super.c b/fs/xfs/xfs_super.c
> index 07f70e1..3b62354 100644
> --- a/fs/xfs/xfs_super.c
> +++ b/fs/xfs/xfs_super.c
> @@ -66,91 +66,171 @@ static const struct super_operations xfs_super_operations;
>  static kmem_zone_t *xfs_ioend_zone;
>  mempool_t *xfs_ioend_pool;
>  
> -#define MNTOPT_LOGBUFS	"logbufs"	/* number of XFS log buffers */
> -#define MNTOPT_LOGBSIZE	"logbsize"	/* size of XFS log buffers */
> -#define MNTOPT_LOGDEV	"logdev"	/* log device */
> -#define MNTOPT_RTDEV	"rtdev"		/* realtime I/O device */
> -#define MNTOPT_BIOSIZE	"biosize"	/* log2 of preferred buffered io size */
> -#define MNTOPT_WSYNC	"wsync"		/* safe-mode nfs compatible mount */
> -#define MNTOPT_NOALIGN	"noalign"	/* turn off stripe alignment */
> -#define MNTOPT_SWALLOC	"swalloc"	/* turn on stripe width allocation */
> -#define MNTOPT_SUNIT	"sunit"		/* data volume stripe unit */
> -#define MNTOPT_SWIDTH	"swidth"	/* data volume stripe width */
> -#define MNTOPT_NOUUID	"nouuid"	/* ignore filesystem UUID */
> -#define MNTOPT_MTPT	"mtpt"		/* filesystem mount point */
> -#define MNTOPT_GRPID	"grpid"		/* group-ID from parent directory */
> -#define MNTOPT_NOGRPID	"nogrpid"	/* group-ID from current process */
> -#define MNTOPT_BSDGROUPS    "bsdgroups"    /* group-ID from parent directory */
> -#define MNTOPT_SYSVGROUPS   "sysvgroups"   /* group-ID from current process */
> -#define MNTOPT_ALLOCSIZE    "allocsize"    /* preferred allocation size */
> -#define MNTOPT_NORECOVERY   "norecovery"   /* don't run XFS recovery */
> -#define MNTOPT_BARRIER	"barrier"	/* use writer barriers for log write and
> -					 * unwritten extent conversion */
> -#define MNTOPT_NOBARRIER "nobarrier"	/* .. disable */
> -#define MNTOPT_64BITINODE   "inode64"	/* inodes can be allocated anywhere */
> -#define MNTOPT_IKEEP	"ikeep"		/* do not free empty inode clusters */
> -#define MNTOPT_NOIKEEP	"noikeep"	/* free empty inode clusters */
> -#define MNTOPT_LARGEIO	   "largeio"	/* report large I/O sizes in stat() */
> -#define MNTOPT_NOLARGEIO   "nolargeio"	/* do not report large I/O sizes
> -					 * in stat(). */
> -#define MNTOPT_ATTR2	"attr2"		/* do use attr2 attribute format */
> -#define MNTOPT_NOATTR2	"noattr2"	/* do not use attr2 attribute format */
> -#define MNTOPT_FILESTREAM  "filestreams" /* use filestreams allocator */
> -#define MNTOPT_QUOTA	"quota"		/* disk quotas (user) */
> -#define MNTOPT_NOQUOTA	"noquota"	/* no quotas */
> -#define MNTOPT_USRQUOTA	"usrquota"	/* user quota enabled */
> -#define MNTOPT_GRPQUOTA	"grpquota"	/* group quota enabled */
> -#define MNTOPT_PRJQUOTA	"prjquota"	/* project quota enabled */
> -#define MNTOPT_UQUOTA	"uquota"	/* user quota (IRIX variant) */
> -#define MNTOPT_GQUOTA	"gquota"	/* group quota (IRIX variant) */
> -#define MNTOPT_PQUOTA	"pquota"	/* project quota (IRIX variant) */
> -#define MNTOPT_UQUOTANOENF "uqnoenforce"/* user quota limit enforcement */
> -#define MNTOPT_GQUOTANOENF "gqnoenforce"/* group quota limit enforcement */
> -#define MNTOPT_PQUOTANOENF "pqnoenforce"/* project quota limit enforcement */
> -#define MNTOPT_QUOTANOENF  "qnoenforce"	/* same as uqnoenforce */
> -#define MNTOPT_DELAYLOG    "delaylog"	/* Delayed logging enabled */
> -#define MNTOPT_NODELAYLOG  "nodelaylog"	/* Delayed logging disabled */
> -#define MNTOPT_DISCARD	   "discard"	/* Discard unused blocks */
> -#define MNTOPT_NODISCARD   "nodiscard"	/* Do not discard unused blocks */
> +#define	MNTOPT_LOGBUFS		"logbufs"
> +#define	MNTOPT_LOGBSIZE		"logbsize"
> +#define	MNTOPT_LOGDEV		"logdev"
> +#define	MNTOPT_RTDEV		"rtdev"
> +#define	MNTOPT_BIOSIZE		"biosize"
> +#define	MNTOPT_WSYNC		"wsync"
> +#define	MNTOPT_NOALIGN		"noalign"
> +#define	MNTOPT_SWALLOC		"swalloc"
> +#define	MNTOPT_SUNIT		"sunit"
> +#define	MNTOPT_SWIDTH		"swidth"
> +#define	MNTOPT_NOUUID		"nouuid"
> +#define	MNTOPT_MTPT		"mtpt"
> +#define	MNTOPT_GRPID		"grpid"
> +#define	MNTOPT_NOGRPID		"nogrpid"
> +#define	MNTOPT_BSDGROUPS	"bsdgroups"
> +#define	MNTOPT_SYSVGROUPS	"sysvgroups"
> +#define	MNTOPT_ALLOCSIZE	"allocsize"
> +#define	MNTOPT_NORECOVERY	"norecovery"
> +#define	MNTOPT_BARRIER		"barrier"
> +#define	MNTOPT_NOBARRIER	"nobarrier"
> +#define	MNTOPT_64BITINODE	"inode64"
> +#define	MNTOPT_IKEEP		"ikeep"
> +#define	MNTOPT_NOIKEEP		"noikeep"
> +#define	MNTOPT_LARGEIO		"largeio"
> +#define	MNTOPT_NOLARGEIO	"nolargeio"
> +#define	MNTOPT_ATTR2		"attr2"
> +#define	MNTOPT_NOATTR2		"noattr2"
> +#define	MNTOPT_FILESTREAM	"filestreams"
> +#define	MNTOPT_QUOTA		"quota"
> +#define	MNTOPT_NOQUOTA		"noquota"
> +#define	MNTOPT_USRQUOTA		"usrquota"
> +#define	MNTOPT_GRPQUOTA		"grpquota"
> +#define	MNTOPT_PRJQUOTA		"prjquota"
> +#define	MNTOPT_UQUOTA		"uquota"
> +#define	MNTOPT_GQUOTA		"gquota"
> +#define	MNTOPT_PQUOTA		"pquota"
> +#define	MNTOPT_UQUOTANOENF	"uqnoenforce"
> +#define	MNTOPT_GQUOTANOENF	"gqnoenforce"
> +#define	MNTOPT_PQUOTANOENF	"pqnoenforce"
> +#define	MNTOPT_QUOTANOENF	"qnoenforce"
> +#define	MNTOPT_DISCARD		"discard"
> +#define	MNTOPT_NODISCARD	"nodiscard"
> +#define	MNTOPT_DELAYLOG		"delaylog"
> +#define	MNTOPT_NODELAYLOG	"nodelaylog"
> +#define	MNTOPT_IHASHSIZE	"ihashsize"
> +#define	MNTOPT_OSYNCISDSYNC	"osyncisdsync"
> +#define	MNTOPT_OSYNCISOSYNC	"osyncisosync"
> +#define	MNTOPT_IRIXSGID		"irixsgid"
> +
> +#define MNTOPT_DEPRECATED "has no effect, option is deprecated"
>  
> -/*
> - * Table driven mount option parser.
> - *
> - * Currently only used for remount, but it will be used for mount
> - * in the future, too.
> - */
>  enum {
> -	Opt_barrier, Opt_nobarrier, Opt_err
> +	Opt_logbufs, Opt_logbsize, Opt_logdev, Opt_rtdev, Opt_biosize,
> +	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_inode64, Opt_ikeep, Opt_noikeep, Opt_largeio,
> +	Opt_nolargeio, Opt_attr2, Opt_noattr2, Opt_filestreams, Opt_quota,
> +	Opt_noquota, Opt_usrquota, Opt_grpquota, Opt_prjquota, Opt_uquota,
> +	Opt_gquota, Opt_pquota, Opt_uqnoenf, Opt_gqnoenf, Opt_pqnoenf,
> +	Opt_qnoenf, Opt_discard, Opt_nodiscard, Opt_delaylog, Opt_nodelaylog,
> +	Opt_ihashsize, Opt_osyncisdsync, Opt_osyncisosync, Opt_irixsgid,
> +	Opt_err
>  };
>  
>  static const match_table_t tokens = {
> -	{Opt_barrier, "barrier"},
> -	{Opt_nobarrier, "nobarrier"},
> +	{Opt_logbufs, MNTOPT_LOGBUFS "=%d"},	/* number of XFS log buffers */
> +	{Opt_logbsize, MNTOPT_LOGBSIZE "=%s"},	/* size of XFS log buffers */
> +	{Opt_logdev, MNTOPT_LOGDEV "=%s"},	/* log device */
> +	{Opt_rtdev, MNTOPT_RTDEV "=%s"},	/* realtime I/O device */
> +	{Opt_biosize, MNTOPT_BIOSIZE "=%d"},	/* log2 of preferred buffered io size */
> +	{Opt_wsync, MNTOPT_WSYNC},		/* safe-mode nfs compatible mount */
> +	{Opt_noalign, MNTOPT_NOALIGN},		/* turn off stripe alignment */
> +	{Opt_swalloc, MNTOPT_SWALLOC},		/* turn on stripe width allocation */
> +	{Opt_sunit, MNTOPT_SUNIT "=%d"},	/* data volume stripe unit */
> +	{Opt_swidth, MNTOPT_SWIDTH "=%d"},	/* data volume stripe width */
> +	{Opt_nouuid, MNTOPT_NOUUID},		/* ignore filesystem UUID */
> +	{Opt_mtpt, MNTOPT_MTPT},		/* filesystem mount point */
> +	{Opt_grpid, MNTOPT_GRPID},		/* group-ID from parent directory */
> +	{Opt_nogrpid, MNTOPT_NOGRPID},		/* group-ID from current process */
> +	{Opt_bsdgroups, MNTOPT_BSDGROUPS},	/* group-ID from parent directory */
> +	{Opt_sysvgroups, MNTOPT_SYSVGROUPS},	/* group-ID from current process */
> +	{Opt_allocsize, MNTOPT_ALLOCSIZE "=%s"},/* preferred allocation size */
> +	{Opt_norecovery, MNTOPT_NORECOVERY},	/* do not run XFS recovery */
> +	{Opt_barrier, MNTOPT_BARRIER},		/* use writer barrier for log write and
> +						 * unwritten extent conversation */
> +	{Opt_nobarrier, MNTOPT_NOBARRIER},	/* .. disable */
> +	{Opt_inode64, MNTOPT_64BITINODE},	/* inodes can be allocated anywhere */
> +	{Opt_ikeep, MNTOPT_IKEEP},		/* do not free empty inode clusters */
> +	{Opt_noikeep, MNTOPT_NOIKEEP},		/* free empty inode clusters */
> +	{Opt_largeio, MNTOPT_LARGEIO},		/* report large I/O sizes in start() */
> +	{Opt_nolargeio, MNTOPT_NOLARGEIO},	/* do not report large I/O sizes
> +						 * in start() */
> +	{Opt_attr2, MNTOPT_ATTR2},		/* do use attr2 attribute format */
> +	{Opt_noattr2, MNTOPT_NOATTR2},		/* do not use attr2 attribute format */
> +	{Opt_filestreams, MNTOPT_FILESTREAM}, 	/* use filestreams allocator */
> +	{Opt_quota, MNTOPT_QUOTA},		/* disk quotas (user) */
> +	{Opt_noquota, MNTOPT_NOQUOTA},		/* no quotas */
> +	{Opt_usrquota, MNTOPT_USRQUOTA},	/* user quota enabled */
> +	{Opt_grpquota, MNTOPT_GRPQUOTA},	/* group quota enabled */
> +	{Opt_prjquota, MNTOPT_PRJQUOTA},	/* project quota enabled */
> +	{Opt_uquota, MNTOPT_UQUOTA},		/* user quota (IRIX variant) */
> +	{Opt_gquota, MNTOPT_GQUOTA},		/* group quota (IRIX variant) */
> +	{Opt_pquota, MNTOPT_PQUOTA},		/* project quota (IRIX variant) */
> +	{Opt_uqnoenf, MNTOPT_UQUOTANOENF},	/* user quota limit enforcement */
> +	{Opt_gqnoenf, MNTOPT_GQUOTANOENF},	/* group quota limit enforcement */
> +	{Opt_pqnoenf, MNTOPT_PQUOTANOENF},	/* project quota limit enforcement */
> +	{Opt_qnoenf, MNTOPT_QUOTANOENF},	/* same as uqnoenforce */
> +	{Opt_discard, MNTOPT_DISCARD},		/* Discard unused blocks */
> +	{Opt_nodiscard, MNTOPT_NODISCARD},	/* Do not discard unused blocks */
> +	{Opt_delaylog, MNTOPT_DELAYLOG},	/* deprecated */
> +	{Opt_nodelaylog, MNTOPT_NODELAYLOG},	/* deprecated */
> +	{Opt_ihashsize, MNTOPT_IHASHSIZE},	/* deprecated */
> +	{Opt_osyncisdsync, MNTOPT_OSYNCISDSYNC},/* deprecated */
> +	{Opt_osyncisosync, MNTOPT_OSYNCISOSYNC},/* deprecated */
> +	{Opt_irixsgid, MNTOPT_IRIXSGID},	/* deprecated */
>  	{Opt_err, NULL}
>  };
>  
> -
> -STATIC unsigned long
> -suffix_strtoul(char *s, char **endp, unsigned int base)
> +STATIC int
> +suffix_match_int(substring_t *s, unsigned long *result)
>  {
> -	int	last, shift_left_factor = 0;
> -	char	*value = s;
> +	int shift_left_factor = 0;
> +	char *value = s->to - 1;
> +	char *string;
>  
> -	last = strlen(value) - 1;
> -	if (value[last] == 'K' || value[last] == 'k') {
> +	if (*value == 'K' || *value == 'k') {
>  		shift_left_factor = 10;
> -		value[last] = '\0';
> +		s->to--;
>  	}
> -	if (value[last] == 'M' || value[last] == 'm') {
> +	if (*value == 'M' || *value == 'm') {
>  		shift_left_factor = 20;
> -		value[last] = '\0';
> +		s->to--;
>  	}
> -	if (value[last] == 'G' || value[last] == 'g') {
> +	if (*value == 'G' || *value == 'g') {
>  		shift_left_factor = 30;
> -		value[last] = '\0';
> +		s->to--;
>  	}
>  
> -	return simple_strtoul((const char *)s, endp, base) << shift_left_factor;
> +	string = match_strdup(s);
> +	if (!string)
> +		return ENOMEM;
> +
> +	*result = simple_strtoul((const char *)string, NULL, 0) <<
> +			shift_left_factor;
> +
> +	kfree(string);
> +	return 0;
> +}
> +
> +STATIC int
> +match_name_strdup(substring_t *s, char *name)
> +{
> +	char *string;
> +	string = match_strdup(s);
> +	if (!string)
> +		return ENOMEM;
> +
> +	name = kstrndup(string, MAXNAMELEN, GFP_KERNEL);
> +	if (!name)
> +		goto free;
> +	return 0;
> +free:
> +	kfree(string);
> +	return ENOMEM;
>  }
>  
>  /*
> @@ -166,11 +246,15 @@ xfs_parseargs(
>  	char			*options)
>  {
>  	struct super_block	*sb = mp->m_super;
> -	char			*this_char, *value, *eov;
> +	char			*p;
>  	int			dsunit = 0;
>  	int			dswidth = 0;
> -	int			iosize = 0;
>  	__uint8_t		iosizelog = 0;
> +	int			intarg;
> +	unsigned long		ularg;
> +	substring_t		args[MAX_OPT_ARGS];
> +	char			*orig = NULL;
> +	int			ret = 0;
>  
>  	/*
>  	 * set up the mount name first so all the errors will refer to the
> @@ -208,175 +292,192 @@ xfs_parseargs(
>  	if (!options)
>  		goto done;
>  
> -	while ((this_char = strsep(&options, ",")) != NULL) {
> -		if (!*this_char)
> +	options = kstrdup(options, GFP_NOFS);
> +	if (!options) {
> +		ret = ENOMEM;
> +		goto done;
> +	}
> +
> +	orig = options;
> +
> +	while ((p = strsep(&orig, ",")) != NULL) {
> +		int token;
> +		if (!*p)
>  			continue;
> -		if ((value = strchr(this_char, '=')) != NULL)
> -			*value++ = 0;
> -
> -		if (!strcmp(this_char, MNTOPT_LOGBUFS)) {
> -			if (!value || !*value) {
> -				xfs_warn(mp, "%s option requires an argument",
> -					this_char);
> -				return EINVAL;
> -			}
> -			mp->m_logbufs = simple_strtoul(value, &eov, 10);
> -		} else if (!strcmp(this_char, MNTOPT_LOGBSIZE)) {
> -			if (!value || !*value) {
> -				xfs_warn(mp, "%s option requires an argument",
> -					this_char);
> -				return EINVAL;
> -			}
> -			mp->m_logbsize = suffix_strtoul(value, &eov, 10);
> -		} else if (!strcmp(this_char, MNTOPT_LOGDEV)) {
> -			if (!value || !*value) {
> -				xfs_warn(mp, "%s option requires an argument",
> -					this_char);
> -				return EINVAL;
> -			}
> -			mp->m_logname = kstrndup(value, MAXNAMELEN, GFP_KERNEL);
> -			if (!mp->m_logname)
> -				return ENOMEM;
> -		} else if (!strcmp(this_char, MNTOPT_MTPT)) {
> -			xfs_warn(mp, "%s option not allowed on this system",
> -				this_char);
> -			return EINVAL;
> -		} else if (!strcmp(this_char, MNTOPT_RTDEV)) {
> -			if (!value || !*value) {
> -				xfs_warn(mp, "%s option requires an argument",
> -					this_char);
> -				return EINVAL;
> -			}
> -			mp->m_rtname = kstrndup(value, MAXNAMELEN, GFP_KERNEL);
> -			if (!mp->m_rtname)
> -				return ENOMEM;
> -		} else if (!strcmp(this_char, MNTOPT_BIOSIZE)) {
> -			if (!value || !*value) {
> -				xfs_warn(mp, "%s option requires an argument",
> -					this_char);
> -				return EINVAL;
> -			}
> -			iosize = simple_strtoul(value, &eov, 10);
> -			iosizelog = ffs(iosize) - 1;
> -		} else if (!strcmp(this_char, MNTOPT_ALLOCSIZE)) {
> -			if (!value || !*value) {
> -				xfs_warn(mp, "%s option requires an argument",
> -					this_char);
> -				return EINVAL;
> -			}
> -			iosize = suffix_strtoul(value, &eov, 10);
> -			iosizelog = ffs(iosize) - 1;
> -		} else if (!strcmp(this_char, MNTOPT_GRPID) ||
> -			   !strcmp(this_char, MNTOPT_BSDGROUPS)) {
> +
> +		token = match_token(p, tokens, args);
> +		intarg = 0;
> +		ularg = 0;
> +		switch (token) {
> +		case Opt_logbufs:
> +			ret = match_int(args, &intarg);
> +			if (ret)
> +				goto free_orig;
> +			mp->m_logbufs = intarg;
> +			break;
> +		case Opt_logbsize:
> +			ret = suffix_match_int(args, &ularg);
> +			if (ret)
> +				goto free_orig;
> +			mp->m_logbsize = ularg;
> +			break;
> +		case Opt_logdev:
> +			ret = match_name_strdup(args, mp->m_logname);
> +			if (ret)
> +				goto free_orig;
> +			break;
> +		case Opt_mtpt:
> +			xfs_warn(mp, "%s option not allowed on this system", p);
> +			ret = EINVAL;
> +			goto free_orig;
> +		case Opt_rtdev:
> +			ret = match_name_strdup(args, mp->m_rtname);
> +			if (ret)
> +				goto free_orig;
> +			break;
> +		case Opt_biosize:
> +		case Opt_allocsize:
> +			ret = suffix_match_int(args, &ularg);
> +			if (ret)
> +				goto free_orig;
> +			iosizelog = ffs(ularg) - 1;
> +			break;
> +		case Opt_grpid:
> +		case Opt_bsdgroups:
>  			mp->m_flags |= XFS_MOUNT_GRPID;
> -		} else if (!strcmp(this_char, MNTOPT_NOGRPID) ||
> -			   !strcmp(this_char, MNTOPT_SYSVGROUPS)) {
> +			break;
> +		case Opt_nogrpid:
> +		case Opt_sysvgroups:
>  			mp->m_flags &= ~XFS_MOUNT_GRPID;
> -		} else if (!strcmp(this_char, MNTOPT_WSYNC)) {
> +			break;
> +		case Opt_wsync:
>  			mp->m_flags |= XFS_MOUNT_WSYNC;
> -		} else if (!strcmp(this_char, MNTOPT_NORECOVERY)) {
> +			break;
> +		case Opt_norecovery:
>  			mp->m_flags |= XFS_MOUNT_NORECOVERY;
> -		} else if (!strcmp(this_char, MNTOPT_NOALIGN)) {
> +			break;
> +		case Opt_noalign:
>  			mp->m_flags |= XFS_MOUNT_NOALIGN;
> -		} else if (!strcmp(this_char, MNTOPT_SWALLOC)) {
> +			break;
> +		case Opt_swalloc:
>  			mp->m_flags |= XFS_MOUNT_SWALLOC;
> -		} else if (!strcmp(this_char, MNTOPT_SUNIT)) {
> -			if (!value || !*value) {
> -				xfs_warn(mp, "%s option requires an argument",
> -					this_char);
> -				return EINVAL;
> -			}
> -			dsunit = simple_strtoul(value, &eov, 10);
> -		} else if (!strcmp(this_char, MNTOPT_SWIDTH)) {
> -			if (!value || !*value) {
> -				xfs_warn(mp, "%s option requires an argument",
> -					this_char);
> -				return EINVAL;
> -			}
> -			dswidth = simple_strtoul(value, &eov, 10);
> -		} else if (!strcmp(this_char, MNTOPT_64BITINODE)) {
> +			break;
> +		case Opt_sunit:
> +			ret = match_int(args, &intarg);
> +			if (ret)
> +				goto free_orig;
> +			dsunit = intarg;
> +			break;
> +		case Opt_swidth:
> +			ret = match_int(args, &intarg);
> +			if (ret)
> +				goto free_orig;
> +			dswidth = intarg;
> +			break;
> +		case Opt_inode64:
>  			mp->m_flags &= ~XFS_MOUNT_SMALL_INUMS;
>  #if !XFS_BIG_INUMS
> -			xfs_warn(mp, "%s option not allowed on this system",
> -				this_char);
> -			return EINVAL;
> +			xfs_warn(mp, "%s options not allowed on this system", p);
> +			ret = EINVAL;
> +			goto free_orig;
>  #endif
> -		} else if (!strcmp(this_char, MNTOPT_NOUUID)) {
> +			break;
> +		case Opt_nouuid:
>  			mp->m_flags |= XFS_MOUNT_NOUUID;
> -		} else if (!strcmp(this_char, MNTOPT_BARRIER)) {
> +			break;
> +		case Opt_barrier:
>  			mp->m_flags |= XFS_MOUNT_BARRIER;
> -		} else if (!strcmp(this_char, MNTOPT_NOBARRIER)) {
> +			break;
> +		case Opt_nobarrier:
>  			mp->m_flags &= ~XFS_MOUNT_BARRIER;
> -		} else if (!strcmp(this_char, MNTOPT_IKEEP)) {
> +			break;
> +		case Opt_ikeep:
>  			mp->m_flags |= XFS_MOUNT_IKEEP;
> -		} else if (!strcmp(this_char, MNTOPT_NOIKEEP)) {
> +			break;
> +		case Opt_noikeep:
>  			mp->m_flags &= ~XFS_MOUNT_IKEEP;
> -		} else if (!strcmp(this_char, MNTOPT_LARGEIO)) {
> +			break;
> +		case Opt_largeio:
>  			mp->m_flags &= ~XFS_MOUNT_COMPAT_IOSIZE;
> -		} else if (!strcmp(this_char, MNTOPT_NOLARGEIO)) {
> +			break;
> +		case Opt_nolargeio:
>  			mp->m_flags |= XFS_MOUNT_COMPAT_IOSIZE;
> -		} else if (!strcmp(this_char, MNTOPT_ATTR2)) {
> +			break;
> +		case Opt_attr2:
>  			mp->m_flags |= XFS_MOUNT_ATTR2;
> -		} else if (!strcmp(this_char, MNTOPT_NOATTR2)) {
> +			break;
> +		case Opt_noattr2:
>  			mp->m_flags &= ~XFS_MOUNT_ATTR2;
>  			mp->m_flags |= XFS_MOUNT_NOATTR2;
> -		} else if (!strcmp(this_char, MNTOPT_FILESTREAM)) {
> +			break;
> +		case Opt_filestreams:
>  			mp->m_flags |= XFS_MOUNT_FILESTREAMS;
> -		} else if (!strcmp(this_char, MNTOPT_NOQUOTA)) {
> +			break;
> +		case Opt_noquota:
>  			mp->m_qflags &= ~XFS_ALL_QUOTA_ACCT;
>  			mp->m_qflags &= ~XFS_ALL_QUOTA_ENFD;
>  			mp->m_qflags &= ~XFS_ALL_QUOTA_ACTIVE;
> -		} else if (!strcmp(this_char, MNTOPT_QUOTA) ||
> -			   !strcmp(this_char, MNTOPT_UQUOTA) ||
> -			   !strcmp(this_char, MNTOPT_USRQUOTA)) {
> +			break;
> +		case Opt_quota:
> +		case Opt_uquota:
> +		case Opt_usrquota:
>  			mp->m_qflags |= (XFS_UQUOTA_ACCT | XFS_UQUOTA_ACTIVE |
>  					 XFS_UQUOTA_ENFD);
> -		} else if (!strcmp(this_char, MNTOPT_QUOTANOENF) ||
> -			   !strcmp(this_char, MNTOPT_UQUOTANOENF)) {
> +			break;
> +		case Opt_qnoenf:
> +		case Opt_uqnoenf:
>  			mp->m_qflags |= (XFS_UQUOTA_ACCT | XFS_UQUOTA_ACTIVE);
>  			mp->m_qflags &= ~XFS_UQUOTA_ENFD;
> -		} else if (!strcmp(this_char, MNTOPT_PQUOTA) ||
> -			   !strcmp(this_char, MNTOPT_PRJQUOTA)) {
> +			break;
> +		case Opt_pquota:
> +		case Opt_prjquota:
>  			mp->m_qflags |= (XFS_PQUOTA_ACCT | XFS_PQUOTA_ACTIVE |
>  					 XFS_OQUOTA_ENFD);
> -		} else if (!strcmp(this_char, MNTOPT_PQUOTANOENF)) {
> +			break;
> +		case Opt_pqnoenf:
>  			mp->m_qflags |= (XFS_PQUOTA_ACCT | XFS_PQUOTA_ACTIVE);
>  			mp->m_qflags &= ~XFS_OQUOTA_ENFD;
> -		} else if (!strcmp(this_char, MNTOPT_GQUOTA) ||
> -			   !strcmp(this_char, MNTOPT_GRPQUOTA)) {
> +			break;
> +		case Opt_gquota:
> +		case Opt_grpquota:
>  			mp->m_qflags |= (XFS_GQUOTA_ACCT | XFS_GQUOTA_ACTIVE |
>  					 XFS_OQUOTA_ENFD);
> -		} else if (!strcmp(this_char, MNTOPT_GQUOTANOENF)) {
> +			break;
> +		case Opt_gqnoenf:
>  			mp->m_qflags |= (XFS_GQUOTA_ACCT | XFS_GQUOTA_ACTIVE);
>  			mp->m_qflags &= ~XFS_OQUOTA_ENFD;
> -		} else if (!strcmp(this_char, MNTOPT_DELAYLOG)) {
> -			xfs_warn(mp,
> -	"delaylog is the default now, option is deprecated.");
> -		} else if (!strcmp(this_char, MNTOPT_NODELAYLOG)) {
> -			xfs_warn(mp,
> -	"nodelaylog support has been removed, option is deprecated.");
> -		} else if (!strcmp(this_char, MNTOPT_DISCARD)) {
> +			break;
> +		case Opt_discard:
>  			mp->m_flags |= XFS_MOUNT_DISCARD;
> -		} else if (!strcmp(this_char, MNTOPT_NODISCARD)) {
> +			break;
> +		case Opt_nodiscard:
>  			mp->m_flags &= ~XFS_MOUNT_DISCARD;
> -		} else if (!strcmp(this_char, "ihashsize")) {
> -			xfs_warn(mp,
> -	"ihashsize no longer used, option is deprecated.");
> -		} else if (!strcmp(this_char, "osyncisdsync")) {
> -			xfs_warn(mp,
> -	"osyncisdsync has no effect, option is deprecated.");
> -		} else if (!strcmp(this_char, "osyncisosync")) {
> -			xfs_warn(mp,
> -	"osyncisosync has no effect, option is deprecated.");
> -		} else if (!strcmp(this_char, "irixsgid")) {
> -			xfs_warn(mp,
> -	"irixsgid is now a sysctl(2) variable, option is deprecated.");
> -		} else {
> -			xfs_warn(mp, "unknown mount option [%s].", this_char);
> -			return EINVAL;
> +			break;
> +		case Opt_delaylog:
> +			xfs_warn(mp, MNTOPT_DELAYLOG MNTOPT_DEPRECATED);
> +			break;
> +		case Opt_nodelaylog:
> +			xfs_warn(mp, MNTOPT_NODELAYLOG MNTOPT_DEPRECATED);
> +			break;
> +		case Opt_ihashsize:
> +			xfs_warn(mp, MNTOPT_IHASHSIZE MNTOPT_DEPRECATED);
> +		case Opt_osyncisdsync:
> +			xfs_warn(mp, MNTOPT_OSYNCISDSYNC MNTOPT_DEPRECATED);
> +			break;
> +		case Opt_osyncisosync:
> +			xfs_warn(mp, MNTOPT_OSYNCISOSYNC MNTOPT_DEPRECATED);
> +			break;
> +		case Opt_irixsgid:
> +			xfs_warn(mp, MNTOPT_IRIXSGID MNTOPT_DEPRECATED);
> +			break;
> +		default:
> +			xfs_warn(mp, "unknown mount option [%s].", p);
> +			break;
>  		}
>  	}
>  
> +	kfree(orig);
> +
>  	/*
>  	 * no recovery flag requires a read-only mount
>  	 */
> @@ -468,6 +569,10 @@ done:
>  	}
>  
>  	return 0;
> +
> +free_orig:
> +	kfree(orig);
> +	return ret;
>  }
>  
>  struct proc_xfs_info {
> @@ -476,10 +581,12 @@ struct proc_xfs_info {
>  };
>  
>  STATIC int
> -xfs_showargs(
> -	struct xfs_mount	*mp,
> -	struct seq_file		*m)
> +xfs_fs_show_options(
> +	struct seq_file		*seq,
> +	struct dentry		*dentry)
>  {
> +	struct xfs_mount	*mp = XFS_M(dentry->d_sb);
> +
>  	static struct proc_xfs_info xfs_info_set[] = {
>  		/* the few simple ones we can get from the mount struct */
>  		{ XFS_MOUNT_IKEEP,		"," MNTOPT_IKEEP },
> @@ -505,58 +612,60 @@ xfs_showargs(
>  
>  	for (xfs_infop = xfs_info_set; xfs_infop->flag; xfs_infop++) {
>  		if (mp->m_flags & xfs_infop->flag)
> -			seq_puts(m, xfs_infop->str);
> +			seq_puts(seq, xfs_infop->str);
>  	}
>  	for (xfs_infop = xfs_info_unset; xfs_infop->flag; xfs_infop++) {
>  		if (!(mp->m_flags & xfs_infop->flag))
> -			seq_puts(m, xfs_infop->str);
> +			seq_puts(seq, xfs_infop->str);
>  	}
>  
>  	if (mp->m_flags & XFS_MOUNT_DFLT_IOSIZE)
> -		seq_printf(m, "," MNTOPT_ALLOCSIZE "=%dk",
> +		seq_printf(seq, "," MNTOPT_ALLOCSIZE "=%dk",
>  				(int)(1 << mp->m_writeio_log) >> 10);
>  
>  	if (mp->m_logbufs > 0)
> -		seq_printf(m, "," MNTOPT_LOGBUFS "=%d", mp->m_logbufs);
> +		seq_printf(seq, "," MNTOPT_LOGBUFS "=%d", mp->m_logbufs);
>  	if (mp->m_logbsize > 0)
> -		seq_printf(m, "," MNTOPT_LOGBSIZE "=%dk", mp->m_logbsize >> 10);
> +		seq_printf(seq, "," MNTOPT_LOGBSIZE "=%dk",
> +				mp->m_logbsize >> 10);
>  
>  	if (mp->m_logname)
> -		seq_printf(m, "," MNTOPT_LOGDEV "=%s", mp->m_logname);
> +		seq_printf(seq, "," MNTOPT_LOGDEV "=%s", mp->m_logname);
>  	if (mp->m_rtname)
> -		seq_printf(m, "," MNTOPT_RTDEV "=%s", mp->m_rtname);
> +		seq_printf(seq, "," MNTOPT_RTDEV "=%s", mp->m_rtname);
>  
>  	if (mp->m_dalign > 0)
> -		seq_printf(m, "," MNTOPT_SUNIT "=%d",
> +		seq_printf(seq, "," MNTOPT_SUNIT "=%d",
>  				(int)XFS_FSB_TO_BB(mp, mp->m_dalign));
>  	if (mp->m_swidth > 0)
> -		seq_printf(m, "," MNTOPT_SWIDTH "=%d",
> +		seq_printf(seq, "," MNTOPT_SWIDTH "=%d",
>  				(int)XFS_FSB_TO_BB(mp, mp->m_swidth));
>  
>  	if (mp->m_qflags & (XFS_UQUOTA_ACCT|XFS_UQUOTA_ENFD))
> -		seq_puts(m, "," MNTOPT_USRQUOTA);
> +		seq_puts(seq, "," MNTOPT_USRQUOTA);
>  	else if (mp->m_qflags & XFS_UQUOTA_ACCT)
> -		seq_puts(m, "," MNTOPT_UQUOTANOENF);
> +		seq_puts(seq, "," MNTOPT_UQUOTANOENF);
>  
>  	/* Either project or group quotas can be active, not both */
>  
>  	if (mp->m_qflags & XFS_PQUOTA_ACCT) {
>  		if (mp->m_qflags & XFS_OQUOTA_ENFD)
> -			seq_puts(m, "," MNTOPT_PRJQUOTA);
> +			seq_puts(seq, "," MNTOPT_PRJQUOTA);
>  		else
> -			seq_puts(m, "," MNTOPT_PQUOTANOENF);
> +			seq_puts(seq, "," MNTOPT_PQUOTANOENF);
>  	} else if (mp->m_qflags & XFS_GQUOTA_ACCT) {
>  		if (mp->m_qflags & XFS_OQUOTA_ENFD)
> -			seq_puts(m, "," MNTOPT_GRPQUOTA);
> +			seq_puts(seq, "," MNTOPT_GRPQUOTA);
>  		else
> -			seq_puts(m, "," MNTOPT_GQUOTANOENF);
> +			seq_puts(seq, "," MNTOPT_GQUOTANOENF);
>  	}
>  
>  	if (!(mp->m_qflags & XFS_ALL_QUOTA_ACCT))
> -		seq_puts(m, "," MNTOPT_NOQUOTA);
> +		seq_puts(seq, "," MNTOPT_NOQUOTA);
>  
>  	return 0;
>  }
> +
>  __uint64_t
>  xfs_max_file_offset(
>  	unsigned int		blockshift)
> @@ -1221,14 +1330,6 @@ xfs_fs_unfreeze(
>  	return 0;
>  }
>  
> -STATIC int
> -xfs_fs_show_options(
> -	struct seq_file		*m,
> -	struct dentry		*root)
> -{
> -	return -xfs_showargs(XFS_M(root->d_sb), m);
> -}
> -
>  /*
>   * This function fills in xfs_mount_t fields based on mount args.
>   * Note: the superblock _has_ now been read in.
> 


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

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

* Re: [PATCH V5] xfs: cleanup the mount options
  2012-07-16  8:06                   ` Wanlong Gao
@ 2012-07-23 20:33                     ` Ben Myers
  0 siblings, 0 replies; 31+ messages in thread
From: Ben Myers @ 2012-07-23 20:33 UTC (permalink / raw)
  To: Wanlong Gao; +Cc: Christoph Hellwig, Zach Brown, xfs

On Mon, Jul 16, 2012 at 04:06:06PM +0800, Wanlong Gao wrote:
> On 07/11/2012 02:29 PM, Wanlong Gao wrote:
> > remove the mount options macro, use tokens instead.
> > 
> > change from V4: (as Dave suggested)
> > 1. suffix_match_int avoid overflow.
> > 2. convert the return style to be consistent with others.
> > 3. move the "intarg" init above the switch.
> > 4. move match_strdup to a help function.
> > 5. collapsed Opt_biosize and Opt_allocsize.
> > 6. make a consistent deprecated message.
> > 
> 
> Any more comments?

Wanlong,
	
Sorry for the delay.  We'll have to work on getting this reviewed and tested
for 3.7.

Regards,
	Ben


> 
> Thanks,
> Wanlong Gao
> 
> > CC: Ben Myers <bpm@sgi.com>
> > CC: Christoph Hellwig <hch@infradead.org>
> > CC: Dave Chinner <david@fromorbit.com>
> > CC: Zach Brown <zab@zabbo.net>
> > Signed-off-by: Wanlong Gao <gaowanlong@cn.fujitsu.com>
> > ---
> >  fs/xfs/xfs_super.c | 551 +++++++++++++++++++++++++++++++----------------------
> >  1 file changed, 326 insertions(+), 225 deletions(-)
> > 
> > diff --git a/fs/xfs/xfs_super.c b/fs/xfs/xfs_super.c
> > index 07f70e1..3b62354 100644
> > --- a/fs/xfs/xfs_super.c
> > +++ b/fs/xfs/xfs_super.c
> > @@ -66,91 +66,171 @@ static const struct super_operations xfs_super_operations;
> >  static kmem_zone_t *xfs_ioend_zone;
> >  mempool_t *xfs_ioend_pool;
> >  
> > -#define MNTOPT_LOGBUFS	"logbufs"	/* number of XFS log buffers */
> > -#define MNTOPT_LOGBSIZE	"logbsize"	/* size of XFS log buffers */
> > -#define MNTOPT_LOGDEV	"logdev"	/* log device */
> > -#define MNTOPT_RTDEV	"rtdev"		/* realtime I/O device */
> > -#define MNTOPT_BIOSIZE	"biosize"	/* log2 of preferred buffered io size */
> > -#define MNTOPT_WSYNC	"wsync"		/* safe-mode nfs compatible mount */
> > -#define MNTOPT_NOALIGN	"noalign"	/* turn off stripe alignment */
> > -#define MNTOPT_SWALLOC	"swalloc"	/* turn on stripe width allocation */
> > -#define MNTOPT_SUNIT	"sunit"		/* data volume stripe unit */
> > -#define MNTOPT_SWIDTH	"swidth"	/* data volume stripe width */
> > -#define MNTOPT_NOUUID	"nouuid"	/* ignore filesystem UUID */
> > -#define MNTOPT_MTPT	"mtpt"		/* filesystem mount point */
> > -#define MNTOPT_GRPID	"grpid"		/* group-ID from parent directory */
> > -#define MNTOPT_NOGRPID	"nogrpid"	/* group-ID from current process */
> > -#define MNTOPT_BSDGROUPS    "bsdgroups"    /* group-ID from parent directory */
> > -#define MNTOPT_SYSVGROUPS   "sysvgroups"   /* group-ID from current process */
> > -#define MNTOPT_ALLOCSIZE    "allocsize"    /* preferred allocation size */
> > -#define MNTOPT_NORECOVERY   "norecovery"   /* don't run XFS recovery */
> > -#define MNTOPT_BARRIER	"barrier"	/* use writer barriers for log write and
> > -					 * unwritten extent conversion */
> > -#define MNTOPT_NOBARRIER "nobarrier"	/* .. disable */
> > -#define MNTOPT_64BITINODE   "inode64"	/* inodes can be allocated anywhere */
> > -#define MNTOPT_IKEEP	"ikeep"		/* do not free empty inode clusters */
> > -#define MNTOPT_NOIKEEP	"noikeep"	/* free empty inode clusters */
> > -#define MNTOPT_LARGEIO	   "largeio"	/* report large I/O sizes in stat() */
> > -#define MNTOPT_NOLARGEIO   "nolargeio"	/* do not report large I/O sizes
> > -					 * in stat(). */
> > -#define MNTOPT_ATTR2	"attr2"		/* do use attr2 attribute format */
> > -#define MNTOPT_NOATTR2	"noattr2"	/* do not use attr2 attribute format */
> > -#define MNTOPT_FILESTREAM  "filestreams" /* use filestreams allocator */
> > -#define MNTOPT_QUOTA	"quota"		/* disk quotas (user) */
> > -#define MNTOPT_NOQUOTA	"noquota"	/* no quotas */
> > -#define MNTOPT_USRQUOTA	"usrquota"	/* user quota enabled */
> > -#define MNTOPT_GRPQUOTA	"grpquota"	/* group quota enabled */
> > -#define MNTOPT_PRJQUOTA	"prjquota"	/* project quota enabled */
> > -#define MNTOPT_UQUOTA	"uquota"	/* user quota (IRIX variant) */
> > -#define MNTOPT_GQUOTA	"gquota"	/* group quota (IRIX variant) */
> > -#define MNTOPT_PQUOTA	"pquota"	/* project quota (IRIX variant) */
> > -#define MNTOPT_UQUOTANOENF "uqnoenforce"/* user quota limit enforcement */
> > -#define MNTOPT_GQUOTANOENF "gqnoenforce"/* group quota limit enforcement */
> > -#define MNTOPT_PQUOTANOENF "pqnoenforce"/* project quota limit enforcement */
> > -#define MNTOPT_QUOTANOENF  "qnoenforce"	/* same as uqnoenforce */
> > -#define MNTOPT_DELAYLOG    "delaylog"	/* Delayed logging enabled */
> > -#define MNTOPT_NODELAYLOG  "nodelaylog"	/* Delayed logging disabled */
> > -#define MNTOPT_DISCARD	   "discard"	/* Discard unused blocks */
> > -#define MNTOPT_NODISCARD   "nodiscard"	/* Do not discard unused blocks */
> > +#define	MNTOPT_LOGBUFS		"logbufs"
> > +#define	MNTOPT_LOGBSIZE		"logbsize"
> > +#define	MNTOPT_LOGDEV		"logdev"
> > +#define	MNTOPT_RTDEV		"rtdev"
> > +#define	MNTOPT_BIOSIZE		"biosize"
> > +#define	MNTOPT_WSYNC		"wsync"
> > +#define	MNTOPT_NOALIGN		"noalign"
> > +#define	MNTOPT_SWALLOC		"swalloc"
> > +#define	MNTOPT_SUNIT		"sunit"
> > +#define	MNTOPT_SWIDTH		"swidth"
> > +#define	MNTOPT_NOUUID		"nouuid"
> > +#define	MNTOPT_MTPT		"mtpt"
> > +#define	MNTOPT_GRPID		"grpid"
> > +#define	MNTOPT_NOGRPID		"nogrpid"
> > +#define	MNTOPT_BSDGROUPS	"bsdgroups"
> > +#define	MNTOPT_SYSVGROUPS	"sysvgroups"
> > +#define	MNTOPT_ALLOCSIZE	"allocsize"
> > +#define	MNTOPT_NORECOVERY	"norecovery"
> > +#define	MNTOPT_BARRIER		"barrier"
> > +#define	MNTOPT_NOBARRIER	"nobarrier"
> > +#define	MNTOPT_64BITINODE	"inode64"
> > +#define	MNTOPT_IKEEP		"ikeep"
> > +#define	MNTOPT_NOIKEEP		"noikeep"
> > +#define	MNTOPT_LARGEIO		"largeio"
> > +#define	MNTOPT_NOLARGEIO	"nolargeio"
> > +#define	MNTOPT_ATTR2		"attr2"
> > +#define	MNTOPT_NOATTR2		"noattr2"
> > +#define	MNTOPT_FILESTREAM	"filestreams"
> > +#define	MNTOPT_QUOTA		"quota"
> > +#define	MNTOPT_NOQUOTA		"noquota"
> > +#define	MNTOPT_USRQUOTA		"usrquota"
> > +#define	MNTOPT_GRPQUOTA		"grpquota"
> > +#define	MNTOPT_PRJQUOTA		"prjquota"
> > +#define	MNTOPT_UQUOTA		"uquota"
> > +#define	MNTOPT_GQUOTA		"gquota"
> > +#define	MNTOPT_PQUOTA		"pquota"
> > +#define	MNTOPT_UQUOTANOENF	"uqnoenforce"
> > +#define	MNTOPT_GQUOTANOENF	"gqnoenforce"
> > +#define	MNTOPT_PQUOTANOENF	"pqnoenforce"
> > +#define	MNTOPT_QUOTANOENF	"qnoenforce"
> > +#define	MNTOPT_DISCARD		"discard"
> > +#define	MNTOPT_NODISCARD	"nodiscard"
> > +#define	MNTOPT_DELAYLOG		"delaylog"
> > +#define	MNTOPT_NODELAYLOG	"nodelaylog"
> > +#define	MNTOPT_IHASHSIZE	"ihashsize"
> > +#define	MNTOPT_OSYNCISDSYNC	"osyncisdsync"
> > +#define	MNTOPT_OSYNCISOSYNC	"osyncisosync"
> > +#define	MNTOPT_IRIXSGID		"irixsgid"
> > +
> > +#define MNTOPT_DEPRECATED "has no effect, option is deprecated"
> >  
> > -/*
> > - * Table driven mount option parser.
> > - *
> > - * Currently only used for remount, but it will be used for mount
> > - * in the future, too.
> > - */
> >  enum {
> > -	Opt_barrier, Opt_nobarrier, Opt_err
> > +	Opt_logbufs, Opt_logbsize, Opt_logdev, Opt_rtdev, Opt_biosize,
> > +	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_inode64, Opt_ikeep, Opt_noikeep, Opt_largeio,
> > +	Opt_nolargeio, Opt_attr2, Opt_noattr2, Opt_filestreams, Opt_quota,
> > +	Opt_noquota, Opt_usrquota, Opt_grpquota, Opt_prjquota, Opt_uquota,
> > +	Opt_gquota, Opt_pquota, Opt_uqnoenf, Opt_gqnoenf, Opt_pqnoenf,
> > +	Opt_qnoenf, Opt_discard, Opt_nodiscard, Opt_delaylog, Opt_nodelaylog,
> > +	Opt_ihashsize, Opt_osyncisdsync, Opt_osyncisosync, Opt_irixsgid,
> > +	Opt_err
> >  };
> >  
> >  static const match_table_t tokens = {
> > -	{Opt_barrier, "barrier"},
> > -	{Opt_nobarrier, "nobarrier"},
> > +	{Opt_logbufs, MNTOPT_LOGBUFS "=%d"},	/* number of XFS log buffers */
> > +	{Opt_logbsize, MNTOPT_LOGBSIZE "=%s"},	/* size of XFS log buffers */
> > +	{Opt_logdev, MNTOPT_LOGDEV "=%s"},	/* log device */
> > +	{Opt_rtdev, MNTOPT_RTDEV "=%s"},	/* realtime I/O device */
> > +	{Opt_biosize, MNTOPT_BIOSIZE "=%d"},	/* log2 of preferred buffered io size */
> > +	{Opt_wsync, MNTOPT_WSYNC},		/* safe-mode nfs compatible mount */
> > +	{Opt_noalign, MNTOPT_NOALIGN},		/* turn off stripe alignment */
> > +	{Opt_swalloc, MNTOPT_SWALLOC},		/* turn on stripe width allocation */
> > +	{Opt_sunit, MNTOPT_SUNIT "=%d"},	/* data volume stripe unit */
> > +	{Opt_swidth, MNTOPT_SWIDTH "=%d"},	/* data volume stripe width */
> > +	{Opt_nouuid, MNTOPT_NOUUID},		/* ignore filesystem UUID */
> > +	{Opt_mtpt, MNTOPT_MTPT},		/* filesystem mount point */
> > +	{Opt_grpid, MNTOPT_GRPID},		/* group-ID from parent directory */
> > +	{Opt_nogrpid, MNTOPT_NOGRPID},		/* group-ID from current process */
> > +	{Opt_bsdgroups, MNTOPT_BSDGROUPS},	/* group-ID from parent directory */
> > +	{Opt_sysvgroups, MNTOPT_SYSVGROUPS},	/* group-ID from current process */
> > +	{Opt_allocsize, MNTOPT_ALLOCSIZE "=%s"},/* preferred allocation size */
> > +	{Opt_norecovery, MNTOPT_NORECOVERY},	/* do not run XFS recovery */
> > +	{Opt_barrier, MNTOPT_BARRIER},		/* use writer barrier for log write and
> > +						 * unwritten extent conversation */
> > +	{Opt_nobarrier, MNTOPT_NOBARRIER},	/* .. disable */
> > +	{Opt_inode64, MNTOPT_64BITINODE},	/* inodes can be allocated anywhere */
> > +	{Opt_ikeep, MNTOPT_IKEEP},		/* do not free empty inode clusters */
> > +	{Opt_noikeep, MNTOPT_NOIKEEP},		/* free empty inode clusters */
> > +	{Opt_largeio, MNTOPT_LARGEIO},		/* report large I/O sizes in start() */
> > +	{Opt_nolargeio, MNTOPT_NOLARGEIO},	/* do not report large I/O sizes
> > +						 * in start() */
> > +	{Opt_attr2, MNTOPT_ATTR2},		/* do use attr2 attribute format */
> > +	{Opt_noattr2, MNTOPT_NOATTR2},		/* do not use attr2 attribute format */
> > +	{Opt_filestreams, MNTOPT_FILESTREAM}, 	/* use filestreams allocator */
> > +	{Opt_quota, MNTOPT_QUOTA},		/* disk quotas (user) */
> > +	{Opt_noquota, MNTOPT_NOQUOTA},		/* no quotas */
> > +	{Opt_usrquota, MNTOPT_USRQUOTA},	/* user quota enabled */
> > +	{Opt_grpquota, MNTOPT_GRPQUOTA},	/* group quota enabled */
> > +	{Opt_prjquota, MNTOPT_PRJQUOTA},	/* project quota enabled */
> > +	{Opt_uquota, MNTOPT_UQUOTA},		/* user quota (IRIX variant) */
> > +	{Opt_gquota, MNTOPT_GQUOTA},		/* group quota (IRIX variant) */
> > +	{Opt_pquota, MNTOPT_PQUOTA},		/* project quota (IRIX variant) */
> > +	{Opt_uqnoenf, MNTOPT_UQUOTANOENF},	/* user quota limit enforcement */
> > +	{Opt_gqnoenf, MNTOPT_GQUOTANOENF},	/* group quota limit enforcement */
> > +	{Opt_pqnoenf, MNTOPT_PQUOTANOENF},	/* project quota limit enforcement */
> > +	{Opt_qnoenf, MNTOPT_QUOTANOENF},	/* same as uqnoenforce */
> > +	{Opt_discard, MNTOPT_DISCARD},		/* Discard unused blocks */
> > +	{Opt_nodiscard, MNTOPT_NODISCARD},	/* Do not discard unused blocks */
> > +	{Opt_delaylog, MNTOPT_DELAYLOG},	/* deprecated */
> > +	{Opt_nodelaylog, MNTOPT_NODELAYLOG},	/* deprecated */
> > +	{Opt_ihashsize, MNTOPT_IHASHSIZE},	/* deprecated */
> > +	{Opt_osyncisdsync, MNTOPT_OSYNCISDSYNC},/* deprecated */
> > +	{Opt_osyncisosync, MNTOPT_OSYNCISOSYNC},/* deprecated */
> > +	{Opt_irixsgid, MNTOPT_IRIXSGID},	/* deprecated */
> >  	{Opt_err, NULL}
> >  };
> >  
> > -
> > -STATIC unsigned long
> > -suffix_strtoul(char *s, char **endp, unsigned int base)
> > +STATIC int
> > +suffix_match_int(substring_t *s, unsigned long *result)
> >  {
> > -	int	last, shift_left_factor = 0;
> > -	char	*value = s;
> > +	int shift_left_factor = 0;
> > +	char *value = s->to - 1;
> > +	char *string;
> >  
> > -	last = strlen(value) - 1;
> > -	if (value[last] == 'K' || value[last] == 'k') {
> > +	if (*value == 'K' || *value == 'k') {
> >  		shift_left_factor = 10;
> > -		value[last] = '\0';
> > +		s->to--;
> >  	}
> > -	if (value[last] == 'M' || value[last] == 'm') {
> > +	if (*value == 'M' || *value == 'm') {
> >  		shift_left_factor = 20;
> > -		value[last] = '\0';
> > +		s->to--;
> >  	}
> > -	if (value[last] == 'G' || value[last] == 'g') {
> > +	if (*value == 'G' || *value == 'g') {
> >  		shift_left_factor = 30;
> > -		value[last] = '\0';
> > +		s->to--;
> >  	}
> >  
> > -	return simple_strtoul((const char *)s, endp, base) << shift_left_factor;
> > +	string = match_strdup(s);
> > +	if (!string)
> > +		return ENOMEM;
> > +
> > +	*result = simple_strtoul((const char *)string, NULL, 0) <<
> > +			shift_left_factor;
> > +
> > +	kfree(string);
> > +	return 0;
> > +}
> > +
> > +STATIC int
> > +match_name_strdup(substring_t *s, char *name)
> > +{
> > +	char *string;
> > +	string = match_strdup(s);
> > +	if (!string)
> > +		return ENOMEM;
> > +
> > +	name = kstrndup(string, MAXNAMELEN, GFP_KERNEL);
> > +	if (!name)
> > +		goto free;
> > +	return 0;
> > +free:
> > +	kfree(string);
> > +	return ENOMEM;
> >  }
> >  
> >  /*
> > @@ -166,11 +246,15 @@ xfs_parseargs(
> >  	char			*options)
> >  {
> >  	struct super_block	*sb = mp->m_super;
> > -	char			*this_char, *value, *eov;
> > +	char			*p;
> >  	int			dsunit = 0;
> >  	int			dswidth = 0;
> > -	int			iosize = 0;
> >  	__uint8_t		iosizelog = 0;
> > +	int			intarg;
> > +	unsigned long		ularg;
> > +	substring_t		args[MAX_OPT_ARGS];
> > +	char			*orig = NULL;
> > +	int			ret = 0;
> >  
> >  	/*
> >  	 * set up the mount name first so all the errors will refer to the
> > @@ -208,175 +292,192 @@ xfs_parseargs(
> >  	if (!options)
> >  		goto done;
> >  
> > -	while ((this_char = strsep(&options, ",")) != NULL) {
> > -		if (!*this_char)
> > +	options = kstrdup(options, GFP_NOFS);
> > +	if (!options) {
> > +		ret = ENOMEM;
> > +		goto done;
> > +	}
> > +
> > +	orig = options;
> > +
> > +	while ((p = strsep(&orig, ",")) != NULL) {
> > +		int token;
> > +		if (!*p)
> >  			continue;
> > -		if ((value = strchr(this_char, '=')) != NULL)
> > -			*value++ = 0;
> > -
> > -		if (!strcmp(this_char, MNTOPT_LOGBUFS)) {
> > -			if (!value || !*value) {
> > -				xfs_warn(mp, "%s option requires an argument",
> > -					this_char);
> > -				return EINVAL;
> > -			}
> > -			mp->m_logbufs = simple_strtoul(value, &eov, 10);
> > -		} else if (!strcmp(this_char, MNTOPT_LOGBSIZE)) {
> > -			if (!value || !*value) {
> > -				xfs_warn(mp, "%s option requires an argument",
> > -					this_char);
> > -				return EINVAL;
> > -			}
> > -			mp->m_logbsize = suffix_strtoul(value, &eov, 10);
> > -		} else if (!strcmp(this_char, MNTOPT_LOGDEV)) {
> > -			if (!value || !*value) {
> > -				xfs_warn(mp, "%s option requires an argument",
> > -					this_char);
> > -				return EINVAL;
> > -			}
> > -			mp->m_logname = kstrndup(value, MAXNAMELEN, GFP_KERNEL);
> > -			if (!mp->m_logname)
> > -				return ENOMEM;
> > -		} else if (!strcmp(this_char, MNTOPT_MTPT)) {
> > -			xfs_warn(mp, "%s option not allowed on this system",
> > -				this_char);
> > -			return EINVAL;
> > -		} else if (!strcmp(this_char, MNTOPT_RTDEV)) {
> > -			if (!value || !*value) {
> > -				xfs_warn(mp, "%s option requires an argument",
> > -					this_char);
> > -				return EINVAL;
> > -			}
> > -			mp->m_rtname = kstrndup(value, MAXNAMELEN, GFP_KERNEL);
> > -			if (!mp->m_rtname)
> > -				return ENOMEM;
> > -		} else if (!strcmp(this_char, MNTOPT_BIOSIZE)) {
> > -			if (!value || !*value) {
> > -				xfs_warn(mp, "%s option requires an argument",
> > -					this_char);
> > -				return EINVAL;
> > -			}
> > -			iosize = simple_strtoul(value, &eov, 10);
> > -			iosizelog = ffs(iosize) - 1;
> > -		} else if (!strcmp(this_char, MNTOPT_ALLOCSIZE)) {
> > -			if (!value || !*value) {
> > -				xfs_warn(mp, "%s option requires an argument",
> > -					this_char);
> > -				return EINVAL;
> > -			}
> > -			iosize = suffix_strtoul(value, &eov, 10);
> > -			iosizelog = ffs(iosize) - 1;
> > -		} else if (!strcmp(this_char, MNTOPT_GRPID) ||
> > -			   !strcmp(this_char, MNTOPT_BSDGROUPS)) {
> > +
> > +		token = match_token(p, tokens, args);
> > +		intarg = 0;
> > +		ularg = 0;
> > +		switch (token) {
> > +		case Opt_logbufs:
> > +			ret = match_int(args, &intarg);
> > +			if (ret)
> > +				goto free_orig;
> > +			mp->m_logbufs = intarg;
> > +			break;
> > +		case Opt_logbsize:
> > +			ret = suffix_match_int(args, &ularg);
> > +			if (ret)
> > +				goto free_orig;
> > +			mp->m_logbsize = ularg;
> > +			break;
> > +		case Opt_logdev:
> > +			ret = match_name_strdup(args, mp->m_logname);
> > +			if (ret)
> > +				goto free_orig;
> > +			break;
> > +		case Opt_mtpt:
> > +			xfs_warn(mp, "%s option not allowed on this system", p);
> > +			ret = EINVAL;
> > +			goto free_orig;
> > +		case Opt_rtdev:
> > +			ret = match_name_strdup(args, mp->m_rtname);
> > +			if (ret)
> > +				goto free_orig;
> > +			break;
> > +		case Opt_biosize:
> > +		case Opt_allocsize:
> > +			ret = suffix_match_int(args, &ularg);
> > +			if (ret)
> > +				goto free_orig;
> > +			iosizelog = ffs(ularg) - 1;
> > +			break;
> > +		case Opt_grpid:
> > +		case Opt_bsdgroups:
> >  			mp->m_flags |= XFS_MOUNT_GRPID;
> > -		} else if (!strcmp(this_char, MNTOPT_NOGRPID) ||
> > -			   !strcmp(this_char, MNTOPT_SYSVGROUPS)) {
> > +			break;
> > +		case Opt_nogrpid:
> > +		case Opt_sysvgroups:
> >  			mp->m_flags &= ~XFS_MOUNT_GRPID;
> > -		} else if (!strcmp(this_char, MNTOPT_WSYNC)) {
> > +			break;
> > +		case Opt_wsync:
> >  			mp->m_flags |= XFS_MOUNT_WSYNC;
> > -		} else if (!strcmp(this_char, MNTOPT_NORECOVERY)) {
> > +			break;
> > +		case Opt_norecovery:
> >  			mp->m_flags |= XFS_MOUNT_NORECOVERY;
> > -		} else if (!strcmp(this_char, MNTOPT_NOALIGN)) {
> > +			break;
> > +		case Opt_noalign:
> >  			mp->m_flags |= XFS_MOUNT_NOALIGN;
> > -		} else if (!strcmp(this_char, MNTOPT_SWALLOC)) {
> > +			break;
> > +		case Opt_swalloc:
> >  			mp->m_flags |= XFS_MOUNT_SWALLOC;
> > -		} else if (!strcmp(this_char, MNTOPT_SUNIT)) {
> > -			if (!value || !*value) {
> > -				xfs_warn(mp, "%s option requires an argument",
> > -					this_char);
> > -				return EINVAL;
> > -			}
> > -			dsunit = simple_strtoul(value, &eov, 10);
> > -		} else if (!strcmp(this_char, MNTOPT_SWIDTH)) {
> > -			if (!value || !*value) {
> > -				xfs_warn(mp, "%s option requires an argument",
> > -					this_char);
> > -				return EINVAL;
> > -			}
> > -			dswidth = simple_strtoul(value, &eov, 10);
> > -		} else if (!strcmp(this_char, MNTOPT_64BITINODE)) {
> > +			break;
> > +		case Opt_sunit:
> > +			ret = match_int(args, &intarg);
> > +			if (ret)
> > +				goto free_orig;
> > +			dsunit = intarg;
> > +			break;
> > +		case Opt_swidth:
> > +			ret = match_int(args, &intarg);
> > +			if (ret)
> > +				goto free_orig;
> > +			dswidth = intarg;
> > +			break;
> > +		case Opt_inode64:
> >  			mp->m_flags &= ~XFS_MOUNT_SMALL_INUMS;
> >  #if !XFS_BIG_INUMS
> > -			xfs_warn(mp, "%s option not allowed on this system",
> > -				this_char);
> > -			return EINVAL;
> > +			xfs_warn(mp, "%s options not allowed on this system", p);
> > +			ret = EINVAL;
> > +			goto free_orig;
> >  #endif
> > -		} else if (!strcmp(this_char, MNTOPT_NOUUID)) {
> > +			break;
> > +		case Opt_nouuid:
> >  			mp->m_flags |= XFS_MOUNT_NOUUID;
> > -		} else if (!strcmp(this_char, MNTOPT_BARRIER)) {
> > +			break;
> > +		case Opt_barrier:
> >  			mp->m_flags |= XFS_MOUNT_BARRIER;
> > -		} else if (!strcmp(this_char, MNTOPT_NOBARRIER)) {
> > +			break;
> > +		case Opt_nobarrier:
> >  			mp->m_flags &= ~XFS_MOUNT_BARRIER;
> > -		} else if (!strcmp(this_char, MNTOPT_IKEEP)) {
> > +			break;
> > +		case Opt_ikeep:
> >  			mp->m_flags |= XFS_MOUNT_IKEEP;
> > -		} else if (!strcmp(this_char, MNTOPT_NOIKEEP)) {
> > +			break;
> > +		case Opt_noikeep:
> >  			mp->m_flags &= ~XFS_MOUNT_IKEEP;
> > -		} else if (!strcmp(this_char, MNTOPT_LARGEIO)) {
> > +			break;
> > +		case Opt_largeio:
> >  			mp->m_flags &= ~XFS_MOUNT_COMPAT_IOSIZE;
> > -		} else if (!strcmp(this_char, MNTOPT_NOLARGEIO)) {
> > +			break;
> > +		case Opt_nolargeio:
> >  			mp->m_flags |= XFS_MOUNT_COMPAT_IOSIZE;
> > -		} else if (!strcmp(this_char, MNTOPT_ATTR2)) {
> > +			break;
> > +		case Opt_attr2:
> >  			mp->m_flags |= XFS_MOUNT_ATTR2;
> > -		} else if (!strcmp(this_char, MNTOPT_NOATTR2)) {
> > +			break;
> > +		case Opt_noattr2:
> >  			mp->m_flags &= ~XFS_MOUNT_ATTR2;
> >  			mp->m_flags |= XFS_MOUNT_NOATTR2;
> > -		} else if (!strcmp(this_char, MNTOPT_FILESTREAM)) {
> > +			break;
> > +		case Opt_filestreams:
> >  			mp->m_flags |= XFS_MOUNT_FILESTREAMS;
> > -		} else if (!strcmp(this_char, MNTOPT_NOQUOTA)) {
> > +			break;
> > +		case Opt_noquota:
> >  			mp->m_qflags &= ~XFS_ALL_QUOTA_ACCT;
> >  			mp->m_qflags &= ~XFS_ALL_QUOTA_ENFD;
> >  			mp->m_qflags &= ~XFS_ALL_QUOTA_ACTIVE;
> > -		} else if (!strcmp(this_char, MNTOPT_QUOTA) ||
> > -			   !strcmp(this_char, MNTOPT_UQUOTA) ||
> > -			   !strcmp(this_char, MNTOPT_USRQUOTA)) {
> > +			break;
> > +		case Opt_quota:
> > +		case Opt_uquota:
> > +		case Opt_usrquota:
> >  			mp->m_qflags |= (XFS_UQUOTA_ACCT | XFS_UQUOTA_ACTIVE |
> >  					 XFS_UQUOTA_ENFD);
> > -		} else if (!strcmp(this_char, MNTOPT_QUOTANOENF) ||
> > -			   !strcmp(this_char, MNTOPT_UQUOTANOENF)) {
> > +			break;
> > +		case Opt_qnoenf:
> > +		case Opt_uqnoenf:
> >  			mp->m_qflags |= (XFS_UQUOTA_ACCT | XFS_UQUOTA_ACTIVE);
> >  			mp->m_qflags &= ~XFS_UQUOTA_ENFD;
> > -		} else if (!strcmp(this_char, MNTOPT_PQUOTA) ||
> > -			   !strcmp(this_char, MNTOPT_PRJQUOTA)) {
> > +			break;
> > +		case Opt_pquota:
> > +		case Opt_prjquota:
> >  			mp->m_qflags |= (XFS_PQUOTA_ACCT | XFS_PQUOTA_ACTIVE |
> >  					 XFS_OQUOTA_ENFD);
> > -		} else if (!strcmp(this_char, MNTOPT_PQUOTANOENF)) {
> > +			break;
> > +		case Opt_pqnoenf:
> >  			mp->m_qflags |= (XFS_PQUOTA_ACCT | XFS_PQUOTA_ACTIVE);
> >  			mp->m_qflags &= ~XFS_OQUOTA_ENFD;
> > -		} else if (!strcmp(this_char, MNTOPT_GQUOTA) ||
> > -			   !strcmp(this_char, MNTOPT_GRPQUOTA)) {
> > +			break;
> > +		case Opt_gquota:
> > +		case Opt_grpquota:
> >  			mp->m_qflags |= (XFS_GQUOTA_ACCT | XFS_GQUOTA_ACTIVE |
> >  					 XFS_OQUOTA_ENFD);
> > -		} else if (!strcmp(this_char, MNTOPT_GQUOTANOENF)) {
> > +			break;
> > +		case Opt_gqnoenf:
> >  			mp->m_qflags |= (XFS_GQUOTA_ACCT | XFS_GQUOTA_ACTIVE);
> >  			mp->m_qflags &= ~XFS_OQUOTA_ENFD;
> > -		} else if (!strcmp(this_char, MNTOPT_DELAYLOG)) {
> > -			xfs_warn(mp,
> > -	"delaylog is the default now, option is deprecated.");
> > -		} else if (!strcmp(this_char, MNTOPT_NODELAYLOG)) {
> > -			xfs_warn(mp,
> > -	"nodelaylog support has been removed, option is deprecated.");
> > -		} else if (!strcmp(this_char, MNTOPT_DISCARD)) {
> > +			break;
> > +		case Opt_discard:
> >  			mp->m_flags |= XFS_MOUNT_DISCARD;
> > -		} else if (!strcmp(this_char, MNTOPT_NODISCARD)) {
> > +			break;
> > +		case Opt_nodiscard:
> >  			mp->m_flags &= ~XFS_MOUNT_DISCARD;
> > -		} else if (!strcmp(this_char, "ihashsize")) {
> > -			xfs_warn(mp,
> > -	"ihashsize no longer used, option is deprecated.");
> > -		} else if (!strcmp(this_char, "osyncisdsync")) {
> > -			xfs_warn(mp,
> > -	"osyncisdsync has no effect, option is deprecated.");
> > -		} else if (!strcmp(this_char, "osyncisosync")) {
> > -			xfs_warn(mp,
> > -	"osyncisosync has no effect, option is deprecated.");
> > -		} else if (!strcmp(this_char, "irixsgid")) {
> > -			xfs_warn(mp,
> > -	"irixsgid is now a sysctl(2) variable, option is deprecated.");
> > -		} else {
> > -			xfs_warn(mp, "unknown mount option [%s].", this_char);
> > -			return EINVAL;
> > +			break;
> > +		case Opt_delaylog:
> > +			xfs_warn(mp, MNTOPT_DELAYLOG MNTOPT_DEPRECATED);
> > +			break;
> > +		case Opt_nodelaylog:
> > +			xfs_warn(mp, MNTOPT_NODELAYLOG MNTOPT_DEPRECATED);
> > +			break;
> > +		case Opt_ihashsize:
> > +			xfs_warn(mp, MNTOPT_IHASHSIZE MNTOPT_DEPRECATED);
> > +		case Opt_osyncisdsync:
> > +			xfs_warn(mp, MNTOPT_OSYNCISDSYNC MNTOPT_DEPRECATED);
> > +			break;
> > +		case Opt_osyncisosync:
> > +			xfs_warn(mp, MNTOPT_OSYNCISOSYNC MNTOPT_DEPRECATED);
> > +			break;
> > +		case Opt_irixsgid:
> > +			xfs_warn(mp, MNTOPT_IRIXSGID MNTOPT_DEPRECATED);
> > +			break;
> > +		default:
> > +			xfs_warn(mp, "unknown mount option [%s].", p);
> > +			break;
> >  		}
> >  	}
> >  
> > +	kfree(orig);
> > +
> >  	/*
> >  	 * no recovery flag requires a read-only mount
> >  	 */
> > @@ -468,6 +569,10 @@ done:
> >  	}
> >  
> >  	return 0;
> > +
> > +free_orig:
> > +	kfree(orig);
> > +	return ret;
> >  }
> >  
> >  struct proc_xfs_info {
> > @@ -476,10 +581,12 @@ struct proc_xfs_info {
> >  };
> >  
> >  STATIC int
> > -xfs_showargs(
> > -	struct xfs_mount	*mp,
> > -	struct seq_file		*m)
> > +xfs_fs_show_options(
> > +	struct seq_file		*seq,
> > +	struct dentry		*dentry)
> >  {
> > +	struct xfs_mount	*mp = XFS_M(dentry->d_sb);
> > +
> >  	static struct proc_xfs_info xfs_info_set[] = {
> >  		/* the few simple ones we can get from the mount struct */
> >  		{ XFS_MOUNT_IKEEP,		"," MNTOPT_IKEEP },
> > @@ -505,58 +612,60 @@ xfs_showargs(
> >  
> >  	for (xfs_infop = xfs_info_set; xfs_infop->flag; xfs_infop++) {
> >  		if (mp->m_flags & xfs_infop->flag)
> > -			seq_puts(m, xfs_infop->str);
> > +			seq_puts(seq, xfs_infop->str);
> >  	}
> >  	for (xfs_infop = xfs_info_unset; xfs_infop->flag; xfs_infop++) {
> >  		if (!(mp->m_flags & xfs_infop->flag))
> > -			seq_puts(m, xfs_infop->str);
> > +			seq_puts(seq, xfs_infop->str);
> >  	}
> >  
> >  	if (mp->m_flags & XFS_MOUNT_DFLT_IOSIZE)
> > -		seq_printf(m, "," MNTOPT_ALLOCSIZE "=%dk",
> > +		seq_printf(seq, "," MNTOPT_ALLOCSIZE "=%dk",
> >  				(int)(1 << mp->m_writeio_log) >> 10);
> >  
> >  	if (mp->m_logbufs > 0)
> > -		seq_printf(m, "," MNTOPT_LOGBUFS "=%d", mp->m_logbufs);
> > +		seq_printf(seq, "," MNTOPT_LOGBUFS "=%d", mp->m_logbufs);
> >  	if (mp->m_logbsize > 0)
> > -		seq_printf(m, "," MNTOPT_LOGBSIZE "=%dk", mp->m_logbsize >> 10);
> > +		seq_printf(seq, "," MNTOPT_LOGBSIZE "=%dk",
> > +				mp->m_logbsize >> 10);
> >  
> >  	if (mp->m_logname)
> > -		seq_printf(m, "," MNTOPT_LOGDEV "=%s", mp->m_logname);
> > +		seq_printf(seq, "," MNTOPT_LOGDEV "=%s", mp->m_logname);
> >  	if (mp->m_rtname)
> > -		seq_printf(m, "," MNTOPT_RTDEV "=%s", mp->m_rtname);
> > +		seq_printf(seq, "," MNTOPT_RTDEV "=%s", mp->m_rtname);
> >  
> >  	if (mp->m_dalign > 0)
> > -		seq_printf(m, "," MNTOPT_SUNIT "=%d",
> > +		seq_printf(seq, "," MNTOPT_SUNIT "=%d",
> >  				(int)XFS_FSB_TO_BB(mp, mp->m_dalign));
> >  	if (mp->m_swidth > 0)
> > -		seq_printf(m, "," MNTOPT_SWIDTH "=%d",
> > +		seq_printf(seq, "," MNTOPT_SWIDTH "=%d",
> >  				(int)XFS_FSB_TO_BB(mp, mp->m_swidth));
> >  
> >  	if (mp->m_qflags & (XFS_UQUOTA_ACCT|XFS_UQUOTA_ENFD))
> > -		seq_puts(m, "," MNTOPT_USRQUOTA);
> > +		seq_puts(seq, "," MNTOPT_USRQUOTA);
> >  	else if (mp->m_qflags & XFS_UQUOTA_ACCT)
> > -		seq_puts(m, "," MNTOPT_UQUOTANOENF);
> > +		seq_puts(seq, "," MNTOPT_UQUOTANOENF);
> >  
> >  	/* Either project or group quotas can be active, not both */
> >  
> >  	if (mp->m_qflags & XFS_PQUOTA_ACCT) {
> >  		if (mp->m_qflags & XFS_OQUOTA_ENFD)
> > -			seq_puts(m, "," MNTOPT_PRJQUOTA);
> > +			seq_puts(seq, "," MNTOPT_PRJQUOTA);
> >  		else
> > -			seq_puts(m, "," MNTOPT_PQUOTANOENF);
> > +			seq_puts(seq, "," MNTOPT_PQUOTANOENF);
> >  	} else if (mp->m_qflags & XFS_GQUOTA_ACCT) {
> >  		if (mp->m_qflags & XFS_OQUOTA_ENFD)
> > -			seq_puts(m, "," MNTOPT_GRPQUOTA);
> > +			seq_puts(seq, "," MNTOPT_GRPQUOTA);
> >  		else
> > -			seq_puts(m, "," MNTOPT_GQUOTANOENF);
> > +			seq_puts(seq, "," MNTOPT_GQUOTANOENF);
> >  	}
> >  
> >  	if (!(mp->m_qflags & XFS_ALL_QUOTA_ACCT))
> > -		seq_puts(m, "," MNTOPT_NOQUOTA);
> > +		seq_puts(seq, "," MNTOPT_NOQUOTA);
> >  
> >  	return 0;
> >  }
> > +
> >  __uint64_t
> >  xfs_max_file_offset(
> >  	unsigned int		blockshift)
> > @@ -1221,14 +1330,6 @@ xfs_fs_unfreeze(
> >  	return 0;
> >  }
> >  
> > -STATIC int
> > -xfs_fs_show_options(
> > -	struct seq_file		*m,
> > -	struct dentry		*root)
> > -{
> > -	return -xfs_showargs(XFS_M(root->d_sb), m);
> > -}
> > -
> >  /*
> >   * This function fills in xfs_mount_t fields based on mount args.
> >   * Note: the superblock _has_ now been read in.
> > 
> 
> 
> _______________________________________________
> xfs mailing list
> xfs@oss.sgi.com
> http://oss.sgi.com/mailman/listinfo/xfs

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

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

* Re: [PATCH V5] xfs: cleanup the mount options
  2012-07-11  6:29                 ` [PATCH V5] " Wanlong Gao
  2012-07-16  8:06                   ` Wanlong Gao
@ 2012-07-23 23:28                   ` Dave Chinner
  2012-07-24  2:01                     ` Wanlong Gao
  2012-07-24  2:10                     ` [PATCH V6] " Wanlong Gao
  1 sibling, 2 replies; 31+ messages in thread
From: Dave Chinner @ 2012-07-23 23:28 UTC (permalink / raw)
  To: Wanlong Gao; +Cc: Christoph Hellwig, Ben Myers, Zach Brown, xfs

On Wed, Jul 11, 2012 at 02:29:05PM +0800, Wanlong Gao wrote:
> -	return simple_strtoul((const char *)s, endp, base) << shift_left_factor;
> +	string = match_strdup(s);

GFP_KERNEL allocation....

> +	if (!string)
> +		return ENOMEM;
> +
> +	*result = simple_strtoul((const char *)string, NULL, 0) <<
> +			shift_left_factor;
> +
> +	kfree(string);
> +	return 0;
> +}
> +
> +STATIC int
> +match_name_strdup(substring_t *s, char *name)
> +{
> +	char *string;
> +	string = match_strdup(s);

GFP_KERNEL allocation....

> +	if (!string)
> +		return ENOMEM;
> +
> +	name = kstrndup(string, MAXNAMELEN, GFP_KERNEL);

GFP_KERNEL allocation....

> +	if (!name)
> +		goto free;
> +	return 0;

Leaks string - it should always be freed.

> +free:
> +	kfree(string);
> +	return ENOMEM;
>  }
>  
>  /*
> @@ -166,11 +246,15 @@ xfs_parseargs(
>  	char			*options)
>  {
>  	struct super_block	*sb = mp->m_super;
> -	char			*this_char, *value, *eov;
> +	char			*p;
>  	int			dsunit = 0;
>  	int			dswidth = 0;
> -	int			iosize = 0;
>  	__uint8_t		iosizelog = 0;
> +	int			intarg;
> +	unsigned long		ularg;
> +	substring_t		args[MAX_OPT_ARGS];
> +	char			*orig = NULL;
> +	int			ret = 0;
>  
>  	/*
>  	 * set up the mount name first so all the errors will refer to the
> @@ -208,175 +292,192 @@ xfs_parseargs(
>  	if (!options)
>  		goto done;
>  
> -	while ((this_char = strsep(&options, ",")) != NULL) {
> -		if (!*this_char)
> +	options = kstrdup(options, GFP_NOFS);

GFP_NOFS allocation. Why is this GFP_NOFS, and all the other
allocations GFP_KERNEL? If it is not safe to use GFP_KERNEL
allocations here, then all of the above allocations need to be
GFP_NOFS, too.


> +	if (!options) {
> +		ret = ENOMEM;
> +		goto done;
> +	}
> +
> +	orig = options;

Also, no need to set up orig like this. Just a simple:

	orig = kstrdup(options, GFP_NOFS);
	if (!orig) {
		ret = ENOMEM;
		goto done;
	}

will work fine.

....

>  	if (mp->m_logbufs > 0)
> -		seq_printf(m, "," MNTOPT_LOGBUFS "=%d", mp->m_logbufs);
> +		seq_printf(seq, "," MNTOPT_LOGBUFS "=%d", mp->m_logbufs);
>  	if (mp->m_logbsize > 0)
> -		seq_printf(m, "," MNTOPT_LOGBSIZE "=%dk", mp->m_logbsize >> 10);
> +		seq_printf(seq, "," MNTOPT_LOGBSIZE "=%dk",
> +				mp->m_logbsize >> 10);

Change of user visible output format here. That will break any
scripts that are parsing the output and expecting numbers. Just
leave it as a raw number.

Cheers,

Dave.
-- 
Dave Chinner
david@fromorbit.com

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

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

* Re: [PATCH V5] xfs: cleanup the mount options
  2012-07-23 23:28                   ` Dave Chinner
@ 2012-07-24  2:01                     ` Wanlong Gao
  2012-07-24 21:18                       ` Dave Chinner
  2012-07-24  2:10                     ` [PATCH V6] " Wanlong Gao
  1 sibling, 1 reply; 31+ messages in thread
From: Wanlong Gao @ 2012-07-24  2:01 UTC (permalink / raw)
  To: Dave Chinner; +Cc: Christoph Hellwig, Ben Myers, Zach Brown, xfs

On 07/24/2012 07:28 AM, Dave Chinner wrote:
> On Wed, Jul 11, 2012 at 02:29:05PM +0800, Wanlong Gao wrote:
>> -	return simple_strtoul((const char *)s, endp, base) << shift_left_factor;
>> +	string = match_strdup(s);
> 
> GFP_KERNEL allocation....
> 
>> +	if (!string)
>> +		return ENOMEM;
>> +
>> +	*result = simple_strtoul((const char *)string, NULL, 0) <<
>> +			shift_left_factor;
>> +
>> +	kfree(string);
>> +	return 0;
>> +}
>> +
>> +STATIC int
>> +match_name_strdup(substring_t *s, char *name)
>> +{
>> +	char *string;
>> +	string = match_strdup(s);
> 
> GFP_KERNEL allocation....
> 
>> +	if (!string)
>> +		return ENOMEM;
>> +
>> +	name = kstrndup(string, MAXNAMELEN, GFP_KERNEL);
> 
> GFP_KERNEL allocation....
> 
>> +	if (!name)
>> +		goto free;
>> +	return 0;
> 
> Leaks string - it should always be freed.

Sorry, will update.

> 
>> +free:
>> +	kfree(string);
>> +	return ENOMEM;
>>  }
>>  
>>  /*
>> @@ -166,11 +246,15 @@ xfs_parseargs(
>>  	char			*options)
>>  {
>>  	struct super_block	*sb = mp->m_super;
>> -	char			*this_char, *value, *eov;
>> +	char			*p;
>>  	int			dsunit = 0;
>>  	int			dswidth = 0;
>> -	int			iosize = 0;
>>  	__uint8_t		iosizelog = 0;
>> +	int			intarg;
>> +	unsigned long		ularg;
>> +	substring_t		args[MAX_OPT_ARGS];
>> +	char			*orig = NULL;
>> +	int			ret = 0;
>>  
>>  	/*
>>  	 * set up the mount name first so all the errors will refer to the
>> @@ -208,175 +292,192 @@ xfs_parseargs(
>>  	if (!options)
>>  		goto done;
>>  
>> -	while ((this_char = strsep(&options, ",")) != NULL) {
>> -		if (!*this_char)
>> +	options = kstrdup(options, GFP_NOFS);
> 
> GFP_NOFS allocation. Why is this GFP_NOFS, and all the other
> allocations GFP_KERNEL? If it is not safe to use GFP_KERNEL
> allocations here, then all of the above allocations need to be
> GFP_NOFS, too.

Since strsep() will change the options, so we should make GFP_NOFS
safely to dup the orig options, but the parse functions can safely
use GFP_KERNEL.

> 
> 
>> +	if (!options) {
>> +		ret = ENOMEM;
>> +		goto done;
>> +	}
>> +
>> +	orig = options;
> 
> Also, no need to set up orig like this. Just a simple:
> 
> 	orig = kstrdup(options, GFP_NOFS);
> 	if (!orig) {
> 		ret = ENOMEM;
> 		goto done;
> 	}
> 
> will work fine.

Yeah, thank you.

> 
> ....
> 
>>  	if (mp->m_logbufs > 0)
>> -		seq_printf(m, "," MNTOPT_LOGBUFS "=%d", mp->m_logbufs);
>> +		seq_printf(seq, "," MNTOPT_LOGBUFS "=%d", mp->m_logbufs);
>>  	if (mp->m_logbsize > 0)
>> -		seq_printf(m, "," MNTOPT_LOGBSIZE "=%dk", mp->m_logbsize >> 10);
>> +		seq_printf(seq, "," MNTOPT_LOGBSIZE "=%dk",
>> +				mp->m_logbsize >> 10);
> 
> Change of user visible output format here. That will break any
> scripts that are parsing the output and expecting numbers. Just
> leave it as a raw number.

OK, defer to you.

Thanks,
Wanlong Gao

> 
> Cheers,
> 
> Dave.
> 

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

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

* [PATCH V6] xfs: cleanup the mount options
  2012-07-23 23:28                   ` Dave Chinner
  2012-07-24  2:01                     ` Wanlong Gao
@ 2012-07-24  2:10                     ` Wanlong Gao
  1 sibling, 0 replies; 31+ messages in thread
From: Wanlong Gao @ 2012-07-24  2:10 UTC (permalink / raw)
  To: xfs; +Cc: Christoph Hellwig, Ben Myers, Zach Brown, Wanlong Gao

remove the mount options macro, use tokens instead.

change from V5: (Dave)
1. fix a string leak.
2. leave the show options to raw numbers.

change from V4: (as Dave suggested)
1. suffix_match_int avoid overflow.
2. convert the return style to be consistent with others.
3. move the "intarg" init above the switch.
4. move match_strdup to a help function.
5. collapsed Opt_biosize and Opt_allocsize.
6. make a consistent deprecated message.

CC: Ben Myers <bpm@sgi.com>
CC: Christoph Hellwig <hch@infradead.org>
CC: Dave Chinner <david@fromorbit.com>
CC: Zach Brown <zab@zabbo.net>
Signed-off-by: Wanlong Gao <gaowanlong@cn.fujitsu.com>
---
 fs/xfs/xfs_super.c | 551 +++++++++++++++++++++++++++++++----------------------
 1 file changed, 325 insertions(+), 226 deletions(-)

diff --git a/fs/xfs/xfs_super.c b/fs/xfs/xfs_super.c
index 07f70e1..eb9aa89 100644
--- a/fs/xfs/xfs_super.c
+++ b/fs/xfs/xfs_super.c
@@ -66,91 +66,171 @@ static const struct super_operations xfs_super_operations;
 static kmem_zone_t *xfs_ioend_zone;
 mempool_t *xfs_ioend_pool;
 
-#define MNTOPT_LOGBUFS	"logbufs"	/* number of XFS log buffers */
-#define MNTOPT_LOGBSIZE	"logbsize"	/* size of XFS log buffers */
-#define MNTOPT_LOGDEV	"logdev"	/* log device */
-#define MNTOPT_RTDEV	"rtdev"		/* realtime I/O device */
-#define MNTOPT_BIOSIZE	"biosize"	/* log2 of preferred buffered io size */
-#define MNTOPT_WSYNC	"wsync"		/* safe-mode nfs compatible mount */
-#define MNTOPT_NOALIGN	"noalign"	/* turn off stripe alignment */
-#define MNTOPT_SWALLOC	"swalloc"	/* turn on stripe width allocation */
-#define MNTOPT_SUNIT	"sunit"		/* data volume stripe unit */
-#define MNTOPT_SWIDTH	"swidth"	/* data volume stripe width */
-#define MNTOPT_NOUUID	"nouuid"	/* ignore filesystem UUID */
-#define MNTOPT_MTPT	"mtpt"		/* filesystem mount point */
-#define MNTOPT_GRPID	"grpid"		/* group-ID from parent directory */
-#define MNTOPT_NOGRPID	"nogrpid"	/* group-ID from current process */
-#define MNTOPT_BSDGROUPS    "bsdgroups"    /* group-ID from parent directory */
-#define MNTOPT_SYSVGROUPS   "sysvgroups"   /* group-ID from current process */
-#define MNTOPT_ALLOCSIZE    "allocsize"    /* preferred allocation size */
-#define MNTOPT_NORECOVERY   "norecovery"   /* don't run XFS recovery */
-#define MNTOPT_BARRIER	"barrier"	/* use writer barriers for log write and
-					 * unwritten extent conversion */
-#define MNTOPT_NOBARRIER "nobarrier"	/* .. disable */
-#define MNTOPT_64BITINODE   "inode64"	/* inodes can be allocated anywhere */
-#define MNTOPT_IKEEP	"ikeep"		/* do not free empty inode clusters */
-#define MNTOPT_NOIKEEP	"noikeep"	/* free empty inode clusters */
-#define MNTOPT_LARGEIO	   "largeio"	/* report large I/O sizes in stat() */
-#define MNTOPT_NOLARGEIO   "nolargeio"	/* do not report large I/O sizes
-					 * in stat(). */
-#define MNTOPT_ATTR2	"attr2"		/* do use attr2 attribute format */
-#define MNTOPT_NOATTR2	"noattr2"	/* do not use attr2 attribute format */
-#define MNTOPT_FILESTREAM  "filestreams" /* use filestreams allocator */
-#define MNTOPT_QUOTA	"quota"		/* disk quotas (user) */
-#define MNTOPT_NOQUOTA	"noquota"	/* no quotas */
-#define MNTOPT_USRQUOTA	"usrquota"	/* user quota enabled */
-#define MNTOPT_GRPQUOTA	"grpquota"	/* group quota enabled */
-#define MNTOPT_PRJQUOTA	"prjquota"	/* project quota enabled */
-#define MNTOPT_UQUOTA	"uquota"	/* user quota (IRIX variant) */
-#define MNTOPT_GQUOTA	"gquota"	/* group quota (IRIX variant) */
-#define MNTOPT_PQUOTA	"pquota"	/* project quota (IRIX variant) */
-#define MNTOPT_UQUOTANOENF "uqnoenforce"/* user quota limit enforcement */
-#define MNTOPT_GQUOTANOENF "gqnoenforce"/* group quota limit enforcement */
-#define MNTOPT_PQUOTANOENF "pqnoenforce"/* project quota limit enforcement */
-#define MNTOPT_QUOTANOENF  "qnoenforce"	/* same as uqnoenforce */
-#define MNTOPT_DELAYLOG    "delaylog"	/* Delayed logging enabled */
-#define MNTOPT_NODELAYLOG  "nodelaylog"	/* Delayed logging disabled */
-#define MNTOPT_DISCARD	   "discard"	/* Discard unused blocks */
-#define MNTOPT_NODISCARD   "nodiscard"	/* Do not discard unused blocks */
+#define	MNTOPT_LOGBUFS		"logbufs"
+#define	MNTOPT_LOGBSIZE		"logbsize"
+#define	MNTOPT_LOGDEV		"logdev"
+#define	MNTOPT_RTDEV		"rtdev"
+#define	MNTOPT_BIOSIZE		"biosize"
+#define	MNTOPT_WSYNC		"wsync"
+#define	MNTOPT_NOALIGN		"noalign"
+#define	MNTOPT_SWALLOC		"swalloc"
+#define	MNTOPT_SUNIT		"sunit"
+#define	MNTOPT_SWIDTH		"swidth"
+#define	MNTOPT_NOUUID		"nouuid"
+#define	MNTOPT_MTPT		"mtpt"
+#define	MNTOPT_GRPID		"grpid"
+#define	MNTOPT_NOGRPID		"nogrpid"
+#define	MNTOPT_BSDGROUPS	"bsdgroups"
+#define	MNTOPT_SYSVGROUPS	"sysvgroups"
+#define	MNTOPT_ALLOCSIZE	"allocsize"
+#define	MNTOPT_NORECOVERY	"norecovery"
+#define	MNTOPT_BARRIER		"barrier"
+#define	MNTOPT_NOBARRIER	"nobarrier"
+#define	MNTOPT_64BITINODE	"inode64"
+#define	MNTOPT_IKEEP		"ikeep"
+#define	MNTOPT_NOIKEEP		"noikeep"
+#define	MNTOPT_LARGEIO		"largeio"
+#define	MNTOPT_NOLARGEIO	"nolargeio"
+#define	MNTOPT_ATTR2		"attr2"
+#define	MNTOPT_NOATTR2		"noattr2"
+#define	MNTOPT_FILESTREAM	"filestreams"
+#define	MNTOPT_QUOTA		"quota"
+#define	MNTOPT_NOQUOTA		"noquota"
+#define	MNTOPT_USRQUOTA		"usrquota"
+#define	MNTOPT_GRPQUOTA		"grpquota"
+#define	MNTOPT_PRJQUOTA		"prjquota"
+#define	MNTOPT_UQUOTA		"uquota"
+#define	MNTOPT_GQUOTA		"gquota"
+#define	MNTOPT_PQUOTA		"pquota"
+#define	MNTOPT_UQUOTANOENF	"uqnoenforce"
+#define	MNTOPT_GQUOTANOENF	"gqnoenforce"
+#define	MNTOPT_PQUOTANOENF	"pqnoenforce"
+#define	MNTOPT_QUOTANOENF	"qnoenforce"
+#define	MNTOPT_DISCARD		"discard"
+#define	MNTOPT_NODISCARD	"nodiscard"
+#define	MNTOPT_DELAYLOG		"delaylog"
+#define	MNTOPT_NODELAYLOG	"nodelaylog"
+#define	MNTOPT_IHASHSIZE	"ihashsize"
+#define	MNTOPT_OSYNCISDSYNC	"osyncisdsync"
+#define	MNTOPT_OSYNCISOSYNC	"osyncisosync"
+#define	MNTOPT_IRIXSGID		"irixsgid"
+
+#define MNTOPT_DEPRECATED "has no effect, option is deprecated"
 
-/*
- * Table driven mount option parser.
- *
- * Currently only used for remount, but it will be used for mount
- * in the future, too.
- */
 enum {
-	Opt_barrier, Opt_nobarrier, Opt_err
+	Opt_logbufs, Opt_logbsize, Opt_logdev, Opt_rtdev, Opt_biosize,
+	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_inode64, Opt_ikeep, Opt_noikeep, Opt_largeio,
+	Opt_nolargeio, Opt_attr2, Opt_noattr2, Opt_filestreams, Opt_quota,
+	Opt_noquota, Opt_usrquota, Opt_grpquota, Opt_prjquota, Opt_uquota,
+	Opt_gquota, Opt_pquota, Opt_uqnoenf, Opt_gqnoenf, Opt_pqnoenf,
+	Opt_qnoenf, Opt_discard, Opt_nodiscard, Opt_delaylog, Opt_nodelaylog,
+	Opt_ihashsize, Opt_osyncisdsync, Opt_osyncisosync, Opt_irixsgid,
+	Opt_err
 };
 
 static const match_table_t tokens = {
-	{Opt_barrier, "barrier"},
-	{Opt_nobarrier, "nobarrier"},
+	{Opt_logbufs, MNTOPT_LOGBUFS "=%d"},	/* number of XFS log buffers */
+	{Opt_logbsize, MNTOPT_LOGBSIZE "=%s"},	/* size of XFS log buffers */
+	{Opt_logdev, MNTOPT_LOGDEV "=%s"},	/* log device */
+	{Opt_rtdev, MNTOPT_RTDEV "=%s"},	/* realtime I/O device */
+	{Opt_biosize, MNTOPT_BIOSIZE "=%d"},	/* log2 of preferred buffered io size */
+	{Opt_wsync, MNTOPT_WSYNC},		/* safe-mode nfs compatible mount */
+	{Opt_noalign, MNTOPT_NOALIGN},		/* turn off stripe alignment */
+	{Opt_swalloc, MNTOPT_SWALLOC},		/* turn on stripe width allocation */
+	{Opt_sunit, MNTOPT_SUNIT "=%d"},	/* data volume stripe unit */
+	{Opt_swidth, MNTOPT_SWIDTH "=%d"},	/* data volume stripe width */
+	{Opt_nouuid, MNTOPT_NOUUID},		/* ignore filesystem UUID */
+	{Opt_mtpt, MNTOPT_MTPT},		/* filesystem mount point */
+	{Opt_grpid, MNTOPT_GRPID},		/* group-ID from parent directory */
+	{Opt_nogrpid, MNTOPT_NOGRPID},		/* group-ID from current process */
+	{Opt_bsdgroups, MNTOPT_BSDGROUPS},	/* group-ID from parent directory */
+	{Opt_sysvgroups, MNTOPT_SYSVGROUPS},	/* group-ID from current process */
+	{Opt_allocsize, MNTOPT_ALLOCSIZE "=%s"},/* preferred allocation size */
+	{Opt_norecovery, MNTOPT_NORECOVERY},	/* do not run XFS recovery */
+	{Opt_barrier, MNTOPT_BARRIER},		/* use writer barrier for log write and
+						 * unwritten extent conversation */
+	{Opt_nobarrier, MNTOPT_NOBARRIER},	/* .. disable */
+	{Opt_inode64, MNTOPT_64BITINODE},	/* inodes can be allocated anywhere */
+	{Opt_ikeep, MNTOPT_IKEEP},		/* do not free empty inode clusters */
+	{Opt_noikeep, MNTOPT_NOIKEEP},		/* free empty inode clusters */
+	{Opt_largeio, MNTOPT_LARGEIO},		/* report large I/O sizes in start() */
+	{Opt_nolargeio, MNTOPT_NOLARGEIO},	/* do not report large I/O sizes
+						 * in start() */
+	{Opt_attr2, MNTOPT_ATTR2},		/* do use attr2 attribute format */
+	{Opt_noattr2, MNTOPT_NOATTR2},		/* do not use attr2 attribute format */
+	{Opt_filestreams, MNTOPT_FILESTREAM}, 	/* use filestreams allocator */
+	{Opt_quota, MNTOPT_QUOTA},		/* disk quotas (user) */
+	{Opt_noquota, MNTOPT_NOQUOTA},		/* no quotas */
+	{Opt_usrquota, MNTOPT_USRQUOTA},	/* user quota enabled */
+	{Opt_grpquota, MNTOPT_GRPQUOTA},	/* group quota enabled */
+	{Opt_prjquota, MNTOPT_PRJQUOTA},	/* project quota enabled */
+	{Opt_uquota, MNTOPT_UQUOTA},		/* user quota (IRIX variant) */
+	{Opt_gquota, MNTOPT_GQUOTA},		/* group quota (IRIX variant) */
+	{Opt_pquota, MNTOPT_PQUOTA},		/* project quota (IRIX variant) */
+	{Opt_uqnoenf, MNTOPT_UQUOTANOENF},	/* user quota limit enforcement */
+	{Opt_gqnoenf, MNTOPT_GQUOTANOENF},	/* group quota limit enforcement */
+	{Opt_pqnoenf, MNTOPT_PQUOTANOENF},	/* project quota limit enforcement */
+	{Opt_qnoenf, MNTOPT_QUOTANOENF},	/* same as uqnoenforce */
+	{Opt_discard, MNTOPT_DISCARD},		/* Discard unused blocks */
+	{Opt_nodiscard, MNTOPT_NODISCARD},	/* Do not discard unused blocks */
+	{Opt_delaylog, MNTOPT_DELAYLOG},	/* deprecated */
+	{Opt_nodelaylog, MNTOPT_NODELAYLOG},	/* deprecated */
+	{Opt_ihashsize, MNTOPT_IHASHSIZE},	/* deprecated */
+	{Opt_osyncisdsync, MNTOPT_OSYNCISDSYNC},/* deprecated */
+	{Opt_osyncisosync, MNTOPT_OSYNCISOSYNC},/* deprecated */
+	{Opt_irixsgid, MNTOPT_IRIXSGID},	/* deprecated */
 	{Opt_err, NULL}
 };
 
-
-STATIC unsigned long
-suffix_strtoul(char *s, char **endp, unsigned int base)
+STATIC int
+suffix_match_int(substring_t *s, unsigned long *result)
 {
-	int	last, shift_left_factor = 0;
-	char	*value = s;
+	int shift_left_factor = 0;
+	char *value = s->to - 1;
+	char *string;
 
-	last = strlen(value) - 1;
-	if (value[last] == 'K' || value[last] == 'k') {
+	if (*value == 'K' || *value == 'k') {
 		shift_left_factor = 10;
-		value[last] = '\0';
+		s->to--;
 	}
-	if (value[last] == 'M' || value[last] == 'm') {
+	if (*value == 'M' || *value == 'm') {
 		shift_left_factor = 20;
-		value[last] = '\0';
+		s->to--;
 	}
-	if (value[last] == 'G' || value[last] == 'g') {
+	if (*value == 'G' || *value == 'g') {
 		shift_left_factor = 30;
-		value[last] = '\0';
+		s->to--;
 	}
 
-	return simple_strtoul((const char *)s, endp, base) << shift_left_factor;
+	string = match_strdup(s);
+	if (!string)
+		return ENOMEM;
+
+	*result = simple_strtoul((const char *)string, NULL, 0) <<
+			shift_left_factor;
+
+	kfree(string);
+	return 0;
+}
+
+STATIC int
+match_name_strdup(substring_t *s, char *name)
+{
+	char *string;
+	int ret = 0;
+	string = match_strdup(s);
+	if (!string)
+		return ENOMEM;
+
+	name = kstrndup(string, MAXNAMELEN, GFP_KERNEL);
+	if (!name)
+		ret = ENOMEM;
+
+	kfree(string);
+	return ret;
 }
 
 /*
@@ -166,11 +246,15 @@ xfs_parseargs(
 	char			*options)
 {
 	struct super_block	*sb = mp->m_super;
-	char			*this_char, *value, *eov;
+	char			*p;
 	int			dsunit = 0;
 	int			dswidth = 0;
-	int			iosize = 0;
 	__uint8_t		iosizelog = 0;
+	int			intarg;
+	unsigned long		ularg;
+	substring_t		args[MAX_OPT_ARGS];
+	char			*orig = NULL;
+	int			ret = 0;
 
 	/*
 	 * set up the mount name first so all the errors will refer to the
@@ -208,175 +292,190 @@ xfs_parseargs(
 	if (!options)
 		goto done;
 
-	while ((this_char = strsep(&options, ",")) != NULL) {
-		if (!*this_char)
+	orig = kstrdup(options, GFP_NOFS);
+	if (!orig) {
+		ret = ENOMEM;
+		goto done;
+	}
+
+	while ((p = strsep(&options, ",")) != NULL) {
+		int token;
+		if (!*p)
 			continue;
-		if ((value = strchr(this_char, '=')) != NULL)
-			*value++ = 0;
-
-		if (!strcmp(this_char, MNTOPT_LOGBUFS)) {
-			if (!value || !*value) {
-				xfs_warn(mp, "%s option requires an argument",
-					this_char);
-				return EINVAL;
-			}
-			mp->m_logbufs = simple_strtoul(value, &eov, 10);
-		} else if (!strcmp(this_char, MNTOPT_LOGBSIZE)) {
-			if (!value || !*value) {
-				xfs_warn(mp, "%s option requires an argument",
-					this_char);
-				return EINVAL;
-			}
-			mp->m_logbsize = suffix_strtoul(value, &eov, 10);
-		} else if (!strcmp(this_char, MNTOPT_LOGDEV)) {
-			if (!value || !*value) {
-				xfs_warn(mp, "%s option requires an argument",
-					this_char);
-				return EINVAL;
-			}
-			mp->m_logname = kstrndup(value, MAXNAMELEN, GFP_KERNEL);
-			if (!mp->m_logname)
-				return ENOMEM;
-		} else if (!strcmp(this_char, MNTOPT_MTPT)) {
-			xfs_warn(mp, "%s option not allowed on this system",
-				this_char);
-			return EINVAL;
-		} else if (!strcmp(this_char, MNTOPT_RTDEV)) {
-			if (!value || !*value) {
-				xfs_warn(mp, "%s option requires an argument",
-					this_char);
-				return EINVAL;
-			}
-			mp->m_rtname = kstrndup(value, MAXNAMELEN, GFP_KERNEL);
-			if (!mp->m_rtname)
-				return ENOMEM;
-		} else if (!strcmp(this_char, MNTOPT_BIOSIZE)) {
-			if (!value || !*value) {
-				xfs_warn(mp, "%s option requires an argument",
-					this_char);
-				return EINVAL;
-			}
-			iosize = simple_strtoul(value, &eov, 10);
-			iosizelog = ffs(iosize) - 1;
-		} else if (!strcmp(this_char, MNTOPT_ALLOCSIZE)) {
-			if (!value || !*value) {
-				xfs_warn(mp, "%s option requires an argument",
-					this_char);
-				return EINVAL;
-			}
-			iosize = suffix_strtoul(value, &eov, 10);
-			iosizelog = ffs(iosize) - 1;
-		} else if (!strcmp(this_char, MNTOPT_GRPID) ||
-			   !strcmp(this_char, MNTOPT_BSDGROUPS)) {
+
+		token = match_token(p, tokens, args);
+		intarg = 0;
+		ularg = 0;
+		switch (token) {
+		case Opt_logbufs:
+			ret = match_int(args, &intarg);
+			if (ret)
+				goto free_orig;
+			mp->m_logbufs = intarg;
+			break;
+		case Opt_logbsize:
+			ret = suffix_match_int(args, &ularg);
+			if (ret)
+				goto free_orig;
+			mp->m_logbsize = ularg;
+			break;
+		case Opt_logdev:
+			ret = match_name_strdup(args, mp->m_logname);
+			if (ret)
+				goto free_orig;
+			break;
+		case Opt_mtpt:
+			xfs_warn(mp, "%s option not allowed on this system", p);
+			ret = EINVAL;
+			goto free_orig;
+		case Opt_rtdev:
+			ret = match_name_strdup(args, mp->m_rtname);
+			if (ret)
+				goto free_orig;
+			break;
+		case Opt_biosize:
+		case Opt_allocsize:
+			ret = suffix_match_int(args, &ularg);
+			if (ret)
+				goto free_orig;
+			iosizelog = ffs(ularg) - 1;
+			break;
+		case Opt_grpid:
+		case Opt_bsdgroups:
 			mp->m_flags |= XFS_MOUNT_GRPID;
-		} else if (!strcmp(this_char, MNTOPT_NOGRPID) ||
-			   !strcmp(this_char, MNTOPT_SYSVGROUPS)) {
+			break;
+		case Opt_nogrpid:
+		case Opt_sysvgroups:
 			mp->m_flags &= ~XFS_MOUNT_GRPID;
-		} else if (!strcmp(this_char, MNTOPT_WSYNC)) {
+			break;
+		case Opt_wsync:
 			mp->m_flags |= XFS_MOUNT_WSYNC;
-		} else if (!strcmp(this_char, MNTOPT_NORECOVERY)) {
+			break;
+		case Opt_norecovery:
 			mp->m_flags |= XFS_MOUNT_NORECOVERY;
-		} else if (!strcmp(this_char, MNTOPT_NOALIGN)) {
+			break;
+		case Opt_noalign:
 			mp->m_flags |= XFS_MOUNT_NOALIGN;
-		} else if (!strcmp(this_char, MNTOPT_SWALLOC)) {
+			break;
+		case Opt_swalloc:
 			mp->m_flags |= XFS_MOUNT_SWALLOC;
-		} else if (!strcmp(this_char, MNTOPT_SUNIT)) {
-			if (!value || !*value) {
-				xfs_warn(mp, "%s option requires an argument",
-					this_char);
-				return EINVAL;
-			}
-			dsunit = simple_strtoul(value, &eov, 10);
-		} else if (!strcmp(this_char, MNTOPT_SWIDTH)) {
-			if (!value || !*value) {
-				xfs_warn(mp, "%s option requires an argument",
-					this_char);
-				return EINVAL;
-			}
-			dswidth = simple_strtoul(value, &eov, 10);
-		} else if (!strcmp(this_char, MNTOPT_64BITINODE)) {
+			break;
+		case Opt_sunit:
+			ret = match_int(args, &intarg);
+			if (ret)
+				goto free_orig;
+			dsunit = intarg;
+			break;
+		case Opt_swidth:
+			ret = match_int(args, &intarg);
+			if (ret)
+				goto free_orig;
+			dswidth = intarg;
+			break;
+		case Opt_inode64:
 			mp->m_flags &= ~XFS_MOUNT_SMALL_INUMS;
 #if !XFS_BIG_INUMS
-			xfs_warn(mp, "%s option not allowed on this system",
-				this_char);
-			return EINVAL;
+			xfs_warn(mp, "%s options not allowed on this system", p);
+			ret = EINVAL;
+			goto free_orig;
 #endif
-		} else if (!strcmp(this_char, MNTOPT_NOUUID)) {
+			break;
+		case Opt_nouuid:
 			mp->m_flags |= XFS_MOUNT_NOUUID;
-		} else if (!strcmp(this_char, MNTOPT_BARRIER)) {
+			break;
+		case Opt_barrier:
 			mp->m_flags |= XFS_MOUNT_BARRIER;
-		} else if (!strcmp(this_char, MNTOPT_NOBARRIER)) {
+			break;
+		case Opt_nobarrier:
 			mp->m_flags &= ~XFS_MOUNT_BARRIER;
-		} else if (!strcmp(this_char, MNTOPT_IKEEP)) {
+			break;
+		case Opt_ikeep:
 			mp->m_flags |= XFS_MOUNT_IKEEP;
-		} else if (!strcmp(this_char, MNTOPT_NOIKEEP)) {
+			break;
+		case Opt_noikeep:
 			mp->m_flags &= ~XFS_MOUNT_IKEEP;
-		} else if (!strcmp(this_char, MNTOPT_LARGEIO)) {
+			break;
+		case Opt_largeio:
 			mp->m_flags &= ~XFS_MOUNT_COMPAT_IOSIZE;
-		} else if (!strcmp(this_char, MNTOPT_NOLARGEIO)) {
+			break;
+		case Opt_nolargeio:
 			mp->m_flags |= XFS_MOUNT_COMPAT_IOSIZE;
-		} else if (!strcmp(this_char, MNTOPT_ATTR2)) {
+			break;
+		case Opt_attr2:
 			mp->m_flags |= XFS_MOUNT_ATTR2;
-		} else if (!strcmp(this_char, MNTOPT_NOATTR2)) {
+			break;
+		case Opt_noattr2:
 			mp->m_flags &= ~XFS_MOUNT_ATTR2;
 			mp->m_flags |= XFS_MOUNT_NOATTR2;
-		} else if (!strcmp(this_char, MNTOPT_FILESTREAM)) {
+			break;
+		case Opt_filestreams:
 			mp->m_flags |= XFS_MOUNT_FILESTREAMS;
-		} else if (!strcmp(this_char, MNTOPT_NOQUOTA)) {
+			break;
+		case Opt_noquota:
 			mp->m_qflags &= ~XFS_ALL_QUOTA_ACCT;
 			mp->m_qflags &= ~XFS_ALL_QUOTA_ENFD;
 			mp->m_qflags &= ~XFS_ALL_QUOTA_ACTIVE;
-		} else if (!strcmp(this_char, MNTOPT_QUOTA) ||
-			   !strcmp(this_char, MNTOPT_UQUOTA) ||
-			   !strcmp(this_char, MNTOPT_USRQUOTA)) {
+			break;
+		case Opt_quota:
+		case Opt_uquota:
+		case Opt_usrquota:
 			mp->m_qflags |= (XFS_UQUOTA_ACCT | XFS_UQUOTA_ACTIVE |
 					 XFS_UQUOTA_ENFD);
-		} else if (!strcmp(this_char, MNTOPT_QUOTANOENF) ||
-			   !strcmp(this_char, MNTOPT_UQUOTANOENF)) {
+			break;
+		case Opt_qnoenf:
+		case Opt_uqnoenf:
 			mp->m_qflags |= (XFS_UQUOTA_ACCT | XFS_UQUOTA_ACTIVE);
 			mp->m_qflags &= ~XFS_UQUOTA_ENFD;
-		} else if (!strcmp(this_char, MNTOPT_PQUOTA) ||
-			   !strcmp(this_char, MNTOPT_PRJQUOTA)) {
+			break;
+		case Opt_pquota:
+		case Opt_prjquota:
 			mp->m_qflags |= (XFS_PQUOTA_ACCT | XFS_PQUOTA_ACTIVE |
 					 XFS_OQUOTA_ENFD);
-		} else if (!strcmp(this_char, MNTOPT_PQUOTANOENF)) {
+			break;
+		case Opt_pqnoenf:
 			mp->m_qflags |= (XFS_PQUOTA_ACCT | XFS_PQUOTA_ACTIVE);
 			mp->m_qflags &= ~XFS_OQUOTA_ENFD;
-		} else if (!strcmp(this_char, MNTOPT_GQUOTA) ||
-			   !strcmp(this_char, MNTOPT_GRPQUOTA)) {
+			break;
+		case Opt_gquota:
+		case Opt_grpquota:
 			mp->m_qflags |= (XFS_GQUOTA_ACCT | XFS_GQUOTA_ACTIVE |
 					 XFS_OQUOTA_ENFD);
-		} else if (!strcmp(this_char, MNTOPT_GQUOTANOENF)) {
+			break;
+		case Opt_gqnoenf:
 			mp->m_qflags |= (XFS_GQUOTA_ACCT | XFS_GQUOTA_ACTIVE);
 			mp->m_qflags &= ~XFS_OQUOTA_ENFD;
-		} else if (!strcmp(this_char, MNTOPT_DELAYLOG)) {
-			xfs_warn(mp,
-	"delaylog is the default now, option is deprecated.");
-		} else if (!strcmp(this_char, MNTOPT_NODELAYLOG)) {
-			xfs_warn(mp,
-	"nodelaylog support has been removed, option is deprecated.");
-		} else if (!strcmp(this_char, MNTOPT_DISCARD)) {
+			break;
+		case Opt_discard:
 			mp->m_flags |= XFS_MOUNT_DISCARD;
-		} else if (!strcmp(this_char, MNTOPT_NODISCARD)) {
+			break;
+		case Opt_nodiscard:
 			mp->m_flags &= ~XFS_MOUNT_DISCARD;
-		} else if (!strcmp(this_char, "ihashsize")) {
-			xfs_warn(mp,
-	"ihashsize no longer used, option is deprecated.");
-		} else if (!strcmp(this_char, "osyncisdsync")) {
-			xfs_warn(mp,
-	"osyncisdsync has no effect, option is deprecated.");
-		} else if (!strcmp(this_char, "osyncisosync")) {
-			xfs_warn(mp,
-	"osyncisosync has no effect, option is deprecated.");
-		} else if (!strcmp(this_char, "irixsgid")) {
-			xfs_warn(mp,
-	"irixsgid is now a sysctl(2) variable, option is deprecated.");
-		} else {
-			xfs_warn(mp, "unknown mount option [%s].", this_char);
-			return EINVAL;
+			break;
+		case Opt_delaylog:
+			xfs_warn(mp, MNTOPT_DELAYLOG MNTOPT_DEPRECATED);
+			break;
+		case Opt_nodelaylog:
+			xfs_warn(mp, MNTOPT_NODELAYLOG MNTOPT_DEPRECATED);
+			break;
+		case Opt_ihashsize:
+			xfs_warn(mp, MNTOPT_IHASHSIZE MNTOPT_DEPRECATED);
+		case Opt_osyncisdsync:
+			xfs_warn(mp, MNTOPT_OSYNCISDSYNC MNTOPT_DEPRECATED);
+			break;
+		case Opt_osyncisosync:
+			xfs_warn(mp, MNTOPT_OSYNCISOSYNC MNTOPT_DEPRECATED);
+			break;
+		case Opt_irixsgid:
+			xfs_warn(mp, MNTOPT_IRIXSGID MNTOPT_DEPRECATED);
+			break;
+		default:
+			xfs_warn(mp, "unknown mount option [%s].", p);
+			break;
 		}
 	}
 
+	kfree(orig);
+
 	/*
 	 * no recovery flag requires a read-only mount
 	 */
@@ -468,6 +567,10 @@ done:
 	}
 
 	return 0;
+
+free_orig:
+	kfree(orig);
+	return ret;
 }
 
 struct proc_xfs_info {
@@ -476,10 +579,12 @@ struct proc_xfs_info {
 };
 
 STATIC int
-xfs_showargs(
-	struct xfs_mount	*mp,
-	struct seq_file		*m)
+xfs_fs_show_options(
+	struct seq_file		*seq,
+	struct dentry		*dentry)
 {
+	struct xfs_mount	*mp = XFS_M(dentry->d_sb);
+
 	static struct proc_xfs_info xfs_info_set[] = {
 		/* the few simple ones we can get from the mount struct */
 		{ XFS_MOUNT_IKEEP,		"," MNTOPT_IKEEP },
@@ -505,58 +610,60 @@ xfs_showargs(
 
 	for (xfs_infop = xfs_info_set; xfs_infop->flag; xfs_infop++) {
 		if (mp->m_flags & xfs_infop->flag)
-			seq_puts(m, xfs_infop->str);
+			seq_puts(seq, xfs_infop->str);
 	}
 	for (xfs_infop = xfs_info_unset; xfs_infop->flag; xfs_infop++) {
 		if (!(mp->m_flags & xfs_infop->flag))
-			seq_puts(m, xfs_infop->str);
+			seq_puts(seq, xfs_infop->str);
 	}
 
 	if (mp->m_flags & XFS_MOUNT_DFLT_IOSIZE)
-		seq_printf(m, "," MNTOPT_ALLOCSIZE "=%dk",
-				(int)(1 << mp->m_writeio_log) >> 10);
+		seq_printf(seq, "," MNTOPT_ALLOCSIZE "=%d",
+				(int)(1 << mp->m_writeio_log));
 
 	if (mp->m_logbufs > 0)
-		seq_printf(m, "," MNTOPT_LOGBUFS "=%d", mp->m_logbufs);
+		seq_printf(seq, "," MNTOPT_LOGBUFS "=%d", mp->m_logbufs);
 	if (mp->m_logbsize > 0)
-		seq_printf(m, "," MNTOPT_LOGBSIZE "=%dk", mp->m_logbsize >> 10);
+		seq_printf(seq, "," MNTOPT_LOGBSIZE "=%d",
+				mp->m_logbsize);
 
 	if (mp->m_logname)
-		seq_printf(m, "," MNTOPT_LOGDEV "=%s", mp->m_logname);
+		seq_printf(seq, "," MNTOPT_LOGDEV "=%s", mp->m_logname);
 	if (mp->m_rtname)
-		seq_printf(m, "," MNTOPT_RTDEV "=%s", mp->m_rtname);
+		seq_printf(seq, "," MNTOPT_RTDEV "=%s", mp->m_rtname);
 
 	if (mp->m_dalign > 0)
-		seq_printf(m, "," MNTOPT_SUNIT "=%d",
+		seq_printf(seq, "," MNTOPT_SUNIT "=%d",
 				(int)XFS_FSB_TO_BB(mp, mp->m_dalign));
 	if (mp->m_swidth > 0)
-		seq_printf(m, "," MNTOPT_SWIDTH "=%d",
+		seq_printf(seq, "," MNTOPT_SWIDTH "=%d",
 				(int)XFS_FSB_TO_BB(mp, mp->m_swidth));
 
 	if (mp->m_qflags & (XFS_UQUOTA_ACCT|XFS_UQUOTA_ENFD))
-		seq_puts(m, "," MNTOPT_USRQUOTA);
+		seq_puts(seq, "," MNTOPT_USRQUOTA);
 	else if (mp->m_qflags & XFS_UQUOTA_ACCT)
-		seq_puts(m, "," MNTOPT_UQUOTANOENF);
+		seq_puts(seq, "," MNTOPT_UQUOTANOENF);
 
 	/* Either project or group quotas can be active, not both */
 
 	if (mp->m_qflags & XFS_PQUOTA_ACCT) {
 		if (mp->m_qflags & XFS_OQUOTA_ENFD)
-			seq_puts(m, "," MNTOPT_PRJQUOTA);
+			seq_puts(seq, "," MNTOPT_PRJQUOTA);
 		else
-			seq_puts(m, "," MNTOPT_PQUOTANOENF);
+			seq_puts(seq, "," MNTOPT_PQUOTANOENF);
 	} else if (mp->m_qflags & XFS_GQUOTA_ACCT) {
 		if (mp->m_qflags & XFS_OQUOTA_ENFD)
-			seq_puts(m, "," MNTOPT_GRPQUOTA);
+			seq_puts(seq, "," MNTOPT_GRPQUOTA);
 		else
-			seq_puts(m, "," MNTOPT_GQUOTANOENF);
+			seq_puts(seq, "," MNTOPT_GQUOTANOENF);
 	}
 
 	if (!(mp->m_qflags & XFS_ALL_QUOTA_ACCT))
-		seq_puts(m, "," MNTOPT_NOQUOTA);
+		seq_puts(seq, "," MNTOPT_NOQUOTA);
 
 	return 0;
 }
+
 __uint64_t
 xfs_max_file_offset(
 	unsigned int		blockshift)
@@ -1221,14 +1328,6 @@ xfs_fs_unfreeze(
 	return 0;
 }
 
-STATIC int
-xfs_fs_show_options(
-	struct seq_file		*m,
-	struct dentry		*root)
-{
-	return -xfs_showargs(XFS_M(root->d_sb), m);
-}
-
 /*
  * This function fills in xfs_mount_t fields based on mount args.
  * Note: the superblock _has_ now been read in.
-- 
1.7.11.3.287.ge771946

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

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

* Re: [PATCH V5] xfs: cleanup the mount options
  2012-07-24  2:01                     ` Wanlong Gao
@ 2012-07-24 21:18                       ` Dave Chinner
  2012-07-25  1:09                         ` Wanlong Gao
  2012-07-25  1:11                         ` [PATCH V7] " Wanlong Gao
  0 siblings, 2 replies; 31+ messages in thread
From: Dave Chinner @ 2012-07-24 21:18 UTC (permalink / raw)
  To: Wanlong Gao; +Cc: Christoph Hellwig, Ben Myers, Zach Brown, xfs

On Tue, Jul 24, 2012 at 10:01:59AM +0800, Wanlong Gao wrote:
> On 07/24/2012 07:28 AM, Dave Chinner wrote:
> > On Wed, Jul 11, 2012 at 02:29:05PM +0800, Wanlong Gao wrote:
> >> @@ -208,175 +292,192 @@ xfs_parseargs(
> >>  	if (!options)
> >>  		goto done;
> >>  
> >> -	while ((this_char = strsep(&options, ",")) != NULL) {
> >> -		if (!*this_char)
> >> +	options = kstrdup(options, GFP_NOFS);
> > 
> > GFP_NOFS allocation. Why is this GFP_NOFS, and all the other
> > allocations GFP_KERNEL? If it is not safe to use GFP_KERNEL
> > allocations here, then all of the above allocations need to be
> > GFP_NOFS, too.
> 
> Since strsep() will change the options, so we should make GFP_NOFS
> safely to dup the orig options, but the parse functions can safely
> use GFP_KERNEL.

I unerstand why you are using kstrdup(). My question is why are you
using GFP_NOFS here? What filesystem recursion deadlock are you
tryin gto avoid here, and why don't the other allocations in the
string parsing need to avoid the same problem as they are called
from the same context?

If there is no recursion deadlock (I can't see that there is one),
then GFP_KERNEL is what you should be using here....

Cheers,

Dave.
-- 
Dave Chinner
david@fromorbit.com

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

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

* Re: [PATCH V5] xfs: cleanup the mount options
  2012-07-24 21:18                       ` Dave Chinner
@ 2012-07-25  1:09                         ` Wanlong Gao
  2012-07-25  1:11                         ` [PATCH V7] " Wanlong Gao
  1 sibling, 0 replies; 31+ messages in thread
From: Wanlong Gao @ 2012-07-25  1:09 UTC (permalink / raw)
  To: Dave Chinner; +Cc: Christoph Hellwig, Ben Myers, Zach Brown, xfs

On 07/25/2012 05:18 AM, Dave Chinner wrote:
> On Tue, Jul 24, 2012 at 10:01:59AM +0800, Wanlong Gao wrote:
>> On 07/24/2012 07:28 AM, Dave Chinner wrote:
>>> On Wed, Jul 11, 2012 at 02:29:05PM +0800, Wanlong Gao wrote:
>>>> @@ -208,175 +292,192 @@ xfs_parseargs(
>>>>  	if (!options)
>>>>  		goto done;
>>>>  
>>>> -	while ((this_char = strsep(&options, ",")) != NULL) {
>>>> -		if (!*this_char)
>>>> +	options = kstrdup(options, GFP_NOFS);
>>>
>>> GFP_NOFS allocation. Why is this GFP_NOFS, and all the other
>>> allocations GFP_KERNEL? If it is not safe to use GFP_KERNEL
>>> allocations here, then all of the above allocations need to be
>>> GFP_NOFS, too.
>>
>> Since strsep() will change the options, so we should make GFP_NOFS
>> safely to dup the orig options, but the parse functions can safely
>> use GFP_KERNEL.
> 
> I unerstand why you are using kstrdup(). My question is why are you
> using GFP_NOFS here? What filesystem recursion deadlock are you
> tryin gto avoid here, and why don't the other allocations in the
> string parsing need to avoid the same problem as they are called
> from the same context?
> 
> If there is no recursion deadlock (I can't see that there is one),
> then GFP_KERNEL is what you should be using here....
> 

Sorry, I have no strong reason, so will use GFP_KERNEL instead.

Thanks,
Wanlong Gao

> Cheers,
> 
> Dave.
> 

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

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

* [PATCH V7] xfs: cleanup the mount options
  2012-07-24 21:18                       ` Dave Chinner
  2012-07-25  1:09                         ` Wanlong Gao
@ 2012-07-25  1:11                         ` Wanlong Gao
  2012-07-29 22:09                           ` Dave Chinner
  2012-08-28 19:38                           ` Ben Myers
  1 sibling, 2 replies; 31+ messages in thread
From: Wanlong Gao @ 2012-07-25  1:11 UTC (permalink / raw)
  To: xfs; +Cc: Christoph Hellwig, Ben Myers, Zach Brown, Wanlong Gao

remove the mount options macro, use tokens instead.

change from V6: (Dave)
1. switch GFP_NOFS to GFP_KERNEL

change from V5: (Dave)
1. fix a string leak.
2. leave the show options to raw numbers.

change from V4: (as Dave suggested)
1. suffix_match_int avoid overflow.
2. convert the return style to be consistent with others.
3. move the "intarg" init above the switch.
4. move match_strdup to a help function.
5. collapsed Opt_biosize and Opt_allocsize.
6. make a consistent deprecated message.

CC: Ben Myers <bpm@sgi.com>
CC: Christoph Hellwig <hch@infradead.org>
CC: Dave Chinner <david@fromorbit.com>
CC: Zach Brown <zab@zabbo.net>
Signed-off-by: Wanlong Gao <gaowanlong@cn.fujitsu.com>
---
 fs/xfs/xfs_super.c | 551 +++++++++++++++++++++++++++++++----------------------
 1 file changed, 325 insertions(+), 226 deletions(-)

diff --git a/fs/xfs/xfs_super.c b/fs/xfs/xfs_super.c
index cb2deb1..336a210 100644
--- a/fs/xfs/xfs_super.c
+++ b/fs/xfs/xfs_super.c
@@ -66,91 +66,171 @@ static const struct super_operations xfs_super_operations;
 static kmem_zone_t *xfs_ioend_zone;
 mempool_t *xfs_ioend_pool;
 
-#define MNTOPT_LOGBUFS	"logbufs"	/* number of XFS log buffers */
-#define MNTOPT_LOGBSIZE	"logbsize"	/* size of XFS log buffers */
-#define MNTOPT_LOGDEV	"logdev"	/* log device */
-#define MNTOPT_RTDEV	"rtdev"		/* realtime I/O device */
-#define MNTOPT_BIOSIZE	"biosize"	/* log2 of preferred buffered io size */
-#define MNTOPT_WSYNC	"wsync"		/* safe-mode nfs compatible mount */
-#define MNTOPT_NOALIGN	"noalign"	/* turn off stripe alignment */
-#define MNTOPT_SWALLOC	"swalloc"	/* turn on stripe width allocation */
-#define MNTOPT_SUNIT	"sunit"		/* data volume stripe unit */
-#define MNTOPT_SWIDTH	"swidth"	/* data volume stripe width */
-#define MNTOPT_NOUUID	"nouuid"	/* ignore filesystem UUID */
-#define MNTOPT_MTPT	"mtpt"		/* filesystem mount point */
-#define MNTOPT_GRPID	"grpid"		/* group-ID from parent directory */
-#define MNTOPT_NOGRPID	"nogrpid"	/* group-ID from current process */
-#define MNTOPT_BSDGROUPS    "bsdgroups"    /* group-ID from parent directory */
-#define MNTOPT_SYSVGROUPS   "sysvgroups"   /* group-ID from current process */
-#define MNTOPT_ALLOCSIZE    "allocsize"    /* preferred allocation size */
-#define MNTOPT_NORECOVERY   "norecovery"   /* don't run XFS recovery */
-#define MNTOPT_BARRIER	"barrier"	/* use writer barriers for log write and
-					 * unwritten extent conversion */
-#define MNTOPT_NOBARRIER "nobarrier"	/* .. disable */
-#define MNTOPT_64BITINODE   "inode64"	/* inodes can be allocated anywhere */
-#define MNTOPT_IKEEP	"ikeep"		/* do not free empty inode clusters */
-#define MNTOPT_NOIKEEP	"noikeep"	/* free empty inode clusters */
-#define MNTOPT_LARGEIO	   "largeio"	/* report large I/O sizes in stat() */
-#define MNTOPT_NOLARGEIO   "nolargeio"	/* do not report large I/O sizes
-					 * in stat(). */
-#define MNTOPT_ATTR2	"attr2"		/* do use attr2 attribute format */
-#define MNTOPT_NOATTR2	"noattr2"	/* do not use attr2 attribute format */
-#define MNTOPT_FILESTREAM  "filestreams" /* use filestreams allocator */
-#define MNTOPT_QUOTA	"quota"		/* disk quotas (user) */
-#define MNTOPT_NOQUOTA	"noquota"	/* no quotas */
-#define MNTOPT_USRQUOTA	"usrquota"	/* user quota enabled */
-#define MNTOPT_GRPQUOTA	"grpquota"	/* group quota enabled */
-#define MNTOPT_PRJQUOTA	"prjquota"	/* project quota enabled */
-#define MNTOPT_UQUOTA	"uquota"	/* user quota (IRIX variant) */
-#define MNTOPT_GQUOTA	"gquota"	/* group quota (IRIX variant) */
-#define MNTOPT_PQUOTA	"pquota"	/* project quota (IRIX variant) */
-#define MNTOPT_UQUOTANOENF "uqnoenforce"/* user quota limit enforcement */
-#define MNTOPT_GQUOTANOENF "gqnoenforce"/* group quota limit enforcement */
-#define MNTOPT_PQUOTANOENF "pqnoenforce"/* project quota limit enforcement */
-#define MNTOPT_QUOTANOENF  "qnoenforce"	/* same as uqnoenforce */
-#define MNTOPT_DELAYLOG    "delaylog"	/* Delayed logging enabled */
-#define MNTOPT_NODELAYLOG  "nodelaylog"	/* Delayed logging disabled */
-#define MNTOPT_DISCARD	   "discard"	/* Discard unused blocks */
-#define MNTOPT_NODISCARD   "nodiscard"	/* Do not discard unused blocks */
+#define	MNTOPT_LOGBUFS		"logbufs"
+#define	MNTOPT_LOGBSIZE		"logbsize"
+#define	MNTOPT_LOGDEV		"logdev"
+#define	MNTOPT_RTDEV		"rtdev"
+#define	MNTOPT_BIOSIZE		"biosize"
+#define	MNTOPT_WSYNC		"wsync"
+#define	MNTOPT_NOALIGN		"noalign"
+#define	MNTOPT_SWALLOC		"swalloc"
+#define	MNTOPT_SUNIT		"sunit"
+#define	MNTOPT_SWIDTH		"swidth"
+#define	MNTOPT_NOUUID		"nouuid"
+#define	MNTOPT_MTPT		"mtpt"
+#define	MNTOPT_GRPID		"grpid"
+#define	MNTOPT_NOGRPID		"nogrpid"
+#define	MNTOPT_BSDGROUPS	"bsdgroups"
+#define	MNTOPT_SYSVGROUPS	"sysvgroups"
+#define	MNTOPT_ALLOCSIZE	"allocsize"
+#define	MNTOPT_NORECOVERY	"norecovery"
+#define	MNTOPT_BARRIER		"barrier"
+#define	MNTOPT_NOBARRIER	"nobarrier"
+#define	MNTOPT_64BITINODE	"inode64"
+#define	MNTOPT_IKEEP		"ikeep"
+#define	MNTOPT_NOIKEEP		"noikeep"
+#define	MNTOPT_LARGEIO		"largeio"
+#define	MNTOPT_NOLARGEIO	"nolargeio"
+#define	MNTOPT_ATTR2		"attr2"
+#define	MNTOPT_NOATTR2		"noattr2"
+#define	MNTOPT_FILESTREAM	"filestreams"
+#define	MNTOPT_QUOTA		"quota"
+#define	MNTOPT_NOQUOTA		"noquota"
+#define	MNTOPT_USRQUOTA		"usrquota"
+#define	MNTOPT_GRPQUOTA		"grpquota"
+#define	MNTOPT_PRJQUOTA		"prjquota"
+#define	MNTOPT_UQUOTA		"uquota"
+#define	MNTOPT_GQUOTA		"gquota"
+#define	MNTOPT_PQUOTA		"pquota"
+#define	MNTOPT_UQUOTANOENF	"uqnoenforce"
+#define	MNTOPT_GQUOTANOENF	"gqnoenforce"
+#define	MNTOPT_PQUOTANOENF	"pqnoenforce"
+#define	MNTOPT_QUOTANOENF	"qnoenforce"
+#define	MNTOPT_DISCARD		"discard"
+#define	MNTOPT_NODISCARD	"nodiscard"
+#define	MNTOPT_DELAYLOG		"delaylog"
+#define	MNTOPT_NODELAYLOG	"nodelaylog"
+#define	MNTOPT_IHASHSIZE	"ihashsize"
+#define	MNTOPT_OSYNCISDSYNC	"osyncisdsync"
+#define	MNTOPT_OSYNCISOSYNC	"osyncisosync"
+#define	MNTOPT_IRIXSGID		"irixsgid"
+
+#define MNTOPT_DEPRECATED "has no effect, option is deprecated"
 
-/*
- * Table driven mount option parser.
- *
- * Currently only used for remount, but it will be used for mount
- * in the future, too.
- */
 enum {
-	Opt_barrier, Opt_nobarrier, Opt_err
+	Opt_logbufs, Opt_logbsize, Opt_logdev, Opt_rtdev, Opt_biosize,
+	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_inode64, Opt_ikeep, Opt_noikeep, Opt_largeio,
+	Opt_nolargeio, Opt_attr2, Opt_noattr2, Opt_filestreams, Opt_quota,
+	Opt_noquota, Opt_usrquota, Opt_grpquota, Opt_prjquota, Opt_uquota,
+	Opt_gquota, Opt_pquota, Opt_uqnoenf, Opt_gqnoenf, Opt_pqnoenf,
+	Opt_qnoenf, Opt_discard, Opt_nodiscard, Opt_delaylog, Opt_nodelaylog,
+	Opt_ihashsize, Opt_osyncisdsync, Opt_osyncisosync, Opt_irixsgid,
+	Opt_err
 };
 
 static const match_table_t tokens = {
-	{Opt_barrier, "barrier"},
-	{Opt_nobarrier, "nobarrier"},
+	{Opt_logbufs, MNTOPT_LOGBUFS "=%d"},	/* number of XFS log buffers */
+	{Opt_logbsize, MNTOPT_LOGBSIZE "=%s"},	/* size of XFS log buffers */
+	{Opt_logdev, MNTOPT_LOGDEV "=%s"},	/* log device */
+	{Opt_rtdev, MNTOPT_RTDEV "=%s"},	/* realtime I/O device */
+	{Opt_biosize, MNTOPT_BIOSIZE "=%d"},	/* log2 of preferred buffered io size */
+	{Opt_wsync, MNTOPT_WSYNC},		/* safe-mode nfs compatible mount */
+	{Opt_noalign, MNTOPT_NOALIGN},		/* turn off stripe alignment */
+	{Opt_swalloc, MNTOPT_SWALLOC},		/* turn on stripe width allocation */
+	{Opt_sunit, MNTOPT_SUNIT "=%d"},	/* data volume stripe unit */
+	{Opt_swidth, MNTOPT_SWIDTH "=%d"},	/* data volume stripe width */
+	{Opt_nouuid, MNTOPT_NOUUID},		/* ignore filesystem UUID */
+	{Opt_mtpt, MNTOPT_MTPT},		/* filesystem mount point */
+	{Opt_grpid, MNTOPT_GRPID},		/* group-ID from parent directory */
+	{Opt_nogrpid, MNTOPT_NOGRPID},		/* group-ID from current process */
+	{Opt_bsdgroups, MNTOPT_BSDGROUPS},	/* group-ID from parent directory */
+	{Opt_sysvgroups, MNTOPT_SYSVGROUPS},	/* group-ID from current process */
+	{Opt_allocsize, MNTOPT_ALLOCSIZE "=%s"},/* preferred allocation size */
+	{Opt_norecovery, MNTOPT_NORECOVERY},	/* do not run XFS recovery */
+	{Opt_barrier, MNTOPT_BARRIER},		/* use writer barrier for log write and
+						 * unwritten extent conversation */
+	{Opt_nobarrier, MNTOPT_NOBARRIER},	/* .. disable */
+	{Opt_inode64, MNTOPT_64BITINODE},	/* inodes can be allocated anywhere */
+	{Opt_ikeep, MNTOPT_IKEEP},		/* do not free empty inode clusters */
+	{Opt_noikeep, MNTOPT_NOIKEEP},		/* free empty inode clusters */
+	{Opt_largeio, MNTOPT_LARGEIO},		/* report large I/O sizes in start() */
+	{Opt_nolargeio, MNTOPT_NOLARGEIO},	/* do not report large I/O sizes
+						 * in start() */
+	{Opt_attr2, MNTOPT_ATTR2},		/* do use attr2 attribute format */
+	{Opt_noattr2, MNTOPT_NOATTR2},		/* do not use attr2 attribute format */
+	{Opt_filestreams, MNTOPT_FILESTREAM}, 	/* use filestreams allocator */
+	{Opt_quota, MNTOPT_QUOTA},		/* disk quotas (user) */
+	{Opt_noquota, MNTOPT_NOQUOTA},		/* no quotas */
+	{Opt_usrquota, MNTOPT_USRQUOTA},	/* user quota enabled */
+	{Opt_grpquota, MNTOPT_GRPQUOTA},	/* group quota enabled */
+	{Opt_prjquota, MNTOPT_PRJQUOTA},	/* project quota enabled */
+	{Opt_uquota, MNTOPT_UQUOTA},		/* user quota (IRIX variant) */
+	{Opt_gquota, MNTOPT_GQUOTA},		/* group quota (IRIX variant) */
+	{Opt_pquota, MNTOPT_PQUOTA},		/* project quota (IRIX variant) */
+	{Opt_uqnoenf, MNTOPT_UQUOTANOENF},	/* user quota limit enforcement */
+	{Opt_gqnoenf, MNTOPT_GQUOTANOENF},	/* group quota limit enforcement */
+	{Opt_pqnoenf, MNTOPT_PQUOTANOENF},	/* project quota limit enforcement */
+	{Opt_qnoenf, MNTOPT_QUOTANOENF},	/* same as uqnoenforce */
+	{Opt_discard, MNTOPT_DISCARD},		/* Discard unused blocks */
+	{Opt_nodiscard, MNTOPT_NODISCARD},	/* Do not discard unused blocks */
+	{Opt_delaylog, MNTOPT_DELAYLOG},	/* deprecated */
+	{Opt_nodelaylog, MNTOPT_NODELAYLOG},	/* deprecated */
+	{Opt_ihashsize, MNTOPT_IHASHSIZE},	/* deprecated */
+	{Opt_osyncisdsync, MNTOPT_OSYNCISDSYNC},/* deprecated */
+	{Opt_osyncisosync, MNTOPT_OSYNCISOSYNC},/* deprecated */
+	{Opt_irixsgid, MNTOPT_IRIXSGID},	/* deprecated */
 	{Opt_err, NULL}
 };
 
-
-STATIC unsigned long
-suffix_strtoul(char *s, char **endp, unsigned int base)
+STATIC int
+suffix_match_int(substring_t *s, unsigned long *result)
 {
-	int	last, shift_left_factor = 0;
-	char	*value = s;
+	int shift_left_factor = 0;
+	char *value = s->to - 1;
+	char *string;
 
-	last = strlen(value) - 1;
-	if (value[last] == 'K' || value[last] == 'k') {
+	if (*value == 'K' || *value == 'k') {
 		shift_left_factor = 10;
-		value[last] = '\0';
+		s->to--;
 	}
-	if (value[last] == 'M' || value[last] == 'm') {
+	if (*value == 'M' || *value == 'm') {
 		shift_left_factor = 20;
-		value[last] = '\0';
+		s->to--;
 	}
-	if (value[last] == 'G' || value[last] == 'g') {
+	if (*value == 'G' || *value == 'g') {
 		shift_left_factor = 30;
-		value[last] = '\0';
+		s->to--;
 	}
 
-	return simple_strtoul((const char *)s, endp, base) << shift_left_factor;
+	string = match_strdup(s);
+	if (!string)
+		return ENOMEM;
+
+	*result = simple_strtoul((const char *)string, NULL, 0) <<
+			shift_left_factor;
+
+	kfree(string);
+	return 0;
+}
+
+STATIC int
+match_name_strdup(substring_t *s, char *name)
+{
+	char *string;
+	int ret = 0;
+	string = match_strdup(s);
+	if (!string)
+		return ENOMEM;
+
+	name = kstrndup(string, MAXNAMELEN, GFP_KERNEL);
+	if (!name)
+		ret = ENOMEM;
+
+	kfree(string);
+	return ret;
 }
 
 /*
@@ -166,11 +246,15 @@ xfs_parseargs(
 	char			*options)
 {
 	struct super_block	*sb = mp->m_super;
-	char			*this_char, *value, *eov;
+	char			*p;
 	int			dsunit = 0;
 	int			dswidth = 0;
-	int			iosize = 0;
 	__uint8_t		iosizelog = 0;
+	int			intarg;
+	unsigned long		ularg;
+	substring_t		args[MAX_OPT_ARGS];
+	char			*orig = NULL;
+	int			ret = 0;
 
 	/*
 	 * set up the mount name first so all the errors will refer to the
@@ -208,175 +292,190 @@ xfs_parseargs(
 	if (!options)
 		goto done;
 
-	while ((this_char = strsep(&options, ",")) != NULL) {
-		if (!*this_char)
+	orig = kstrdup(options, GFP_KERNEL);
+	if (!orig) {
+		ret = ENOMEM;
+		goto done;
+	}
+
+	while ((p = strsep(&options, ",")) != NULL) {
+		int token;
+		if (!*p)
 			continue;
-		if ((value = strchr(this_char, '=')) != NULL)
-			*value++ = 0;
-
-		if (!strcmp(this_char, MNTOPT_LOGBUFS)) {
-			if (!value || !*value) {
-				xfs_warn(mp, "%s option requires an argument",
-					this_char);
-				return EINVAL;
-			}
-			mp->m_logbufs = simple_strtoul(value, &eov, 10);
-		} else if (!strcmp(this_char, MNTOPT_LOGBSIZE)) {
-			if (!value || !*value) {
-				xfs_warn(mp, "%s option requires an argument",
-					this_char);
-				return EINVAL;
-			}
-			mp->m_logbsize = suffix_strtoul(value, &eov, 10);
-		} else if (!strcmp(this_char, MNTOPT_LOGDEV)) {
-			if (!value || !*value) {
-				xfs_warn(mp, "%s option requires an argument",
-					this_char);
-				return EINVAL;
-			}
-			mp->m_logname = kstrndup(value, MAXNAMELEN, GFP_KERNEL);
-			if (!mp->m_logname)
-				return ENOMEM;
-		} else if (!strcmp(this_char, MNTOPT_MTPT)) {
-			xfs_warn(mp, "%s option not allowed on this system",
-				this_char);
-			return EINVAL;
-		} else if (!strcmp(this_char, MNTOPT_RTDEV)) {
-			if (!value || !*value) {
-				xfs_warn(mp, "%s option requires an argument",
-					this_char);
-				return EINVAL;
-			}
-			mp->m_rtname = kstrndup(value, MAXNAMELEN, GFP_KERNEL);
-			if (!mp->m_rtname)
-				return ENOMEM;
-		} else if (!strcmp(this_char, MNTOPT_BIOSIZE)) {
-			if (!value || !*value) {
-				xfs_warn(mp, "%s option requires an argument",
-					this_char);
-				return EINVAL;
-			}
-			iosize = simple_strtoul(value, &eov, 10);
-			iosizelog = ffs(iosize) - 1;
-		} else if (!strcmp(this_char, MNTOPT_ALLOCSIZE)) {
-			if (!value || !*value) {
-				xfs_warn(mp, "%s option requires an argument",
-					this_char);
-				return EINVAL;
-			}
-			iosize = suffix_strtoul(value, &eov, 10);
-			iosizelog = ffs(iosize) - 1;
-		} else if (!strcmp(this_char, MNTOPT_GRPID) ||
-			   !strcmp(this_char, MNTOPT_BSDGROUPS)) {
+
+		token = match_token(p, tokens, args);
+		intarg = 0;
+		ularg = 0;
+		switch (token) {
+		case Opt_logbufs:
+			ret = match_int(args, &intarg);
+			if (ret)
+				goto free_orig;
+			mp->m_logbufs = intarg;
+			break;
+		case Opt_logbsize:
+			ret = suffix_match_int(args, &ularg);
+			if (ret)
+				goto free_orig;
+			mp->m_logbsize = ularg;
+			break;
+		case Opt_logdev:
+			ret = match_name_strdup(args, mp->m_logname);
+			if (ret)
+				goto free_orig;
+			break;
+		case Opt_mtpt:
+			xfs_warn(mp, "%s option not allowed on this system", p);
+			ret = EINVAL;
+			goto free_orig;
+		case Opt_rtdev:
+			ret = match_name_strdup(args, mp->m_rtname);
+			if (ret)
+				goto free_orig;
+			break;
+		case Opt_biosize:
+		case Opt_allocsize:
+			ret = suffix_match_int(args, &ularg);
+			if (ret)
+				goto free_orig;
+			iosizelog = ffs(ularg) - 1;
+			break;
+		case Opt_grpid:
+		case Opt_bsdgroups:
 			mp->m_flags |= XFS_MOUNT_GRPID;
-		} else if (!strcmp(this_char, MNTOPT_NOGRPID) ||
-			   !strcmp(this_char, MNTOPT_SYSVGROUPS)) {
+			break;
+		case Opt_nogrpid:
+		case Opt_sysvgroups:
 			mp->m_flags &= ~XFS_MOUNT_GRPID;
-		} else if (!strcmp(this_char, MNTOPT_WSYNC)) {
+			break;
+		case Opt_wsync:
 			mp->m_flags |= XFS_MOUNT_WSYNC;
-		} else if (!strcmp(this_char, MNTOPT_NORECOVERY)) {
+			break;
+		case Opt_norecovery:
 			mp->m_flags |= XFS_MOUNT_NORECOVERY;
-		} else if (!strcmp(this_char, MNTOPT_NOALIGN)) {
+			break;
+		case Opt_noalign:
 			mp->m_flags |= XFS_MOUNT_NOALIGN;
-		} else if (!strcmp(this_char, MNTOPT_SWALLOC)) {
+			break;
+		case Opt_swalloc:
 			mp->m_flags |= XFS_MOUNT_SWALLOC;
-		} else if (!strcmp(this_char, MNTOPT_SUNIT)) {
-			if (!value || !*value) {
-				xfs_warn(mp, "%s option requires an argument",
-					this_char);
-				return EINVAL;
-			}
-			dsunit = simple_strtoul(value, &eov, 10);
-		} else if (!strcmp(this_char, MNTOPT_SWIDTH)) {
-			if (!value || !*value) {
-				xfs_warn(mp, "%s option requires an argument",
-					this_char);
-				return EINVAL;
-			}
-			dswidth = simple_strtoul(value, &eov, 10);
-		} else if (!strcmp(this_char, MNTOPT_64BITINODE)) {
+			break;
+		case Opt_sunit:
+			ret = match_int(args, &intarg);
+			if (ret)
+				goto free_orig;
+			dsunit = intarg;
+			break;
+		case Opt_swidth:
+			ret = match_int(args, &intarg);
+			if (ret)
+				goto free_orig;
+			dswidth = intarg;
+			break;
+		case Opt_inode64:
 			mp->m_flags &= ~XFS_MOUNT_SMALL_INUMS;
 #if !XFS_BIG_INUMS
-			xfs_warn(mp, "%s option not allowed on this system",
-				this_char);
-			return EINVAL;
+			xfs_warn(mp, "%s options not allowed on this system", p);
+			ret = EINVAL;
+			goto free_orig;
 #endif
-		} else if (!strcmp(this_char, MNTOPT_NOUUID)) {
+			break;
+		case Opt_nouuid:
 			mp->m_flags |= XFS_MOUNT_NOUUID;
-		} else if (!strcmp(this_char, MNTOPT_BARRIER)) {
+			break;
+		case Opt_barrier:
 			mp->m_flags |= XFS_MOUNT_BARRIER;
-		} else if (!strcmp(this_char, MNTOPT_NOBARRIER)) {
+			break;
+		case Opt_nobarrier:
 			mp->m_flags &= ~XFS_MOUNT_BARRIER;
-		} else if (!strcmp(this_char, MNTOPT_IKEEP)) {
+			break;
+		case Opt_ikeep:
 			mp->m_flags |= XFS_MOUNT_IKEEP;
-		} else if (!strcmp(this_char, MNTOPT_NOIKEEP)) {
+			break;
+		case Opt_noikeep:
 			mp->m_flags &= ~XFS_MOUNT_IKEEP;
-		} else if (!strcmp(this_char, MNTOPT_LARGEIO)) {
+			break;
+		case Opt_largeio:
 			mp->m_flags &= ~XFS_MOUNT_COMPAT_IOSIZE;
-		} else if (!strcmp(this_char, MNTOPT_NOLARGEIO)) {
+			break;
+		case Opt_nolargeio:
 			mp->m_flags |= XFS_MOUNT_COMPAT_IOSIZE;
-		} else if (!strcmp(this_char, MNTOPT_ATTR2)) {
+			break;
+		case Opt_attr2:
 			mp->m_flags |= XFS_MOUNT_ATTR2;
-		} else if (!strcmp(this_char, MNTOPT_NOATTR2)) {
+			break;
+		case Opt_noattr2:
 			mp->m_flags &= ~XFS_MOUNT_ATTR2;
 			mp->m_flags |= XFS_MOUNT_NOATTR2;
-		} else if (!strcmp(this_char, MNTOPT_FILESTREAM)) {
+			break;
+		case Opt_filestreams:
 			mp->m_flags |= XFS_MOUNT_FILESTREAMS;
-		} else if (!strcmp(this_char, MNTOPT_NOQUOTA)) {
+			break;
+		case Opt_noquota:
 			mp->m_qflags &= ~XFS_ALL_QUOTA_ACCT;
 			mp->m_qflags &= ~XFS_ALL_QUOTA_ENFD;
 			mp->m_qflags &= ~XFS_ALL_QUOTA_ACTIVE;
-		} else if (!strcmp(this_char, MNTOPT_QUOTA) ||
-			   !strcmp(this_char, MNTOPT_UQUOTA) ||
-			   !strcmp(this_char, MNTOPT_USRQUOTA)) {
+			break;
+		case Opt_quota:
+		case Opt_uquota:
+		case Opt_usrquota:
 			mp->m_qflags |= (XFS_UQUOTA_ACCT | XFS_UQUOTA_ACTIVE |
 					 XFS_UQUOTA_ENFD);
-		} else if (!strcmp(this_char, MNTOPT_QUOTANOENF) ||
-			   !strcmp(this_char, MNTOPT_UQUOTANOENF)) {
+			break;
+		case Opt_qnoenf:
+		case Opt_uqnoenf:
 			mp->m_qflags |= (XFS_UQUOTA_ACCT | XFS_UQUOTA_ACTIVE);
 			mp->m_qflags &= ~XFS_UQUOTA_ENFD;
-		} else if (!strcmp(this_char, MNTOPT_PQUOTA) ||
-			   !strcmp(this_char, MNTOPT_PRJQUOTA)) {
+			break;
+		case Opt_pquota:
+		case Opt_prjquota:
 			mp->m_qflags |= (XFS_PQUOTA_ACCT | XFS_PQUOTA_ACTIVE |
 					 XFS_OQUOTA_ENFD);
-		} else if (!strcmp(this_char, MNTOPT_PQUOTANOENF)) {
+			break;
+		case Opt_pqnoenf:
 			mp->m_qflags |= (XFS_PQUOTA_ACCT | XFS_PQUOTA_ACTIVE);
 			mp->m_qflags &= ~XFS_OQUOTA_ENFD;
-		} else if (!strcmp(this_char, MNTOPT_GQUOTA) ||
-			   !strcmp(this_char, MNTOPT_GRPQUOTA)) {
+			break;
+		case Opt_gquota:
+		case Opt_grpquota:
 			mp->m_qflags |= (XFS_GQUOTA_ACCT | XFS_GQUOTA_ACTIVE |
 					 XFS_OQUOTA_ENFD);
-		} else if (!strcmp(this_char, MNTOPT_GQUOTANOENF)) {
+			break;
+		case Opt_gqnoenf:
 			mp->m_qflags |= (XFS_GQUOTA_ACCT | XFS_GQUOTA_ACTIVE);
 			mp->m_qflags &= ~XFS_OQUOTA_ENFD;
-		} else if (!strcmp(this_char, MNTOPT_DELAYLOG)) {
-			xfs_warn(mp,
-	"delaylog is the default now, option is deprecated.");
-		} else if (!strcmp(this_char, MNTOPT_NODELAYLOG)) {
-			xfs_warn(mp,
-	"nodelaylog support has been removed, option is deprecated.");
-		} else if (!strcmp(this_char, MNTOPT_DISCARD)) {
+			break;
+		case Opt_discard:
 			mp->m_flags |= XFS_MOUNT_DISCARD;
-		} else if (!strcmp(this_char, MNTOPT_NODISCARD)) {
+			break;
+		case Opt_nodiscard:
 			mp->m_flags &= ~XFS_MOUNT_DISCARD;
-		} else if (!strcmp(this_char, "ihashsize")) {
-			xfs_warn(mp,
-	"ihashsize no longer used, option is deprecated.");
-		} else if (!strcmp(this_char, "osyncisdsync")) {
-			xfs_warn(mp,
-	"osyncisdsync has no effect, option is deprecated.");
-		} else if (!strcmp(this_char, "osyncisosync")) {
-			xfs_warn(mp,
-	"osyncisosync has no effect, option is deprecated.");
-		} else if (!strcmp(this_char, "irixsgid")) {
-			xfs_warn(mp,
-	"irixsgid is now a sysctl(2) variable, option is deprecated.");
-		} else {
-			xfs_warn(mp, "unknown mount option [%s].", this_char);
-			return EINVAL;
+			break;
+		case Opt_delaylog:
+			xfs_warn(mp, MNTOPT_DELAYLOG MNTOPT_DEPRECATED);
+			break;
+		case Opt_nodelaylog:
+			xfs_warn(mp, MNTOPT_NODELAYLOG MNTOPT_DEPRECATED);
+			break;
+		case Opt_ihashsize:
+			xfs_warn(mp, MNTOPT_IHASHSIZE MNTOPT_DEPRECATED);
+		case Opt_osyncisdsync:
+			xfs_warn(mp, MNTOPT_OSYNCISDSYNC MNTOPT_DEPRECATED);
+			break;
+		case Opt_osyncisosync:
+			xfs_warn(mp, MNTOPT_OSYNCISOSYNC MNTOPT_DEPRECATED);
+			break;
+		case Opt_irixsgid:
+			xfs_warn(mp, MNTOPT_IRIXSGID MNTOPT_DEPRECATED);
+			break;
+		default:
+			xfs_warn(mp, "unknown mount option [%s].", p);
+			break;
 		}
 	}
 
+	kfree(orig);
+
 	/*
 	 * no recovery flag requires a read-only mount
 	 */
@@ -468,6 +567,10 @@ done:
 	}
 
 	return 0;
+
+free_orig:
+	kfree(orig);
+	return ret;
 }
 
 struct proc_xfs_info {
@@ -476,10 +579,12 @@ struct proc_xfs_info {
 };
 
 STATIC int
-xfs_showargs(
-	struct xfs_mount	*mp,
-	struct seq_file		*m)
+xfs_fs_show_options(
+	struct seq_file		*seq,
+	struct dentry		*dentry)
 {
+	struct xfs_mount	*mp = XFS_M(dentry->d_sb);
+
 	static struct proc_xfs_info xfs_info_set[] = {
 		/* the few simple ones we can get from the mount struct */
 		{ XFS_MOUNT_IKEEP,		"," MNTOPT_IKEEP },
@@ -505,58 +610,60 @@ xfs_showargs(
 
 	for (xfs_infop = xfs_info_set; xfs_infop->flag; xfs_infop++) {
 		if (mp->m_flags & xfs_infop->flag)
-			seq_puts(m, xfs_infop->str);
+			seq_puts(seq, xfs_infop->str);
 	}
 	for (xfs_infop = xfs_info_unset; xfs_infop->flag; xfs_infop++) {
 		if (!(mp->m_flags & xfs_infop->flag))
-			seq_puts(m, xfs_infop->str);
+			seq_puts(seq, xfs_infop->str);
 	}
 
 	if (mp->m_flags & XFS_MOUNT_DFLT_IOSIZE)
-		seq_printf(m, "," MNTOPT_ALLOCSIZE "=%dk",
-				(int)(1 << mp->m_writeio_log) >> 10);
+		seq_printf(seq, "," MNTOPT_ALLOCSIZE "=%d",
+				(int)(1 << mp->m_writeio_log));
 
 	if (mp->m_logbufs > 0)
-		seq_printf(m, "," MNTOPT_LOGBUFS "=%d", mp->m_logbufs);
+		seq_printf(seq, "," MNTOPT_LOGBUFS "=%d", mp->m_logbufs);
 	if (mp->m_logbsize > 0)
-		seq_printf(m, "," MNTOPT_LOGBSIZE "=%dk", mp->m_logbsize >> 10);
+		seq_printf(seq, "," MNTOPT_LOGBSIZE "=%d",
+				mp->m_logbsize);
 
 	if (mp->m_logname)
-		seq_printf(m, "," MNTOPT_LOGDEV "=%s", mp->m_logname);
+		seq_printf(seq, "," MNTOPT_LOGDEV "=%s", mp->m_logname);
 	if (mp->m_rtname)
-		seq_printf(m, "," MNTOPT_RTDEV "=%s", mp->m_rtname);
+		seq_printf(seq, "," MNTOPT_RTDEV "=%s", mp->m_rtname);
 
 	if (mp->m_dalign > 0)
-		seq_printf(m, "," MNTOPT_SUNIT "=%d",
+		seq_printf(seq, "," MNTOPT_SUNIT "=%d",
 				(int)XFS_FSB_TO_BB(mp, mp->m_dalign));
 	if (mp->m_swidth > 0)
-		seq_printf(m, "," MNTOPT_SWIDTH "=%d",
+		seq_printf(seq, "," MNTOPT_SWIDTH "=%d",
 				(int)XFS_FSB_TO_BB(mp, mp->m_swidth));
 
 	if (mp->m_qflags & (XFS_UQUOTA_ACCT|XFS_UQUOTA_ENFD))
-		seq_puts(m, "," MNTOPT_USRQUOTA);
+		seq_puts(seq, "," MNTOPT_USRQUOTA);
 	else if (mp->m_qflags & XFS_UQUOTA_ACCT)
-		seq_puts(m, "," MNTOPT_UQUOTANOENF);
+		seq_puts(seq, "," MNTOPT_UQUOTANOENF);
 
 	/* Either project or group quotas can be active, not both */
 
 	if (mp->m_qflags & XFS_PQUOTA_ACCT) {
 		if (mp->m_qflags & XFS_OQUOTA_ENFD)
-			seq_puts(m, "," MNTOPT_PRJQUOTA);
+			seq_puts(seq, "," MNTOPT_PRJQUOTA);
 		else
-			seq_puts(m, "," MNTOPT_PQUOTANOENF);
+			seq_puts(seq, "," MNTOPT_PQUOTANOENF);
 	} else if (mp->m_qflags & XFS_GQUOTA_ACCT) {
 		if (mp->m_qflags & XFS_OQUOTA_ENFD)
-			seq_puts(m, "," MNTOPT_GRPQUOTA);
+			seq_puts(seq, "," MNTOPT_GRPQUOTA);
 		else
-			seq_puts(m, "," MNTOPT_GQUOTANOENF);
+			seq_puts(seq, "," MNTOPT_GQUOTANOENF);
 	}
 
 	if (!(mp->m_qflags & XFS_ALL_QUOTA_ACCT))
-		seq_puts(m, "," MNTOPT_NOQUOTA);
+		seq_puts(seq, "," MNTOPT_NOQUOTA);
 
 	return 0;
 }
+
 __uint64_t
 xfs_max_file_offset(
 	unsigned int		blockshift)
@@ -1166,14 +1273,6 @@ xfs_fs_unfreeze(
 	return 0;
 }
 
-STATIC int
-xfs_fs_show_options(
-	struct seq_file		*m,
-	struct dentry		*root)
-{
-	return -xfs_showargs(XFS_M(root->d_sb), m);
-}
-
 /*
  * This function fills in xfs_mount_t fields based on mount args.
  * Note: the superblock _has_ now been read in.
-- 
1.7.12.rc0

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

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

* Re: [PATCH V7] xfs: cleanup the mount options
  2012-07-25  1:11                         ` [PATCH V7] " Wanlong Gao
@ 2012-07-29 22:09                           ` Dave Chinner
  2012-08-28 19:38                           ` Ben Myers
  1 sibling, 0 replies; 31+ messages in thread
From: Dave Chinner @ 2012-07-29 22:09 UTC (permalink / raw)
  To: Wanlong Gao; +Cc: Christoph Hellwig, Ben Myers, Zach Brown, xfs

On Wed, Jul 25, 2012 at 09:11:37AM +0800, Wanlong Gao wrote:
> remove the mount options macro, use tokens instead.
> 
> change from V6: (Dave)
> 1. switch GFP_NOFS to GFP_KERNEL
> 
> change from V5: (Dave)
> 1. fix a string leak.
> 2. leave the show options to raw numbers.
> 
> change from V4: (as Dave suggested)
> 1. suffix_match_int avoid overflow.
> 2. convert the return style to be consistent with others.
> 3. move the "intarg" init above the switch.
> 4. move match_strdup to a help function.
> 5. collapsed Opt_biosize and Opt_allocsize.
> 6. make a consistent deprecated message.

Looks good now. Thanks for takingthe time to get this right!

Reviewed-by: Dave Chinner <dchinner@redhat.com>

-- 
Dave Chinner
david@fromorbit.com

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

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

* Re: [PATCH V7] xfs: cleanup the mount options
  2012-07-25  1:11                         ` [PATCH V7] " Wanlong Gao
  2012-07-29 22:09                           ` Dave Chinner
@ 2012-08-28 19:38                           ` Ben Myers
  1 sibling, 0 replies; 31+ messages in thread
From: Ben Myers @ 2012-08-28 19:38 UTC (permalink / raw)
  To: Wanlong Gao; +Cc: Christoph Hellwig, Zach Brown, xfs

On Wed, Jul 25, 2012 at 09:11:37AM +0800, Wanlong Gao wrote:
> remove the mount options macro, use tokens instead.

Wanlong,
	
This causes xfstests to try to run the dmapi tests on machines where it
shouldn't.  Did you have a chance to do before and after test runs with
xfstests?  I can take a look to try and find the problem, but if you have the
time to look at it that would be much appreciated.

Thanks,
	Ben

> change from V6: (Dave)
> 1. switch GFP_NOFS to GFP_KERNEL
> 
> change from V5: (Dave)
> 1. fix a string leak.
> 2. leave the show options to raw numbers.
> 
> change from V4: (as Dave suggested)
> 1. suffix_match_int avoid overflow.
> 2. convert the return style to be consistent with others.
> 3. move the "intarg" init above the switch.
> 4. move match_strdup to a help function.
> 5. collapsed Opt_biosize and Opt_allocsize.
> 6. make a consistent deprecated message.
> 
> CC: Ben Myers <bpm@sgi.com>
> CC: Christoph Hellwig <hch@infradead.org>
> CC: Dave Chinner <david@fromorbit.com>
> CC: Zach Brown <zab@zabbo.net>
> Signed-off-by: Wanlong Gao <gaowanlong@cn.fujitsu.com>
> ---
>  fs/xfs/xfs_super.c | 551 +++++++++++++++++++++++++++++++----------------------
>  1 file changed, 325 insertions(+), 226 deletions(-)
> 
> diff --git a/fs/xfs/xfs_super.c b/fs/xfs/xfs_super.c
> index cb2deb1..336a210 100644
> --- a/fs/xfs/xfs_super.c
> +++ b/fs/xfs/xfs_super.c
> @@ -66,91 +66,171 @@ static const struct super_operations xfs_super_operations;
>  static kmem_zone_t *xfs_ioend_zone;
>  mempool_t *xfs_ioend_pool;
>  
> -#define MNTOPT_LOGBUFS	"logbufs"	/* number of XFS log buffers */
> -#define MNTOPT_LOGBSIZE	"logbsize"	/* size of XFS log buffers */
> -#define MNTOPT_LOGDEV	"logdev"	/* log device */
> -#define MNTOPT_RTDEV	"rtdev"		/* realtime I/O device */
> -#define MNTOPT_BIOSIZE	"biosize"	/* log2 of preferred buffered io size */
> -#define MNTOPT_WSYNC	"wsync"		/* safe-mode nfs compatible mount */
> -#define MNTOPT_NOALIGN	"noalign"	/* turn off stripe alignment */
> -#define MNTOPT_SWALLOC	"swalloc"	/* turn on stripe width allocation */
> -#define MNTOPT_SUNIT	"sunit"		/* data volume stripe unit */
> -#define MNTOPT_SWIDTH	"swidth"	/* data volume stripe width */
> -#define MNTOPT_NOUUID	"nouuid"	/* ignore filesystem UUID */
> -#define MNTOPT_MTPT	"mtpt"		/* filesystem mount point */
> -#define MNTOPT_GRPID	"grpid"		/* group-ID from parent directory */
> -#define MNTOPT_NOGRPID	"nogrpid"	/* group-ID from current process */
> -#define MNTOPT_BSDGROUPS    "bsdgroups"    /* group-ID from parent directory */
> -#define MNTOPT_SYSVGROUPS   "sysvgroups"   /* group-ID from current process */
> -#define MNTOPT_ALLOCSIZE    "allocsize"    /* preferred allocation size */
> -#define MNTOPT_NORECOVERY   "norecovery"   /* don't run XFS recovery */
> -#define MNTOPT_BARRIER	"barrier"	/* use writer barriers for log write and
> -					 * unwritten extent conversion */
> -#define MNTOPT_NOBARRIER "nobarrier"	/* .. disable */
> -#define MNTOPT_64BITINODE   "inode64"	/* inodes can be allocated anywhere */
> -#define MNTOPT_IKEEP	"ikeep"		/* do not free empty inode clusters */
> -#define MNTOPT_NOIKEEP	"noikeep"	/* free empty inode clusters */
> -#define MNTOPT_LARGEIO	   "largeio"	/* report large I/O sizes in stat() */
> -#define MNTOPT_NOLARGEIO   "nolargeio"	/* do not report large I/O sizes
> -					 * in stat(). */
> -#define MNTOPT_ATTR2	"attr2"		/* do use attr2 attribute format */
> -#define MNTOPT_NOATTR2	"noattr2"	/* do not use attr2 attribute format */
> -#define MNTOPT_FILESTREAM  "filestreams" /* use filestreams allocator */
> -#define MNTOPT_QUOTA	"quota"		/* disk quotas (user) */
> -#define MNTOPT_NOQUOTA	"noquota"	/* no quotas */
> -#define MNTOPT_USRQUOTA	"usrquota"	/* user quota enabled */
> -#define MNTOPT_GRPQUOTA	"grpquota"	/* group quota enabled */
> -#define MNTOPT_PRJQUOTA	"prjquota"	/* project quota enabled */
> -#define MNTOPT_UQUOTA	"uquota"	/* user quota (IRIX variant) */
> -#define MNTOPT_GQUOTA	"gquota"	/* group quota (IRIX variant) */
> -#define MNTOPT_PQUOTA	"pquota"	/* project quota (IRIX variant) */
> -#define MNTOPT_UQUOTANOENF "uqnoenforce"/* user quota limit enforcement */
> -#define MNTOPT_GQUOTANOENF "gqnoenforce"/* group quota limit enforcement */
> -#define MNTOPT_PQUOTANOENF "pqnoenforce"/* project quota limit enforcement */
> -#define MNTOPT_QUOTANOENF  "qnoenforce"	/* same as uqnoenforce */
> -#define MNTOPT_DELAYLOG    "delaylog"	/* Delayed logging enabled */
> -#define MNTOPT_NODELAYLOG  "nodelaylog"	/* Delayed logging disabled */
> -#define MNTOPT_DISCARD	   "discard"	/* Discard unused blocks */
> -#define MNTOPT_NODISCARD   "nodiscard"	/* Do not discard unused blocks */
> +#define	MNTOPT_LOGBUFS		"logbufs"
> +#define	MNTOPT_LOGBSIZE		"logbsize"
> +#define	MNTOPT_LOGDEV		"logdev"
> +#define	MNTOPT_RTDEV		"rtdev"
> +#define	MNTOPT_BIOSIZE		"biosize"
> +#define	MNTOPT_WSYNC		"wsync"
> +#define	MNTOPT_NOALIGN		"noalign"
> +#define	MNTOPT_SWALLOC		"swalloc"
> +#define	MNTOPT_SUNIT		"sunit"
> +#define	MNTOPT_SWIDTH		"swidth"
> +#define	MNTOPT_NOUUID		"nouuid"
> +#define	MNTOPT_MTPT		"mtpt"
> +#define	MNTOPT_GRPID		"grpid"
> +#define	MNTOPT_NOGRPID		"nogrpid"
> +#define	MNTOPT_BSDGROUPS	"bsdgroups"
> +#define	MNTOPT_SYSVGROUPS	"sysvgroups"
> +#define	MNTOPT_ALLOCSIZE	"allocsize"
> +#define	MNTOPT_NORECOVERY	"norecovery"
> +#define	MNTOPT_BARRIER		"barrier"
> +#define	MNTOPT_NOBARRIER	"nobarrier"
> +#define	MNTOPT_64BITINODE	"inode64"
> +#define	MNTOPT_IKEEP		"ikeep"
> +#define	MNTOPT_NOIKEEP		"noikeep"
> +#define	MNTOPT_LARGEIO		"largeio"
> +#define	MNTOPT_NOLARGEIO	"nolargeio"
> +#define	MNTOPT_ATTR2		"attr2"
> +#define	MNTOPT_NOATTR2		"noattr2"
> +#define	MNTOPT_FILESTREAM	"filestreams"
> +#define	MNTOPT_QUOTA		"quota"
> +#define	MNTOPT_NOQUOTA		"noquota"
> +#define	MNTOPT_USRQUOTA		"usrquota"
> +#define	MNTOPT_GRPQUOTA		"grpquota"
> +#define	MNTOPT_PRJQUOTA		"prjquota"
> +#define	MNTOPT_UQUOTA		"uquota"
> +#define	MNTOPT_GQUOTA		"gquota"
> +#define	MNTOPT_PQUOTA		"pquota"
> +#define	MNTOPT_UQUOTANOENF	"uqnoenforce"
> +#define	MNTOPT_GQUOTANOENF	"gqnoenforce"
> +#define	MNTOPT_PQUOTANOENF	"pqnoenforce"
> +#define	MNTOPT_QUOTANOENF	"qnoenforce"
> +#define	MNTOPT_DISCARD		"discard"
> +#define	MNTOPT_NODISCARD	"nodiscard"
> +#define	MNTOPT_DELAYLOG		"delaylog"
> +#define	MNTOPT_NODELAYLOG	"nodelaylog"
> +#define	MNTOPT_IHASHSIZE	"ihashsize"
> +#define	MNTOPT_OSYNCISDSYNC	"osyncisdsync"
> +#define	MNTOPT_OSYNCISOSYNC	"osyncisosync"
> +#define	MNTOPT_IRIXSGID		"irixsgid"
> +
> +#define MNTOPT_DEPRECATED "has no effect, option is deprecated"
>  
> -/*
> - * Table driven mount option parser.
> - *
> - * Currently only used for remount, but it will be used for mount
> - * in the future, too.
> - */
>  enum {
> -	Opt_barrier, Opt_nobarrier, Opt_err
> +	Opt_logbufs, Opt_logbsize, Opt_logdev, Opt_rtdev, Opt_biosize,
> +	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_inode64, Opt_ikeep, Opt_noikeep, Opt_largeio,
> +	Opt_nolargeio, Opt_attr2, Opt_noattr2, Opt_filestreams, Opt_quota,
> +	Opt_noquota, Opt_usrquota, Opt_grpquota, Opt_prjquota, Opt_uquota,
> +	Opt_gquota, Opt_pquota, Opt_uqnoenf, Opt_gqnoenf, Opt_pqnoenf,
> +	Opt_qnoenf, Opt_discard, Opt_nodiscard, Opt_delaylog, Opt_nodelaylog,
> +	Opt_ihashsize, Opt_osyncisdsync, Opt_osyncisosync, Opt_irixsgid,
> +	Opt_err
>  };
>  
>  static const match_table_t tokens = {
> -	{Opt_barrier, "barrier"},
> -	{Opt_nobarrier, "nobarrier"},
> +	{Opt_logbufs, MNTOPT_LOGBUFS "=%d"},	/* number of XFS log buffers */
> +	{Opt_logbsize, MNTOPT_LOGBSIZE "=%s"},	/* size of XFS log buffers */
> +	{Opt_logdev, MNTOPT_LOGDEV "=%s"},	/* log device */
> +	{Opt_rtdev, MNTOPT_RTDEV "=%s"},	/* realtime I/O device */
> +	{Opt_biosize, MNTOPT_BIOSIZE "=%d"},	/* log2 of preferred buffered io size */
> +	{Opt_wsync, MNTOPT_WSYNC},		/* safe-mode nfs compatible mount */
> +	{Opt_noalign, MNTOPT_NOALIGN},		/* turn off stripe alignment */
> +	{Opt_swalloc, MNTOPT_SWALLOC},		/* turn on stripe width allocation */
> +	{Opt_sunit, MNTOPT_SUNIT "=%d"},	/* data volume stripe unit */
> +	{Opt_swidth, MNTOPT_SWIDTH "=%d"},	/* data volume stripe width */
> +	{Opt_nouuid, MNTOPT_NOUUID},		/* ignore filesystem UUID */
> +	{Opt_mtpt, MNTOPT_MTPT},		/* filesystem mount point */
> +	{Opt_grpid, MNTOPT_GRPID},		/* group-ID from parent directory */
> +	{Opt_nogrpid, MNTOPT_NOGRPID},		/* group-ID from current process */
> +	{Opt_bsdgroups, MNTOPT_BSDGROUPS},	/* group-ID from parent directory */
> +	{Opt_sysvgroups, MNTOPT_SYSVGROUPS},	/* group-ID from current process */
> +	{Opt_allocsize, MNTOPT_ALLOCSIZE "=%s"},/* preferred allocation size */
> +	{Opt_norecovery, MNTOPT_NORECOVERY},	/* do not run XFS recovery */
> +	{Opt_barrier, MNTOPT_BARRIER},		/* use writer barrier for log write and
> +						 * unwritten extent conversation */
> +	{Opt_nobarrier, MNTOPT_NOBARRIER},	/* .. disable */
> +	{Opt_inode64, MNTOPT_64BITINODE},	/* inodes can be allocated anywhere */
> +	{Opt_ikeep, MNTOPT_IKEEP},		/* do not free empty inode clusters */
> +	{Opt_noikeep, MNTOPT_NOIKEEP},		/* free empty inode clusters */
> +	{Opt_largeio, MNTOPT_LARGEIO},		/* report large I/O sizes in start() */
> +	{Opt_nolargeio, MNTOPT_NOLARGEIO},	/* do not report large I/O sizes
> +						 * in start() */
> +	{Opt_attr2, MNTOPT_ATTR2},		/* do use attr2 attribute format */
> +	{Opt_noattr2, MNTOPT_NOATTR2},		/* do not use attr2 attribute format */
> +	{Opt_filestreams, MNTOPT_FILESTREAM}, 	/* use filestreams allocator */
> +	{Opt_quota, MNTOPT_QUOTA},		/* disk quotas (user) */
> +	{Opt_noquota, MNTOPT_NOQUOTA},		/* no quotas */
> +	{Opt_usrquota, MNTOPT_USRQUOTA},	/* user quota enabled */
> +	{Opt_grpquota, MNTOPT_GRPQUOTA},	/* group quota enabled */
> +	{Opt_prjquota, MNTOPT_PRJQUOTA},	/* project quota enabled */
> +	{Opt_uquota, MNTOPT_UQUOTA},		/* user quota (IRIX variant) */
> +	{Opt_gquota, MNTOPT_GQUOTA},		/* group quota (IRIX variant) */
> +	{Opt_pquota, MNTOPT_PQUOTA},		/* project quota (IRIX variant) */
> +	{Opt_uqnoenf, MNTOPT_UQUOTANOENF},	/* user quota limit enforcement */
> +	{Opt_gqnoenf, MNTOPT_GQUOTANOENF},	/* group quota limit enforcement */
> +	{Opt_pqnoenf, MNTOPT_PQUOTANOENF},	/* project quota limit enforcement */
> +	{Opt_qnoenf, MNTOPT_QUOTANOENF},	/* same as uqnoenforce */
> +	{Opt_discard, MNTOPT_DISCARD},		/* Discard unused blocks */
> +	{Opt_nodiscard, MNTOPT_NODISCARD},	/* Do not discard unused blocks */
> +	{Opt_delaylog, MNTOPT_DELAYLOG},	/* deprecated */
> +	{Opt_nodelaylog, MNTOPT_NODELAYLOG},	/* deprecated */
> +	{Opt_ihashsize, MNTOPT_IHASHSIZE},	/* deprecated */
> +	{Opt_osyncisdsync, MNTOPT_OSYNCISDSYNC},/* deprecated */
> +	{Opt_osyncisosync, MNTOPT_OSYNCISOSYNC},/* deprecated */
> +	{Opt_irixsgid, MNTOPT_IRIXSGID},	/* deprecated */
>  	{Opt_err, NULL}
>  };
>  
> -
> -STATIC unsigned long
> -suffix_strtoul(char *s, char **endp, unsigned int base)
> +STATIC int
> +suffix_match_int(substring_t *s, unsigned long *result)
>  {
> -	int	last, shift_left_factor = 0;
> -	char	*value = s;
> +	int shift_left_factor = 0;
> +	char *value = s->to - 1;
> +	char *string;
>  
> -	last = strlen(value) - 1;
> -	if (value[last] == 'K' || value[last] == 'k') {
> +	if (*value == 'K' || *value == 'k') {
>  		shift_left_factor = 10;
> -		value[last] = '\0';
> +		s->to--;
>  	}
> -	if (value[last] == 'M' || value[last] == 'm') {
> +	if (*value == 'M' || *value == 'm') {
>  		shift_left_factor = 20;
> -		value[last] = '\0';
> +		s->to--;
>  	}
> -	if (value[last] == 'G' || value[last] == 'g') {
> +	if (*value == 'G' || *value == 'g') {
>  		shift_left_factor = 30;
> -		value[last] = '\0';
> +		s->to--;
>  	}
>  
> -	return simple_strtoul((const char *)s, endp, base) << shift_left_factor;
> +	string = match_strdup(s);
> +	if (!string)
> +		return ENOMEM;
> +
> +	*result = simple_strtoul((const char *)string, NULL, 0) <<
> +			shift_left_factor;
> +
> +	kfree(string);
> +	return 0;
> +}
> +
> +STATIC int
> +match_name_strdup(substring_t *s, char *name)
> +{
> +	char *string;
> +	int ret = 0;
> +	string = match_strdup(s);
> +	if (!string)
> +		return ENOMEM;
> +
> +	name = kstrndup(string, MAXNAMELEN, GFP_KERNEL);
> +	if (!name)
> +		ret = ENOMEM;
> +
> +	kfree(string);
> +	return ret;
>  }
>  
>  /*
> @@ -166,11 +246,15 @@ xfs_parseargs(
>  	char			*options)
>  {
>  	struct super_block	*sb = mp->m_super;
> -	char			*this_char, *value, *eov;
> +	char			*p;
>  	int			dsunit = 0;
>  	int			dswidth = 0;
> -	int			iosize = 0;
>  	__uint8_t		iosizelog = 0;
> +	int			intarg;
> +	unsigned long		ularg;
> +	substring_t		args[MAX_OPT_ARGS];
> +	char			*orig = NULL;
> +	int			ret = 0;
>  
>  	/*
>  	 * set up the mount name first so all the errors will refer to the
> @@ -208,175 +292,190 @@ xfs_parseargs(
>  	if (!options)
>  		goto done;
>  
> -	while ((this_char = strsep(&options, ",")) != NULL) {
> -		if (!*this_char)
> +	orig = kstrdup(options, GFP_KERNEL);
> +	if (!orig) {
> +		ret = ENOMEM;
> +		goto done;
> +	}
> +
> +	while ((p = strsep(&options, ",")) != NULL) {
> +		int token;
> +		if (!*p)
>  			continue;
> -		if ((value = strchr(this_char, '=')) != NULL)
> -			*value++ = 0;
> -
> -		if (!strcmp(this_char, MNTOPT_LOGBUFS)) {
> -			if (!value || !*value) {
> -				xfs_warn(mp, "%s option requires an argument",
> -					this_char);
> -				return EINVAL;
> -			}
> -			mp->m_logbufs = simple_strtoul(value, &eov, 10);
> -		} else if (!strcmp(this_char, MNTOPT_LOGBSIZE)) {
> -			if (!value || !*value) {
> -				xfs_warn(mp, "%s option requires an argument",
> -					this_char);
> -				return EINVAL;
> -			}
> -			mp->m_logbsize = suffix_strtoul(value, &eov, 10);
> -		} else if (!strcmp(this_char, MNTOPT_LOGDEV)) {
> -			if (!value || !*value) {
> -				xfs_warn(mp, "%s option requires an argument",
> -					this_char);
> -				return EINVAL;
> -			}
> -			mp->m_logname = kstrndup(value, MAXNAMELEN, GFP_KERNEL);
> -			if (!mp->m_logname)
> -				return ENOMEM;
> -		} else if (!strcmp(this_char, MNTOPT_MTPT)) {
> -			xfs_warn(mp, "%s option not allowed on this system",
> -				this_char);
> -			return EINVAL;
> -		} else if (!strcmp(this_char, MNTOPT_RTDEV)) {
> -			if (!value || !*value) {
> -				xfs_warn(mp, "%s option requires an argument",
> -					this_char);
> -				return EINVAL;
> -			}
> -			mp->m_rtname = kstrndup(value, MAXNAMELEN, GFP_KERNEL);
> -			if (!mp->m_rtname)
> -				return ENOMEM;
> -		} else if (!strcmp(this_char, MNTOPT_BIOSIZE)) {
> -			if (!value || !*value) {
> -				xfs_warn(mp, "%s option requires an argument",
> -					this_char);
> -				return EINVAL;
> -			}
> -			iosize = simple_strtoul(value, &eov, 10);
> -			iosizelog = ffs(iosize) - 1;
> -		} else if (!strcmp(this_char, MNTOPT_ALLOCSIZE)) {
> -			if (!value || !*value) {
> -				xfs_warn(mp, "%s option requires an argument",
> -					this_char);
> -				return EINVAL;
> -			}
> -			iosize = suffix_strtoul(value, &eov, 10);
> -			iosizelog = ffs(iosize) - 1;
> -		} else if (!strcmp(this_char, MNTOPT_GRPID) ||
> -			   !strcmp(this_char, MNTOPT_BSDGROUPS)) {
> +
> +		token = match_token(p, tokens, args);
> +		intarg = 0;
> +		ularg = 0;
> +		switch (token) {
> +		case Opt_logbufs:
> +			ret = match_int(args, &intarg);
> +			if (ret)
> +				goto free_orig;
> +			mp->m_logbufs = intarg;
> +			break;
> +		case Opt_logbsize:
> +			ret = suffix_match_int(args, &ularg);
> +			if (ret)
> +				goto free_orig;
> +			mp->m_logbsize = ularg;
> +			break;
> +		case Opt_logdev:
> +			ret = match_name_strdup(args, mp->m_logname);
> +			if (ret)
> +				goto free_orig;
> +			break;
> +		case Opt_mtpt:
> +			xfs_warn(mp, "%s option not allowed on this system", p);
> +			ret = EINVAL;
> +			goto free_orig;
> +		case Opt_rtdev:
> +			ret = match_name_strdup(args, mp->m_rtname);
> +			if (ret)
> +				goto free_orig;
> +			break;
> +		case Opt_biosize:
> +		case Opt_allocsize:
> +			ret = suffix_match_int(args, &ularg);
> +			if (ret)
> +				goto free_orig;
> +			iosizelog = ffs(ularg) - 1;
> +			break;
> +		case Opt_grpid:
> +		case Opt_bsdgroups:
>  			mp->m_flags |= XFS_MOUNT_GRPID;
> -		} else if (!strcmp(this_char, MNTOPT_NOGRPID) ||
> -			   !strcmp(this_char, MNTOPT_SYSVGROUPS)) {
> +			break;
> +		case Opt_nogrpid:
> +		case Opt_sysvgroups:
>  			mp->m_flags &= ~XFS_MOUNT_GRPID;
> -		} else if (!strcmp(this_char, MNTOPT_WSYNC)) {
> +			break;
> +		case Opt_wsync:
>  			mp->m_flags |= XFS_MOUNT_WSYNC;
> -		} else if (!strcmp(this_char, MNTOPT_NORECOVERY)) {
> +			break;
> +		case Opt_norecovery:
>  			mp->m_flags |= XFS_MOUNT_NORECOVERY;
> -		} else if (!strcmp(this_char, MNTOPT_NOALIGN)) {
> +			break;
> +		case Opt_noalign:
>  			mp->m_flags |= XFS_MOUNT_NOALIGN;
> -		} else if (!strcmp(this_char, MNTOPT_SWALLOC)) {
> +			break;
> +		case Opt_swalloc:
>  			mp->m_flags |= XFS_MOUNT_SWALLOC;
> -		} else if (!strcmp(this_char, MNTOPT_SUNIT)) {
> -			if (!value || !*value) {
> -				xfs_warn(mp, "%s option requires an argument",
> -					this_char);
> -				return EINVAL;
> -			}
> -			dsunit = simple_strtoul(value, &eov, 10);
> -		} else if (!strcmp(this_char, MNTOPT_SWIDTH)) {
> -			if (!value || !*value) {
> -				xfs_warn(mp, "%s option requires an argument",
> -					this_char);
> -				return EINVAL;
> -			}
> -			dswidth = simple_strtoul(value, &eov, 10);
> -		} else if (!strcmp(this_char, MNTOPT_64BITINODE)) {
> +			break;
> +		case Opt_sunit:
> +			ret = match_int(args, &intarg);
> +			if (ret)
> +				goto free_orig;
> +			dsunit = intarg;
> +			break;
> +		case Opt_swidth:
> +			ret = match_int(args, &intarg);
> +			if (ret)
> +				goto free_orig;
> +			dswidth = intarg;
> +			break;
> +		case Opt_inode64:
>  			mp->m_flags &= ~XFS_MOUNT_SMALL_INUMS;
>  #if !XFS_BIG_INUMS
> -			xfs_warn(mp, "%s option not allowed on this system",
> -				this_char);
> -			return EINVAL;
> +			xfs_warn(mp, "%s options not allowed on this system", p);
> +			ret = EINVAL;
> +			goto free_orig;
>  #endif
> -		} else if (!strcmp(this_char, MNTOPT_NOUUID)) {
> +			break;
> +		case Opt_nouuid:
>  			mp->m_flags |= XFS_MOUNT_NOUUID;
> -		} else if (!strcmp(this_char, MNTOPT_BARRIER)) {
> +			break;
> +		case Opt_barrier:
>  			mp->m_flags |= XFS_MOUNT_BARRIER;
> -		} else if (!strcmp(this_char, MNTOPT_NOBARRIER)) {
> +			break;
> +		case Opt_nobarrier:
>  			mp->m_flags &= ~XFS_MOUNT_BARRIER;
> -		} else if (!strcmp(this_char, MNTOPT_IKEEP)) {
> +			break;
> +		case Opt_ikeep:
>  			mp->m_flags |= XFS_MOUNT_IKEEP;
> -		} else if (!strcmp(this_char, MNTOPT_NOIKEEP)) {
> +			break;
> +		case Opt_noikeep:
>  			mp->m_flags &= ~XFS_MOUNT_IKEEP;
> -		} else if (!strcmp(this_char, MNTOPT_LARGEIO)) {
> +			break;
> +		case Opt_largeio:
>  			mp->m_flags &= ~XFS_MOUNT_COMPAT_IOSIZE;
> -		} else if (!strcmp(this_char, MNTOPT_NOLARGEIO)) {
> +			break;
> +		case Opt_nolargeio:
>  			mp->m_flags |= XFS_MOUNT_COMPAT_IOSIZE;
> -		} else if (!strcmp(this_char, MNTOPT_ATTR2)) {
> +			break;
> +		case Opt_attr2:
>  			mp->m_flags |= XFS_MOUNT_ATTR2;
> -		} else if (!strcmp(this_char, MNTOPT_NOATTR2)) {
> +			break;
> +		case Opt_noattr2:
>  			mp->m_flags &= ~XFS_MOUNT_ATTR2;
>  			mp->m_flags |= XFS_MOUNT_NOATTR2;
> -		} else if (!strcmp(this_char, MNTOPT_FILESTREAM)) {
> +			break;
> +		case Opt_filestreams:
>  			mp->m_flags |= XFS_MOUNT_FILESTREAMS;
> -		} else if (!strcmp(this_char, MNTOPT_NOQUOTA)) {
> +			break;
> +		case Opt_noquota:
>  			mp->m_qflags &= ~XFS_ALL_QUOTA_ACCT;
>  			mp->m_qflags &= ~XFS_ALL_QUOTA_ENFD;
>  			mp->m_qflags &= ~XFS_ALL_QUOTA_ACTIVE;
> -		} else if (!strcmp(this_char, MNTOPT_QUOTA) ||
> -			   !strcmp(this_char, MNTOPT_UQUOTA) ||
> -			   !strcmp(this_char, MNTOPT_USRQUOTA)) {
> +			break;
> +		case Opt_quota:
> +		case Opt_uquota:
> +		case Opt_usrquota:
>  			mp->m_qflags |= (XFS_UQUOTA_ACCT | XFS_UQUOTA_ACTIVE |
>  					 XFS_UQUOTA_ENFD);
> -		} else if (!strcmp(this_char, MNTOPT_QUOTANOENF) ||
> -			   !strcmp(this_char, MNTOPT_UQUOTANOENF)) {
> +			break;
> +		case Opt_qnoenf:
> +		case Opt_uqnoenf:
>  			mp->m_qflags |= (XFS_UQUOTA_ACCT | XFS_UQUOTA_ACTIVE);
>  			mp->m_qflags &= ~XFS_UQUOTA_ENFD;
> -		} else if (!strcmp(this_char, MNTOPT_PQUOTA) ||
> -			   !strcmp(this_char, MNTOPT_PRJQUOTA)) {
> +			break;
> +		case Opt_pquota:
> +		case Opt_prjquota:
>  			mp->m_qflags |= (XFS_PQUOTA_ACCT | XFS_PQUOTA_ACTIVE |
>  					 XFS_OQUOTA_ENFD);
> -		} else if (!strcmp(this_char, MNTOPT_PQUOTANOENF)) {
> +			break;
> +		case Opt_pqnoenf:
>  			mp->m_qflags |= (XFS_PQUOTA_ACCT | XFS_PQUOTA_ACTIVE);
>  			mp->m_qflags &= ~XFS_OQUOTA_ENFD;
> -		} else if (!strcmp(this_char, MNTOPT_GQUOTA) ||
> -			   !strcmp(this_char, MNTOPT_GRPQUOTA)) {
> +			break;
> +		case Opt_gquota:
> +		case Opt_grpquota:
>  			mp->m_qflags |= (XFS_GQUOTA_ACCT | XFS_GQUOTA_ACTIVE |
>  					 XFS_OQUOTA_ENFD);
> -		} else if (!strcmp(this_char, MNTOPT_GQUOTANOENF)) {
> +			break;
> +		case Opt_gqnoenf:
>  			mp->m_qflags |= (XFS_GQUOTA_ACCT | XFS_GQUOTA_ACTIVE);
>  			mp->m_qflags &= ~XFS_OQUOTA_ENFD;
> -		} else if (!strcmp(this_char, MNTOPT_DELAYLOG)) {
> -			xfs_warn(mp,
> -	"delaylog is the default now, option is deprecated.");
> -		} else if (!strcmp(this_char, MNTOPT_NODELAYLOG)) {
> -			xfs_warn(mp,
> -	"nodelaylog support has been removed, option is deprecated.");
> -		} else if (!strcmp(this_char, MNTOPT_DISCARD)) {
> +			break;
> +		case Opt_discard:
>  			mp->m_flags |= XFS_MOUNT_DISCARD;
> -		} else if (!strcmp(this_char, MNTOPT_NODISCARD)) {
> +			break;
> +		case Opt_nodiscard:
>  			mp->m_flags &= ~XFS_MOUNT_DISCARD;
> -		} else if (!strcmp(this_char, "ihashsize")) {
> -			xfs_warn(mp,
> -	"ihashsize no longer used, option is deprecated.");
> -		} else if (!strcmp(this_char, "osyncisdsync")) {
> -			xfs_warn(mp,
> -	"osyncisdsync has no effect, option is deprecated.");
> -		} else if (!strcmp(this_char, "osyncisosync")) {
> -			xfs_warn(mp,
> -	"osyncisosync has no effect, option is deprecated.");
> -		} else if (!strcmp(this_char, "irixsgid")) {
> -			xfs_warn(mp,
> -	"irixsgid is now a sysctl(2) variable, option is deprecated.");
> -		} else {
> -			xfs_warn(mp, "unknown mount option [%s].", this_char);
> -			return EINVAL;
> +			break;
> +		case Opt_delaylog:
> +			xfs_warn(mp, MNTOPT_DELAYLOG MNTOPT_DEPRECATED);
> +			break;
> +		case Opt_nodelaylog:
> +			xfs_warn(mp, MNTOPT_NODELAYLOG MNTOPT_DEPRECATED);
> +			break;
> +		case Opt_ihashsize:
> +			xfs_warn(mp, MNTOPT_IHASHSIZE MNTOPT_DEPRECATED);
> +		case Opt_osyncisdsync:
> +			xfs_warn(mp, MNTOPT_OSYNCISDSYNC MNTOPT_DEPRECATED);
> +			break;
> +		case Opt_osyncisosync:
> +			xfs_warn(mp, MNTOPT_OSYNCISOSYNC MNTOPT_DEPRECATED);
> +			break;
> +		case Opt_irixsgid:
> +			xfs_warn(mp, MNTOPT_IRIXSGID MNTOPT_DEPRECATED);
> +			break;
> +		default:
> +			xfs_warn(mp, "unknown mount option [%s].", p);
> +			break;
>  		}
>  	}
>  
> +	kfree(orig);
> +
>  	/*
>  	 * no recovery flag requires a read-only mount
>  	 */
> @@ -468,6 +567,10 @@ done:
>  	}
>  
>  	return 0;
> +
> +free_orig:
> +	kfree(orig);
> +	return ret;
>  }
>  
>  struct proc_xfs_info {
> @@ -476,10 +579,12 @@ struct proc_xfs_info {
>  };
>  
>  STATIC int
> -xfs_showargs(
> -	struct xfs_mount	*mp,
> -	struct seq_file		*m)
> +xfs_fs_show_options(
> +	struct seq_file		*seq,
> +	struct dentry		*dentry)
>  {
> +	struct xfs_mount	*mp = XFS_M(dentry->d_sb);
> +
>  	static struct proc_xfs_info xfs_info_set[] = {
>  		/* the few simple ones we can get from the mount struct */
>  		{ XFS_MOUNT_IKEEP,		"," MNTOPT_IKEEP },
> @@ -505,58 +610,60 @@ xfs_showargs(
>  
>  	for (xfs_infop = xfs_info_set; xfs_infop->flag; xfs_infop++) {
>  		if (mp->m_flags & xfs_infop->flag)
> -			seq_puts(m, xfs_infop->str);
> +			seq_puts(seq, xfs_infop->str);
>  	}
>  	for (xfs_infop = xfs_info_unset; xfs_infop->flag; xfs_infop++) {
>  		if (!(mp->m_flags & xfs_infop->flag))
> -			seq_puts(m, xfs_infop->str);
> +			seq_puts(seq, xfs_infop->str);
>  	}
>  
>  	if (mp->m_flags & XFS_MOUNT_DFLT_IOSIZE)
> -		seq_printf(m, "," MNTOPT_ALLOCSIZE "=%dk",
> -				(int)(1 << mp->m_writeio_log) >> 10);
> +		seq_printf(seq, "," MNTOPT_ALLOCSIZE "=%d",
> +				(int)(1 << mp->m_writeio_log));
>  
>  	if (mp->m_logbufs > 0)
> -		seq_printf(m, "," MNTOPT_LOGBUFS "=%d", mp->m_logbufs);
> +		seq_printf(seq, "," MNTOPT_LOGBUFS "=%d", mp->m_logbufs);
>  	if (mp->m_logbsize > 0)
> -		seq_printf(m, "," MNTOPT_LOGBSIZE "=%dk", mp->m_logbsize >> 10);
> +		seq_printf(seq, "," MNTOPT_LOGBSIZE "=%d",
> +				mp->m_logbsize);
>  
>  	if (mp->m_logname)
> -		seq_printf(m, "," MNTOPT_LOGDEV "=%s", mp->m_logname);
> +		seq_printf(seq, "," MNTOPT_LOGDEV "=%s", mp->m_logname);
>  	if (mp->m_rtname)
> -		seq_printf(m, "," MNTOPT_RTDEV "=%s", mp->m_rtname);
> +		seq_printf(seq, "," MNTOPT_RTDEV "=%s", mp->m_rtname);
>  
>  	if (mp->m_dalign > 0)
> -		seq_printf(m, "," MNTOPT_SUNIT "=%d",
> +		seq_printf(seq, "," MNTOPT_SUNIT "=%d",
>  				(int)XFS_FSB_TO_BB(mp, mp->m_dalign));
>  	if (mp->m_swidth > 0)
> -		seq_printf(m, "," MNTOPT_SWIDTH "=%d",
> +		seq_printf(seq, "," MNTOPT_SWIDTH "=%d",
>  				(int)XFS_FSB_TO_BB(mp, mp->m_swidth));
>  
>  	if (mp->m_qflags & (XFS_UQUOTA_ACCT|XFS_UQUOTA_ENFD))
> -		seq_puts(m, "," MNTOPT_USRQUOTA);
> +		seq_puts(seq, "," MNTOPT_USRQUOTA);
>  	else if (mp->m_qflags & XFS_UQUOTA_ACCT)
> -		seq_puts(m, "," MNTOPT_UQUOTANOENF);
> +		seq_puts(seq, "," MNTOPT_UQUOTANOENF);
>  
>  	/* Either project or group quotas can be active, not both */
>  
>  	if (mp->m_qflags & XFS_PQUOTA_ACCT) {
>  		if (mp->m_qflags & XFS_OQUOTA_ENFD)
> -			seq_puts(m, "," MNTOPT_PRJQUOTA);
> +			seq_puts(seq, "," MNTOPT_PRJQUOTA);
>  		else
> -			seq_puts(m, "," MNTOPT_PQUOTANOENF);
> +			seq_puts(seq, "," MNTOPT_PQUOTANOENF);
>  	} else if (mp->m_qflags & XFS_GQUOTA_ACCT) {
>  		if (mp->m_qflags & XFS_OQUOTA_ENFD)
> -			seq_puts(m, "," MNTOPT_GRPQUOTA);
> +			seq_puts(seq, "," MNTOPT_GRPQUOTA);
>  		else
> -			seq_puts(m, "," MNTOPT_GQUOTANOENF);
> +			seq_puts(seq, "," MNTOPT_GQUOTANOENF);
>  	}
>  
>  	if (!(mp->m_qflags & XFS_ALL_QUOTA_ACCT))
> -		seq_puts(m, "," MNTOPT_NOQUOTA);
> +		seq_puts(seq, "," MNTOPT_NOQUOTA);
>  
>  	return 0;
>  }
> +
>  __uint64_t
>  xfs_max_file_offset(
>  	unsigned int		blockshift)
> @@ -1166,14 +1273,6 @@ xfs_fs_unfreeze(
>  	return 0;
>  }
>  
> -STATIC int
> -xfs_fs_show_options(
> -	struct seq_file		*m,
> -	struct dentry		*root)
> -{
> -	return -xfs_showargs(XFS_M(root->d_sb), m);
> -}
> -
>  /*
>   * This function fills in xfs_mount_t fields based on mount args.
>   * Note: the superblock _has_ now been read in.
> -- 
> 1.7.12.rc0
> 
> _______________________________________________
> xfs mailing list
> xfs@oss.sgi.com
> http://oss.sgi.com/mailman/listinfo/xfs

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

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

end of thread, other threads:[~2012-08-28 19:37 UTC | newest]

Thread overview: 31+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-06-27 16:57 [PATCH] xfs: cleanup the mount options Wanlong Gao
2012-06-27 17:44 ` Christoph Hellwig
2012-06-28  0:54   ` Wanlong Gao
2012-06-28 16:01     ` Ben Myers
2012-06-28 16:33       ` Zach Brown
2012-06-28 19:54         ` Carlos Maiolino
2012-06-29  1:00         ` Wanlong Gao
2012-06-29 16:29           ` Zach Brown
2012-06-29 16:37             ` Wanlong Gao
2012-06-29 18:06 ` [PATCH 1/2 V2] " Wanlong Gao
2012-06-29 18:06   ` [PATCH 2/2] xfs: rename xfs_fs_* to xfs_* Wanlong Gao
2012-07-01 23:47     ` Dave Chinner
2012-07-02  0:39       ` Wanlong Gao
2012-07-02  6:26   ` [PATCH 1/2 V2] xfs: cleanup the mount options Christoph Hellwig
2012-07-02  7:05     ` [PATCH V3] " Wanlong Gao
2012-07-06  3:05       ` Dave Chinner
2012-07-08 11:36         ` [PATCH V4] " Wanlong Gao
2012-07-09  0:22           ` Dave Chinner
2012-07-09  9:21             ` Wanlong Gao
2012-07-11  2:26               ` Dave Chinner
2012-07-11  6:29                 ` [PATCH V5] " Wanlong Gao
2012-07-16  8:06                   ` Wanlong Gao
2012-07-23 20:33                     ` Ben Myers
2012-07-23 23:28                   ` Dave Chinner
2012-07-24  2:01                     ` Wanlong Gao
2012-07-24 21:18                       ` Dave Chinner
2012-07-25  1:09                         ` Wanlong Gao
2012-07-25  1:11                         ` [PATCH V7] " Wanlong Gao
2012-07-29 22:09                           ` Dave Chinner
2012-08-28 19:38                           ` Ben Myers
2012-07-24  2:10                     ` [PATCH V6] " Wanlong Gao

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.