linux-block.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] virtio_pmem: do flush synchronously
@ 2023-06-20  3:28 Hou Tao
  2023-06-21 12:13 ` Christoph Hellwig
  0 siblings, 1 reply; 20+ messages in thread
From: Hou Tao @ 2023-06-20  3:28 UTC (permalink / raw)
  To: Dan Williams, Jens Axboe
  Cc: linux-block, nvdimm, virtualization, Pankaj Gupta,
	Christoph Hellwig, houtao1

From: Hou Tao <houtao1@huawei.com>

The following warning was reported when doing fsync on a pmem device:

 ------------[ cut here ]------------
 WARNING: CPU: 2 PID: 384 at block/blk-core.c:751 submit_bio_noacct+0x340/0x520
 Modules linked in:
 CPU: 2 PID: 384 Comm: mkfs.xfs Not tainted 6.4.0-rc7+ #154
 Hardware name: QEMU Standard PC (i440FX + PIIX, 1996)
 RIP: 0010:submit_bio_noacct+0x340/0x520
 ......
 Call Trace:
  <TASK>
  ? asm_exc_invalid_op+0x1b/0x20
  ? submit_bio_noacct+0x340/0x520
  ? submit_bio_noacct+0xd5/0x520
  submit_bio+0x37/0x60
  async_pmem_flush+0x79/0xa0
  nvdimm_flush+0x17/0x40
  pmem_submit_bio+0x370/0x390
  __submit_bio+0xbc/0x190
  submit_bio_noacct_nocheck+0x14d/0x370
  submit_bio_noacct+0x1ef/0x520
  submit_bio+0x55/0x60
  submit_bio_wait+0x5a/0xc0
  blkdev_issue_flush+0x44/0x60

The root cause is that submit_bio_noacct() needs bio_op() is either
WRITE or ZONE_APPEND for flush bio and async_pmem_flush() doesn't assign
REQ_OP_WRITE when allocating flush bio.

The reason for allocating a new flush bio is to execute the flush
command asynchrously and doesn't want to block the original submit_bio()
invocation. However the original submit_bio() will be blocked anyway,
because the nested submit_bio() for the flush bio just places the flush
bio in current->bio_list and the original submit_bio() only returns
after submitting all bio in bio_list.

So just removing the allocation of new flush bio and do synchronous
flush directly.

Fixes: b4a6bb3a67aa ("block: add a sanity check for non-write flush/fua bios")
Signed-off-by: Hou Tao <houtao1@huawei.com>
---
Hi Jens & Dan,

I found Pankaj was working on the optimization of virtio-pmem flush bio
[0], but considering the last status update was 1/12/2022, so could you
please pick the patch up for v6.7 and we can do the flush optimization
later ?

[0]: https://lore.kernel.org/lkml/20220111161937.56272-1-pankaj.gupta.linux@gmail.com/T/

 drivers/nvdimm/nd_virtio.c | 16 ----------------
 1 file changed, 16 deletions(-)

diff --git a/drivers/nvdimm/nd_virtio.c b/drivers/nvdimm/nd_virtio.c
index c6a648fd8744..a7d510f446e0 100644
--- a/drivers/nvdimm/nd_virtio.c
+++ b/drivers/nvdimm/nd_virtio.c
@@ -100,22 +100,6 @@ 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_PREFLUSH,
-					      GFP_ATOMIC);
-
-		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))
 		return -EIO;
 
-- 
2.29.2


^ permalink raw reply related	[flat|nested] 20+ messages in thread

end of thread, other threads:[~2023-08-07 17:55 UTC | newest]

Thread overview: 20+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-06-20  3:28 [PATCH] virtio_pmem: do flush synchronously Hou Tao
2023-06-21 12:13 ` Christoph Hellwig
2023-06-21 13:43   ` [PATCH v2] virtio_pmem: add the missing REQ_OP_WRITE for flush bio Hou Tao
2023-06-21 13:15     ` Christoph Hellwig
2023-06-25  2:26       ` [PATCH v3] " Hou Tao
2023-06-26  7:53         ` Christoph Hellwig
2023-06-26  8:40         ` Chaitanya Kulkarni
2023-07-13  8:17           ` Pankaj Gupta
2023-06-27  9:03         ` Pankaj Gupta
2023-07-13  8:23           ` Pankaj Gupta
2023-07-13 13:06             ` Hou Tao
2023-07-13 13:54             ` [PATCH v4] " Hou Tao
2023-08-04 18:39               ` Pankaj Gupta
2023-08-04 21:03                 ` Verma, Vishal L
2023-08-06 15:10                   ` Michael S. Tsirkin
2023-08-07 16:42                   ` Dave Jiang
2023-08-07 17:55                     ` Pankaj Gupta
2023-06-22  8:35     ` [PATCH v2] " Pankaj Gupta
2023-06-30  2:25       ` Hou Tao
2023-06-30  4:45         ` Pankaj Gupta

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).