From: Chaitanya Kulkarni <kch@nvidia.com>
To: <linux-block@vger.kernel.org>
Cc: <axboe@kernel.dk>, <damien.lemoal@opensource.wdc.com>,
<johannes.thumshirn@wdc.com>, <bvanassche@acm.org>,
<kbusch@kernel.org>, <vincent.fu@samsung.com>,
<shinichiro.kawasaki@wdc.com>, <error27@gmail.com>,
Chaitanya Kulkarni <kch@nvidia.com>
Subject: [PATCH 2/4] null_blk: use memcpy_page() in copy_from_nullb()
Date: Wed, 29 Mar 2023 13:46:50 -0700 [thread overview]
Message-ID: <20230329204652.52785-3-kch@nvidia.com> (raw)
In-Reply-To: <20230329204652.52785-1-kch@nvidia.com>
Use library helper memcpy_page() to copy source page into destination
instead of having duplicate code and zero_user() instead of memset as
this removes deprecated API from :include/linux/highmem.h:
"kmap_atomic - Atomically map a page for temporary usage - Deprecated!"
Signed-off-by: Chaitanya Kulkarni <kch@nvidia.com>
---
drivers/block/null_blk/main.c | 16 +++++-----------
1 file changed, 5 insertions(+), 11 deletions(-)
diff --git a/drivers/block/null_blk/main.c b/drivers/block/null_blk/main.c
index 947bba174e1e..2b344dcb4382 100644
--- a/drivers/block/null_blk/main.c
+++ b/drivers/block/null_blk/main.c
@@ -1144,7 +1144,6 @@ static int copy_from_nullb(struct nullb *nullb, struct page *dest,
size_t temp, count = 0;
unsigned int offset;
struct nullb_page *t_page;
- void *dst, *src;
while (count < n) {
temp = min_t(size_t, nullb->dev->blocksize, n - count);
@@ -1153,16 +1152,11 @@ static int copy_from_nullb(struct nullb *nullb, struct page *dest,
t_page = null_lookup_page(nullb, sector, false,
!null_cache_active(nullb));
- dst = kmap_atomic(dest);
- if (!t_page) {
- memset(dst + off + count, 0, temp);
- goto next;
- }
- src = kmap_atomic(t_page->page);
- memcpy(dst + off + count, src + offset, temp);
- kunmap_atomic(src);
-next:
- kunmap_atomic(dst);
+ if (t_page)
+ memcpy_page(dest, off + count, t_page->page, offset,
+ temp);
+ else
+ zero_user(dest, off + count, temp);
count += temp;
sector += temp >> SECTOR_SHIFT;
--
2.29.0
next prev parent reply other threads:[~2023-03-29 20:47 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-29 20:46 [PATCH 0/4] null_blk: usr memcpy_[to|from]_page() Chaitanya Kulkarni
2023-03-29 20:46 ` [PATCH 1/4] null_blk: use memcpy_page() in copy_to_nullb() Chaitanya Kulkarni
2023-03-29 20:46 ` Chaitanya Kulkarni [this message]
2023-03-29 20:46 ` [PATCH 3/4] null-blk: use memset_page() to fill page pattern Chaitanya Kulkarni
2023-03-29 20:46 ` [PATCH 4/4] null_blk: use kmap_local_page() and kunmap_local() Chaitanya Kulkarni
2023-03-29 22:48 ` [PATCH 0/4] null_blk: usr memcpy_[to|from]_page() Jens Axboe
2023-03-30 18:56 ` Chaitanya Kulkarni
2023-03-30 23:00 ` Jens Axboe
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230329204652.52785-3-kch@nvidia.com \
--to=kch@nvidia.com \
--cc=axboe@kernel.dk \
--cc=bvanassche@acm.org \
--cc=damien.lemoal@opensource.wdc.com \
--cc=error27@gmail.com \
--cc=johannes.thumshirn@wdc.com \
--cc=kbusch@kernel.org \
--cc=linux-block@vger.kernel.org \
--cc=shinichiro.kawasaki@wdc.com \
--cc=vincent.fu@samsung.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.