ceph: add helper function ceph_cap_is_removed()

Having it as a wrapper allows replacing the implementation, which the
next patch will do.

Signed-off-by: Max Kellermann <max.kellermann@ionos.com>
Reviewed-by: Alex Markuze <amarkuze@redhat.com>
Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
This commit is contained in:
Max Kellermann 2026-07-06 09:38:10 +02:00 committed by Ilya Dryomov
parent 6cd69ea0f0
commit 8619a36ff5
3 changed files with 18 additions and 6 deletions

View File

@ -1136,11 +1136,10 @@ 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 */
ci = cap->ci;
if (!ci)
if (ceph_cap_is_removed(cap))
return;
ci = cap->ci;
session = cap->session;
cl = session->s_mdsc->fsc->client;
inode = &ci->netfs.inode;
@ -1212,8 +1211,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;
}

View File

@ -1956,7 +1956,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;

View File

@ -1278,6 +1278,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);