linux-xfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* decruft misc mount related code
@ 2019-10-25 17:40 Christoph Hellwig
  2019-10-25 17:40 ` [PATCH 1/7] xfs: cleanup stat blksize reporting Christoph Hellwig
                   ` (6 more replies)
  0 siblings, 7 replies; 21+ messages in thread
From: Christoph Hellwig @ 2019-10-25 17:40 UTC (permalink / raw)
  To: linux-xfs; +Cc: Ian Kent

Hi all,

this series decrufts various bits of vaguely mount / mount option
related code.  The background is the mount API from series, which
currently is a lot more ugly than it should be do the way how
we parse two mount options with arguments into local variables
instead of directly into the mount structure.  This series cleans
that and a few nearby warts.

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

* [PATCH 1/7] xfs: cleanup stat blksize reporting
  2019-10-25 17:40 decruft misc mount related code Christoph Hellwig
@ 2019-10-25 17:40 ` Christoph Hellwig
  2019-10-25 17:56   ` Eric Sandeen
  2019-10-25 17:40 ` [PATCH 2/7] xfs: remove the unused m_readio_blocks field from struct xfs_mount Christoph Hellwig
                   ` (5 subsequent siblings)
  6 siblings, 1 reply; 21+ messages in thread
From: Christoph Hellwig @ 2019-10-25 17:40 UTC (permalink / raw)
  To: linux-xfs; +Cc: Ian Kent

Move xfs_preferred_iosize to xfs_iops.c, unobsfucate it and also handle
the realtime special case in the helper.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 fs/xfs/xfs_iops.c  | 47 ++++++++++++++++++++++++++++++++++++----------
 fs/xfs/xfs_mount.h | 24 -----------------------
 2 files changed, 37 insertions(+), 34 deletions(-)

diff --git a/fs/xfs/xfs_iops.c b/fs/xfs/xfs_iops.c
index 404f2dd58698..b6dbfd8eb6a1 100644
--- a/fs/xfs/xfs_iops.c
+++ b/fs/xfs/xfs_iops.c
@@ -484,6 +484,42 @@ xfs_vn_get_link_inline(
 	return link;
 }
 
