Re: [PATCH v2] blk-mq: fix incorrect blk_status_t casts

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

 



On 5/18/22 05:45, Vasily Averin wrote:
> Fixes sparse warnings:
> block/blk-mq.c:1163:36: sparse:
>   warning: cast from restricted blk_status_t
> block/blk-mq.c:1251:17: sparse:
>   warning: cast to restricted blk_status_t
> 
> blk_status_t type is bitwaise and requires __force for any casts.
> 
> Signed-off-by: Vasily Averin <vvs@xxxxxxxxxx>
> ---
> v2: introduced request_blk_status_en/decode helpers
> 	thanks Christoph Hellwig for the hint
> ---
>   block/blk-mq.c | 15 +++++++++++++--
>   1 file changed, 13 insertions(+), 2 deletions(-)
> 
> diff --git a/block/blk-mq.c b/block/blk-mq.c
> index 84d749511f55..8f067b021af3 100644
> --- a/block/blk-mq.c
> +++ b/block/blk-mq.c
> @@ -1151,6 +1151,16 @@ void blk_mq_start_request(struct request *rq)
>   }
>   EXPORT_SYMBOL(blk_mq_start_request);
>   
> +static void *request_blk_status_encode(blk_status_t status)
> +{
> +	return (void *)(__force uintptr_t)status;
> +}
> +
> +static blk_status_t request_blk_status_decode(void *ptr)
> +{
> +	return (__force blk_status_t)(uintptr_t)ptr;
> +}
> +

why not use blk_sts_encode() and blk_sts_decode() since both the
functions neither accept request parameter nor return request in any
form ?

-ck

>   /**
>    * blk_end_sync_rq - executes a completion event on a request
>    * @rq: request to complete
> @@ -1160,7 +1170,7 @@ static void blk_end_sync_rq(struct request *rq, blk_status_t error)
>   {
>   	struct completion *waiting = rq->end_io_data;
>   
> -	rq->end_io_data = (void *)(uintptr_t)error;
> +	rq->end_io_data = request_blk_status_encode(error);
>   
>   	/*
>   	 * complete last, if this is a stack request the process (and thus
> @@ -1228,6 +1238,7 @@ static void blk_rq_poll_completion(struct request *rq, struct completion *wait)
>    *    for execution and wait for completion.
>    * Return: The blk_status_t result provided to blk_mq_end_request().
>    */
> +

white line ?

>   blk_status_t blk_execute_rq(struct request *rq, bool at_head)
>   {
>   	DECLARE_COMPLETION_ONSTACK(wait);
> @@ -1248,7 +1259,7 @@ blk_status_t blk_execute_rq(struct request *rq, bool at_head)
>   	else
>   		wait_for_completion_io(&wait);
>   
> -	return (blk_status_t)(uintptr_t)rq->end_io_data;
> +	return request_blk_status_decode(rq->end_io_data);
>   }
>   EXPORT_SYMBOL(blk_execute_rq);
>   




[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