2023-06-20 03:59:46

by Li Dong

[permalink] [raw]
Subject: [PATCH] fs: Fix bug in gfs2_freeze_func that can cause deadlock

Function gfs2_freeze_func causes a deadlock,because sd_freeze_mutex was
not released when return

Signed-off-by: Li Dong <[email protected]>
---
fs/gfs2/super.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/fs/gfs2/super.c b/fs/gfs2/super.c
--- a/fs/gfs2/super.c
+++ b/fs/gfs2/super.c
@@ -741,8 +741,10 @@ void gfs2_freeze_func(struct work_struct *work)
set_bit(SDF_FROZEN, &sdp->sd_flags);

error = gfs2_do_thaw(sdp);
- if (error)
+ if (error) {
+ mutex_unlock(&sdp->sd_freeze_mutex);
goto out;
+ }

clear_bit(SDF_FROZEN, &sdp->sd_flags);

--
2.31.1.windows.1



2023-07-03 20:36:42

by Andreas Gruenbacher

[permalink] [raw]
Subject: Re: [PATCH] fs: Fix bug in gfs2_freeze_func that can cause deadlock

Li Dong,

On Tue, Jun 20, 2023 at 5:47 AM Li Dong <[email protected]> wrote:
> Function gfs2_freeze_func causes a deadlock,because sd_freeze_mutex was
> not released when return
>
> Signed-off-by: Li Dong <[email protected]>
> ---
> fs/gfs2/super.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/fs/gfs2/super.c b/fs/gfs2/super.c
> --- a/fs/gfs2/super.c
> +++ b/fs/gfs2/super.c
> @@ -741,8 +741,10 @@ void gfs2_freeze_func(struct work_struct *work)
> set_bit(SDF_FROZEN, &sdp->sd_flags);
>
> error = gfs2_do_thaw(sdp);
> - if (error)
> + if (error) {
> + mutex_unlock(&sdp->sd_freeze_mutex);
> goto out;
> + }

thank you for this bug report. I have chosen to fold this fix into
commit "gfs2: Rework freeze / thaw logic" and clean up
gfs2_freeze_func() a little along the way; see the current for-next
branch.

Thanks,
Andreas

> clear_bit(SDF_FROZEN, &sdp->sd_flags);
>
> --
> 2.31.1.windows.1