f2fs: fix to update injection attrs according to fault_option
authorChao Yu <chao@kernel.org>
Thu, 20 Mar 2025 02:22:30 +0000 (10:22 +0800)
committerJaegeuk Kim <jaegeuk@kernel.org>
Thu, 10 Apr 2025 03:59:58 +0000 (03:59 +0000)
commit2be96c2147e25d5845c1b06dc20521ab9e0eeeb0
tree519abc21bc66c7928502dba61985a5a1e713d380
parente073e92789839d10a8828c13f9fe47ee517aa8e6
f2fs: fix to update injection attrs according to fault_option

When we update inject type via sysfs, it shows wrong rate value as
below, there is a same problem when we update inject rate, fix it.

Before:
F2FS-fs (vdd): build fault injection attr: rate: 0, type: 0xffff
F2FS-fs (vdd): build fault injection attr: rate: 1, type: 0x0

After:
F2FS-fs (vdd): build fault injection type: 0x1
F2FS-fs (vdd): build fault injection rate: 1

Meanwhile, let's avoid turning on all fault types when we enable fault
injection via fault_injection mount option, it will lead to shutdown
filesystem or fail the mount() easily.

mount -o fault_injection=4 /dev/vdd /mnt/f2fs
F2FS-fs (vdd): build fault injection attr: rate: 4, type: 0x7fffff
F2FS-fs (vdd): inject kmalloc in f2fs_kmalloc of f2fs_fill_super+0xbdf/0x27c0

Signed-off-by: Chao Yu <chao@kernel.org>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
fs/f2fs/checkpoint.c
fs/f2fs/f2fs.h
fs/f2fs/super.c
fs/f2fs/sysfs.c