aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorMatthew Wilcox (Oracle) <willy@infradead.org>2025-05-14 18:06:04 +0100
committerAndrew Morton <akpm@linux-foundation.org>2025-05-31 22:46:07 -0700
commitd9736929445e7f4c60f0093af61ff0b52e2d4412 (patch)
treea48299526fda77f2f7daabdc407e42bf677a7610 /lib
parentntfs3: use folios more in ntfs_compress_write() (diff)
downloadlinux-rng-d9736929445e7f4c60f0093af61ff0b52e2d4412.tar.xz
linux-rng-d9736929445e7f4c60f0093af61ff0b52e2d4412.zip
iov: remove copy_page_from_iter_atomic()
All callers now use copy_folio_from_iter_atomic(), so convert copy_page_from_iter_atomic(). While I'm in there, use kmap_local_folio() and pagefault_disable() instead of kmap_atomic(). That allows preemption and/or task migration to happen during the copy_from_user(). Also use the new folio_test_partial_kmap() predicate instead of open-coding it. Link: https://lkml.kernel.org/r/20250514170607.3000994-4-willy@infradead.org Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org> Cc: Alexander Viro <viro@zeniv.linux.org.uk> Cc: Hugh Dickins <hughd@google.com> Cc: Konstantin Komarov <almaz.alexandrovich@paragon-software.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Diffstat (limited to 'lib')
-rw-r--r--lib/iov_iter.c29
1 files changed, 13 insertions, 16 deletions
diff --git a/lib/iov_iter.c b/lib/iov_iter.c
index d9e19fb2dcf3..969d4ad510df 100644
--- a/lib/iov_iter.c
+++ b/lib/iov_iter.c
@@ -457,38 +457,35 @@ size_t iov_iter_zero(size_t bytes, struct iov_iter *i)
}
EXPORT_SYMBOL(iov_iter_zero);
-size_t copy_page_from_iter_atomic(struct page *page, size_t offset,
+size_t copy_folio_from_iter_atomic(struct folio *folio, size_t offset,
size_t bytes, struct iov_iter *i)
{
size_t n, copied = 0;
- bool uses_kmap = IS_ENABLED(CONFIG_DEBUG_KMAP_LOCAL_FORCE_MAP) ||
- PageHighMem(page);
- if (!page_copy_sane(page, offset, bytes))
+ if (!page_copy_sane(&folio->page, offset, bytes))
return 0;
if (WARN_ON_ONCE(!i->data_source))
return 0;
do {
- char *p;
+ char *to = kmap_local_folio(folio, offset);
n = bytes - copied;
- if (uses_kmap) {
- page += offset / PAGE_SIZE;
- offset %= PAGE_SIZE;
- n = min_t(size_t, n, PAGE_SIZE - offset);
- }
-
- p = kmap_atomic(page) + offset;
- n = __copy_from_iter(p, n, i);
- kunmap_atomic(p);
+ if (folio_test_partial_kmap(folio) &&
+ n > PAGE_SIZE - offset_in_page(offset))
+ n = PAGE_SIZE - offset_in_page(offset);
+
+ pagefault_disable();
+ n = __copy_from_iter(to, n, i);
+ pagefault_enable();
+ kunmap_local(to);
copied += n;
offset += n;
- } while (uses_kmap && copied != bytes && n > 0);
+ } while (copied != bytes && n > 0);
return copied;
}
-EXPORT_SYMBOL(copy_page_from_iter_atomic);
+EXPORT_SYMBOL(copy_folio_from_iter_atomic);
static void iov_iter_bvec_advance(struct iov_iter *i, size_t size)
{