]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
f2fs: introduce FAULT_INCONSISTENT_FOOTER
authorChao Yu <chao@kernel.org>
Wed, 5 Mar 2025 09:11:48 +0000 (17:11 +0800)
committerJaegeuk Kim <jaegeuk@kernel.org>
Tue, 11 Mar 2025 03:25:53 +0000 (03:25 +0000)
To simulate inconsistent node footer error.

Signed-off-by: Chao Yu <chao@kernel.org>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
Documentation/ABI/testing/sysfs-fs-f2fs
Documentation/filesystems/f2fs.rst
fs/f2fs/f2fs.h
fs/f2fs/node.c
fs/f2fs/super.c

index 81deae2af84d2a6b7b2999dfb3c86c9a246f3131..b9a000e5098abdf1e2c5e5bcd621cc7caf61b9ce 100644 (file)
@@ -734,6 +734,7 @@ Description:        Support configuring fault injection type, should be
                FAULT_BLKADDR_VALIDITY           0x000040000
                FAULT_BLKADDR_CONSISTENCE        0x000080000
                FAULT_NO_SEGMENT                 0x000100000
+               FAULT_INCONSISTENT_FOOTER        0x000200000
                ===========================      ===========
 
 What:          /sys/fs/f2fs/<disk>/discard_io_aware_gran
index aad08eff05029bfa12ab23747f367e335825539c..e15c4275862a721c44953b4908ef70e7239f4e46 100644 (file)
@@ -206,6 +206,7 @@ fault_type=%d                Support configuring fault injection type, should be
                         FAULT_BLKADDR_VALIDITY           0x000040000
                         FAULT_BLKADDR_CONSISTENCE        0x000080000
                         FAULT_NO_SEGMENT                 0x000100000
+                        FAULT_INCONSISTENT_FOOTER        0x000200000
                         ===========================      ===========
 mode=%s                         Control block allocation mode which supports "adaptive"
                         and "lfs". In "lfs" mode, there should be no random
index 9ddf73c627f55dbdfb04c6cccd05a30b1d588d7b..307ec68d8de04c6e7a09d3e26973f7962d51ef95 100644 (file)
@@ -62,6 +62,7 @@ enum {
        FAULT_BLKADDR_VALIDITY,
        FAULT_BLKADDR_CONSISTENCE,
        FAULT_NO_SEGMENT,
+       FAULT_INCONSISTENT_FOOTER,
        FAULT_MAX,
 };
 
index f958ce9f58aedad8b303c42e7bce044eca679876..9ea40fa22b3fba4471247ce1a449770e5ffc6a23 100644 (file)
@@ -1463,7 +1463,8 @@ static int sanity_check_node_footer(struct f2fs_sb_info *sbi,
        if (unlikely(nid != nid_of_node(page) ||
                (ntype == NODE_TYPE_INODE && !IS_INODE(page)) ||
                (ntype == NODE_TYPE_XATTR &&
-               !f2fs_has_xattr_block(ofs_of_node(page))))) {
+               !f2fs_has_xattr_block(ofs_of_node(page))) ||
+               time_to_inject(sbi, FAULT_INCONSISTENT_FOOTER))) {
                f2fs_warn(sbi, "inconsistent node block, node_type:%d, nid:%lu, "
                          "node_footer[nid:%u,ino:%u,ofs:%u,cpver:%llu,blkaddr:%u]",
                          ntype, nid, nid_of_node(page), ino_of_node(page),
index a2808f5fd705627bd1d7f9dad60bd80d3f6c2b56..397df271885ce616d1d1893b3cb60d7202943aed 100644 (file)
@@ -63,6 +63,7 @@ const char *f2fs_fault_name[FAULT_MAX] = {
        [FAULT_BLKADDR_VALIDITY]        = "invalid blkaddr",
        [FAULT_BLKADDR_CONSISTENCE]     = "inconsistent blkaddr",
        [FAULT_NO_SEGMENT]              = "no free segment",
+       [FAULT_INCONSISTENT_FOOTER]     = "inconsistent footer",
 };
 
 int f2fs_build_fault_attr(struct f2fs_sb_info *sbi, unsigned long rate,