The Linux Kernel Mailing List
 help / color / mirror / Atom feed
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] fs/ceph/dir: __{dir,dentry}_lease_check() returns an enum
Date: Thu,  9 Jul 2026 12:41:21 +0200	[thread overview]
Message-ID: <20260709104121.884183-1-max.kellermann@ionos.com> (raw)

The declaration of these return valued (KEEP, DELETE, TOUCH, STOP) and
their use in __dentry_leases_walk() suggests that these are bit flags,
but there is only ever one bit set.  Converting these to a
non-anonymous enum expresses the intent more clearly.

Signed-off-by: Max Kellermann <max.kellermann@ionos.com>
---
 fs/ceph/dir.c | 33 ++++++++++++++++++---------------
 1 file changed, 18 insertions(+), 15 deletions(-)

diff --git a/fs/ceph/dir.c b/fs/ceph/dir.c
index 27ce9e55e947..6b1891289ff9 100644
--- a/fs/ceph/dir.c
+++ b/fs/ceph/dir.c
@@ -1626,11 +1626,14 @@ static void __dentry_lease_unlist(struct ceph_dentry_info *di)
 	spin_unlock(&mdsc->dentry_list_lock);
 }
 
-enum {
-	KEEP	= 0,
-	DELETE	= 1,
-	TOUCH	= 2,
-	STOP	= 4,
+/**
+ * Result of __dir_lease_check() and __dentry_lease_check().
+ */
+enum lease_check_result {
+	KEEP,
+	DELETE,
+	TOUCH,
+	STOP,
 };
 
 struct ceph_lease_walk_control {
@@ -1640,8 +1643,8 @@ struct ceph_lease_walk_control {
 	unsigned long dir_lease_ttl;
 };
 
-static int __dir_lease_check(const struct dentry *, struct ceph_lease_walk_control *);
-static int __dentry_lease_check(const struct dentry *);
+static enum lease_check_result __dir_lease_check(const struct dentry *, struct ceph_lease_walk_control *);
+static enum lease_check_result __dentry_lease_check(const struct dentry *);
 
 static unsigned long
 __dentry_leases_walk(struct ceph_mds_client *mdsc,
@@ -1652,11 +1655,12 @@ __dentry_leases_walk(struct ceph_mds_client *mdsc,
 	struct list_head* list;
         LIST_HEAD(dispose);
 	unsigned long freed = 0;
-	int ret = 0;
 
 	list = lwc->dir_lease ? &mdsc->dentry_dir_leases : &mdsc->dentry_leases;
 	spin_lock(&mdsc->dentry_list_lock);
 	list_for_each_entry_safe(di, tmp, list, lease_list) {
+		enum lease_check_result ret = KEEP;
+
 		if (!lwc->nr_to_scan)
 			break;
 		--lwc->nr_to_scan;
@@ -1677,13 +1681,12 @@ __dentry_leases_walk(struct ceph_mds_client *mdsc,
 			ret = __dir_lease_check(dentry, lwc);
 		else
 			ret = __dentry_lease_check(dentry);
-		if (ret & TOUCH) {
+		if (ret == TOUCH) {
 			/* move it into tail of dir lease list */
 			__dentry_dir_lease_touch(mdsc, di);
 			if (!last)
 				last = dentry;
-		}
-		if (ret & DELETE) {
+		} else if (ret == DELETE) {
 			/* stale lease */
 			di->flags &= ~CEPH_DENTRY_REFERENCED;
 			if (dentry->d_lockref.count > 0) {
@@ -1700,7 +1703,7 @@ __dentry_leases_walk(struct ceph_mds_client *mdsc,
 		}
 next:
 		spin_unlock(&dentry->d_lock);
-		if (ret & STOP)
+		if (ret == STOP)
 			break;
 	}
 	spin_unlock(&mdsc->dentry_list_lock);
@@ -1733,7 +1736,7 @@ __dentry_leases_walk(struct ceph_mds_client *mdsc,
 	return freed;
 }
 
-static int __dentry_lease_check(const struct dentry *dentry)
+static enum lease_check_result __dentry_lease_check(const struct dentry *dentry)
 {
 	struct ceph_dentry_info *di = ceph_dentry(dentry);
 	int ret;
@@ -1748,8 +1751,8 @@ static int __dentry_lease_check(const struct dentry *dentry)
 	return DELETE;
 }
 
-static int __dir_lease_check(const struct dentry *dentry,
-			     struct ceph_lease_walk_control *lwc)
+static enum lease_check_result __dir_lease_check(const struct dentry *dentry,
+						 struct ceph_lease_walk_control *lwc)
 {
 	struct ceph_dentry_info *di = ceph_dentry(dentry);
 
-- 
2.47.3


                 reply	other threads:[~2026-07-09 10:41 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20260709104121.884183-1-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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox