]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - fs/nfs/dir.c
Merge rsync://rsync.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6
[linux-2.6-omap-h63xx.git] / fs / nfs / dir.c
index a23f3489416709288655f80603337f91ea94e398..e7ffb4deb3e5f21973a0e165f229ddc98c7ff754 100644 (file)
@@ -128,15 +128,14 @@ struct inode_operations nfs4_dir_inode_operations = {
 static int
 nfs_opendir(struct inode *inode, struct file *filp)
 {
-       int res = 0;
+       int res;
 
        dfprintk(VFS, "NFS: opendir(%s/%ld)\n",
                        inode->i_sb->s_id, inode->i_ino);
 
        lock_kernel();
        /* Call generic open code in order to cache credentials */
-       if (!res)
-               res = nfs_open(inode, filp);
+       res = nfs_open(inode, filp);
        unlock_kernel();
        return res;
 }
@@ -529,7 +528,7 @@ static int nfs_readdir(struct file *filp, void *dirent, filldir_t filldir)
 
        lock_kernel();
 
-       res = nfs_revalidate_inode(NFS_SERVER(inode), inode);
+       res = nfs_revalidate_mapping(inode, filp->f_mapping);
        if (res < 0) {
                unlock_kernel();
                return res;
@@ -691,7 +690,9 @@ int nfs_lookup_verify_inode(struct inode *inode, struct nameidata *nd)
                        goto out_force;
                /* This is an open(2) */
                if (nfs_lookup_check_intent(nd, LOOKUP_OPEN) != 0 &&
-                               !(server->flags & NFS_MOUNT_NOCTO))
+                               !(server->flags & NFS_MOUNT_NOCTO) &&
+                               (S_ISREG(inode->i_mode) ||
+                                S_ISDIR(inode->i_mode)))
                        goto out_force;
        }
        return nfs_revalidate_inode(server, inode);
@@ -869,6 +870,17 @@ int nfs_is_exclusive_create(struct inode *dir, struct nameidata *nd)
        return (nd->intent.open.flags & O_EXCL) != 0;
 }
 
+static inline int nfs_reval_fsid(struct inode *dir,
+               struct nfs_fh *fh, struct nfs_fattr *fattr)
+{
+       struct nfs_server *server = NFS_SERVER(dir);
+
+       if (!nfs_fsid_equal(&server->fsid, &fattr->fsid))
+               /* Revalidate fsid on root dir */
+               return __nfs_revalidate_inode(server, dir->i_sb->s_root->d_inode);
+       return 0;
+}
+
 static struct dentry *nfs_lookup(struct inode *dir, struct dentry * dentry, struct nameidata *nd)
 {
        struct dentry *res;
@@ -901,6 +913,11 @@ static struct dentry *nfs_lookup(struct inode *dir, struct dentry * dentry, stru
                res = ERR_PTR(error);
                goto out_unlock;
        }
+       error = nfs_reval_fsid(dir, &fhandle, &fattr);
+       if (error < 0) {
+               res = ERR_PTR(error);
+               goto out_unlock;
+       }
        inode = nfs_fhget(dentry->d_sb, &fhandle, &fattr);
        res = (struct dentry *)inode;
        if (IS_ERR(res))