From: Andy Adamson <andros@xxxxxxxxxx> Signed-off-by: Andy Adamson <andros@xxxxxxxxxx> --- fs/nfs/pnfs.c | 24 +++++++++++++----------- 1 files changed, 13 insertions(+), 11 deletions(-) diff --git a/fs/nfs/pnfs.c b/fs/nfs/pnfs.c index d42c5da..040f9e0 100644 --- a/fs/nfs/pnfs.c +++ b/fs/nfs/pnfs.c @@ -371,7 +371,10 @@ pnfs_layout_release(struct pnfs_layout_type *lo, spin_lock(&nfsi->vfs_inode.i_lock); if (range) pnfs_free_layout(lo, range); - /* Matched in _pnfs_update_layout for layoutget */ + /* + * Matched in _pnfs_update_layout for layoutget + * and by get_layout in _pnfs_return_layout for layoutreturn + */ put_layout_locked(lo); spin_unlock(&nfsi->vfs_inode.i_lock); wake_up_all(&nfsi->lo_waitq); @@ -776,9 +779,8 @@ _pnfs_return_layout(struct inode *ino, struct nfs4_pnfs_layout_segment *range, if (type == RETURN_FILE) { spin_lock(&ino->i_lock); - lo = grab_current_layout(nfsi); + lo = nfsi->layout; if (lo && !has_layout_to_return(lo, &arg)) { - put_layout(lo); lo = NULL; } if (!lo) { @@ -787,18 +789,15 @@ _pnfs_return_layout(struct inode *ino, struct nfs4_pnfs_layout_segment *range, goto out; } - /* unlock w/o put rebalanced by eventual call to - * pnfs_layout_release - */ + /* Reference for layoutreturn matched in pnfs_layout_release */ + get_layout(lo); + spin_unlock(&ino->i_lock); if (pnfs_return_layout_barrier(nfsi, &arg)) { if (stateid) { /* callback */ status = -EAGAIN; - spin_lock(&ino->i_lock); - put_layout(lo); - spin_unlock(&ino->i_lock); - goto out; + goto out_put; } dprintk("%s: waiting\n", __func__); wait_event(nfsi->lo_waitq, @@ -809,7 +808,7 @@ _pnfs_return_layout(struct inode *ino, struct nfs4_pnfs_layout_segment *range, if (stateid && !wait) { /* callback */ dprintk("%s: layoutcommit pending\n", __func__); status = -EAGAIN; - goto out; + goto out_put; } status = pnfs_layoutcommit_inode(ino, wait); if (status) { @@ -828,6 +827,9 @@ _pnfs_return_layout(struct inode *ino, struct nfs4_pnfs_layout_segment *range, out: dprintk("<-- %s status: %d\n", __func__, status); return status; +out_put: + put_layout(ino); + goto out; } void -- 1.6.6 -- To unsubscribe from this list: send the line "unsubscribe linux-nfs" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html