[pnfs] [PATCH 9/9] layoutrecall: allow nested layout recall/return in nfsd_close

Benny Halevy bhalevy at panasas.com
Thu Aug 30 09:34:35 EDT 2007


The exported file system may generate layoutrecall callbacks
in the nfsd_close() -> fput() path and then synchronously wait for
the corresponding layoutreturns before returning the release() vfs
file operation. I'm unlocking the state lock around the call to
nfsd_close() in release_stateid() (after verifying the the current thread
holds the state lock) to allow these nested layoutreturn calls in.

Signed-off-by: Benny Halevy <bhalevy at panasas.com>
---
 fs/nfsd/nfs4state.c |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)

diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c
index 5eee479..0a1965b 100644
--- a/fs/nfsd/nfs4state.c
+++ b/fs/nfsd/nfs4state.c
@@ -112,7 +112,8 @@ static kmem_cache_t *file_slab = NULL;
 static kmem_cache_t *stateid_slab = NULL;
 static kmem_cache_t *deleg_slab = NULL;
 
-#define BUG_ON_UNLOCKED_STATE() BUG_ON(mutex_trylock(&client_mutex))
+#define BUG_ON_UNLOCKED_STATE() BUG_ON(mutex_trylock(&client_mutex) || \
+	client_mutex_owner != current->thread_info)
 
 void
 nfs4_lock_state(void)
@@ -1699,7 +1700,10 @@ release_stateid(struct nfs4_stateid *stp, int flags)
 	if (flags & OPEN_STATE) {
 		release_stateid_lockowners(stp);
 		stp->st_vfs_file = NULL;
+		BUG_ON_UNLOCKED_STATE();
+		nfs4_unlock_state();	/* allow nested layout recall/return */
 		nfsd_close(filp);
+		nfs4_lock_state();
 	} else if (flags & LOCK_STATE)
 		locks_remove_posix(filp, (fl_owner_t) stp->st_stateowner);
 	put_nfs4_file(stp->st_file);
-- 
1.5.2.5



More information about the pNFS mailing list