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

From: Andreas Gruenbacher
Date: Mon Jul 03 2023 - 16:32:58 EST


Li Dong,

On Tue, Jun 20, 2023 at 5:47 AM Li Dong <lidong@xxxxxxxx> wrote:
> Function gfs2_freeze_func causes a deadlock,because sd_freeze_mutex was
> not released when return
>
> Signed-off-by: Li Dong <lidong@xxxxxxxx>
> ---
> 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