Linux virtualization list
 help / color / mirror / Atom feed
From: Li Chen <me@linux.beauty>
To: Pankaj Gupta <pankaj.gupta.linux@gmail.com>,
	Dan Williams <dan.j.williams@intel.com>,
	Vishal Verma <vishal.l.verma@intel.com>,
	Dave Jiang <dave.jiang@intel.com>,
	Ira Weiny <ira.weiny@intel.com>,
	Alison Schofield <alison.schofield@intel.com>,
	virtualization@lists.linux.dev, nvdimm@lists.linux.dev
Cc: linux-kernel@vger.kernel.org, Li Chen <me@linux.beauty>
Subject: [PATCH v6 04/12] nvdimm: virtio_pmem: stop allocating child flush bio
Date: Sun, 21 Jun 2026 21:02:35 +0800	[thread overview]
Message-ID: <20260621130246.2973254-5-me@linux.beauty> (raw)
In-Reply-To: <20260621130246.2973254-1-me@linux.beauty>

pmem_submit_bio() passes the parent bio to nvdimm_flush() for
REQ_FUA. For virtio-pmem this makes async_pmem_flush() allocate
and submit a child PREFLUSH bio chained to the parent.

That child allocation is in the block submit path. Making it
blocking with GFP_NOIO can consume the same global bio mempool that
submit_bio() uses, while making it GFP_ATOMIC can fail under
pressure. A forced failure of the child allocation produced:

virtio_pmem: forcing child bio allocation failure for test
Buffer I/O error on dev pmem0, logical block 0, lost sync page write
EXT4-fs (pmem0): I/O error while writing superblock
EXT4-fs (pmem0): mount failed

Avoid the child bio completely. Flush FUA synchronously, like
REQ_PREFLUSH, then complete the parent after the flush. Since no
child bio can be created, async_pmem_flush() now only issues the
virtio flush and preserves negative errno values.

Signed-off-by: Li Chen <me@linux.beauty>
---
Changes in v6:
- Replace the child bio allocation fix with synchronous FUA flushing.

 drivers/nvdimm/nd_virtio.c | 22 ++++------------------
 drivers/nvdimm/pmem.c      |  2 +-
 2 files changed, 5 insertions(+), 19 deletions(-)

diff --git a/drivers/nvdimm/nd_virtio.c b/drivers/nvdimm/nd_virtio.c
index 4176046627beb..4b2e9c47af0f5 100644
--- a/drivers/nvdimm/nd_virtio.c
+++ b/drivers/nvdimm/nd_virtio.c
@@ -110,27 +110,13 @@ static int virtio_pmem_flush(struct nd_region *nd_region)
 /* The asynchronous flush callback function */
 int async_pmem_flush(struct nd_region *nd_region, struct bio *bio)
 {
-	/*
-	 * Create child bio for asynchronous flush and chain with
-	 * parent bio. Otherwise directly call nd_region flush.
-	 */
-	if (bio && bio->bi_iter.bi_sector != -1) {
-		struct bio *child = bio_alloc(bio->bi_bdev, 0,
-					      REQ_OP_WRITE | REQ_PREFLUSH,
-					      GFP_ATOMIC);
+	int err;
 
-		if (!child)
-			return -ENOMEM;
-		bio_clone_blkg_association(child, bio);
-		child->bi_iter.bi_sector = -1;
-		bio_chain(child, bio);
-		submit_bio(child);
-		return 0;
-	}
-	if (virtio_pmem_flush(nd_region))
+	err = virtio_pmem_flush(nd_region);
+	if (err > 0)
 		return -EIO;
 
-	return 0;
+	return err;
 };
 EXPORT_SYMBOL_GPL(async_pmem_flush);
 MODULE_DESCRIPTION("Virtio Persistent Memory Driver");
diff --git a/drivers/nvdimm/pmem.c b/drivers/nvdimm/pmem.c
index 82ee1ddb3a445..058d2739c95a1 100644
--- a/drivers/nvdimm/pmem.c
+++ b/drivers/nvdimm/pmem.c
@@ -242,7 +242,7 @@ static void pmem_submit_bio(struct bio *bio)
 	}
 
 	if ((bio->bi_opf & REQ_FUA) && !bio->bi_status)
-		ret = nvdimm_flush(nd_region, bio);
+		ret = nvdimm_flush(nd_region, NULL);
 
 	if (ret)
 		bio->bi_status = errno_to_blk_status(ret);
-- 
2.52.0

  parent reply	other threads:[~2026-06-21 13:03 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-21 13:02 [PATCH v6 00/12] nvdimm: virtio_pmem: fix request lifetime and converge broken queue failures Li Chen
2026-06-21 13:02 ` [PATCH v6 01/12] nvdimm: preserve flush callback errors Li Chen
2026-06-23  9:46   ` Pankaj Gupta
2026-06-27  8:53     ` Li Chen
2026-06-21 13:02 ` [PATCH v6 02/12] nvdimm: pmem: keep PREFLUSH before data writes Li Chen
2026-06-21 13:02 ` [PATCH v6 03/12] nvdimm: pmem: guard data loop for dataless bios Li Chen
2026-06-21 13:02 ` Li Chen [this message]
2026-06-24 17:22   ` [PATCH v6 04/12] nvdimm: virtio_pmem: stop allocating child flush bio Pankaj Gupta
2026-06-27 12:44     ` Li Chen
2026-06-21 13:02 ` [PATCH v6 05/12] nvdimm: virtio_pmem: use GFP_NOIO for flush requests Li Chen
2026-06-21 13:02 ` [PATCH v6 06/12] nvdimm: virtio_pmem: always wake -ENOSPC waiters Li Chen
2026-06-21 13:02 ` [PATCH v6 07/12] nvdimm: virtio_pmem: use READ_ONCE()/WRITE_ONCE() for wait flags Li Chen
2026-06-23  8:34   ` Pankaj Gupta
2026-06-21 13:02 ` [PATCH v6 08/12] nvdimm: virtio_pmem: refcount requests for token lifetime Li Chen
2026-06-21 13:02 ` [PATCH v6 09/12] nvdimm: virtio_pmem: publish done with release/acquire Li Chen
2026-06-21 13:02 ` [PATCH v6 10/12] nvdimm: virtio_pmem: isolate DMA request buffers Li Chen
2026-06-21 13:02 ` [PATCH v6 11/12] nvdimm: virtio_pmem: converge broken virtqueue to -EIO Li Chen
2026-06-21 13:02 ` [PATCH v6 12/12] nvdimm: virtio_pmem: drain requests in freeze Li Chen

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=20260621130246.2973254-5-me@linux.beauty \
    --to=me@linux.beauty \
    --cc=alison.schofield@intel.com \
    --cc=dan.j.williams@intel.com \
    --cc=dave.jiang@intel.com \
    --cc=ira.weiny@intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=nvdimm@lists.linux.dev \
    --cc=pankaj.gupta.linux@gmail.com \
    --cc=virtualization@lists.linux.dev \
    --cc=vishal.l.verma@intel.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