Commit f37bf75c authored by Yu Kuai's avatar Yu Kuai Committed by Jens Axboe
Browse files

block, bfq: cleanup 'bfqg->online'



After commit dfd6200a ("blk-cgroup: support to track if policy is
online"), there is no need to do this again in bfq.

However, 'pd->online' is not protected by 'bfqd->lock', in order to make
sure bfq won't see that 'pd->online' is still set after bfq_pd_offline(),
clear it before bfq_pd_offline() is called. This is fine because other
polices doesn't use 'pd->online' and bfq_pd_offline() will move active
bfqq to root cgroup anyway.

Signed-off-by: default avatarYu Kuai <yukuai3@huawei.com>
Reviewed-by: default avatarJan Kara <jack@suse.cz>
Link: https://lore.kernel.org/r/20230202134913.2364549-1-yukuai1@huaweicloud.com


Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
parent 455944e4
Loading
Loading
Loading
Loading
+1 −3
Original line number Original line Diff line number Diff line
@@ -551,7 +551,6 @@ static void bfq_pd_init(struct blkg_policy_data *pd)
	bfqg->bfqd = bfqd;
	bfqg->bfqd = bfqd;
	bfqg->active_entities = 0;
	bfqg->active_entities = 0;
	bfqg->num_queues_with_pending_reqs = 0;
	bfqg->num_queues_with_pending_reqs = 0;
	bfqg->online = true;
	bfqg->rq_pos_tree = RB_ROOT;
	bfqg->rq_pos_tree = RB_ROOT;
}
}


@@ -614,7 +613,7 @@ struct bfq_group *bfq_bio_bfqg(struct bfq_data *bfqd, struct bio *bio)
			continue;
			continue;
		}
		}
		bfqg = blkg_to_bfqg(blkg);
		bfqg = blkg_to_bfqg(blkg);
		if (bfqg->online) {
		if (bfqg->pd.online) {
			bio_associate_blkg_from_css(bio, &blkg->blkcg->css);
			bio_associate_blkg_from_css(bio, &blkg->blkcg->css);
			return bfqg;
			return bfqg;
		}
		}
@@ -985,7 +984,6 @@ static void bfq_pd_offline(struct blkg_policy_data *pd)


put_async_queues:
put_async_queues:
	bfq_put_async_queues(bfqd, bfqg);
	bfq_put_async_queues(bfqd, bfqg);
	bfqg->online = false;


	spin_unlock_irqrestore(&bfqd->lock, flags);
	spin_unlock_irqrestore(&bfqd->lock, flags);
	/*
	/*
+0 −2
Original line number Original line Diff line number Diff line
@@ -1009,8 +1009,6 @@ struct bfq_group {


	/* reference counter (see comments in bfq_bic_update_cgroup) */
	/* reference counter (see comments in bfq_bic_update_cgroup) */
	refcount_t ref;
	refcount_t ref;
	/* Is bfq_group still online? */
	bool online;


	struct bfq_entity entity;
	struct bfq_entity entity;
	struct bfq_sched_data sched_data;
	struct bfq_sched_data sched_data;
+1 −1
Original line number Original line Diff line number Diff line
@@ -479,9 +479,9 @@ static void blkg_destroy(struct blkcg_gq *blkg)
		struct blkcg_policy *pol = blkcg_policy[i];
		struct blkcg_policy *pol = blkcg_policy[i];


		if (blkg->pd[i] && blkg->pd[i]->online) {
		if (blkg->pd[i] && blkg->pd[i]->online) {
			blkg->pd[i]->online = false;
			if (pol->pd_offline_fn)
			if (pol->pd_offline_fn)
				pol->pd_offline_fn(blkg->pd[i]);
				pol->pd_offline_fn(blkg->pd[i]);
			blkg->pd[i]->online = false;
		}
		}
	}
	}