Commit 18a6234c authored by Christoph Hellwig's avatar Christoph Hellwig Committed by Jens Axboe

dm-writecache: use bvec_kmap_local instead of bvec_kmap_irq

There is no need to disable interrupts in bio_copy_block, and the local
only mappings helps to avoid any sort of problems with stray writes
into the bio data.
Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
Reviewed-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
Reviewed-by: default avatarIra Weiny <ira.weiny@intel.com>
Link: https://lore.kernel.org/r/20210727055646.118787-8-hch@lst.deSigned-off-by: default avatarJens Axboe <axboe@kernel.dk>
parent 732022b8
...@@ -1214,14 +1214,13 @@ static void memcpy_flushcache_optimized(void *dest, void *source, size_t size) ...@@ -1214,14 +1214,13 @@ static void memcpy_flushcache_optimized(void *dest, void *source, size_t size)
static void bio_copy_block(struct dm_writecache *wc, struct bio *bio, void *data) static void bio_copy_block(struct dm_writecache *wc, struct bio *bio, void *data)
{ {
void *buf; void *buf;
unsigned long flags;
unsigned size; unsigned size;
int rw = bio_data_dir(bio); int rw = bio_data_dir(bio);
unsigned remaining_size = wc->block_size; unsigned remaining_size = wc->block_size;
do { do {
struct bio_vec bv = bio_iter_iovec(bio, bio->bi_iter); struct bio_vec bv = bio_iter_iovec(bio, bio->bi_iter);
buf = bvec_kmap_irq(&bv, &flags); buf = bvec_kmap_local(&bv);
size = bv.bv_len; size = bv.bv_len;
if (unlikely(size > remaining_size)) if (unlikely(size > remaining_size))
size = remaining_size; size = remaining_size;
...@@ -1239,7 +1238,7 @@ static void bio_copy_block(struct dm_writecache *wc, struct bio *bio, void *data ...@@ -1239,7 +1238,7 @@ static void bio_copy_block(struct dm_writecache *wc, struct bio *bio, void *data
memcpy_flushcache_optimized(data, buf, size); memcpy_flushcache_optimized(data, buf, size);
} }
bvec_kunmap_irq(buf, &flags); kunmap_local(buf);
data = (char *)data + size; data = (char *)data + size;
remaining_size -= size; remaining_size -= size;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment