linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Christoph Hellwig <hch@lst.de>
To: Ming Lei <ming.lei@redhat.com>
Cc: Christoph Hellwig <hch@lst.de>, Brian Foster <bfoster@redhat.com>,
	"Darrick J. Wong" <djwong@kernel.org>,
	Dave Chinner <dchinner@redhat.com>,
	linux-block@vger.kernel.org, linux-fsdevel@vger.kernel.org
Subject: Re: iomap: writeback ioend/bio allocation deadlock risk
Date: Mon, 24 May 2021 17:32:47 +0200	[thread overview]
Message-ID: <20210524153247.GA6041@lst.de> (raw)
In-Reply-To: <YKd1VS5gkzQRn+7x@T590>

On Fri, May 21, 2021 at 04:54:45PM +0800, Ming Lei wrote:
> On Fri, May 21, 2021 at 10:36:35AM +0200, Christoph Hellwig wrote:
> > On Fri, May 21, 2021 at 04:35:03PM +0800, Ming Lei wrote:
> > > Just wondering why the ioend isn't submitted out after it becomes full?
> > 
> > block layer plugging?  Although failing bio allocations will kick that,
> > so that is not a deadlock risk.
> 
> These ioends are just added to one list stored on local stack variable(submit_list),

Yes.  But only until the code finished iterating over a page.  The
worst case number of bios for a page is PAGE_SIZE / SECTOR_SIZE, and
the bio_set is side to handle that comfortably.

> how can block layer plugging observe & submit them out?

It can't.  I was talking about the high-level plug that is held
over multiple pages.  At that point the bios are submitted to the
block layer already, but they might be held in a plug.  And looking at
the bio_alloc_bioset code we don't actually flush a plug at the moment
in that case.  Something like the patch below would do that:

diff --git a/block/bio.c b/block/bio.c
index 44205dfb6b60..5b9d2f4d7c08 100644
--- a/block/bio.c
+++ b/block/bio.c
@@ -432,6 +432,7 @@ struct bio *bio_alloc_bioset(gfp_t gfp_mask, unsigned short nr_iovecs,
 
 	p = mempool_alloc(&bs->bio_pool, gfp_mask);
 	if (!p && gfp_mask != saved_gfp) {
+		blk_schedule_flush_plug(current);
 		punt_bios_to_rescuer(bs);
 		gfp_mask = saved_gfp;
 		p = mempool_alloc(&bs->bio_pool, gfp_mask);

  reply	other threads:[~2021-05-24 15:34 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-21  3:27 iomap: writeback ioend/bio allocation deadlock risk Ming Lei
2021-05-21  7:17 ` Christoph Hellwig
2021-05-21  7:31   ` Ming Lei
2021-05-21  7:35     ` Christoph Hellwig
2021-05-21  8:35       ` Ming Lei
2021-05-21  8:36         ` Christoph Hellwig
2021-05-21  8:54           ` Ming Lei
2021-05-24 15:32             ` Christoph Hellwig [this message]
2021-05-24 23:55             ` Dave Chinner
2021-05-25  4:54               ` Ming Lei
2021-05-25  6:28                 ` Ming Lei
2021-05-25  8:21                   ` Dave Chinner

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=20210524153247.GA6041@lst.de \
    --to=hch@lst.de \
    --cc=bfoster@redhat.com \
    --cc=dchinner@redhat.com \
    --cc=djwong@kernel.org \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=ming.lei@redhat.com \
    /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;
as well as URLs for NNTP newsgroup(s).