diff options
author | Chao Yu | 2014-03-22 14:57:23 +0800 |
---|---|---|
committer | Jaegeuk Kim | 2014-04-01 18:53:41 +0900 |
commit | df0f8dc0e154de13e3a54846f384b674dd557c85 (patch) | |
tree | 9465da562d6136bd8a49d55b834f3713af880c5f /fs/f2fs/segment.c | |
parent | 3bb5e2c8fe2296ddd9d864dcfb5ee1b77135f3ec (diff) |
f2fs: avoid unnecessary bio submit when wait page writeback
This patch introduce is_merged_page() to check whether current page is merged
in f2fs bio cache. When page is not in cache, we can avoid submitting bio cache,
resulting in having more chance to merge pages.
Signed-off-by: Chao Yu <chao2.yu@samsung.com>
Signed-off-by: Jaegeuk Kim <jaegeuk.kim@samsung.com>
Diffstat (limited to 'fs/f2fs/segment.c')
-rw-r--r-- | fs/f2fs/segment.c | 28 |
1 files changed, 27 insertions, 1 deletions
diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c index e7ff23a536a4..570ab9a084c5 100644 --- a/fs/f2fs/segment.c +++ b/fs/f2fs/segment.c @@ -1046,12 +1046,38 @@ void rewrite_node_page(struct f2fs_sb_info *sbi, mutex_unlock(&curseg->curseg_mutex); } +static inline bool is_merged_page(struct f2fs_sb_info *sbi, + struct page *page, enum page_type type) +{ + enum page_type btype = PAGE_TYPE_OF_BIO(type); + struct f2fs_bio_info *io = &sbi->write_io[btype]; + struct bio *bio = io->bio; + struct bio_vec *bvec; + int i; + + down_read(&io->io_rwsem); + if (!bio) + goto out; + + bio_for_each_segment_all(bvec, bio, i) { + if (page == bvec->bv_page) { + up_read(&io->io_rwsem); + return true; + } + } + +out: + up_read(&io->io_rwsem); + return false; +} + void f2fs_wait_on_page_writeback(struct page *page, enum page_type type) { struct f2fs_sb_info *sbi = F2FS_SB(page->mapping->host->i_sb); if (PageWriteback(page)) { - f2fs_submit_merged_bio(sbi, type, WRITE); + if (is_merged_page(sbi, page, type)) + f2fs_submit_merged_bio(sbi, type, WRITE); wait_on_page_writeback(page); } } |