mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] fs/gfs2:lock a spinlock always before returning from do_xmote()
@ 2020-04-28  3:29 Wu Bo
  2020-04-28  9:56 ` Andreas Gruenbacher
  0 siblings, 1 reply; 2+ messages in thread
From: Wu Bo @ 2020-04-28  3:29 UTC (permalink / raw)
  To: rpeterso, agruenba
  Cc: cluster-devel, linux-kernel, liuzhiqiang26, linfeilong, wubo40

The call stack is as follows:
finish_xmote()
        ...
        spin_lock(&gl->gl_lockref.lock);
        ...
	--> do_xmote()
            spin_unlock(&gl->gl_lockref.lock);
            ...
            return;
        ...
        spin_unlock(&gl->gl_lockref.lock);
           
do_xmote function needs to be locked before returning,
Otherwise, there will be a double release lock in finish_xmote() function.

Signed-off-by: Wu Bo <wubo40@huawei.com>
---
 fs/gfs2/glock.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/fs/gfs2/glock.c b/fs/gfs2/glock.c
index 29f9b66..7129d10 100644
--- a/fs/gfs2/glock.c
+++ b/fs/gfs2/glock.c
@@ -613,6 +613,7 @@ static void do_xmote(struct gfs2_glock *gl, struct gfs2_holder *gh, unsigned int
 				fs_err(sdp, "Error %d syncing glock \n", ret);
 				gfs2_dump_glock(NULL, gl, true);
 			}
+			spin_lock(&gl->gl_lockref.lock);
 			return;
 		}
 	}
-- 
1.8.3.1


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] fs/gfs2:lock a spinlock always before returning from do_xmote()
  2020-04-28  3:29 [PATCH] fs/gfs2:lock a spinlock always before returning from do_xmote() Wu Bo
@ 2020-04-28  9:56 ` Andreas Gruenbacher
  0 siblings, 0 replies; 2+ messages in thread
From: Andreas Gruenbacher @ 2020-04-28  9:56 UTC (permalink / raw)
  To: Wu Bo; +Cc: Bob Peterson, cluster-devel, LKML, liuzhiqiang26, linfeilong

Hi,

On Tue, Apr 28, 2020 at 5:30 AM Wu Bo <wubo40@huawei.com> wrote:
> The call stack is as follows:
> finish_xmote()
>         ...
>         spin_lock(&gl->gl_lockref.lock);
>         ...
>         --> do_xmote()
>             spin_unlock(&gl->gl_lockref.lock);
>             ...
>             return;
>         ...
>         spin_unlock(&gl->gl_lockref.lock);
>
> do_xmote function needs to be locked before returning,
> Otherwise, there will be a double release lock in finish_xmote() function.
>
> Signed-off-by: Wu Bo <wubo40@huawei.com>
> ---
>  fs/gfs2/glock.c | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/fs/gfs2/glock.c b/fs/gfs2/glock.c
> index 29f9b66..7129d10 100644
> --- a/fs/gfs2/glock.c
> +++ b/fs/gfs2/glock.c
> @@ -613,6 +613,7 @@ static void do_xmote(struct gfs2_glock *gl, struct gfs2_holder *gh, unsigned int
>                                 fs_err(sdp, "Error %d syncing glock \n", ret);
>                                 gfs2_dump_glock(NULL, gl, true);
>                         }
> +                       spin_lock(&gl->gl_lockref.lock);
>                         return;
>                 }
>         }
> --
> 1.8.3.1

this patch looks correct. We've independently discovered this bug as
well in the meantime, and we'll send the fix upstream.

Thanks,
Andreas


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-04-28  9:56 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-28  3:29 [PATCH] fs/gfs2:lock a spinlock always before returning from do_xmote() Wu Bo
2020-04-28  9:56 ` Andreas Gruenbacher

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

all inboxes | Powered by JetHome®