[pnfs] [PATCH 1/3] pnfs: shift nfsi structures protected by pnfs_spinlock to nfsi->lo_lock

Fred Isaman iisaman at citi.umich.edu
Wed Jun 11 12:34:06 EDT 2008


pnfs_spinlock was sometimes protecting layoutcommit data held in nfsi.
Switch these over to being protected by nfsi->lo_lock, and make the
protection more consistent.

Signed-off-by: Fred Isaman <iisaman at citi.umich.edu>
---
 fs/nfs/pnfs.c |   21 ++++++++++++++-------
 1 files changed, 14 insertions(+), 7 deletions(-)

diff --git a/fs/nfs/pnfs.c b/fs/nfs/pnfs.c
index c51243a..63a184a 100644
--- a/fs/nfs/pnfs.c
+++ b/fs/nfs/pnfs.c
@@ -161,16 +161,16 @@ pnfs_need_layoutcommit(struct nfs_inode *nfsi, struct nfs_open_context *ctx)
 {
 	dprintk("%s: current_layout=%p layoutcommit_ctx=%p ctx=%p\n", __func__,
 		nfsi->current_layout, nfsi->layoutcommit_ctx, ctx);
-	spin_lock(&pnfs_spinlock);
+	spin_lock(&nfsi->lo_lock);
 	if (nfsi->current_layout && !nfsi->layoutcommit_ctx) {
 		nfsi->layoutcommit_ctx = get_nfs_open_context(ctx);
 		nfsi->change_attr++;
-		spin_unlock(&pnfs_spinlock);
+		spin_unlock(&nfsi->lo_lock);
 		dprintk("%s: Set layoutcommit_ctx=%p\n", __func__,
 			nfsi->layoutcommit_ctx);
 		return;
 	}
-	spin_unlock(&pnfs_spinlock);
+	spin_unlock(&nfsi->lo_lock);
 }
 
 /* Update last_write_offset for layoutcommit.
@@ -183,6 +183,7 @@ pnfs_update_last_write(struct nfs_inode *nfsi, loff_t offset, size_t extent)
 {
 	loff_t end_pos, orig_offset = offset;
 
+	spin_lock(&nfsi->lo_lock);
 	if (orig_offset < nfsi->pnfs_write_begin_pos)
 		nfsi->pnfs_write_begin_pos = orig_offset;
 	end_pos = orig_offset + extent - 1; /* I'm being inclusive */
@@ -194,6 +195,7 @@ pnfs_update_last_write(struct nfs_inode *nfsi, loff_t offset, size_t extent)
 		(unsigned long) offset ,
 		(unsigned long) nfsi->pnfs_write_begin_pos,
 		(unsigned long) nfsi->pnfs_write_end_pos);
+	spin_unlock(&nfsi->lo_lock);
 }
 
 /* Unitialize a mountpoint in a layout driver */
@@ -634,6 +636,9 @@ _pnfs_return_layout(struct inode *ino, struct nfs4_pnfs_layout_segment *range,
 			goto out;
 		}
 		pnfs_free_layout(lo, &arg);
+		/* unlock w/o put rebalanced by eventual call to
+		 * pnfs_layout_release
+		 */
 		spin_unlock(&nfsi->lo_lock);
 	}
 
@@ -958,6 +963,7 @@ pnfs_update_layout(struct inode *ino,
 		}
 	}
 
+	/* Lose lock, but not reference, match this with pnfs_layout_release */
 	spin_unlock(&nfsi->lo_lock);
 
 	result = get_layout(ino, ctx, &arg, lsegpp, lo);
@@ -984,6 +990,7 @@ pnfs_get_layout_done(struct pnfs_layout_type *lo,
 
 	dprintk("-->%s\n", __func__);
 
+	/* Already have reference */
 	spin_lock(&nfsi->lo_lock);
 
 	BUG_ON(nfsi->current_layout != lo);
@@ -1902,7 +1909,7 @@ pnfs_layoutcommit_setup(struct pnfs_layoutcommit_data *data, int sync)
 	 * until xdr time.
 	 */
 	/* BUG - a major purpose of this call is to set (and thus allocate)
-	 * data->args.new_layout, but pnfs_spinlock is currently held
+	 * data->args.new_layout, but nfsi->lo_lock is currently held
 	 */
 	if (nfss->pnfs_curr_ld->ld_io_ops->setup_layoutcommit) {
 		result = nfss->pnfs_curr_ld->ld_io_ops->setup_layoutcommit(
@@ -1938,7 +1945,7 @@ pnfs_layoutcommit_inode(struct inode *inode, int sync)
 	if (!data)
 		return -ENOMEM;
 
-	spin_lock(&pnfs_spinlock);
+	spin_lock(&nfsi->lo_lock);
 	if (!nfsi->layoutcommit_ctx) {
 		pnfs_layoutcommit_free(data);
 		goto out_unlock;
@@ -1961,7 +1968,7 @@ pnfs_layoutcommit_inode(struct inode *inode, int sync)
 	nfsi->layoutcommit_ctx = NULL;
 
 	/* release lock on pnfs layoutcommit attrs */
-	spin_unlock(&pnfs_spinlock);
+	spin_unlock(&nfsi->lo_lock);
 
 	/* Execute the layout commit synchronously */
 	if (sync) {
@@ -1974,7 +1981,7 @@ out:
 	dprintk("%s end (err:%d)\n", __func__, status);
 	return status;
 out_unlock:
-	spin_unlock(&pnfs_spinlock);
+	spin_unlock(&nfsi->lo_lock);
 	goto out;
 }
 
-- 
1.5.3.3



More information about the pNFS mailing list