From 72fb38f11cf810537bfbb53f72123c806ffa1745 Mon Sep 17 00:00:00 2001 From: "Matthew Wilcox (Oracle)" Date: Wed, 27 Nov 2024 14:44:20 +0900 Subject: [PATCH] fs: Convert aops->write_begin to take a folio 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 Signed-off-by: Matthew Wilcox (Oracle) Signed-off-by: Christian Brauner Signed-off-by: Namjae Jeon --- file.c | 14 +++++++++++++- inode.c | 8 ++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/file.c b/file.c index bcf573a..be80032 100644 --- a/file.c +++ b/file.c @@ -635,7 +635,11 @@ 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; @@ -643,17 +647,25 @@ static int exfat_file_zeroed_range(struct file *file, loff_t start, loff_t 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 diff --git a/inode.c b/inode.c index c44613c..fedf0c9 100644 --- a/inode.c +++ b/inode.c @@ -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, @@ -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);