Re: Possible bug in smb2_set_file_info

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Good catch (I hate typos!).

Fix attached.  I verified that the optimization does work now.  Should
cut traffic in some cases with default smb3 mounts.


On Thu, Aug 2, 2018 at 11:00 AM Stefan Metzmacher <metze@xxxxxxxxx> wrote:
>
> Hi Steve,
>
> I'm wondering if this patch:
>
> >commit 18dd8e1a65ddae2351d0f0d6dd4a334f441fc5fa
> >Author: Steve French <smfrench@xxxxxxxxx>
> >Date:   Mon Sep 26 14:23:08 2016 -0500
> >
> >    Do not send SMB3 SET_INFO request if nothing is changing
> >
> >    [CIFS] We had cases where we sent a SMB2/SMB3 setinfo request with >all
> >    timestamp (and DOS attribute) fields marked as 0 (ie do not change)
> >    e.g. on chmod or chown.
> >
> >    Signed-off-by: Steve French <steve.french@xxxxxxxxxxxxxxx>
> >    CC: Stable <stable@xxxxxxxxxxxxxxx>
> >---
> > fs/cifs/smb2inode.c | 6 ++++++
> > 1 file changed, 6 insertions(+)
> >
> >diff --git a/fs/cifs/smb2inode.c b/fs/cifs/smb2inode.c
> >index 4f0231e685a92..1238cd3552f9c 100644
> >--- a/fs/cifs/smb2inode.c
> >+++ b/fs/cifs/smb2inode.c
> >@@ -266,9 +266,15 @@ smb2_set_file_info(struct inode *inode, const char
> >*full_path,
> >        struct tcon_link *tlink;
> >        int rc;
> >
> >+       if ((buf->CreationTime == 0) && (buf->LastAccessTime == 0) &&
> >+           (buf->LastWriteTime == 0) && (buf->ChangeTime) &&
> >+           (buf->Attributes == 0))
> >+               return 0; /* would be a no op, no sense sending this */
> >+
>
> Should this contain (buf->ChangeTime == 0) instead of
> (buf->ChangeTime).
>
> Am I missing something?
>
> metze
>


-- 
Thanks,

Steve
From c9ef31c6cebaad59ee7d062d94e8253c718d3bc5 Mon Sep 17 00:00:00 2001
From: Steve French <stfrench@xxxxxxxxxxxxx>
Date: Thu, 2 Aug 2018 20:28:18 -0500
Subject: [PATCH] smb3: Do not send SMB3 SET_INFO if nothing changed

An earlier commit had a typo which prevented the
optimization from working:
     commit 18dd8e1a65ddae2351d0f0d6dd4a334f441fc5fa
Thank you to Metze for noticing this.  Also clear a
reserved field in the FILE_BASIC_INFO struct we send
that should be zero.

CC: Stable <stable@xxxxxxxxxxxxxxx> # 4.9.x+
Reported-by: Stefan Metzmacher <metze@xxxxxxxxx>
Signed-off-by: Steve French <stfrench@xxxxxxxxxxxxx>
---
 fs/cifs/inode.c     | 2 ++
 fs/cifs/smb2inode.c | 2 +-
 2 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/fs/cifs/inode.c b/fs/cifs/inode.c
index 054e880c1dac..d32eaa4b2437 100644
--- a/fs/cifs/inode.c
+++ b/fs/cifs/inode.c
@@ -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 =
diff --git a/fs/cifs/smb2inode.c b/fs/cifs/smb2inode.c
index f22cbc0d1869..1eef1791d0c4 100644
--- a/fs/cifs/smb2inode.c
+++ b/fs/cifs/smb2inode.c
@@ -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 */
 
-- 
2.17.1


[Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux