[1/2] blk-integrity: add rq_integrity_payload_size helper

Message ID 20230412052133epcms2p4d52e78b4fc1bc6ac1cc9d399a0378fce@epcms2p4
State New
Headers
Series Fix NVMe metadata mapping size for integrity |

Commit Message

Jinyoung Choi April 12, 2023, 5:21 a.m. UTC
  This provides a nice shortcut to get the size of the integrity data
for the driver like NVMe that only support a single integrity segment.

Signed-off-by: Jinyoung Choi <j-young.choi@samsung.com>
---
 include/linux/blk-integrity.h | 7 +++++++
 1 file changed, 7 insertions(+)
  

Comments

Chaitanya Kulkarni April 12, 2023, 5:41 a.m. UTC | #1
On 4/11/23 22:21, Jinyoung CHOI wrote:
> This provides a nice shortcut to get the size of the integrity data
> for the driver like NVMe that only support a single integrity segment.
>
> Signed-off-by: Jinyoung Choi <j-young.choi@samsung.com>
> ---
>   include/linux/blk-integrity.h | 7 +++++++
>   1 file changed, 7 insertions(+)
>
> diff --git a/include/linux/blk-integrity.h b/include/linux/blk-integrity.h
> index 378b2459efe2..abf1923f4aa5 100644
> --- a/include/linux/blk-integrity.h
> +++ b/include/linux/blk-integrity.h
> @@ -114,6 +114,13 @@ static inline struct bio_vec *rq_integrity_vec(struct request *rq)
>   		return NULL;
>   	return rq->bio->bi_integrity->bip_vec;
>   }
> +
> +static inline unsigned int rq_integrity_payload_size(struct request *rq)
> +{
> +	if (WARN_ON_ONCE(queue_max_integrity_segments(rq->q) > 1))
> +		return 0;
> +	return rq->bio->bi_integrity->bip_iter.bi_size;
> +}
>   #else /* CONFIG_BLK_DEV_INTEGRITY */
>   static inline int blk_rq_count_integrity_sg(struct request_queue *q,
>   					    struct bio *b)

from the comments that I got in the past, you should only be adding
a helper in the patch that is actually using it.

-ck
  
Chaitanya Kulkarni April 12, 2023, 5:42 a.m. UTC | #2
>> +
>> +static inline unsigned int rq_integrity_payload_size(struct request 
>> *rq)
>> +{
>> +    if (WARN_ON_ONCE(queue_max_integrity_segments(rq->q) > 1))
>> +        return 0;
>> +    return rq->bio->bi_integrity->bip_iter.bi_size;
>> +}
>>   #else /* CONFIG_BLK_DEV_INTEGRITY */
>>   static inline int blk_rq_count_integrity_sg(struct request_queue *q,
>>                           struct bio *b)
>
> from the comments that I got in the past, you should only be adding
> a helper in the patch that is actually using it.
>
> -ck
>
>

disregard my comment, I think this is correct looking at the next patch...

-ck
  
Christoph Hellwig April 12, 2023, 6:53 a.m. UTC | #3
> +	if (WARN_ON_ONCE(queue_max_integrity_segments(rq->q) > 1))
> +		return 0;

This should work for multiple segments as well.
  
Jinyoung Choi April 12, 2023, 8:55 a.m. UTC | #4
>>> +
>>> +static inline unsigned int rq_integrity_payload_size(struct request 
>>> *rq)
>>> +{
>>> +    if (WARN_ON_ONCE(queue_max_integrity_segments(rq->q) > 1))
>>> +        return 0;
>>> +    return rq->bio->bi_integrity->bip_iter.bi_size;
>>> +}
>>>   #else /* CONFIG_BLK_DEV_INTEGRITY */
>>>   static inline int blk_rq_count_integrity_sg(struct request_queue *q,
>>>                           struct bio *b)
>>
>> from the comments that I got in the past, you should only be adding
>> a helper in the patch that is actually using it.
>>
>> -ck
>>
>>
>
> disregard my comment, I think this is correct looking at the next patch...
>
> -ck

OK Thanks for your review :)
I sent it to the wrong email address. (result from get_maintainer.pl)
I will update your email address for cc.

Kind Regards,
Jinyoung.
  

Patch

diff --git a/include/linux/blk-integrity.h b/include/linux/blk-integrity.h
index 378b2459efe2..abf1923f4aa5 100644
--- a/include/linux/blk-integrity.h
+++ b/include/linux/blk-integrity.h
@@ -114,6 +114,13 @@  static inline struct bio_vec *rq_integrity_vec(struct request *rq)
 		return NULL;
 	return rq->bio->bi_integrity->bip_vec;
 }
+
+static inline unsigned int rq_integrity_payload_size(struct request *rq)
+{
+	if (WARN_ON_ONCE(queue_max_integrity_segments(rq->q) > 1))
+		return 0;
+	return rq->bio->bi_integrity->bip_iter.bi_size;
+}
 #else /* CONFIG_BLK_DEV_INTEGRITY */
 static inline int blk_rq_count_integrity_sg(struct request_queue *q,
 					    struct bio *b)