jbd2
bpftrace探测jbd2:
root@user-ODROID-H2:/usr/sbin# bpftrace -e "kprobe:ext4_journal_commit_callback {@[comm,pid,kstack]=count()}"
Attaching 1 probe...
^C
@[jbd2/sda2-8, 270,
ext4_journal_commit_callback+1
kjournald2+182
kthread+260
ret_from_fork+31
]: 15
Part1:
static int jbd2_journal_start_thread(journal_t *journal)
|__kthread_run(kjournald2, journal, "jbd2/%s",journal->j_devname);
static int kjournald2(void *arg)
|__jbd2_journal_commit_transaction(journal);
|__journal->j_commit_callback(journal, commit_transaction);
Part2:
static struct dentry *ext4_mount(struct file_system_type *fs_type, int flags,const char *dev_name, void *data)
|__mount_bdev(fs_type, flags, dev_name, data, ext4_fill_super);
|__ext4_fill_super()
|__sbi->s_journal->j_commit_callback = ext4_journal_commit_callback;
从这两部分可以看到,ext4挂载时候注册了自己的commit_callback.
而内核线程jbd2在唤醒,完成最终的日志提交的时候,最终调用ext4注册的commit_callback