We must not call gfs2_consist (which does a file system withdraw) from
the freeze glock's freeze_go_xmote_bh function because the withdraw
will try to use the freeze glock, thus causing a glock recursion error.

This patch changes freeze_go_xmote_bh to call function
gfs2_assert_withdraw_delayed instead of gfs2_consist to avoid recursion.

Signed-off-by: Bob Peterson <rpete...@redhat.com>
---
 fs/gfs2/glops.c | 22 +++++++++++-----------
 1 file changed, 11 insertions(+), 11 deletions(-)

diff --git a/fs/gfs2/glops.c b/fs/gfs2/glops.c
index 54d3fbeb3002..4939308d54f3 100644
--- a/fs/gfs2/glops.c
+++ b/fs/gfs2/glops.c
@@ -604,24 +604,24 @@ static int freeze_go_xmote_bh(struct gfs2_glock *gl)
        struct gfs2_inode *ip = GFS2_I(sdp->sd_jdesc->jd_inode);
        struct gfs2_glock *j_gl = ip->i_gl;
        struct gfs2_log_header_host head;
-       int error;
+       int error = 0;
 
        if (test_bit(SDF_JOURNAL_LIVE, &sdp->sd_flags)) {
                j_gl->gl_ops->go_inval(j_gl, DIO_METADATA);
 
                error = gfs2_find_jhead(sdp->sd_jdesc, &head, false);
-               if (error)
-                       gfs2_consist(sdp);
-               if (!(head.lh_flags & GFS2_LOG_HEAD_UNMOUNT))
-                       gfs2_consist(sdp);
-
-               /*  Initialize some head of the log stuff  */
-               if (!gfs2_withdrawn(sdp)) {
-                       sdp->sd_log_sequence = head.lh_sequence + 1;
-                       gfs2_log_pointers_init(sdp, head.lh_blkno);
+               if (gfs2_assert_withdraw_delayed(sdp, !error))
+                       goto out;
+               if (gfs2_assert_withdraw_delayed(sdp, head.lh_flags &
+                                                GFS2_LOG_HEAD_UNMOUNT)) {
+                       error = -EIO;
+                       goto out;
                }
+               sdp->sd_log_sequence = head.lh_sequence + 1;
+               gfs2_log_pointers_init(sdp, head.lh_blkno);
        }
-       return 0;
+out:
+       return error;
 }
 
 /**

Reply via email to