Thread (5 messages) 5 messages, 1 author, 2023-03-28
STALE1215d

[PATCH 1/4] brd: use memcpy_to_page() in copy_to_brd()

From: Chaitanya Kulkarni <kch@nvidia.com>
Date: 2023-03-28 19:57:48
Subsystem: block layer, ramdisk ram block device driver, the rest · Maintainers: Jens Axboe, Linus Torvalds

In copy_to_brd() it uses kmap_atomic() call on the page in question to
create destination page mapping on buffer (dst), then it uses memcpy()
call to copy the data from source pointer onto mapped buffer (dst) with
added offset and size equals to number of bytes stored in copy variable.
Then it uses the kunmap_atomic(), also from :include/linux/highmem.h:

"kmap_atomic - Atomically map a page for temporary usage - Deprecated!"

Use memcpy_from_page() helper does the same job of mapping and copying
except it uses non deprecated kmap_local_page() and kunmap_local().

Signed-off-by: Chaitanya Kulkarni <kch@nvidia.com>
---
 drivers/block/brd.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/drivers/block/brd.c b/drivers/block/brd.c
index 34177f1bd97d..91ab0a76a39f 100644
--- a/drivers/block/brd.c
+++ b/drivers/block/brd.c
@@ -197,9 +197,7 @@ static void copy_to_brd(struct brd_device *brd, const void *src,
 	page = brd_lookup_page(brd, sector);
 	BUG_ON(!page);
 
-	dst = kmap_atomic(page);
-	memcpy(dst + offset, src, copy);
-	kunmap_atomic(dst);
+	memcpy_to_page(page, offset, src, copy);
 
 	if (copy < n) {
 		src += copy;
-- 
2.29.0
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help