Skip to contentSkip to conversation

F2FS support

PATCH In review Jaegeuk Kim 2 participants 2 messages May 4, 2017 Kbuild

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 F2FS support

"F2FS (Flash-Friendly File System) is flash-friendly file system which was merged into Linux kernel v3.8 in 2013.

The motive for F2FS was to build a file system that from the start, takes into account the characteristics of NAND flash memory-based storage devices (such as solid-state disks, eMMC, and SD cards).

F2FS was designed on a basis of a log-structured file system approach, which remedies some known issues of the older log structured file systems, such as the snowball effect of wandering trees and high cleaning overhead. In addition, since a NAND-based storage device shows different characteristics according to its internal geometry or flash memory management scheme (such as the Flash Translation Layer or FTL), it supports various parameters not only for configuring on-disk layout, but also for selecting allocation and cleaning algorithm.", quote by https://en.wikipedia.org/wiki/F2FS.

The source codes for F2FS are available from:

http://git.kernel.org/cgit/linux/kernel/git/jaegeuk/f2fs.git
http://git.kernel.org/cgit/linux/kernel/git/jaegeuk/f2fs-tools.git

Update:
- This patch has been integrated in OpenMandriva Lx 3.
https://www.openmandriva.org/

---
 Makefile.util.def            |    7 +
 docs/grub.texi               |    5 +-
 grub-core/Makefile.core.def  |    5 +
 grub-core/fs/f2fs.c          | 1289 ++++++++++++++++++++++++++++++++++++++++++
 po/exclude.pot               |    1 +
 tests/f2fs_test.in           |   19 +
 tests/util/grub-fs-tester.in |   10 +-
 7 files changed, 1332 insertions(+), 4 deletions(-)
 create mode 100644 grub-core/fs/f2fs.c
 create mode 100644 tests/f2fs_test.in
Makefile.util.def +7 -0
index f9caccb97..3180ac880 100644
@@ -99,6 +99,7 @@ library = {
   common = grub-core/fs/ext2.c;
   common = grub-core/fs/fat.c;
   common = grub-core/fs/exfat.c;
+  common = grub-core/fs/f2fs.c;
   common = grub-core/fs/fshelp.c;
   common = grub-core/fs/hfs.c;
   common = grub-core/fs/hfsplus.c;
@@ -776,6 +777,12 @@ script = {
 
 script = {
   testcase;
+  name = f2fs_test;
+  common = tests/f2fs_test.in;
+};
+
+script = {
+  testcase;
   name = nilfs2_test;
   common = tests/nilfs2_test.in;
 };
docs/grub.texi +3 -2
index e935af33e..7137d6d0d 100644
@@ -360,7 +360,8 @@ blocklist notation. The currently supported filesystem types are @dfn{Amiga
 Fast FileSystem (AFFS)}, @dfn{AtheOS fs}, @dfn{BeFS},
 @dfn{BtrFS} (including raid0, raid1, raid10, gzip and lzo),
 @dfn{cpio} (little- and big-endian bin, odc and newc variants),
-@dfn{Linux ext2/ext3/ext4}, @dfn{DOS FAT12/FAT16/FAT32}, @dfn{exFAT}, @dfn{HFS},
+@dfn{Linux ext2/ext3/ext4}, @dfn{DOS FAT12/FAT16/FAT32}, @dfn{exFAT},
+@dfn{f2fs}, @dfn{HFS},
 @dfn{HFS+}, @dfn{ISO9660} (including Joliet, Rock-ridge and multi-chunk files),
 @dfn{JFS}, @dfn{Minix fs} (versions 1, 2 and 3), @dfn{nilfs2},
 @dfn{NTFS} (including compression), @dfn{ReiserFS}, @dfn{ROMFS},
@@ -5368,7 +5369,7 @@ NTFS, JFS, UDF, HFS+, exFAT, long filenames in FAT, Joliet part of
 ISO9660 are treated as UTF-16 as per specification. AFS and BFS are read
 as UTF-8, again according to specification. BtrFS, cpio, tar, squash4, minix,
 minix2, minix3, ROMFS, ReiserFS, XFS, ext2, ext3, ext4, FAT (short names),
-RockRidge part of ISO9660, nilfs2, UFS1, UFS2 and ZFS are assumed
+f2fs, RockRidge part of ISO9660, nilfs2, UFS1, UFS2 and ZFS are assumed
 to be UTF-8. This might be false on systems configured with legacy charset
 but as long as the charset used is superset of ASCII you should be able to
 access ASCII-named files. And it's recommended to configure your system to use
grub-core/Makefile.core.def +5 -0
index 2dfa22a92..7f084d466 100644
@@ -1291,6 +1291,11 @@ module = {
 };
 
 module = {
+  name = f2fs;
+  common = fs/f2fs.c;
+};
+
+module = {
   name = fshelp;
   common = fs/fshelp.c;
 };
grub-core/fs/f2fs.c new file +1289 -0

1,289 lines not on this page · raw message

po/exclude.pot +1 -0
index 0a9b215ea..816089c30 100644
@@ -1214,6 +1214,7 @@ msgstr ""
 
 #: grub-core/commands/xnu_uuid.c:75 grub-core/fs/jfs.c:924
 #: grub-core/fs/nilfs2.c:1135
+#: grub-core/fs/f2fs.c:1259
 #, c-format
 msgid "%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x"
 msgstr ""
tests/f2fs_test.in new file +19 -0
new file mode 100644
index 000000000..1ea77c826
@@ -0,0 +1,19 @@
+#!/bin/sh
+
+set -e
+
+if [ "x$EUID" = "x" ] ; then
+ EUID=`id -u`
+fi
+
+if [ "$EUID" != 0 ] ; then
+ exit 77
+fi
+
+if ! which mkfs.f2fs >/dev/null 2>&1; then
+ echo "mkfs.f2fs not installed; cannot test f2fs."
+ exit 77
+fi
+
+
+"@builddir@/grub-fs-tester" f2fs
tests/util/grub-fs-tester.in +8 -2
index 2337771a1..333c45035 100644
@@ -145,7 +145,7 @@ for ((LOGSECSIZE=MINLOGSECSIZE;LOGSECSIZE<=MAXLOGSECSIZE;LOGSECSIZE=LOGSECSIZE +
 	xsquash*)
 	    MINBLKSIZE=4096
 	    MAXBLKSIZE=1048576;;
-	xxfs)
+	xxfs|xf2fs)
 	    MINBLKSIZE=$SECSIZE
 		# OS Limitation: GNU/Linux doesn't accept > 4096
 	    MAXBLKSIZE=4096;;
@@ -268,6 +268,10 @@ for ((LOGSECSIZE=MINLOGSECSIZE;LOGSECSIZE<=MAXLOGSECSIZE;LOGSECSIZE=LOGSECSIZE +
 		x"btrfs"*)
 		    FSLABEL="grub_;/testé莭莽😁киритi urewfceniuewruevrewnuuireurevueurnievrewfnerfcnevirivinrewvnirewnivrewiuvcrewvnuewvrrrewniuerwreiuviurewiuviurewnuvewnvrenurnunuvrevuurerejiremvreijnvcreivire nverivnreivrevnureiorfnfrvoeoiroireoireoifrefoieroifoireoi";;
 
+	    # FS LIMITATION: f2fs label is at most 512 UTF-16 chars
+		x"f2fs")
+		    FSLABEL="grub_;/testé䏌䐓䏕киритiurewfceniuewruewnuuireurevueurnievrewfnerfcnevirivinrewvnirewnivrewiuvcrewvnuewvrrrewniuerwreiuviurewiuviurewnuvewnvrenurnunuvrevuurerejiremvreijnvvcreivire nverivnreivrevnureiorfnfrvoeoiroireoireoifrefoieroifoirvcreivire nverivnreivrevnureiorfnfrvoeoiroireoireoifrefoieroifoircreivire nverivnreivrevnureiorfnfrvoeoiroireoireoifrefoieroifoireoifoiq";;
+
 	    # FS LIMITATION: exfat is at most 15 UTF-16 chars
 		x"exfat")
 		    FSLABEL="géт ;/莭莽😁кир";;
