Skip to content

Commit 15fa5df

Browse files
z00467499gregkh
authored andcommitted
cifs: update ctime and mtime during truncate
[ Upstream commit 5618303 ] 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>
1 parent 9c732cc commit 15fa5df

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

fs/cifs/inode.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2270,6 +2270,15 @@ cifs_set_file_size(struct inode *inode, struct iattr *attrs,
22702270
if (rc == 0) {
22712271
cifsInode->server_eof = attrs->ia_size;
22722272
cifs_setsize(inode, attrs->ia_size);
2273+
2274+
/*
2275+
* The man page of truncate says if the size changed,
2276+
* then the st_ctime and st_mtime fields for the file
2277+
* are updated.
2278+
*/
2279+
attrs->ia_ctime = attrs->ia_mtime = current_time(inode);
2280+
attrs->ia_valid |= ATTR_CTIME | ATTR_MTIME;
2281+
22732282
cifs_truncate_page(inode->i_mapping, inode->i_size);
22742283
}
22752284

0 commit comments

Comments
 (0)