[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20251005145041.GA1266@redhat.com>
Date: Sun, 5 Oct 2025 16:50:41 +0200
From: Oleg Nesterov <oleg@...hat.com>
To: Alexander Viro <viro@...iv.linux.org.uk>,
Boqun Feng <boqun.feng@...il.com>,
David Howells <dhowells@...hat.com>, Ingo Molnar <mingo@...hat.com>,
Li RongQing <lirongqing@...du.com>,
Linus Torvalds <torvalds@...ux-foundation.org>,
Peter Zijlstra <peterz@...radead.org>,
Waiman Long <longman@...hat.com>, Will Deacon <will@...nel.org>
Cc: linux-kernel@...r.kernel.org
Subject: [PATCH 5/5] seqlock: change __dentry_path() to use
__SEQLOCK_READ_SECTION()
To simplify the code and make it more readable.
Signed-off-by: Oleg Nesterov <oleg@...hat.com>
---
fs/d_path.c | 31 +++++++++++++------------------
1 file changed, 13 insertions(+), 18 deletions(-)
diff --git a/fs/d_path.c b/fs/d_path.c
index bb365511066b..0dab1ab1e78d 100644
--- a/fs/d_path.c
+++ b/fs/d_path.c
@@ -332,28 +332,23 @@ static char *__dentry_path(const struct dentry *d, struct prepend_buffer *p)
{
const struct dentry *dentry;
struct prepend_buffer b;
- int seq = 0;
rcu_read_lock();
-restart:
- dentry = d;
- b = *p;
- read_seqbegin_or_lock(&rename_lock, &seq);
- while (!IS_ROOT(dentry)) {
- const struct dentry *parent = dentry->d_parent;
+ __SEQLOCK_READ_SECTION(&rename_lock, lockless, seq, NULL) {
+ dentry = d;
+ b = *p;
+ while (!IS_ROOT(dentry)) {
+ const struct dentry *parent = dentry->d_parent;
- prefetch(parent);
- if (!prepend_name(&b, &dentry->d_name))
- break;
- dentry = parent;
- }
- if (!(seq & 1))
- rcu_read_unlock();
- if (need_seqretry(&rename_lock, seq)) {
- seq = 1;
- goto restart;
+ prefetch(parent);
+ if (!prepend_name(&b, &dentry->d_name))
+ break;
+ dentry = parent;
+ }
+ if (lockless)
+ rcu_read_unlock();
}
- done_seqretry(&rename_lock, seq);
+
if (b.len == p->len)
prepend_char(&b, '/');
return extract_string(&b);
--
2.25.1.362.g51ebf55
Powered by blists - more mailing lists