Re: [PATCH v3 3/7] blk-mq: add a new queue sysfs attribute async_depth

From: Nilay Shroff
Date: Fri Oct 10 2025 - 00:48:58 EST




On 10/10/25 7:58 AM, Yu Kuai wrote:
> +static ssize_t
> +queue_async_depth_store(struct gendisk *disk, const char *page, size_t count)
> +{
> + struct request_queue *q = disk->queue;
> + unsigned int memflags;
> + unsigned long nr;
> + int ret;
> +
> + if (!queue_is_mq(q))
> + return -EINVAL;
> +
> + ret = queue_var_store(&nr, page, count);
> + if (ret < 0)
> + return ret;
> +
> + if (nr == 0)
> + return -EINVAL;
> +
> + memflags = blk_mq_freeze_queue(q);
> + scoped_guard(mutex, &q->elevator_lock) {
> + if (q->elevator) {
> + q->async_depth = min(q->nr_requests, nr);
> + if (q->elevator->type->ops.depth_updated)
> + q->elevator->type->ops.depth_updated(q);
> + } else {
> + ret = -EINVAL;
> + }
> + }
> + blk_mq_unfreeze_queue(q, memflags);
> +
> + return ret;
> +}
> +
With this change, we've got the first user of scoped_guard() in the
block subsystem!

Looks good to me:
Reviewed-by: Nilay Shroff <nilay@xxxxxxxxxxxxx>