linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RFC] iomap: set REQ_NOWAIT according to IOCB_NOWAIT in Direct IO
@ 2020-11-18  7:52 Hao Xu
  2020-11-18 11:11 ` [RFC RESEND] " Hao Xu
  0 siblings, 1 reply; 4+ messages in thread
From: Hao Xu @ 2020-11-18  7:52 UTC (permalink / raw)
  To: Alexander Viro, Christoph Hellwig; +Cc: Darrick J. Wong, linux-fsdevel

Currently, IOCB_NOWAIT is ignored in direct io, REQ_NOWAIT is only set
when IOCB_HIPRI is set. But REQ_NOWAIT should be set as well when
IOCB_NOWAIT is set.

Signed-off-by: Hao Xu <haoxu@linux.alibaba.com>
---

Hi all,
I tested fio io_uring direct read for a file on ext4 filesystem on a
nvme ssd. I found that IOCB_NOWAIT is ignored in iomap layer, which
means REQ_NOWAIT is not set in bio->bi_opf. This makes nowait IO a
normal IO. Since I'm new to iomap and block layer, I sincerely ask
yours opinions in case I misunderstand the code which is very likely
to happen.:)

 fs/block_dev.c       | 3 +++
 fs/iomap/direct-io.c | 3 +++
 2 files changed, 6 insertions(+)

diff --git a/fs/block_dev.c b/fs/block_dev.c
index 9e84b1928b94..b7db3b7e2ba1 100644
--- a/fs/block_dev.c
+++ b/fs/block_dev.c
@@ -424,6 +424,9 @@ static void blkdev_bio_end_io(struct bio *bio)
 		if (!nr_pages) {
 			bool polled = false;
 
+			if ((iocb->ki_flags & IOCB_NOWAIT) && !is_sync)
+				bio->bi_opf |= REQ_NOWAIT;
+
 			if (iocb->ki_flags & IOCB_HIPRI) {
 				bio_set_polled(bio, iocb);
 				polled = true;
diff --git a/fs/iomap/direct-io.c b/fs/iomap/direct-io.c
index 933f234d5bec..22f7488bf5e5 100644
--- a/fs/iomap/direct-io.c
+++ b/fs/iomap/direct-io.c
@@ -64,6 +64,9 @@ static void iomap_dio_submit_bio(struct iomap_dio *dio, struct iomap *iomap,
 {
 	atomic_inc(&dio->ref);
 
+	if ((dio->iocb->ki_flags & IOCB_NOWAIT) && !is_sync_kiocb(dio->iocb))
+		bio->bi_opf |= REQ_NOWAIT;
+
 	if (dio->iocb->ki_flags & IOCB_HIPRI)
 		bio_set_polled(bio, dio->iocb);
 
-- 
1.8.3.1


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

* [RFC RESEND] iomap: set REQ_NOWAIT according to IOCB_NOWAIT in Direct IO
  2020-11-18  7:52 [RFC] iomap: set REQ_NOWAIT according to IOCB_NOWAIT in Direct IO Hao Xu
@ 2020-11-18 11:11 ` Hao Xu
  2020-11-18 11:51   ` [RFC v2] " Hao Xu
  0 siblings, 1 reply; 4+ messages in thread
From: Hao Xu @ 2020-11-18 11:11 UTC (permalink / raw)
  To: Alexander Viro, Christoph Hellwig; +Cc: Darrick J. Wong, linux-fsdevel

Currently, IOCB_NOWAIT is ignored in direct io, REQ_NOWAIT is only set
when IOCB_HIPRI is set. But REQ_NOWAIT should be set as well when
IOCB_NOWAIT is set.

Signed-off-by: Hao Xu <haoxu@linux.alibaba.com>
---

Hi all,
I tested fio io_uring direct read for a file on ext4 filesystem on a
nvme ssd. I found that IOCB_NOWAIT is ignored in iomap layer, which
means REQ_NOWAIT is not set in bio->bi_opf. This makes nowait IO a
normal IO. Since I'm new to iomap and block layer, I sincerely ask
yours opinions in case I misunderstand the code which is very likely
to happen.:)

 fs/block_dev.c       | 3 +++
 fs/iomap/direct-io.c | 3 +++
 2 files changed, 6 insertions(+)

diff --git a/fs/block_dev.c b/fs/block_dev.c
index 9e84b1928b94..b7db3b7e2ba1 100644
--- a/fs/block_dev.c
+++ b/fs/block_dev.c
@@ -424,6 +424,9 @@ static void blkdev_bio_end_io(struct bio *bio)
 		if (!nr_pages) {
 			bool polled = false;
 
+			if (iocb->ki_flags & IOCB_NOWAIT)
+				bio->bi_opf |= REQ_NOWAIT;
+
 			if (iocb->ki_flags & IOCB_HIPRI) {
 				bio_set_polled(bio, iocb);
 				polled = true;
diff --git a/fs/iomap/direct-io.c b/fs/iomap/direct-io.c
index 933f234d5bec..22f7488bf5e5 100644
--- a/fs/iomap/direct-io.c
+++ b/fs/iomap/direct-io.c
@@ -64,6 +64,9 @@ static void iomap_dio_submit_bio(struct iomap_dio *dio, struct iomap *iomap,
 {
 	atomic_inc(&dio->ref);
 
+	if (dio->iocb->ki_flags & IOCB_NOWAIT)
+		bio->bi_opf |= REQ_NOWAIT;
+
 	if (dio->iocb->ki_flags & IOCB_HIPRI)
 		bio_set_polled(bio, dio->iocb);
 
-- 
1.8.3.1


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

* [RFC v2] iomap: set REQ_NOWAIT according to IOCB_NOWAIT in Direct IO
  2020-11-18 11:11 ` [RFC RESEND] " Hao Xu
