]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
block: fix direct io NOWAIT flag not work
authorFengnan Chang <changfengnan@bytedance.com>
Tue, 13 May 2025 11:28:04 +0000 (19:28 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 22 May 2025 12:08:26 +0000 (14:08 +0200)
commit 8b44b4d81598 ("block: don't allow multiple bios for IOCB_NOWAIT
issue") backport a upstream fix, but miss commit b77c88c2100c ("block:
pass a block_device and opf to bio_alloc_kiocb"), and introduce this bug.
commit b77c88c2100c ("block: pass a block_device and opf to
bio_alloc_kiocb") have other depend patch, so just fix it.

Fixes: 8b44b4d81598 ("block: don't allow multiple bios for IOCB_NOWAIT issue")
Signed-off-by: Fengnan Chang <changfengnan@bytedance.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
block/fops.c

index 4c8948979921a69f22b23280990eaf4632f69461..72da501542f148d47f37bbf32a4bb68987675c87 100644 (file)
@@ -259,7 +259,6 @@ static ssize_t __blkdev_direct_IO(struct kiocb *iocb, struct iov_iter *iter,
                                blk_finish_plug(&plug);
                                return -EAGAIN;
                        }
-                       bio->bi_opf |= REQ_NOWAIT;
                }
 
                if (is_read) {
@@ -270,6 +269,10 @@ static ssize_t __blkdev_direct_IO(struct kiocb *iocb, struct iov_iter *iter,
                        bio->bi_opf = dio_bio_write_op(iocb);
                        task_io_account_write(bio->bi_iter.bi_size);
                }
+
+               if (iocb->ki_flags & IOCB_NOWAIT)
+                       bio->bi_opf |= REQ_NOWAIT;
+
                dio->size += bio->bi_iter.bi_size;
                pos += bio->bi_iter.bi_size;