page cache

page cache

 

bdi_writeback的b_dirty链表上插入node(inode.i_io_list)

__set_page_dirty_nobuffers()里调用__mark_inode_dirty(I_DIRTY_PAGES),这个函数里将此inode的i_state或上I_DIRTY_PAGES flag,并将inode(i_io_list成员)插入bdi_writeback的b_dirty链表上,同时可能会queue一个writeback delayed work(delay 5s)

queue_io将bdi_writeback的b_more_io、b_dirty链表上的node移动到b_io链表上

fs/fs-writeback.c

/*
 * Queue all expired dirty inodes for io, eldest first.
 * Before
 *         newly dirtied     b_dirty    b_io    b_more_io
 *         =============>    gf         edc     BA
 * After
 *         newly dirtied     b_dirty    b_io    b_more_io
 *         =============>    g          fBAedc
 *                                           |
 *                                           +--> dequeue for IO
 */
static void queue_io(struct bdi_writeback *wb, struct wb_writeback_work *work,
             unsigned long dirtied_before)
{
    int moved;
    unsigned long time_expire_jif = dirtied_before;

    assert_spin_locked(&wb->list_lock);
    list_splice_init(&wb->b_more_io, &wb->b_io);
    moved = move_expired_inodes(&wb->b_dirty, &wb->b_io, dirtied_before);
    if (!work->for_sync)
        time_expire_jif = jiffies - dirtytime_expire_interval * HZ;
    moved += move_expired_inodes(&wb->b_dirty_time, &wb->b_io,
                     time_expire_jif);
    if (moved)
        wb_io_lists_populated(wb);
    trace_writeback_queue_io(wb, work, dirtied_before, moved);
}

 

posted @ 2023-01-28 23:27  aspirs  阅读(62)  评论(0编辑  收藏  举报