On Wed, Jul 26, 2023 at 06:23:05AM -0700, Christoph Hellwig wrote:
On Mon, Jul 24, 2023 at 10:43:12PM -0400, Kent Overstreet wrote:
quoted
Doing the blk-cgroup association at bio alloc time sounds broken to me,
because of stacking block devices - why was the association not done at
generic_make_request() time?
Because blk-cgroup not only works at the lowest level in the stack,
but also for stackable block devices. It's not a design decision I
particularly agree with, but it's been there forever.
You're setting the association only to the highest block device in the
stack - how on earth is it supposed to work with anything lower?
And looking at bio_associate_blkg(), this code looks completely broken.
It's checking bio->bi_blkg, but that's just been set to NULL in
bio_init().
And this is your code, so I think you need to go over this again.
Anyways, bio_associate_blkg() is also called by bio_set_dev(), which
means passing the block device to bio_init() was a completely pointless
change. bcachefs uses bio_set_dev(), so everything is fine.