文件系统一些debug方法积累,不定期跟新
f2fs status
cat /sys/kernel/debug/f2fs/status /sys/fs/f2fs/sda<x> https://www.kernel.org/doc/Documentation/filesystems/f2fs.txtCONFIG_F2FS_CHECK_FS
再内核的config中可以使能这个宏,其会对F2FS文件系统进行更多的逻辑检查,如果检查到错误会触发bug on
抓取 f2fs ftrace event
echo 0 > /d/tracing/tracing_on echo 204800 > /d/tracing/buffer_size_kb echo "" > /d/tracing/set_event echo "" > /d/tracing/trace echo 1 > /d/tracing/events/f2fs/f2fs_background_gc/enable echo 1 > /sys/kernel/debug/tracing/tracing_on cat /d/tracing/trace_pipe在开机阶段开启f2fs ftrace
文件系统的一些问题是在开机阶段mount时候,此时无法通过adb 抓取,可以在kernel的command line传入使能f2fs trace参数
//在cmdline中加入如下参数 trace_event=f2fs:* trace_buf_size=64M ftrace=tracing_on //如果想选择性使能部分f2fs event,可以在/d/tracing/events中选择自己需要部分加入 trace_event=f2fs:f2fs_sync_fs,f2fs:f2fs_gc_begin trace_buf_size=64M ftrace=tracing_on使用 fcsk.f2fs 工具
fcsk.f2fs,可以在umount data分区的情况下,使用 fcsk.f2fs 对文件系统进行检查或修复,可以通过检查时的log,来定位文件系统问题
Usage: fsck.f2fs [options] device [options]: -a check/fix potential corruption, reported by f2fs -d debug level [default:0] -f check/fix entire partition -g add default options -O feature1[feature2,feature3,...] e.g. "encrypt" -p preen mode [default:0 the same as -a [0|1]] -S sparse_mode -t show directory tree -q preserve quota limits -y fix all the time -V print the version number and exit --dry-run do not really fix corruptions或在启动阶段如果检查到异常就会执行fcsk进行修复,这部分可以修改 kernel command line以及修改f2fs_init_configuration代码,使其在开机阶段从kernel log中抛出更多信息
// cmdline 中加入如下参数 printk.devkmsg=on //在如下位置加入c.dbg_lv = 3; //fix the debug level here -------- https://android.googlesource.com/platform/external/f2fs-tools/+/a78c2885b591a8fbcfc572bbd0b4b614434bde1c/lib/libf2fs.c -------- /* * device information */ void f2fs_init_configuration(void) { ...... /* calculated by overprovision ratio */ c.segs_per_sec = 1; c.secs_per_zone = 1; c.segs_per_zone = 1; c.vol_label = ""; c.trim = 1; c.kd = -1; c.fixed_time = -1; ----- ++c.dbg_lv = 3; ----- c.s_encoding = 0; ...... }