gfs2 filesystem and dlm development
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Andreas Gruenbacher" <agruenba@redhat.com>, gfs2@lists.linux.dev
Subject: Re: [PATCH] gfs2: wait for bio in gfs2_write_log_header
Date: Thu, 26 Nov 2026 22:55:58 +0000	[thread overview]
Message-ID: <sashiko-outbox-236316@kernel.org> (raw)
In-Reply-To: <20261126224415.3049791-1-agruenba@redhat.com>

Thank you for your contribution! Sashiko AI review found 2 potential
issues to consider:
- [Medium] gfs2: early withdraw returns in gfs2_write_log_header() skip
  log_flush_wait()
- [Low] gfs2: missing Fixes: trailer for commit 4a3d049db42b in commit
  message
--

commit 189e12a17911781cb0db12a8bd02ce7d201fa367
Author: Andreas Gruenbacher <agruenba@redhat.com>

> gfs2: wait for bio in gfs2_write_log_header
>
> During journal recovery, clean_journal() calls gfs2_write_log_header(),
> which allocates a page from gfs2_page_pool, puts that page in a bio, and
> submits the bio.  If a subsequent step in gfs2_fill_super() fails after
> journal replay, or a read-only mount that replayed a journal is
> unmounted (where gfs2_put_super() skips gfs2_make_fs_ro()), the journal
> glock can get dropped before the bio completes.  Also, if the module is
> immediately removed, gfs2_page_pool can get destroyed before the page is
> freed.
>
> This very unlikely race was pointed out by Sashiko.
>
> Fix by moving the call to log_flush_wait() from log_write_header() to
> gfs2_write_log_header().
>
> Signed-off-by: Andreas Gruenbacher <agruenba@redhat.com>

[Severity: Low]
Should this include a Fixes tag for the commit that moved log_flush_wait()
out of gfs2_write_log_header()?

  Fixes: 4a3d049db42b ("gfs2: Don't wait for journal flush in clean_journal")

> diff --git a/fs/gfs2/log.c b/fs/gfs2/log.c
> index 1baaaf30c4fa6..db40045ee2d0a 100644
> --- a/fs/gfs2/log.c
> +++ b/fs/gfs2/log.c
> @@ -908,6 +908,7 @@ void gfs2_write_log_header(struct gfs2_sbd *sdp, struct gfs2_jdesc *jd,
>  	gfs2_log_write(sdp, jd, page, sb->s_blocksize, 0, dblock,
>  		       REQ_OP_WRITE | op_flags);
>  	gfs2_log_submit_write(&jd->jd_log_bio);
> +	log_flush_wait(sdp);
>  }
>  
>  /**
> @@ -935,7 +936,6 @@ static void log_write_header(struct gfs2_sbd *sdp, u32 flags)
>  			      sdp->sd_log_flush_tail, sdp->sd_log_flush_head,
>  			      flags, op_flags);
>  	gfs2_log_incr_head(sdp);
> -	log_flush_wait(sdp);
>  	log_pull_tail(sdp);
>  	gfs2_log_update_head(sdp);
>  }

[Severity: Medium]
Can moving log_flush_wait(sdp) to the bottom of gfs2_write_log_header()
leave transaction payload bios in flight when the filesystem withdraws?

__gfs2_log_flush() submits payload bios through lops_before_commit() and
gfs2_log_submit_write() before calling log_write_header().  If the
filesystem withdraws before gfs2_write_log_header() reaches
gfs2_log_submit_write() (or if gfs2_get_extent() fails there), the early
returns in gfs2_write_log_header() bypass log_flush_wait(sdp):

fs/gfs2/log.c:gfs2_write_log_header() {
	...
	if (gfs2_withdrawn(sdp))
		return;
	...
		ret = gfs2_get_extent(jd->jd_inode, lblock, &dblock, &extlen);
		if (gfs2_assert_withdraw(sdp, ret == 0))
			return;
	...
}

Before 4a3d049db42b ("gfs2: Don't wait for journal flush in
clean_journal"), the gfs2_withdrawn(sdp) check jumped to an out label that
still called log_flush_wait(sdp).  Without that wait, __gfs2_log_flush()
finishes while earlier payload bios are still in flight, allowing unmount
and module removal to free sdp and destroy gfs2_page_pool before
gfs2_end_log_write() runs.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261126224415.3049791-1-agruenba@redhat.com?part=1

      reply	other threads:[~2026-11-26 22:55 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-26 22:44 [PATCH] gfs2: wait for bio in gfs2_write_log_header Andreas Gruenbacher
2026-11-26 22:55 ` sashiko-bot [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=sashiko-outbox-236316@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=agruenba@redhat.com \
    --cc=gfs2@lists.linux.dev \
    --cc=sashiko-reviews@lists.linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox