Thread (6 messages) 6 messages, 2 authors, 2018-01-18

Re: [PATCH 1/2] xfs: reflink should break pnfs leases before sharing blocks

From: Christoph Hellwig <hch@lst.de>
Date: 2018-01-18 14:26:48

On Wed, Jan 17, 2018 at 11:42:33PM -0800, Darrick J. Wong wrote:
quoted hunk ↗ jump to hunk
From: Darrick J. Wong <redacted>

Before we share blocks between files, we need to break the pnfs leases
on the layout before we start slicing and dicing the block map.

Signed-off-by: Darrick J. Wong <redacted>
---
 fs/xfs/xfs_reflink.c |   32 +++++++++++++++++++++++++++++++-
 1 file changed, 31 insertions(+), 1 deletion(-)

diff --git a/fs/xfs/xfs_reflink.c b/fs/xfs/xfs_reflink.c
index da5c490..a701336 100644
--- a/fs/xfs/xfs_reflink.c
+++ b/fs/xfs/xfs_reflink.c
@@ -1249,6 +1249,34 @@ xfs_reflink_remap_blocks(
 }
 
 /*
+ * Grab the exclusive iolock for a data copy from in to out, making sure to
+ * break the pnfs layout leases on out before proceeding.
+ */
+static int
+xfs_iolock_two_inodes_and_break_layout(
+	struct inode		*inode_in,
+	struct inode		*inode_out)
+{
+	uint			iolock = XFS_IOLOCK_EXCL;
+	int			error;
+
+	if (inode_in < inode_out) {
+		inode_lock(inode_in);
+		inode_lock_nested(inode_out, I_MUTEX_NONDIR2);
+	} else {
+		inode_lock(inode_out);
+	}
+	error = xfs_break_layouts(inode_out, &iolock);
+	if (error) {
+		inode_unlock(inode_in);
+		return error;
+	}
+	if (inode_in > inode_out)
+		inode_lock_nested(inode_in, I_MUTEX_NONDIR2);
+	return 0;
So we'll keep the other inode lock while recalling in one of the
cases?  In general I suspect we should be dropping all loops and
just restart all checks, similar to what we do for various cases
in the write path.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help