All of lore.kernel.org
 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; 24+ 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] 24+ messages in thread

* Re: [PATCH] virtio_pmem: do flush synchronously
  2023-06-20  3:28 [PATCH] virtio_pmem: do flush synchronously Hou Tao
@ 2023-06-21 12:13   ` Christoph Hellwig
  0 siblings, 0 replies; 24+ messages in thread
From: Christoph Hellwig @ 2023-06-21 12:13 UTC (permalink / raw)
  To: Hou Tao
  Cc: Dan Williams, Jens Axboe, linux-block, nvdimm, virtualization,
	Pankaj Gupta, Christoph Hellwig, houtao1

I think the proper minimal fix is to pass in a REQ_WRITE in addition to
REQ_PREFLUSH.  We can than have a discussion on the merits of this
weird async pmem flush scheme separately.


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

* Re: [PATCH] virtio_pmem: do flush synchronously
@ 2023-06-21 12:13   ` Christoph Hellwig
  0 siblings, 0 replies; 24+ messages in thread
From: Christoph Hellwig @ 2023-06-21 12:13 UTC (permalink / raw)
  To: Hou Tao
  Cc: Jens Axboe, Pankaj Gupta, nvdimm, houtao1, virtualization,
	linux-block, Christoph Hellwig, Dan Williams

I think the proper minimal fix is to pass in a REQ_WRITE in addition to
REQ_PREFLUSH.  We can than have a discussion on the merits of this
weird async pmem flush scheme separately.

_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization

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

* Re: [PATCH v2] virtio_pmem: add the missing REQ_OP_WRITE for flush bio
  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-22  8:35     ` [PATCH v2] " Pankaj Gupta
  1 sibling, 0 replies; 24+ messages in thread
From: Christoph Hellwig @ 2023-06-21 13:15 UTC (permalink / raw)
  To: Hou Tao
  Cc: Dan Williams, Jens Axboe, Christoph Hellwig, linux-block, nvdimm,
	virtualization, Pankaj Gupta, houtao1

Please avoid the overly long line.  With that fixe this looks good
to me.


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

* Re: [PATCH v2] virtio_pmem: add the missing REQ_OP_WRITE for flush bio
@ 2023-06-21 13:15       ` Christoph Hellwig
  0 siblings, 0 replies; 24+ messages in thread
From: Christoph Hellwig @ 2023-06-21 13:15 UTC (permalink / raw)
  To: Hou Tao
  Cc: Jens Axboe, linux-block, nvdimm, Pankaj Gupta, virtualization,
	Christoph Hellwig, houtao1, Dan Williams

Please avoid the overly long line.  With that fixe this looks good
to me.

_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization

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

* [PATCH v2] virtio_pmem: add the missing REQ_OP_WRITE for flush bio
  2023-06-21 12:13   ` Christoph Hellwig
  (?)
@ 2023-06-21 13:43   ` Hou Tao
  2023-06-21 13:15       ` Christoph Hellwig
  2023-06-22  8:35     ` [PATCH v2] " Pankaj Gupta
  -1 siblings, 2 replies; 24+ messages in thread
From: Hou Tao @ 2023-06-21 13:43 UTC (permalink / raw)
  To: Dan Williams, Jens Axboe, Christoph Hellwig
  Cc: linux-block, nvdimm, virtualization, Pankaj Gupta, 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, so submit_bio_noacct just fail
the flush bio.

Simply fix it by adding the missing REQ_OP_WRITE for flush bio. And we
could fix the flush order issue and do flush optimization later.

Fixes: b4a6bb3a67aa ("block: add a sanity check for non-write flush/fua bios")
Signed-off-by: Hou Tao <houtao1@huawei.com>
---
v2:
  * do a minimal fix first (Suggested by Christoph)
v1: https://lore.kernel.org/linux-block/ZJLpYMC8FgtZ0k2k@infradead.org/T/#t

Hi Jens & Dan,

I found Pankaj was working on the fix and 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.4 and we can do the flush fix
and optimization later ?

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

 drivers/nvdimm/nd_virtio.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/nvdimm/nd_virtio.c b/drivers/nvdimm/nd_virtio.c
index c6a648fd8744..97098099f8a3 100644
--- a/drivers/nvdimm/nd_virtio.c
+++ b/drivers/nvdimm/nd_virtio.c
@@ -105,7 +105,7 @@ int async_pmem_flush(struct nd_region *nd_region, struct bio *bio)
 	 * 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,
+		struct bio *child = bio_alloc(bio->bi_bdev, 0, REQ_OP_WRITE | REQ_PREFLUSH,
 					      GFP_ATOMIC);
 
 		if (!child)
-- 
2.29.2


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

* Re: [PATCH v2] virtio_pmem: add the missing REQ_OP_WRITE for flush bio
  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-22  8:35     ` Pankaj Gupta
  2023-06-30  2:25       ` Hou Tao
  1 sibling, 1 reply; 24+ messages in thread
From: Pankaj Gupta @ 2023-06-22  8:35 UTC (permalink / raw)
  To: Hou Tao
  Cc: Dan Williams, Jens Axboe, Christoph Hellwig, linux-block, nvdimm,
	virtualization, houtao1

> 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, so submit_bio_noacct just fail
> the flush bio.
>
> Simply fix it by adding the missing REQ_OP_WRITE for flush bio. And we
> could fix the flush order issue and do flush optimization later.
>
> Fixes: b4a6bb3a67aa ("block: add a sanity check for non-write flush/fua bios")
> Signed-off-by: Hou Tao <houtao1@huawei.com>
> ---
> v2:
>   * do a minimal fix first (Suggested by Christoph)
> v1: https://lore.kernel.org/linux-block/ZJLpYMC8FgtZ0k2k@infradead.org/T/#t
>
> Hi Jens & Dan,
>
> I found Pankaj was working on the fix and 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.4 and we can do the flush fix
> and optimization later ?
>
> [0]: https://lore.kernel.org/lkml/20220111161937.56272-1-pankaj.gupta.linux@gmail.com/T/
>
>  drivers/nvdimm/nd_virtio.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/nvdimm/nd_virtio.c b/drivers/nvdimm/nd_virtio.c
> index c6a648fd8744..97098099f8a3 100644
> --- a/drivers/nvdimm/nd_virtio.c
> +++ b/drivers/nvdimm/nd_virtio.c
> @@ -105,7 +105,7 @@ int async_pmem_flush(struct nd_region *nd_region, struct bio *bio)
>          * 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,
> +               struct bio *child = bio_alloc(bio->bi_bdev, 0, REQ_OP_WRITE | REQ_PREFLUSH,
>                                               GFP_ATOMIC);
>
>                 if (!child)

Fix looks good to me. Will give a run soon.

Yes, [0] needs to be completed. Curious to know if you guys using
virtio-pmem device?

Thanks,
Pankaj

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

* [PATCH v3] virtio_pmem: add the missing REQ_OP_WRITE for flush bio
  2023-06-21 13:15       ` Christoph Hellwig
  (?)
@ 2023-06-25  2:26       ` Hou Tao
  2023-06-26  7:53           ` Christoph Hellwig
                           ` (2 more replies)
  -1 siblings, 3 replies; 24+ messages in thread
From: Hou Tao @ 2023-06-25  2:26 UTC (permalink / raw)
  To: Dan Williams, Jens Axboe, Christoph Hellwig, Pankaj Gupta
  Cc: linux-block, nvdimm, virtualization, houtao1

From: Hou Tao <houtao1@huawei.com>

When doing mkfs.xfs on a pmem device, the following warning was
reported and :

 ------------[ cut here ]------------
 WARNING: CPU: 2 PID: 384 at block/blk-core.c:751 submit_bio_noacct
 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, so submit_bio_noacct just fail
the flush bio.

Simply fix it by adding the missing REQ_OP_WRITE for flush bio. And we
could fix the flush order issue and do flush optimization later.

Fixes: b4a6bb3a67aa ("block: add a sanity check for non-write flush/fua bios")
Signed-off-by: Hou Tao <houtao1@huawei.com>
---
v3:
 * adjust the overly long lines in both commit message and code

v2: https://lore.kernel.org/linux-block/20230621134340.878461-1-houtao@huaweicloud.com
 * do a minimal fix first (Suggested by Christoph)

v1: https://lore.kernel.org/linux-block/ZJLpYMC8FgtZ0k2k@infradead.org/T/#t

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.4 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 | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/nvdimm/nd_virtio.c b/drivers/nvdimm/nd_virtio.c
index c6a648fd8744..1f8c667c6f1e 100644
--- a/drivers/nvdimm/nd_virtio.c
+++ b/drivers/nvdimm/nd_virtio.c
@@ -105,7 +105,8 @@ int async_pmem_flush(struct nd_region *nd_region, struct bio *bio)
 	 * 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,
+		struct bio *child = bio_alloc(bio->bi_bdev, 0,
+					      REQ_OP_WRITE | REQ_PREFLUSH,
 					      GFP_ATOMIC);
 
 		if (!child)
-- 
2.29.2


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

* Re: [PATCH v3] virtio_pmem: add the missing REQ_OP_WRITE for flush bio
  2023-06-25  2:26       ` [PATCH v3] " Hou Tao
@ 2023-06-26  7:53           ` Christoph Hellwig
  2023-06-26  8:40         ` Chaitanya Kulkarni
  2023-06-27  9:03         ` Pankaj Gupta
  2 siblings, 0 replies; 24+ messages in thread
From: Christoph Hellwig @ 2023-06-26  7:53 UTC (permalink / raw)
  To: Hou Tao
  Cc: Dan Williams, Jens Axboe, Christoph Hellwig, Pankaj Gupta,
	linux-block, nvdimm, virtualization, houtao1

Looks good:

Reviewed-by: Christoph Hellwig <hch@lst.de>

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

* Re: [PATCH v3] virtio_pmem: add the missing REQ_OP_WRITE for flush bio
@ 2023-06-26  7:53           ` Christoph Hellwig
  0 siblings, 0 replies; 24+ messages in thread
From: Christoph Hellwig @ 2023-06-26  7:53 UTC (permalink / raw)
  To: Hou Tao
  Cc: Jens Axboe, nvdimm, Pankaj Gupta, virtualization,
	Christoph Hellwig, linux-block, houtao1, Dan Williams

Looks good:

Reviewed-by: Christoph Hellwig <hch@lst.de>
_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization

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

* Re: [PATCH v3] virtio_pmem: add the missing REQ_OP_WRITE for flush bio
  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
  2 siblings, 1 reply; 24+ messages in thread
From: Chaitanya Kulkarni @ 2023-06-26  8:40 UTC (permalink / raw)
  To: Hou Tao, Dan Williams, Jens Axboe, Christoph Hellwig, Pankaj Gupta
  Cc: linux-block, nvdimm, virtualization, houtao1

On 6/24/2023 7:26 PM, Hou Tao wrote:
> From: Hou Tao <houtao1@huawei.com>
> 
> When doing mkfs.xfs on a pmem device, the following warning was
> reported and :
> 
>   ------------[ cut here ]------------
>   WARNING: CPU: 2 PID: 384 at block/blk-core.c:751 submit_bio_noacct
>   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, so submit_bio_noacct just fail
> the flush bio.
> 
> Simply fix it by adding the missing REQ_OP_WRITE for flush bio. And we
> could fix the flush order issue and do flush optimization later.
> 
> Fixes: b4a6bb3a67aa ("block: add a sanity check for non-write flush/fua bios")
> Signed-off-by: Hou Tao <houtao1@huawei.com>
> ---
> v3:
>   * adjust the overly long lines in both commit message and code
> 
> v2: https://lore.kernel.org/linux-block/20230621134340.878461-1-houtao@huaweicloud.com
>   * do a minimal fix first (Suggested by Christoph)
> 
> v1: https://lore.kernel.org/linux-block/ZJLpYMC8FgtZ0k2k@infradead.org/T/#t
> 
> 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.4 and we can do the flush optimization
> later ?
> 
> [0]: https://lore.kernel.org/lkml/20220111161937.56272-1-pankaj.gupta.linux@gmail.com/T/
> 

I've failed to understand why we should wait for [0] ...

Reviewed-by: Chaitanya Kulkarni <kch@nvidia.com>

-ck



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

* Re: [PATCH v3] virtio_pmem: add the missing REQ_OP_WRITE for flush bio
  2023-06-25  2:26       ` [PATCH v3] " Hou Tao
  2023-06-26  7:53           ` Christoph Hellwig
  2023-06-26  8:40         ` Chaitanya Kulkarni
@ 2023-06-27  9:03         ` Pankaj Gupta
  2023-07-13  8:23           ` Pankaj Gupta
  2 siblings, 1 reply; 24+ messages in thread
From: Pankaj Gupta @ 2023-06-27  9:03 UTC (permalink / raw)
  To: Hou Tao
  Cc: Dan Williams, Jens Axboe, Christoph Hellwig, linux-block, nvdimm,
	virtualization, houtao1

> From: Hou Tao <houtao1@huawei.com>
>
> When doing mkfs.xfs on a pmem device, the following warning was
> reported and :
>
>  ------------[ cut here ]------------
>  WARNING: CPU: 2 PID: 384 at block/blk-core.c:751 submit_bio_noacct
>  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, so submit_bio_noacct just fail
> the flush bio.
>
> Simply fix it by adding the missing REQ_OP_WRITE for flush bio. And we
> could fix the flush order issue and do flush optimization later.
>
> Fixes: b4a6bb3a67aa ("block: add a sanity check for non-write flush/fua bios")
> Signed-off-by: Hou Tao <houtao1@huawei.com>

With 6.3+ stable Cc, Feel free to add:

Reviewed-by: Pankaj Gupta <pankaj.gupta@amd.com>
Tested-by: Pankaj Gupta <pankaj.gupta@amd.com>

Thanks,
Pankaj

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

* Re: [PATCH v2] virtio_pmem: add the missing REQ_OP_WRITE for flush bio
  2023-06-22  8:35     ` [PATCH v2] " Pankaj Gupta
@ 2023-06-30  2:25       ` Hou Tao
  2023-06-30  4:45         ` Pankaj Gupta
  0 siblings, 1 reply; 24+ messages in thread
From: Hou Tao @ 2023-06-30  2:25 UTC (permalink / raw)
  To: Pankaj Gupta
  Cc: Dan Williams, Jens Axboe, Christoph Hellwig, linux-block, nvdimm,
	virtualization, houtao1

Hi Pankaj,

On 6/22/2023 4:35 PM, Pankaj Gupta wrote:
>> 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
SNIP
>> Hi Jens & Dan,
>>
>> I found Pankaj was working on the fix and 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.4 and we can do the flush fix
>> and optimization later ?
>>
>> [0]: https://lore.kernel.org/lkml/20220111161937.56272-1-pankaj.gupta.linux@gmail.com/T/
>>
>>  drivers/nvdimm/nd_virtio.c | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/drivers/nvdimm/nd_virtio.c b/drivers/nvdimm/nd_virtio.c
>> index c6a648fd8744..97098099f8a3 100644
>> --- a/drivers/nvdimm/nd_virtio.c
>> +++ b/drivers/nvdimm/nd_virtio.c
>> @@ -105,7 +105,7 @@ int async_pmem_flush(struct nd_region *nd_region, struct bio *bio)
>>          * 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,
>> +               struct bio *child = bio_alloc(bio->bi_bdev, 0, REQ_OP_WRITE | REQ_PREFLUSH,
>>                                               GFP_ATOMIC);
>>
>>                 if (!child)
> Fix looks good to me. Will give a run soon.
>
> Yes, [0] needs to be completed. Curious to know if you guys using
> virtio-pmem device?
Sorry about missing the question. We are plan to use DAX to do page
cache offload and now we are just do experiment with virtio-pmem and
nd-pmem.

> Thanks,
> Pankaj


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

* Re: [PATCH v2] virtio_pmem: add the missing REQ_OP_WRITE for flush bio
  2023-06-30  2:25       ` Hou Tao