+static uint32_t
+xfs_stat_blksize(
+	struct xfs_inode	*ip)
+{
+	struct xfs_mount	*mp = ip->i_mount;
+
+	/*
+	 * If the file blocks are being allocated from a realtime volume, then
+	 * always return the realtime extent size.
+	 */
+	if (XFS_IS_REALTIME_INODE(ip))
+		return xfs_get_extsz_hint(ip) << mp->m_sb.sb_blocklog;
+
+	/*
+	 * Allow large block sizes to be reported to userspace programs if the
+	 * "largeio" mount option is used.
+	 *
+	 * If compatibility mode is specified, simply return the basic unit of
+	 * caching so that we don't get inefficient read/modify/write I/O from
+	 * user apps. Otherwise....
+	 *
+	 * If the underlying volume is a stripe, then return the stripe width in
+	 * bytes as the recommended I/O size. It is not a stripe and we've set a
+	 * default buffered I/O size, return that, otherwise return the compat
+	 * default.
+	 */
+	if (!(mp->m_flags & XFS_MOUNT_COMPAT_IOSIZE)) {
+		if (mp->m_swidth)
+			return mp->m_swidth << mp->m_sb.sb_blocklog;
+		if (mp->m_flags & XFS_MOUNT_DFLT_IOSIZE)
+			return 1U << max(mp->m_readio_log, mp->m_writeio_log);
+	}
+
+	return PAGE_SIZE;
+}
+
 STATIC int
 xfs_vn_getattr(
 	const struct path	*path,
@@ -543,16 +579,7 @@ xfs_vn_getattr(
 		stat->rdev = inode->i_rdev;
 		break;
 	default:
-		if (XFS_IS_REALTIME_INODE(ip)) {
-			/*
-			 * If the file blocks are being allocated from a
-			 * realtime volume, then return the inode's realtime
-			 * extent size or the realtime volume's extent size.
-			 */
-			stat->blksize =
-				xfs_get_extsz_hint(ip) << mp->m_sb.sb_blocklog;
-		} else
-			stat->blksize = xfs_preferred_iosize(mp);
+		stat->blksize = xfs_stat_blksize(ip);
 		stat->rdev = 0;
 		break;
 	}
diff --git a/fs/xfs/xfs_mount.h b/fs/xfs/xfs_mount.h
index fdb60e09a9c5..f69e370db341 100644
--- a/fs/xfs/xfs_mount.h
+++ b/fs/xfs/xfs_mount.h
@@ -267,30 +267,6 @@ typedef struct xfs_mount {
 #define	XFS_WSYNC_READIO_LOG	15	/* 32k */
 #define	XFS_WSYNC_WRITEIO_LOG	14	/* 16k */
 
-/*
- * Allow large block sizes to be reported to userspace programs if the
- * "largeio" mount option is used.
- *
- * If compatibility mode is specified, simply return the basic unit of caching
- * so that we don't get inefficient read/modify/write I/O from user apps.
- * Otherwise....
- *
- * If the underlying volume is a stripe, then return the stripe width in bytes
- * as the recommended I/O size. It is not a stripe and we've set a default
- * buffered I/O size, return that, otherwise return the compat default.
- */
-static inline unsigned long
-xfs_preferred_iosize(xfs_mount_t *mp)
-{
-	if (mp->m_flags & XFS_MOUNT_COMPAT_IOSIZE)
-		return PAGE_SIZE;
-	return (mp->m_swidth ?
-		(mp->m_swidth << mp->m_sb.sb_blocklog) :
-		((mp->m_flags & XFS_MOUNT_DFLT_IOSIZE) ?
-			(1 << (int)max(mp->m_readio_log, mp->m_writeio_log)) :
-			PAGE_SIZE));
-}
-
 #define XFS_LAST_UNMOUNT_WAS_CLEAN(mp)	\
 				((mp)->m_flags & XFS_MOUNT_WAS_CLEAN)
 #define XFS_FORCED_SHUTDOWN(mp)	((mp)->m_flags & XFS_MOUNT_FS_SHUTDOWN)
-- 
2.20.1


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

* [PATCH 2/7] xfs: remove the unused m_readio_blocks field from struct xfs_mount
  2019-10-25 17:40 decruft misc mount related code Christoph Hellwig
  2019-10-25 17:40 ` [PATCH 1/7] xfs: cleanup stat blksize reporting Christoph Hellwig
@ 2019-10-25 17:40 ` Christoph Hellwig
  2019-10-25 18:02   ` Eric Sandeen
  2019-10-25 17:40 ` [PATCH 3/7] xfs: remove the m_readio_log " Christoph Hellwig
                   ` (4 subsequent siblings)
  6 siblings, 1 reply; 21+ messages in thread
From: Christoph Hellwig @ 2019-10-25 17:40 UTC (permalink / raw)
  To: linux-xfs; +Cc: Ian Kent

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 fs/xfs/xfs_mount.c | 1 -
 fs/xfs/xfs_mount.h | 1 -
 2 files changed, 2 deletions(-)

diff --git a/fs/xfs/xfs_mount.c b/fs/xfs/xfs_mount.c
index ba5b6f3b2b88..18af97512aec 100644
--- a/fs/xfs/xfs_mount.c
+++ b/fs/xfs/xfs_mount.c
@@ -455,7 +455,6 @@ xfs_set_rw_sizes(xfs_mount_t *mp)
 	} else {
 		mp->m_readio_log = readio_log;
 	}
-	mp->m_readio_blocks = 1 << (mp->m_readio_log - sbp->sb_blocklog);
 	if (sbp->sb_blocklog > writeio_log) {
 		mp->m_writeio_log = sbp->sb_blocklog;
 	} else {
diff --git a/fs/xfs/xfs_mount.h b/fs/xfs/xfs_mount.h
index f69e370db341..ecde5b3828c8 100644
--- a/fs/xfs/xfs_mount.h
+++ b/fs/xfs/xfs_mount.h
@@ -99,7 +99,6 @@ typedef struct xfs_mount {
 	spinlock_t		m_agirotor_lock;/* .. and lock protecting it */
 	xfs_agnumber_t		m_maxagi;	/* highest inode alloc group */
 	uint			m_readio_log;	/* min read size log bytes */
-	uint			m_readio_blocks; /* min read size blocks */
 	uint			m_writeio_log;	/* min write size log bytes */
 	uint			m_writeio_blocks; /* min write size blocks */
 	struct xfs_da_geometry	*m_dir_geo;	/* directory block geometry */
-- 
2.20.1


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

* [PATCH 3/7] xfs: remove the m_readio_log field from struct xfs_mount
  2019-10-25 17:40 decruft misc mount related code Christoph Hellwig
  2019-10-25 17:40 ` [PATCH 1/7] xfs: cleanup stat blksize reporting Christoph Hellwig
  2019-10-25 17:40 ` [PATCH 2/7] xfs: remove the unused m_readio_blocks field from struct xfs_mount Christoph Hellwig
@ 2019-10-25 17:40 ` Christoph Hellwig
  2019-10-25 18:26   ` Eric Sandeen
  2019-10-25 17:40 ` [PATCH 4/7] xfs: remove the dsunit and dswidth variables in xfs_parseargs Christoph Hellwig
                   ` (3 subsequent siblings)
  6 siblings, 1 reply; 21+ messages in thread
From: Christoph Hellwig @ 2019-10-25 17:40 UTC (permalink / raw)
  To: linux-xfs; +Cc: Ian Kent

The m_readio_log is only used for reporting the blksize (aka preferred
I/O size) in struct stat.  For all cases but a file system that does not
use stripe alignment, but which has the wsync and largeio mount option
set the value is the same as the write I/O size.

Remove the field and report a smaller preferred I/O size for that corner
case, which actually is the right thing to do for that case (except for
the fact that is probably is entirely unused).

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 fs/xfs/xfs_iops.c  |  2 +-
 fs/xfs/xfs_mount.c | 17 ++++-------------
 fs/xfs/xfs_mount.h | 15 ++++-----------
 fs/xfs/xfs_super.c |  1 -
 4 files changed, 9 insertions(+), 26 deletions(-)

diff --git a/fs/xfs/xfs_iops.c b/fs/xfs/xfs_iops.c
index b6dbfd8eb6a1..271fcbe04d48 100644
--- a/fs/xfs/xfs_iops.c
+++ b/fs/xfs/xfs_iops.c
@@ -514,7 +514,7 @@ xfs_stat_blksize(
 		if (mp->m_swidth)
 			return mp->m_swidth << mp->m_sb.sb_blocklog;
 		if (mp->m_flags & XFS_MOUNT_DFLT_IOSIZE)
-			return 1U << max(mp->m_readio_log, mp->m_writeio_log);
+			return 1U << mp->m_writeio_log;
 	}
 
 	return PAGE_SIZE;
diff --git a/fs/xfs/xfs_mount.c b/fs/xfs/xfs_mount.c
index 18af97512aec..9800401a7d6f 100644
--- a/fs/xfs/xfs_mount.c
+++ b/fs/xfs/xfs_mount.c
@@ -435,26 +435,17 @@ STATIC void
 xfs_set_rw_sizes(xfs_mount_t *mp)
 {
 	xfs_sb_t	*sbp = &(mp->m_sb);
-	int		readio_log, writeio_log;
+	int		writeio_log;
 
 	if (!(mp->m_flags & XFS_MOUNT_DFLT_IOSIZE)) {
-		if (mp->m_flags & XFS_MOUNT_WSYNC) {
-			readio_log = XFS_WSYNC_READIO_LOG;
-			writeio_log = XFS_WSYNC_WRITEIO_LOG;
-		} else {
-			readio_log = XFS_READIO_LOG_LARGE;
+		if (mp->m_flags & XFS_MOUNT_WSYNC)
+			writeio_log = XFS_WRITEIO_LOG_WSYNC;
+		else
 			writeio_log = XFS_WRITEIO_LOG_LARGE;
-		}
 	} else {
-		readio_log = mp->m_readio_log;
 		writeio_log = mp->m_writeio_log;
 	}
 
-	if (sbp->sb_blocklog > readio_log) {
-		mp->m_readio_log = sbp->sb_blocklog;
-	} else {
-		mp->m_readio_log = readio_log;
-	}
 	if (sbp->sb_blocklog > writeio_log) {
 		mp->m_writeio_log = sbp->sb_blocklog;
 	} else {
diff --git a/fs/xfs/xfs_mount.h b/fs/xfs/xfs_mount.h
index ecde5b3828c8..fb3a36a048cc 100644
--- a/fs/xfs/xfs_mount.h
+++ b/fs/xfs/xfs_mount.h
@@ -98,7 +98,6 @@ typedef struct xfs_mount {
 	xfs_agnumber_t		m_agirotor;	/* last ag dir inode alloced */
 	spinlock_t		m_agirotor_lock;/* .. and lock protecting it */
 	xfs_agnumber_t		m_maxagi;	/* highest inode alloc group */
-	uint			m_readio_log;	/* min read size log bytes */
 	uint			m_writeio_log;	/* min write size log bytes */
 	uint			m_writeio_blocks; /* min write size blocks */
 	struct xfs_da_geometry	*m_dir_geo;	/* directory block geometry */
@@ -247,10 +246,11 @@ typedef struct xfs_mount {
 
 
 /*
- * Default minimum read and write sizes.
+ * Default minimum write size.  The smaller sync value is better for
+ * NFSv2 wsync file systems.
  */
-#define XFS_READIO_LOG_LARGE	16
-#define XFS_WRITEIO_LOG_LARGE	16
+#define XFS_WRITEIO_LOG_WSYNC	14	/* 16k */
+#define XFS_WRITEIO_LOG_LARGE	16	/* 64k */
 
 /*
  * Max and min values for mount-option defined I/O
@@ -259,13 +259,6 @@ typedef struct xfs_mount {
 #define XFS_MAX_IO_LOG		30	/* 1G */
 #define XFS_MIN_IO_LOG		PAGE_SHIFT
 
-/*
- * Synchronous read and write sizes.  This should be
- * better for NFSv2 wsync filesystems.
- */
-#define	XFS_WSYNC_READIO_LOG	15	/* 32k */
-#define	XFS_WSYNC_WRITEIO_LOG	14	/* 16k */
-
 #define XFS_LAST_UNMOUNT_WAS_CLEAN(mp)	\
 				((mp)->m_flags & XFS_MOUNT_WAS_CLEAN)
 #define XFS_FORCED_SHUTDOWN(mp)	((mp)->m_flags & XFS_MOUNT_FS_SHUTDOWN)
diff --git a/fs/xfs/xfs_super.c b/fs/xfs/xfs_super.c
index 0a8cf6b87a21..4ededdbed5a4 100644
--- a/fs/xfs/xfs_super.c
+++ b/fs/xfs/xfs_super.c
@@ -418,7 +418,6 @@ xfs_parseargs(
 		}
 
 		mp->m_flags |= XFS_MOUNT_DFLT_IOSIZE;
-		mp->m_readio_log = iosizelog;
 		mp->m_writeio_log = iosizelog;
 	}
 
-- 
2.20.1


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

* [PATCH 4/7] xfs: remove the dsunit and dswidth variables in xfs_parseargs
  2019-10-25 17:40 decruft misc mount related code Christoph Hellwig
                   ` (2 preceding siblings ...)
  2019-10-25 17:40 ` [PATCH 3/7] xfs: remove the m_readio_log " Christoph Hellwig
@ 2019-10-25 17:40 ` Christoph Hellwig
  2019-10-25 18:29   ` Eric Sandeen
  2019-10-25 17:40 ` [PATCH 5/7] xfs: remove the iosizelog variable " Christoph Hellwig
                   ` (2 subsequent siblings)
  6 siblings, 1 reply; 21+ messages in thread
From: Christoph Hellwig @ 2019-10-25 17:40 UTC (permalink / raw)
  To: linux-xfs; +Cc: Ian Kent

There is no real need for the local variables here - either they
are applied to the mount structure, or if the noalign mount option
is set the mount will fail entirely if either is set.  Removing
them helps cleaning up the mount API conversion.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 fs/xfs/xfs_super.c | 27 ++++++++-------------------
 1 file changed, 8 insertions(+), 19 deletions(-)

diff --git a/fs/xfs/xfs_super.c b/fs/xfs/xfs_super.c
index 4ededdbed5a4..ee2dde897fb7 100644
--- a/fs/xfs/xfs_super.c
+++ b/fs/xfs/xfs_super.c
@@ -160,8 +160,6 @@ xfs_parseargs(
 	const struct super_block *sb = mp->m_super;
 	char			*p;
 	substring_t		args[MAX_OPT_ARGS];
-	int			dsunit = 0;
-	int			dswidth = 0;
 	int			iosize = 0;
 	uint8_t			iosizelog = 0;
 
@@ -254,11 +252,11 @@ xfs_parseargs(
 			mp->m_flags |= XFS_MOUNT_SWALLOC;
 			break;
 		case Opt_sunit:
-			if (match_int(args, &dsunit))
+			if (match_int(args, &mp->m_dalign))
 				return -EINVAL;
 			break;
 		case Opt_swidth:
-			if (match_int(args, &dswidth))
+			if (match_int(args, &mp->m_swidth))
 				return -EINVAL;
 			break;
 		case Opt_inode32:
@@ -352,7 +350,8 @@ xfs_parseargs(
 		return -EINVAL;
 	}
 
-	if ((mp->m_flags & XFS_MOUNT_NOALIGN) && (dsunit || dswidth)) {
+	if ((mp->m_flags & XFS_MOUNT_NOALIGN) &&
+	    (mp->m_dalign || mp->m_swidth)) {
 		xfs_warn(mp,
 	"sunit and swidth options incompatible with the noalign option");
 		return -EINVAL;
@@ -365,30 +364,20 @@ xfs_parseargs(
 	}
 #endif
 
-	if ((dsunit && !dswidth) || (!dsunit && dswidth)) {
+	if ((mp->m_dalign && !mp->m_swidth) ||
+	    (!mp->m_dalign && mp->m_swidth)) {
 		xfs_warn(mp, "sunit and swidth must be specified together");
 		return -EINVAL;
 	}
 
-	if (dsunit && (dswidth % dsunit != 0)) {
+	if (mp->m_dalign && (mp->m_swidth % mp->m_dalign != 0)) {
 		xfs_warn(mp,
 	"stripe width (%d) must be a multiple of the stripe unit (%d)",
-			dswidth, dsunit);
+			mp->m_swidth, mp->m_dalign);
 		return -EINVAL;
 	}
 
 done:
-	if (dsunit && !(mp->m_flags & XFS_MOUNT_NOALIGN)) {
-		/*
-		 * At this point the superblock has not been read
-		 * in, therefore we do not know the block size.
-		 * Before the mount call ends we will convert
-		 * these to FSBs.
-		 */
-		mp->m_dalign = dsunit;
-		mp->m_swidth = dswidth;
-	}
-
 	if (mp->m_logbufs != -1 &&
 	    mp->m_logbufs != 0 &&
 	    (mp->m_logbufs < XLOG_MIN_ICLOGS ||
-- 
2.20.1


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

* [PATCH 5/7] xfs: remove the iosizelog variable in xfs_parseargs
  2019-10-25 17:40 decruft misc mount related code Christoph Hellwig
                   ` (3 preceding siblings ...)
  2019-10-25 17:40 ` [PATCH 4/7] xfs: remove the dsunit and dswidth variables in xfs_parseargs Christoph Hellwig
@ 2019-10-25 17:40 ` Christoph Hellwig
  2019-10-25 18:35   ` Eric Sandeen
  2019-10-25 17:40 ` [PATCH 6/7] xfs: clean up setting m_readio_* / m_writeio_* Christoph Hellwig
  2019-10-25 17:40 ` [PATCH 7/7] xfs: reverse the polarity of XFS_MOUNT_COMPAT_IOSIZE Christoph Hellwig
  6 siblings, 1 reply; 21+ messages in thread
From: Christoph Hellwig @ 2019-10-25 17:40 UTC (permalink / raw)
  To: linux-xfs; +Cc: Ian Kent

There is no real need for a local variables here - either the I/O size
is valid and gets applied to the mount structure, or it is invalid and
the mount will fail entirely.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 fs/xfs/xfs_super.c | 17 +++++++----------
 1 file changed, 7 insertions(+), 10 deletions(-)

diff --git a/fs/xfs/xfs_super.c b/fs/xfs/xfs_super.c
index ee2dde897fb7..1467f4bebc41 100644
--- a/fs/xfs/xfs_super.c
+++ b/fs/xfs/xfs_super.c
@@ -161,7 +161,6 @@ xfs_parseargs(
 	char			*p;
 	substring_t		args[MAX_OPT_ARGS];
 	int			iosize = 0;
-	uint8_t			iosizelog = 0;
 
 	/*
 	 * set up the mount name first so all the errors will refer to the
@@ -229,7 +228,8 @@ xfs_parseargs(
 		case Opt_biosize:
 			if (suffix_kstrtoint(args, 10, &iosize))
 				return -EINVAL;
-			iosizelog = ffs(iosize) - 1;
+			mp->m_writeio_log = ffs(iosize) - 1;
+			mp->m_flags |= XFS_MOUNT_DFLT_IOSIZE;
 			break;
 		case Opt_grpid:
 		case Opt_bsdgroups:
@@ -397,17 +397,14 @@ xfs_parseargs(
 		return -EINVAL;
 	}
 
-	if (iosizelog) {
-		if (iosizelog > XFS_MAX_IO_LOG ||
-		    iosizelog < XFS_MIN_IO_LOG) {
+	if (mp->m_flags & XFS_MOUNT_DFLT_IOSIZE) {
+		if (mp->m_writeio_log > XFS_MAX_IO_LOG ||
+		    mp->m_writeio_log < XFS_MIN_IO_LOG) {
 			xfs_warn(mp, "invalid log iosize: %d [not %d-%d]",
-				iosizelog, XFS_MIN_IO_LOG,
-				XFS_MAX_IO_LOG);
+				mp->m_writeio_log,
+				XFS_MIN_IO_LOG, XFS_MAX_IO_LOG);
 			return -EINVAL;
 		}
-
-		mp->m_flags |= XFS_MOUNT_DFLT_IOSIZE;
-		mp->m_writeio_log = iosizelog;
 	}
 
 	return 0;
-- 
2.20.1


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

* [PATCH 6/7] xfs: clean up setting m_readio_* / m_writeio_*
  2019-10-25 17:40 decruft misc mount related code Christoph Hellwig
                   ` (4 preceding siblings ...)
  2019-10-25 17:40 ` [PATCH 5/7] xfs: remove the iosizelog variable " Christoph Hellwig
@ 2019-10-25 17:40 ` Christoph Hellwig
  2019-10-25 19:18   ` Eric Sandeen
  2019-10-25 17:40 ` [PATCH 7/7] xfs: reverse the polarity of XFS_MOUNT_COMPAT_IOSIZE Christoph Hellwig
  6 siblings, 1 reply; 21+ messages in thread
From: Christoph Hellwig @ 2019-10-25 17:40 UTC (permalink / raw)
  To: linux-xfs; +Cc: Ian Kent

Fill in the default _log values in xfs_parseargs similar to other
defaults, and open code the updates based on the on-disk superblock
in xfs_mountfs now that they are completely trivial.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 fs/xfs/xfs_mount.c | 36 +++++-------------------------------
 fs/xfs/xfs_super.c |  5 +++++
 2 files changed, 10 insertions(+), 31 deletions(-)

diff --git a/fs/xfs/xfs_mount.c b/fs/xfs/xfs_mount.c
index 9800401a7d6f..bae53fdd5d51 100644
--- a/fs/xfs/xfs_mount.c
+++ b/fs/xfs/xfs_mount.c
@@ -425,35 +425,6 @@ xfs_update_alignment(xfs_mount_t *mp)
 	return 0;
 }
 
-/*
- * Set the default minimum read and write sizes unless
- * already specified in a mount option.
- * We use smaller I/O sizes when the file system
- * is being used for NFS service (wsync mount option).
- */
-STATIC void
-xfs_set_rw_sizes(xfs_mount_t *mp)
-{
-	xfs_sb_t	*sbp = &(mp->m_sb);
-	int		writeio_log;
-
-	if (!(mp->m_flags & XFS_MOUNT_DFLT_IOSIZE)) {
-		if (mp->m_flags & XFS_MOUNT_WSYNC)
-			writeio_log = XFS_WRITEIO_LOG_WSYNC;
-		else
-			writeio_log = XFS_WRITEIO_LOG_LARGE;
-	} else {
-		writeio_log = mp->m_writeio_log;
-	}
-
-	if (sbp->sb_blocklog > writeio_log) {
-		mp->m_writeio_log = sbp->sb_blocklog;
-	} else {
-		mp->m_writeio_log = writeio_log;
-	}
-	mp->m_writeio_blocks = 1 << (mp->m_writeio_log - sbp->sb_blocklog);
-}
-
 /*
  * precalculate the low space thresholds for dynamic speculative preallocation.
  */
@@ -718,9 +689,12 @@ xfs_mountfs(
 		goto out_remove_errortag;
 
 	/*
-	 * Set the minimum read and write sizes
+	 * Update the preferred write size based on the information from the
+	 * on-disk superblock.
 	 */
-	xfs_set_rw_sizes(mp);
+	mp->m_writeio_log =
+		max_t(uint32_t, mp->m_sb.sb_blocklog, mp->m_writeio_log);
+	mp->m_writeio_blocks = 1 << (mp->m_writeio_log - mp->m_sb.sb_blocklog);
 
 	/* set the low space thresholds for dynamic preallocation */
 	xfs_set_low_space_thresholds(mp);
diff --git a/fs/xfs/xfs_super.c b/fs/xfs/xfs_super.c
index 1467f4bebc41..83dbfcc5a02d 100644
--- a/fs/xfs/xfs_super.c
+++ b/fs/xfs/xfs_super.c
@@ -405,6 +405,11 @@ xfs_parseargs(
 				XFS_MIN_IO_LOG, XFS_MAX_IO_LOG);
 			return -EINVAL;
 		}
+	} else {
+		if (mp->m_flags & XFS_MOUNT_WSYNC)
+			mp->m_writeio_log = XFS_WRITEIO_LOG_WSYNC;
+		else
+			mp->m_writeio_log = XFS_WRITEIO_LOG_LARGE;
 	}
 
 	return 0;
-- 
2.20.1


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

* [PATCH 7/7] xfs: reverse the polarity of XFS_MOUNT_COMPAT_IOSIZE
  2019-10-25 17:40 decruft misc mount related code Christoph Hellwig
                   ` (5 preceding siblings ...)
  2019-10-25 17:40 ` [PATCH 6/7] xfs: clean up setting m_readio_* / m_writeio_* Christoph Hellwig
@ 2019-10-25 17:40 ` Christoph Hellwig
  2019-10-25 19:24   ` Eric Sandeen
  6 siblings, 1 reply; 21+ messages in thread
From: Christoph Hellwig @ 2019-10-25 17:40 UTC (permalink / raw)
  To: linux-xfs; +Cc: Ian Kent

Replace XFS_MOUNT_COMPAT_IOSIZE with an inverted XFS_MOUNT_LARGEIO flag
that makes the usage more clear.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 fs/xfs/xfs_iops.c  |  2 +-
 fs/xfs/xfs_mount.h |  2 +-
 fs/xfs/xfs_super.c | 12 +++---------
 3 files changed, 5 insertions(+), 11 deletions(-)

diff --git a/fs/xfs/xfs_iops.c b/fs/xfs/xfs_iops.c
index 271fcbe04d48..98e30a300c64 100644
--- a/fs/xfs/xfs_iops.c
+++ b/fs/xfs/xfs_iops.c
@@ -510,7 +510,7 @@ xfs_stat_blksize(
 	 * default buffered I/O size, return that, otherwise return the compat
 	 * default.
 	 */
-	if (!(mp->m_flags & XFS_MOUNT_COMPAT_IOSIZE)) {
+	if (mp->m_flags & XFS_MOUNT_LARGEIO) {
 		if (mp->m_swidth)
 			return mp->m_swidth << mp->m_sb.sb_blocklog;
 		if (mp->m_flags & XFS_MOUNT_DFLT_IOSIZE)
diff --git a/fs/xfs/xfs_mount.h b/fs/xfs/xfs_mount.h
index fb3a36a048cc..dde45d5664f4 100644
--- a/fs/xfs/xfs_mount.h
+++ b/fs/xfs/xfs_mount.h
@@ -236,7 +236,7 @@ typedef struct xfs_mount {
 						 * allocation */
 #define XFS_MOUNT_RDONLY	(1ULL << 20)	/* read-only fs */
 #define XFS_MOUNT_DIRSYNC	(1ULL << 21)	/* synchronous directory ops */
-#define XFS_MOUNT_COMPAT_IOSIZE	(1ULL << 22)	/* don't report large preferred
+#define XFS_MOUNT_LARGEIO	(1ULL << 22)	/* report large preferred
 						 * I/O size in stat() */
 #define XFS_MOUNT_FILESTREAMS	(1ULL << 24)	/* enable the filestreams
 						   allocator */
diff --git a/fs/xfs/xfs_super.c b/fs/xfs/xfs_super.c
index 83dbfcc5a02d..52f4629278b0 100644
--- a/fs/xfs/xfs_super.c
+++ b/fs/xfs/xfs_super.c
@@ -181,12 +181,6 @@ xfs_parseargs(
 	if (sb->s_flags & SB_SYNCHRONOUS)
 		mp->m_flags |= XFS_MOUNT_WSYNC;
 
-	/*
-	 * Set some default flags that could be cleared by the mount option
-	 * parsing.
-	 */
-	mp->m_flags |= XFS_MOUNT_COMPAT_IOSIZE;
-
 	/*
 	 * These can be overridden by the mount option parsing.
 	 */
@@ -275,10 +269,10 @@ xfs_parseargs(
 			mp->m_flags &= ~XFS_MOUNT_IKEEP;
 			break;
 		case Opt_largeio:
-			mp->m_flags &= ~XFS_MOUNT_COMPAT_IOSIZE;
+			mp->m_flags |= XFS_MOUNT_LARGEIO;
 			break;
 		case Opt_nolargeio:
-			mp->m_flags |= XFS_MOUNT_COMPAT_IOSIZE;
+			mp->m_flags &= ~XFS_MOUNT_LARGEIO;
 			break;
 		case Opt_attr2:
 			mp->m_flags |= XFS_MOUNT_ATTR2;
@@ -438,12 +432,12 @@ xfs_showargs(
 		{ XFS_MOUNT_GRPID,		",grpid" },
 		{ XFS_MOUNT_DISCARD,		",discard" },
 		{ XFS_MOUNT_SMALL_INUMS,	",inode32" },
+		{ XFS_MOUNT_LARGEIO,		",largeio" },
 		{ XFS_MOUNT_DAX,		",dax" },
 		{ 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,	",largeio" },
 		{ XFS_MOUNT_SMALL_INUMS,	",inode64" },
 		{ 0, NULL }
 	};
-- 
2.20.1


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

* Re: [PATCH 1/7] xfs: cleanup stat blksize reporting
  2019-10-25 17:40 ` [PATCH 1/7] xfs: cleanup stat blksize reporting Christoph Hellwig
@ 2019-10-25 17:56   ` Eric Sandeen
  0 siblings, 0 replies; 21+ messages in thread
From: Eric Sandeen @ 2019-10-25 17:56 UTC (permalink / raw)
  To: Christoph Hellwig, linux-xfs; +Cc: Ian Kent

On 10/25/19 12:40 PM, Christoph Hellwig wrote:
> Move xfs_preferred_iosize to xfs_iops.c, unobsfucate it and also handle
> the realtime special case in the helper.
> 
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> ---
>  fs/xfs/xfs_iops.c  | 47 ++++++++++++++++++++++++++++++++++++----------
>  fs/xfs/xfs_mount.h | 24 -----------------------
>  2 files changed, 37 insertions(+), 34 deletions(-)

Looks legit.

Reviewed-by: Eric Sandeen <sandeen@redhat.com>


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

* Re: [PATCH 2/7] xfs: remove the unused m_readio_blocks field from struct xfs_mount
  2019-10-25 17:40 ` [PATCH 2/7] xfs: remove the unused m_readio_blocks field from struct xfs_mount Christoph Hellwig
@ 2019-10-25 18:02   ` Eric Sandeen
  0 siblings, 0 replies; 21+ messages in thread
From: Eric Sandeen @ 2019-10-25 18:02 UTC (permalink / raw)
  To: Christoph Hellwig, linux-xfs; +Cc: Ian Kent

On 10/25/19 12:40 PM, Christoph Hellwig wrote:
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> ---
>  fs/xfs/xfs_mount.c | 1 -
>  fs/xfs/xfs_mount.h | 1 -
>  2 files changed, 2 deletions(-)

Reviewed-by: Eric Sandeen <sandeen@redhat.com>



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

* Re: [PATCH 3/7] xfs: remove the m_readio_log field from struct xfs_mount
  2019-10-25 17:40 ` [PATCH 3/7] xfs: remove the m_readio_log " Christoph Hellwig
@ 2019-10-25 18:26   ` Eric Sandeen
  2019-10-25 20:43     ` Dave Chinner
  0 siblings, 1 reply; 21+ messages in thread
From: Eric Sandeen @ 2019-10-25 18:26 UTC (permalink / raw)
  To: Christoph Hellwig, linux-xfs; +Cc: Ian Kent

On 10/25/19 12:40 PM, Christoph Hellwig wrote:
> The m_readio_log is only used for reporting the blksize (aka preferred
> I/O size) in struct stat.  For all cases but a file system that does not
> use stripe alignment, but which has the wsync and largeio mount option
> set the value is the same as the write I/O size.
> 
> Remove the field and report a smaller preferred I/O size for that corner
> case, which actually is the right thing to do for that case (except for
> the fact that is probably is entirely unused).

hm, I wonder what the history of the WSYNC_ sizes are, tbh.  So while I can't
speak to the need for a separate READIO_LOG or not, this doesn't seem 
too far fetched...

If Dave remembers something about NFS behavior, he can nak my rvb :)

Reviewed-by: Eric Sandeen <sandeen@redhat.com>

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

* Re: [PATCH 4/7] xfs: remove the dsunit and dswidth variables in xfs_parseargs
  2019-10-25 17:40 ` [PATCH 4/7] xfs: remove the dsunit and dswidth variables in xfs_parseargs Christoph Hellwig
@ 2019-10-25 18:29   ` Eric Sandeen
  0 siblings, 0 replies; 21+ messages in thread
From: Eric Sandeen @ 2019-10-25 18:29 UTC (permalink / raw)
  To: Christoph Hellwig, linux-xfs; +Cc: Ian Kent

On 10/25/19 12:40 PM, Christoph Hellwig wrote:
> There is no real need for the local variables here - either they
> are applied to the mount structure, or if the noalign mount option
> is set the mount will fail entirely if either is set.  Removing
> them helps cleaning up the mount API conversion.

<checks that mp is zeroed on allocation - it is>

Reviewed-by: Eric Sandeen <sandeen@redhat.com>

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

* Re: [PATCH 5/7] xfs: remove the iosizelog variable in xfs_parseargs
  2019-10-25 17:40 ` [PATCH 5/7] xfs: remove the iosizelog variable " Christoph Hellwig
@ 2019-10-25 18:35   ` Eric Sandeen
  2019-10-25 19:03     ` Eric Sandeen
  0 siblings, 1 reply; 21+ messages in thread
From: Eric Sandeen @ 2019-10-25 18:35 UTC (permalink / raw)
  To: Christoph Hellwig, linux-xfs; +Cc: Ian Kent

On 10/25/19 12:40 PM, Christoph Hellwig wrote:
> There is no real need for a local variables here - either the I/O size
> is valid and gets applied to the mount structure, or it is invalid and
> the mount will fail entirely.
> 
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> ---
>  fs/xfs/xfs_super.c | 17 +++++++----------
>  1 file changed, 7 insertions(+), 10 deletions(-)
> 
> diff --git a/fs/xfs/xfs_super.c b/fs/xfs/xfs_super.c
> index ee2dde897fb7..1467f4bebc41 100644
> --- a/fs/xfs/xfs_super.c
> +++ b/fs/xfs/xfs_super.c
> @@ -161,7 +161,6 @@ xfs_parseargs(
>  	char			*p;
>  	substring_t		args[MAX_OPT_ARGS];
>  	int			iosize = 0;
> -	uint8_t			iosizelog = 0;
>  
>  	/*
>  	 * set up the mount name first so all the errors will refer to the
> @@ -229,7 +228,8 @@ xfs_parseargs(
>  		case Opt_biosize:
>  			if (suffix_kstrtoint(args, 10, &iosize))
>  				return -EINVAL;
> -			iosizelog = ffs(iosize) - 1;
> +			mp->m_writeio_log = ffs(iosize) - 1;
> +			mp->m_flags |= XFS_MOUNT_DFLT_IOSIZE;
>  			break;
>  		case Opt_grpid:
>  		case Opt_bsdgroups:
> @@ -397,17 +397,14 @@ xfs_parseargs(
>  		return -EINVAL;
>  	}
>  
> -	if (iosizelog) {
> -		if (iosizelog > XFS_MAX_IO_LOG ||
> -		    iosizelog < XFS_MIN_IO_LOG) {
> +	if (mp->m_flags & XFS_MOUNT_DFLT_IOSIZE) {
> +		if (mp->m_writeio_log > XFS_MAX_IO_LOG ||
> +		    mp->m_writeio_log < XFS_MIN_IO_LOG) {

There's a slight change in behavior here.

Before, "mount -o biosize=0" would pass, because iosizelog, though specified,
did not satisfy "if (iosizelog)"and so it was never tested, so it was
essentially ignored.

Now the same specification will fail mount.

To make this a completely cosmetic change, perhaps this should test
mp->m_writeio_log rather than the flag.

If a change in behavior is desired I think that should be an explicit
2nd change.

>  			xfs_warn(mp, "invalid log iosize: %d [not %d-%d]",
> -				iosizelog, XFS_MIN_IO_LOG,
> -				XFS_MAX_IO_LOG);
> +				mp->m_writeio_log,
> +				XFS_MIN_IO_LOG, XFS_MAX_IO_LOG);
>  			return -EINVAL;
>  		}
> -
> -		mp->m_flags |= XFS_MOUNT_DFLT_IOSIZE;
> -		mp->m_writeio_log = iosizelog;
>  	}
>  
>  	return 0;
> 

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

* Re: [PATCH 5/7] xfs: remove the iosizelog variable in xfs_parseargs
  2019-10-25 18:35   ` Eric Sandeen
@ 2019-10-25 19:03     ` Eric Sandeen
  2019-10-26  5:47       ` Christoph Hellwig
  0 siblings, 1 reply; 21+ messages in thread
From: Eric Sandeen @ 2019-10-25 19:03 UTC (permalink / raw)
  To: Christoph Hellwig, linux-xfs; +Cc: Ian Kent

On 10/25/19 1:35 PM, Eric Sandeen wrote:

> There's a slight change in behavior here.
> 
> Before, "mount -o biosize=0" would pass, because iosizelog, though specified,
> did not satisfy "if (iosizelog)"and so it was never tested, so it was
> essentially ignored.

sorry make that "-o allocsize=0"

Which I guess /is/ documented as being invalid, we just never rejected it
before.

Still a change in behavior and worth being explicit about I think.

-Eric

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

* Re: [PATCH 6/7] xfs: clean up setting m_readio_* / m_writeio_*
  2019-10-25 17:40 ` [PATCH 6/7] xfs: clean up setting m_readio_* / m_writeio_* Christoph Hellwig
@ 2019-10-25 19:18   ` Eric Sandeen
  2019-10-25 20:53     ` Dave Chinner
  0 siblings, 1 reply; 21+ messages in thread
From: Eric Sandeen @ 2019-10-25 19:18 UTC (permalink / raw)
  To: Christoph Hellwig, linux-xfs; +Cc: Ian Kent

On 10/25/19 12:40 PM, Christoph Hellwig wrote:
> Fill in the default _log values in xfs_parseargs similar to other
> defaults, and open code the updates based on the on-disk superblock
> in xfs_mountfs now that they are completely trivial.
> 
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> ---
>  fs/xfs/xfs_mount.c | 36 +++++-------------------------------
>  fs/xfs/xfs_super.c |  5 +++++
>  2 files changed, 10 insertions(+), 31 deletions(-)
> 
> diff --git a/fs/xfs/xfs_mount.c b/fs/xfs/xfs_mount.c
> index 9800401a7d6f..bae53fdd5d51 100644
> --- a/fs/xfs/xfs_mount.c
> +++ b/fs/xfs/xfs_mount.c
> @@ -425,35 +425,6 @@ xfs_update_alignment(xfs_mount_t *mp)
>  	return 0;
>  }
>  
> -/*
> - * Set the default minimum read and write sizes unless
> - * already specified in a mount option.
> - * We use smaller I/O sizes when the file system
> - * is being used for NFS service (wsync mount option).
> - */
> -STATIC void
> -xfs_set_rw_sizes(xfs_mount_t *mp)
> -{
> -	xfs_sb_t	*sbp = &(mp->m_sb);
> -	int		writeio_log;
> -
> -	if (!(mp->m_flags & XFS_MOUNT_DFLT_IOSIZE)) {
> -		if (mp->m_flags & XFS_MOUNT_WSYNC)
> -			writeio_log = XFS_WRITEIO_LOG_WSYNC;
> -		else
> -			writeio_log = XFS_WRITEIO_LOG_LARGE;
> -	} else {
> -		writeio_log = mp->m_writeio_log;
> -	}
> -
> -	if (sbp->sb_blocklog > writeio_log) {
> -		mp->m_writeio_log = sbp->sb_blocklog;
> -	} else {
> -		mp->m_writeio_log = writeio_log;
> -	}
> -	mp->m_writeio_blocks = 1 << (mp->m_writeio_log - sbp->sb_blocklog);
> -}
> -
>  /*
>   * precalculate the low space thresholds for dynamic speculative preallocation.
>   */
> @@ -718,9 +689,12 @@ xfs_mountfs(
>  		goto out_remove_errortag;
>  
>  	/*
> -	 * Set the minimum read and write sizes
> +	 * Update the preferred write size based on the information from the
> +	 * on-disk superblock.
>  	 */
> -	xfs_set_rw_sizes(mp);
> +	mp->m_writeio_log =
> +		max_t(uint32_t, mp->m_sb.sb_blocklog, mp->m_writeio_log);
> +	mp->m_writeio_blocks = 1 << (mp->m_writeio_log - mp->m_sb.sb_blocklog);
>  
>  	/* set the low space thresholds for dynamic preallocation */
>  	xfs_set_low_space_thresholds(mp);
> diff --git a/fs/xfs/xfs_super.c b/fs/xfs/xfs_super.c
> index 1467f4bebc41..83dbfcc5a02d 100644
> --- a/fs/xfs/xfs_super.c
> +++ b/fs/xfs/xfs_super.c
> @@ -405,6 +405,11 @@ xfs_parseargs(
>  				XFS_MIN_IO_LOG, XFS_MAX_IO_LOG);
>  			return -EINVAL;
>  		}
> +	} else {
> +		if (mp->m_flags & XFS_MOUNT_WSYNC)
> +			mp->m_writeio_log = XFS_WRITEIO_LOG_WSYNC;
> +		else
> +			mp->m_writeio_log = XFS_WRITEIO_LOG_LARGE;
>  	}

Ok let's see, by here, if Opt_allocsize was specified, we set
mp->m_writeio_log to the specified value, else if Opt_wsync was set, we 
set m_writeio_log to XFS_WRITEIO_LOG_WSYNC (14), otherwise we default to
XFS_WRITEIO_LOG_LARGE (16).  So that's it for parseargs.

AFAICT we can't escape parseargs w/ writeio_log less than PAGE_SHIFT
(i.e. page size).

Then in xfs_mountfs, you have it reset to the max of sb_blocklog and
m_writeio_log.  i.e. it gets resized iff sb_blocklog is greater than
the current m_writeio_log, which has a minimum of page size.

IOWS, it only gets a new value in mountfs if block size is > page size.

Which is a little surprising and nonobvious and it makes me wonder
if you're intentionally future-proofing here, or if that's just weird.
:)

-Eric


>  	return 0;
> 

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

* Re: [PATCH 7/7] xfs: reverse the polarity of XFS_MOUNT_COMPAT_IOSIZE
  2019-10-25 17:40 ` [PATCH 7/7] xfs: reverse the polarity of XFS_MOUNT_COMPAT_IOSIZE Christoph Hellwig
@ 2019-10-25 19:24   ` Eric Sandeen
  0 siblings, 0 replies; 21+ messages in thread
From: Eric Sandeen @ 2019-10-25 19:24 UTC (permalink / raw)
  To: Christoph Hellwig, linux-xfs; +Cc: Ian Kent

On 10/25/19 12:40 PM, Christoph Hellwig wrote:
> Replace XFS_MOUNT_COMPAT_IOSIZE with an inverted XFS_MOUNT_LARGEIO flag
> that makes the usage more clear.
> 
> Signed-off-by: Christoph Hellwig <hch@lst.de>

I like it.

Reviewed-by: Eric Sandeen <sandeen@redhat.com>

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

* Re: [PATCH 3/7] xfs: remove the m_readio_log field from struct xfs_mount
  2019-10-25 18:26   ` Eric Sandeen
@ 2019-10-25 20:43     ` Dave Chinner
  2019-10-26  5:47       ` Christoph Hellwig
  0 siblings, 1 reply; 21+ messages in thread
From: Dave Chinner @ 2019-10-25 20:43 UTC (permalink / raw)
  To: Eric Sandeen; +Cc: Christoph Hellwig, linux-xfs, Ian Kent

On Fri, Oct 25, 2019 at 01:26:05PM -0500, Eric Sandeen wrote:
> On 10/25/19 12:40 PM, Christoph Hellwig wrote:
> > The m_readio_log is only used for reporting the blksize (aka preferred
> > I/O size) in struct stat.  For all cases but a file system that does not
> > use stripe alignment, but which has the wsync and largeio mount option
> > set the value is the same as the write I/O size.
> > 
> > Remove the field and report a smaller preferred I/O size for that corner
> > case, which actually is the right thing to do for that case (except for
> > the fact that is probably is entirely unused).
> 
> hm, I wonder what the history of the WSYNC_ sizes are, tbh.  So while I can't
> speak to the need for a separate READIO_LOG or not, this doesn't seem 
> too far fetched...

NFSv2 had a maximum client IO size of 8kB and writes were
synchronous. The Irix NFS server had some magic in it (enabled by
the filesystem wsync mount option) that allowed clients to have two
sequential 8k writes in flight at once, allowing XFS to optimise for
16KB write IOs instead of the normal default of 64kB. This
optimisation was the reason that, at the time (early-mid 90s), SGI
machines had double the NFS write throughput of any other Unix
systems.

I'm surprised we still support NFSv2 at all in this day and age - I
suspect we should just kill NFSv2 altogether. We need to keep the
wsync option around for HA systems serving files to NFS and CIFS
clients, but the 8kB IO size optimisations can certainly die....

Cheers,

Dave.
-- 
Dave Chinner
david@fromorbit.com

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

* Re: [PATCH 6/7] xfs: clean up setting m_readio_* / m_writeio_*
  2019-10-25 19:18   ` Eric Sandeen
@ 2019-10-25 20:53     ` Dave Chinner
  2019-10-27  2:23       ` Eric Sandeen
  0 siblings, 1 reply; 21+ messages in thread
From: Dave Chinner @ 2019-10-25 20:53 UTC (permalink / raw)
  To: Eric Sandeen; +Cc: Christoph Hellwig, linux-xfs, Ian Kent

On Fri, Oct 25, 2019 at 02:18:02PM -0500, Eric Sandeen wrote:
> On 10/25/19 12:40 PM, Christoph Hellwig wrote:
> > Fill in the default _log values in xfs_parseargs similar to other
> > defaults, and open code the updates based on the on-disk superblock
> > in xfs_mountfs now that they are completely trivial.
> > 
> > Signed-off-by: Christoph Hellwig <hch@lst.de>
> > ---
> >  fs/xfs/xfs_mount.c | 36 +++++-------------------------------
> >  fs/xfs/xfs_super.c |  5 +++++
> >  2 files changed, 10 insertions(+), 31 deletions(-)
> > 
> > diff --git a/fs/xfs/xfs_mount.c b/fs/xfs/xfs_mount.c
> > index 9800401a7d6f..bae53fdd5d51 100644
> > --- a/fs/xfs/xfs_mount.c
> > +++ b/fs/xfs/xfs_mount.c
> > @@ -425,35 +425,6 @@ xfs_update_alignment(xfs_mount_t *mp)
> >  	return 0;
> >  }
> >  
> > -/*
> > - * Set the default minimum read and write sizes unless
> > - * already specified in a mount option.
> > - * We use smaller I/O sizes when the file system
> > - * is being used for NFS service (wsync mount option).
> > - */
> > -STATIC void
> > -xfs_set_rw_sizes(xfs_mount_t *mp)
> > -{
> > -	xfs_sb_t	*sbp = &(mp->m_sb);
> > -	int		writeio_log;
> > -
> > -	if (!(mp->m_flags & XFS_MOUNT_DFLT_IOSIZE)) {
> > -		if (mp->m_flags & XFS_MOUNT_WSYNC)
> > -			writeio_log = XFS_WRITEIO_LOG_WSYNC;
> > -		else
> > -			writeio_log = XFS_WRITEIO_LOG_LARGE;
> > -	} else {
> > -		writeio_log = mp->m_writeio_log;
> > -	}
> > -
> > -	if (sbp->sb_blocklog > writeio_log) {
> > -		mp->m_writeio_log = sbp->sb_blocklog;
> > -	} else {
> > -		mp->m_writeio_log = writeio_log;
> > -	}
> > -	mp->m_writeio_blocks = 1 << (mp->m_writeio_log - sbp->sb_blocklog);
> > -}
> > -
> >  /*
> >   * precalculate the low space thresholds for dynamic speculative preallocation.
> >   */
> > @@ -718,9 +689,12 @@ xfs_mountfs(
> >  		goto out_remove_errortag;
> >  
> >  	/*
> > -	 * Set the minimum read and write sizes
> > +	 * Update the preferred write size based on the information from the
> > +	 * on-disk superblock.
> >  	 */
> > -	xfs_set_rw_sizes(mp);
> > +	mp->m_writeio_log =
> > +		max_t(uint32_t, mp->m_sb.sb_blocklog, mp->m_writeio_log);
> > +	mp->m_writeio_blocks = 1 << (mp->m_writeio_log - mp->m_sb.sb_blocklog);
> >  
> >  	/* set the low space thresholds for dynamic preallocation */
> >  	xfs_set_low_space_thresholds(mp);
> > diff --git a/fs/xfs/xfs_super.c b/fs/xfs/xfs_super.c
> > index 1467f4bebc41..83dbfcc5a02d 100644
> > --- a/fs/xfs/xfs_super.c
> > +++ b/fs/xfs/xfs_super.c
> > @@ -405,6 +405,11 @@ xfs_parseargs(
> >  				XFS_MIN_IO_LOG, XFS_MAX_IO_LOG);
> >  			return -EINVAL;
> >  		}
> > +	} else {
> > +		if (mp->m_flags & XFS_MOUNT_WSYNC)
> > +			mp->m_writeio_log = XFS_WRITEIO_LOG_WSYNC;
> > +		else
> > +			mp->m_writeio_log = XFS_WRITEIO_LOG_LARGE;
> >  	}
> 
> Ok let's see, by here, if Opt_allocsize was specified, we set
> mp->m_writeio_log to the specified value, else if Opt_wsync was set, we 
> set m_writeio_log to XFS_WRITEIO_LOG_WSYNC (14), otherwise we default to
> XFS_WRITEIO_LOG_LARGE (16).  So that's it for parseargs.
> 
> AFAICT we can't escape parseargs w/ writeio_log less than PAGE_SHIFT
> (i.e. page size).

We can - 64k page size means XFS_WRITEIO_LOG_WSYNC is less than
PAGE_SHIFT, so it can escape here.

> Then in xfs_mountfs, you have it reset to the max of sb_blocklog and
> m_writeio_log.  i.e. it gets resized iff sb_blocklog is greater than
> the current m_writeio_log, which has a minimum of page size.
> 
> IOWS, it only gets a new value in mountfs if block size is > page size.

Which will never be true on 64k page size machines, but that's not
what this code does, anyway. It will rewrite m_writeio_log if the
block size is larger than the m_writeio_log value, so it preserves
the existing behaviour of setting the m_writeio_log value to a
minimum of one filesystem block....

Cheers,

Dave.

-- 
Dave Chinner
david@fromorbit.com

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

* Re: [PATCH 3/7] xfs: remove the m_readio_log field from struct xfs_mount
  2019-10-25 20:43     ` Dave Chinner
@ 2019-10-26  5:47       ` Christoph Hellwig
  0 siblings, 0 replies; 21+ messages in thread
From: Christoph Hellwig @ 2019-10-26  5:47 UTC (permalink / raw)
  To: Dave Chinner; +Cc: Eric Sandeen, Christoph Hellwig, linux-xfs, Ian Kent

On Sat, Oct 26, 2019 at 07:43:29AM +1100, Dave Chinner wrote:
> NFSv2 had a maximum client IO size of 8kB and writes were
> synchronous. The Irix NFS server had some magic in it (enabled by
> the filesystem wsync mount option) that allowed clients to have two
> sequential 8k writes in flight at once, allowing XFS to optimise for
> 16KB write IOs instead of the normal default of 64kB. This
> optimisation was the reason that, at the time (early-mid 90s), SGI
> machines had double the NFS write throughput of any other Unix
> systems.
> 
> I'm surprised we still support NFSv2 at all in this day and age - I
> suspect we should just kill NFSv2 altogether. We need to keep the
> wsync option around for HA systems serving files to NFS and CIFS
> clients, but the 8kB IO size optimisations can certainly die....

Last time I talked to the NFS folks there still were some very obscure
v2 use cases left (embedded devices that can't be upgraded).

But yeah, I'll add a patch to stop overriding rsize/wsize with the
sync option.

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

* Re: [PATCH 5/7] xfs: remove the iosizelog variable in xfs_parseargs
  2019-10-25 19:03     ` Eric Sandeen
@ 2019-10-26  5:47       ` Christoph Hellwig
  0 siblings, 0 replies; 21+ messages in thread
From: Christoph Hellwig @ 2019-10-26  5:47 UTC (permalink / raw)
  To: Eric Sandeen; +Cc: Christoph Hellwig, linux-xfs, Ian Kent

On Fri, Oct 25, 2019 at 02:03:06PM -0500, Eric Sandeen wrote:
> sorry make that "-o allocsize=0"
> 
> Which I guess /is/ documented as being invalid, we just never rejected it
> before.
> 
> Still a change in behavior and worth being explicit about I think.

I'll updated the changelog to mention that.

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

* Re: [PATCH 6/7] xfs: clean up setting m_readio_* / m_writeio_*
  2019-10-25 20:53     ` Dave Chinner
@ 2019-10-27  2:23       ` Eric Sandeen
  0 siblings, 0 replies; 21+ messages in thread
From: Eric Sandeen @ 2019-10-27  2:23 UTC (permalink / raw)
  To: Dave Chinner; +Cc: Christoph Hellwig, linux-xfs, Ian Kent

On 10/25/19 3:53 PM, Dave Chinner wrote:
> On Fri, Oct 25, 2019 at 02:18:02PM -0500, Eric Sandeen wrote:
>> On 10/25/19 12:40 PM, Christoph Hellwig wrote:
>>> Fill in the default _log values in xfs_parseargs similar to other
>>> defaults, and open code the updates based on the on-disk superblock
>>> in xfs_mountfs now that they are completely trivial.
>>>
>>> Signed-off-by: Christoph Hellwig <hch@lst.de>
>>> ---
>>>  fs/xfs/xfs_mount.c | 36 +++++-------------------------------
>>>  fs/xfs/xfs_super.c |  5 +++++
>>>  2 files changed, 10 insertions(+), 31 deletions(-)
>>>
>>> diff --git a/fs/xfs/xfs_mount.c b/fs/xfs/xfs_mount.c
>>> index 9800401a7d6f..bae53fdd5d51 100644
>>> --- a/fs/xfs/xfs_mount.c
>>> +++ b/fs/xfs/xfs_mount.c
>>> @@ -425,35 +425,6 @@ xfs_update_alignment(xfs_mount_t *mp)
>>>  	return 0;
>>>  }
>>>  
>>> -/*
>>> - * Set the default minimum read and write sizes unless
>>> - * already specified in a mount option.
>>> - * We use smaller I/O sizes when the file system
>>> - * is being used for NFS service (wsync mount option).
>>> - */
>>> -STATIC void
>>> -xfs_set_rw_sizes(xfs_mount_t *mp)
>>> -{
>>> -	xfs_sb_t	*sbp = &(mp->m_sb);
>>> -	int		writeio_log;
>>> -
>>> -	if (!(mp->m_flags & XFS_MOUNT_DFLT_IOSIZE)) {
>>> -		if (mp->m_flags & XFS_MOUNT_WSYNC)
>>> -			writeio_log = XFS_WRITEIO_LOG_WSYNC;
>>> -		else
>>> -			writeio_log = XFS_WRITEIO_LOG_LARGE;
>>> -	} else {
>>> -		writeio_log = mp->m_writeio_log;
>>> -	}
>>> -
>>> -	if (sbp->sb_blocklog > writeio_log) {
>>> -		mp->m_writeio_log = sbp->sb_blocklog;
>>> -	} else {
>>> -		mp->m_writeio_log = writeio_log;
>>> -	}
>>> -	mp->m_writeio_blocks = 1 << (mp->m_writeio_log - sbp->sb_blocklog);
>>> -}
>>> -
>>>  /*
>>>   * precalculate the low space thresholds for dynamic speculative preallocation.
>>>   */
>>> @@ -718,9 +689,12 @@ xfs_mountfs(
>>>  		goto out_remove_errortag;
>>>  
>>>  	/*
>>> -	 * Set the minimum read and write sizes
>>> +	 * Update the preferred write size based on the information from the
>>> +	 * on-disk superblock.
>>>  	 */
>>> -	xfs_set_rw_sizes(mp);
>>> +	mp->m_writeio_log =
>>> +		max_t(uint32_t, mp->m_sb.sb_blocklog, mp->m_writeio_log);
>>> +	mp->m_writeio_blocks = 1 << (mp->m_writeio_log - mp->m_sb.sb_blocklog);
>>>  
>>>  	/* set the low space thresholds for dynamic preallocation */
>>>  	xfs_set_low_space_thresholds(mp);
>>> diff --git a/fs/xfs/xfs_super.c b/fs/xfs/xfs_super.c
>>> index 1467f4bebc41..83dbfcc5a02d 100644
>>> --- a/fs/xfs/xfs_super.c
>>> +++ b/fs/xfs/xfs_super.c
>>> @@ -405,6 +405,11 @@ xfs_parseargs(
>>>  				XFS_MIN_IO_LOG, XFS_MAX_IO_LOG);
>>>  			return -EINVAL;
>>>  		}
>>> +	} else {
>>> +		if (mp->m_flags & XFS_MOUNT_WSYNC)
>>> +			mp->m_writeio_log = XFS_WRITEIO_LOG_WSYNC;
>>> +		else
>>> +			mp->m_writeio_log = XFS_WRITEIO_LOG_LARGE;
>>>  	}
>>
>> Ok let's see, by here, if Opt_allocsize was specified, we set
>> mp->m_writeio_log to the specified value, else if Opt_wsync was set, we 
>> set m_writeio_log to XFS_WRITEIO_LOG_WSYNC (14), otherwise we default to
>> XFS_WRITEIO_LOG_LARGE (16).  So that's it for parseargs.
>>
>> AFAICT we can't escape parseargs w/ writeio_log less than PAGE_SHIFT
>> (i.e. page size).
> 
> We can - 64k page size means XFS_WRITEIO_LOG_WSYNC is less than
> PAGE_SHIFT, so it can escape here.

Whoops my brain just hotwires PAGE to 4k occasionally, thanks.

>> Then in xfs_mountfs, you have it reset to the max of sb_blocklog and
>> m_writeio_log.  i.e. it gets resized iff sb_blocklog is greater than
>> the current m_writeio_log, which has a minimum of page size.
>>
>> IOWS, it only gets a new value in mountfs if block size is > page size.
> 
> Which will never be true on 64k page size machines, but that's not
> what this code does, anyway. It will rewrite m_writeio_log if the
> block size is larger than the m_writeio_log value, so it preserves
> the existing behaviour of setting the m_writeio_log value to a
> minimum of one filesystem block....

Right, ok, thanks for straightening me out.

-Eric

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

end of thread, other threads:[~2019-10-27  2:23 UTC | newest]

Thread overview: 21+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-10-25 17:40 decruft misc mount related code Christoph Hellwig
2019-10-25 17:40 ` [PATCH 1/7] xfs: cleanup stat blksize reporting Christoph Hellwig
2019-10-25 17:56   ` Eric Sandeen
2019-10-25 17:40 ` [PATCH 2/7] xfs: remove the unused m_readio_blocks field from struct xfs_mount Christoph Hellwig
2019-10-25 18:02   ` Eric Sandeen
2019-10-25 17:40 ` [PATCH 3/7] xfs: remove the m_readio_log " Christoph Hellwig
2019-10-25 18:26   ` Eric Sandeen
2019-10-25 20:43     ` Dave Chinner
2019-10-26  5:47       ` Christoph Hellwig
2019-10-25 17:40 ` [PATCH 4/7] xfs: remove the dsunit and dswidth variables in xfs_parseargs Christoph Hellwig
2019-10-25 18:29   ` Eric Sandeen
2019-10-25 17:40 ` [PATCH 5/7] xfs: remove the iosizelog variable " Christoph Hellwig
2019-10-25 18:35   ` Eric Sandeen
2019-10-25 19:03     ` Eric Sandeen
2019-10-26  5:47       ` Christoph Hellwig
2019-10-25 17:40 ` [PATCH 6/7] xfs: clean up setting m_readio_* / m_writeio_* Christoph Hellwig
2019-10-25 19:18   ` Eric Sandeen
2019-10-25 20:53     ` Dave Chinner
2019-10-27  2:23       ` Eric Sandeen
2019-10-25 17:40 ` [PATCH 7/7] xfs: reverse the polarity of XFS_MOUNT_COMPAT_IOSIZE Christoph Hellwig
2019-10-25 19:24   ` Eric Sandeen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).