remove opencoded kmap of bio_vecs v2
Subsystems (9)
Hi all,
this series replaces various open coded kmaps of bio_vecs with higher level helpers that use kmap_local_page underneath. It does not touch other kmap calls in these drivers even if those should probably also be switched to use kmap_local eventually.
Changes since v1:
- fix missing switches to kunmap_local
PATCH 1/10 iss-simdisk: use bvec_kmap_local in simdisk_submit_bio
Using local kmaps slightly reduces the chances to stray writes, and the bvec interface cleans up the code a little bit.
--- arch/xtensa/platforms/iss/simdisk.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
arch/xtensa/platforms/iss/simdisk.c +2 -2
@@ -108,13 +108,13 @@ static void simdisk_submit_bio(struct bio *bio)sector_t sector = bio->bi_iter.bi_sector;bio_for_each_segment (bvec, bio, iter) { -char *buffer =kmap_atomic (bvec.bv_page) + bvec.bv_offset; +char *buffer =bvec_kmap_local (&bvec);unsigned len = bvec.bv_len >>SECTOR_SHIFT ;simdisk_transfer (dev, sector, len, buffer,bio_data_dir (bio) ==WRITE ); sector += len; -kunmap_atomic (buffer); +kunmap_local (buffer); }bio_endio (bio);
Signature · 1 line
2.30.2
Re: [PATCH 01/10] iss-simdisk: use bvec_kmap_local in simdisk_submit_bio
Quoted 9 lines · Christoph Hellwig
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 <[email protected]>Reviewed-by Ira Weiny <[email protected]>--- arch/xtensa/platforms/iss/simdisk.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
Signature · 2 lines
Thanks. -- Max
Re: [PATCH 01/10] iss-simdisk: use bvec_kmap_local in simdisk_submit_bio
In reply to Christoph HellwigQuoted 4 lines · Christoph Hellwig
Using local kmaps slightly reduces the chances to stray writes, and the bvec interface cleans up the code a little bit.
Applied, thanks!
[01/10] iss-simdisk: use bvec_kmap_local in simdisk_submit_bio
commit: 143a70b8b4300faa92ad82468f65dccd440e7957
[02/10] aoe: use bvec_kmap_local in bvcpy
commit: b7ab4611b6c793100197abc93e069d6f9aab7960
[03/10] zram: use memcpy_to_bvec in zram_bvec_read
commit: b3bd0a8a74ab970cc1cf0849e66bd0906741105b
[04/10] zram: use memcpy_from_bvec in zram_bvec_write
commit: bd3d3203eb84d08a6daef805efe9316b79d3bf3c
[05/10] nvdimm-blk: use bvec_kmap_local in nd_blk_rw_integrity
commit: 20072ec828640b7d23a0cfdbccf0dea48e77ba3e
[06/10] nvdimm-btt: use bvec_kmap_local in btt_rw_integrity
commit: 3205190655ea56ea5e00815eeff4dab2bde0af80
[07/10] bcache: use bvec_kmap_local in bio_csum
commit: 07fee7aba5472d0e65345146a68b4bd1a8b656c3
[08/10] drbd: use bvec_kmap_local in drbd_csum_bio
commit: 472278508dce25316e806e45778658c3e4b353b3
[09/10] drbd: use bvec_kmap_local in recv_dless_read
commit: 3eddaa60b8411c135d1c71090dea9b59ff3f2e26
[10/10] floppy: use memcpy_{to,from}_bvec
commit: 13d4ef0f66b7ee9415e101e213acaf94a0cb28eeBest regards,
Signature · 1 line
Jens Axboe
PATCH 2/10 aoe: use bvec_kmap_local in bvcpy
In reply to Christoph HellwigUsing local kmaps slightly reduces the chances to stray writes, and the bvec interface cleans up the code a little bit.
--- drivers/block/aoe/aoecmd.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/block/aoe/aoecmd.c +2 -2
@@ -1018,9 +1018,9 @@ bvcpy(struct sk_buff *skb, struct bio *bio, struct bvec_iter iter, long cnt) iter.bi_size = cnt;__bio_for_each_segment (bv, bio, iter, iter) { -char *p =kmap_atomic (bv.bv_page) + bv.bv_offset; +char *p =bvec_kmap_local (&bv);skb_copy_bits (skb, soff, p, bv.bv_len); -kunmap_atomic (p); +kunmap_local (p); soff += bv.bv_len; } }
Signature · 1 line
2.30.2
PATCH 3/10 zram: use memcpy_to_bvec in zram_bvec_read
In reply to Christoph HellwigUse the proper helper instead of open coding the copy.
--- drivers/block/zram/zram_drv.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/block/zram/zram_drv.c +1 -3
@@ -1331,12 +1331,10 @@ static int zram_bvec_read(struct zram *zram, struct bio_vec *bvec, goto out;if (is_partial_io (bvec)) { -void *dst =kmap_atomic (bvec->bv_page);void *src =kmap_atomic (page); -memcpy (dst + bvec->bv_offset, src + offset, bvec->bv_len); +memcpy_to_bvec (bvec, src + offset);kunmap_atomic (src); -kunmap_atomic (dst); } out:if (is_partial_io (bvec))
Signature · 1 line
2.30.2
PATCH 4/10 zram: use memcpy_from_bvec in zram_bvec_write
In reply to Christoph HellwigUse memcpy_from_bvec instead of open coding the logic.
--- drivers/block/zram/zram_drv.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)
drivers/block/zram/zram_drv.c +1 -4
@@ -1465,7 +1465,6 @@ static int zram_bvec_write(struct zram *zram, struct bio_vec *bvec, {int ret;struct page *page =NULL ; -void *src;struct bio_vec vec; vec = *bvec;
@@ -1483,11 +1482,9 @@ static int zram_bvec_write(struct zram *zram, struct bio_vec *bvec,if (ret) goto out; - src =kmap_atomic (bvec->bv_page); dst =kmap_atomic (page); -memcpy (dst + offset, src + bvec->bv_offset, bvec->bv_len); +memcpy_from_bvec (dst + offset, bvec);kunmap_atomic (dst); -kunmap_atomic (src); vec.bv_page = page; vec.bv_len =PAGE_SIZE ;
Signature · 1 line
2.30.2
PATCH 5/10 nvdimm-blk: use bvec_kmap_local in nd_blk_rw_integrity
In reply to Christoph HellwigUsing local kmaps slightly reduces the chances to stray writes, and the bvec interface cleans up the code a little bit.
--- drivers/nvdimm/blk.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)
drivers/nvdimm/blk.c +3 -4
@@ -88,10 +88,9 @@ static int nd_blk_rw_integrity(struct nd_namespace_blk *nsblk,*/ cur_len =min (len, bv.bv_len); - iobuf =kmap_atomic (bv.bv_page); - err = ndbr->do_io (ndbr, dev_offset, iobuf + bv.bv_offset, - cur_len, rw); -kunmap_atomic (iobuf); + iobuf =bvec_kmap_local (&bv); + err = ndbr->do_io (ndbr, dev_offset, iobuf, cur_len, rw); +kunmap_local (iobuf);if (err)return err;
Signature · 1 line
2.30.2
PATCH 6/10 nvdimm-btt: use bvec_kmap_local in btt_rw_integrity
In reply to Christoph HellwigUsing local kmaps slightly reduces the chances to stray writes, and the bvec interface cleans up the code a little bit.
--- drivers/nvdimm/btt.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-)
drivers/nvdimm/btt.c +4 -6
@@ -1163,17 +1163,15 @@ static int btt_rw_integrity(struct btt *btt, struct bio_integrity_payload *bip,*/ cur_len =min (len, bv.bv_len); - mem =kmap_atomic (bv.bv_page); + mem =bvec_kmap_local (&bv);if (rw) - ret =arena_write_bytes (arena, meta_nsoff, - mem + bv.bv_offset, cur_len, + ret =arena_write_bytes (arena, meta_nsoff, mem, cur_len,NVDIMM_IO_ATOMIC );else - ret =arena_read_bytes (arena, meta_nsoff, - mem + bv.bv_offset, cur_len, + ret =arena_read_bytes (arena, meta_nsoff, mem, cur_len,NVDIMM_IO_ATOMIC ); -kunmap_atomic (mem); +kunmap_local (mem);if (ret)return ret;
Signature · 1 line
2.30.2
Re: [PATCH 06/10] nvdimm-btt: use bvec_kmap_local in btt_rw_integrity
Quoted 4 lines · Christoph Hellwig
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 <[email protected]>
Quoted 33 lines
--- drivers/nvdimm/btt.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-)drivers/nvdimm/btt.c +4
-6@@ -1163,17 +1163,15 @@ static int btt_rw_integrity(struct btt *btt, struct bio_integrity_payload *bip,*/ cur_len =min (len, bv.bv_len); - mem =kmap_atomic (bv.bv_page); + mem =bvec_kmap_local (&bv);if (rw) - ret =arena_write_bytes (arena, meta_nsoff, - mem + bv.bv_offset, cur_len, + ret =arena_write_bytes (arena, meta_nsoff, mem, cur_len,NVDIMM_IO_ATOMIC );else - ret =arena_read_bytes (arena, meta_nsoff, - mem + bv.bv_offset, cur_len, + ret =arena_read_bytes (arena, meta_nsoff, mem, cur_len,NVDIMM_IO_ATOMIC ); -kunmap_atomic (mem); +kunmap_local (mem);if (ret)return ret;Signature · 1 line
2.30.2
PATCH 7/10 bcache: use bvec_kmap_local in bio_csum
In reply to Christoph HellwigUsing local kmaps slightly reduces the chances to stray writes, and the bvec interface cleans up the code a little bit.
--- drivers/md/bcache/request.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/md/bcache/request.c +2 -2
@@ -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 );
Signature · 1 line
2.30.2
Re: [PATCH 07/10] bcache: use bvec_kmap_local in bio_csum
Quoted 4 lines · Christoph Hellwig
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 <[email protected]>
Quoted 24 lines
--- drivers/md/bcache/request.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)drivers/md/bcache/request.c +2
-2@@ -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 );Signature · 1 line
2.30.2
Re: [PATCH 07/10] bcache: use bvec_kmap_local in bio_csum
In reply to Christoph HellwigQuoted 4 lines · Christoph Hellwig
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 <[email protected]>
Thanks.
Coly Li
Quoted 21 lines
--- drivers/md/bcache/request.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)drivers/md/bcache/request.c +2
-2@@ -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 );
PATCH 8/10 drbd: use bvec_kmap_local in drbd_csum_bio
In reply to Christoph HellwigUsing local kmaps slightly reduces the chances to stray writes, and the bvec interface cleans up the code a little bit.
--- drivers/block/drbd/drbd_worker.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/block/drbd/drbd_worker.c +3 -3
@@ -326,9 +326,9 @@ void drbd_csum_bio(struct crypto_shash *tfm, struct bio *bio, void *digest)bio_for_each_segment (bvec, bio, iter) {u8 *src; - src =kmap_atomic (bvec.bv_page); -crypto_shash_update (desc, src + bvec.bv_offset, bvec.bv_len); -kunmap_atomic (src); + src =bvec_kmap_local (&bvec); +crypto_shash_update (desc, src, bvec.bv_len); +kunmap_local (src);/* REQ_OP_WRITE_SAME has only one segment, * checksum the payload only once. */
Signature · 1 line
2.30.2
PATCH 9/10 drbd: use bvec_kmap_local in recv_dless_read
In reply to Christoph HellwigUsing local kmaps slightly reduces the chances to stray writes, and the bvec interface cleans up the code a little bit.
--- drivers/block/drbd/drbd_receiver.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/block/drbd/drbd_receiver.c +2 -2
@@ -2017,10 +2017,10 @@ static int recv_dless_read(struct drbd_peer_device *peer_device, struct drbd_reqD_ASSERT (peer_device->device, sector == bio->bi_iter.bi_sector);bio_for_each_segment (bvec, bio, iter) { -void *mapped =kmap (bvec.bv_page) + bvec.bv_offset; +void *mapped =bvec_kmap_local (&bvec); expect =min_t (int, data_size, bvec.bv_len); err =drbd_recv_all_warn (peer_device->connection, mapped, expect); -kunmap (bvec.bv_page); +kunmap_local (mapped);if (err)return err; data_size -= expect;
Signature · 1 line
2.30.2
PATCH 10/10 floppy: use memcpy_{to,from}_bvec
In reply to Christoph HellwigUse the helpers instead of open coding them.
--- drivers/block/floppy.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/block/floppy.c +2 -4
@@ -2485,11 +2485,9 @@ static void copy_buffer(int ssize, int max_sector, int max_sector_2) }if (CT (raw_cmd->cmd[COMMAND ]) ==FD_READ ) -memcpy_to_page (bv.bv_page, bv.bv_offset, dma_buffer, - size); +memcpy_to_bvec (&bv, dma_buffer);else -memcpy_from_page (dma_buffer, bv.bv_page, bv.bv_offset, - size); +memcpy_from_bvec (dma_buffer, &bv); remaining -= size; dma_buffer += size;
Signature · 1 line
2.30.2