mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] ceph: only check the caps of a clean file early after its last close
@ 2026-12-01  0:48 Xiubo Li via B4 Relay
  2026-12-02 12:00 ` Alex Markuze
  0 siblings, 1 reply; 2+ messages in thread
From: Xiubo Li via B4 Relay @ 2026-12-01  0:48 UTC (permalink / raw)
  To: Ilya Dryomov, Alex Markuze, Viacheslav Dubeyko
  Cc: ceph-devel, linux-kernel, Xiubo Li

From: Xiubo Li <xiubo.li@clyso.com>

Commit 2377544a8ffe ("ceph: check the caps of a closed file after
caps_wanted_delay_min") queues every regular file that still holds
exclusive or write caps for a cap check caps_wanted_delay_min after its
last close.

Leave out a file with dirty data or dirty caps.  Its caps get checked
anyway when its writeback completes (ceph_put_wrbuffer_cap_refs()),
which flushes and gives them back in one message, 30-35s after the
write with the default dirty_expire_centisecs.  An earlier check has to
flush them first, a second cap message and a second inode update in the
MDS journal for every such file.

That extra cost hits any workload that writes files and closes them
soon after.  Measured with mdtest on bare metal: 1 MDS, 2 BlueStore OSDs
on NVMe, 4 kernel mounts, 16 processes.  "small files" creates files in
one shared directory and writes 3901 bytes to each, "empty files"
creates empty files, a directory per process.  Medians of 2 runs.  Caps
messages are the ones the MDS handles, journal events the ones it logs,
both per file:

  +-------------+-----------------+--------+-------+
  | workload    |                 | before | after |
  +-------------+-----------------+--------+-------+
  | small files | kops/s          |   6.64 |  7.87 |
  |             | caps msgs/file  |   1.98 |  1.09 |
  |             | journal ev/file |   2.98 |  2.09 |
  | empty files | kops/s          |  10.15 | 10.31 |
  |             | caps msgs/file  |   1.00 |  0.99 |
  |             | journal ev/file |   1.99 |  1.98 |
  +-------------+-----------------+--------+-------+

The early check made writing small files 13% slower (from 7.66 kops/s);
with this it is back to where it was.  Empty files still give their
caps back early.

Checking such files after a fixed delay instead does not help.  With
10s or 20s writing small files is as slow as before (6.65, 6.66), with
30s it is half way (7.36), and from 40s on it is the same as with this
change (7.81, 7.88): by then writeback has given the caps back.

Fixes: 2377544a8ffe ("ceph: check the caps of a closed file after caps_wanted_delay_min")
Signed-off-by: Xiubo Li <xiubo.li@clyso.com>
---
A follow-up to "ceph: check the caps of a closed file after
caps_wanted_delay_min", which is already in the testing branch: v1
also checks the caps of files with dirty data early, which costs the
MDS a second cap message and journal event per file and made writing
many small files 13% slower in mdtest.  This brings it back, see the
numbers in the commit message.

Link to v1 of that patch: https://patch.msgid.link/20261008-ceph-cap-idle-release-v1-1-86e7a8bf36d0@clyso.com
---
 fs/ceph/caps.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/fs/ceph/caps.c b/fs/ceph/caps.c
index cc8748f7e0bd..fe76da4fe69d 100644
--- a/fs/ceph/caps.c
+++ b/fs/ceph/caps.c
@@ -5246,9 +5246,16 @@ void ceph_put_fmode(struct ceph_inode_info *ci, int fmode, int count)
 		 * the exclusive caps from us first when another client
 		 * looks at the file, e.g. stats a file we just created.
 		 * Check again after caps_wanted_delay_min instead.
+		 *
+		 * Only a clean file, though.  One with dirty data gets its
+		 * caps checked anyway when its writeback completes, and
+		 * that check flushes and gives them back in one message.
+		 * Checking it earlier would cost a second cap message and
+		 * a second inode update in the MDS journal.
 		 */
 		if (S_ISREG(ci->netfs.inode.i_mode) &&
-		    (__ceph_caps_issued(ci, NULL) & CEPH_CAP_ANY_WR))
+		    (__ceph_caps_issued(ci, NULL) & CEPH_CAP_ANY_WR) &&
+		    !ci->i_wrbuffer_ref && !__ceph_caps_dirty(ci))
 			__cap_delay_requeue_idle(mdsc, ci);
 	}
 	spin_unlock(&ci->i_ceph_lock);

---
base-commit: 3f90412e989cb381d4bf96260468f5c7b2d08655
change-id: 20261010-ceph-cap-idle-release-clean-only-30aa18a01a3a

Best regards,
--  
Xiubo Li <xiubo.li@clyso.com>



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-12-02 12:00 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-12-01  0:48 [PATCH] ceph: only check the caps of a clean file early after its last close Xiubo Li via B4 Relay
2026-12-02 12:00 ` Alex Markuze

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®