From: no-reply@sashiko.virtuozzo.com
To: "Denis V. Lunev" <den@openvz.org>,
andrey.zhadchenko@virtuozzo.com, alexander.ivanov@virtuozzo.com,
vasileios.almpanis@virtuozzo.com
Cc: devel@openvz.org
Subject: Re: [Devel] [PATCH hci-8.2 6/9] dm-rq: complete dm-qcow2 requests directly in task context
Date: Tue, 1 Dec 2026 00:35:38 +0000 [thread overview]
Message-ID: <010701a22f075082-cb0bbda0-480d-4363-accf-99eeb11983e1-000000@eu-central-1.amazonses.com> (raw)
In-Reply-To: <20261125012525.681662-7-den@openvz.org>
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] dm-rq: dm_complete_request_direct() gates inline completion
on in_task(), not preemptible()
--
commit 6b8fa61333058b203793f7fad936707219ef0649
Author: Denis V. Lunev <den@openvz.org>
dm-rq: complete dm-qcow2 requests directly in task context
This adds dm_complete_request_direct(). In task context it runs dm_softirq_done() inline through blk_mq_complete_request_direct(). It otherwise falls back to blk_mq_complete_request(). dm-qcow2's qrq_endio() now uses it.
https://virtuozzo.atlassian.net/browse/VSTOR-95494
> diff --git a/drivers/md/dm-rq.c b/drivers/md/dm-rq.c
> index 5a8cd59ec257..0d31fcf84aed 100644
> --- a/drivers/md/dm-rq.c
> +++ b/drivers/md/dm-rq.c
> @@ -294,6 +294,26 @@ void dm_complete_request(struct request *rq, blk_status_t error)
> }
> EXPORT_SYMBOL(dm_complete_request);
>
> +/*
> + * Raising BLOCK_SOFTIRQ from a task wakes ksoftirqd. Complete inline
> + * if affinity permits. The caller must not hold a lock that completion
> + * of the original request may take.
> + */
> +void dm_complete_request_direct(struct request *rq, blk_status_t error)
> +{
> + struct dm_rq_target_io *tio = tio_from_request(rq);
> +
> + tio->error = error;
> + if (unlikely(blk_should_fake_timeout(rq->q)))
> + return;
> +
> + if (in_task() && !test_bit(QUEUE_FLAG_SAME_FORCE, &rq->q->queue_flags))
> + blk_mq_complete_request_direct(rq, dm_softirq_done);
[Severity: Medium]
Is in_task() a strong enough condition for running the original request's end_io inline here?
in_task() stays true while a spinlock is held, with preemption or BH disabled, and inside an RCU read-side section. Before this patch, blk_mq_complete_request() never ran the end_io on the caller's stack in those contexts.
dm-qcow2 itself looks safe. qrq_endio() is only reached after the target has dropped its locks, or from workqueues. The problem is on the lower-layer side. qcow2_aio_complete() is the ki_complete callback for the backing file. qcow2_call_rw_iter() also calls it synchronously. The target can't tell what context the lower layer completes the kiocb in.
If a lower layer completes in task context with a lock, preemption or RCU held, the end_io now runs there. That could cause a self-deadlock, a sleep in atomic context, or deep stack recursion.
blk_mq_complete_request_direct() is meant for preemptible callers. Would it be better to also require preemptible(), which implies !irqs_disabled(), or to take an explicit flag from the caller as scsi_done_direct() does?
--
Sashiko AI review · https://sashiko.vzint.dev/#/patchset/20261125012525.681662-1-den@openvz.org?part=6
_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel
next prev parent reply other threads:[~2026-12-01 0:36 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-25 1:25 [Devel] [PATCH hci-8.2 0/9] dm-qcow2: lockless fast path, direct completion, no I/O scheduler Denis V. Lunev
2026-11-25 1:25 ` [Devel] [PATCH hci-8.2 1/9] dm-qcow2: move md_pages_lock off the deferred_lock cache line Denis V. Lunev
2026-12-01 0:05 ` no-reply
2026-11-25 1:25 ` [Devel] [PATCH hci-8.2 2/9] dm-qcow2: free md pages after an RCU grace period Denis V. Lunev
2026-11-25 11:19 ` Konstantin Khorenko
2026-12-01 0:06 ` no-reply
2026-11-25 1:25 ` [Devel] [PATCH hci-8.2 3/9] dm-qcow2: map fast path reads without md_pages_lock Denis V. Lunev
2026-11-25 11:19 ` Konstantin Khorenko
2026-12-01 0:17 ` no-reply
2026-11-25 1:25 ` [Devel] [PATCH hci-8.2 4/9] dm-qcow2: map fast path writes " Denis V. Lunev
2026-11-25 11:19 ` Konstantin Khorenko
2026-12-01 0:25 ` no-reply
2026-11-25 1:25 ` [Devel] [PATCH hci-8.2 5/9] dm-qcow2: submit fast path qios without deferred_lock Denis V. Lunev
2026-12-01 0:27 ` no-reply
2026-11-25 1:25 ` [Devel] [PATCH hci-8.2 6/9] dm-rq: complete dm-qcow2 requests directly in task context Denis V. Lunev
2026-11-25 11:19 ` Konstantin Khorenko
2026-12-01 0:35 ` no-reply [this message]
2026-11-25 1:25 ` [Devel] [PATCH hci-8.2 7/9] dm-qcow2: requeue requests when the request pool is empty Denis V. Lunev
2026-12-01 0:37 ` no-reply
2026-11-25 1:25 ` [Devel] [PATCH hci-8.2 8/9] dm-ploop: " Denis V. Lunev
2026-11-25 11:19 ` Konstantin Khorenko
2026-12-01 0:38 ` no-reply
2026-11-25 1:25 ` [Devel] [PATCH hci-8.2 9/9] dm: default dm-qcow2 devices to no I/O scheduler Denis V. Lunev
2026-11-25 11:19 ` Konstantin Khorenko
2026-12-01 0:39 ` no-reply
2026-11-25 11:19 ` [Devel] [PATCH hci-8.2 0/9] dm-qcow2: lockless fast path, direct completion, " Konstantin Khorenko
2026-11-26 13:58 ` Andrey Zhadchenko
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=010701a22f075082-cb0bbda0-480d-4363-accf-99eeb11983e1-000000@eu-central-1.amazonses.com \
--to=no-reply@sashiko.virtuozzo.com \
--cc=alexander.ivanov@virtuozzo.com \
--cc=andrey.zhadchenko@virtuozzo.com \
--cc=den@openvz.org \
--cc=devel@openvz.org \
--cc=vasileios.almpanis@virtuozzo.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox