* [PATCH v2] ceph: ignore the truncate when size won't change with Fx caps ssued
@ 2021-10-08 8:23 xiubli
2021-10-08 10:42 ` Jeff Layton
0 siblings, 1 reply; 2+ messages in thread
From: xiubli @ 2021-10-08 8:23 UTC (permalink / raw)
To: jlayton; +Cc: idryomov, pdonnell, ceph-devel, Xiubo Li
From: Xiubo Li <xiubli@redhat.com>
If the new size is the same with current size, the MDS will do nothing
except changing the mtime/atime. The posix doesn't mandate that the
filesystems must update them. So just ignore it.
Signed-off-by: Xiubo Li <xiubli@redhat.com>
---
fs/ceph/inode.c | 14 ++++++++------
1 file changed, 8 insertions(+), 6 deletions(-)
diff --git a/fs/ceph/inode.c b/fs/ceph/inode.c
index 23b5a0867e3a..81a7b342fae7 100644
--- a/fs/ceph/inode.c
+++ b/fs/ceph/inode.c
@@ -2105,12 +2105,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);
--
2.27.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH v2] ceph: ignore the truncate when size won't change with Fx caps ssued
2021-10-08 8:23 [PATCH v2] ceph: ignore the truncate when size won't change with Fx caps ssued xiubli
@ 2021-10-08 10:42 ` Jeff Layton
0 siblings, 0 replies; 2+ messages in thread
From: Jeff Layton @ 2021-10-08 10:42 UTC (permalink / raw)
To: xiubli; +Cc: idryomov, pdonnell, ceph-devel
On Fri, 2021-10-08 at 16:23 +0800, xiubli@redhat.com wrote:
> From: Xiubo Li <xiubli@redhat.com>
>
> If the new size is the same with current size, the MDS will do nothing
> except changing the mtime/atime. The posix doesn't mandate that the
> filesystems must update them. So just ignore it.
>
> Signed-off-by: Xiubo Li <xiubli@redhat.com>
> ---
> fs/ceph/inode.c | 14 ++++++++------
> 1 file changed, 8 insertions(+), 6 deletions(-)
>
> diff --git a/fs/ceph/inode.c b/fs/ceph/inode.c
> index 23b5a0867e3a..81a7b342fae7 100644
> --- a/fs/ceph/inode.c
> +++ b/fs/ceph/inode.c
> @@ -2105,12 +2105,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);
Thanks Xiubo, looks good. Merged into testing.
--
Jeff Layton <jlayton@kernel.org>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-10-08 10:42 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-08 8:23 [PATCH v2] ceph: ignore the truncate when size won't change with Fx caps ssued xiubli
2021-10-08 10:42 ` Jeff Layton
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.