fs: cifs: Fix atime update check vs mtime
authorDeepa Dinamani <deepa.kernel@gmail.com>
Sat, 30 Nov 2019 05:30:25 +0000 (21:30 -0800)
committerSteve French <stfrench@microsoft.com>
Mon, 2 Dec 2019 21:15:35 +0000 (15:15 -0600)
According to the comment in the code and commit log, some apps
expect atime >= mtime; but the introduced code results in
atime==mtime.  Fix the comparison to guard against atime<mtime.

Fixes: 9b9c5bea0b96 ("cifs: do not return atime less than mtime")
Signed-off-by: Deepa Dinamani <deepa.kernel@gmail.com>
Cc: stfrench@microsoft.com
Cc: linux-cifs@vger.kernel.org
Signed-off-by: Steve French <stfrench@microsoft.com>
fs/cifs/inode.c

index 8a76195e8a695afef04edb915db7a74d26636eae..ca76a9287456f3b6a1a0f085f7ec9c34fa6134b9 100644 (file)
@@ -163,7 +163,7 @@ cifs_fattr_to_inode(struct inode *inode, struct cifs_fattr *fattr)
 
        spin_lock(&inode->i_lock);
        /* we do not want atime to be less than mtime, it broke some apps */
-       if (timespec64_compare(&fattr->cf_atime, &fattr->cf_mtime))
+       if (timespec64_compare(&fattr->cf_atime, &fattr->cf_mtime) < 0)
                inode->i_atime = fattr->cf_mtime;
        else
                inode->i_atime = fattr->cf_atime;