linux-block.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] io_uring: make req from defer and link list not touch async list
@ 2019-07-13  3:58 Zhengyuan Liu
  2019-07-13  3:58 ` [PATCH 2/2] io_uring: fix the judging condition in io_sequence_defer Zhengyuan Liu
  2019-07-16 14:08 ` [PATCH 1/2] io_uring: make req from defer and link list not touch async list Jens Axboe
  0 siblings, 2 replies; 5+ messages in thread
From: Zhengyuan Liu @ 2019-07-13  3:58 UTC (permalink / raw)
  To: axboe; +Cc: linux-block, Zhengyuan Liu

We would queue a work for each req in defer and link list without
increasing async->cnt, so we shouldn't decrease it while exiting
from workqueue as well as shouldn't process the req in async list.

Signed-off-by: Zhengyuan Liu <liuzhengyuan@kylinos.cn>
---
 fs/io_uring.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/fs/io_uring.c b/fs/io_uring.c
index 7e932c572f26..3e48fd7cd08f 100644
--- a/fs/io_uring.c
+++ b/fs/io_uring.c
@@ -333,7 +333,8 @@ struct io_kiocb {
 #define REQ_F_IO_DRAIN		16	/* drain existing IO first */
 #define REQ_F_IO_DRAINED	32	/* drain done */
 #define REQ_F_LINK		64	/* linked sqes */
-#define REQ_F_FAIL_LINK		128	/* fail rest of links */
+#define REQ_F_LINKED		128	/* linked sqes done */
+#define REQ_F_FAIL_LINK		256	/* fail rest of links */
 	u64			user_data;
 	u32			result;
 	u32			sequence;
@@ -630,6 +631,7 @@ static void io_req_link_next(struct io_kiocb *req)
 			nxt->flags |= REQ_F_LINK;
 		}
 
+		nxt->flags |= REQ_F_LINKED;
 		INIT_WORK(&nxt->work, io_sq_wq_submit_work);
 		queue_work(req->ctx->sqo_wq, &nxt->work);
 	}
@@ -1845,6 +1847,10 @@ static void io_sq_wq_submit_work(struct work_struct *work)
 		/* async context always use a copy of the sqe */
 		kfree(sqe);
 
+		/* req from defer and link list needn't dec async_list->cnt */
+		if (req->flags & (REQ_F_IO_DRAINED | REQ_F_LINKED))
+			goto out;
+
 		if (!async_list)
 			break;
 		if (!list_empty(&req_list)) {
@@ -1892,6 +1898,7 @@ static void io_sq_wq_submit_work(struct work_struct *work)
 		}
 	}
 
+out:
 	if (cur_mm) {
 		set_fs(old_fs);
 		unuse_mm(cur_mm);
-- 
2.19.1




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

end of thread, other threads:[~2019-07-16 14:10 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-07-13  3:58 [PATCH 1/2] io_uring: make req from defer and link list not touch async list Zhengyuan Liu
2019-07-13  3:58 ` [PATCH 2/2] io_uring: fix the judging condition in io_sequence_defer Zhengyuan Liu
2019-07-13 21:43   ` Jens Axboe
     [not found]     ` <5d2be620.1c69fb81.fff62.8eeeSMTPIN_ADDED_BROKEN@mx.google.com>
2019-07-16 14:10       ` Jens Axboe
2019-07-16 14:08 ` [PATCH 1/2] io_uring: make req from defer and link list not touch async list 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).