smb3: Do not send SMB3 SET_INFO if nothing changed
authorSteve French <stfrench@microsoft.com>
Fri, 3 Aug 2018 01:28:18 +0000 (20:28 -0500)
committerSteve French <stfrench@microsoft.com>
Tue, 7 Aug 2018 19:30:59 +0000 (14:30 -0500)
An earlier commit had a typo which prevented the
optimization from working:

commit 18dd8e1a65dd ("Do not send SMB3 SET_INFO request if nothing is changing")

Thank you to Metze for noticing this.  Also clear a
reserved field in the FILE_BASIC_INFO struct we send
that should be zero (all the other fields in that
struct were set or cleared explicitly already in
cifs_set_file_info).

Reviewed-by: Pavel Shilovsky <pshilov@microsoft.com>
CC: Stable <stable@vger.kernel.org> # 4.9.x+
Reported-by: Stefan Metzmacher <metze@samba.org>
Signed-off-by: Steve French <stfrench@microsoft.com>
fs/cifs/inode.c
fs/cifs/smb2inode.c

index 054e880c1dac9cc8ab01e753fefd51b36c2e695a..d32eaa4b243767a9c65f0fc19906fdc00e0e4ece 100644 (file)
@@ -1120,6 +1120,8 @@ cifs_set_file_info(struct inode *inode, struct iattr *attrs, unsigned int xid,
        if (!server->ops->set_file_info)
                return -ENOSYS;
 
+       info_buf.Pad = 0;
+
        if (attrs->ia_valid & ATTR_ATIME) {
                set_time = true;
                info_buf.LastAccessTime =
index f22cbc0d1869ee28db90c291498d4e257b743f48..1eef1791d0c4099403d5cb6089e18336a1108b9e 100644 (file)
@@ -283,7 +283,7 @@ smb2_set_file_info(struct inode *inode, const char *full_path,
        int rc;
 
        if ((buf->CreationTime == 0) && (buf->LastAccessTime == 0) &&
-           (buf->LastWriteTime == 0) && (buf->ChangeTime) &&
+           (buf->LastWriteTime == 0) && (buf->ChangeTime == 0) &&
            (buf->Attributes == 0))
                return 0; /* would be a no op, no sense sending this */