Skip to contentSkip to conversation

Add 16K Support for f2fs

PATCH Superseded Daniel Rosenberg 3 participants 4 messages Aug 16, 2023 F2FS file system

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

cover Add 16K Support for f2fs

F2fs filesystems currently have two large restrictions around block size. The block size must equal the page size, and the block size must be 4096.

The following patch, along with the associated f2fs-tools patch set, relax the latter restriction, allowing you to use 16K block size f2fs on a 16K page size system. It does not allow mounting 4K block size f2fs on a 16k page system.

Doing that would require a lot more work, requiring a refactor of all block sized struct similar to the userspace patches, as well as handling the block reading/writing at sub page boundaries. As far as I know, buffer_heads are still the main way this is handled in other filesystems. Is there a different option there? I know there's a general desire to move away from buffer_heads, but I don't know of any replacements covering that use case. And it would feel a bit silly to not be able to read older filesystems from a 16k system...

Daniel Rosenberg (1):
ANDROID: f2fs: Support Block Size == Page Size

 fs/f2fs/data.c          |  2 +-
 fs/f2fs/node.c          |  2 +-
 fs/f2fs/super.c         |  4 +--
 include/linux/f2fs_fs.h | 69 ++++++++++++++++++++++++-----------------
 4 files changed, 45 insertions(+), 32 deletions(-)

base-commit: 0cc81b1ad51287847e494e055e5d3426f95e7921

Signature · 1 line
2.41.0.694.ge786442a9b-goog
#1 lore raw

PATCH 1/1 ANDROID: f2fs: Support Block Size == Page Size

This allows f2fs to support cases where the block size = page size for both 4K and 16K block sizes. Other sizes should work as well, should the need arise. This does not currently support 4K Block size filesystems if the page size is 16K.

---
 fs/f2fs/data.c          |  2 +-
 fs/f2fs/node.c          |  2 +-
 fs/f2fs/super.c         |  4 +--
 include/linux/f2fs_fs.h | 69 ++++++++++++++++++++++++-----------------
 4 files changed, 45 insertions(+), 32 deletions(-)
