linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] block: clear iocb->private in blkdev_bio_end_io_async()
@ 2022-02-11  9:01 Stefano Garzarella
  2022-02-21 11:49 ` Stefano Garzarella
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Stefano Garzarella @ 2022-02-11  9:01 UTC (permalink / raw)
  To: Jens Axboe; +Cc: linux-kernel, Pavel Begunkov, linux-block

iocb_bio_iopoll() expects iocb->private to be cleared before
releasing the bio.

We already do this in blkdev_bio_end_io(), but we forgot in the
recently added blkdev_bio_end_io_async().

Fixes: 54a88eb838d3 ("block: add single bio async direct IO helper")
Cc: asml.silence@gmail.com
Signed-off-by: Stefano Garzarella <sgarzare@redhat.com>
---
I haven't seen a failure, I was just reading the code to understand iopoll,
so IIUC we should clean iocb->private in blkdev_bio_end_io_async().

Thanks,
Stefano
---
 block/fops.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/block/fops.c b/block/fops.c
index 4f59e0f5bf30..a18e7fbd97b8 100644
--- a/block/fops.c
+++ b/block/fops.c
@@ -289,6 +289,8 @@ static void blkdev_bio_end_io_async(struct bio *bio)
 	struct kiocb *iocb = dio->iocb;
 	ssize_t ret;
 
+	WRITE_ONCE(iocb->private, NULL);
+
 	if (likely(!bio->bi_status)) {
 		ret = dio->size;
 		iocb->ki_pos += ret;
-- 
2.34.1


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

* Re: [PATCH] block: clear iocb->private in blkdev_bio_end_io_async()
  2022-02-11  9:01 [PATCH] block: clear iocb->private in blkdev_bio_end_io_async() Stefano Garzarella
@ 2022-02-21 11:49 ` Stefano Garzarella
  2022-02-22  1:43 ` Ming Lei
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Stefano Garzarella @ 2022-02-21 11:49 UTC (permalink / raw)
  To: Jens Axboe, Pavel Begunkov; +Cc: kernel list, linux-block

Gentle ping :-)


On Fri, Feb 11, 2022 at 10:01 AM Stefano Garzarella <sgarzare@redhat.com> wrote:
>
> iocb_bio_iopoll() expects iocb->private to be cleared before
> releasing the bio.
>
> We already do this in blkdev_bio_end_io(), but we forgot in the
> recently added blkdev_bio_end_io_async().
>
> Fixes: 54a88eb838d3 ("block: add single bio async direct IO helper")
> Cc: asml.silence@gmail.com
> Signed-off-by: Stefano Garzarella <sgarzare@redhat.com>
> ---
> I haven't seen a failure, I was just reading the code to understand iopoll,
> so IIUC we should clean iocb->private in blkdev_bio_end_io_async().
>
> Thanks,
> Stefano
> ---
>  block/fops.c | 2 ++
>  1 file changed, 2 insertions(+)
>
> diff --git a/block/fops.c b/block/fops.c
> index 4f59e0f5bf30..a18e7fbd97b8 100644
> --- a/block/fops.c
> +++ b/block/fops.c
> @@ -289,6 +289,8 @@ static void blkdev_bio_end_io_async(struct bio *bio)
>         struct kiocb *iocb = dio->iocb;
>         ssize_t ret;
>
> +       WRITE_ONCE(iocb->private, NULL);
> +
>         if (likely(!bio->bi_status)) {
>                 ret = dio->size;
>                 iocb->ki_pos += ret;
> --
> 2.34.1
>


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

* Re: [PATCH] block: clear iocb->private in blkdev_bio_end_io_async()
  2022-02-11  9:01 [PATCH] block: clear iocb->private in blkdev_bio_end_io_async() Stefano Garzarella
  2022-02-21 11:49 ` Stefano Garzarella
@ 2022-02-22  1:43 ` Ming Lei
  2022-02-22  8:21 ` Christoph Hellwig
  2022-02-22 14:00 ` Jens Axboe
  3 siblings, 0 replies; 5+ messages in thread
From: Ming Lei @ 2022-02-22  1:43 UTC (permalink / raw)
  To: Stefano Garzarella; +Cc: Jens Axboe, linux-kernel, Pavel Begunkov, linux-block

On Fri, Feb 11, 2022 at 10:01:36AM +0100, Stefano Garzarella wrote:
> iocb_bio_iopoll() expects iocb->private to be cleared before
> releasing the bio.
> 
> We already do this in blkdev_bio_end_io(), but we forgot in the

But also iomap_dio_bio_end_io().

> recently added blkdev_bio_end_io_async().
> 
> Fixes: 54a88eb838d3 ("block: add single bio async direct IO helper")
> Cc: asml.silence@gmail.com
> Signed-off-by: Stefano Garzarella <sgarzare@redhat.com>
> ---
> I haven't seen a failure, I was just reading the code to understand iopoll,
> so IIUC we should clean iocb->private in blkdev_bio_end_io_async().
> 
> Thanks,
> Stefano
> ---
>  block/fops.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/block/fops.c b/block/fops.c
> index 4f59e0f5bf30..a18e7fbd97b8 100644
> --- a/block/fops.c
> +++ b/block/fops.c
> @@ -289,6 +289,8 @@ static void blkdev_bio_end_io_async(struct bio *bio)
>  	struct kiocb *iocb = dio->iocb;
>  	ssize_t ret;
>  
> +	WRITE_ONCE(iocb->private, NULL);

It might cause race in case of concurrent polling on same queue without
clearing iocb->private, so looks fine:

Reviewed-by: Ming Lei <ming.lei@redhat.com>

Thanks,
Ming


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

* Re: [PATCH] block: clear iocb->private in blkdev_bio_end_io_async()
  2022-02-11  9:01 [PATCH] block: clear iocb->private in blkdev_bio_end_io_async() Stefano Garzarella
  2022-02-21 11:49 ` Stefano Garzarella
  2022-02-22  1:43 ` Ming Lei
@ 2022-02-22  8:21 ` Christoph Hellwig
  2022-02-22 14:00 ` Jens Axboe
  3 siblings, 0 replies; 5+ messages in thread
From: Christoph Hellwig @ 2022-02-22  8:21 UTC (permalink / raw)
  To: Stefano Garzarella; +Cc: Jens Axboe, linux-kernel, Pavel Begunkov, linux-block

Looks good,

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

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

* Re: [PATCH] block: clear iocb->private in blkdev_bio_end_io_async()
  2022-02-11  9:01 [PATCH] block: clear iocb->private in blkdev_bio_end_io_async() Stefano Garzarella
                   ` (2 preceding siblings ...)
  2022-02-22  8:21 ` Christoph Hellwig
@ 2022-02-22 14:00 ` Jens Axboe
  3 siblings, 0 replies; 5+ messages in thread
From: Jens Axboe @ 2022-02-22 14:00 UTC (permalink / raw)
  To: Stefano Garzarella; +Cc: Pavel Begunkov, linux-kernel, linux-block

On Fri, 11 Feb 2022 10:01:36 +0100, Stefano Garzarella wrote:
> iocb_bio_iopoll() expects iocb->private to be cleared before
> releasing the bio.
> 
> We already do this in blkdev_bio_end_io(), but we forgot in the
> recently added blkdev_bio_end_io_async().
> 
> 
> [...]

Applied, thanks!

[1/1] block: clear iocb->private in blkdev_bio_end_io_async()
      commit: bb49c6fa8b845591b317b0d7afea4ae60ec7f3aa

Best regards,
-- 
Jens Axboe



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

end of thread, other threads:[~2022-02-22 14:00 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-11  9:01 [PATCH] block: clear iocb->private in blkdev_bio_end_io_async() Stefano Garzarella
2022-02-21 11:49 ` Stefano Garzarella
2022-02-22  1:43 ` Ming Lei
2022-02-22  8:21 ` Christoph Hellwig
2022-02-22 14:00 ` Jens Axboe

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