summaryrefslogtreecommitdiff
path: root/fs
diff options
context:
space:
mode:
authorZhang Xiaoxu <zhangxiaoxu5@huawei.com>2020-06-20 05:51:29 +0300
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2020-07-22 10:22:16 +0300
commit34a71f641f0b6ff78c3a3b58238958566af0cfe2 (patch)
tree82b59611b38eafe533ee4934e35890893fbcfc71 /fs
parent7038f9eb426c820422cc3f56f26001a3f4f6e1bc (diff)
downloadlinux-34a71f641f0b6ff78c3a3b58238958566af0cfe2.tar.xz
cifs: update ctime and mtime during truncate
[ Upstream commit 5618303d8516f8ac5ecfe53ee8e8bc9a40eaf066 ] As the man description of the truncate, if the size changed, then the st_ctime and st_mtime fields should be updated. But in cifs, we doesn't do it. It lead the xfstests generic/313 failed. So, add the ATTR_MTIME|ATTR_CTIME flags on attrs when change the file size Reported-by: Hulk Robot <hulkci@huawei.com> Signed-off-by: Zhang Xiaoxu <zhangxiaoxu5@huawei.com> Signed-off-by: Steve French <stfrench@microsoft.com> Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'fs')
-rw-r--r--fs/cifs/inode.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/fs/cifs/inode.c b/fs/cifs/inode.c
index 528fe225b65a..d0d295a28b6e 100644
--- a/fs/cifs/inode.c
+++ b/fs/cifs/inode.c
@@ -2216,6 +2216,15 @@ set_size_out:
if (rc == 0) {
cifsInode->server_eof = attrs->ia_size;
cifs_setsize(inode, attrs->ia_size);
+
+ /*
+ * The man page of truncate says if the size changed,
+ * then the st_ctime and st_mtime fields for the file
+ * are updated.
+ */
+ attrs->ia_ctime = attrs->ia_mtime = current_time(inode);
+ attrs->ia_valid |= ATTR_CTIME | ATTR_MTIME;
+
cifs_truncate_page(inode->i_mapping, inode->i_size);
}