On Sat, 2021-09-25 at 16:51 +0800, xiubli@xxxxxxxxxx wrote: > From: Xiubo Li <xiubli@xxxxxxxxxx> > > If the new size is the same with current size, the MDS will do nothing > except changing the mtime/atime. We can just buffer the truncate in > this case. > > Signed-off-by: Xiubo Li <xiubli@xxxxxxxxxx> > --- > fs/ceph/inode.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/fs/ceph/inode.c b/fs/ceph/inode.c > index 03530793c969..14989b961431 100644 > --- a/fs/ceph/inode.c > +++ b/fs/ceph/inode.c > @@ -2370,7 +2370,7 @@ int __ceph_setattr(struct inode *inode, struct iattr *attr, struct ceph_iattr *c > 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) { > + 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; I wonder if we ought to just ignore the attr->ia_size == isize case altogether instead? Truncating to the same size should be a no-op, so we shouldn't even need to dirty caps or anything. Thoughts? -- Jeff Layton <jlayton@xxxxxxxxxx>