hostfs: Convert hostfs_read_folio() to use a folio
Remove the use of page APIs, including setting/clearing the error flag which is never checked on hostfs folios. This does not include support for large folios as kmap_local_folio() maps only one page at a time. Cc: Richard Weinberger <richard@nod.at> Cc: Anton Ivanov <anton.ivanov@cambridgegreys.com> Cc: Johannes Berg <johannes@sipsolutions.net> Cc: linux-um@lists.infradead.org Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org> Link: https://lore.kernel.org/r/20240530202110.2653630-8-willy@infradead.org Signed-off-by: Christian Brauner <brauner@kernel.org>
This commit is contained in:
parent
4df37c5f08
commit
e3ec0fe944
1 changed files with 6 additions and 17 deletions
|
@ -432,31 +432,20 @@ static int hostfs_writepage(struct page *page, struct writeback_control *wbc)
|
||||||
|
|
||||||
static int hostfs_read_folio(struct file *file, struct folio *folio)
|
static int hostfs_read_folio(struct file *file, struct folio *folio)
|
||||||
{
|
{
|
||||||
struct page *page = &folio->page;
|
|
||||||
char *buffer;
|
char *buffer;
|
||||||
loff_t start = page_offset(page);
|
loff_t start = folio_pos(folio);
|
||||||
int bytes_read, ret = 0;
|
int bytes_read, ret = 0;
|
||||||
|
|
||||||
buffer = kmap_local_page(page);
|
buffer = kmap_local_folio(folio, 0);
|
||||||
bytes_read = read_file(FILE_HOSTFS_I(file)->fd, &start, buffer,
|
bytes_read = read_file(FILE_HOSTFS_I(file)->fd, &start, buffer,
|
||||||
PAGE_SIZE);
|
PAGE_SIZE);
|
||||||
if (bytes_read < 0) {
|
if (bytes_read < 0)
|
||||||
ClearPageUptodate(page);
|
|
||||||
SetPageError(page);
|
|
||||||
ret = bytes_read;
|
ret = bytes_read;
|
||||||
goto out;
|
else
|
||||||
}
|
buffer = folio_zero_tail(folio, bytes_read, buffer);
|
||||||
|
|
||||||
memset(buffer + bytes_read, 0, PAGE_SIZE - bytes_read);
|
|
||||||
|
|
||||||
ClearPageError(page);
|
|
||||||
SetPageUptodate(page);
|
|
||||||
|
|
||||||
out:
|
|
||||||
flush_dcache_page(page);
|
|
||||||
kunmap_local(buffer);
|
kunmap_local(buffer);
|
||||||
unlock_page(page);
|
|
||||||
|
|
||||||
|
folio_end_read(folio, ret == 0);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue