Skip to content

Commit 4121b43

Browse files
oleg-nesterovdhowells
authored andcommitted
afs: fix the usage of read_seqbegin_or_lock() in afs_lookup_volume_rcu()
David Howells says: (2) afs_lookup_volume_rcu(). There can be a lot of volumes known by a system. A thousand would require a 10-step walk and this is drivable by remote operation, so I think this should probably take a lock on the second pass too. Make the "seq" counter odd on the 2nd pass, otherwise read_seqbegin_or_lock() never takes the lock. Signed-off-by: Oleg Nesterov <[email protected]> Signed-off-by: David Howells <[email protected]> cc: Marc Dionne <[email protected]> cc: [email protected] Link: https://lore.kernel.org/r/[email protected]/
1 parent 2daa640 commit 4121b43

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

fs/afs/callback.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,13 +110,14 @@ static struct afs_volume *afs_lookup_volume_rcu(struct afs_cell *cell,
110110
{
111111
struct afs_volume *volume = NULL;
112112
struct rb_node *p;
113-
int seq = 0;
113+
int seq = 1;
114114

115115
do {
116116
/* Unfortunately, rbtree walking doesn't give reliable results
117117
* under just the RCU read lock, so we have to check for
118118
* changes.
119119
*/
120+
seq++; /* 2 on the 1st/lockless path, otherwise odd */
120121
read_seqbegin_or_lock(&cell->volume_lock, &seq);
121122

122123
p = rcu_dereference_raw(cell->volumes.rb_node);

0 commit comments

Comments
 (0)