]> err.no Git - linux-2.6/blobdiff - fs/nfs/inode.c
pull asus sony thinkpad into release branch
[linux-2.6] / fs / nfs / inode.c
index 7bcb3dfa61790541098c0bb6dd524a1f26a6475a..71a49c3acabdb26d941fb5fea5ce41e23e72ff2b 100644 (file)
@@ -461,7 +461,6 @@ static struct nfs_open_context *alloc_nfs_open_context(struct vfsmount *mnt, str
 
        ctx = kmalloc(sizeof(*ctx), GFP_KERNEL);
        if (ctx != NULL) {
-               atomic_set(&ctx->count, 1);
                ctx->path.dentry = dget(dentry);
                ctx->path.mnt = mntget(mnt);
                ctx->cred = get_rpccred(cred);
@@ -469,6 +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;
+               atomic_set(&ctx->count, 1);
        }
        return ctx;
 }
@@ -482,21 +482,19 @@ struct nfs_open_context *get_nfs_open_context(struct nfs_open_context *ctx)
 
 void put_nfs_open_context(struct nfs_open_context *ctx)
 {
-       if (atomic_dec_and_test(&ctx->count)) {
-               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 (ctx->state != NULL)
-                       nfs4_close_state(&ctx->path, ctx->state, ctx->mode);
-               if (ctx->cred != NULL)
-                       put_rpccred(ctx->cred);
-               dput(ctx->path.dentry);
-               mntput(ctx->path.mnt);
-               kfree(ctx);
-       }
+       struct inode *inode = ctx->path.dentry->d_inode;
+
+       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)
+               put_rpccred(ctx->cred);
+       dput(ctx->path.dentry);
+       mntput(ctx->path.mnt);
+       kfree(ctx);
 }
 
 /*
@@ -1066,8 +1064,10 @@ static int nfs_update_inode(struct inode *inode, struct nfs_fattr *fattr)
                invalid &= ~NFS_INO_INVALID_DATA;
        if (data_stable)
                invalid &= ~(NFS_INO_INVALID_ATTR|NFS_INO_INVALID_ATIME|NFS_INO_REVAL_PAGECACHE);
-       if (!nfs_have_delegation(inode, FMODE_READ))
+       if (!nfs_have_delegation(inode, FMODE_READ) ||
+                       (nfsi->cache_validity & NFS_INO_REVAL_FORCED))
                nfsi->cache_validity |= invalid;
+       nfsi->cache_validity &= ~NFS_INO_REVAL_FORCED;
 
        return 0;
  out_changed:
@@ -1148,27 +1148,23 @@ static void init_once(void * foo, struct kmem_cache * cachep, unsigned long flag
        struct nfs_inode *nfsi = (struct nfs_inode *) foo;
 
        inode_init_once(&nfsi->vfs_inode);
-       spin_lock_init(&nfsi->req_lock);
-       INIT_LIST_HEAD(&nfsi->dirty);
-       INIT_LIST_HEAD(&nfsi->commit);
        INIT_LIST_HEAD(&nfsi->open_files);
        INIT_LIST_HEAD(&nfsi->access_cache_entry_lru);
        INIT_LIST_HEAD(&nfsi->access_cache_inode_lru);
        INIT_RADIX_TREE(&nfsi->nfs_page_tree, GFP_ATOMIC);
        atomic_set(&nfsi->data_updates, 0);
-       nfsi->ndirty = 0;
        nfsi->ncommit = 0;
        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;