nvdimm.lists.linux.dev archive mirror
 help / color / mirror / Atom feed
From: Dan Williams <dan.j.williams@intel.com>
To: linux-nvdimm@lists.01.org
Cc: jack@suse.cz, "Darrick J. Wong" <darrick.wong@oracle.com>,
	Dave Chinner <david@fromorbit.com>,
	linux-kernel@vger.kernel.org, linux-xfs@vger.kernel.org,
	linux-fsdevel@vger.kernel.org, hch@lst.de
Subject: [PATCH v6 13/15] xfs: communicate lock drop events from xfs_break_layouts()
Date: Thu, 15 Mar 2018 08:52:39 -0700	[thread overview]
Message-ID: <152112915950.24669.2377167541944853596.stgit@dwillia2-desk3.amr.corp.intel.com> (raw)
In-Reply-To: <152112908134.24669.10222746224538377035.stgit@dwillia2-desk3.amr.corp.intel.com>

In preparation for adding a new layout type, teach xfs_break_layouts()
to return a positive number if it needed to drop locks while trying to
break leases. For all layouts to be successfully broken each layout type
needs to be able to assert that the layouts were broken with the locks
held.

The existing a xfs_break_layouts() is pushed down a level to
xfs_break_leased_layouts() and the new xfs_break_layouts() will
coordinate interpreting the return code from the low level 'break'
helpers.

Cc: "Darrick J. Wong" <darrick.wong@oracle.com>
Cc: Ross Zwisler <ross.zwisler@linux.intel.com>
Cc: Dave Chinner <david@fromorbit.com>
Cc: Christoph Hellwig <hch@lst.de>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
---
 fs/xfs/xfs_file.c  |   17 +++++++++++++++++
 fs/xfs/xfs_inode.h |    2 ++
 fs/xfs/xfs_ioctl.c |    1 -
 fs/xfs/xfs_iops.c  |    1 -
 fs/xfs/xfs_pnfs.c  |   15 ++++++++-------
 fs/xfs/xfs_pnfs.h  |    4 ++--
 6 files changed, 29 insertions(+), 11 deletions(-)

diff --git a/fs/xfs/xfs_file.c b/fs/xfs/xfs_file.c
index ba969019bf26..5742d395a4e4 100644
--- a/fs/xfs/xfs_file.c
+++ b/fs/xfs/xfs_file.c
@@ -759,6 +759,23 @@ xfs_file_write_iter(
 	return ret;
 }
 
