Skip to contentSkip to conversation

fs: gfs2: Check if the return value of rhashtable_walk_start is -EAGAIN

PATCH New [email protected] 3 participants 3 messages Aug 26, 2016 GFS2 file system

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 fs: gfs2: Check if the return value of rhashtable_walk_start is -EAGAIN

From: Gao Feng <[email protected]>

When rhashtable_walk_start returns -EAGAIN, it means the resize event happened but the iterator still could be used. So it should not be treated as an error in gfs2_glock_seq_start.

---
 fs/gfs2/glock.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/gfs2/glock.c +1 -1
index 3a90b2b..732721b 100644
@@ -1818,7 +1818,7 @@ static void *gfs2_glock_seq_start(struct seq_file *seq, loff_t *pos)
 		n = (*pos - gi->last_pos);
 
 	ret = rhashtable_walk_start(&gi->hti);
-	if (ret)
+	if (ret && ret != -EAGAIN)
 		return NULL;
 
 	do {
Signature · 1 line
1.9.1
#1 lore raw

PATCH 1/1 fs: gfs2: Check if the return value of rhashtable_walk_start is -EAGAIN

----- Original Message -----

| From: Gao Feng <[email protected]>
| 
| When rhashtable_walk_start returns -EAGAIN, it means the resize event
| happened but the iterator still could be used. So it should not be
| treated as an error in gfs2_glock_seq_start.
| 
| Signed-off-by: Gao Feng <[email protected]>
| ---
|  fs/gfs2/glock.c | 2 +-
|  1 file changed, 1 insertion(+), 1 deletion(-)
| 
| diff --git a/fs/gfs2/glock.c b/fs/gfs2/glock.c
| index 3a90b2b..732721b 100644
| --- a/fs/gfs2/glock.c
| +++ b/fs/gfs2/glock.c
| @@ -1818,7 +1818,7 @@ static void *gfs2_glock_seq_start(struct seq_file *seq,
| loff_t *pos)
|  		n = (*pos - gi->last_pos);
|  
|  	ret = rhashtable_walk_start(&gi->hti);
| -	if (ret)
| +	if (ret && ret != -EAGAIN)
|  		return NULL;
|  
|  	do {
| --
| 1.9.1

Hi Feng Gao,

Thanks for the updated patch, and sorry I haven't gotten back to you. I'm not familiar enough with the rhashtable internals to know whether this makes sense. I think it does, but rhashtable is a complex beast. I've asked a guy who knows rhashtable better. At first he said he patch looked wrong. Later he said it was okay.

Before I apply the patch, I wanted to ask you a question:

What problem are you trying to solve? Are you seeing glocks that are missing from the list in debugfs (or the glocktop tool) due to resize events?

* It seems like if we don't do this patch, glocks might be accidentally not listed during a resize event.

* It seems like if we do this patch, we might get glocks listed twice in debugfs. I suppose it's better to list them twice than not at all, but I don't know of anything besides the "glocktop" tool that would care.

Regards,

Bob Peterson
Red Hat File Systems

#2 lore raw

PATCH 1/1 fs: gfs2: Check if the return value of rhashtable_walk_start is -EAGAIN

Hi Bob,

inline

Quoted 37 lines · Bob Peterson

----- Original Message -----

| From: Gao Feng <[email protected]>
|
| When rhashtable_walk_start returns -EAGAIN, it means the resize event
| happened but the iterator still could be used. So it should not be
| treated as an error in gfs2_glock_seq_start.
|
| Signed-off-by: Gao Feng <[email protected]>
| ---
|  fs/gfs2/glock.c | 2 +-
|  1 file changed, 1 insertion(+), 1 deletion(-)
|
| diff --git a/fs/gfs2/glock.c b/fs/gfs2/glock.c
| index 3a90b2b..732721b 100644
| --- a/fs/gfs2/glock.c
| +++ b/fs/gfs2/glock.c
| @@ -1818,7 +1818,7 @@ static void *gfs2_glock_seq_start(struct seq_file *seq,
| loff_t *pos)
|               n = (*pos - gi->last_pos);
|
|       ret = rhashtable_walk_start(&gi->hti);
| -     if (ret)
| +     if (ret && ret != -EAGAIN)
|               return NULL;
|
|       do {
| --
| 1.9.1

Hi Feng Gao,

Thanks for the updated patch, and sorry I haven't gotten back to you. I'm not familiar enough with the rhashtable internals to know whether this makes sense. I think it does, but rhashtable is a complex beast. I've asked a guy who knows rhashtable better. At first he said he patch looked wrong. Later he said it was okay.

Quoted 5 lines

Before I apply the patch, I wanted to ask you a question:

What problem are you trying to solve? Are you seeing glocks that are missing from the list in debugfs (or the glocktop tool) due to resize events?

No, I did not meet any problem. I just read kernel codes and think this is a bug in GFS2.

Quoted 3 lines

* It seems like if we don't do this patch, glocks might be accidentally not listed during a resize event.

Yes. It might be not list anything during a resize event.

Quoted 4 lines

* It seems like if we do this patch, we might get glocks listed twice in debugfs. I suppose it's better to list them twice than not at all, but I don't know of anything besides the "glocktop" tool that would care.

It is true that list twice according to current logic. But I think it may be avoided by enhancing the glocks codes.
Because I am not familiar with the glocks codes, I just raise one brute solution as an example.

Show all outputs one-time by iterating all nodes in gfs2_glock_seq_show instead of original seq_file's flow "start->next->next->...->stop".
But it may be not good solution for glocks. I just take it as an example.

To summarize, now it should be one bug that glocks does not check the return value of rhashtable_walk_start.

Best Regards
Feng

Quoted 5 lines

Regards,

Bob Peterson
Red Hat File Systems