Re: [PATCH 07/10] bcache: use bvec_kmap_local in bio_csum

Coly Li
2022-03-05T14:02:29Z

On 3/3/22 7:19 PM, Christoph Hellwig wrote:
> Using local kmaps slightly reduces the chances to stray writes, and
> the bvec interface cleans up the code a little bit.
>
> Signed-off-by: Christoph Hellwig <hch@lst.de>

Acked-by: Coly Li <colyli@suse.de>

Thanks.

Coly Li

> ---
> drivers/md/bcache/request.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/md/bcache/request.c b/drivers/md/bcache/request.c
> index 6869e010475a3..fdd0194f84dd0 100644
> --- a/drivers/md/bcache/request.c
> +++ b/drivers/md/bcache/request.c
> @@ -44,10 +44,10 @@ static void bio_csum(struct bio *bio, struct bkey *k)
> uint64_t csum = 0;
>
> bio_for_each_segment(bv, bio, iter) {
> - void *d = kmap(bv.bv_page) + bv.bv_offset;
> + void *d = bvec_kmap_local(&bv);
>
> csum = crc64_be(csum, d, bv.bv_len);
> - kunmap(bv.bv_page);
> + kunmap_local(d);
> }
>
> k->ptr[KEY_PTRS(k)] = csum & (~0ULL >> 1);