Before this patch, function gfs2_end_log_write would detect any IO
errors writing to the journal and put out an appropriate message,
but it never set a withdrawing condition. Eventually, the log daemon
would see the error and determine it was time to withdraw, but in
the meantime, other processes could continue running as if nothing
bad ever happened. The biggest consequence is that __gfs2_glock_put
would BUG() when it saw that there were still unwritten items.

This patch sets the WITHDRAWING status as soon as an IO error is
detected, and that way, the BUG will be avoided so the file system
can be properly withdrawn and unmounted.

Signed-off-by: Bob Peterson <rpete...@redhat.com>
---
 fs/gfs2/lops.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/fs/gfs2/lops.c b/fs/gfs2/lops.c
index edff7538d7f2..bfe296be621c 100644
--- a/fs/gfs2/lops.c
+++ b/fs/gfs2/lops.c
@@ -214,6 +214,7 @@ static void gfs2_end_log_write(struct bio *bio)
                if (!cmpxchg(&sdp->sd_log_error, 0, (int)bio->bi_status))
                        fs_err(sdp, "Error %d writing to journal, jid=%u\n",
                               bio->bi_status, sdp->sd_jdesc->jd_jid);
+               set_bit(SDF_WITHDRAWING, &sdp->sd_flags);
                wake_up(&sdp->sd_logd_waitq);
        }
 
-- 
2.21.0

Reply via email to