blob: cf6a096034dd85f0923d107d92067bb793ee3883 [file] [log] [blame]
From b8304092bed366c7b491be0598a7ba53c30cbd57 Mon Sep 17 00:00:00 2001
From: Deepa Dinamani <>
Date: Fri, 29 Nov 2019 21:30:25 -0800
Subject: [PATCH] fs: cifs: Fix atime update check vs mtime
commit 69738cfdfa7032f45d9e7462d24490e61cf163dd upstream.
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 <>
Signed-off-by: Steve French <>
Signed-off-by: Paul Gortmaker <>
diff --git a/fs/cifs/inode.c b/fs/cifs/inode.c
index f2042d1a1cc4..6e974a90e491 100644
--- a/fs/cifs/inode.c
+++ b/fs/cifs/inode.c
@@ -163,7 +163,7 @@ cifs_fattr_to_inode(struct inode *inode, struct cifs_fattr *fattr)
/* 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;
inode->i_atime = fattr->cf_atime;