@ 2023-06-30  4:45         ` Pankaj Gupta
  0 siblings, 0 replies; 24+ messages in thread
From: Pankaj Gupta @ 2023-06-30  4:45 UTC (permalink / raw)
  To: Hou Tao
  Cc: Dan Williams, Jens Axboe, Christoph Hellwig, linux-block, nvdimm,
	virtualization, houtao1

> > Yes, [0] needs to be completed. Curious to know if you guys using
> > virtio-pmem device?
> Sorry about missing the question. We are plan to use DAX to do page
> cache offload and now we are just do experiment with virtio-pmem and
> nd-pmem.

Sounds good. Thank you for answering!

Best regards,
Pankaj

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

* Re: [PATCH v3] virtio_pmem: add the missing REQ_OP_WRITE for flush bio
  2023-06-26  8:40         ` Chaitanya Kulkarni
@ 2023-07-13  8:17           ` Pankaj Gupta
  0 siblings, 0 replies; 24+ messages in thread
From: Pankaj Gupta @ 2023-07-13  8:17 UTC (permalink / raw)
  To: Chaitanya Kulkarni
  Cc: Hou Tao, Dan Williams, Jens Axboe, Christoph Hellwig,
	linux-block, nvdimm, virtualization, houtao1, Vishal Verma

> I've failed to understand why we should wait for [0] ...

Sorry, missed to answer before. The optimization was to make the
virtio-pmem interface completely
asynchronous and coalesce the flush requests. As this uses the
asynchronous behavior of virtio bus
there is no stall of guest vCPU, so this optimization intends to solve below:

- Guest IO submitting thread can do other other operations till the
host flush completes.
- As all the guest flush work on one virtio-pmem device. If there is
single flush in queue all the subsequent flush would wait enabling
request coalescing.

Currently, its solved by splitting the bio request to parent & child.
But this results in preorder issue (As PREFLUSH happens after the
first fsync, because of the way how bio_submit() works). I think the
preflush order issue will still remain after this patch. But currently
this interface is broken in mainline. So, this patch fixes the issue.


Thanks,
Pankaj

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

* Re: [PATCH v3] virtio_pmem: add the missing REQ_OP_WRITE for flush bio
  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
  0 siblings, 2 replies; 24+ messages in thread
From: Pankaj Gupta @ 2023-07-13  8:23 UTC (permalink / raw)
  To: Hou Tao
  Cc: Dan Williams, Jens Axboe, Christoph Hellwig, linux-block, nvdimm,
	virtualization, houtao1, Vishal Verma, Chaitanya Kulkarni

+Cc Vishal,

> > Fixes: b4a6bb3a67aa ("block: add a sanity check for non-write flush/fua bios")
> > Signed-off-by: Hou Tao <houtao1@huawei.com>
>
> With 6.3+ stable Cc, Feel free to add:

Hi Dan, Vishal,

Do you have any suggestion on this patch? Or can we queue this please?

Hi Hou,

Could you please send a new version with Cc stable or as per any
suggestions from maintainers.

Thanks,
Pankaj

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

* Re: [PATCH v3] virtio_pmem: add the missing REQ_OP_WRITE for flush bio
  2023-07-13  8:23           ` Pankaj Gupta
@ 2023-07-13 13:06             ` Hou Tao
  2023-07-13 13:54             ` [PATCH v4] " Hou Tao
  1 sibling, 0 replies; 24+ messages in thread
From: Hou Tao @ 2023-07-13 13:06 UTC (permalink / raw)
  To: Pankaj Gupta
  Cc: Dan Williams, Jens Axboe, Christoph Hellwig, linux-block, nvdimm,
	virtualization, houtao1, Vishal Verma, Chaitanya Kulkarni

Hi Pankaj,

On 7/13/2023 4:23 PM, Pankaj Gupta wrote:
> +Cc Vishal,
>
>>> Fixes: b4a6bb3a67aa ("block: add a sanity check for non-write flush/fua bios")
>>> Signed-off-by: Hou Tao <houtao1@huawei.com>
>> With 6.3+ stable Cc, Feel free to add:
> Hi Dan, Vishal,
>
> Do you have any suggestion on this patch? Or can we queue this please?
>
> Hi Hou,
>
> Could you please send a new version with Cc stable or as per any
> suggestions from maintainers.
Will add Cc stable for v6.3 in v4.
>
> Thanks,
> Pankaj
> .


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

* [PATCH v4] virtio_pmem: add the missing REQ_OP_WRITE for flush bio
  2023-07-13  8:23           ` Pankaj Gupta
  2023-07-13 13:06             ` Hou Tao
@ 2023-07-13 13:54             ` Hou Tao
  2023-08-04 18:39               ` Pankaj Gupta
  1 sibling, 1 reply; 24+ messages in thread
From: Hou Tao @ 2023-07-13 13:54 UTC (permalink / raw)
  To: Pankaj Gupta, Dan Williams, Vishal Verma
  Cc: Jens Axboe, Christoph Hellwig, Chaitanya Kulkarni, linux-block,
	nvdimm, virtualization, houtao1

From: Hou Tao <houtao1@huawei.com>

When doing mkfs.xfs on a pmem device, the following warning was
reported:

 ------------[ cut here ]------------
 WARNING: CPU: 2 PID: 384 at block/blk-core.c:751 submit_bio_noacct
 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>
  ? 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, so submit_bio_noacct just fail
the flush bio.

Simply fix it by adding the missing REQ_OP_WRITE for flush bio. And we
could fix the flush order issue and do flush optimization later.

