Skip to content

Commit

Permalink
cifs: Check uniqueid for SMB2+ and return -ESTALE if necessary
Browse files Browse the repository at this point in the history
Commit 7196ac1 ("Fix to check Unique id and FileType when client
refer file directly.") checks whether the uniqueid of an inode has
changed when getting the inode info, but only when using the UNIX
extensions. Add a similar check for SMB2+, since this can be done
without an extra network roundtrip.

Signed-off-by: Ross Lagerwall <[email protected]>
Signed-off-by: Steve French <[email protected]>
  • Loading branch information
rosslagerwall authored and Steve French committed Jan 14, 2016
1 parent 275516c commit a108471
Showing 1 changed file with 22 additions and 2 deletions.
24 changes: 22 additions & 2 deletions fs/cifs/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -814,8 +814,21 @@ cifs_get_inode_info(struct inode **inode, const char *full_path,
}
} else
fattr.cf_uniqueid = iunique(sb, ROOT_I);
} else
fattr.cf_uniqueid = CIFS_I(*inode)->uniqueid;
} else {
if ((cifs_sb->mnt_cifs_flags & CIFS_MOUNT_SERVER_INUM) &&
validinum == false && server->ops->get_srv_inum) {
/*
* Pass a NULL tcon to ensure we don't make a round
* trip to the server. This only works for SMB2+.
*/
tmprc = server->ops->get_srv_inum(xid,
NULL, cifs_sb, full_path,
&fattr.cf_uniqueid, data);
if (tmprc)
fattr.cf_uniqueid = CIFS_I(*inode)->uniqueid;
} else
fattr.cf_uniqueid = CIFS_I(*inode)->uniqueid;
}

/* query for SFU type info if supported and needed */
if (fattr.cf_cifsattrs & ATTR_SYSTEM &&
Expand Down Expand Up @@ -856,6 +869,13 @@ cifs_get_inode_info(struct inode **inode, const char *full_path,
} else {
/* we already have inode, update it */

/* if uniqueid is different, return error */
if (unlikely(cifs_sb->mnt_cifs_flags & CIFS_MOUNT_SERVER_INUM &&
CIFS_I(*inode)->uniqueid != fattr.cf_uniqueid)) {
rc = -ESTALE;
goto cgii_exit;
}

/* if filetype is different, return error */
if (unlikely(((*inode)->i_mode & S_IFMT) !=
(fattr.cf_mode & S_IFMT))) {
Expand Down

0 comments on commit a108471

Please sign in to comment.