Commit Graph

1033 Commits

Author SHA1 Message Date
Sheng Yong
0d7c27c5da inject.f2fs: add sit injection
This patch enables injecting sit entry. print_raw_sit_entry_info() is
added to show values of the sit entry.

The meanings of options are:
 * sit: means sit entry is injected, its argument chooses which sit pack
        to be injected, where 0 means the current valid sit is choosen
	automatically.
 * blk: is the block address of the sit entry.

The members could be injected in cp contains:
 * vblocks: sit entry vblocks
 * valid_map: sit entry valid_map
 * mtime: sit entry mtime

Reviewed-by: Chao Yu <chao@kernel.org>
Signed-off-by: Sheng Yong <shengyong@oppo.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2024-07-25 18:40:29 +00:00
Sheng Yong
28754d326c inject.f2fs: add nat injection
This patch enables injecting nat entry. print_raw_nat_entry_info() is
added to show values of the nat entry.

The meanings of options are:
 * nat: means nat entry is injected, its argument chooses which nat pack
        to be injected, where 0 means the current valid nat is choosen
	automatically.
 * nid: is the nid of the nat entry

The members could be injected in cp contains:
 * version: nat entry version
 * ino: nat entry ino
 * block_addr: nat entry block_addr

Reviewed-by: Chao Yu <chao@kernel.org>
Signed-off-by: Sheng Yong <shengyong@oppo.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2024-07-25 18:40:29 +00:00
Sheng Yong
a6cca0edf0 inject.f2fs: add cp injection
This patch enables injecting checkpoint. To archive this, a helper
write_raw_cp_blocks() is added to write the first and last blocks
of a specific cp. And print_ckpt_info() is exported to show new
checkpoint info.

The meanings of options are:
 * cp: means cp is injected, its argument chooses which cp pack to be
       injected, where 0 means the current valid cp is choosen
       automatically.

The members could be injected in cp contains:
 * checkpoint_ver: checkpoint version
 * ckpt_flags: checkpoint flags
 * cur_node_segno: cur_node_segno array
 * cur_node_blkoff: cur_node_blkoff array
 * cur_data_segno: cur_data_segno array
 * cur_data_blkoff: cur_data_blkoff array

Reviewed-by: Chao Yu <chao@kernel.org>
Signed-off-by: Sheng Yong <shengyong@oppo.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2024-07-25 18:40:29 +00:00
Sheng Yong
082e3515a7 inject.f2fs: add sb injection
This patch enables injecting super block.

The meanings of options are:
 * sb: means sb is injected, its argument chooses which sb pack to be
       injected, where 0 means the current valid sb is choosen
       automatically.
 * mb: indicates which member in sb is injected, its argument is the
       member name.
 * idx: is used when the mb is an array, its argument is the index of
        the array.
 * val: is the new value to be set when the type of mb is a number.
 * str: is the new value to be set when the type of mb is a string.

The members could be injected in sb contains:
 * magic: magic number
 * s_stop_reason: s_stop_reason array
 * s_errors: s_errors array
 * devs.path: path in devs array

Signed-off-by: Sheng Yong <shengyong@oppo.com>
Reviewed-by: Chao Yu <chao@kernel.org>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2024-07-25 18:40:29 +00:00
Sheng Yong
b39aa80647 inject.f2fs: introduce inject.f2fs
This patch introduces a new tool inject.f2fs to modify metadata or data
(directory entry) of f2fs image offline flexibly.

