Message ID | 20210608160603.1535935-9-hch@lst.de |
---|---|
State | Superseded |
Headers | show |
Series | [01/16] mm: use kmap_local_page in memzero_page | expand |
On Tue, Jun 08, 2021 at 09:30:56AM -0700, Bart Van Assche wrote: > >From one of the functions called by kunmap_local(): > > unsigned long addr = (unsigned long) vaddr & PAGE_MASK; > > This won't work well if bvec->bv_offset >= PAGE_SIZE I assume? It won't indeed. Both the existing and new helpers operate on single page bvecs only, and all callers only use those. I should have probably mentioned that in the cover letter and documented the assumptions in the code, though.
diff --git a/drivers/md/dm-writecache.c b/drivers/md/dm-writecache.c index aecc246ade26..93ca454eaca9 100644 --- a/drivers/md/dm-writecache.c +++ b/drivers/md/dm-writecache.c @@ -1205,14 +1205,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) { void *buf; - unsigned long flags; unsigned size; int rw = bio_data_dir(bio); unsigned remaining_size = wc->block_size; do { 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; if (unlikely(size > remaining_size)) size = remaining_size; @@ -1230,7 +1229,7 @@ static void bio_copy_block(struct dm_writecache *wc, struct bio *bio, void *data memcpy_flushcache_optimized(data, buf, size); } - bvec_kunmap_irq(buf, &flags); + kunmap_local(buf); data = (char *)data + size; remaining_size -= size;
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: Christoph Hellwig <hch@lst.de> --- drivers/md/dm-writecache.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)