Skip to content

Commit 2896199

Browse files
weiny2torvalds
authored andcommitted
iov_iter: lift memzero_page() to highmem.h
Patch series "btrfs: Convert kmap/memset/kunmap to memzero_user()". Lifting memzero_user(), convert it to kmap_local_page() and then use it in btrfs. This patch (of 3): memzero_page() can replace the kmap/memset/kunmap pattern in other places in the code. While zero_user() has the same interface it is not the same call and its use should be limited and some of those calls may be better converted from zero_user() to memzero_page().[1] But that is not addressed in this series. Lift memzero_page() to highmem. [1] https://lore.kernel.org/lkml/CAHk-=wijdojzo56FzYqE5TOYw2Vws7ik3LEMGj9SPQaJJ+Z73Q@mail.gmail.com/ Link: https://lkml.kernel.org/r/[email protected] Link: https://lkml.kernel.org/r/[email protected] Signed-off-by: Ira Weiny <[email protected]> Cc: Alexander Viro <[email protected]> Cc: David Sterba <[email protected]> Cc: Chris Mason <[email protected]> Cc: Josef Bacik <[email protected]> Cc: Chaitanya Kulkarni <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent ecfc2bd commit 2896199

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

include/linux/highmem.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -332,4 +332,11 @@ static inline void memcpy_to_page(struct page *page, size_t offset,
332332
kunmap_local(to);
333333
}
334334

335+
static inline void memzero_page(struct page *page, size_t offset, size_t len)
336+
{
337+
char *addr = kmap_atomic(page);
338+
memset(addr + offset, 0, len);
339+
kunmap_atomic(addr);
340+
}
341+
335342
#endif /* _LINUX_HIGHMEM_H */

lib/iov_iter.c

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
#include <linux/fault-inject-usercopy.h>
66
#include <linux/uio.h>
77
#include <linux/pagemap.h>
8+
#include <linux/highmem.h>
89
#include <linux/slab.h>
910
#include <linux/vmalloc.h>
1011
#include <linux/splice.h>
@@ -507,13 +508,6 @@ void iov_iter_init(struct iov_iter *i, unsigned int direction,
507508
}
508509
EXPORT_SYMBOL(iov_iter_init);
509510

510-
static void memzero_page(struct page *page, size_t offset, size_t len)
511-
{
512-
char *addr = kmap_atomic(page);
513-
memset(addr + offset, 0, len);
514-
kunmap_atomic(addr);
515-
}
516-
517511
static inline bool allocated(struct pipe_buffer *buf)
518512
{
519513
return buf->ops == &default_pipe_buf_ops;

0 commit comments

Comments
 (0)