Skip to contentSkip to conversation

cleanup block-style layouts exports v2

PATCH In review Christoph Hellwig 4 participants 18 messages Apr 1 – Apr 27

Subsystems (6)
lore
Share & tools
lore

Christoph Hellwig

author reviewer
#0 lore raw

Hi all,

this series cleanups the exportfs support for block-style layouts that provide direct block device access. This is preparation for supporting exportfs of more than a single device per file system.

Changes since v1:
- consity struct exportfs_block_ops
- fix spelling

Changes since the multi-device export series:
- check for NULL bops in nfsd4_setup_layout_type
- clearly document why we are ignoring loca_time_modify

Diffstat:

 MAINTAINERS                    |    2 
 fs/nfsd/blocklayout.c          |   37 +++++++----------
 fs/nfsd/export.c               |    3 -
 fs/nfsd/nfs4layouts.c          |   29 +++----------
 fs/xfs/xfs_export.c            |    4 -
 fs/xfs/xfs_pnfs.c              |   44 ++++++++++++++------
 fs/xfs/xfs_pnfs.h              |   11 ++---
 include/linux/exportfs.h       |   25 +++--------
 include/linux/exportfs_block.h |   88 +++++++++++++++++++++++++++++++++++++++++
 9 files changed, 162 insertions(+), 81 deletions(-)
author reviewer
#1 lore raw

PATCH 1/4 nfsd/blocklayout: always ignore loca_time_modify

RFC 8881 Section 18.42 makes it clear that the client provided timestamp is a "may" condition, and clients that want to force a specific timestamp should send a separate SETATTR in the compound.

Since commit b82f92d5dd1a ("fs: have setattr_copy handle multigrain timestamps appropriately") the ia_mtime value is ignored by file systems using multi-grain timestamps like XFS, which is the only file system supporting blocklayout exports right now, so make that explicit in NFSD as well.

---
 fs/nfsd/blocklayout.c | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)
