fedora core 6 1.2949 + vserver 2.2.0
[linux-2.6.git] / fs / nfs / dir.c
index d424d08..7422b73 100644 (file)
 #include <linux/nfs_mount.h>
 #include <linux/pagemap.h>
 #include <linux/smp_lock.h>
+#include <linux/pagevec.h>
 #include <linux/namei.h>
 #include <linux/mount.h>
-#include <linux/vserver/xid.h>
+#include <linux/vs_tag.h>
 
 #include "nfs4_fs.h"
 #include "delegation.h"
@@ -142,12 +143,12 @@ nfs_opendir(struct inode *inode, struct file *filp)
        return res;
 }
 
-typedef u32 * (*decode_dirent_t)(u32 *, struct nfs_entry *, int);
+typedef __be32 * (*decode_dirent_t)(__be32 *, struct nfs_entry *, int);
 typedef struct {
        struct file     *file;
        struct page     *page;
        unsigned long   page_index;
-       u32             *ptr;
+       __be32          *ptr;
        u64             *dir_cookie;
        loff_t          current_index;
        struct nfs_entry *entry;
@@ -172,7 +173,7 @@ static
 int nfs_readdir_filler(nfs_readdir_descriptor_t *desc, struct page *page)
 {
        struct file     *file = desc->file;
-       struct inode    *inode = file->f_dentry->d_inode;
+       struct inode    *inode = file->f_path.dentry->d_inode;
        struct rpc_cred *cred = nfs_file_cred(file);
        unsigned long   timestamp;
        int             error;
@@ -183,7 +184,7 @@ int nfs_readdir_filler(nfs_readdir_descriptor_t *desc, struct page *page)
 
  again:
        timestamp = jiffies;
-       error = NFS_PROTO(inode)->readdir(file->f_dentry, cred, desc->entry->cookie, page,
+       error = NFS_PROTO(inode)->readdir(file->f_path.dentry, cred, desc->entry->cookie, page,
                                          NFS_SERVER(inode)->dtsize, desc->plus);
        if (error < 0) {
                /* We requested READDIRPLUS, but the server doesn't grok it */
@@ -203,8 +204,10 @@ int nfs_readdir_filler(nfs_readdir_descriptor_t *desc, struct page *page)
         * Note: assumes we have exclusive access to this mapping either
         *       through inode->i_mutex or some other mechanism.
         */
-       if (page->index == 0)
-               invalidate_inode_pages2_range(inode->i_mapping, PAGE_CACHE_SIZE, -1);
+       if (page->index == 0 && invalidate_inode_pages2_range(inode->i_mapping, PAGE_CACHE_SIZE, -1) < 0) {
+               /* Should never happen */
+               nfs_zap_mapping(inode, inode->i_mapping);
+       }
        unlock_page(page);
        return 0;
  error:
@@ -218,7 +221,7 @@ int nfs_readdir_filler(nfs_readdir_descriptor_t *desc, struct page *page)
 static inline
 int dir_decode(nfs_readdir_descriptor_t *desc)
 {
-       u32     *p = desc->ptr;
+       __be32  *p = desc->ptr;
        p = desc->decode(p, desc->entry, desc->plus);
        if (IS_ERR(p))
                return PTR_ERR(p);
@@ -306,7 +309,7 @@ int find_dirent_index(nfs_readdir_descriptor_t *desc)
 static inline
 int find_dirent_page(nfs_readdir_descriptor_t *desc)
 {
-       struct inode    *inode = desc->file->f_dentry->d_inode;
+       struct inode    *inode = desc->file->f_path.dentry->d_inode;
        struct page     *page;
        int             status;
 
@@ -398,7 +401,7 @@ int nfs_do_filldir(nfs_readdir_descriptor_t *desc, void *dirent,
        struct file     *file = desc->file;
        struct nfs_entry *entry = desc->entry;
        struct dentry   *dentry = NULL;
-       u64             fileid;
+       unsigned long   fileid;
        int             loop_count = 0,
                        res;
 
@@ -409,7 +412,7 @@ int nfs_do_filldir(nfs_readdir_descriptor_t *desc, void *dirent,
                unsigned d_type = DT_UNKNOWN;
                /* Note: entry->prev_cookie contains the cookie for
                 *       retrieving the current dirent on the server */
-               fileid = entry->ino;
+               fileid = nfs_fileid_to_ino_t(entry->ino);
 
                /* Get a dentry if we have one */
                if (dentry != NULL)
@@ -419,7 +422,7 @@ int nfs_do_filldir(nfs_readdir_descriptor_t *desc, void *dirent,
                /* Use readdirplus info */
                if (dentry != NULL && dentry->d_inode != NULL) {
                        d_type = dt_type(dentry->d_inode);
-                       fileid = NFS_FILEID(dentry->d_inode);
+                       fileid = dentry->d_inode->i_ino;
                }
 
                res = filldir(dirent, entry->name, entry->len, 
@@ -462,7 +465,7 @@ int uncached_readdir(nfs_readdir_descriptor_t *desc, void *dirent,
                     filldir_t filldir)
 {
        struct file     *file = desc->file;
-       struct inode    *inode = file->f_dentry->d_inode;
+       struct inode    *inode = file->f_path.dentry->d_inode;
        struct rpc_cred *cred = nfs_file_cred(file);
        struct page     *page = NULL;
        int             status;
@@ -475,7 +478,7 @@ int uncached_readdir(nfs_readdir_descriptor_t *desc, void *dirent,
                status = -ENOMEM;
                goto out;
        }
-       desc->error = NFS_PROTO(inode)->readdir(file->f_dentry, cred, *desc->dir_cookie,
+       desc->error = NFS_PROTO(inode)->readdir(file->f_path.dentry, cred, *desc->dir_cookie,
                                                page,
                                                NFS_SERVER(inode)->dtsize,
                                                desc->plus);
@@ -514,7 +517,7 @@ int uncached_readdir(nfs_readdir_descriptor_t *desc, void *dirent,
  */
 static int nfs_readdir(struct file *filp, void *dirent, filldir_t filldir)
 {
-       struct dentry   *dentry = filp->f_dentry;
+       struct dentry   *dentry = filp->f_path.dentry;
        struct inode    *inode = dentry->d_inode;
        nfs_readdir_descriptor_t my_desc,
                        *desc = &my_desc;
@@ -530,7 +533,7 @@ static int nfs_readdir(struct file *filp, void *dirent, filldir_t filldir)
 
        lock_kernel();
 
-       res = nfs_revalidate_mapping(inode, filp->f_mapping);
+       res = nfs_revalidate_mapping_nolock(inode, filp->f_mapping);
        if (res < 0) {
                unlock_kernel();
                return res;
@@ -597,7 +600,7 @@ static int nfs_readdir(struct file *filp, void *dirent, filldir_t filldir)
 
 loff_t nfs_llseek_dir(struct file *filp, loff_t offset, int origin)
 {
-       mutex_lock(&filp->f_dentry->d_inode->i_mutex);
+       mutex_lock(&filp->f_path.dentry->d_inode->i_mutex);
        switch (origin) {
                case 1:
                        offset += filp->f_pos;
@@ -613,7 +616,7 @@ loff_t nfs_llseek_dir(struct file *filp, loff_t offset, int origin)
                ((struct nfs_open_context *)filp->private_data)->dir_cookie = 0;
        }
 out:
-       mutex_unlock(&filp->f_dentry->d_inode->i_mutex);
+       mutex_unlock(&filp->f_path.dentry->d_inode->i_mutex);
        return offset;
 }
 
@@ -843,7 +846,7 @@ static void nfs_dentry_iput(struct dentry *dentry, struct inode *inode)
        nfs_inode_return_delegation(inode);
        if (dentry->d_flags & DCACHE_NFSFS_RENAMED) {
                lock_kernel();
-               inode->i_nlink--;
+               drop_nlink(inode);
                nfs_complete_unlink(dentry);
                unlock_kernel();
        }
@@ -930,12 +933,21 @@ static struct dentry *nfs_lookup(struct inode *dir, struct dentry * dentry, stru
        res = (struct dentry *)inode;
        if (IS_ERR(res))
                goto out_unlock;
-       vx_propagate_xid(nd, inode);
 
+       dx_propagate_tag(nd, inode);
 no_entry:
        res = d_materialise_unique(dentry, inode);
-       if (res != NULL)
+       if (res != NULL) {
+               struct dentry *parent;
+               if (IS_ERR(res))
+                       goto out_unlock;
+               /* Was a directory renamed! */
+               parent = dget_parent(res);
+               if (!IS_ROOT(parent))
+                       nfs_mark_for_revalidate(parent->d_inode);
+               dput(parent);
                dentry = res;
+       }
        nfs_renew_times(dentry);
        nfs_set_verifier(dentry, nfs_save_change_attribute(dir));
 out_unlock:
@@ -1093,7 +1105,7 @@ no_open:
 
 static struct dentry *nfs_readdir_lookup(nfs_readdir_descriptor_t *desc)
 {
-       struct dentry *parent = desc->file->f_dentry;
+       struct dentry *parent = desc->file->f_path.dentry;
        struct inode *dir = parent->d_inode;
        struct nfs_entry *entry = desc->entry;
        struct dentry *dentry, *alias;
@@ -1132,6 +1144,8 @@ static struct dentry *nfs_readdir_lookup(nfs_readdir_descriptor_t *desc)
        alias = d_materialise_unique(dentry, inode);
        if (alias != NULL) {
                dput(dentry);
+               if (IS_ERR(alias))
+                       return NULL;
                dentry = alias;
        }
 
@@ -1156,25 +1170,22 @@ int nfs_instantiate(struct dentry *dentry, struct nfs_fh *fhandle,
                struct inode *dir = dentry->d_parent->d_inode;
                error = NFS_PROTO(dir)->lookup(dir, &dentry->d_name, fhandle, fattr);
                if (error)
-                       goto out_err;
+                       return error;
        }
        if (!(fattr->valid & NFS_ATTR_FATTR)) {
                struct nfs_server *server = NFS_SB(dentry->d_sb);
                error = server->nfs_client->rpc_ops->getattr(server, fhandle, fattr);
                if (error < 0)
-                       goto out_err;
+                       return error;
        }
        inode = nfs_fhget(dentry->d_sb, fhandle, fattr);
        error = PTR_ERR(inode);
        if (IS_ERR(inode))
-               goto out_err;
+               return error;
        d_instantiate(dentry, inode);
        if (d_unhashed(dentry))
                d_rehash(dentry);
        return 0;
-out_err:
-       d_drop(dentry);
-       return error;
 }
 
 /*
@@ -1291,7 +1302,7 @@ static int nfs_rmdir(struct inode *dir, struct dentry *dentry)
        error = NFS_PROTO(dir)->rmdir(dir, &dentry->d_name);
        /* Ensure the VFS deletes this inode */
        if (error == 0 && dentry->d_inode != NULL)
-               dentry->d_inode->i_nlink = 0;
+               clear_nlink(dentry->d_inode);
        nfs_end_data_update(dir);
        unlock_kernel();
 
@@ -1406,7 +1417,7 @@ static int nfs_safe_remove(struct dentry *dentry)
                error = NFS_PROTO(dir)->remove(dir, &dentry->d_name);
                /* The VFS may want to delete this inode */
                if (error == 0)
-                       inode->i_nlink--;
+                       drop_nlink(inode);
                nfs_mark_for_revalidate(inode);
                nfs_end_data_update(inode);
        } else
@@ -1455,48 +1466,82 @@ static int nfs_unlink(struct inode *dir, struct dentry *dentry)
        return error;
 }
 
-static int
-nfs_symlink(struct inode *dir, struct dentry *dentry, const char *symname)
+/*
+ * To create a symbolic link, most file systems instantiate a new inode,
+ * add a page to it containing the path, then write it out to the disk
+ * using prepare_write/commit_write.
+ *
+ * Unfortunately the NFS client can't create the in-core inode first
+ * because it needs a file handle to create an in-core inode (see
+ * fs/nfs/inode.c:nfs_fhget).  We only have a file handle *after* the
+ * symlink request has completed on the server.
+ *
+ * So instead we allocate a raw page, copy the symname into it, then do
+ * the SYMLINK request with the page as the buffer.  If it succeeds, we
+ * now have a new file handle and can instantiate an in-core NFS inode
+ * and move the raw page into its mapping.
+ */
+static int nfs_symlink(struct inode *dir, struct dentry *dentry, const char *symname)
 {
+       struct pagevec lru_pvec;
+       struct page *page;
+       char *kaddr;
        struct iattr attr;
-       struct nfs_fattr sym_attr;
-       struct nfs_fh sym_fh;
-       struct qstr qsymname;
+       unsigned int pathlen = strlen(symname);
        int error;
 
        dfprintk(VFS, "NFS: symlink(%s/%ld, %s, %s)\n", dir->i_sb->s_id,
                dir->i_ino, dentry->d_name.name, symname);
 
-#ifdef NFS_PARANOIA
-if (dentry->d_inode)
-printk("nfs_proc_symlink: %s/%s not negative!\n",
-dentry->d_parent->d_name.name, dentry->d_name.name);
-#endif
-       /*
-        * Fill in the sattr for the call.
-        * Note: SunOS 4.1.2 crashes if the mode isn't initialized!
-        */
-       attr.ia_valid = ATTR_MODE;
-       attr.ia_mode = S_IFLNK | S_IRWXUGO;
+       if (pathlen > PAGE_SIZE)
+               return -ENAMETOOLONG;
 
-       qsymname.name = symname;
-       qsymname.len  = strlen(symname);
+       attr.ia_mode = S_IFLNK | S_IRWXUGO;
+       attr.ia_valid = ATTR_MODE;
 
        lock_kernel();
+
+       page = alloc_page(GFP_KERNEL);
+       if (!page) {
+               unlock_kernel();
+               return -ENOMEM;
+       }
+
+       kaddr = kmap_atomic(page, KM_USER0);
+       memcpy(kaddr, symname, pathlen);
+       if (pathlen < PAGE_SIZE)
+               memset(kaddr + pathlen, 0, PAGE_SIZE - pathlen);
+       kunmap_atomic(kaddr, KM_USER0);
+
        nfs_begin_data_update(dir);
-       error = NFS_PROTO(dir)->symlink(dir, &dentry->d_name, &qsymname,
-                                         &attr, &sym_fh, &sym_attr);
+       error = NFS_PROTO(dir)->symlink(dir, dentry, page, pathlen, &attr);
        nfs_end_data_update(dir);
-       if (!error) {
-               error = nfs_instantiate(dentry, &sym_fh, &sym_attr);
-       } else {
-               if (error == -EEXIST)
-                       printk("nfs_proc_symlink: %s/%s already exists??\n",
-                              dentry->d_parent->d_name.name, dentry->d_name.name);
+       if (error != 0) {
+               dfprintk(VFS, "NFS: symlink(%s/%ld, %s, %s) error %d\n",
+                       dir->i_sb->s_id, dir->i_ino,
+                       dentry->d_name.name, symname, error);
                d_drop(dentry);
+               __free_page(page);
+               unlock_kernel();
+               return error;
        }
+
+       /*
+        * No big deal if we can't add this page to the page cache here.
+        * READLINK will get the missing page from the server if needed.
+        */
+       pagevec_init(&lru_pvec, 0);
+       if (!add_to_page_cache(page, dentry->d_inode->i_mapping, 0,
+                                                       GFP_KERNEL)) {
+               pagevec_add(&lru_pvec, page);
+               pagevec_lru_add(&lru_pvec);
+               SetPageUptodate(page);
+               unlock_page(page);
+       } else
+               __free_page(page);
+
        unlock_kernel();
-       return error;
+       return 0;
 }
 
 static int 
@@ -1610,14 +1655,15 @@ static int nfs_rename(struct inode *old_dir, struct dentry *old_dentry,
                        goto out;
                }
        } else
-               new_inode->i_nlink--;
+               drop_nlink(new_inode);
 
 go_ahead:
        /*
         * ... prune child dentries and writebacks if needed.
         */
        if (atomic_read(&old_dentry->d_count) > 1) {
-               nfs_wb_all(old_inode);
+               if (S_ISREG(old_inode->i_mode))
+                       nfs_wb_all(old_inode);
                shrink_dcache_parent(old_dentry);
        }
        nfs_inode_return_delegation(old_inode);
@@ -1640,8 +1686,7 @@ out:
        if (rehash)
                d_rehash(rehash);
        if (!error) {
-               if (!S_ISDIR(old_inode->i_mode))
-                       d_move(old_dentry, new_dentry);
+               d_move(old_dentry, new_dentry);
                nfs_renew_times(new_dentry);
                nfs_set_verifier(new_dentry, nfs_save_change_attribute(new_dir));
        }
@@ -1653,35 +1698,211 @@ out:
        return error;
 }
 
+static DEFINE_SPINLOCK(nfs_access_lru_lock);
+static LIST_HEAD(nfs_access_lru_list);
+static atomic_long_t nfs_access_nr_entries;
+
+static void nfs_access_free_entry(struct nfs_access_entry *entry)
+{
+       put_rpccred(entry->cred);
+       kfree(entry);
+       smp_mb__before_atomic_dec();
+       atomic_long_dec(&nfs_access_nr_entries);
+       smp_mb__after_atomic_dec();
+}
+
+int nfs_access_cache_shrinker(int nr_to_scan, gfp_t gfp_mask)
+{
+       LIST_HEAD(head);
+       struct nfs_inode *nfsi;
+       struct nfs_access_entry *cache;
+
+       spin_lock(&nfs_access_lru_lock);
+restart:
+       list_for_each_entry(nfsi, &nfs_access_lru_list, access_cache_inode_lru) {
+               struct inode *inode;
+
+               if (nr_to_scan-- == 0)
+                       break;
+               inode = igrab(&nfsi->vfs_inode);
+               if (inode == NULL)
+                       continue;
+               spin_lock(&inode->i_lock);
+               if (list_empty(&nfsi->access_cache_entry_lru))
+                       goto remove_lru_entry;
+               cache = list_entry(nfsi->access_cache_entry_lru.next,
+                               struct nfs_access_entry, lru);
+               list_move(&cache->lru, &head);
+               rb_erase(&cache->rb_node, &nfsi->access_cache);
+               if (!list_empty(&nfsi->access_cache_entry_lru))
+                       list_move_tail(&nfsi->access_cache_inode_lru,
+                                       &nfs_access_lru_list);
+               else {
+remove_lru_entry:
+                       list_del_init(&nfsi->access_cache_inode_lru);
+                       clear_bit(NFS_INO_ACL_LRU_SET, &nfsi->flags);
+               }
+               spin_unlock(&inode->i_lock);
+               iput(inode);
+               goto restart;
+       }
+       spin_unlock(&nfs_access_lru_lock);
+       while (!list_empty(&head)) {
+               cache = list_entry(head.next, struct nfs_access_entry, lru);
+               list_del(&cache->lru);
+               nfs_access_free_entry(cache);
+       }
+       return (atomic_long_read(&nfs_access_nr_entries) / 100) * sysctl_vfs_cache_pressure;
+}
+
+static void __nfs_access_zap_cache(struct inode *inode)
+{
+       struct nfs_inode *nfsi = NFS_I(inode);
+       struct rb_root *root_node = &nfsi->access_cache;
+       struct rb_node *n, *dispose = NULL;
+       struct nfs_access_entry *entry;
+
+       /* Unhook entries from the cache */
+       while ((n = rb_first(root_node)) != NULL) {
+               entry = rb_entry(n, struct nfs_access_entry, rb_node);
+               rb_erase(n, root_node);
+               list_del(&entry->lru);
+               n->rb_left = dispose;
+               dispose = n;
+       }
+       nfsi->cache_validity &= ~NFS_INO_INVALID_ACCESS;
+       spin_unlock(&inode->i_lock);
+
+       /* Now kill them all! */
+       while (dispose != NULL) {
+               n = dispose;
+               dispose = n->rb_left;
+               nfs_access_free_entry(rb_entry(n, struct nfs_access_entry, rb_node));
+       }
+}
+
+void nfs_access_zap_cache(struct inode *inode)
+{
+       /* Remove from global LRU init */
+       if (test_and_clear_bit(NFS_INO_ACL_LRU_SET, &NFS_FLAGS(inode))) {
+               spin_lock(&nfs_access_lru_lock);
+               list_del_init(&NFS_I(inode)->access_cache_inode_lru);
+               spin_unlock(&nfs_access_lru_lock);
+       }
+
+       spin_lock(&inode->i_lock);
+       /* This will release the spinlock */
+       __nfs_access_zap_cache(inode);
+}
+
+static struct nfs_access_entry *nfs_access_search_rbtree(struct inode *inode, struct rpc_cred *cred)
+{
+       struct rb_node *n = NFS_I(inode)->access_cache.rb_node;
+       struct nfs_access_entry *entry;
+
+       while (n != NULL) {
+               entry = rb_entry(n, struct nfs_access_entry, rb_node);
+
+               if (cred < entry->cred)
+                       n = n->rb_left;
+               else if (cred > entry->cred)
+                       n = n->rb_right;
+               else
+                       return entry;
+       }
+       return NULL;
+}
+
 int nfs_access_get_cached(struct inode *inode, struct rpc_cred *cred, struct nfs_access_entry *res)
 {
        struct nfs_inode *nfsi = NFS_I(inode);
-       struct nfs_access_entry *cache = &nfsi->cache_access;
+       struct nfs_access_entry *cache;
+       int err = -ENOENT;
 
-       if (cache->cred != cred
-                       || time_after(jiffies, cache->jiffies + NFS_ATTRTIMEO(inode))
-                       || (nfsi->cache_validity & NFS_INO_INVALID_ACCESS))
-               return -ENOENT;
-       memcpy(res, cache, sizeof(*res));
-       return 0;
+       spin_lock(&inode->i_lock);
+       if (nfsi->cache_validity & NFS_INO_INVALID_ACCESS)
+               goto out_zap;
+       cache = nfs_access_search_rbtree(inode, cred);
+       if (cache == NULL)
+               goto out;
+       if (time_after(jiffies, cache->jiffies + NFS_ATTRTIMEO(inode)))
+               goto out_stale;
+       res->jiffies = cache->jiffies;
+       res->cred = cache->cred;
+       res->mask = cache->mask;
+       list_move_tail(&cache->lru, &nfsi->access_cache_entry_lru);
+       err = 0;
+out:
+       spin_unlock(&inode->i_lock);
+       return err;
+out_stale:
+       rb_erase(&cache->rb_node, &nfsi->access_cache);
+       list_del(&cache->lru);
+       spin_unlock(&inode->i_lock);
+       nfs_access_free_entry(cache);
+       return -ENOENT;
+out_zap:
+       /* This will release the spinlock */
+       __nfs_access_zap_cache(inode);
+       return -ENOENT;
 }
 
-void nfs_access_add_cache(struct inode *inode, struct nfs_access_entry *set)
+static void nfs_access_add_rbtree(struct inode *inode, struct nfs_access_entry *set)
 {
        struct nfs_inode *nfsi = NFS_I(inode);
-       struct nfs_access_entry *cache = &nfsi->cache_access;
+       struct rb_root *root_node = &nfsi->access_cache;
+       struct rb_node **p = &root_node->rb_node;
+       struct rb_node *parent = NULL;
+       struct nfs_access_entry *entry;
 
-       if (cache->cred != set->cred) {
-               if (cache->cred)
-                       put_rpccred(cache->cred);
-               cache->cred = get_rpccred(set->cred);
-       }
-       /* FIXME: replace current access_cache BKL reliance with inode->i_lock */
        spin_lock(&inode->i_lock);
-       nfsi->cache_validity &= ~NFS_INO_INVALID_ACCESS;
+       while (*p != NULL) {
+               parent = *p;
+               entry = rb_entry(parent, struct nfs_access_entry, rb_node);
+
+               if (set->cred < entry->cred)
+                       p = &parent->rb_left;
+               else if (set->cred > entry->cred)
+                       p = &parent->rb_right;
+               else
+                       goto found;
+       }
+       rb_link_node(&set->rb_node, parent, p);
+       rb_insert_color(&set->rb_node, root_node);
+       list_add_tail(&set->lru, &nfsi->access_cache_entry_lru);
+       spin_unlock(&inode->i_lock);
+       return;
+found:
+       rb_replace_node(parent, &set->rb_node, root_node);
+       list_add_tail(&set->lru, &nfsi->access_cache_entry_lru);
+       list_del(&entry->lru);
        spin_unlock(&inode->i_lock);
+       nfs_access_free_entry(entry);
+}
+
+void nfs_access_add_cache(struct inode *inode, struct nfs_access_entry *set)
+{
+       struct nfs_access_entry *cache = kmalloc(sizeof(*cache), GFP_KERNEL);
+       if (cache == NULL)
+               return;
+       RB_CLEAR_NODE(&cache->rb_node);
        cache->jiffies = set->jiffies;
+       cache->cred = get_rpccred(set->cred);
        cache->mask = set->mask;
+
+       nfs_access_add_rbtree(inode, cache);
+
+       /* Update accounting */
+       smp_mb__before_atomic_inc();
+       atomic_long_inc(&nfs_access_nr_entries);
+       smp_mb__after_atomic_inc();
+
+       /* Add inode to global LRU list */
+       if (!test_and_set_bit(NFS_INO_ACL_LRU_SET, &NFS_FLAGS(inode))) {
+               spin_lock(&nfs_access_lru_lock);
+               list_add_tail(&NFS_I(inode)->access_cache_inode_lru, &nfs_access_lru_list);
+               spin_unlock(&nfs_access_lru_lock);
+       }
 }
 
 static int nfs_do_access(struct inode *inode, struct rpc_cred *cred, int mask)