@ 2020-11-18 11:51   ` Hao Xu
  2020-11-22 12:48     ` Hao Xu
  0 siblings, 1 reply; 4+ messages in thread
From: Hao Xu @ 2020-11-18 11:51 UTC (permalink / raw)
  To: Alexander Viro, Christoph Hellwig; +Cc: Darrick J. Wong, linux-fsdevel

Currently, IOCB_NOWAIT is ignored in Direct IO, REQ_NOWAIT is only set
when IOCB_HIPRI is set. But REQ_NOWAIT should be set as well when
IOCB_NOWAIT is set.

Signed-off-by: Hao Xu <haoxu@linux.alibaba.com>
---

Hi all,
I tested fio io_uring direct read for a file on ext4 filesystem on a
nvme ssd. I found that IOCB_NOWAIT is ignored in iomap layer, which
means REQ_NOWAIT is not set in bio->bi_opf. This makes nowait IO a
normal IO. Since I'm new to iomap and block layer, I sincerely ask
yours opinions in case I misunderstand the code which is very likely
to happen.:)

v1->v2:
* add same logic in __blkdev_direct_IO_simple()

 fs/block_dev.c       | 7 +++++++
 fs/iomap/direct-io.c | 3 +++
 2 files changed, 10 insertions(+)

diff --git a/fs/block_dev.c b/fs/block_dev.c
index 9e84b1928b94..f3e9e13a9a9f 100644
--- a/fs/block_dev.c
+++ b/fs/block_dev.c
@@ -263,6 +263,10 @@ static void blkdev_bio_end_io_simple(struct bio *bio)
 	 	bio.bi_opf = dio_bio_write_op(iocb);
 		task_io_account_write(ret);
 	}
+
+	if (iocb->ki_flags & IOCB_NOWAIT)
+		bio.bi_opf |= REQ_NOWAIT;
+
 	if (iocb->ki_flags & IOCB_HIPRI)
 		bio_set_polled(&bio, iocb);
 
@@ -424,6 +428,9 @@ static void blkdev_bio_end_io(struct bio *bio)
 		if (!nr_pages) {
 			bool polled = false;
 
+			if (iocb->ki_flags & IOCB_NOWAIT)
+				bio->bi_opf |= REQ_NOWAIT;
+
 			if (iocb->ki_flags & IOCB_HIPRI) {
 				bio_set_polled(bio, iocb);
 				polled = true;
diff --git a/fs/iomap/direct-io.c b/fs/iomap/direct-io.c
index 933f234d5bec..2e897688ed6d 100644
--- a/fs/iomap/direct-io.c
+++ b/fs/iomap/direct-io.c
@@ -64,6 +64,9 @@ static void iomap_dio_submit_bio(struct iomap_dio *dio, struct iomap *iomap,
 {
 	atomic_inc(&dio->ref);
 
+	if (dio->iocb->ki_flags & IOCB_NOWAIT)
+		bio->bi_opf |= REQ_NOWAIT;
+
 	if (dio->iocb->ki_flags & IOCB_HIPRI)
 		bio_set_polled(bio, dio->iocb);
 
-- 
1.8.3.1


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

* Re: [RFC v2] iomap: set REQ_NOWAIT according to IOCB_NOWAIT in Direct IO
  2020-11-18 11:51   ` [RFC v2] " Hao Xu
@ 2020-11-22 12:48     ` Hao Xu
  0 siblings, 0 replies; 4+ messages in thread
From: Hao Xu @ 2020-11-22 12:48 UTC (permalink / raw)
  To: Alexander Viro, Christoph Hellwig
  Cc: Darrick J. Wong, linux-fsdevel, Joseph Qi

在 2020/11/18 下午7:51, Hao Xu 写道:
> Currently, IOCB_NOWAIT is ignored in Direct IO, REQ_NOWAIT is only set
> when IOCB_HIPRI is set. But REQ_NOWAIT should be set as well when
> IOCB_NOWAIT is set.
> 
> Signed-off-by: Hao Xu <haoxu@linux.alibaba.com>
> ---
> 
> Hi all,
> I tested fio io_uring direct read for a file on ext4 filesystem on a
> nvme ssd. I found that IOCB_NOWAIT is ignored in iomap layer, which
> means REQ_NOWAIT is not set in bio->bi_opf. This makes nowait IO a
> normal IO. Since I'm new to iomap and block layer, I sincerely ask
> yours opinions in case I misunderstand the code which is very likely
> to happen.:)
> 
> v1->v2:
> * add same logic in __blkdev_direct_IO_simple()
> 
>   fs/block_dev.c       | 7 +++++++
>   fs/iomap/direct-io.c | 3 +++
>   2 files changed, 10 insertions(+)
> 
ping...
> diff --git a/fs/block_dev.c b/fs/block_dev.c
> index 9e84b1928b94..f3e9e13a9a9f 100644
> --- a/fs/block_dev.c
> +++ b/fs/block_dev.c
> @@ -263,6 +263,10 @@ static void blkdev_bio_end_io_simple(struct bio *bio)
>   	 	bio.bi_opf = dio_bio_write_op(iocb);
>   		task_io_account_write(ret);
>   	}
> +
> +	if (iocb->ki_flags & IOCB_NOWAIT)
> +		bio.bi_opf |= REQ_NOWAIT;
> +
>   	if (iocb->ki_flags & IOCB_HIPRI)
>   		bio_set_polled(&bio, iocb);
>   
> @@ -424,6 +428,9 @@ static void blkdev_bio_end_io(struct bio *bio)
>   		if (!nr_pages) {
>   			bool polled = false;
>   
> +			if (iocb->ki_flags & IOCB_NOWAIT)
> +				bio->bi_opf |= REQ_NOWAIT;
> +
>   			if (iocb->ki_flags & IOCB_HIPRI) {
>   				bio_set_polled(bio, iocb);
>   				polled = true;
> diff --git a/fs/iomap/direct-io.c b/fs/iomap/direct-io.c
> index 933f234d5bec..2e897688ed6d 100644
> --- a/fs/iomap/direct-io.c
> +++ b/fs/iomap/direct-io.c
> @@ -64,6 +64,9 @@ static void iomap_dio_submit_bio(struct iomap_dio *dio, struct iomap *iomap,
>   {
>   	atomic_inc(&dio->ref);
>   
> +	if (dio->iocb->ki_flags & IOCB_NOWAIT)
> +		bio->bi_opf |= REQ_NOWAIT;
> +
>   	if (dio->iocb->ki_flags & IOCB_HIPRI)
>   		bio_set_polled(bio, dio->iocb);
>   
> 

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

end of thread, other threads:[~2020-11-22 12:48 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-18  7:52 [RFC] iomap: set REQ_NOWAIT according to IOCB_NOWAIT in Direct IO Hao Xu
2020-11-18 11:11 ` [RFC RESEND] " Hao Xu
2020-11-18 11:51   ` [RFC v2] " Hao Xu
2020-11-22 12:48     ` Hao Xu

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