Cc: stable@vger.kernel.org # 6.3+
Fixes: b4a6bb3a67aa ("block: add a sanity check for non-write flush/fua bios")
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Chaitanya Kulkarni <kch@nvidia.com>
Reviewed-by: Pankaj Gupta <pankaj.gupta@amd.com>
Tested-by: Pankaj Gupta <pankaj.gupta@amd.com>
Signed-off-by: Hou Tao <houtao1@huawei.com>
---
v4:
 * add stable Cc
 * collect Rvb and Tested-by tags

v3: https://lore.kernel.org/linux-block/20230625022633.2753877-1-houtao@huaweicloud.com
 * adjust the overly long lines in both commit message and code

v2: https://lore.kernel.org/linux-block/20230621134340.878461-1-houtao@huaweicloud.com
 * do a minimal fix first (Suggested by Christoph)

v1: https://lore.kernel.org/linux-block/ZJLpYMC8FgtZ0k2k@infradead.org/T/#t

 drivers/nvdimm/nd_virtio.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/nvdimm/nd_virtio.c b/drivers/nvdimm/nd_virtio.c
index c6a648fd8744..1f8c667c6f1e 100644
--- a/drivers/nvdimm/nd_virtio.c
+++ b/drivers/nvdimm/nd_virtio.c
@@ -105,7 +105,8 @@ int async_pmem_flush(struct nd_region *nd_region, struct bio *bio)
 	 * 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,
+		struct bio *child = bio_alloc(bio->bi_bdev, 0,
+					      REQ_OP_WRITE | REQ_PREFLUSH,
 					      GFP_ATOMIC);
 
 		if (!child)
-- 
2.29.2


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

* Re: [PATCH v4] virtio_pmem: add the missing REQ_OP_WRITE for flush bio
  2023-07-13 13:54             ` [PATCH v4] " Hou Tao
@ 2023-08-04 18:39               ` Pankaj Gupta
  2023-08-04 21:03                 ` Verma, Vishal L
  0 siblings, 1 reply; 24+ messages in thread
From: Pankaj Gupta @ 2023-08-04 18:39 UTC (permalink / raw)
  To: Hou Tao
  Cc: Dan Williams, Vishal Verma, Jens Axboe, Christoph Hellwig,
	Chaitanya Kulkarni, linux-block, nvdimm, virtualization, houtao1,
	Michael S . Tsirkin, pankaj.gupta

Gentle ping!

Dan, Vishal for suggestion/review on this patch and request for merging.
+Cc Michael for awareness, as virtio-pmem device is currently broken.

Thanks,
Pankaj

> From: Hou Tao <houtao1@huawei.com>
>
> When doing mkfs.xfs on a pmem device, the following warning was
> reported:
>
>  ------------[ cut here ]------------
>  WARNING: CPU: 2 PID: 384 at block/blk-core.c:751 submit_bio_noacct
>  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>
>   ? 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, so submit_bio_noacct just fail
> the flush bio.
>
> Simply fix it by adding the missing REQ_OP_WRITE for flush bio. And we
> could fix the flush order issue and do flush optimization later.
>
> Cc: stable@vger.kernel.org # 6.3+
> Fixes: b4a6bb3a67aa ("block: add a sanity check for non-write flush/fua bios")
> Reviewed-by: Christoph Hellwig <hch@lst.de>
> Reviewed-by: Chaitanya Kulkarni <kch@nvidia.com>
> Reviewed-by: Pankaj Gupta <pankaj.gupta@amd.com>
> Tested-by: Pankaj Gupta <pankaj.gupta@amd.com>
> Signed-off-by: Hou Tao <houtao1@huawei.com>
> ---
> v4:
>  * add stable Cc
>  * collect Rvb and Tested-by tags
>
> v3: https://lore.kernel.org/linux-block/20230625022633.2753877-1-houtao@huaweicloud.com
>  * adjust the overly long lines in both commit message and code
>
> v2: https://lore.kernel.org/linux-block/20230621134340.878461-1-houtao@huaweicloud.com
>  * do a minimal fix first (Suggested by Christoph)
>
> v1: https://lore.kernel.org/linux-block/ZJLpYMC8FgtZ0k2k@infradead.org/T/#t
>
>  drivers/nvdimm/nd_virtio.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/nvdimm/nd_virtio.c b/drivers/nvdimm/nd_virtio.c
> index c6a648fd8744..1f8c667c6f1e 100644
> --- a/drivers/nvdimm/nd_virtio.c
> +++ b/drivers/nvdimm/nd_virtio.c
> @@ -105,7 +105,8 @@ int async_pmem_flush(struct nd_region *nd_region, struct bio *bio)
>          * 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,
> +               struct bio *child = bio_alloc(bio->bi_bdev, 0,
> +                                             REQ_OP_WRITE | REQ_PREFLUSH,
>                                               GFP_ATOMIC);
>
>                 if (!child)
> --
> 2.29.2
>

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

* Re: [PATCH v4] virtio_pmem: add the missing REQ_OP_WRITE for flush bio
  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
  0 siblings, 2 replies; 24+ messages in thread
From: Verma, Vishal L @ 2023-08-04 21:03 UTC (permalink / raw)
  To: Jiang, Dave, pankaj.gupta.linux, houtao
  Cc: houtao1, virtualization, hch, Williams, Dan J, axboe, mst,
	nvdimm, linux-block, pankaj.gupta, kch

On Fri, 2023-08-04 at 20:39 +0200, Pankaj Gupta wrote:
> Gentle ping!
> 
> Dan, Vishal for suggestion/review on this patch and request for merging.
> +Cc Michael for awareness, as virtio-pmem device is currently broken.

Looks good to me,

Reviewed-by: Vishal Verma <vishal.l.verma@intel.com>

Dave, will you queue this for 6.6.

> 
> Thanks,
> Pankaj
> 
> > From: Hou Tao <houtao1@huawei.com>
> > 
> > When doing mkfs.xfs on a pmem device, the following warning was
> > reported:
> > 
> >  ------------[ cut here ]------------
> >  WARNING: CPU: 2 PID: 384 at block/blk-core.c:751 submit_bio_noacct
> >  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>
> >   ? 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, so submit_bio_noacct just fail
> > the flush bio.
> > 
> > Simply fix it by adding the missing REQ_OP_WRITE for flush bio. And we
> > could fix the flush order issue and do flush optimization later.
> > 
> > Cc: stable@vger.kernel.org # 6.3+
> > Fixes: b4a6bb3a67aa ("block: add a sanity check for non-write flush/fua bios")
> > Reviewed-by: Christoph Hellwig <hch@lst.de>
> > Reviewed-by: Chaitanya Kulkarni <kch@nvidia.com>
> > Reviewed-by: Pankaj Gupta <pankaj.gupta@amd.com>
> > Tested-by: Pankaj Gupta <pankaj.gupta@amd.com>
> > Signed-off-by: Hou Tao <houtao1@huawei.com>
> > ---
> > v4:
> >  * add stable Cc
> >  * collect Rvb and Tested-by tags
> > 
> > v3: https://lore.kernel.org/linux-block/20230625022633.2753877-1-houtao@huaweicloud.com
> >  * adjust the overly long lines in both commit message and code
> > 
> > v2: https://lore.kernel.org/linux-block/20230621134340.878461-1-houtao@huaweicloud.com
> >  * do a minimal fix first (Suggested by Christoph)
> > 
> > v1: https://lore.kernel.org/linux-block/ZJLpYMC8FgtZ0k2k@infradead.org/T/#t
> > 
> >  drivers/nvdimm/nd_virtio.c | 3 ++-
> >  1 file changed, 2 insertions(+), 1 deletion(-)
> > 
> > diff --git a/drivers/nvdimm/nd_virtio.c b/drivers/nvdimm/nd_virtio.c
> > index c6a648fd8744..1f8c667c6f1e 100644
> > --- a/drivers/nvdimm/nd_virtio.c
> > +++ b/drivers/nvdimm/nd_virtio.c
> > @@ -105,7 +105,8 @@ int async_pmem_flush(struct nd_region *nd_region, struct bio *bio)
> >          * 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,
> > +               struct bio *child = bio_alloc(bio->bi_bdev, 0,
> > +                                             REQ_OP_WRITE | REQ_PREFLUSH,
> >                                               GFP_ATOMIC);
> > 
> >                 if (!child)
> > --
> > 2.29.2
> > 


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

* Re: [PATCH v4] virtio_pmem: add the missing REQ_OP_WRITE for flush bio
  2023-08-04 21:03                 ` Verma, Vishal L
