Skip to contentSkip to conversation

ceph: ignore the truncate when size won't change with Fx caps ssued

PATCH In review [email protected] 2 participants 2 messages Oct 8, 2021 Ceph client

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 ceph: ignore the truncate when size won't change with Fx caps ssued

From: Xiubo Li <[email protected]>

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.

---
 fs/ceph/inode.c | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)
fs/ceph/inode.c +8 -6
index 23b5a0867e3a..81a7b342fae7 100644
@@ -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);
Signature · 1 line
2.27.0
#1 lore raw
Quoted 26 lines · On Fri, 2021-10-08 at 16:23 +0800, [email protected] wrote:

From: Xiubo Li <[email protected]>

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.

---
 fs/ceph/inode.c | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)
fs/ceph/inode.c +1 -6
index 23b5a0867e3a..81a7b342fae7 100644
@@ -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) {

fs/ceph/inode.c int __ceph_setattr(struct inode *inode, struct iattr *attr) · line 2118

Quoted 10 lines
fs/ceph/inode.c +7 -0
+			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.

Signature · 1 line
Jeff Layton <[email protected]>