Skip to content

Commit e90334e

Browse files
lxbszidryomov
authored andcommitted
ceph: ignore the truncate when size won't change with Fx caps issued
If the new size is the same as the current size, the MDS will do nothing but change the mtime/atime. POSIX doesn't mandate that the filesystems must update them in this case, so just ignore it instead. Signed-off-by: Xiubo Li <[email protected]> Reviewed-by: Jeff Layton <[email protected]> Signed-off-by: Ilya Dryomov <[email protected]>
1 parent e1c9788 commit e90334e

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

fs/ceph/inode.c

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2103,12 +2103,14 @@ int __ceph_setattr(struct inode *inode, struct iattr *attr)
21032103
loff_t isize = i_size_read(inode);
21042104

21052105
dout("setattr %p size %lld -> %lld\n", inode, isize, attr->ia_size);
2106-
if ((issued & CEPH_CAP_FILE_EXCL) && attr->ia_size > isize) {
2107-
i_size_write(inode, attr->ia_size);
2108-
inode->i_blocks = calc_inode_blocks(attr->ia_size);
2109-
ci->i_reported_size = attr->ia_size;
2110-
dirtied |= CEPH_CAP_FILE_EXCL;
2111-
ia_valid |= ATTR_MTIME;
2106+
if ((issued & CEPH_CAP_FILE_EXCL) && attr->ia_size >= isize) {
2107+
if (attr->ia_size > isize) {
2108+
i_size_write(inode, attr->ia_size);
2109+
inode->i_blocks = calc_inode_blocks(attr->ia_size);
2110+
ci->i_reported_size = attr->ia_size;
2111+
dirtied |= CEPH_CAP_FILE_EXCL;
2112+
ia_valid |= ATTR_MTIME;
2113+
}
21122114
} else if ((issued & CEPH_CAP_FILE_SHARED) == 0 ||
21132115
attr->ia_size != isize) {
21142116
req->r_args.setattr.size = cpu_to_le64(attr->ia_size);

0 commit comments

Comments
 (0)