Re: [RFC PATCH 2/2] blk-mq: blk_mq_tag_to_rq() always return null for sched_tags

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 2021/03/01 11:12, Yufen Yu wrote:
> We just set hctx->tags->rqs[tag] when get driver tag, but will
> not set hctx->sched_tags->rqs[tag] when get sched tag.
> So, blk_mq_tag_to_rq() always return NULL for sched_tags.
> 
> Signed-off-by: Yufen Yu <yuyufen@xxxxxxxxxx>
> ---
>  block/blk-mq.c | 14 +++-----------
>  1 file changed, 3 insertions(+), 11 deletions(-)
> 
> diff --git a/block/blk-mq.c b/block/blk-mq.c
> index 5362a7958b74..424afe112b58 100644
> --- a/block/blk-mq.c
> +++ b/block/blk-mq.c
> @@ -846,6 +846,7 @@ static int blk_mq_test_tag_bit(struct blk_mq_tags *tags, unsigned int tag)
>  
>  struct request *blk_mq_tag_to_rq(struct blk_mq_tags *tags, unsigned int tag)
>  {
> +	/* if tags is hctx->sched_tags, it always return NULL */
>  	if (tag < tags->nr_tags && blk_mq_test_tag_bit(tags, tag)) {
>  		prefetch(tags->rqs[tag]);
>  		return tags->rqs[tag];
> @@ -3845,17 +3846,8 @@ static bool blk_mq_poll_hybrid(struct request_queue *q,
>  
>  	if (!blk_qc_t_is_internal(cookie))
>  		rq = blk_mq_tag_to_rq(hctx->tags, blk_qc_t_to_tag(cookie));
> -	else {
> -		rq = blk_mq_tag_to_rq(hctx->sched_tags, blk_qc_t_to_tag(cookie));
> -		/*
> -		 * With scheduling, if the request has completed, we'll
> -		 * get a NULL return here, as we clear the sched tag when
> -		 * that happens. The request still remains valid, like always,
> -		 * so we should be safe with just the NULL check.
> -		 */
> -		if (!rq)
> -			return false;
> -	}
> +	else
> +		return false;

Reverse the if condition to avoid the "else". That will nicely cleanup the code.

>  
>  	return blk_mq_poll_hybrid_sleep(q, rq);
>  }
> 


-- 
Damien Le Moal
Western Digital Research




[Index of Archives]     [Linux RAID]     [Linux SCSI]     [Linux ATA RAID]     [IDE]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Device Mapper]

  Powered by Linux