fs/f2fs/data.c +1 -1
index 5d9697717353..c9e4d02d21d6 100644
@@ -4052,7 +4052,7 @@ static int check_swap_activate(struct swap_info_struct *sis,
 	sis->highest_bit = cur_lblock - 1;
 out:
 	if (not_aligned)
-		f2fs_warn(sbi, "Swapfile (%u) is not align to section: 1) creat(), 2) ioctl(F2FS_IOC_SET_PIN_FILE), 3) fallocate(%u * N)",
+		f2fs_warn(sbi, "Swapfile (%u) is not align to section: 1) creat(), 2) ioctl(F2FS_IOC_SET_PIN_FILE), 3) fallocate(%lu * N)",
 			  not_aligned, blks_per_sec * F2FS_BLKSIZE);
 	return ret;
 }
fs/f2fs/node.c +1 -1
index ee2e1dd64f25..a2b2c6c7f66d 100644
@@ -633,7 +633,7 @@ static void f2fs_ra_node_pages(struct page *parent, int start, int n)
 
 	/* Then, try readahead for siblings of the desired node */
 	end = start + n;
-	end = min(end, NIDS_PER_BLOCK);
+	end = min(end, (int)NIDS_PER_BLOCK);
 	for (i = start; i < end; i++) {
 		nid = get_nid(parent, i, false);
 		f2fs_ra_node_page(sbi, nid);
fs/f2fs/super.c +2 -2
index a067466a694c..895122ff3964 100644
@@ -3469,7 +3469,7 @@ static int sanity_check_raw_super(struct f2fs_sb_info *sbi,
 		return -EFSCORRUPTED;
 	}
 
-	/* Currently, support 512/1024/2048/4096 bytes sector size */
+	/* Currently, support 512/1024/2048/4096/16K bytes sector size */
 	if (le32_to_cpu(raw_super->log_sectorsize) >
 				F2FS_MAX_LOG_SECTOR_SIZE ||
 		le32_to_cpu(raw_super->log_sectorsize) <
@@ -4915,7 +4915,7 @@ static int __init init_f2fs_fs(void)
 	int err;
 
 	if (PAGE_SIZE != F2FS_BLKSIZE) {
-		printk("F2FS not supported on PAGE_SIZE(%lu) != %d\n",
+		printk("F2FS not supported on PAGE_SIZE(%lu) != BLOCK_SIZE(%lu)\n",
 				PAGE_SIZE, F2FS_BLKSIZE);
 		return -EINVAL;
 	}
include/linux/f2fs_fs.h +41 -28

156 lines not on this page · raw message

Signature · 1 line
2.41.0.694.ge786442a9b-goog
#2 lore raw

Re: [PATCH 1/1] ANDROID: f2fs: Support Block Size == Page Size

kernel test robot noticed the following build warnings:

Hi Daniel,

kernel test robot noticed the following build warnings:

[auto build test WARNING on 0cc81b1ad51287847e494e055e5d3426f95e7921]

url:    https://github.com/intel-lab-lkp/linux/commits/Daniel-Rosenberg/ANDROID-f2fs-Support-Block-Size-Page-Size/20230816-091721
base:   0cc81b1ad51287847e494e055e5d3426f95e7921
patch link:    https://lore.kernel.org/r/20230816011432.1966838-2-drosen%40google.com
patch subject: [PATCH 1/1] ANDROID: f2fs: Support Block Size == Page Size
config: m68k-randconfig-r013-20230816 (https://download.01.org/0day-ci/archive/20230816/[email protected]/config)
compiler: m68k-linux-gcc (GCC) 12.3.0
reproduce: (https://download.01.org/0day-ci/archive/20230816/[email protected]/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/

All warnings (new ones prefixed by >>):

In file included from include/linux/printk.h:7,

                    from include/asm-generic/bug.h:22,
                    from arch/m68k/include/asm/bug.h:32,
                    from include/linux/bug.h:5,
                    from include/linux/thread_info.h:13,
                    from include/asm-generic/preempt.h:5,
                    from ./arch/m68k/include/generated/asm/preempt.h:1,
                    from include/linux/preempt.h:79,
                    from include/linux/spinlock.h:56,
                    from include/linux/wait.h:9,
                    from include/linux/wait_bit.h:8,
                    from include/linux/fs.h:6,
                    from fs/f2fs/inode.c:8:
   fs/f2fs/inode.c: In function 'sanity_check_inode':
>> include/linux/kern_levels.h:5:25: warning: format '%zu' expects argument of type 'size_t', but argument 6 has type 'long unsigned int' [-Wformat=]
       5 | #define KERN_SOH        "\001"          /* ASCII Start Of Header */
         |                         ^~~~~~
   include/linux/kern_levels.h:12:25: note: in expansion of macro 'KERN_SOH'
      12 | #define KERN_WARNING    KERN_SOH "4"    /* warning conditions */
         |                         ^~~~~~~~
   fs/f2fs/f2fs.h:2315:26: note: in expansion of macro 'KERN_WARNING'
    2315 |         f2fs_printk(sbi, KERN_WARNING fmt, ##__VA_ARGS__)
         |                          ^~~~~~~~~~~~
   fs/f2fs/inode.c:325:25: note: in expansion of macro 'f2fs_warn'
     325 |                         f2fs_warn(sbi, "%s: inode (ino=%lx) has corrupted i_inline_xattr_size: %d, max: %zu",
         |                         ^~~~~~~~~

vim +5 include/linux/kern_levels.h

314ba3520e513a Joe Perches 2012-07-30 4
04d2c8c83d0e3a Joe Perches 2012-07-30 @5 #define KERN_SOH "\001" /* ASCII Start Of Header */
04d2c8c83d0e3a Joe Perches 2012-07-30 6 #define KERN_SOH_ASCII '\001'
04d2c8c83d0e3a Joe Perches 2012-07-30 7

Signature · 2 lines
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
#3 lore raw
In reply to Daniel Rosenberg
Quoted 7 lines · On Tue, Aug 15, 2023 at 06:14:31PM -0700, Daniel Rosenberg via…

F2fs filesystems currently have two large restrictions around block size. The block size must equal the page size, and the block size must be 4096.

The following patch, along with the associated f2fs-tools patch set, relax the latter restriction, allowing you to use 16K block size f2fs on a 16K page size system. It does not allow mounting 4K block size f2fs on a 16k page system.

Quoted 7 lines

Doing that would require a lot more work, requiring a refactor of all block sized struct similar to the userspace patches, as well as handling the block reading/writing at sub page boundaries. As far as I know, buffer_heads are still the main way this is handled in other filesystems. Is there a different option there? I know there's a general desire to move away from buffer_heads, but I don't know of any replacements covering that use case. And it would feel a bit silly to not be able to read older filesystems from a 16k system...

iomap is the replacement for buffer heads. See https://lwn.net/Articles/935934

- Eric

_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel