[pnfs] [PATCH 5/5] introduce BUG_ON_UNLOCKED_STATE
Benny Halevy
bhalevy at panasas.com
Thu May 17 09:47:17 EDT 2007
This patch adds BUG_ON_UNLOCKED_STATE calls to assert the
state_lock is taken in some strategic places.
Signed-off-by: Benny Halevy <bhalevy at panasas.com>
---
fs/nfsd/nfs4state.c | 6 ++++++
1 files changed, 6 insertions(+), 0 deletions(-)
diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c
index 916cb26..1d5d639 100644
--- a/fs/nfsd/nfs4state.c
+++ b/fs/nfsd/nfs4state.c
@@ -91,6 +91,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))
+
void
nfs4_lock_state(void)
{
@@ -140,6 +142,7 @@ free_nfs4_file(struct kref *kref)
static inline void
put_nfs4_file(struct nfs4_file *fi)
{
+ BUG_ON_UNLOCKED_STATE();
kref_put(&fi->fi_ref, free_nfs4_file);
}
@@ -549,6 +552,7 @@ expire_client(struct nfs4_client *clp)
dprintk("NFSD: expire_client cl_count %d\n",
atomic_read(&clp->cl_count));
+ BUG_ON_UNLOCKED_STATE();
shutdown_callback_client(clp);
INIT_LIST_HEAD(&reaplist);
@@ -1553,6 +1557,7 @@ find_openstateowner_str(unsigned int hashval, struct nfsd4_open *open)
{
struct nfs4_stateowner *so = NULL;
+ BUG_ON_UNLOCKED_STATE();
list_for_each_entry(so, &ownerstr_hashtbl[hashval], so_strhash) {
if (cmp_owner_str(so, &open->op_owner, &open->op_clientid))
return so;
@@ -1567,6 +1572,7 @@ find_file(struct inode *ino)
unsigned int hashval = file_hashval(ino);
struct nfs4_file *fp;
+ BUG_ON_UNLOCKED_STATE();
list_for_each_entry(fp, &file_hashtbl[hashval], fi_hash) {
if (fp->fi_inode == ino) {
get_nfs4_file(fp);
More information about the pNFS
mailing list