Skip to content

Commit 7e10cc2

Browse files
author
Trond Myklebust
committed
NFS: Don't refresh attributes with mounted-on-file information
If we've been given the attributes of the mounted-on-file, then do not use those to check or update the attributes on the application-visible inode. Signed-off-by: Trond Myklebust <[email protected]>
1 parent d1abaeb commit 7e10cc2

File tree

1 file changed

+19
-14
lines changed

1 file changed

+19
-14
lines changed

fs/nfs/inode.c

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1403,12 +1403,21 @@ static int nfs_check_inode_attributes(struct inode *inode, struct nfs_fattr *fat
14031403
if (NFS_PROTO(inode)->have_delegation(inode, FMODE_READ))
14041404
return 0;
14051405

1406+
/* No fileid? Just exit */
1407+
if (!(fattr->valid & NFS_ATTR_FATTR_FILEID))
1408+
return 0;
14061409
/* Has the inode gone and changed behind our back? */
1407-
if ((fattr->valid & NFS_ATTR_FATTR_FILEID) && nfsi->fileid != fattr->fileid)
1410+
if (nfsi->fileid != fattr->fileid) {
1411+
/* Is this perhaps the mounted-on fileid? */
1412+
if ((fattr->valid & NFS_ATTR_FATTR_MOUNTED_ON_FILEID) &&
1413+
nfsi->fileid == fattr->mounted_on_fileid)
1414+
return 0;
14081415
return -ESTALE;
1416+
}
14091417
if ((fattr->valid & NFS_ATTR_FATTR_TYPE) && (inode->i_mode & S_IFMT) != (fattr->mode & S_IFMT))
14101418
return -ESTALE;
14111419

1420+
14121421
if (!nfs_file_has_buffered_writers(nfsi)) {
14131422
/* Verify a few of the more important attributes */
14141423
if ((fattr->valid & NFS_ATTR_FATTR_CHANGE) != 0 && !inode_eq_iversion_raw(inode, fattr->change_attr))
@@ -1768,18 +1777,6 @@ int nfs_post_op_update_inode_force_wcc(struct inode *inode, struct nfs_fattr *fa
17681777
EXPORT_SYMBOL_GPL(nfs_post_op_update_inode_force_wcc);
17691778

17701779

1771-
static inline bool nfs_fileid_valid(struct nfs_inode *nfsi,
1772-
struct nfs_fattr *fattr)
1773-
{
1774-
bool ret1 = true, ret2 = true;
1775-
1776-
if (fattr->valid & NFS_ATTR_FATTR_FILEID)
1777-
ret1 = (nfsi->fileid == fattr->fileid);
1778-
if (fattr->valid & NFS_ATTR_FATTR_MOUNTED_ON_FILEID)
1779-
ret2 = (nfsi->fileid == fattr->mounted_on_fileid);
1780-
return ret1 || ret2;
1781-
}
1782-
17831780
/*
17841781
* Many nfs protocol calls return the new file attributes after
17851782
* an operation. Here we update the inode to reflect the state
@@ -1810,7 +1807,15 @@ static int nfs_update_inode(struct inode *inode, struct nfs_fattr *fattr)
18101807
nfs_display_fhandle_hash(NFS_FH(inode)),
18111808
atomic_read(&inode->i_count), fattr->valid);
18121809

1813-
if (!nfs_fileid_valid(nfsi, fattr)) {
1810+
/* No fileid? Just exit */
1811+
if (!(fattr->valid & NFS_ATTR_FATTR_FILEID))
1812+
return 0;
1813+
/* Has the inode gone and changed behind our back? */
1814+
if (nfsi->fileid != fattr->fileid) {
1815+
/* Is this perhaps the mounted-on fileid? */
1816+
if ((fattr->valid & NFS_ATTR_FATTR_MOUNTED_ON_FILEID) &&
1817+
nfsi->fileid == fattr->mounted_on_fileid)
1818+
return 0;
18141819
printk(KERN_ERR "NFS: server %s error: fileid changed\n"
18151820
"fsid %s: expected fileid 0x%Lx, got 0x%Lx\n",
18161821
NFS_SERVER(inode)->nfs_client->cl_hostname,

0 commit comments

Comments
 (0)