hon@hon:~/f2fs$ grep -i "clearpagedirty" . -nr
./mm/shmem.c:1240: ClearPageDirty(page);
./mm/memory-failure.c:717: ClearPageDirty(p);
./mm/vmscan.c:562: ClearPageDirty(page);
./mm/page-writeback.c:2612: if (TestClearPageDirty(page))
./mm/page-writeback.c:2618: ClearPageDirty(page);
./mm/page-writeback.c:2687: if (TestClearPageDirty(page)) {
./mm/page-writeback.c:2697: return TestClearPageDirty(page);
./fs/ext4/inline.c:746: ClearPageDirty(page);
./fs/nilfs2/page.c:496: return TestClearPageDirty(page);
./fs/btrfs/tests/extent-io-tests.c:229: ClearPageDirty(page);
./fs/hugetlbfs/inode.c:298: ClearPageDirty(page);
./fs/gfs2/ops_fstype.c:239: ClearPageDirty(page);
clear_page_dirty_for_io 在实际文件系统中大量存在,但是都是为了支持这些文件系统的一些特殊的特性,比如f2fs的垃圾回收.
mm/page-writeback.c 2228行左右,发现在调用实际文件系统的writeback写回之前,会将文件的脏位取消掉,所以到真正的的write_back之前,
其实page的dirty位已经没有了!
同时,write_one_page函数中,在调用珍重的writeback函数之前也会把页的脏位去掉!
Call trace:
[<ffffffc00008960c>] dump_backtrace+0x0/0x12c
[<ffffffc000089748>] show_stack+0x10/0x1c
[<ffffffc00034d97c>] do_write_data_page+0xa8/0x77c
[<ffffffc00034e44c>] f2fs_write_data_page+0x3fc/0x5dc
[<ffffffc00034761c>] __f2fs_writepage+0x18/0x60
[<ffffffc000180d70>] write_cache_pages+0x1f0/0x5b4 会在该函数中将page的 dirty 标志 PG_dirty 清除. 然后进入write back 过程, 在写入之前设置write back标志,并在bio结束之后, 在bio的回调函数中将writeback标志位清除.
[<ffffffc000348cbc>] f2fs_write_data_pages+0xf8/0x370
[<ffffffc000181bd4>] do_writepages+0x20/0x44
[<ffffffc000204e20>] __writeback_single_inode+0xac/0xbb0
[<ffffffc000205ba4>] writeback_sb_inodes+0x280/0x518
[<ffffffc000205ed4>] __writeback_inodes_wb+0x98/0xe0
[<ffffffc0002061d0>] wb_writeback+0x2b4/0x73c
[<ffffffc0002076c4>] wb_workfn+0x3d8/0x98c
[<ffffffc0000b505c>] process_one_work+0x218/0x7ec
[<ffffffc0000b5764>] worker_thread+0x134/0x458
[<ffffffc0000bc010>] kthread+0xd4/0xec
原文:http://www.cnblogs.com/honpey/p/4926605.html