Thread (11 messages) flat view 11 messages, 4 authors, 1d ago

Re: [PATCH v2 2/3] blk-cgroup: store blkcg in bio instead of blkg

From: Christoph Hellwig <hch@lst.de>
Date: 2026-09-15 06:49:57
Also in: cgroups, dm-devel, gfs2, linux-block, linux-doc, linux-fsdevel, linux-mm, linux-raid, lkml, llvm

On Sun, Sep 13, 2026 at 02:54:39PM +0800, Yu Kuai wrote:
quoted hunk ↗ jump to hunk
@@ -6243,10 +6245,17 @@ static void bfq_insert_request(struct blk_mq_hw_ctx *hctx, struct request *rq,
 	bool idle_timer_disabled = false;
 	blk_opf_t cmd_flags;
 	LIST_HEAD(free);
 
 #ifdef CONFIG_BFQ_GROUP_IOSCHED
+	/*
+	 * Pin the blkg used to look up bfqg.  If this is the first IO for
+	 * the blkcg on this queue, create the bfqg before holding bfqd->lock.
+	 */
+	if (rq->bio && !bio_flagged(rq->bio, BIO_BLKG_REF))
+		bio_blkg(rq->bio);
Can rq->bio be NULL here?  flush or empty passthrough request should
never enter the scheuler.
 	if (!cgroup_subsys_on_dfl(io_cgrp_subsys) && rq->bio)
 		bfqg_stats_update_legacy_io(q, rq);
But I guess given that the code below checks it, we should at least
be consistent, so I guess it is better to keep it for now.
 
 static inline void dm_bio_record(struct dm_bio_details *bd, struct bio *bio)
 {
 	bd->bi_bdev = bio->bi_bdev;
-	bd->bi_flags = bio->bi_flags;
+	/* Restoring an ownership bit cannot recreate the associated reference. */
+	bd->bi_flags = bio->bi_flags & ~(1U << BIO_BLKG_REF);
I have a bit of a hard time parsing this, the line also is overly
long.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help