diff mbox series

[for-6.12,4/4] block, bfq: use bfq_reassign_last_bfqq() in bfq_bfqq_move()

Message ID 20240902130329.3787024-5-yukuai1@huaweicloud.com (mailing list archive)
State New, archived
Headers show
Series block, bfq: fix corner cases related to bfqq merging | expand

Commit Message

Yu Kuai Sept. 2, 2024, 1:03 p.m. UTC
From: Yu Kuai <yukuai3@huawei.com>

Instead of open coding it, there are no functional changes.

Signed-off-by: Yu Kuai <yukuai3@huawei.com>
---
 block/bfq-cgroup.c  | 7 +------
 block/bfq-iosched.c | 4 ++--
 block/bfq-iosched.h | 2 ++
 3 files changed, 5 insertions(+), 8 deletions(-)

Comments

Jan Kara Sept. 4, 2024, 12:22 p.m. UTC | #1
On Mon 02-09-24 21:03:29, Yu Kuai wrote:
> From: Yu Kuai <yukuai3@huawei.com>
> 
> Instead of open coding it, there are no functional changes.
> 
> Signed-off-by: Yu Kuai <yukuai3@huawei.com>

Looks good. Feel free to add:

Reviewed-by: Jan Kara <jack@suse.cz>

								Honza

> ---
>  block/bfq-cgroup.c  | 7 +------
>  block/bfq-iosched.c | 4 ++--
>  block/bfq-iosched.h | 2 ++
>  3 files changed, 5 insertions(+), 8 deletions(-)
> 
> diff --git a/block/bfq-cgroup.c b/block/bfq-cgroup.c
> index b758693697c0..9fb9f3533150 100644
> --- a/block/bfq-cgroup.c
> +++ b/block/bfq-cgroup.c
> @@ -679,12 +679,7 @@ void bfq_bfqq_move(struct bfq_data *bfqd, struct bfq_queue *bfqq,
>  		bfq_put_idle_entity(bfq_entity_service_tree(entity), entity);
>  	bfqg_and_blkg_put(old_parent);
>  
> -	if (entity->parent &&
> -	    entity->parent->last_bfqq_created == bfqq)
> -		entity->parent->last_bfqq_created = NULL;
> -	else if (bfqd->last_bfqq_created == bfqq)
> -		bfqd->last_bfqq_created = NULL;
> -
> +	bfq_reassign_last_bfqq(bfqq, NULL);
>  	entity->parent = bfqg->my_entity;
>  	entity->sched_data = &bfqg->sched_data;
>  	/* pin down bfqg and its associated blkg  */
> diff --git a/block/bfq-iosched.c b/block/bfq-iosched.c
> index ca766b7d5560..d1bf2b8a3576 100644
> --- a/block/bfq-iosched.c
> +++ b/block/bfq-iosched.c
> @@ -3097,8 +3097,8 @@ static void bfq_bfqq_save_state(struct bfq_queue *bfqq)
>  }
>  
>  
> -static void
> -bfq_reassign_last_bfqq(struct bfq_queue *cur_bfqq, struct bfq_queue *new_bfqq)
> +void bfq_reassign_last_bfqq(struct bfq_queue *cur_bfqq,
> +			    struct bfq_queue *new_bfqq)
>  {
>  	if (cur_bfqq->entity.parent &&
>  	    cur_bfqq->entity.parent->last_bfqq_created == cur_bfqq)
> diff --git a/block/bfq-iosched.h b/block/bfq-iosched.h
> index 08ddf2cfae5b..e16d96e2367b 100644
> --- a/block/bfq-iosched.h
> +++ b/block/bfq-iosched.h
> @@ -1156,6 +1156,8 @@ void bfq_del_bfqq_busy(struct bfq_queue *bfqq, bool expiration);
>  void bfq_add_bfqq_busy(struct bfq_queue *bfqq);
>  void bfq_add_bfqq_in_groups_with_pending_reqs(struct bfq_queue *bfqq);
>  void bfq_del_bfqq_in_groups_with_pending_reqs(struct bfq_queue *bfqq);
> +void bfq_reassign_last_bfqq(struct bfq_queue *cur_bfqq,
> +			    struct bfq_queue *new_bfqq);
>  
>  /* --------------- end of interface of B-WF2Q+ ---------------- */
>  
> -- 
> 2.39.2
>
diff mbox series

Patch

diff --git a/block/bfq-cgroup.c b/block/bfq-cgroup.c
index b758693697c0..9fb9f3533150 100644
--- a/block/bfq-cgroup.c
+++ b/block/bfq-cgroup.c
@@ -679,12 +679,7 @@  void bfq_bfqq_move(struct bfq_data *bfqd, struct bfq_queue *bfqq,
 		bfq_put_idle_entity(bfq_entity_service_tree(entity), entity);
 	bfqg_and_blkg_put(old_parent);
 
-	if (entity->parent &&
-	    entity->parent->last_bfqq_created == bfqq)
-		entity->parent->last_bfqq_created = NULL;
-	else if (bfqd->last_bfqq_created == bfqq)
-		bfqd->last_bfqq_created = NULL;
-
+	bfq_reassign_last_bfqq(bfqq, NULL);
 	entity->parent = bfqg->my_entity;
 	entity->sched_data = &bfqg->sched_data;
 	/* pin down bfqg and its associated blkg  */
diff --git a/block/bfq-iosched.c b/block/bfq-iosched.c
index ca766b7d5560..d1bf2b8a3576 100644
--- a/block/bfq-iosched.c
+++ b/block/bfq-iosched.c
@@ -3097,8 +3097,8 @@  static void bfq_bfqq_save_state(struct bfq_queue *bfqq)
 }
 
 
-static void
-bfq_reassign_last_bfqq(struct bfq_queue *cur_bfqq, struct bfq_queue *new_bfqq)
+void bfq_reassign_last_bfqq(struct bfq_queue *cur_bfqq,
+			    struct bfq_queue *new_bfqq)
 {
 	if (cur_bfqq->entity.parent &&
 	    cur_bfqq->entity.parent->last_bfqq_created == cur_bfqq)
diff --git a/block/bfq-iosched.h b/block/bfq-iosched.h
index 08ddf2cfae5b..e16d96e2367b 100644
--- a/block/bfq-iosched.h
+++ b/block/bfq-iosched.h
@@ -1156,6 +1156,8 @@  void bfq_del_bfqq_busy(struct bfq_queue *bfqq, bool expiration);
 void bfq_add_bfqq_busy(struct bfq_queue *bfqq);
 void bfq_add_bfqq_in_groups_with_pending_reqs(struct bfq_queue *bfqq);
 void bfq_del_bfqq_in_groups_with_pending_reqs(struct bfq_queue *bfqq);
+void bfq_reassign_last_bfqq(struct bfq_queue *cur_bfqq,
+			    struct bfq_queue *new_bfqq);
 
 /* --------------- end of interface of B-WF2Q+ ---------------- */