@ 2023-08-06 15:10                     ` Michael S. Tsirkin
  2023-08-07 16:42                   ` Dave Jiang
  1 sibling, 0 replies; 24+ messages in thread
From: Michael S. Tsirkin @ 2023-08-06 15:10 UTC (permalink / raw)
  To: Verma, Vishal L
  Cc: axboe, pankaj.gupta.linux, Jiang, Dave, houtao, linux-block,
	virtualization, hch, nvdimm, houtao1, pankaj.gupta, Williams,
	Dan J

On Fri, Aug 04, 2023 at 09:03:20PM +0000, Verma, Vishal L wrote:
> On Fri, 2023-08-04 at 20:39 +0200, Pankaj Gupta wrote:
> > Gentle ping!
> > 
> > Dan, Vishal for suggestion/review on this patch and request for merging.
> > +Cc Michael for awareness, as virtio-pmem device is currently broken.
> 
> Looks good to me,
> 
> Reviewed-by: Vishal Verma <vishal.l.verma@intel.com>
> 
> Dave, will you queue this for 6.6.


Generally if you expect me to merge a patch I should be CC'd.


> > 
> > Thanks,
> > Pankaj
> > 
> > > From: Hou Tao <houtao1@huawei.com>
> > > 
> > > When doing mkfs.xfs on a pmem device, the following warning was
> > > reported:
> > > 
> > >  ------------[ cut here ]------------
> > >  WARNING: CPU: 2 PID: 384 at block/blk-core.c:751 submit_bio_noacct
> > >  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>
> > >   ? 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, so submit_bio_noacct just fail
> > > the flush bio.
> > > 
> > > Simply fix it by adding the missing REQ_OP_WRITE for flush bio. And we
> > > could fix the flush order issue and do flush optimization later.
> > > 
> > > Cc: stable@vger.kernel.org # 6.3+
> > > Fixes: b4a6bb3a67aa ("block: add a sanity check for non-write flush/fua bios")
> > > Reviewed-by: Christoph Hellwig <hch@lst.de>
> > > Reviewed-by: Chaitanya Kulkarni <kch@nvidia.com>
> > > Reviewed-by: Pankaj Gupta <pankaj.gupta@amd.com>
> > > Tested-by: Pankaj Gupta <pankaj.gupta@amd.com>
> > > Signed-off-by: Hou Tao <houtao1@huawei.com>
> > > ---
> > > v4:
> > >  * add stable Cc
> > >  * collect Rvb and Tested-by tags
> > > 
> > > v3: https://lore.kernel.org/linux-block/20230625022633.2753877-1-houtao@huaweicloud.com
> > >  * adjust the overly long lines in both commit message and code
> > > 
> > > v2: https://lore.kernel.org/linux-block/20230621134340.878461-1-houtao@huaweicloud.com
> > >  * do a minimal fix first (Suggested by Christoph)
> > > 
> > > v1: https://lore.kernel.org/linux-block/ZJLpYMC8FgtZ0k2k@infradead.org/T/#t
> > > 
> > >  drivers/nvdimm/nd_virtio.c | 3 ++-
> > >  1 file changed, 2 insertions(+), 1 deletion(-)
> > > 
> > > diff --git a/drivers/nvdimm/nd_virtio.c b/drivers/nvdimm/nd_virtio.c
> > > index c6a648fd8744..1f8c667c6f1e 100644
> > > --- a/drivers/nvdimm/nd_virtio.c
> > > +++ b/drivers/nvdimm/nd_virtio.c
> > > @@ -105,7 +105,8 @@ int async_pmem_flush(struct nd_region *nd_region, struct bio *bio)
> > >          * 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,
> > > +               struct bio *child = bio_alloc(bio->bi_bdev, 0,
> > > +                                             REQ_OP_WRITE | REQ_PREFLUSH,
> > >                                               GFP_ATOMIC);
> > > 
> > >                 if (!child)
> > > --
> > > 2.29.2
> > > 
> 

_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization

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

* Re: [PATCH v4] virtio_pmem: add the missing REQ_OP_WRITE for flush bio
@ 2023-08-06 15:10                     ` Michael S. Tsirkin
  0 siblings, 0 replies; 24+ messages in thread
From: Michael S. Tsirkin @ 2023-08-06 15:10 UTC (permalink / raw)
  To: Verma, Vishal L
  Cc: Jiang, Dave, pankaj.gupta.linux, houtao, houtao1, virtualization,
	hch, Williams, Dan J, axboe, nvdimm, linux-block, pankaj.gupta,
	kch

On Fri, Aug 04, 2023 at 09:03:20PM +0000, Verma, Vishal L wrote:
> On Fri, 2023-08-04 at 20:39 +0200, Pankaj Gupta wrote:
> > Gentle ping!
> > 
> > Dan, Vishal for suggestion/review on this patch and request for merging.
> > +Cc Michael for awareness, as virtio-pmem device is currently broken.
> 
> Looks good to me,
> 
> Reviewed-by: Vishal Verma <vishal.l.verma@intel.com>
> 
> Dave, will you queue this for 6.6.


Generally if you expect me to merge a patch I should be CC'd.


> > 
> > Thanks,
> > Pankaj
> > 
> > > From: Hou Tao <houtao1@huawei.com>
> > > 
> > > When doing mkfs.xfs on a pmem device, the following warning was
> > > reported:
> > > 
> > >  ------------[ cut here ]------------
> > >  WARNING: CPU: 2 PID: 384 at block/blk-core.c:751 submit_bio_noacct
> > >  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>
> > >   ? 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, so submit_bio_noacct just fail
> > > the flush bio.
> > > 
> > > Simply fix it by adding the missing REQ_OP_WRITE for flush bio. And we
> > > could fix the flush order issue and do flush optimization later.
> > > 
> > > Cc: stable@vger.kernel.org # 6.3+
> > > Fixes: b4a6bb3a67aa ("block: add a sanity check for non-write flush/fua bios")
> > > Reviewed-by: Christoph Hellwig <hch@lst.de>
> > > Reviewed-by: Chaitanya Kulkarni <kch@nvidia.com>
> > > Reviewed-by: Pankaj Gupta <pankaj.gupta@amd.com>
> > > Tested-by: Pankaj Gupta <pankaj.gupta@amd.com>
> > > Signed-off-by: Hou Tao <houtao1@huawei.com>
> > > ---
> > > v4:
> > >  * add stable Cc
> > >  * collect Rvb and Tested-by tags
> > > 
> > > v3: https://lore.kernel.org/linux-block/20230625022633.2753877-1-houtao@huaweicloud.com
> > >  * adjust the overly long lines in both commit message and code
> > > 
> > > v2: https://lore.kernel.org/linux-block/20230621134340.878461-1-houtao@huaweicloud.com
> > >  * do a minimal fix first (Suggested by Christoph)
> > > 
> > > v1: https://lore.kernel.org/linux-block/ZJLpYMC8FgtZ0k2k@infradead.org/T/#t
> > > 
> > >  drivers/nvdimm/nd_virtio.c | 3 ++-
> > >  1 file changed, 2 insertions(+), 1 deletion(-)
> > > 
> > > diff --git a/drivers/nvdimm/nd_virtio.c b/drivers/nvdimm/nd_virtio.c
> > > index c6a648fd8744..1f8c667c6f1e 100644
> > > --- a/drivers/nvdimm/nd_virtio.c
> > > +++ b/drivers/nvdimm/nd_virtio.c
> > > @@ -105,7 +105,8 @@ int async_pmem_flush(struct nd_region *nd_region, struct bio *bio)
> > >          * 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,
> > > +               struct bio *child = bio_alloc(bio->bi_bdev, 0,
> > > +                                             REQ_OP_WRITE | REQ_PREFLUSH,
> > >                                               GFP_ATOMIC);
> > > 
> > >                 if (!child)
> > > --
> > > 2.29.2
> > > 
> 


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

* Re: [PATCH v4] virtio_pmem: add the missing REQ_OP_WRITE for flush bio
  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
  1 sibling, 1 reply; 24+ messages in thread
From: Dave Jiang @ 2023-08-07 16:42 UTC (permalink / raw)
  To: Verma, Vishal L, pankaj.gupta.linux, houtao
  Cc: houtao1, virtualization, hch, Williams, Dan J, axboe, mst,
	nvdimm, linux-block, pankaj.gupta, kch, mst



On 8/4/23 14:03, Verma, Vishal L wrote:
> On Fri, 2023-08-04 at 20:39 +0200, Pankaj Gupta wrote:
>> Gentle ping!
>>
>> Dan, Vishal for suggestion/review on this patch and request for merging.
>> +Cc Michael for awareness, as virtio-pmem device is currently broken.
> 
> Looks good to me,
> 
> Reviewed-by: Vishal Verma <vishal.l.verma@intel.com>
> 
> Dave, will you queue this for 6.6.

Looks like it's already queued:
https://git.kernel.org/pub/scm/linux/kernel/git/nvdimm/nvdimm.git/commit/?h=libnvdimm-for-next&id=c1dbd8a849183b9c12d257ad3043ecec50db50b3


> 
>>
>> Thanks,
>> Pankaj
>>
>>> From: Hou Tao <houtao1@huawei.com>
>>>
>>> When doing mkfs.xfs on a pmem device, the following warning was
>>> reported:
>>>
>>>   ------------[ cut here ]------------
>>>   WARNING: CPU: 2 PID: 384 at block/blk-core.c:751 submit_bio_noacct
>>>   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>
>>>    ? 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, so submit_bio_noacct just fail
>>> the flush bio.
>>>
>>> Simply fix it by adding the missing REQ_OP_WRITE for flush bio. And we
>>> could fix the flush order issue and do flush optimization later.
>>>
>>> Cc: stable@vger.kernel.org # 6.3+
>>> Fixes: b4a6bb3a67aa ("block: add a sanity check for non-write flush/fua bios")
>>> Reviewed-by: Christoph Hellwig <hch@lst.de>
>>> Reviewed-by: Chaitanya Kulkarni <kch@nvidia.com>
>>> Reviewed-by: Pankaj Gupta <pankaj.gupta@amd.com>
>>> Tested-by: Pankaj Gupta <pankaj.gupta@amd.com>
>>> Signed-off-by: Hou Tao <houtao1@huawei.com>
>>> ---
>>> v4:
>>>   * add stable Cc
>>>   * collect Rvb and Tested-by tags
>>>
>>> v3: https://lore.kernel.org/linux-block/20230625022633.2753877-1-houtao@huaweicloud.com
>>>   * adjust the overly long lines in both commit message and code
>>>
>>> v2: https://lore.kernel.org/linux-block/20230621134340.878461-1-houtao@huaweicloud.com
>>>   * do a minimal fix first (Suggested by Christoph)
>>>
>>> v1: https://lore.kernel.org/linux-block/ZJLpYMC8FgtZ0k2k@infradead.org/T/#t
>>>
>>>   drivers/nvdimm/nd_virtio.c | 3 ++-
>>>   1 file changed, 2 insertions(+), 1 deletion(-)
>>>
>>> diff --git a/drivers/nvdimm/nd_virtio.c b/drivers/nvdimm/nd_virtio.c
>>> index c6a648fd8744..1f8c667c6f1e 100644
>>> --- a/drivers/nvdimm/nd_virtio.c
>>> +++ b/drivers/nvdimm/nd_virtio.c
>>> @@ -105,7 +105,8 @@ int async_pmem_flush(struct nd_region *nd_region, struct bio *bio)
>>>           * 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,
>>> +               struct bio *child = bio_alloc(bio->bi_bdev, 0,
>>> +                                             REQ_OP_WRITE | REQ_PREFLUSH,
>>>                                                GFP_ATOMIC);
>>>
>>>                  if (!child)
>>> --
>>> 2.29.2
>>>
> 

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

* Re: [PATCH v4] virtio_pmem: add the missing REQ_OP_WRITE for flush bio
  2023-08-07 16:42                   ` Dave Jiang