With inject.f2fs, it is easier to generate a corrupted f2fs image, which
can help verify fsck or reproduce userspace behaviors of some a fault.
If option `--dry-run' is used, nothing really gets changed, and that
could be used to get the value of a specified field.

The following patches enable injecting each part of f2fs.

Reviewed-by: Chao Yu <chao@kernel.org>
Signed-off-by: Sheng Yong <shengyong@oppo.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2024-07-25 18:40:29 +00:00
Sheng Yong
a9066a4e23 f2fs-tools: cleanup is_sit_bitmap_set
Remove redundant function definition of is_sit_bitmap_set() and
export it.

Signed-off-by: Sheng Yong <shengyong@oppo.com>
Reviewed-by: Chao Yu <chao@kernel.org>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2024-07-25 18:40:29 +00:00
Sheng Yong
2c7fa4f0a1 f2fs-tools: show device info of sb->devs
Show multidevice infomation like the follwoing:

  devs[i].path                            [meta.img]
  devs[i].total_segments                  [0x      3f : 63]
  devs[i].path                            [data.img]
  devs[i].total_segments                  [0x      80 : 128]

Signed-off-by: Sheng Yong <shengyong@oppo.com>
Reviewed-by: Chao Yu <chao@kernel.org>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2024-07-25 18:40:29 +00:00
Sheng Yong
2d653ca599 fsck.f2fs: check all-zero inline data with helper is_zeroed
Signed-off-by: Sheng Yong <shengyong@oppo.com>
Reviewed-by: Chao Yu <chao@kernel.org>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2024-07-25 18:40:28 +00:00
Sheng Yong
752fcbe65a fsck.f2fs: fix checking wp of all devices
For zoned model, the first device (devices[0]) is not zoned device,
whose zoned_model is not F2FS_ZONED_HM. Let's skip it and check write
pointer of left devices continuously.

Signed-off-by: Sheng Yong <shengyong@oppo.com>
Reviewed-by: Chao Yu <chao@kernel.org>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2024-07-25 18:40:28 +00:00
Sheng Yong
3a3d362a86 fsck.f2fs: update superblock if invalid
If a superblock failed in sanity check, it should be fixed. This patch
add a new state `sb_invalid' to tell fsck needs to update superblock
at the end of all checkings.

