diff options
author | Zhang Xiaoxu <zhangxiaoxu5@huawei.com> | 2020-06-19 22:51:29 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2020-07-16 08:17:23 +0200 |
commit | 38bcc785c2eb67b22caca3ec4ac7ce08bcc65326 (patch) | |
tree | 21793dc2ced026518728f55eb06cce08ee7dd42d | |
parent | 7e7f71be56c563d82d0a1f9cb099c1c76a70a30d (diff) |
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>
-rw-r--r-- | fs/cifs/inode.c | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/fs/cifs/inode.c b/fs/cifs/inode.c index 44fb9ae6d105..1d951936b092 100644 --- a/fs/cifs/inode.c +++ b/fs/cifs/inode.c @@ -2225,6 +2225,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); } |