]> err.no Git - linux-2.6/blobdiff - fs/nfs/inode.c
Merge branch 'agp-patches' of git://git.kernel.org/pub/scm/linux/kernel/git/airlied...
[linux-2.6] / fs / nfs / inode.c
index 3d9fccf4ef93eb9f51c01f2fa7d3e435ca881216..71a49c3acabdb26d941fb5fea5ce41e23e72ff2b 100644 (file)
@@ -468,7 +468,7 @@ static struct nfs_open_context *alloc_nfs_open_context(struct vfsmount *mnt, str
                ctx->lockowner = current->files;
                ctx->error = 0;
                ctx->dir_cookie = 0;
-               kref_init(&ctx->kref);
+               atomic_set(&ctx->count, 1);
        }
        return ctx;
 }
@@ -476,21 +476,18 @@ static struct nfs_open_context *alloc_nfs_open_context(struct vfsmount *mnt, str
 struct nfs_open_context *get_nfs_open_context(struct nfs_open_context *ctx)
 {
        if (ctx != NULL)
-               kref_get(&ctx->kref);
+               atomic_inc(&ctx->count);
        return ctx;
 }
 
-static void nfs_free_open_context(struct kref *kref)
+void put_nfs_open_context(struct nfs_open_context *ctx)
 {
-       struct nfs_open_context *ctx = container_of(kref,
-                       struct nfs_open_context, kref);
+       struct inode *inode = ctx->path.dentry->d_inode;
 
-       if (!list_empty(&ctx->list)) {
-               struct inode *inode = ctx->path.dentry->d_inode;
-               spin_lock(&inode->i_lock);
-               list_del(&ctx->list);
-               spin_unlock(&inode->i_lock);
-       }
+       if (!atomic_dec_and_lock(&ctx->count, &inode->i_lock))
+               return;
+       list_del(&ctx->list);
+       spin_unlock(&inode->i_lock);
        if (ctx->state != NULL)
                nfs4_close_state(&ctx->path, ctx->state, ctx->mode);
        if (ctx->cred != NULL)
@@ -500,11 +497,6 @@ static void nfs_free_open_context(struct kref *kref)
        kfree(ctx);
 }
 
-void put_nfs_open_context(struct nfs_open_context *ctx)
-{
-       kref_put(&ctx->kref, nfs_free_open_context);
-}
-
 /*
  * Ensure that mmap has a recent RPC credential for use when writing out
  * shared pages
@@ -1165,14 +1157,14 @@ static void init_once(void * foo, struct kmem_cache * cachep, unsigned long flag
        nfsi->npages = 0;
        nfs4_init_once(nfsi);
 }
+
 static int __init nfs_init_inodecache(void)
 {
        nfs_inode_cachep = kmem_cache_create("nfs_inode_cache",
                                             sizeof(struct nfs_inode),
                                             0, (SLAB_RECLAIM_ACCOUNT|
                                                SLAB_MEM_SPREAD),
-                                            init_once, NULL);
+                                            init_once);
        if (nfs_inode_cachep == NULL)
                return -ENOMEM;