projects/linux·commit 01fe654f

fs: cifs: Fix atime update check

01fe654f · Zizhi Wo <[email protected]> · 2023-12-13 10:23:53 +08:00

Commit 9b9c5bea0b96 ("cifs: do not return atime less than mtime") indicates
that in cifs, if atime is less than mtime, some apps will break.
Therefore, it introduce a function to compare this two variables in two
places where atime is updated. If atime is less than mtime, update it to
mtime.

However, the patch was handled incorrectly, resulting in atime and mtime
being exactly equal. A previous commit 69738cfdfa70 ("fs: cifs: Fix atime
update check vs mtime") fixed one place and forgot to fix another. Fix it.

Fixes: 9b9c5bea0b96 ("cifs: do not return atime less than mtime")
Cc: [email protected]
Signed-off-by: Zizhi Wo <[email protected]>
Signed-off-by: Steve French <[email protected]>
Commit
01fe654f78fd1ea4df046ef76b07ba92a35f8dbe
Parents
567320c4

Changes

1 files changed · +1 −1

FileStatusAddDelContent
fs/smb/client/file.cmodified+1−1View file

fs/smb/client/file.c

View file
diff --git a/fs/smb/client/file.c b/fs/smb/client/file.c
index cf17e3d..32a8525 100644
--- a/fs/smb/client/file.c
+++ b/fs/smb/client/file.c
@@ -4671,7 +4671,7 @@ static int cifs_readpage_worker(struct file *file, struct page *page,
/* we do not want atime to be less than mtime, it broke some apps */
atime = inode_set_atime_to_ts(inode, current_time(inode));
mtime = inode_get_mtime(inode);
- if (timespec64_compare(&atime, &mtime))
+ if (timespec64_compare(&atime, &mtime) < 0)
inode_set_atime_to_ts(inode, inode_get_mtime(inode));
if (PAGE_SIZE > rc)