From: Max Kellermann <max.kellermann@ionos.com>
To: idryomov@gmail.com, amarkuze@redhat.com,
ceph-devel@vger.kernel.org, linux-kernel@vger.kernel.org
Cc: Max Kellermann <max.kellermann@ionos.com>
Subject: [PATCH v2 2/4] fs/ceph: add helper function ceph_cap_is_removed()
Date: Mon, 6 Jul 2026 09:38:10 +0200 [thread overview]
Message-ID: <20260706073812.3922732-2-max.kellermann@ionos.com> (raw)
In-Reply-To: <20260706073812.3922732-1-max.kellermann@ionos.com>
Having it as a wrapper allows replacing the implementation, which the
next patch will do.
Signed-off-by: Max Kellermann <max.kellermann@ionos.com>
---
fs/ceph/caps.c | 6 ++----
fs/ceph/mds_client.c | 2 +-
fs/ceph/super.h | 14 ++++++++++++++
3 files changed, 17 insertions(+), 5 deletions(-)
diff --git a/fs/ceph/caps.c b/fs/ceph/caps.c
index c1213d72645e..f6f3e817b712 100644
--- a/fs/ceph/caps.c
+++ b/fs/ceph/caps.c
@@ -1128,8 +1128,7 @@ static void __ceph_remove_cap(struct ceph_cap *cap, bool queue_release)
struct ceph_mds_client *mdsc;
int removed = 0;
- /* 'ci' being NULL means the remove have already occurred */
- if (!ci) {
+ if (ceph_cap_is_removed(cap)) {
doutc(cl, "inode is NULL\n");
return;
}
@@ -1201,8 +1200,7 @@ void ceph_remove_cap(struct ceph_mds_client *mdsc, struct ceph_cap *cap,
struct ceph_inode_info *ci = cap->ci;
struct ceph_fs_client *fsc;
- /* 'ci' being NULL means the remove have already occurred */
- if (!ci) {
+ if (ceph_cap_is_removed(cap)) {
doutc(mdsc->fsc->client, "inode is NULL\n");
return;
}
diff --git a/fs/ceph/mds_client.c b/fs/ceph/mds_client.c
index 853bf698b356..019f5e60ff82 100644
--- a/fs/ceph/mds_client.c
+++ b/fs/ceph/mds_client.c
@@ -1902,7 +1902,7 @@ int ceph_iterate_session_caps(struct ceph_mds_session *session,
spin_lock(&session->s_cap_lock);
p = p->next;
- if (!cap->ci) {
+ if (ceph_cap_is_removed(cap)) {
doutc(cl, "finishing cap %p removal\n", cap);
BUG_ON(cap->session != session);
cap->session = NULL;
diff --git a/fs/ceph/super.h b/fs/ceph/super.h
index b878f14ca959..628d153601a5 100644
--- a/fs/ceph/super.h
+++ b/fs/ceph/super.h
@@ -1269,6 +1269,20 @@ extern void ceph_add_cap(struct inode *inode,
unsigned issued, unsigned wanted,
unsigned cap, unsigned seq, u64 realmino, int flags,
struct ceph_cap **new_cap);
+
+/**
+ * Determine whether __ceph_remove_cap() has been called on this #cap
+ * (but the object has not yet been freed because it is protected by
+ * `ceph_mds_session.s_cap_iterator`).
+ *
+ * Caller must lock either `ceph_inode_info.i_ceph_lock` or
+ * `ceph_mds_session.s_cap_lock`.
+ */
+static inline bool ceph_cap_is_removed(const struct ceph_cap *cap)
+{
+ return !cap->ci;
+}
+
extern void ceph_remove_cap(struct ceph_mds_client *mdsc, struct ceph_cap *cap,
bool queue_release);
extern void __ceph_remove_caps(struct ceph_inode_info *ci);
--
2.47.3
next prev parent reply other threads:[~2026-07-06 7:38 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-06 7:38 [PATCH v2 1/4] fs/ceph/caps: make __ceph_remove_cap() static Max Kellermann
2026-07-06 7:38 ` Max Kellermann [this message]
2026-07-06 7:38 ` [PATCH v2 3/4] fs/ceph/caps: mark cap remove with RB_CLEAR_NODE() instead of ci=NULL Max Kellermann
2026-07-06 7:38 ` [PATCH v2 4/4] fs/ceph/cap: pass inode pointer around instead of reloading from RAM Max Kellermann
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260706073812.3922732-2-max.kellermann@ionos.com \
--to=max.kellermann@ionos.com \
--cc=amarkuze@redhat.com \
--cc=ceph-devel@vger.kernel.org \
--cc=idryomov@gmail.com \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.