This patch also cleans up force_stop, abnormal_stop, fs_errors and
sb_invalid by merging them into an `invalid_sb' flags, and each of
them is indicated using one bit.

Signed-off-by: Sheng Yong <shengyong@oppo.com>
Reviewed-by: Chao Yu <chao@kernel.org>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2024-07-25 18:40:28 +00:00
Chao Yu
d31d5f26ae f2fs-tools: clean up addrs_per_{inode,block}()
Introduce a new help addrs_per_page() to wrap common code
from addrs_per_inode() and addrs_per_block() for cleanup.

Signed-off-by: Chao Yu <chao@kernel.org>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2024-07-25 18:40:28 +00:00
Chao Yu
250d610d62 f2fs-tools: fix to add missing le32_to_cpu()/cpu_to_le32()
This patch fixes some cases in where we missed to consider
endianness when we access/update inode.i_flags.

Signed-off-by: Chao Yu <chao@kernel.org>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2024-07-25 18:40:28 +00:00
Chao Yu
1a1e775935 f2fs-tools: fix to do not dump inode if it has F2FS_NODUMP_FL flag
Quoted from manual of chattr:
"
CHATTR(1)
...

ATTRIBUTES
A file with the 'd' attribute set is not a candidate for backup when
the dump(8) program is run.
"

Once we set F2FS_NODUMP_FL flag to inode, do not allow dumping info
from it.

Signed-off-by: Chao Yu <chao@kernel.org>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2024-07-25 18:40:28 +00:00
Wu Bo
4f7ac389f4 libf2fs: add BLKFINISHZONE define if not defined
BLKFINISHZONE may not defined in old blkzoned.h, and cause build error.

Signed-off-by: Wu Bo <bo.wu@vivo.com>
Reviewed-by: Chao Yu <chao@kernel.org>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2024-07-25 18:40:28 +00:00
Daniel Rosenberg
a66d49fd26 dump.f2fs: Dump symlinks as symlinks
Previously, dumped symlinks would always create regular files instead.
This allows symlinks to be dumped as symlinks with the -L option.

The i_name field's name may not be the same as the actual name from the
dirent, so we use the dirent name when available.

Currently hardlinks aren't detected, so print a warning if we notice a
nondirectory with a link count over 1.

Signed-off-by: Daniel Rosenberg <drosen@google.com>
Reviewed-by: Chao Yu <chao@kernel.org>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2024-07-25 18:40:28 +00:00
Sheng Yong
4a5da2ef15 f2fs-tools: export is_digits
Reviewed-by: Chao Yu <chao@kernel.org>
Signed-off-by: Sheng Yong <shengyong@oppo.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2024-07-10 22:51:40 +00:00
Xiuhong Wang
bd1474707d f2fs-tools: fix do_set_verity ioctl fail issue
When using the f2fs_io tool to set_verity, it will fail as follows:
unisc:/data # ./f2fs_io set_verity file
FS_IOC_ENABLE_VERITY: Inappropriate ioctl for device
this is because commit: 95ae251fe828 ("f2fs: add fs-verity support"),
the passed parameters do not match the latest kernel version.

After patch:
unisoc:/data # ./f2fs_io set_verity file
Set fsverity bit to file
unisoc:/data # ./f2fs_io getflags file
get a flag on file ret=0, flags=verity

Fixes: 95ae251fe828 ("f2fs: add fs-verity support")
Signed-off-by: Xiuhong Wang <xiuhong.wang@unisoc.com>
Signed-off-by: Zhiguo Niu <zhiguo.niu@unisoc.com>
Reviewed-by: Chao Yu <chao@kernel.org>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2024-07-09 21:41:18 +00:00
Xiuhong Wang
584ebc710b f2fs-tools: use atoll replace atoi to avoid data truncate
If input exceeds int range, data will be truncated, such as lseek:
unisoc:/data # ./f2fs_io lseek set 3221225000 file
returned offset=2147483647
The offset is truncated.

After patch:
unisoc:/data # ./f2fs_io lseek set 3221225000 file
returned offset=3221225000

Signed-off-by: Xiuhong Wang <xiuhong.wang@unisoc.com>
Signed-off-by: Zhiguo Niu <zhiguo.niu@unisoc.com>
Reviewed-by: Chao Yu <chao@kernel.org>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2024-06-24 17:47:35 +00:00
Daniel Rosenberg
b5ec029d2b dump.f2fs: Fix dumping inlined files
The code for dumping files was ignoring i_extra_isize, leading to
invalid data for some inlined files after dumping. This swaps inode
dumping to use the common inline_data_addr function.

Signed-off-by: Daniel Rosenberg <drosen@google.com>
Reviewed-by: Chao Yu <chao@kernel.org>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2024-06-24 17:44:31 +00:00
Chao Yu
c07b095450 dump.f2fs: update dump_usage() for directory dumping
Add missing usage for directory dumping functionality of dump.f2fs
as below:

  -r dump out from the root inode
  -f do not prompt before dumping
  -y alias for -f
  -o dump inodes to the given path
  -P preserve mode/owner/group for dumped inode

Cc: Daniel Rosenberg <drosen@google.com>
Signed-off-by: Chao Yu <chao@kernel.org>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2024-06-04 18:11:49 +00:00
Chao Yu
a3104a1597 f2fs_io: fix output of do_read()
echo 1 > file
f2fs_io read 1 0 1 dio 4096 ./file
Read 0 bytes total_time = 17 us, print 4096 bytes:
00000000 : ffffffd537 ffffffc957 0500 0000 0000 0000 0000 0000
00000100 : 0000 0000 0000 0000 0000 0000 0000 0000
00000200 : 0000 0000 0000 0000 0000 0000 0000 0000
00000300 : 0000 0000 0000 0000 ffffffc10f 0200 0000 0000

For the case reading across EOF, it missed to copy returned
data to print_buf.

After:
f2fs_io read 1 0 1 dio 4096 ./file
pread expected: 4096, readed: 2
Read 2 bytes total_time = 177 us, print 4096 bytes:
00000000 : 310a 0000 0000 0000 0000 0000 0000 0000

Signed-off-by: Chao Yu <chao@kernel.org>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2024-05-30 23:42:53 +00:00
Daniel Rosenberg
c1a97862b0 dump.f2fs: Fix xattr dumping
Xattrs for files with inline data were being skipped. This dumps those,
as well as xattrs for folders.

Signed-off-by: Daniel Rosenberg <drosen@google.com>
Reviewed-by: Daeho Jeong <daehojeong@google.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2024-05-23 23:28:35 +00:00
Daniel Rosenberg
d5a053ee06 dump.f2fs: Add ability to dump folders
This adds the ability to dump folders as well as files. Folders are
dumped recursively. Additionally, dumped files/folders may be directed
to a folder specified by -o [path] instead of ./lost_found. The -r flag
will dump the entire fs from the root inode. -f or -y will skip the
prompt before dumping, and -P will preserve the mode/owner info for the
created file/folder.

Signed-off-by: Daniel Rosenberg <drosen@google.com>
Reviewed-by: Daeho Jeong <daehojeong@google.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2024-05-23 23:28:29 +00:00
Sheng Yong
5cfe1971ad mkfs.f2fs: align each device to zone size
For multiple device, each device should be aligned to zone size, instead
of aligning the total size.

Signed-off-by: Sheng Yong <shengyong@oppo.com>
Reviewed-by: Chao Yu <chao@kernel.org>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2024-05-09 00:42:09 +00:00
Chao Yu
acaa17359c mkfs.f2fs: add description for ro feature in manual
Add missing description for readonly feature in manual of mkfs.f2fs.

Signed-off-by: Chao Yu <chao@kernel.org>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2024-04-16 16:54:02 +00:00
Chao Yu
91e7365533 f2fs_io: support unset subcommand for pinfile
This patch adds unset subcommand for pinfile command.

Usage: f2fs_io pinfile unset [target_file]

Signed-off-by: Chao Yu <chao@kernel.org>
Reviewed-by: Daeho Jeong <daehojeong@google.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2024-04-12 20:54:18 +00:00
Sheng Yong
cc40084468 f2fs-tools: print extension list properly
The "hot file extensions" list does not print properly.

**Before**

extension_count                         [0x      23 : 35]
cold file extentsions
                                        [mp      wm      og      jp      ]
                                        [avi     m4v     m4p     mkv     ]
                                        [mov     webm    wav     m4a     ]
                                        [3gp     opus    flac    gif     ]
                                        [png     svg     webp    jar     ]
                                        [deb     iso     gz      xz      ]
                                        [zst     pdf     pyc     ttc     ]
                                        [ttf     exe     apk     cnt     ]
                                        [exo     odex    vdex    ]
hot_ext_count                           [0x       1 : 1]
hot file extentsions
db      ]
cp_payload                              [0x       0 : 0]

**After**

extension_count                         [0x      23 : 35]
cold file extentsions
                                        [mp      wm      og      jp      ]
                                        [avi     m4v     m4p     mkv     ]
                                        [mov     webm    wav     m4a     ]
                                        [3gp     opus    flac    gif     ]
                                        [png     svg     webp    jar     ]
                                        [deb     iso     gz      xz      ]
                                        [zst     pdf     pyc     ttc     ]
                                        [ttf     exe     apk     cnt     ]
                                        [exo     odex    vdex            ]
hot_ext_count                           [0x       1 : 1]
hot file extentsions
                                        [db                              ]
cp_payload                              [0x       0 : 0]

Signed-off-by: Sheng Yong <shengyong@oppo.com>
Reviewed-by: Chao Yu <chao@kernel.org>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2024-04-10 00:35:35 +00:00
Jaegeuk Kim
5da4e52415 f2fs-tools: give 6 sections for overprovision buffer
This addresses high GC cost at runtime.

Reviewed-by: Daeho Jeong <daehojeong@google.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2024-04-08 18:10:33 +00:00
Daeho Jeong
f611eac6d9 f2fs-tools: reset only current zones
Send reset commands to only current zones and finish the others.

Signed-off-by: Daeho Jeong <daehojeong@google.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2024-03-11 13:37:43 -07:00
Chao Yu
151fdb1aa0 f2fs_io: support get_advise command
Support get_advise command to get i_advise field value and info
in file.

For example:
f2fs_io get_advise /mnt/f2fs/foo.so
i_advise=0x11, advise_type: cold keep_size

Signed-off-by: Chao Yu <chao@kernel.org>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2024-03-08 13:34:54 -08:00
Jaegeuk Kim
dc03566da7 mkfs.f2fs: should give section-aligned reserved segments
The reserved segments should be aligned to the section boundary.

Reviewed-by: Daeho Jeong <daehojeong@google.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2024-03-08 13:34:51 -08:00
Jaegeuk Kim
efcff4bc16 f2fs-tools: deal with permission denial on non-root user
This fixes some android build failures due to the missing permission when
checking the loop device. Until we get a better solution, let's ignore
the error with warnings.

Reviewed-by: Huang Jianan <huangjianan@xiaomi.com>
Reviewed-by: Daeho Jeong <daehojeong@google.com>
Reviewed-by: Chao Yu <chao@kernel.org>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2024-03-06 09:42:08 -08:00
Chao Yu
4ecb90c2e3 f2fs-tools: print hexadecimal number in log
Otherwise, it will waste time to convert for comparison.

Signed-off-by: Chao Yu <chao@kernel.org>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2024-02-23 14:59:40 -08:00
Chao Yu
71855932e7 f2fs-tools: use NULL_ADDR macro to instead magic number for cleanup
Use NULL_ADDR macro to instead magic number for cleanup.

Signed-off-by: Chao Yu <chao@kernel.org>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2024-02-23 14:59:33 -08:00
Chao Yu
4f1ab35c65 f2fs-tools: remove obsolete fields in struct f2fs_sb_info
No logic change.

Signed-off-by: Chao Yu <chao@kernel.org>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2024-02-23 14:59:17 -08:00
Chao Yu
d1225a911d mkfs.f2fs: kill heap allocation
No one uses this feature. Let's kill it.

Signed-off-by: Chao Yu <chao@kernel.org>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2024-02-21 09:42:41 -08:00
Konstantin Vyshetsky
b6fad4e648 f2fs_io: add write_advice command
Add a write_advice command with same behavior as existing write command
with the exception that data should be treated as hot or cold.

Signed-off-by: Konstantin Vyshetsky <vkon@google.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2024-02-21 09:41:52 -08:00
Konstantin Vyshetsky
575e8e05d3 f2fs_io: override setxattr value for system.advise
Adjust behavior to match kernel.

Signed-off-by: Konstantin Vyshetsky <vkon@google.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2024-02-21 09:41:52 -08:00
Zhiguo Niu
ab654fcca2 f2fs-tools: add a new stop cp reason STOP_CP_REASON_NO_SEGMENT
Add a new stop cp reason STOP_CP_REASON_NO_SEGMENT for keeping
consistent with kernel codes.

Signed-off-by: Zhiguo Niu <zhiguo.niu@unisoc.com>
Reviewed-by: Chao Yu <chao@kernel.org>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2024-02-21 09:38:14 -08:00
Daeho Jeong
06393fda81 f2fs_io: add lseek command to execute lseek()
Added lseek command to support lseek() for SEEK_DATA and SEEK_HOLE.

Signed-off-by: Daeho Jeong <daehojeong@google.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2024-02-15 13:49:34 -08:00
Jaegeuk Kim
e22c886268 mkfs.f2fs: fix sparse_mode case on stat
When we turn on sparse_mode, stat() will be failed, as the file will be
created afterwards. Let's fix.

Fixes: 14197d546b ("f2fs-tools: fix to check loop device")
Reviewed-by: Daeho Jeong <daehojeong@google.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2024-02-13 16:23:05 -08:00
Chao Yu
14197d546b f2fs-tools: fix to check loop device
Otherwise, mkfs/fsck can update backfile of moutned loop device.

1. mkfs.f2fs image
2. mount -o loop image /mnt/f2fs/
3. mkfs.f2fs image -f

Before:
...
Info: format successful

After:
...
	Error: In use by loop device!

Signed-off-by: Chao Yu <chao@kernel.org>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2024-02-07 16:25:51 -08:00
Daeho Jeong
96da467d93 f2fs-tools: allocate logs after conventional area for HM zoned devices
Make to allocate logs after conventional area for HM zoned devices to
spare them for file pinning support.

Signed-off-by: Daeho Jeong <daehojeong@google.com>
Reviewed-by: Chao Yu <chao@kernel.org>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2024-02-07 16:22:14 -08:00
Daniel Rosenberg
eca9049a07 libf2fs: Fix possible memleak with Sparse Files
If sparse files is set along with multiple devices, we initialize
sparse file data multiple times without freeing the previously allocated
data. This skips the initialization for subsequent devices, as sparse
file mode currently only deals with device 0 anyways.

Signed-off-by: Daniel Rosenberg <drosen@google.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2024-01-29 12:14:56 -08:00
Daniel Rosenberg
9f435e3d57 libf2fs: Accept Sparse files with non 4K Blocksize
Since we may not know the block size when initializing sparse files, we
should assume that the sparse file's blocksize is correct.

Signed-off-by: Daniel Rosenberg <drosen@google.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2024-01-29 12:14:52 -08:00
Chao Yu
dff4893b49 f2fs-tools: don't call fsync on a clean image
generic/019 50s ... _check_generic_filesystem: filesystem on /dev/vdc is inconsistent
(see /media/fstests/results//generic/019.full for details)

[FSCK] Max image size: 16196 MB, Free space: 188 MB
[FSCK] Unreachable nat entries                        [Ok..] [0x0]
[FSCK] SIT valid block bitmap checking                [Ok..]
[FSCK] Hard link checking for regular file            [Ok..] [0x166]
[FSCK] valid_block_count matching with CP             [Ok..] [0x3ecfe7]
[FSCK] valid_node_count matching with CP (de lookup)  [Ok..] [0x4c79]
[FSCK] valid_node_count matching with CP (nat lookup) [Ok..] [0x4c79]
[FSCK] valid_inode_count matched with CP              [Ok..] [0xb46]
[FSCK] free segment_count matched with CP             [Ok..] [0x9d]
[FSCK] next block offset is free                      [Ok..]
[FSCK] fixing SIT types
[FSCK] other corrupted bugs                           [Ok..]
        Error: Could not conduct fsync!!!

Generic/019 will trigger fsync() on a clean image, but it will fail
due to simulated failure on disk, result in testcase failure.

Let's add c.need_fsync to record dirty status of image, and only trigger
fsync() when there is dirty data in image.

Signed-off-by: Chao Yu <chao@kernel.org>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2024-01-26 00:40:27 -08:00
Chao Yu
54f637a965 fsck.f2fs: fix to avoid assert in do_record_fsync_data()
As Kane Ch'in reported in bugzilla [1]

I am using some Debian VMs with f2fs root partition for development.
My host machine crashed for some reason and this caused the f2fs
partitions in the VMs to become corrupted. I tried to boot from Debian
Live and repair the partitions but failed.

do_record_fsync_data: [node] ino = 24573, nid = 0, blkaddr = 2063580
recover_data: ino = 24573, nid = 0, recorded = 0, err = 0
do_record_fsync_data: [node] ino = 471286, nid = 0, blkaddr = 2063581
recover_data: ino = 471286, nid = 0, recorded = 0, err = 0
[ASSERT] (do_record_fsync_data:3475) 0

During do_record_fsync_data(), if dnode in warm node chain is valid in
SIT table, it's better to continue checking rather than triggering
assert().

[1] https://bugzilla.kernel.org/show_bug.cgi?id=218349

Reported-by: Kane Ch'in <qinfd2023@lzu.edu.cn>
Signed-off-by: Chao Yu <chao@kernel.org>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2024-01-16 10:47:37 -08:00
Wu Bo
fa3bb83a48 fsck.f2fs: fix orphan inode check fail
Call path:
fsck_chk_orphan_node
  fsck_chk_node_blk
    fsck_chk_inode_blk

'F2FS_FT_ORPHAN' will pass to fsck_chk_inode_blk(). If the orphan inode
is a DIR, it will be wrongly fixed.

Fixes: 8fd836f ("fsck: clear unexpected casefold flags")
Signed-off-by: Wu Bo <bo.wu@vivo.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2023-12-15 15:07:41 -08:00
Daniel Rosenberg
bf5100606d man: Add description for mkfs -b option
Describes the block size option -b. This sets the block size, which is
restricted to powers of 2. The linux kernel currently requires that the
block size be equal to the page size to mount.

Signed-off-by: Daniel Rosenberg <drosen@google.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2023-12-08 10:12:32 -08:00
Daeho Jeong
1cbaa9069e f2fs-tools: skip finishing zones for current zones
Do not finishing zones for current zones.

Signed-off-by: Daeho Jeong <daehojeong@google.com>
Fixes: 06a25b021d ("f2fs-tools: make six open zone check resilient")
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2023-12-04 17:17:06 -08:00