@@ -309,8 +309,7 @@ struct bfq_group *bfqq_group(struct bfq_queue *bfqq)
{
struct bfq_entity *group_entity = bfqq->entity.parent;
- return group_entity ? container_of(group_entity, struct bfq_group,
- entity) :
+ return group_entity ? bfq_entity_to_bfqg(group_entity) :
bfqq->bfqd->root_group;
}
@@ -610,8 +609,7 @@ struct bfq_group *bfq_find_set_group(struct bfq_data *bfqd,
*/
entity = &bfqg->entity;
for_each_entity(entity) {
- struct bfq_group *curr_bfqg = container_of(entity,
- struct bfq_group, entity);
+ struct bfq_group *curr_bfqg = bfq_entity_to_bfqg(entity);
if (curr_bfqg != bfqd->root_group) {
parent = bfqg_parent(curr_bfqg);
if (!parent)
@@ -941,6 +941,7 @@ struct bfq_group {
#endif
struct bfq_queue *bfq_entity_to_bfqq(struct bfq_entity *entity);
+struct bfq_group *bfq_entity_to_bfqg(struct bfq_entity *entity);
/* --------------- main algorithm interface ----------------- */
@@ -149,7 +149,7 @@ struct bfq_group *bfq_bfqq_to_bfqg(struct bfq_queue *bfqq)
if (!group_entity)
group_entity = &bfqq->bfqd->root_group->entity;
- return container_of(group_entity, struct bfq_group, entity);
+ return bfq_entity_to_bfqg(group_entity);
}
/*
@@ -208,7 +208,7 @@ static bool bfq_no_longer_next_in_service(struct bfq_entity *entity)
if (bfq_entity_to_bfqq(entity))
return true;
- bfqg = container_of(entity, struct bfq_group, entity);
+ bfqg = bfq_entity_to_bfqg(entity);
/*
* The field active_entities does not always contain the
@@ -266,6 +266,15 @@ struct bfq_queue *bfq_entity_to_bfqq(struct bfq_entity *entity)
return bfqq;
}
+struct bfq_group *bfq_entity_to_bfqg(struct bfq_entity *entity)
+{
+ struct bfq_group *bfqg = NULL;
+
+ if (entity->my_sched_data)
+ bfqg = container_of(entity, struct bfq_group, entity);
+
+ return bfqg;
+}
/**
* bfq_delta - map service into the virtual time domain.
@@ -1001,8 +1010,7 @@ static void __bfq_activate_entity(struct bfq_entity *entity,
#ifdef CONFIG_BFQ_GROUP_IOSCHED
if (!bfq_entity_to_bfqq(entity)) { /* bfq_group */
- struct bfq_group *bfqg =
- container_of(entity, struct bfq_group, entity);
+ struct bfq_group *bfqg = bfq_entity_to_bfqg(entity);
struct bfq_data *bfqd = bfqg->bfqd;
if (!entity->in_groups_with_pending_reqs) {