Skip to contentSkip to conversation

loop: clear nowait flag in workqueue context

PATCH Applied Chaitanya Kulkarni 3 participants 5 messages Nov 19, 2025 – Nov 20, 2025

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/2 loop: clear nowait flag in workqueue context

The loop driver advertises REQ_NOWAIT support through BLK_FEAT_NOWAIT (enabled by default for all blk-mq devices), and honors the nowait behavior throughout loop_queue_rq().

However, actual I/O to the backing file is performed in a workqueue, where blocking is allowed.

To avoid imposing unnecessary non-blocking constraints in this blocking context, clear the REQ_NOWAIT flag before processing the request in the workqueue context.

---

v1->v2:-

Unset REQ_NOWAIT at the start of the workqueue context. (Damien)

HEAD:-

commit 6dbcc40ec7aa17ed3dd1f798e4201e75ab7d7447 (HEAD -> for-next, origin/for-next)
Merge: 58625d626327 ba13710ddd1f
Author: Jens Axboe <[email protected]>
Date: Wed Nov 5 18:24:17 2025 -0700

Merge branch 'for-6.19/block' into for-next

* for-6.19/block:
rust: block: update ARef and AlwaysRefCounted imports from sync::aref

---
 drivers/block/loop.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/block/loop.c +4 -0
index 13ce229d450c..ebe751f39742 100644
@@ -1908,6 +1908,10 @@ static void loop_handle_cmd(struct loop_cmd *cmd)
 		goto failed;
 	}
 
+	/* We can block in this context, so ignore REQ_NOWAIT. */
+	if (rq->cmd_flags & REQ_NOWAIT)
+		rq->cmd_flags &= ~REQ_NOWAIT;
+
 	if (cmd_blkcg_css)
 		kthread_associate_blkcg(cmd_blkcg_css);
 	if (cmd_memcg_css)
Signature · 1 line
2.40.0
#1 lore raw

PATCH v2 2/2 zloop: clear nowait flag in workqueue context

The zloop driver advertises REQ_NOWAIT support through BLK_FEAT_NOWAIT (enabled by default for all blk-mq devices), and honors the nowait behavior throughout zloop_queue_rq().

However, actual I/O to the backing file is performed in a workqueue, where blocking is allowed.

To avoid imposing unnecessary non-blocking constraints in this blocking context, clear the REQ_NOWAIT flag before processing the request in the workqueue context.

---

v1->v2:-

Unset REQ_NOWAIT at the start of the workqueue context. (Damien)

HEAD:-

commit 6dbcc40ec7aa17ed3dd1f798e4201e75ab7d7447 (HEAD -> for-next, origin/for-next)
Merge: 58625d626327 ba13710ddd1f
Author: Jens Axboe <[email protected]>
Date: Wed Nov 5 18:24:17 2025 -0700

Merge branch 'for-6.19/block' into for-next

* for-6.19/block:
rust: block: update ARef and AlwaysRefCounted imports from sync::aref

---
 drivers/block/zloop.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/block/zloop.c +4 -0
index 92be9f0af00a..1a97b21f5fed 100644
@@ -498,6 +498,10 @@ static void zloop_handle_cmd(struct zloop_cmd *cmd)
 	struct request *rq = blk_mq_rq_from_pdu(cmd);
 	struct zloop_device *zlo = rq->q->queuedata;
 
+	/* We can block in this context, so ignore REQ_NOWAIT. */
+	if (rq->cmd_flags & REQ_NOWAIT)
+		rq->cmd_flags &= ~REQ_NOWAIT;
+
 	switch (req_op(rq)) {
 	case REQ_OP_READ:
 	case REQ_OP_WRITE:
Signature · 1 line
2.40.0
maintainer Reviewed-by on v2 2/2
#2 lore raw

Re: [PATCH V2 2/2] zloop: clear nowait flag in workqueue context

Quoted 4 lines · Chaitanya Kulkarni

The zloop driver advertises REQ_NOWAIT support through BLK_FEAT_NOWAIT (enabled by default for all blk-mq devices), and honors the nowait behavior throughout zloop_queue_rq().

Quoted 8 lines

However, actual I/O to the backing file is performed in a workqueue, where blocking is allowed.

To avoid imposing unnecessary non-blocking constraints in this blocking context, clear the REQ_NOWAIT flag before processing the request in the workqueue context.

Looks good.

Signature · 2 lines
Damien Le Moal
Western Digital Research
maintainer Reviewed-by on v2 1/2
#3 lore raw
In reply to Chaitanya Kulkarni
Quoted 4 lines · Chaitanya Kulkarni

The loop driver advertises REQ_NOWAIT support through BLK_FEAT_NOWAIT (enabled by default for all blk-mq devices), and honors the nowait behavior throughout loop_queue_rq().

Quoted 8 lines

However, actual I/O to the backing file is performed in a workqueue, where blocking is allowed.

To avoid imposing unnecessary non-blocking constraints in this blocking context, clear the REQ_NOWAIT flag before processing the request in the workqueue context.

Looks good.

Signature · 2 lines
Damien Le Moal
Western Digital Research
maintainer Applied
#4 lore raw
In reply to Chaitanya Kulkarni
Quoted 8 lines · Chaitanya Kulkarni

The loop driver advertises REQ_NOWAIT support through BLK_FEAT_NOWAIT (enabled by default for all blk-mq devices), and honors the nowait behavior throughout loop_queue_rq().

However, actual I/O to the backing file is performed in a workqueue, where blocking is allowed.

[...]

Applied, thanks!

[1/2] loop: clear nowait flag in workqueue context

      commit: b11e483a1cc32e7b557ff680e9bfb4ff11dea9c1
[2/2] zloop: clear nowait flag in workqueue context
      commit: e8f0abdd49baacee3886d5827f113514fcd9fd05

Best regards,

Signature · 1 line
Jens Axboe