From 79cb31b73630cc308ef9e9cf7d1afdd9b60e9bd5 Mon Sep 17 00:00:00 2001 From: RoyHuang Date: Sun, 27 Jul 2025 23:54:17 +0800 Subject: [PATCH] Support Linux 6.12 To align with Linux kernel v6.12 api. ref: https://git.sceen.net/linux/linux-stable.git/patch/mm/filemap.c?id=2775df6e5e324be9dc375f7db2c8d3042df72bbf https://github.com/torvalds/linux/commit/1da86618bdce301d23e89ecce92161f9d3b3c5e7 --- file.c | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/file.c b/file.c index f6868c0..8a7f1b2 100644 --- a/file.c +++ b/file.c @@ -113,7 +113,14 @@ static int simplefs_writepage(struct page *page, struct writeback_control *wbc) * the data into the page cache. This function checks if the write operation * can complete and allocates the necessary blocks through block_write_begin(). */ -#if SIMPLEFS_AT_LEAST(5, 19, 0) +#if SIMPLEFS_AT_LEAST(6, 12, 0) +static int simplefs_write_begin(struct file *file, + struct address_space *mapping, + loff_t pos, + unsigned int len, + struct folio **foliop, + void **fsdata) +#elif SIMPLEFS_AT_LEAST(5, 19, 0) static int simplefs_write_begin(struct file *file, struct address_space *mapping, loff_t pos, @@ -147,7 +154,9 @@ static int simplefs_write_begin(struct file *file, return -ENOSPC; /* prepare the write */ -#if SIMPLEFS_AT_LEAST(5, 19, 0) +#if SIMPLEFS_AT_LEAST(6, 12, 0) + err = block_write_begin(mapping, pos, len, foliop, simplefs_file_get_block); +#elif SIMPLEFS_AT_LEAST(5, 19, 0) err = block_write_begin(mapping, pos, len, pagep, simplefs_file_get_block); #else err = block_write_begin(mapping, pos, len, flags, pagep, @@ -163,6 +172,15 @@ static int simplefs_write_begin(struct file *file, * cache. This function updates inode metadata and truncates the file if * necessary. */ +#if SIMPLEFS_AT_LEAST(6, 12, 0) +static int simplefs_write_end(struct file *file, + struct address_space *mapping, + loff_t pos, + unsigned int len, + unsigned int copied, + struct folio *foliop, + void *fsdata) +#else static int simplefs_write_end(struct file *file, struct address_space *mapping, loff_t pos, @@ -170,6 +188,7 @@ static int simplefs_write_end(struct file *file, unsigned int copied, struct page *page, void *fsdata) +#endif { struct inode *inode = file->f_inode; struct simplefs_inode_info *ci = SIMPLEFS_INODE(inode); @@ -180,7 +199,12 @@ static int simplefs_write_end(struct file *file, uint32_t nr_blocks_old; /* Complete the write() */ +#if SIMPLEFS_AT_LEAST(6, 12, 0) + int ret = + generic_write_end(file, mapping, pos, len, copied, foliop, fsdata); +#else int ret = generic_write_end(file, mapping, pos, len, copied, page, fsdata); +#endif if (ret < len) { pr_err("wrote less than requested."); return ret;