通过f2fs_buffered_write_iter接口写入数据,由于使用page cache机制,所以需要保证对应的page在内存中,所以f2fs将这个流程又分为3个阶段:a. write_begin阶段:这个负责从page cache中获取page,如果不存在,则新建一个,还需要从存储介质中将原来的数据读上来;如果是NEW_ADDR,表示预留,直接全部初始化为0即可。这里还需要注...
atomic write commit 也需要在 i_gc_rwsem WRITE 锁的保护下进行,因为会修改 block addr,类似于 i_gc_rwsem WRITE 锁的第二个引入 commit。 Q2.6:为什么 atomic write 的 start/commit/abort 操作都需要 lock inode? inode_lock 会在写入 inode 期间持有,覆盖了 write_begin/write_end。start/commit/abort a...
.writepage = f2fs_write_data_page, .writepages = f2fs_write_data_pages, .write_begin = f2fs_write_begin, //准备页框 .write_end = f2fs_write_end, // set_page_dirty .set_page_dirty = f2fs_set_data_page_dirty, .invalidatepage = f2fs_invalidate_page, .releasepage = f2fs_release_page...
vfs_write --> new_sync_write --> call_write_iter --> f2fs_file_write_iter -> f2fs_buffered_write_iter --> generic_perform_write --> f2fs_write_begin --> prepare_write_begin --> f2fs_get_block --> f2fs_reserve_block --> f2fs_get_dnode_of_data --> f2fs_new_node_page -->...
static int f2fs_write_begin(struct file *file, struct address_space *mapping, loff_t pos, unsigned len, unsigned flags, struct page **pagep, void **fsdata) @@ -3321,7 +3420,7 @@ static int f2fs_write_begin(struct file *file, struct address_space *mapping,...
@@ -2009,6 +2022,8 @@ static int f2fs_write_begin(struct file *file, struct address_space *mapping, fail: f2fs_put_page(page, 1); f2fs_write_failed(mapping, pos + len); if (f2fs_is_atomic_file(inode)) drop_inmem_pages_all(sbi); ...
(&sbi->wb_sync_req[NODE]); if (err) { f2fs_up_write(&sbi->node_change); f2fs_unlock_all(sbi); return err; } cond_resched(); goto retry_flush_nodes; } /* * sbi->node_change is used only for AIO write_begin path which produces * dirty node blocks and some checkpoint values ...
inode->i_write_hint); Expand All @@ -4233,7 +4219,7 @@ static int f2fs_iomap_begin(struct inode *inode, loff_t offset, loff_t length, if (err) return err; iomap->offset = blks_to_bytes(inode, map.m_lblk); iomap->offset = F2FS_BLK_TO_BYTES(map.m_lblk); /* * When ...
trace_f2fs_gc_begin(sbi->sb, gc_type, gc_control->no_bg_gc, gc_control->nr_free_secs, @@ -1890,8 +1891,13 @@ int f2fs_gc(struct f2fs_sb_info *sbi, struct f2fs_gc_control *gc_control) } } /* Write checkpoint to reclaim prefree segments */ if (free_sections(sbi) < NR_...