[V2,5/8] iov_iter: Remove memzero_page() in favor of zero_user()
diff mbox series

Message ID 20210210062221.3023586-6-ira.weiny@intel.com
State New, archived
Headers show
Series
  • btrfs: convert kmaps to core page calls
Related show

Commit Message

Ira Weiny Feb. 10, 2021, 6:22 a.m. UTC
From: Ira Weiny <ira.weiny@intel.com>

zero_user() is already defined with the same interface and contains the
same code pattern as memzero_page().  Remove memzero_page() and use the
already defined common function zero_user()

To: Alexander Viro <viro@zeniv.linux.org.uk>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Christoph Hellwig <hch@infradead.org>
Signed-off-by: Ira Weiny <ira.weiny@intel.com>

---
New for V2
---
 lib/iov_iter.c | 12 +++---------
 1 file changed, 3 insertions(+), 9 deletions(-)

Comments

Christoph Hellwig Feb. 10, 2021, 12:55 p.m. UTC | #1
On Tue, Feb 09, 2021 at 10:22:18PM -0800, ira.weiny@intel.com wrote:
> From: Ira Weiny <ira.weiny@intel.com>
> 
> zero_user() is already defined with the same interface and contains the
> same code pattern as memzero_page().  Remove memzero_page() and use the
> already defined common function zero_user()

Looks good,

Reviewed-by: Christoph Hellwig <hch@lst.de>

Patch
diff mbox series

diff --git a/lib/iov_iter.c b/lib/iov_iter.c
index 9889e9903cdf..aa0d03b33a1e 100644
--- a/lib/iov_iter.c
+++ b/lib/iov_iter.c
@@ -5,6 +5,7 @@ 
 #include <linux/fault-inject-usercopy.h>
 #include <linux/uio.h>
 #include <linux/pagemap.h>
+#include <linux/highmem.h>
 #include <linux/slab.h>
 #include <linux/vmalloc.h>
 #include <linux/splice.h>
@@ -466,13 +467,6 @@  void iov_iter_init(struct iov_iter *i, unsigned int direction,
 }
 EXPORT_SYMBOL(iov_iter_init);
 
-static void memzero_page(struct page *page, size_t offset, size_t len)
-{
-	char *addr = kmap_atomic(page);
-	memset(addr + offset, 0, len);
-	kunmap_atomic(addr);
-}
-
 static inline bool allocated(struct pipe_buffer *buf)
 {
 	return buf->ops == &default_pipe_buf_ops;
@@ -950,7 +944,7 @@  static size_t pipe_zero(size_t bytes, struct iov_iter *i)
 
 	do {
 		size_t chunk = min_t(size_t, n, PAGE_SIZE - off);
-		memzero_page(pipe->bufs[i_head & p_mask].page, off, chunk);
+		zero_user(pipe->bufs[i_head & p_mask].page, off, chunk);
 		i->head = i_head;
 		i->iov_offset = off + chunk;
 		n -= chunk;
@@ -967,7 +961,7 @@  size_t iov_iter_zero(size_t bytes, struct iov_iter *i)
 		return pipe_zero(bytes, i);
 	iterate_and_advance(i, bytes, v,
 		clear_user(v.iov_base, v.iov_len),
-		memzero_page(v.bv_page, v.bv_offset, v.bv_len),
+		zero_user(v.bv_page, v.bv_offset, v.bv_len),
 		memset(v.iov_base, 0, v.iov_len)
 	)