]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
afs: Use scoped_seqlock_read() rather than manually doing seqlock stuff
authorDavid Howells <dhowells@redhat.com>
Mon, 22 Jun 2026 09:08:48 +0000 (10:08 +0100)
committerChristian Brauner <brauner@kernel.org>
Wed, 1 Jul 2026 13:26:21 +0000 (15:26 +0200)
This is an addendum to the patch to remove the erroneous seq |= 1 in volume
lookup loop.

Switch to using scoped_seqlock_read() as suggested by Oleg Nesterov[1].

Signed-off-by: David Howells <dhowells@redhat.com>
Link: https://lore.kernel.org/r/aifaeKvz3KemfzaS@redhat.com/
Link: https://patch.msgid.link/20260622090856.2746629-15-dhowells@redhat.com
Reviewed-by: Oleg Nesterov <oleg@redhat.com>
cc: Marc Dionne <marc.dionne@auristor.com>
cc: Li RongQing <lirongqing@baidu.com>
cc: linux-afs@lists.infradead.org
Signed-off-by: Christian Brauner (Amutable) <brauner@kernel.org>
fs/afs/callback.c

index 833ac3178ddc75b92b7a6b743626674e8dbb051b..dd7a407ea36861066d8b47c25c5a9d0a80327f8a 100644 (file)
@@ -113,16 +113,12 @@ static struct afs_volume *afs_lookup_volume_rcu(struct afs_cell *cell,
 {
        struct afs_volume *volume = NULL;
        struct rb_node *p;
-       int seq = 1;
 
-       for (;;) {
+       scoped_seqlock_read(&cell->volume_lock, ss_lock) {
                /* Unfortunately, rbtree walking doesn't give reliable results
                 * under just the RCU read lock, so we have to check for
                 * changes.
                 */
-               seq++; /* 2 on the 1st/lockless path, otherwise odd */
-               read_seqbegin_or_lock(&cell->volume_lock, &seq);
-
                p = rcu_dereference_raw(cell->volumes.rb_node);
                while (p) {
                        volume = rb_entry(p, struct afs_volume, cell_node);
@@ -138,11 +134,8 @@ static struct afs_volume *afs_lookup_volume_rcu(struct afs_cell *cell,
 
                if (volume && afs_try_get_volume(volume, afs_volume_trace_get_callback))
                        break;
-               if (!need_seqretry(&cell->volume_lock, seq))
-                       break;
        }
 
-       done_seqretry(&cell->volume_lock, seq);
        return volume;
 }