@ 2023-08-07 17:55                     ` Pankaj Gupta
  0 siblings, 0 replies; 24+ messages in thread
From: Pankaj Gupta @ 2023-08-07 17:55 UTC (permalink / raw)
  To: Dave Jiang
  Cc: Verma, Vishal L, houtao, houtao1, virtualization, hch, Williams,
	Dan J, axboe, mst, nvdimm, linux-block, pankaj.gupta, kch

> >> Gentle ping!
> >>
> >> Dan, Vishal for suggestion/review on this patch and request for merging.
> >> +Cc Michael for awareness, as virtio-pmem device is currently broken.
> >
> > Looks good to me,
> >
> > Reviewed-by: Vishal Verma <vishal.l.verma@intel.com>
> >
> > Dave, will you queue this for 6.6.
>
> Looks like it's already queued:
> https://git.kernel.org/pub/scm/linux/kernel/git/nvdimm/nvdimm.git/commit/?h=libnvdimm-for-next&id=c1dbd8a849183b9c12d257ad3043ecec50db50b3

Thank you, Dave!

Best regards,
Pankaj

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

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

Thread overview: 24+ 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 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-21 13:15       ` Christoph Hellwig
2023-06-25  2:26       ` [PATCH v3] " Hou Tao
2023-06-26  7:53         ` Christoph Hellwig
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-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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.