fs/nfsd/blocklayout.c +10 -5
index a7cfba29990e..5ee5735b39bb 100644
@@ -179,15 +179,20 @@ static __be32
 nfsd4_block_commit_blocks(struct inode *inode, struct nfsd4_layoutcommit *lcp,
 		struct iomap *iomaps, int nr_iomaps)
 {
-	struct timespec64 mtime = inode_get_mtime(inode);
 	struct iattr iattr = { .ia_valid = 0 };
 	int error;
 
-	if (lcp->lc_mtime.tv_nsec == UTIME_NOW ||
-	    timespec64_compare(&lcp->lc_mtime, &mtime) < 0)
-		lcp->lc_mtime = current_time(inode);
+	/*
+	 * This ignores the client provided mtime in loca_time_modify, as a
+	 * fully client specified mtime doesn't really fit into the Linux
+	 * multi-grain timestamp architecture.
+	 *
+	 * RFC 8881 Section 18.42 makes it clear that the client provided
+	 * timestamp is a "may" condition, and clients that want to force a
+	 * specific timestamp should send a separate SETATTR in the compound.
+	 */
 	iattr.ia_valid |= ATTR_ATIME | ATTR_CTIME | ATTR_MTIME;
-	iattr.ia_atime = iattr.ia_ctime = iattr.ia_mtime = lcp->lc_mtime;
+	iattr.ia_atime = iattr.ia_ctime = iattr.ia_mtime = current_time(inode);
 
 	if (lcp->lc_size_chg) {
 		iattr.ia_valid |= ATTR_SIZE;
Signature · 1 line
2.47.3
author reviewer
#2 lore raw

PATCH 2/4 exportfs: split out the ops for layout-based block device access

In reply to Christoph Hellwig

The support to grant layouts for direct block device access works at a very different layer than the rest of exports. Split the methods for it into a separate struct, and move that into a separate header to better split things out. The pointer to the new operation vector is kept in export_operations to avoid bloating the super_block.

---
 MAINTAINERS                    |  2 +-
 fs/nfsd/blocklayout.c          | 14 ++++++------
 fs/nfsd/nfs4layouts.c          |  9 ++++----
 fs/xfs/xfs_export.c            |  4 +---
 fs/xfs/xfs_pnfs.c              | 12 ++++++++---
 fs/xfs/xfs_pnfs.h              | 11 +++++-----
 include/linux/exportfs.h       | 25 +++++++---------------
 include/linux/exportfs_block.h | 39 ++++++++++++++++++++++++++++++++++
 8 files changed, 74 insertions(+), 42 deletions(-)
 create mode 100644 include/linux/exportfs_block.h
MAINTAINERS +1 -1
index c3fe46d7c4bc..b531b87a007e 100644
@@ -9856,7 +9856,7 @@ S:	Supported
 F:	Documentation/filesystems/nfs/exporting.rst
 F:	fs/exportfs/
 F:	fs/fhandle.c
-F:	include/linux/exportfs.h
+F:	include/linux/exportfs*.h
 
 FILESYSTEMS [IDMAPPED MOUNTS]
 M:	Christian Brauner <[email protected]>
fs/nfsd/blocklayout.c +7 -7
index 5ee5735b39bb..3cc3b47361e2 100644
@@ -2,7 +2,7 @@
 /*
  * Copyright (c) 2014-2016 Christoph Hellwig.
  */
-#include <linux/exportfs.h>
+#include <linux/exportfs_block.h>
 #include <linux/iomap.h>
 #include <linux/slab.h>
 #include <linux/pr.h>
@@ -32,8 +32,8 @@ nfsd4_block_map_extent(struct inode *inode, const struct svc_fh *fhp,
 	u32 device_generation = 0;
 	int error;
 
-	error = sb->s_export_op->map_blocks(inode, offset, length, &iomap,
-			iomode != IOMODE_READ, &device_generation);
+	error = sb->s_export_op->block_ops->map_blocks(inode, offset, length,
+			&iomap, iomode != IOMODE_READ, &device_generation);
 	if (error) {
 		if (error == -ENXIO)
 			return nfserr_layoutunavailable;
@@ -199,8 +199,8 @@ nfsd4_block_commit_blocks(struct inode *inode, struct nfsd4_layoutcommit *lcp,
 		iattr.ia_size = lcp->lc_newsize;
 	}
 
-	error = inode->i_sb->s_export_op->commit_blocks(inode, iomaps,
-			nr_iomaps, &iattr);
+	error = inode->i_sb->s_export_op->block_ops->commit_blocks(inode,
+			iomaps, nr_iomaps, &iattr);
 	kfree(iomaps);
 	return nfserrno(error);
 }
@@ -223,8 +223,8 @@ nfsd4_block_get_device_info_simple(struct super_block *sb,
 
 	b->type = PNFS_BLOCK_VOLUME_SIMPLE;
 	b->simple.sig_len = PNFS_BLOCK_UUID_LEN;
-	return sb->s_export_op->get_uuid(sb, b->simple.sig, &b->simple.sig_len,
-			&b->simple.offset);
+	return sb->s_export_op->block_ops->get_uuid(sb, b->simple.sig,
+			&b->simple.sig_len, &b->simple.offset);
 }
 
 static __be32
fs/nfsd/nfs4layouts.c +4 -5
index ad7af8cfcf1f..6c1ff21b83a2 100644
@@ -3,6 +3,7 @@
  * Copyright (c) 2014 Christoph Hellwig.
  */
 #include <linux/blkdev.h>
+#include <linux/exportfs_block.h>
 #include <linux/kmod.h>
 #include <linux/file.h>
 #include <linux/jhash.h>
@@ -127,6 +128,7 @@ void nfsd4_setup_layout_type(struct svc_export *exp)
 {
 #if defined(CONFIG_NFSD_BLOCKLAYOUT) || defined(CONFIG_NFSD_SCSILAYOUT)
 	struct super_block *sb = exp->ex_path.mnt->mnt_sb;
+	const struct exportfs_block_ops *bops = sb->s_export_op->block_ops;
 #endif
 
 	if (!(exp->ex_flags & NFSEXP_PNFS))
@@ -136,14 +138,11 @@ void nfsd4_setup_layout_type(struct svc_export *exp)
 	exp->ex_layout_types |= 1 << LAYOUT_FLEX_FILES;
 #endif
 #ifdef CONFIG_NFSD_BLOCKLAYOUT
-	if (sb->s_export_op->get_uuid &&
-	    sb->s_export_op->map_blocks &&
-	    sb->s_export_op->commit_blocks)
+	if (bops && bops->get_uuid && bops->map_blocks && bops->commit_blocks)
 		exp->ex_layout_types |= 1 << LAYOUT_BLOCK_VOLUME;
 #endif
 #ifdef CONFIG_NFSD_SCSILAYOUT
-	if (sb->s_export_op->map_blocks &&
-	    sb->s_export_op->commit_blocks &&
+	if (bops && bops->map_blocks && bops->commit_blocks &&
 	    sb->s_bdev &&
 	    sb->s_bdev->bd_disk->fops->pr_ops &&
 	    sb->s_bdev->bd_disk->fops->get_unique_id)
fs/xfs/xfs_export.c +1 -3
index e3e3c3c89840..9b2ad3786b19 100644
@@ -244,8 +244,6 @@ const struct export_operations xfs_export_operations = {
 	.get_parent		= xfs_fs_get_parent,
 	.commit_metadata	= xfs_fs_nfs_commit_metadata,
 #ifdef CONFIG_EXPORTFS_BLOCK_OPS
-	.get_uuid		= xfs_fs_get_uuid,
-	.map_blocks		= xfs_fs_map_blocks,
-	.commit_blocks		= xfs_fs_commit_blocks,
+	.block_ops		= &xfs_export_block_ops,
 #endif
 };
fs/xfs/xfs_pnfs.c +9 -3
index 221e55887a2a..12e083f1b9ba 100644
@@ -49,7 +49,7 @@ xfs_break_leased_layouts(
  * Get a unique ID including its location so that the client can identify
  * the exported device.
  */
-int
+static int
 xfs_fs_get_uuid(
 	struct super_block	*sb,
 	u8			*buf,
@@ -104,7 +104,7 @@ xfs_fs_map_update_inode(
 /*
  * Get a layout for the pNFS client.
  */
-int
+static int
 xfs_fs_map_blocks(
 	struct inode		*inode,
 	loff_t			offset,
@@ -252,7 +252,7 @@ xfs_pnfs_validate_isize(
  * to manually flush the cache here similar to what the fsync code path does
  * for datasyncs on files that have no dirty metadata.
  */
-int
+static int
 xfs_fs_commit_blocks(
 	struct inode		*inode,
 	struct iomap		*maps,
@@ -332,3 +332,9 @@ xfs_fs_commit_blocks(
 	xfs_iunlock(ip, XFS_IOLOCK_EXCL);
 	return error;
 }
+
+const struct exportfs_block_ops xfs_export_block_ops = {
+	.get_uuid		= xfs_fs_get_uuid,
+	.map_blocks		= xfs_fs_map_blocks,
+	.commit_blocks		= xfs_fs_commit_blocks,
+};
fs/xfs/xfs_pnfs.h +5 -6
index 940c6c2ad88c..bf43b2009e4c 100644
@@ -2,13 +2,9 @@
 #ifndef _XFS_PNFS_H
 #define _XFS_PNFS_H 1
 
-#ifdef CONFIG_EXPORTFS_BLOCK_OPS
-int xfs_fs_get_uuid(struct super_block *sb, u8 *buf, u32 *len, u64 *offset);
-int xfs_fs_map_blocks(struct inode *inode, loff_t offset, u64 length,
-		struct iomap *iomap, bool write, u32 *device_generation);
-int xfs_fs_commit_blocks(struct inode *inode, struct iomap *maps, int nr_maps,
-		struct iattr *iattr);
+#include <linux/exportfs_block.h>
 
+#ifdef CONFIG_EXPORTFS_BLOCK_OPS
 int xfs_break_leased_layouts(struct inode *inode, uint *iolock,
 		bool *did_unlock);
 #else
@@ -18,4 +14,7 @@ xfs_break_leased_layouts(struct inode *inode, uint *iolock, bool *did_unlock)
 	return 0;
 }
 #endif /* CONFIG_EXPORTFS_BLOCK_OPS */
+
+extern const struct exportfs_block_ops xfs_export_block_ops;
+
 #endif /* _XFS_PNFS_H */
include/linux/exportfs.h +8 -17
index 8bcdba28b406..c835bc64f4fa 100644
@@ -6,9 +6,8 @@
 #include <linux/path.h>
 
 struct dentry;
-struct iattr;
+struct exportfs_block_ops;
 struct inode;
-struct iomap;
 struct super_block;
 struct vfsmount;
 
@@ -260,19 +259,13 @@ struct handle_to_path_ctx {
  * @commit_metadata:
  *    @commit_metadata should commit metadata changes to stable storage.
  *
- * @get_uuid:
- *    Get a filesystem unique signature exposed to clients.
- *
- * @map_blocks:
- *    Map and, if necessary, allocate blocks for a layout.
- *
- * @commit_blocks:
- *    Commit blocks in a layout once the client is done with them.
- *
  * @flags:
  *    Allows the filesystem to communicate to nfsd that it may want to do things
  *    differently when dealing with it.
  *
+ * @block_ops:
+ *    Operations for layout grants to block on the underlying device.
+ *
  * Locking rules:
  *    get_parent is called with child->d_inode->i_rwsem down
  *    get_name is not (which is possibly inconsistent)
@@ -290,12 +283,6 @@ struct export_operations {
 	struct dentry * (*get_parent)(struct dentry *child);
 	int (*commit_metadata)(struct inode *inode);
 
-	int (*get_uuid)(struct super_block *sb, u8 *buf, u32 *len, u64 *offset);
-	int (*map_blocks)(struct inode *inode, loff_t offset,
-			  u64 len, struct iomap *iomap,
-			  bool write, u32 *device_generation);
-	int (*commit_blocks)(struct inode *inode, struct iomap *iomaps,
-			     int nr_iomaps, struct iattr *iattr);
 	int (*permission)(struct handle_to_path_ctx *ctx, unsigned int oflags);
 	struct file * (*open)(const struct path *path, unsigned int oflags);
 #define	EXPORT_OP_NOWCC			(0x1) /* don't collect v3 wcc data */
@@ -308,6 +295,10 @@ struct export_operations {
 #define EXPORT_OP_FLUSH_ON_CLOSE	(0x20) /* fs flushes file data on close */
 #define EXPORT_OP_NOLOCKS		(0x40) /* no file locking support */
 	unsigned long	flags;
+
+#ifdef CONFIG_EXPORTFS_BLOCK_OPS
+	const struct exportfs_block_ops *block_ops;
+#endif
 };
 
 /**
include/linux/exportfs_block.h new file +39 -0
new file mode 100644
index 000000000000..1f52fea8e4dc
@@ -0,0 +1,39 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * Copyright (c) 2014-2026 Christoph Hellwig.
+ *
+ * Support for exportfs-based layout grants for direct block device access.
+ */
+#ifndef LINUX_EXPORTFS_BLOCK_H
+#define LINUX_EXPORTFS_BLOCK_H 1
+
+#include <linux/types.h>
+
+struct iattr;
+struct inode;
+struct iomap;
+struct super_block;
+
+struct exportfs_block_ops {
+	/*
+	 * Get the in-band device unique signature exposed to clients.
+	 */
+	int (*get_uuid)(struct super_block *sb, u8 *buf, u32 *len, u64 *offset);
+
+	/*
+	 * Map blocks for direct block access.
+	 * If @write is %true, also allocate the blocks for the range if needed.
+	 */
+	int (*map_blocks)(struct inode *inode, loff_t offset, u64 len,
+			struct iomap *iomap, bool write,
+			u32 *device_generation);
+
+	/*
+	 * Commit blocks previously handed out by ->map_blocks and written to by
+	 * the client.
+	 */
+	int (*commit_blocks)(struct inode *inode, struct iomap *iomaps,
+			int nr_iomaps, struct iattr *iattr);
+};
+
+#endif /* LINUX_EXPORTFS_BLOCK_H */
Signature · 1 line
2.47.3
author reviewer
#3 lore raw

PATCH 3/4 exportfs: don't pass struct iattr to ->commit_blocks

In reply to Christoph Hellwig

The only thing ->commit_blocks really needs is the new size, with a magic -1 placeholder 0 for "do not change the size" because it only ever extends the size.

---
 fs/nfsd/blocklayout.c          | 12 ++----------
 fs/xfs/xfs_pnfs.c              | 19 ++++++++++---------
 include/linux/exportfs_block.h |  3 +--
 3 files changed, 13 insertions(+), 21 deletions(-)
fs/nfsd/blocklayout.c +2 -10
index 3cc3b47361e2..23c0e4d0ff34 100644
@@ -179,7 +179,6 @@ static __be32
 nfsd4_block_commit_blocks(struct inode *inode, struct nfsd4_layoutcommit *lcp,
 		struct iomap *iomaps, int nr_iomaps)
 {
-	struct iattr iattr = { .ia_valid = 0 };
 	int error;
 
 	/*
@@ -191,16 +190,9 @@ nfsd4_block_commit_blocks(struct inode *inode, struct nfsd4_layoutcommit *lcp,
 	 * timestamp is a "may" condition, and clients that want to force a
 	 * specific timestamp should send a separate SETATTR in the compound.
 	 */
-	iattr.ia_valid |= ATTR_ATIME | ATTR_CTIME | ATTR_MTIME;
-	iattr.ia_atime = iattr.ia_ctime = iattr.ia_mtime = current_time(inode);
-
-	if (lcp->lc_size_chg) {
-		iattr.ia_valid |= ATTR_SIZE;
-		iattr.ia_size = lcp->lc_newsize;
-	}
-
 	error = inode->i_sb->s_export_op->block_ops->commit_blocks(inode,
-			iomaps, nr_iomaps, &iattr);
+			iomaps, nr_iomaps,
+			lcp->lc_size_chg ? lcp->lc_newsize : 0);
 	kfree(iomaps);
 	return nfserrno(error);
 }
fs/xfs/xfs_pnfs.c +10 -9
index 12e083f1b9ba..7d689bb2efd9 100644
@@ -257,23 +257,22 @@ xfs_fs_commit_blocks(
 	struct inode		*inode,
 	struct iomap		*maps,
 	int			nr_maps,
-	struct iattr		*iattr)
+	loff_t			new_size)
 {
 	struct xfs_inode	*ip = XFS_I(inode);
 	struct xfs_mount	*mp = ip->i_mount;
 	struct xfs_trans	*tp;
+	struct timespec64	now;
 	bool			update_isize = false;
 	int			error, i;
 	loff_t			size;
 
-	ASSERT(iattr->ia_valid & (ATTR_ATIME|ATTR_CTIME|ATTR_MTIME));
-
 	xfs_ilock(ip, XFS_IOLOCK_EXCL);
 
 	size = i_size_read(inode);
-	if ((iattr->ia_valid & ATTR_SIZE) && iattr->ia_size > size) {
+	if (new_size > size) {
 		update_isize = true;
-		size = iattr->ia_size;
+		size = new_size;
 	}
 
 	for (i = 0; i < nr_maps; i++) {
@@ -318,11 +317,13 @@ xfs_fs_commit_blocks(
 	xfs_trans_ijoin(tp, ip, XFS_ILOCK_EXCL);
 	xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE);
 
-	ASSERT(!(iattr->ia_valid & (ATTR_UID | ATTR_GID)));
-	setattr_copy(&nop_mnt_idmap, inode, iattr);
+	now = inode_set_ctime_current(inode);
+	inode_set_atime_to_ts(inode, now);
+	inode_set_mtime_to_ts(inode, now);
+
 	if (update_isize) {
-		i_size_write(inode, iattr->ia_size);
-		ip->i_disk_size = iattr->ia_size;
+		i_size_write(inode, new_size);
+		ip->i_disk_size = new_size;
 	}
 
 	xfs_trans_set_sync(tp);
include/linux/exportfs_block.h +1 -2
index 1f52fea8e4dc..d1dec4689b14 100644
@@ -9,7 +9,6 @@
 
 #include <linux/types.h>
 
-struct iattr;
 struct inode;
 struct iomap;
 struct super_block;
@@ -33,7 +32,7 @@ struct exportfs_block_ops {
 	 * the client.
 	 */
 	int (*commit_blocks)(struct inode *inode, struct iomap *iomaps,
-			int nr_iomaps, struct iattr *iattr);
+			int nr_iomaps, loff_t new_size);
 };
 
 #endif /* LINUX_EXPORTFS_BLOCK_H */
Signature · 1 line
2.47.3
author reviewer
#4 lore raw

PATCH 4/4 exportfs,nfsd: rework checking for layout-based block device access support

In reply to Christoph Hellwig

Currently NFSD hard codes checking support for block-style layouts. Lift the checks into a file system-helper and provide a exportfs-level helper to implement the typical checks.

This prepares for supporting block layout export of multiple devices per file system.

---
 fs/nfsd/export.c               |  3 +-
 fs/nfsd/nfs4layouts.c          | 26 +++++------------
 fs/xfs/xfs_pnfs.c              | 13 +++++++++
 include/linux/exportfs_block.h | 52 +++++++++++++++++++++++++++++++++-
 4 files changed, 73 insertions(+), 21 deletions(-)
fs/nfsd/export.c +2 -1
index 8e8a76a44ff0..e20298f9212f 100644
@@ -735,7 +735,8 @@ static int svc_export_parse(struct cache_detail *cd, char *mesg, int mlen)
 			goto out4;
 		err = 0;
 
-		nfsd4_setup_layout_type(&exp);
+		if (exp.ex_flags & NFSEXP_PNFS)
+			nfsd4_setup_layout_type(&exp);
 	}
 
 	expp = svc_export_lookup(&exp);
fs/nfsd/nfs4layouts.c +7 -19
index 6c1ff21b83a2..0b51eabbafde 100644
@@ -2,7 +2,6 @@
 /*
  * Copyright (c) 2014 Christoph Hellwig.
  */
-#include <linux/blkdev.h>
 #include <linux/exportfs_block.h>
 #include <linux/kmod.h>
 #include <linux/file.h>
@@ -126,28 +125,17 @@ nfsd4_set_deviceid(struct nfsd4_deviceid *id, const struct svc_fh *fhp,
 
 void nfsd4_setup_layout_type(struct svc_export *exp)
 {
-#if defined(CONFIG_NFSD_BLOCKLAYOUT) || defined(CONFIG_NFSD_SCSILAYOUT)
 	struct super_block *sb = exp->ex_path.mnt->mnt_sb;
-	const struct exportfs_block_ops *bops = sb->s_export_op->block_ops;
-#endif
-
-	if (!(exp->ex_flags & NFSEXP_PNFS))
-		return;
+	expfs_block_layouts_t block_supported = exportfs_layouts_supported(sb);
 
-#ifdef CONFIG_NFSD_FLEXFILELAYOUT
-	exp->ex_layout_types |= 1 << LAYOUT_FLEX_FILES;
-#endif
-#ifdef CONFIG_NFSD_BLOCKLAYOUT
-	if (bops && bops->get_uuid && bops->map_blocks && bops->commit_blocks)
+	if (IS_ENABLED(CONFIG_NFSD_FLEXFILELAYOUT))
+		exp->ex_layout_types |= 1 << LAYOUT_FLEX_FILES;
+	if (IS_ENABLED(CONFIG_NFSD_BLOCKLAYOUT) &&
+	    (block_supported & EXPFS_BLOCK_IN_BAND_ID))
 		exp->ex_layout_types |= 1 << LAYOUT_BLOCK_VOLUME;
-#endif
-#ifdef CONFIG_NFSD_SCSILAYOUT
-	if (bops && bops->map_blocks && bops->commit_blocks &&
-	    sb->s_bdev &&
-	    sb->s_bdev->bd_disk->fops->pr_ops &&
-	    sb->s_bdev->bd_disk->fops->get_unique_id)
+	if (IS_ENABLED(CONFIG_NFSD_SCSILAYOUT) &&
+	    (block_supported & EXPFS_BLOCK_OUT_OF_BAND_ID))
 		exp->ex_layout_types |= 1 << LAYOUT_SCSI;
-#endif
 }
 
 void nfsd4_close_layout(struct nfs4_layout_stateid *ls)
fs/xfs/xfs_pnfs.c +13 -0
index 7d689bb2efd9..266a07601e8d 100644
@@ -13,6 +13,7 @@
 #include "xfs_bmap.h"
 #include "xfs_iomap.h"
 #include "xfs_pnfs.h"
+#include <linux/exportfs_block.h>
 
 /*
  * Ensure that we do not have any outstanding pNFS layouts that can be used by
@@ -45,6 +46,17 @@ xfs_break_leased_layouts(
 	return error;
 }
 
+static expfs_block_layouts_t
+xfs_fs_layouts_supported(
+	struct super_block	*sb)
+{
+	expfs_block_layouts_t	supported = EXPFS_BLOCK_IN_BAND_ID;
+
+	if (exportfs_bdev_supports_out_of_band_id(sb->s_bdev))
+		supported |= EXPFS_BLOCK_OUT_OF_BAND_ID;
+	return supported;
+}
+
 /*
  * Get a unique ID including its location so that the client can identify
  * the exported device.
@@ -335,6 +347,7 @@ xfs_fs_commit_blocks(
 }
 
 const struct exportfs_block_ops xfs_export_block_ops = {
+	.layouts_supported	= xfs_fs_layouts_supported,
 	.get_uuid		= xfs_fs_get_uuid,
 	.map_blocks		= xfs_fs_map_blocks,
 	.commit_blocks		= xfs_fs_commit_blocks,
include/linux/exportfs_block.h +51 -1

68 lines not on this page · raw message

Signature · 1 line
2.47.3
maintainer
#5 lore raw

Re: [PATCH 4/4] exportfs,nfsd: rework checking for layout-based block device access support

Quoted 21 lines · Christoph Hellwig

Currently NFSD hard codes checking support for block-style layouts. Lift the checks into a file system-helper and provide a exportfs-level helper to implement the typical checks.

This prepares for supporting block layout export of multiple devices per file system.

---
 fs/nfsd/export.c               |  3 +-
 fs/nfsd/nfs4layouts.c          | 26 +++++------------
 fs/xfs/xfs_pnfs.c              | 13 +++++++++
 include/linux/exportfs_block.h | 52 +++++++++++++++++++++++++++++++++-
 4 files changed, 73 insertions(+), 21 deletions(-)
fs/nfsd/export.c +0 -0
index 8e8a76a44ff0..e20298f9212f 100644

fs/nfsd/export.c static int svc_export_parse(struct cache_detail *cd, char *mesg, int mlen) · line 741

Quoted 8 lines
fs/nfsd/export.c +2 -1
@@ -735,7 +735,8 @@ static int svc_export_parse(struct cache_detail *cd, char *mesg, int mlen)
 			goto out4;
 		err = 0;
 
-		nfsd4_setup_layout_type(&exp);
+		if (exp.ex_flags & NFSEXP_PNFS)
+			nfsd4_setup_layout_type(&exp);
 	}
 

There is a (minor) problem with this patch. There is a second call to nfsd4_setup_layout_type() in Chuck's nfsd-next branch, in nfsd_nl_parse_one_export(). It needs to be gated on this flag now, or we end up enabling pnfs unconditionally.

Signature · 1 line
Jeff Layton <[email protected]>
maintainer
#6 lore raw
In reply to Christoph Hellwig
Quoted 15 lines · Christoph Hellwig

Hi all,

this series cleanups the exportfs support for block-style layouts that provide direct block device access. This is preparation for supporting exportfs of more than a single device per file system.

Changes since v1:
- consity struct exportfs_block_ops
- fix spelling

Changes since the multi-device export series:
- check for NULL bops in nfsd4_setup_layout_type
- clearly document why we are ignoring loca_time_modify

Diffstat:

Quoted 10 lines
 MAINTAINERS                    |    2 
 fs/nfsd/blocklayout.c          |   37 +++++++----------
 fs/nfsd/export.c               |    3 -
 fs/nfsd/nfs4layouts.c          |   29 +++----------
 fs/xfs/xfs_export.c            |    4 -
 fs/xfs/xfs_pnfs.c              |   44 ++++++++++++++------
 fs/xfs/xfs_pnfs.h              |   11 ++---
 include/linux/exportfs.h       |   25 +++--------
 include/linux/exportfs_block.h |   88 +++++++++++++++++++++++++++++++++++++++++
 9 files changed, 162 insertions(+), 81 deletions(-)

Christian, are you OK if I take this series through the NFSD tree?

Signature · 1 line
Chuck Lever
#7 lore raw
Quoted 29 lines · Chuck Lever
Quoted 15 lines · Christoph Hellwig

Hi all,

this series cleanups the exportfs support for block-style layouts that provide direct block device access. This is preparation for supporting exportfs of more than a single device per file system.

Changes since v1:
- consity struct exportfs_block_ops
- fix spelling

Changes since the multi-device export series:
- check for NULL bops in nfsd4_setup_layout_type
- clearly document why we are ignoring loca_time_modify

Diffstat:

Quoted 10 lines
 MAINTAINERS                    |    2 
 fs/nfsd/blocklayout.c          |   37 +++++++----------
 fs/nfsd/export.c               |    3 -
 fs/nfsd/nfs4layouts.c          |   29 +++----------
 fs/xfs/xfs_export.c            |    4 -
 fs/xfs/xfs_pnfs.c              |   44 ++++++++++++++------
 fs/xfs/xfs_pnfs.h              |   11 ++---
 include/linux/exportfs.h       |   25 +++--------
 include/linux/exportfs_block.h |   88 +++++++++++++++++++++++++++++++++++++++++
 9 files changed, 162 insertions(+), 81 deletions(-)
Quoted 1 line

Christian, are you OK if I take this series through the NFSD tree?

Hm, I generally prefer infrastructure to go through the VFS tree. You can get a stable branch ofc.

author reviewer
#8 lore raw
Quoted 4 lines · Christian Brauner
Quoted 1 line

Christian, are you OK if I take this series through the NFSD tree?

Hm, I generally prefer infrastructure to go through the VFS tree. You can get a stable branch ofc.

Communicating this earlier would be helpful. If we switch to a new tree base we're going to miss this merge window.

#9 lore raw
Quoted 8 lines · Christoph Hellwig
Quoted 4 lines · Christian Brauner
Quoted 1 line

Christian, are you OK if I take this series through the NFSD tree?

Hm, I generally prefer infrastructure to go through the VFS tree. You can get a stable branch ofc.

Communicating this earlier would be helpful. If we switch to a new tree base we're going to miss this merge window.

The series was sent on April 1 so with about 2 weeks before the merge window... If your series isn't ready by -rc5 what is it doing being merged for the coming merge window is the other side of the question. So afaict, there's no hurry.

author reviewer
#10 lore raw
Quoted 7 lines · Christian Brauner
Quoted 6 lines · Christoph Hellwig
Quoted 4 lines · Christian Brauner
Quoted 1 line

Christian, are you OK if I take this series through the NFSD tree?

Hm, I generally prefer infrastructure to go through the VFS tree. You can get a stable branch ofc.

Quoted 7 lines
Quoted 2 lines

Communicating this earlier would be helpful. If we switch to a new tree base we're going to miss this merge window.

The series was sent on April 1 so with about 2 weeks before the merge window... If your series isn't ready by -rc5 what is it doing being merged for the coming merge window is the other side of the question. So afaict, there's no hurry.

That's a very weird generic standard. I know a lot of subsystem don't take complex core changes until a bit before the cutoff, but killing 3 weeks of the merge window for everything is odd.

Even more I'm not even why we're having that discussion - exportfs has it's own maintainers, one of whom ACKed this including the whole tree discussion.

maintainer
#11 lore raw
Quoted 16 lines · Christoph Hellwig
Quoted 7 lines · Christian Brauner
Quoted 6 lines · Christoph Hellwig
Quoted 4 lines · Christian Brauner
Quoted 1 line

Christian, are you OK if I take this series through the NFSD tree?

Hm, I generally prefer infrastructure to go through the VFS tree. You can get a stable branch ofc.

Quoted 7 lines
Quoted 2 lines

Communicating this earlier would be helpful. If we switch to a new tree base we're going to miss this merge window.

The series was sent on April 1 so with about 2 weeks before the merge window... If your series isn't ready by -rc5 what is it doing being merged for the coming merge window is the other side of the question. So afaict, there's no hurry.

Quoted 7 lines

That's a very weird generic standard. I know a lot of subsystem don't take complex core changes until a bit before the cutoff, but killing 3 weeks of the merge window for everything is odd.

Even more I'm not even why we're having that discussion - exportfs has it's own maintainers, one of whom ACKed this including the whole tree discussion.

In this case, pNFS is the only consumer that will notice or use the new "infrastructure" and us NFS experts are the only ones who can test and review it properly. And, the likelihood of conflicts with patches in nfsd-testing is high (in fact we've already had at least one). It makes sense to me to take this series through NFSD.

Signature · 1 line
Chuck Lever
maintainer
#12 lore raw
Quoted 6 lines · Chuck Lever
Quoted 5 lines · Christoph Hellwig
Quoted 4 lines · Christian Brauner
Quoted 3 lines · Christoph Hellwig
Quoted 2 lines · Christian Brauner
Quoted 1 line

Christian, are you OK if I take this series through the NFSD tree?

Quoted 8 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

Hm, I generally prefer infrastructure to go through the VFS tree. You can get a stable branch ofc.

In this case, pNFS is the only consumer that will notice or use the new "infrastructure" and us NFS experts are the only ones who can test and review it properly. And, the likelihood of conflicts with patches in nfsd-testing is high (in fact we've already had at least one). It makes sense to me to take this series through NFSD.

I see that Jeff has posted a series that modifies the fs_notify API surface to support the NFSv4 CB_NOTIFY operation. That likely counts as an infrastructure change.

To meet you halfway, Christian, you could take Christoph's series and Jeff's series into a "vfs.nfsd" tree and I can base my nfsd-next branch on that for the NFSD PR 7.2. Building the NFSD PR on that should avoid merge conflicts with significant changes I have planned.

Signature · 1 line
Chuck Lever
#13 lore raw
Quoted 17 lines · Chuck Lever
Quoted 6 lines · Chuck Lever
Quoted 5 lines · Christoph Hellwig
Quoted 4 lines · Christian Brauner
Quoted 3 lines · Christoph Hellwig
Quoted 2 lines · Christian Brauner
Quoted 1 line

Christian, are you OK if I take this series through the NFSD tree?

Quoted 8 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

Hm, I generally prefer infrastructure to go through the VFS tree. You can get a stable branch ofc.

In this case, pNFS is the only consumer that will notice or use the new "infrastructure" and us NFS experts are the only ones who can test and review it properly. And, the likelihood of conflicts with patches in nfsd-testing is high (in fact we've already had at least one). It makes sense to me to take this series through NFSD.

Quoted 8 lines

I see that Jeff has posted a series that modifies the fs_notify API surface to support the NFSv4 CB_NOTIFY operation. That likely counts as an infrastructure change.

To meet you halfway, Christian, you could take Christoph's series and Jeff's series into a "vfs.nfsd" tree and I can base my nfsd-next branch on that for the NFSD PR 7.2. Building the NFSD PR on that should avoid merge conflicts with significant changes I have planned.

Sounds perfect. I don't rebase branches unless there's something really really gnarly to handle and I would ping you in advance if anything like that were to happen.

maintainer
#14 lore raw
Quoted 22 lines · Christian Brauner
Quoted 21 lines · Chuck Lever
Quoted 6 lines · Chuck Lever
Quoted 5 lines · Christoph Hellwig
Quoted 4 lines · Christian Brauner
Quoted 3 lines · Christoph Hellwig
Quoted 2 lines · Christian Brauner
Quoted 1 line

Christian, are you OK if I take this series through the NFSD tree?

Quoted 8 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

Hm, I generally prefer infrastructure to go through the VFS tree. You can get a stable branch ofc.

In this case, pNFS is the only consumer that will notice or use the new "infrastructure" and us NFS experts are the only ones who can test and review it properly. And, the likelihood of conflicts with patches in nfsd-testing is high (in fact we've already had at least one). It makes sense to me to take this series through NFSD.

I see that Jeff has posted a series that modifies the fs_notify API surface to support the NFSv4 CB_NOTIFY operation. That likely counts as an infrastructure change.

Quoted 8 lines
Quoted 4 lines

To meet you halfway, Christian, you could take Christoph's series and Jeff's series into a "vfs.nfsd" tree and I can base my nfsd-next branch on that for the NFSD PR 7.2. Building the NFSD PR on that should avoid merge conflicts with significant changes I have planned.

Sounds perfect. I don't rebase branches unless there's something really really gnarly to handle and I would ping you in advance if anything like that were to happen.

Note that there is a small difference (error-handling fix) between the most-recently posted CB_NOTIFY patchset and what's currently in my tree. You can either pick or pull the series from my tree, or I can re- post. Let me know which you'd prefer:

fs/nfsd/nfs4state.c +3 -2
index 5eca7899c48d..bb9093e3933f 100644
@@ -1193,8 +1193,8 @@ static void nfs4_free_dir_deleg(struct nfs4_stid *stid)
 
 	for (i = 0; i < ncn->ncn_evt_cnt; ++i)
 		nfsd_notify_event_put(ncn->ncn_evt[i]);
-	release_pages(ncn->ncn_pages, NOTIFY4_PAGE_ARRAY_SIZE);
 	kfree(ncn->ncn_nf);
+	release_pages(ncn->ncn_pages, NOTIFY4_PAGE_ARRAY_SIZE);
 	nfs4_free_deleg(stid);
 }
 
@@ -1213,7 +1213,8 @@ alloc_init_dir_deleg(struct nfs4_client *clp, struct nfs4_file *fp)
 
 	npages = alloc_pages_bulk(GFP_KERNEL, NOTIFY4_PAGE_ARRAY_SIZE, ncn->ncn_pages);
 	if (npages != NOTIFY4_PAGE_ARRAY_SIZE) {
-		nfs4_put_stid(&dp->dl_stid);
+		release_pages(ncn->ncn_pages, npages);
+		nfs4_free_deleg(&dp->dl_stid);
 		return NULL;
 	}
 
#15 lore raw
Quoted 28 lines · Jeff Layton
Quoted 27 lines · Christian Brauner
Quoted 25 lines · Chuck Lever
Quoted 6 lines · Chuck Lever
Quoted 5 lines · Christoph Hellwig
Quoted 4 lines · Christian Brauner
Quoted 3 lines · Christoph Hellwig
Quoted 2 lines · Christian Brauner
Quoted 1 line

Christian, are you OK if I take this series through the NFSD tree?

Quoted 8 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

Hm, I generally prefer infrastructure to go through the VFS tree. You can get a stable branch ofc.

In this case, pNFS is the only consumer that will notice or use the new "infrastructure" and us NFS experts are the only ones who can test and review it properly. And, the likelihood of conflicts with patches in nfsd-testing is high (in fact we've already had at least one). It makes sense to me to take this series through NFSD.

I see that Jeff has posted a series that modifies the fs_notify API surface to support the NFSv4 CB_NOTIFY operation. That likely counts as an infrastructure change.

To meet you halfway, Christian, you could take Christoph's series and Jeff's series into a "vfs.nfsd" tree and I can base my nfsd-next branch on that for the NFSD PR 7.2. Building the NFSD PR on that should avoid merge conflicts with significant changes I have planned.

Quoted 8 lines
Quoted 3 lines

Sounds perfect. I don't rebase branches unless there's something really really gnarly to handle and I would ping you in advance if anything like that were to happen.

Note that there is a small difference (error-handling fix) between the most-recently posted CB_NOTIFY patchset and what's currently in my tree. You can either pick or pull the series from my tree, or I can re- post. Let me know which you'd prefer:

Just repost, if you would be so kind. (I wonder whether we should start having a quiet period for new work during the mw like net has.)

#16 lore raw
In reply to Christoph Hellwig
Quoted 11 lines · Christoph Hellwig
Quoted 10 lines · Christian Brauner
Quoted 8 lines · Christoph Hellwig
Quoted 4 lines · Christian Brauner
Quoted 1 line

Christian, are you OK if I take this series through the NFSD tree?

Hm, I generally prefer infrastructure to go through the VFS tree. You can get a stable branch ofc.

Communicating this earlier would be helpful. If we switch to a new tree base we're going to miss this merge window.

Quoted 8 lines
Quoted 4 lines

The series was sent on April 1 so with about 2 weeks before the merge window... If your series isn't ready by -rc5 what is it doing being merged for the coming merge window is the other side of the question. So afaict, there's no hurry.

That's a very weird generic standard. I know a lot of subsystem don't take complex core changes until a bit before the cutoff, but killing 3 weeks of the merge window for everything is odd.

I didn't NAK anything. You pushed urgency here by complaining I didn't communicate antyhing earlier. And I'm merely clarifying that 2 weeks before the merge window when stuff should've been stabilized there's other things to do then rush to reply to something that looks like it can't go in this merge window anymore.

Quoted 3 lines

Even more I'm not even why we're having that discussion - exportfs has it's own maintainers, one of whom ACKed this including the whole tree discussion.

If it's generic infra I generally want it centralized in one of the VFS tree. I have clarified this over and over. It's fine to make exceptions. It's not fine to pick and choose what currently best suits your needs.

maintainer
#17 lore raw
In reply to Christoph Hellwig

From: Chuck Lever <[email protected]>

Quoted 9 lines · Christoph Hellwig

this series cleanups the exportfs support for block-style layouts that provide direct block device access. This is preparation for supporting exportfs of more than a single device per file system.

Changes since v1:
- consity struct exportfs_block_ops
- fix spelling

[...]

Applied to nfsd-testing, thanks!

[1/4] nfsd/blocklayout: always ignore loca_time_modify

      commit: ff6bb92c2f41eac178f9886d15a62cb7f8acf111
[2/4] exportfs: split out the ops for layout-based block device access
      commit: 86cc64ab3045f7130c2d2d7c458646038282938a
[3/4] exportfs: don't pass struct iattr to ->commit_blocks
      commit: 949378be2cd289d749ef9a826ea6cf376bca973e
[4/4] exportfs,nfsd: rework checking for layout-based block device access support
      commit: e0259785dffcb12f6850450344ab0f99b6283d60

--
Chuck Lever