Lines Matching +full:i +full:- +full:cache +full:- +full:block +full:- +full:size
1 .. SPDX-License-Identifier: GPL-2.0
4 WHAT IS Flash-Friendly File System (F2FS)?
7 NAND flash memory-based storage devices, such as SSD, eMMC, and SD cards, have
13 F2FS is a file system exploiting NAND flash memory-based storage devices, which
14 is based on Log-structured File System (LFS). The design has been focused on
18 Since a NAND flash memory-based storage device shows different characteristic
20 F2FS and its tools support various parameters not only for configuring on-disk
26 - git://git.kernel.org/pub/scm/linux/kernel/git/jaegeuk/f2fs-tools.git
30 - linux-f2fs-devel@lists.sourceforge.net
34 - https://bugzilla.kernel.org/enter_bug.cgi?product=File%20System&component=f2fs
39 Log-structured File System (LFS)
40 --------------------------------
41 "A log-structured file system writes all modifications to disk sequentially in
42 a log-like structure, thereby speeding up both file writing and crash recovery.
48 implementation of a log-structured file system", ACM Trans. Computer Systems
52 ----------------------
54 pointer block is updated due to the changed location. Then the indirect pointer
55 block is also updated due to the direct pointer block update. In this manner,
56 the upper index structures such as inode, inode map, and checkpoint block are
61 [1] Bityutskiy, A. 2005. JFFS3 design issues. http://www.linux-mtd.infradead.org/
64 -----------------
65 Since LFS is based on out-of-place writes, it produces so many obsolete blocks
75 3. It checks the cross-reference between the data and its parent index structure.
86 ---------------
87 - Enlarge the random write area for better performance, but provide the high
89 - Align FS data structures to the operational units in FTL as best efforts
92 ----------------------
93 - Use a term, “node”, that represents inodes as well as various pointer blocks
94 - Introduce Node Address Table (NAT) containing the locations of all the “node”
98 -----------------
99 - Support a background cleaning process
100 - Support greedy and cost-benefit algorithms for victim selection policies
101 - Support multi-head logs for static/dynamic hot and cold data separation
102 - Introduce adaptive logging for efficient block allocation
110 collection, triggered in background when I/O subsystem is
121 I/O and CPU resources.
123 disable_roll_forward Disable the roll-forward recovery routine
124 norecovery Disable the roll-forward recovery routine, mounted read-
125 only (i.e., -o ro,disable_roll_forward)
126 discard/nodiscard Enable/disable real-time discard in f2fs, if discard is
141 inline_xattr_size=%u Support configuring inline xattr size, it depends on
144 files can be written into inode block.
146 directory entries can be written into inode block. The
147 space of inode block which is used to store inline
164 extent_cache Enable an extent cache based on rb-tree, it can cache
167 increasing the cache hit ratio. Set by default.
168 noextent_cache Disable an extent cache based on rb-tree explicitly, see
214 mode=%s Control block allocation mode which supports "adaptive"
217 "fragment:segment" and "fragment:block" are newly added here.
219 fragmentation/after-GC situation itself. The developers use these
220 modes to understand filesystem fragmentation/after-GC condition well,
223 position. With this, we can simulate the after-GC condition.
224 In "fragment:block", we can scatter block allocation with
226 We added some randomness to both chunk and hole size to make
231 Note that "fragment:block" implicitly enables "fragment:segment"
234 recommend to re-format the filesystem after using these options.
247 alloc_mode=%s Adjust block allocation policy, which supports "reuse"
257 non-atomic files likewise "nobarrier" mount option.
285 a cgroup having low i/o budget and cpu shares. To make this
286 do better, we set the default i/o priority of the kernel daemon
288 This is the same way to give a I/O priority to the jbd2
292 "lz4", "zstd" and "lzo-rle" algorithm.
296 lz4 3 - 16
297 zstd 1 - 22
298 compress_log_size=%u Support configuring compress cluster size. The size will
329 cache compressed block, in order to improve cache hit ratio of
332 files using the blk-crypto framework rather than
333 filesystem-layer encryption. This allows the use of
334 inline encryption hardware. The on-disk format is
336 Documentation/block/inline-encryption.rst.
337 atgc Enable age-threshold garbage collection, it provides high
339 discard_unit=%s Control discard unit, the argument can be "block", "segment"
340 and "section", issued discard command's offset/size will be
341 aligned to the unit, by default, "discard_unit=block" is set,
352 age_extent_cache Enable an age extent cache based on rb-tree. It records
353 data block update frequency of the extent per inode, in
354 order to provide better temperature hints for data block
357 "panic", "continue" and "remount-ro", respectively, trigger
359 the partition in read-only mode. By default it uses "continue"
362 mode continue remount-ro panic
365 syscall errors -EIO -EROFS N/A
368 pending non-dir write drop keep N/A
381 perf (Default) Enforces a hash-only lookup.
383 disabled, ignoring the on-disk flag.
387 different case-folding algorithm.
388 This mode ignores the on-disk flag.
390 on-disk `SB_ENC_NO_COMPAT_FALLBACK_FL`
403 - major file system information managed by f2fs currently
404 - average SIT information about whole segments
405 - current memory footprint consumed by f2fs.
412 /sys/fs/f2fs based on its device name (i.e., /sys/fs/f2fs/sda).
413 The files in each per-device directory are shown in table below.
416 (see also Documentation/ABI/testing/sysfs-fs-f2fs)
432 4. Format the block device, and then mount as f2fs::
434 # mkfs.f2fs -l label /dev/block_device
435 # mount -t f2fs /dev/block_device /mnt/f2fs
438 ---------
440 which builds a basic on-disk layout.
445 ``-l [label]`` Give a volume label, up to 512 unicode name.
446 ``-a [0 or 1]`` Split start location of each area for heap-based allocation.
449 ``-o [int]`` Set overprovision ratio in percent over volume size.
452 ``-s [int]`` Set the number of segments per section.
455 ``-z [int]`` Set the number of sections per zone.
458 ``-e [str]`` Set basic extension list. e.g. "mp3,gif,mov"
459 ``-t [0 or 1]`` Disable discard command or not.
467 ---------
468 The fsck.f2fs is a tool to check the consistency of an f2fs-formatted
469 partition, which examines whether the filesystem metadata and user-made data
470 are cross-referenced correctly or not.
475 -d debug level [default:0]
480 ---------
484 The dump.f2fs is used to debug on-disk data structures of the f2fs filesystem.
485 It shows on-disk inode information recognized by a given inode number, and is
491 -d debug level [default:0]
492 -i inode no (hex)
493 -s [SIT dump segno from #1~#2 (decimal), for all 0~-1]
494 -a [SSA dump segno from #1~#2 (decimal), for all 0~-1]
498 # dump.f2fs -i [ino] /dev/sdx
499 # dump.f2fs -s 0~-1 /dev/sdx (SIT dump)
500 # dump.f2fs -a 0~-1 /dev/sdx (SSA dump)
505 ----------
512 -----------
513 The resize.f2fs lets a user resize the f2fs-formatted disk image, while preserving
519 -----------
527 -------
529 f2fs-specific ones, which is very useful for QA tests.
536 On-disk Layout
537 --------------
540 to 2MB in size. A section is composed of consecutive segments, and a zone
542 segment size identically, but users can easily modify the sizes by mkfs.
547 align with the zone size <-|
548 |-> align with the segment size
566 - Superblock (SB)
571 - Checkpoint (CP)
575 - Segment Information Table (SIT)
576 It contains segment information such as valid block count and bitmap for the
579 - Node Address Table (NAT)
580 It is composed of a block address table for all the node blocks stored in
583 - Segment Summary Area (SSA)
587 - Main Area
590 In order to avoid misalignment between file system and flash-based storage, F2FS
591 aligns the start block address of CP with the segment size. Also, it aligns the
592 start block address of Main area with the zone size by reserving some segments
599 ------------------------------
610 +--------+----------+---------+
612 +--------+----------+---------+
616 +-------+-------+--------+--------+--------+--------+
618 +-------+-------+--------+--------+--------+--------+
621 `----------------------------------------'
624 ---------------
628 indirect node. F2FS assigns 4KB to an inode block which contains 923 data block
630 indirect node pointer as described below. One direct node block contains 1018
631 data blocks, and one indirect node block contains also 1018 node blocks. Thus,
632 one inode block (i.e., a file) covers::
636 Inode block (4KB)
637 |- data (923)
638 |- direct node (2)
639 | `- data (1018)
640 |- indirect node (2)
641 | `- direct node (1018)
642 | `- data (1018)
643 `- double indirect node (1)
644 `- indirect node (1018)
645 `- direct node (1018)
646 `- data (1018)
654 -------------------
658 - hash hash value of the file name
659 - ino inode number
660 - len the length of file name
661 - type file type such as directory, symlink, etc
663 A dentry block consists of 214 dentry slots and file names. Therein a bitmap is
664 used to represent whether each dentry is valid or not. A dentry block occupies
669 Dentry Block(4 K) = bitmap (27 bytes) + reserved (3 bytes) +
673 +--------------------------------+
674 |dentry block 1 | dentry block 2 |
675 +--------------------------------+
678 . [Dentry Block Structure: 4KB] .
679 +--------+----------+----------+------------+
681 +--------+----------+----------+------------+
682 [Dentry Block: 4KB] . .
685 +------+------+-----+------+
687 +------+------+-----+------+
690 F2FS implements multi-level hash tables for directory structure. Each level has
696 ----------------------
698 B : block
700 ----------------------
704 level #1 | A(2B) - A(2B)
706 level #2 | A(2B) - A(2B) - A(2B) - A(2B)
708 level #N/2 | A(2B) - A(2B) - A(2B) - A(2B) - A(2B) - ... - A(2B)
710 level #N | A(4B) - A(4B) - A(4B) - A(4B) - A(4B) - ... - A(4B)
714 ,- 2, if n < MAX_DIR_HASH_DEPTH / 2,
716 `- 4, Otherwise
718 ,- 2^(n + dir_level),
721 `- 2^((MAX_DIR_HASH_DEPTH / 2) - 1),
740 --------------> Dir <--------------
744 child - child [hole] - child
746 child - child - child [hole] - [hole] - child
750 File size = 7 File size = 7
752 Default Block Allocation
753 ------------------------
758 - Hot node contains direct node blocks of directories.
759 - Warm node contains direct node blocks except hot node blocks.
760 - Cold node contains indirect node blocks
761 - Hot data contains dentry blocks
762 - Warm data contains data blocks except hot and cold data blocks
763 - Cold data contains multimedia data or migrated data blocks
765 LFS has two schemes for free space management: threaded log and copy-and-compac-
766 tion. The copy-and-compaction scheme which is known as cleaning, is well-suited
771 scheme where the copy-and-compaction scheme is adopted by default, but the
775 In order to align F2FS with underlying flash-based storage, F2FS allocates a
776 segment in a unit of section. F2FS expects that the section size would be the
777 same as the unit size of garbage collection in FTL. Furthermore, with respect
783 ----------------
785 F2FS does cleaning both on demand and in the background. On-demand cleaning is
790 F2FS supports two victim selection policies: greedy and cost-benefit algorithms.
792 of valid blocks. In the cost-benefit algorithm, F2FS selects a victim segment
794 log block thrashing problem in the greedy algorithm. F2FS adopts the greedy
795 algorithm for on-demand cleaner, while background cleaner adopts cost-benefit
799 F2FS manages a bitmap. Each bit represents the validity of a block, and the
802 Write-hint Policy
803 -----------------
808 User F2FS Block
817 -- buffered io
822 -- direct io
832 -------------------
837 The default operation (i.e., mode is zero) of fallocate() allocates
839 file size (as reported by stat(2)) will be changed if offset+len is
840 greater than the file size. Any subregion within the range specified
847 fallocate(fd, DEFAULT_MODE), it allocates on-disk block addresses having
852 3. fallocate(fd, 0, 0, size)
858 --------------------------
860 - New term named cluster is defined as basic unit of compression, file can
862 (n >= 0) logical pages, compression size is also cluster size, each of
865 - In cluster metadata layout, one special block address is used to indicate
867 metadata maps cluster to [1, 4 << n - 1] physical blocks, in where f2fs
870 - In order to eliminate write amplification during overwrite, F2FS only
871 support compression on write-once file, data can be compressed only when
875 - To enable compression on regular inode, there are four ways:
879 * mount w/ -o compress_extension=ext; touch file.ext
880 * mount w/ -o compress_extension=*; touch any_file
882 - To disable compression on regular inode, there are two ways:
884 * chattr -c file
885 * mount w/ -o nocompress_extension=ext; touch file.ext
887 - Priority in between FS_COMPR_FL, FS_NOCOMP_FS, extensions:
891 should be compresse, bar.zip should be non-compressed. chattr +c dir/bar.zip
893 * compress_extension=so; nocompress_extension=zip; chattr -c dir; touch
895 compresse, bar.zip and baz.txt should be non-compressed.
899 - At this point, compression feature doesn't expose compressed space to user
906 will block writing data to the file until either the compressed space is
907 reserved via ioctl(F2FS_IOC_RESERVE_COMPRESS_BLOCKS) or the file size is
913 +-----------------------------------------------+
915 +-----------------------------------------------+
919 +----------+---------+---------+---------+ +---------+---------+---------+---------+
920 |compr flag| block 1 | block 2 | block 3 | | block 1 | block 2 | block 3 | block 4 |
921 +----------+---------+---------+---------+ +---------+---------+---------+---------+
925 +-------------+-------------+----------+----------------------------+
927 +-------------+-------------+----------+----------------------------+
930 --------------------------
958 ----------------------------
960 - ZNS defines a per-zone capacity which can be equal or less than the
961 zone-size. Zone-capacity is the number of usable blocks in the zone.
962 F2FS checks if zone-capacity is less than zone-size, if it is, then any
963 segment which starts after the zone-capacity is marked as not-free in
967 zone-capacity is not aligned to default segment size(2MB), then a segment
968 can start before the zone-capacity and span across zone-capacity boundary.
970 past the zone-capacity are considered unusable in these segments.
973 -----------------------
985 <use-case>
990 # mkfs.f2fs -c /dev/vdc@vdc.file /dev/vdb
992 # ls -l /mnt/f2fs
994 # df -h
997 # mount -o loop /dev/vdc /mnt/ext4
998 # df -h
1009 # df -h
1014 That doesn't require modifying partition size and filesystem format.