f2fs: refactor ->page_mkwrite() flow
PATCH v2 1/1 f2fs: refactor ->page_mkwrite() flow
Thread A Thread B
- f2fs_vm_page_mkwrite
- f2fs_setattr
- down_write(i_mmap_sem)
- truncate_setsize
- f2fs_truncate
- up_write(i_mmap_sem)
- f2fs_reserve_block
reserve NEW_ADDR
- skip dirty page due to truncation
1. we don't need to rserve new block address for a truncated page.
2. dn.data_blkaddr is used out of node page lock coverage.
Refactor ->page_mkwrite() flow to fix above issues:
- use __do_map_lock() to avoid racing checkpoint()
- lock data page in prior to dnode page
- cover f2fs_reserve_block with i_mmap_sem lock
- wait page writeback before zeroing page
---
v2:
- handle error path correctly
- wait page writeback before zeroing page
fs/f2fs/data.c | 2 +- fs/f2fs/f2fs.h | 1 + fs/f2fs/file.c | 45 ++++++++++++++++++++++----------------------- 3 files changed, 24 insertions(+), 24 deletions(-)
fs/f2fs/data.c +1 -1
@@ -972,7 +972,7 @@ int f2fs_preallocate_blocks(struct kiocb *iocb, struct iov_iter *from)return err; } -static inline void __do_map_lock (struct f2fs_sb_info *sbi,int flag,bool lock) +void __do_map_lock (struct f2fs_sb_info *sbi,int flag,bool lock) {if (flag ==F2FS_GET_BLOCK_PRE_AIO ) {if (lock)
fs/f2fs/f2fs.h +1 -0
@@ -3050,6 +3050,7 @@ struct page *f2fs_get_lock_data_page(struct inode *inode, pgoff_t index,struct page *f2fs_get_new_data_page (struct inode *inode,struct page *ipage,pgoff_t index,bool new_i_size);int f2fs_do_write_data_page (struct f2fs_io_info *fio); +void __do_map_lock (struct f2fs_sb_info *sbi,int flag,bool lock);int f2fs_map_blocks (struct inode *inode,struct f2fs_map_blocks *map,int create,int flag); int f2fs_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,
fs/f2fs/file.c +22 -23
75 lines not on this page · raw message
Signature · 1 line
2.18.0.rc1