Skip to content

Commit

Permalink
fs: Convert aops->write_begin to take a folio
Browse files Browse the repository at this point in the history
Convert all callers from working on a page to working on one page
of a folio (support for working on an entire folio can come later).
Removes a lot of folio->page->folio conversions.

Reviewed-by: Josef Bacik <[email protected]>
Signed-off-by: Matthew Wilcox (Oracle) <[email protected]>
Signed-off-by: Christian Brauner <[email protected]>
Signed-off-by: Namjae Jeon <[email protected]>
  • Loading branch information
Matthew Wilcox (Oracle) authored and namjaejeon committed Nov 27, 2024
1 parent 9d0bbdc commit 72fb38f
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
14 changes: 13 additions & 1 deletion file.c
Original file line number Diff line number Diff line change
Expand Up @@ -635,25 +635,37 @@ static int exfat_file_zeroed_range(struct file *file, loff_t start, loff_t end)

while (start < end) {
u32 zerofrom, len;
#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 12, 0)
struct folio *folio;
#else
struct page *page = NULL;
#endif

zerofrom = start & (PAGE_SIZE - 1);
len = PAGE_SIZE - zerofrom;
if (start + len > end)
len = end - start;

#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 0, 0)
#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 12, 0)
err = ops->write_begin(file, mapping, start, len, &folio, NULL);
#else
err = ops->write_begin(file, mapping, start, len, &page, NULL);
#endif
#else
err = ops->write_begin(file, mapping, start, len, 0, &page, NULL);
#endif
if (err)
goto out;

#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 12, 0)
folio_zero_range(folio, offset_in_folio(folio, start), len);
#else
zero_user_segment(page, zerofrom, zerofrom + len);
#endif

#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 12, 0)
err = ops->write_end(file, mapping, start, len, len, page_folio(page), NULL);
err = ops->write_end(file, mapping, start, len, len, folio, NULL);
#else
err = ops->write_end(file, mapping, start, len, len, page, NULL);
#endif
Expand Down
8 changes: 8 additions & 0 deletions inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -493,7 +493,11 @@ static void exfat_write_failed(struct address_space *mapping, loff_t to)
#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 19, 0)
static int exfat_write_begin(struct file *file, struct address_space *mapping,
loff_t pos, unsigned int len,
#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 12, 0)
struct folio **foliop, void **fsdata)
#else
struct page **pagep, void **fsdata)
#endif
#else
static int exfat_write_begin(struct file *file, struct address_space *mapping,
loff_t pos, unsigned int len, unsigned int flags,
Expand All @@ -502,12 +506,16 @@ static int exfat_write_begin(struct file *file, struct address_space *mapping,
{
int ret;

#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 12, 0)
ret = block_write_begin(mapping, pos, len, foliop, exfat_get_block);
#else
*pagep = NULL;
#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 19, 0)
ret = block_write_begin(mapping, pos, len, pagep, exfat_get_block);
#else
ret = block_write_begin(mapping, pos, len, flags, pagep,
exfat_get_block);
#endif
#endif
if (ret < 0)
exfat_write_failed(mapping, pos+len);
Expand Down

0 comments on commit 72fb38f

Please sign in to comment.