+int
+xfs_break_layouts(
+	struct inode		*inode,
+	uint			*iolock)
+{
+	struct xfs_inode	*ip = XFS_I(inode);
+	int			ret;
+
+	ASSERT(xfs_isilocked(ip, XFS_IOLOCK_SHARED | XFS_IOLOCK_EXCL
+				| XFS_MMAPLOCK_EXCL));
+
+	ret = xfs_break_leased_layouts(inode, iolock);
+	if (ret > 0)
+		ret = 0;
+	return ret;
+}
+
 #define	XFS_FALLOC_FL_SUPPORTED						\
 		(FALLOC_FL_KEEP_SIZE | FALLOC_FL_PUNCH_HOLE |		\
 		 FALLOC_FL_COLLAPSE_RANGE | FALLOC_FL_ZERO_RANGE |	\
diff --git a/fs/xfs/xfs_inode.h b/fs/xfs/xfs_inode.h
index 3e8dc990d41c..74c63f3a720f 100644
--- a/fs/xfs/xfs_inode.h
+++ b/fs/xfs/xfs_inode.h
@@ -447,6 +447,8 @@ int	xfs_zero_eof(struct xfs_inode *ip, xfs_off_t offset,
 		     xfs_fsize_t isize, bool *did_zeroing);
 int	xfs_zero_range(struct xfs_inode *ip, xfs_off_t pos, xfs_off_t count,
 		bool *did_zero);
+int	xfs_break_layouts(struct inode *inode, uint *iolock);
+
 
 /* from xfs_iops.c */
 extern void xfs_setup_inode(struct xfs_inode *ip);
diff --git a/fs/xfs/xfs_ioctl.c b/fs/xfs/xfs_ioctl.c
index 4151fade4bb1..d70a1919e787 100644
--- a/fs/xfs/xfs_ioctl.c
+++ b/fs/xfs/xfs_ioctl.c
@@ -39,7 +39,6 @@
 #include "xfs_icache.h"
 #include "xfs_symlink.h"
 #include "xfs_trans.h"
-#include "xfs_pnfs.h"
 #include "xfs_acl.h"
 #include "xfs_btree.h"
 #include <linux/fsmap.h>
diff --git a/fs/xfs/xfs_iops.c b/fs/xfs/xfs_iops.c
index d23aa08426f9..78eb56d447df 100644
--- a/fs/xfs/xfs_iops.c
+++ b/fs/xfs/xfs_iops.c
@@ -37,7 +37,6 @@
 #include "xfs_da_btree.h"
 #include "xfs_dir2.h"
 #include "xfs_trans_space.h"
-#include "xfs_pnfs.h"
 #include "xfs_iomap.h"
 
 #include <linux/capability.h>
diff --git a/fs/xfs/xfs_pnfs.c b/fs/xfs/xfs_pnfs.c
index 9fe661c2d59c..49784828929d 100644
--- a/fs/xfs/xfs_pnfs.c
+++ b/fs/xfs/xfs_pnfs.c
@@ -31,25 +31,26 @@
  * rules in the page fault path we don't bother.
  */
 int
-xfs_break_layouts(
+xfs_break_leased_layouts(
 	struct inode		*inode,
 	uint			*iolock)
 {
 	struct xfs_inode	*ip = XFS_I(inode);
 	int			error;
-
-	ASSERT(xfs_isilocked(ip, XFS_IOLOCK_SHARED | XFS_IOLOCK_EXCL
-				| XFS_MMAPLOCK_EXCL));
+	int			did_unlock = 0;
 
 	while ((error = break_layout(inode, false) == -EWOULDBLOCK)) {
 		xfs_iunlock(ip, *iolock);
+		did_unlock = 1;
 		error = break_layout(inode, true);
 		*iolock &= ~XFS_IOLOCK_SHARED;
 		*iolock |= XFS_IOLOCK_EXCL;
 		xfs_ilock(ip, *iolock);
 	}
 
-	return error;
+	if (error < 0)
+		return error;
+	return did_unlock;
 }
 
 /*
@@ -122,8 +123,8 @@ xfs_fs_map_blocks(
 	 * Lock out any other I/O before we flush and invalidate the pagecache,
 	 * and then hand out a layout to the remote system.  This is very
 	 * similar to direct I/O, except that the synchronization is much more
-	 * complicated.  See the comment near xfs_break_layouts for a detailed
-	 * explanation.
+	 * complicated.  See the comment near xfs_break_leased_layouts
+	 * for a detailed explanation.
 	 */
 	xfs_ilock(ip, XFS_IOLOCK_EXCL);
 
diff --git a/fs/xfs/xfs_pnfs.h b/fs/xfs/xfs_pnfs.h
index bf45951e28fe..12f46fe6d902 100644
--- a/fs/xfs/xfs_pnfs.h
+++ b/fs/xfs/xfs_pnfs.h
@@ -9,10 +9,10 @@ int xfs_fs_map_blocks(struct inode *inode, loff_t offset, u64 length,
 int xfs_fs_commit_blocks(struct inode *inode, struct iomap *maps, int nr_maps,
 		struct iattr *iattr);
 
-int xfs_break_layouts(struct inode *inode, uint *iolock);
+int xfs_break_leased_layouts(struct inode *inode, uint *iolock);
 #else
 static inline int
-xfs_break_layouts(struct inode *inode, uint *iolock)
+xfs_break_leased_layouts(struct inode *inode, uint *iolock)
 {
 	return 0;
 }

_______________________________________________
Linux-nvdimm mailing list
Linux-nvdimm@lists.01.org
https://lists.01.org/mailman/listinfo/linux-nvdimm

  parent reply	other threads:[~2018-03-15 15:55 UTC|newest]

Thread overview: 40+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-03-15 15:51 [PATCH v6 00/15] dax: fix dma vs truncate/hole-punch Dan Williams
2018-03-15 15:51 ` [PATCH v6 01/15] dax: store pfns in the radix Dan Williams
2018-03-15 15:51 ` [PATCH v6 02/15] fs, dax: prepare for dax-specific address_space_operations Dan Williams
2018-03-16 18:59   ` Christoph Hellwig
2018-03-15 15:51 ` [PATCH v6 03/15] block, dax: remove dead code in blkdev_writepages() Dan Williams
2018-03-16 18:59   ` Christoph Hellwig
2018-03-15 15:51 ` [PATCH v6 04/15] xfs, dax: introduce xfs_dax_aops Dan Williams
2018-03-16 19:00   ` Christoph Hellwig
2018-03-15 15:51 ` [PATCH v6 05/15] ext4, dax: introduce ext4_dax_aops Dan Williams
2018-03-15 15:51 ` [PATCH v6 06/15] ext2, dax: introduce ext2_dax_aops Dan Williams
2018-03-18  4:02   ` kbuild test robot
2018-03-18  4:02   ` [RFC PATCH] ext2, dax: ext2_dax_aops can be static kbuild test robot
2018-03-15 15:52 ` [PATCH v6 07/15] fs, dax: use page->mapping to warn if truncate collides with a busy page Dan Williams
2018-03-18  6:26   ` kbuild test robot
2018-03-15 15:52 ` [PATCH v6 08/15] mm, dax: enable filesystems to trigger dev_pagemap ->page_free callbacks Dan Williams
2018-03-15 15:52 ` [PATCH v6 09/15] mm, dev_pagemap: introduce CONFIG_DEV_PAGEMAP_OPS Dan Williams
2018-03-15 15:52 ` [PATCH v6 10/15] memremap: mark devm_memremap_pages() EXPORT_SYMBOL_GPL Dan Williams
2018-03-15 15:52 ` [PATCH v6 11/15] mm, fs, dax: handle layout changes to pinned dax mappings Dan Williams
2018-03-16 19:01   ` Christoph Hellwig
2018-03-17 22:14   ` kbuild test robot
2018-03-15 15:52 ` [PATCH v6 12/15] xfs: require mmap lock for xfs_break_layouts() Dan Williams
2018-03-16 19:04   ` Christoph Hellwig
2018-03-16 19:10     ` Dan Williams
2018-03-19 17:33   ` Darrick J. Wong
2018-03-19 17:57     ` Dan Williams
2018-03-19 18:19       ` Darrick J. Wong
2018-03-19 18:34         ` Dan Williams
2018-03-19 19:45       ` Christoph Hellwig
2018-03-19 20:10         ` Dan Williams
2018-03-19 21:14           ` Christoph Hellwig
2018-03-15 15:52 ` Dan Williams [this message]
2018-03-16 19:08   ` [PATCH v6 13/15] xfs: communicate lock drop events from xfs_break_layouts() Christoph Hellwig
2018-03-15 15:52 ` [PATCH v6 14/15] xfs: prepare xfs_break_layouts() for another layout type Dan Williams
2018-03-16 19:08   ` Christoph Hellwig
2018-03-19 17:45   ` Darrick J. Wong
2018-03-19 18:09     ` Dan Williams
2018-03-15 15:52 ` [PATCH v6 15/15] xfs, dax: introduce xfs_break_dax_layouts() Dan Williams
2018-03-16 19:09   ` Christoph Hellwig
2018-03-17 22:11   ` kbuild test robot
2018-03-17 23:47   ` kbuild test robot

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=152112915950.24669.2377167541944853596.stgit@dwillia2-desk3.amr.corp.intel.com \
    --to=dan.j.williams@intel.com \
    --cc=darrick.wong@oracle.com \
    --cc=david@fromorbit.com \
    --cc=hch@lst.de \
    --cc=jack@suse.cz \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-nvdimm@lists.01.org \
    --cc=linux-xfs@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).