Skip to content

Commit e3ec0fe

Browse files
Matthew Wilcox (Oracle)brauner
authored andcommitted
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 <[email protected]> Cc: Anton Ivanov <[email protected]> Cc: Johannes Berg <[email protected]> Cc: [email protected] Signed-off-by: Matthew Wilcox (Oracle) <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Christian Brauner <[email protected]>
1 parent 4df37c5 commit e3ec0fe

File tree

1 file changed

+6
-17
lines changed

1 file changed

+6
-17
lines changed

fs/hostfs/hostfs_kern.c

Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -432,31 +432,20 @@ static int hostfs_writepage(struct page *page, struct writeback_control *wbc)
432432

433433
static int hostfs_read_folio(struct file *file, struct folio *folio)
434434
{
435-
struct page *page = &folio->page;
436435
char *buffer;
437-
loff_t start = page_offset(page);
436+
loff_t start = folio_pos(folio);
438437
int bytes_read, ret = 0;
439438

440-
buffer = kmap_local_page(page);
439+
buffer = kmap_local_folio(folio, 0);
441440
bytes_read = read_file(FILE_HOSTFS_I(file)->fd, &start, buffer,
442441
PAGE_SIZE);
443-
if (bytes_read < 0) {
444-
ClearPageUptodate(page);
445-
SetPageError(page);
442+
if (bytes_read < 0)
446443
ret = bytes_read;
447-
goto out;
448-
}
449-
450-
memset(buffer + bytes_read, 0, PAGE_SIZE - bytes_read);
451-
452-
ClearPageError(page);
453-
SetPageUptodate(page);
454-
455-
out:
456-
flush_dcache_page(page);
444+
else
445+
buffer = folio_zero_tail(folio, bytes_read, buffer);
457446
kunmap_local(buffer);
458-
unlock_page(page);
459447

448+
folio_end_read(folio, ret == 0);
460449
return ret;
461450
}
462451

0 commit comments

Comments
 (0)