[pnfs] [Fwd: [PATCH 09/13] pnfs: list and unlist nfs_inode on cl_lo_inodes]
Benny Halevy
bhalevy at panasas.com
Wed Jan 23 05:48:08 EST 2008
Resending since previous message didn't get to the mailing list.
On Jan. 22, 2008, 21:34 +0200, Benny Halevy <bhalevy at panasas.com> wrote:
list the nfs inode on cl_lo_inodes whenever the first
layout is retrieved and unlist when the layout is
destroyed.
Signed-off-by: Benny Halevy <bhalevy at panasas.com>
---
fs/nfs/pnfs.c | 20 ++++++++++++++++++++
1 files changed, 20 insertions(+), 0 deletions(-)
diff --git a/fs/nfs/pnfs.c b/fs/nfs/pnfs.c
index 99eadb6..e3280c5 100644
--- a/fs/nfs/pnfs.c
+++ b/fs/nfs/pnfs.c
@@ -342,6 +342,8 @@ static inline void
put_unlock_current_layout(struct nfs_inode *nfsi,
struct pnfs_layout_type *lo)
{
+ struct nfs_client *clp;
+
BUG_ON_UNLOCKED_LO(lo);
BUG_ON(lo->refcount <= 0);
@@ -353,6 +355,18 @@ put_unlock_current_layout(struct nfs_inode *nfsi,
io_ops->free_layout(lo);
nfsi->current_layout = NULL;
+
+ /* Unlist the inode.
+ * Note that nfsi->lo_lock must be released before getting
+ * cl_sem as the latter can sleep
+ */
+ clp = NFS_SERVER(&nfsi->vfs_inode)->nfs_client;
+ spin_unlock(&nfsi->lo_lock);
+ down_write(&clp->cl_sem);
+ spin_lock(&nfsi->lo_lock);
+ if (!nfsi->current_layout)
+ list_del_init(&nfsi->lo_inodes);
+ up_write(&clp->cl_sem);
}
spin_unlock(&nfsi->lo_lock);
}
@@ -733,9 +747,15 @@ get_lock_alloc_layout(struct inode *ino,
lo = alloc_init_layout(ino, io_ops);
if (lo) {
+ struct nfs_client *clp = NFS_SERVER(ino)->nfs_client;
+
/* must grab the layout lock */
spin_lock(&nfsi->lo_lock);
nfsi->current_layout = lo;
+
+ down_write(&clp->cl_sem);
+ list_add_tail(&nfsi->lo_inodes, &clp->cl_lo_inodes);
+ up_write(&clp->cl_sem);
} else
lo = ERR_PTR(-ENOMEM);
--
1.5.3.3
--
Benny Halevy
Software Architect
Tel/Fax: +972-3-647-8340
Mobile: +972-54-802-8340
US: +1-412-203-3187
bhalevy at panasas.com
Panasas, Inc.
The Leader in Parallel Storage
www.panasas.com
More information about the pNFS
mailing list