@@ -477,7 +481,7 @@ for ((LOGSECSIZE=MINLOGSECSIZE;LOGSECSIZE<=MAXLOGSECSIZE;LOGSECSIZE=LOGSECSIZE +
 	    # FIXME: Not sure about BtrFS, NTFS, JFS, AFS, UDF and SFS. Check it.
 	# FS LIMITATION: as far as I know those FS don't store their last modification date.
 		x"jfs_caseins" | x"jfs" | x"xfs" | x"xfs_crc" | x"btrfs"* | x"reiserfs_old" | x"reiserfs" \
-		    | x"bfs" | x"afs" \
+		    | x"bfs" | x"afs" | x"f2fs" \
 		    | x"tarfs" | x"cpio_"* | x"minix" | x"minix2" \
 		    | x"minix3" | x"ntfs"* | x"udf" | x"sfs"*)
 		    NOFSTIME=y;;
@@ -756,6 +760,8 @@ for ((LOGSECSIZE=MINLOGSECSIZE;LOGSECSIZE<=MAXLOGSECSIZE;LOGSECSIZE=LOGSECSIZE +
 		    MOUNTDEVICE="/dev/mapper/grub_test-testvol"
 		    MOUNTFS=ext2
 		    "mkfs.ext2" -L "$FSLABEL" -q "${MOUNTDEVICE}"  ;;
+		xf2fs)
+		    "mkfs.f2fs" -l "$FSLABEL" -q "${LODEVICES[0]}" ;;
 		xnilfs2)
 		    "mkfs.nilfs2" -L "$FSLABEL" -b $BLKSIZE  -q "${LODEVICES[0]}" ;;
 		xext2_old)
Signature · 10 lines
2.11.0


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
#1 lore raw
Quoted 6 lines · Jaegeuk Kim

"F2FS (Flash-Friendly File System) is flash-friendly file system which was merged into Linux kernel v3.8 in 2013.

The motive for F2FS was to build a file system that from the start, takes into account the characteristics of NAND flash memory-based storage devices (such as solid-state disks, eMMC, and SD cards).

Some reason "why?" would be nice.

Here's a rough comparison, class 4 SD card on a Pine64, median of 5:
* "git reset --hard" in a big empty tree:
btrfs 3m45s, f2fs 4m, ext4 12m, xfs 16-18m (huge variance)
* "./configure && make -j4 && make test" (highly CPU-bound) f2fs 95s, btrfs 97s, xfs 120s, ext4 122s
* linear write of a single big file
no meaningful differences

Ie, there's a drastic gain for using f2fs or btrfs. But btrfs is... well, btrfs. It has both significant data safety features and "WTF" level caveats that can result in abysmal performance, unexpected lack of space or even data loss when handled by a naive user in ways that are perfectly safe for most other filesystems. Thus, it'd be irresponsible to unleash btrfs onto an unprepared user. Which leaves f2fs which works well with "install and forget".

And there's a bunch of new machines that boot from SD/eMMC even on x86.

Meow!

Signature · 8 lines
Don't be racist.  White, amber or black, all beers should be judged based
solely on their merits.  Heck, even if occasionally a cider applies for a
beer's job, why not?
On the other hand, corpo lager is not a race.

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot