nfs: use check_submounts_and_drop()
[platform/adaptation/renesas_rcar/renesas_kernel.git] / fs / nfs / dir.c
index 0fac2cb..7468735 100644 (file)
@@ -450,6 +450,7 @@ void nfs_prime_dcache(struct dentry *parent, struct nfs_entry *entry)
        dentry = d_lookup(parent, &filename);
        if (dentry != NULL) {
                if (nfs_same_file(dentry, entry)) {
+                       nfs_set_verifier(dentry, nfs_save_change_attribute(dir));
                        status = nfs_refresh_inode(dentry->d_inode, entry->fattr);
                        if (!status)
                                nfs_setsecurity(dentry->d_inode, entry->fattr, entry->label);
@@ -817,7 +818,7 @@ static int nfs_readdir(struct file *file, struct dir_context *ctx)
        nfs_readdir_descriptor_t my_desc,
                        *desc = &my_desc;
        struct nfs_open_dir_context *dir_ctx = file->private_data;
-       int res;
+       int res = 0;
 
        dfprintk(FILE, "NFS: readdir(%s/%s) starting at cookie %llu\n",
                        dentry->d_parent->d_name.name, dentry->d_name.name,
@@ -839,7 +840,8 @@ static int nfs_readdir(struct file *file, struct dir_context *ctx)
        desc->plus = nfs_use_readdirplus(inode, ctx) ? 1 : 0;
 
        nfs_block_sillyrename(dentry);
-       res = nfs_revalidate_mapping(inode, file->f_mapping);
+       if (ctx->pos == 0 || nfs_attribute_cache_expired(inode))
+               res = nfs_revalidate_mapping(inode, file->f_mapping);
        if (res < 0)
                goto out;
 
@@ -1133,14 +1135,13 @@ out_zap_parent:
        if (inode && S_ISDIR(inode->i_mode)) {
                /* Purge readdir caches. */
                nfs_zap_caches(inode);
-               /* If we have submounts, don't unhash ! */
-               if (have_submounts(dentry))
-                       goto out_valid;
                if (dentry->d_flags & DCACHE_DISCONNECTED)
                        goto out_valid;
-               shrink_dcache_parent(dentry);
        }
-       d_drop(dentry);
+       /* If we have submounts, don't unhash ! */
+       if (check_submounts_and_drop(dentry) != 0)
+               goto out_valid;
+
        dput(parent);
        dfprintk(LOOKUPCACHE, "NFS: %s(%s/%s) is invalid\n",
                        __func__, dentry->d_parent->d_name.name,