The Linux Kernel Mailing List
 help / color / mirror / Atom feed
* [PATCH] fs/ceph/dir: __{dir,dentry}_lease_check() returns an enum
@ 2026-07-09 10:41 Max Kellermann
  0 siblings, 0 replies; only message in thread
From: Max Kellermann @ 2026-07-09 10:41 UTC (permalink / raw)
  To: idryomov, amarkuze, ceph-devel, linux-kernel; +Cc: Max Kellermann

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


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2026-07-09 10:41 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-09 10:41 [PATCH] fs/ceph/dir: __{dir,dentry}_lease_check() returns an enum Max Kellermann

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