ArticleslgStudy

science

F2FS

F2FS is a science topic covered in the lgStudy science library. This page brings together a partial reference excerpt, illustrations, worked examples, real-world applications and a short study plan, so you can understand F2FS rather than just read about it. In short: F2FS (Flash-Friendly File System) is a flash file system initially developed by Samsung Electronics for the Linux kernel. 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), which are widely used in computer systems ranging from mobile devices to servers.

Key takeaways

  • F2FS belongs to science; place it in that map before memorising details.
  • Learn the definition first, then one example that makes the definition concrete.
  • Connect F2FS to a quantity you can measure, compute or draw — that is where exam questions come from.
  • Reproduce the core statement of F2FS from memory before moving on to harder problems.

Reference excerpt

F2FS (Flash-Friendly File System) is a flash file system initially developed by Samsung Electronics for the Linux kernel. 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), which are widely used in computer systems ranging from mobile devices to servers. F2FS was designed on a basis of a log-structured file system approach, which is adapted to newer forms of storage. Jaegeuk Kim, the principal F2FS author, has stated that it 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 algorithms.

Features Multi-head logging Multi-level hash table for directory entries Static/dynamic hot and cold data separation Adaptive logging scheme Configurable operational units Dual checkpoint Roll-back and roll-forward recovery Heap-style block allocation TRIM/FITRIM support Online fs defragmentation/file defragmentation Inline xattrs/data/dir Offline filesystem check (Check and fix inconsistency) Atomic operations Filesystem-level encryption Offline resizing (shrinking not supported.) Inner periodically data flush Extent cache Transparent file compression using LZO or LZ4 (with Linux 5.6), or zstd (with Linux 5.7)

Design

On-disk layout F2FS divides the whole volume into a number of segments, each of which is fixed at 2 MB. A section is composed of consecutive segments, and a zone consists of a set of sections. By default, section and zone sizes are set to the same size, but users can easily modify the size with mkfs. F2FS splits the entire volume into six areas, and all except the superblock area consist of multiple segments as described below.

Superblock (SB) The SB is located at the beginning of the partition. There are two copies to avoid file-system corruption. It contains basic partition information and some default F2FS parameters. Checkpoint (CP) The CP contains file system information, bitmaps for valid NAT/SIT sets, orphan inode lists, and summary entries of current active segments. Segment Information Table (SIT) The SIT contains the valid block count and validity bitmap of all the Main Area blocks. Node Address Table (NAT) The NAT is an address table for the Main Area node blocks. Segment Summary Area (SSA) The SSA contains entries which contain the owner information of the Main Area data and node blocks. Main Area The main area contains file and directory data and their indices. In order to avoid misalignment between file system and flash storage, F2FS aligns the start block address of the CP with the segment size. It also aligns the Main Area start block address with the zone size by reserving some segments in the SSA area.

Metadata structure F2FS uses the checkpoint scheme to maintain file system integrity. At mount time, F2FS first tries to find the last valid checkpoint data by scanning the CP area. In order to reduce the scanning time, F2FS uses only two copies of the CP. One of them always indicates the last valid data, which is called a shadow copy mechanism. In addition to the CP, the NAT and SIT also use the shadow copy mechanism. For file system consistency, each CP points to which NAT and SIT copies are valid.

Index structure The key data structure is the "node". Similar to traditional file structures, F2FS has three types of nodes: inode, direct node, indirect node. F2FS assigns 4 KB to an inode block which contains 923 data block indices, two direct node pointers, two indirect node pointers, and one double indirect node pointer as described below. A direct node block contains 1018 data block indices, and an indirect node block contains 1018 node block indices. Thus, one inode block (i.e., a file) covers:

4 KiB × (923 + 2×1018 + 2×10182 + 10183) = 4,228,213,756 KiB = 4,129,114.996 MiB = 4,032.338863 GiB = 3.937830921 TiB

Note that all the node blocks are mapped by the NAT, which means that the location of each node is translated by the NAT. To mitigate the wandering tree problem, F2FS is able to cut off the propagation of node updates caused by leaf data writes.

Directory structure A directory entry (dentry) occupies 11 bytes, which consists of the following attributes.

A dentry block consists of 214 dentry slots and file names. A bitmap is used to represent whether each dentry is valid or not. A dentry block occupies 4 KB and has the following composition:

