aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ceph/inode.c
diff options
context:
space:
mode:
authorXiubo Li <xiubli@redhat.com>2021-10-08 16:23:58 +0800
committerIlya Dryomov <idryomov@gmail.com>2021-11-08 03:29:52 +0100
commite90334e89b0c3caa64213ba80fbbc053c7975c66 (patch)
tree013e69cfb2fa4ece069ba0bcc5243cd251085ca1 /fs/ceph/inode.c
parentceph: don't rely on error_string to validate blocklisted session. (diff)
downloadlinux-dev-e90334e89b0c3caa64213ba80fbbc053c7975c66.tar.xz
linux-dev-e90334e89b0c3caa64213ba80fbbc053c7975c66.zip
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 <xiubli@redhat.com> Reviewed-by: Jeff Layton <jlayton@kernel.org> Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
Diffstat (limited to 'fs/ceph/inode.c')
-rw-r--r--fs/ceph/inode.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/fs/ceph/inode.c b/fs/ceph/inode.c
index c22c0676090f..e3322fcb2e8d 100644
--- a/fs/ceph/inode.c
+++ b/fs/ceph/inode.c
@@ -2103,12 +2103,14 @@ int __ceph_setattr(struct inode *inode, struct iattr *attr)
loff_t isize = i_size_read(inode);
dout("setattr %p size %lld -> %lld\n", inode, isize, attr->ia_size);
- if ((issued & CEPH_CAP_FILE_EXCL) && attr->ia_size > isize) {
- i_size_write(inode, attr->ia_size);
- inode->i_blocks = calc_inode_blocks(attr->ia_size);
- ci->i_reported_size = attr->ia_size;
- dirtied |= CEPH_CAP_FILE_EXCL;
- ia_valid |= ATTR_MTIME;
+ if ((issued & CEPH_CAP_FILE_EXCL) && attr->ia_size >= isize) {
+ if (attr->ia_size > isize) {
+ i_size_write(inode, attr->ia_size);
+ inode->i_blocks = calc_inode_blocks(attr->ia_size);
+ ci->i_reported_size = attr->ia_size;
+ dirtied |= CEPH_CAP_FILE_EXCL;
+ ia_valid |= ATTR_MTIME;
+ }
} else if ((issued & CEPH_CAP_FILE_SHARED) == 0 ||
attr->ia_size != isize) {
req->r_args.setattr.size = cpu_to_le64(attr->ia_size);