Commit b23fb762 authored by Matthew Wilcox's avatar Matthew Wilcox Committed by Theodore Ts'o

ext4: Convert pagecache_read() to use a folio

Use the folio API and support folios of arbitrary sizes.
Signed-off-by: default avatarMatthew Wilcox (Oracle) <willy@infradead.org>
Link: https://lore.kernel.org/r/20230324180129.1220691-29-willy@infradead.orgSigned-off-by: default avatarTheodore Ts'o <tytso@mit.edu>
parent 3060b6ef
...@@ -42,18 +42,16 @@ static int pagecache_read(struct inode *inode, void *buf, size_t count, ...@@ -42,18 +42,16 @@ static int pagecache_read(struct inode *inode, void *buf, size_t count,
loff_t pos) loff_t pos)
{ {
while (count) { while (count) {
size_t n = min_t(size_t, count, struct folio *folio;
PAGE_SIZE - offset_in_page(pos)); size_t n;
struct page *page;
page = read_mapping_page(inode->i_mapping, pos >> PAGE_SHIFT, folio = read_mapping_folio(inode->i_mapping, pos >> PAGE_SHIFT,
NULL); NULL);
if (IS_ERR(page)) if (IS_ERR(folio))
return PTR_ERR(page); return PTR_ERR(folio);
memcpy_from_page(buf, page, offset_in_page(pos), n);
put_page(page); n = memcpy_from_file_folio(buf, folio, pos, count);
folio_put(folio);
buf += n; buf += n;
pos += n; pos += n;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment