]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
block/cgroup: Inline blkg_conf_{open,close}_bdev_frozen()
authorBart Van Assche <bvanassche@acm.org>
Fri, 5 Jun 2026 18:01:00 +0000 (11:01 -0700)
committerJens Axboe <axboe@kernel.dk>
Fri, 5 Jun 2026 19:41:11 +0000 (13:41 -0600)
The blkg_conf_open_bdev_frozen() calling convention is not compatible
with lock context annotations. Fold both blkg_conf_open_bdev_frozen()
and blkg_conf_close_bdev_frozen() into their only caller. This patch
prepares for enabling lock context analysis.

The type of 'memflags' has been changed from unsigned long into unsigned
int to match the type of current->flags. See also <linux/sched.h>.

Reviewed-by: Hannes Reinecke <hare@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Cc: Tejun Heo <tj@kernel.org>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Reviewed-by: Chaitanya Kulkarni <kch@nvidia.com>
Link: https://patch.msgid.link/05661d1555decc6dd5389174ba448d803b72ed9a.1780682325.git.bvanassche@acm.org
Signed-off-by: Jens Axboe <axboe@kernel.dk>
block/blk-cgroup.c
block/blk-cgroup.h
block/blk-iocost.c

index 86513c54c21703934f97dc6d283581b13b997325..de0f753b8fe5f5c9e71c4e08a13bee0a0dabf7a2 100644 (file)
@@ -812,39 +812,6 @@ int blkg_conf_open_bdev(struct blkg_conf_ctx *ctx)
 }
 EXPORT_SYMBOL_GPL(blkg_conf_open_bdev);
 
-/*
- * Similar to blkg_conf_open_bdev, but additionally freezes the queue,
- * ensures the correct locking order between freeze queue and q->rq_qos_mutex.
- *
- * This function returns negative error on failure. On success it returns
- * memflags which must be saved and later passed to
- * blkg_conf_close_bdev_frozen() for restoring the memalloc scope.
- */
-unsigned long __must_check blkg_conf_open_bdev_frozen(struct blkg_conf_ctx *ctx)
-{
-       int ret;
-       unsigned long memflags;
-
-       if (ctx->bdev)
-               return -EINVAL;
-
-       ret = blkg_conf_open_bdev(ctx);
-       if (ret < 0)
-               return ret;
-       /*
-        * At this point, we haven’t started protecting anything related to QoS,
-        * so we release q->rq_qos_mutex here, which was first acquired in blkg_
-        * conf_open_bdev. Later, we re-acquire q->rq_qos_mutex after freezing
-        * the queue to maintain the correct locking order.
-        */
-       mutex_unlock(&ctx->bdev->bd_queue->rq_qos_mutex);
-
-       memflags = blk_mq_freeze_queue(ctx->bdev->bd_queue);
-       mutex_lock(&ctx->bdev->bd_queue->rq_qos_mutex);
-
-       return memflags;
-}
-
 /**
  * blkg_conf_prep - parse and prepare for per-blkg config update
  * @blkcg: target block cgroup
@@ -991,19 +958,6 @@ void blkg_conf_close_bdev(struct blkg_conf_ctx *ctx)
 }
 EXPORT_SYMBOL_GPL(blkg_conf_close_bdev);
 
-/*
- * Similar to blkg_close_bdev, but also unfreezes the queue. Should be used
- * when blkg_conf_open_bdev_frozen is used to open the bdev.
- */
-void blkg_conf_close_bdev_frozen(struct blkg_conf_ctx *ctx,
-                                unsigned long memflags)
-{
-       struct request_queue *q = ctx->bdev->bd_queue;
-
-       blkg_conf_close_bdev(ctx);
-       blk_mq_unfreeze_queue(q, memflags);
-}
-
 static void blkg_iostat_add(struct blkg_iostat *dst, struct blkg_iostat *src)
 {
        int i;
index f0a3af520c5594f3ffdd7ff5099c03196c6e9e8d..f25fecb87c43f2a9d5238f7ce54e22481fe78d28 100644 (file)
@@ -220,7 +220,6 @@ struct blkg_conf_ctx {
 void blkg_conf_init(struct blkg_conf_ctx *ctx, char *input);
 int blkg_conf_open_bdev(struct blkg_conf_ctx *ctx)
        __cond_acquires(0, &ctx->bdev->bd_queue->rq_qos_mutex);
-unsigned long blkg_conf_open_bdev_frozen(struct blkg_conf_ctx *ctx);
 int blkg_conf_prep(struct blkcg *blkcg, const struct blkcg_policy *pol,
                   struct blkg_conf_ctx *ctx)
        __cond_acquires(0, &ctx->bdev->bd_disk->queue->queue_lock);
@@ -228,9 +227,6 @@ void blkg_conf_unprep(struct blkg_conf_ctx *ctx)
        __releases(ctx->bdev->bd_disk->queue->queue_lock);
 void blkg_conf_close_bdev(struct blkg_conf_ctx *ctx)
        __releases(&ctx->bdev->bd_queue->rq_qos_mutex);
-void blkg_conf_close_bdev_frozen(struct blkg_conf_ctx *ctx,
-                                unsigned long memflags)
-       __releases(&ctx->bdev->bd_queue->rq_qos_mutex);
 
 /**
  * bio_issue_as_root_blkg - see if this bio needs to be issued as root blkg
index 050bfbc6d80622f219e0c693643b1381a282e919..302388e995883f612ff83b4eafa145b544e5bb17 100644 (file)
@@ -3233,19 +3233,30 @@ static ssize_t ioc_qos_write(struct kernfs_open_file *of, char *input,
                             size_t nbytes, loff_t off)
 {
        struct blkg_conf_ctx ctx;
+       struct request_queue *q;
        struct gendisk *disk;
        struct ioc *ioc;
        u32 qos[NR_QOS_PARAMS];
        bool enable, user;
        char *body, *p;
-       unsigned long memflags;
-       int ret = 0;
+       unsigned int memflags;
+       int ret;
 
        blkg_conf_init(&ctx, input);
 
-       memflags = blkg_conf_open_bdev_frozen(&ctx);
-       if (IS_ERR_VALUE(memflags))
-               return memflags;
+       ret = blkg_conf_open_bdev(&ctx);
+       if (ret)
+               return ret;
+       /*
+        * At this point, we haven’t started protecting anything related to QoS,
+        * so we release q->rq_qos_mutex here, which was first acquired in blkg_
+        * conf_open_bdev. Later, we re-acquire q->rq_qos_mutex after freezing
+        * the queue to maintain the correct locking order.
+        */
+       mutex_unlock(&ctx.bdev->bd_queue->rq_qos_mutex);
+
+       memflags = blk_mq_freeze_queue(ctx.bdev->bd_queue);
+       mutex_lock(&ctx.bdev->bd_queue->rq_qos_mutex);
 
        body = ctx.body;
        disk = ctx.bdev->bd_disk;
@@ -3363,7 +3374,9 @@ static ssize_t ioc_qos_write(struct kernfs_open_file *of, char *input,
        blk_mq_unquiesce_queue(disk->queue);
 
 close_bdev:
-       blkg_conf_close_bdev_frozen(&ctx, memflags);
+       q = ctx.bdev->bd_queue;
+       blkg_conf_close_bdev(&ctx);
+       blk_mq_unfreeze_queue(q, memflags);
        return ret ?: nbytes;
 
 einval: