summaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorSteve French <stfrench@microsoft.com>2018-09-22 13:07:06 -0400
committerSteve French <stfrench@microsoft.com>2018-10-23 22:16:05 -0400
commit9b9c5bea0b960616d638711d0ecc270c3a074e7f (patch)
treeae8b0d2c9121e9a368530f6e8d11c4eb0b3dc68d /fs
parent3d621230b8a0c6616f32b86ec3f0bc3ead9eb5b8 (diff)
cifs: do not return atime less than mtime
In network file system it is fairly easy for server and client atime vs. mtime to get confused (and atime updated less frequently) which we noticed broke some apps which expect atime >= mtime Also ignore relatime mount option (rather than error on it) since relatime is basically what some network server fs are doing (relatime). Signed-off-by: Steve French <stfrench@microsoft.com> Reviewed-by: Ronnie Sahlberg <lsahlber@redhat.com>
Diffstat (limited to 'fs')
-rw-r--r--fs/cifs/connect.c1
-rw-r--r--fs/cifs/file.c8
-rw-r--r--fs/cifs/inode.c6
3 files changed, 12 insertions, 3 deletions
diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c
index 1605bf250691..d82f0cc71755 100644
--- a/fs/cifs/connect.c
+++ b/fs/cifs/connect.c
@@ -250,6 +250,7 @@ static const match_table_t cifs_mount_option_tokens = {
250 { Opt_ignore, "dev" }, 250 { Opt_ignore, "dev" },
251 { Opt_ignore, "mand" }, 251 { Opt_ignore, "mand" },
252 { Opt_ignore, "nomand" }, 252 { Opt_ignore, "nomand" },
253 { Opt_ignore, "relatime" },
253 { Opt_ignore, "_netdev" }, 254 { Opt_ignore, "_netdev" },
254 255
255 { Opt_err, NULL } 256 { Opt_err, NULL }
diff --git a/fs/cifs/file.c b/fs/cifs/file.c
index 8d41ca7bfcf1..fa723e7a08d7 100644
--- a/fs/cifs/file.c
+++ b/fs/cifs/file.c
@@ -3889,8 +3889,12 @@ static int cifs_readpage_worker(struct file *file, struct page *page,
3889 else 3889 else
3890 cifs_dbg(FYI, "Bytes read %d\n", rc); 3890 cifs_dbg(FYI, "Bytes read %d\n", rc);
3891 3891
3892 file_inode(file)->i_atime = 3892 /* we do not want atime to be less than mtime, it broke some apps */
3893 current_time(file_inode(file)); 3893 file_inode(file)->i_atime = current_time(file_inode(file));
3894 if (timespec64_compare(&(file_inode(file)->i_atime), &(file_inode(file)->i_mtime)))
3895 file_inode(file)->i_atime = file_inode(file)->i_mtime;
3896 else
3897 file_inode(file)->i_atime = current_time(file_inode(file));
3894 3898
3895 if (PAGE_SIZE > rc) 3899 if (PAGE_SIZE > rc)
3896 memset(read_data + rc, 0, PAGE_SIZE - rc); 3900 memset(read_data + rc, 0, PAGE_SIZE - rc);
diff --git a/fs/cifs/inode.c b/fs/cifs/inode.c
index 6e8765f44508..0945d40030eb 100644
--- a/fs/cifs/inode.c
+++ b/fs/cifs/inode.c
@@ -162,7 +162,11 @@ cifs_fattr_to_inode(struct inode *inode, struct cifs_fattr *fattr)
162 cifs_revalidate_cache(inode, fattr); 162 cifs_revalidate_cache(inode, fattr);
163 163
164 spin_lock(&inode->i_lock); 164 spin_lock(&inode->i_lock);
165 inode->i_atime = fattr->cf_atime; 165 /* we do not want atime to be less than mtime, it broke some apps */
166 if (timespec64_compare(&fattr->cf_atime, &fattr->cf_mtime))
167 inode->i_atime = fattr->cf_mtime;
168 else
169 inode->i_atime = fattr->cf_atime;
166 inode->i_mtime = fattr->cf_mtime; 170 inode->i_mtime = fattr->cf_mtime;
167 inode->i_ctime = fattr->cf_ctime; 171 inode->i_ctime = fattr->cf_ctime;
168 inode->i_rdev = fattr->cf_rdev; 172 inode->i_rdev = fattr->cf_rdev;