Dentry Block (4 K) = bitmap (27 bytes) + reserved (3 bytes) + dentries (11 * 214 bytes) + file name (8 * 214 bytes)

F2FS implements multi-level hash tables for the directory structure. Each level has a hash table with a dedicated number of hash buckets as shown below. Note that "A(2B)" means a bucket includes 2 data blocks.

Term A indicates bucket B indicates block N indicates MAX_DIR_HASH_DEPTH level #0 A(2B) level #1 A(2B) - A(2B) level #2 A(2B) - A(2B) - A(2B) - A(2B) ... level #N/2 A(2B) - A(2B) - A(2B) - A(2B) - A(2B) - ... - A(2B) ... level #N A(4B) - A(4B) - A(4B) - A(4B) - A(4B) - ... - A(4B)

When F2FS finds a file name in a directory, first a hash value of the file name is calculated. Then, F2FS scans the hash table in level #0 to find the dentry consisting of the file name and its inode number. If not found, F2FS scans the next hash table in level #1. In this way, F2FS scans hash tables in each level incrementally from 1 to N. In each level F2FS needs to scan only one bucket determined by the following equation, which shows O(log(# of files)) complexity.

bucket number to scan in level #n = (hash value) % (# of buckets in level #n)

In the case of file creation, F2FS finds empty consecutive slots that cover the file name. F2FS searches the empty slots in the hash tables of whole levels from 1 to N in the same way as the lookup operation.

Default block allocation At runtime, F2FS manages six active logs inside the "Main Area:" Hot/Warm/Cold node and Hot/Warm/Cold data.

… excerpt ends here. Continue reading the full article.

Worked examples

Example 1 — a first encounter with F2FS

Start with the simplest possible case. Write down what F2FS claims or describes in one sentence, then invent the smallest concrete situation in which that sentence is true. In science, the smallest case is usually a single object, a single equation or a single measurement. Check that every symbol or term in your sentence has a meaning in that case.

Example 2 — changing one variable

Take the situation from Example 1 and change exactly one quantity: double it, halve it, or set it to zero. Predict what should happen to F2FS before you calculate. Comparing your prediction with the result is the fastest way to find out whether you understand the idea or only the words.

Example 3 — an exam-style question

Typical questions about F2FS ask you to (a) state it precisely, (b) apply it to given data, and (c) explain a limitation. Practise writing all three answers in under five minutes; the third part is what separates a full-mark answer from an average one.

Applications of F2FS

In research
F2FS appears in science research whenever the underlying quantities have to be modelled precisely. Papers usually cite it as a starting assumption and then explore where it breaks down.
In technology and industry
Engineering practice reuses F2FS in design rules, simulations and safety margins. Knowing the idea lets you read a specification sheet and understand why the numbers look the way they do.
In the classroom
F2FS is common in secondary-school and first-year university syllabi. It links to neighbouring topics Compression file systems, Embedded Linux, Flash file systems supported by the Linux kernel, so understanding it makes those chapters shorter.
In everyday life
Look for F2FS outside the textbook — in sport, cooking, traffic, electronics or the sky above you. An example you found yourself is remembered far longer than one you were given.
Ask Teacher Smith questions about this articleOpens your AI tutor with a question about “F2FS” →

How to study F2FS in 20 minutes

  1. Read the reference excerpt below once, without taking notes.
  2. Close the page and write down what F2FS means in your own words.
  3. Compare your version with the excerpt and mark what you missed.
  4. Work through the three examples above with pen and paper.
  5. Explain F2FS out loud to somebody else — or to Teacher Smith in the lgStudy chat.

Frequently asked questions

What is F2FS in simple terms?

F2FS (Flash-Friendly File System) is a flash file system initially developed by Samsung Electronics for the Linux kernel. 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…

Why does F2FS matter?

Because it connects several science ideas at once: it gives you a definition you can apply, a quantity you can calculate, and a way to check whether a result is plausible.

How should I study F2FS?

Read the excerpt, restate it from memory, then work through the examples and applications listed on this page. The five-step study plan above takes about twenty minutes.

What does this page cover?

It gives you a compact reference excerpt plus original lgStudy explanations, examples, applications and study material on F2FS.

Tags

  • Compression file systems
  • Embedded Linux
  • Flash file systems supported by the Linux kernel
  • Free special-purpose file systems

Keep exploring