summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorAl Viro <viro@zeniv.linux.org.uk>2021-04-30 13:40:48 -0400
committerAl Viro <viro@zeniv.linux.org.uk>2021-06-10 11:45:23 -0400
commit2495bdcc86dc5e6b71b6785e1faa76452496c687 (patch)
treea3ae036caa4ad9933c94ce1ba1e80b09cc3694e1 /lib
parent55ca375c5dcc7aebd89de42f00ff18f5c40d25f3 (diff)
iov_iter: clean csum_and_copy_...() primitives up a bit
1) kmap_atomic() is not needed here, kmap_local_page() is enough. 2) No need to make sum = csum_block_add(sum, next, off); conditional upon next != 0 - adding 0 is a no-op as far as csum_block_add() is concerned. Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'lib')
-rw-r--r--lib/iov_iter.c10
1 files changed, 4 insertions, 6 deletions
diff --git a/lib/iov_iter.c b/lib/iov_iter.c
index ba7eb6557750..3b442d25a966 100644
--- a/lib/iov_iter.c
+++ b/lib/iov_iter.c
@@ -600,9 +600,9 @@ static size_t csum_and_copy_to_pipe_iter(const void *addr, size_t bytes,
return 0;
do {
size_t chunk = min_t(size_t, n, PAGE_SIZE - r);
- char *p = kmap_atomic(pipe->bufs[i_head & p_mask].page);
+ char *p = kmap_local_page(pipe->bufs[i_head & p_mask].page);
sum = csum_and_memcpy(p + r, addr, chunk, sum, off);
- kunmap_atomic(p);
+ kunmap_local(p);
i->head = i_head;
i->iov_offset = r + chunk;
n -= chunk;
@@ -1665,8 +1665,7 @@ size_t csum_and_copy_from_iter(void *addr, size_t bytes, __wsum *csum,
}
iterate_and_advance(i, bytes, base, len, off, ({
next = csum_and_copy_from_user(base, addr + off, len);
- if (next)
- sum = csum_block_add(sum, next, off);
+ sum = csum_block_add(sum, next, off);
next ? 0 : len;
}), ({
sum = csum_and_memcpy(addr + off, base, len, sum, off);
@@ -1693,8 +1692,7 @@ size_t csum_and_copy_to_iter(const void *addr, size_t bytes, void *_csstate,
}
iterate_and_advance(i, bytes, base, len, off, ({
next = csum_and_copy_to_user(addr + off, base, len);
- if (next)
- sum = csum_block_add(sum, next, off);
+ sum = csum_block_add(sum, next, off);
next ? 0 : len;
}), ({
sum = csum_and_memcpy(base, addr + off, len, sum, off);