mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Yu Kuai <yukuai@kernel.org>
To: axboe@kernel.dk, tj@kernel.org, linux-block@vger.kernel.org,
	cgroups@vger.kernel.org, nilay@linux.ibm.com, bvanassche@acm.org,
	ming.lei@redhat.com, hch@lst.de
Cc: linux-kernel@vger.kernel.org, Yu Kuai <yukuai3@huawei.com>
Subject: [PATCH v2 19/19] blk-cgroup: remove unsed blkg configuration helpers
Date: Fri, 10 Oct 2025 17:14:44 +0800	[thread overview]
Message-ID: <20251010091446.3048529-20-yukuai@kernel.org> (raw)
In-Reply-To: <20251010091446.3048529-1-yukuai@kernel.org>

From: Yu Kuai <yukuai3@huawei.com>

Remove followings helpers that is now unused:

- blkg_conf_open_bdev()
- blkg_conf_open_bdev_frozen()
- blkg_conf_prep()
- blkg_conf_exit()
- blkg_conf_exit_frozen()

Signed-off-by: Yu Kuai <yukuai3@huawei.com>
---
 block/blk-cgroup.c | 224 +--------------------------------------------
 block/blk-cgroup.h |   6 --
 2 files changed, 1 insertion(+), 229 deletions(-)

diff --git a/block/blk-cgroup.c b/block/blk-cgroup.c
index 4b7324c1d0d5..d93654334854 100644
--- a/block/blk-cgroup.c
+++ b/block/blk-cgroup.c
@@ -729,8 +729,7 @@ EXPORT_SYMBOL_GPL(__blkg_prfill_u64);
  * @input: input string
  *
  * Initialize @ctx which can be used to parse blkg config input string @input.
- * Once initialized, @ctx can be used with blkg_conf_open_bdev() and
- * blkg_conf_prep(), and must be cleaned up with blkg_conf_exit().
+ * Once initialized, @ctx can be used with blkg_conf_start().
  */
 void blkg_conf_init(struct blkg_conf_ctx *ctx, char *input)
 {
@@ -738,92 +737,6 @@ void blkg_conf_init(struct blkg_conf_ctx *ctx, char *input)
 }
 EXPORT_SYMBOL_GPL(blkg_conf_init);
 
-/**
- * blkg_conf_open_bdev - parse and open bdev for per-blkg config update
- * @ctx: blkg_conf_ctx initialized with blkg_conf_init()
- *
- * Parse the device node prefix part, MAJ:MIN, of per-blkg config update from
- * @ctx->input and get and store the matching bdev in @ctx->bdev. @ctx->body is
- * set to point past the device node prefix.
- *
- * This function may be called multiple times on @ctx and the extra calls become
- * NOOPs. blkg_conf_prep() implicitly calls this function. Use this function
- * explicitly if bdev access is needed without resolving the blkcg / policy part
- * of @ctx->input. Returns -errno on error.
- */
-int blkg_conf_open_bdev(struct blkg_conf_ctx *ctx)
-{
-	char *input = ctx->input;
-	unsigned int major, minor;
-	struct block_device *bdev;
-	int key_len;
-
-	if (ctx->bdev)
-		return 0;
-
-	if (sscanf(input, "%u:%u%n", &major, &minor, &key_len) != 2)
-		return -EINVAL;
-
-	input += key_len;
-	if (!isspace(*input))
-		return -EINVAL;
-	input = skip_spaces(input);
-
-	bdev = blkdev_get_no_open(MKDEV(major, minor), false);
-	if (!bdev)
-		return -ENODEV;
-	if (bdev_is_partition(bdev)) {
-		blkdev_put_no_open(bdev);
-		return -ENODEV;
-	}
-
-	mutex_lock(&bdev->bd_queue->rq_qos_mutex);
-	if (!disk_live(bdev->bd_disk)) {
-		blkdev_put_no_open(bdev);
-		mutex_unlock(&bdev->bd_queue->rq_qos_mutex);
-		return -ENODEV;
-	}
-
-	ctx->body = input;
-	ctx->bdev = bdev;
-	return 0;
-}
-/*
- * Similar to blkg_conf_open_bdev, but additionally freezes the queue,
- * acquires q->elevator_lock, and ensures the correct locking order
- * between q->elevator_lock 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_exit_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 and acquiring q->elevator_lock 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->elevator_lock);
-	mutex_lock(&ctx->bdev->bd_queue->rq_qos_mutex);
-
-	return memflags;
-}
-
 void blkg_conf_end(struct blkg_conf_ctx *ctx)
 {
 	struct request_queue *q = bdev_get_queue(ctx->bdev);
@@ -885,141 +798,6 @@ int blkg_conf_start(struct blkcg *blkcg, struct blkg_conf_ctx *ctx)
 }
 EXPORT_SYMBOL_GPL(blkg_conf_start);
 
-/**
- * blkg_conf_prep - parse and prepare for per-blkg config update
- * @blkcg: target block cgroup
- * @pol: target policy
- * @ctx: blkg_conf_ctx initialized with blkg_conf_init()
- *
- * Parse per-blkg config update from @ctx->input and initialize @ctx
- * accordingly. On success, @ctx->body points to the part of @ctx->input
- * following MAJ:MIN, @ctx->bdev points to the target block device and
- * @ctx->blkg to the blkg being configured.
- *
- * blkg_conf_open_bdev() may be called on @ctx beforehand. On success, this
- * function returns with queue lock held and must be followed by
- * blkg_conf_exit().
- */
-int blkg_conf_prep(struct blkcg *blkcg, const struct blkcg_policy *pol,
-		   struct blkg_conf_ctx *ctx)
-	__acquires(&bdev->bd_queue->blkcg_mutex)
-{
-	struct gendisk *disk;
-	struct request_queue *q;
-	struct blkcg_gq *blkg;
-	int ret;
-
-	ret = blkg_conf_open_bdev(ctx);
-	if (ret)
-		return ret;
-
-	disk = ctx->bdev->bd_disk;
-	q = disk->queue;
-
-	/* Prevent concurrent with blkcg_deactivate_policy() */
-	mutex_lock(&q->blkcg_mutex);
-
-	if (!blkcg_policy_enabled(q, pol)) {
-		ret = -EOPNOTSUPP;
-		goto fail_unlock;
-	}
-
-	blkg = blkg_lookup(blkcg, q);
-	if (blkg)
-		goto success;
-
-	/*
-	 * Create blkgs walking down from blkcg_root to @blkcg, so that all
-	 * non-root blkgs have access to their parents.
-	 */
-	while (true) {
-		struct blkcg *pos = blkcg;
-		struct blkcg *parent;
-
-		parent = blkcg_parent(blkcg);
-		while (parent && !blkg_lookup(parent, q)) {
-			pos = parent;
-			parent = blkcg_parent(parent);
-		}
-
-		if (!blkcg_policy_enabled(q, pol)) {
-			ret = -EOPNOTSUPP;
-			goto fail_unlock;
-		}
-
-		blkg = blkg_lookup(pos, q);
-		if (!blkg) {
-			blkg = blkg_create(pos, disk);
-			if (IS_ERR(blkg)) {
-				ret = PTR_ERR(blkg);
-				goto fail_unlock;
-			}
-		}
-
-		if (pos == blkcg)
-			goto success;
-	}
-success:
-	ctx->blkg = blkg;
-	return 0;
-
-fail_unlock:
-	mutex_unlock(&q->blkcg_mutex);
-	/*
-	 * If queue was bypassing, we should retry.  Do so after a
-	 * short msleep().  It isn't strictly necessary but queue
-	 * can be bypassing for some time and it's always nice to
-	 * avoid busy looping.
-	 */
-	if (ret == -EBUSY) {
-		msleep(10);
-		ret = restart_syscall();
-	}
-	return ret;
-}
-EXPORT_SYMBOL_GPL(blkg_conf_prep);
-
-/**
- * blkg_conf_exit - clean up per-blkg config update
- * @ctx: blkg_conf_ctx initialized with blkg_conf_init()
- *
- * Clean up after per-blkg config update. This function must be called on all
- * blkg_conf_ctx's initialized with blkg_conf_init().
- */
-void blkg_conf_exit(struct blkg_conf_ctx *ctx)
-	__releases(&ctx->bdev->bd_queue->blkcg_mutex)
-	__releases(&ctx->bdev->bd_queue->rq_qos_mutex)
-{
-	if (ctx->blkg) {
-		mutex_unlock(&bdev_get_queue(ctx->bdev)->blkcg_mutex);
-		ctx->blkg = NULL;
-	}
-
-	if (ctx->bdev) {
-		mutex_unlock(&ctx->bdev->bd_queue->rq_qos_mutex);
-		blkdev_put_no_open(ctx->bdev);
-		ctx->body = NULL;
-		ctx->bdev = NULL;
-	}
-}
-EXPORT_SYMBOL_GPL(blkg_conf_exit);
-
-/*
- * Similar to blkg_conf_exit, but also unfreezes the queue and releases
- * q->elevator_lock. Should be used when blkg_conf_open_bdev_frozen
- * is used to open the bdev.
- */
-void blkg_conf_exit_frozen(struct blkg_conf_ctx *ctx, unsigned long memflags)
-{
-	if (ctx->bdev) {
-		struct request_queue *q = ctx->bdev->bd_queue;
-
-		blkg_conf_exit(ctx);
-		mutex_unlock(&q->elevator_lock);
-		blk_mq_unfreeze_queue(q, memflags);
-	}
-}
-
 static void blkg_iostat_add(struct blkg_iostat *dst, struct blkg_iostat *src)
 {
 	int i;
diff --git a/block/blk-cgroup.h b/block/blk-cgroup.h
index c3d16d52c275..aec801255821 100644
--- a/block/blk-cgroup.h
+++ b/block/blk-cgroup.h
@@ -221,12 +221,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);
-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);
-void blkg_conf_exit(struct blkg_conf_ctx *ctx);
-void blkg_conf_exit_frozen(struct blkg_conf_ctx *ctx, unsigned long memflags);
 void blkg_conf_end(struct blkg_conf_ctx *ctx);
 int blkg_conf_start(struct blkcg *blkcg, struct blkg_conf_ctx *ctx);
 
-- 
2.51.0


      parent reply	other threads:[~2025-10-10  9:15 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-10-10  9:14 [PATCH v2 00/19] blk-cgroup: convert to use blkcg_mutex for protection Yu Kuai
2025-10-10  9:14 ` [PATCH v2 01/19] blk-cgroup: protect iterating blkgs with blkcg->lock in blkcg_print_stat() Yu Kuai
2025-10-10  9:14 ` [PATCH v2 02/19] blk-cgroup: delay freeing policy data after rcu grace period Yu Kuai
2025-10-10  9:14 ` [PATCH v2 03/19] blk-cgroup: don't nest queue_lock under rcu in blkcg_print_blkgs() Yu Kuai
2025-10-10  9:14 ` [PATCH v2 04/19] blk-cgroup: don't nest queue_lock under rcu in blkg_lookup_create() Yu Kuai
2025-10-10  9:14 ` [PATCH v2 05/19] blk-cgroup: don't nest queu_lock under rcu in bio_associate_blkg() Yu Kuai
2025-10-10  9:14 ` [PATCH v2 06/19] blk-cgroup: don't nest queue_lock under blkcg->lock in blkcg_destroy_blkgs() Yu Kuai
2025-10-10  9:14 ` [PATCH v2 07/19] mm/page_io: don't nest queue_lock under rcu in bio_associate_blkg_from_page() Yu Kuai
2025-10-10  9:14 ` [PATCH v2 08/19] block, bfq: don't grab queue_lock to initialize bfq Yu Kuai
2025-10-10  9:14 ` [PATCH v2 09/19] blk-cgroup: convert to protect blkgs with blkcg_mutex Yu Kuai
2025-10-10  9:14 ` [PATCH v2 10/19] blk-cgroup: remove radix_tree_preload() Yu Kuai
2025-10-10  9:14 ` [PATCH v2 11/19] blk-cgroup: remove preallocate blkg for blkg_create() Yu Kuai
2025-10-10  9:14 ` [PATCH v2 12/19] blk-throttle: fix possible deadlock due to queue_lock in timer Yu Kuai
2025-10-10  9:14 ` [PATCH v2 13/19] blk-cgroup: add new blkg configuration helpers Yu Kuai
2025-10-10  9:14 ` [PATCH v2 14/19] blk-cgroup: factor out a helper __blkg_activate_policy() Yu Kuai
2025-10-10  9:14 ` [PATCH v2 15/19] blk-throttle: convert to use blkg_conf_{start, end} Yu Kuai
2025-10-10  9:14 ` [PATCH v2 16/19] block, bfq: " Yu Kuai
2025-10-10  9:14 ` [PATCH v2 17/19] blk-iolatency: " Yu Kuai
2025-10-10  9:14 ` [PATCH v2 18/19] blk-iocost: " Yu Kuai
2025-10-10  9:14 ` Yu Kuai [this message]

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=20251010091446.3048529-20-yukuai@kernel.org \
    --to=yukuai@kernel.org \
    --cc=axboe@kernel.dk \
    --cc=bvanassche@acm.org \
    --cc=cgroups@vger.kernel.org \
    --cc=hch@lst.de \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=ming.lei@redhat.com \
    --cc=nilay@linux.ibm.com \
    --cc=tj@kernel.org \
    --cc=yukuai3@huawei.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

all inboxes | Powered by JetHome®