From 971767caf632190f77a40b4011c19948232eed75 Mon Sep 17 00:00:00 2001 From: Jaegeuk Kim Date: Mon, 18 Nov 2013 17:16:17 +0900 Subject: f2fs: use sbi->write_mutex for write bios This patch removes an unnecessary semaphore (i.e., sbi->bio_sem). There is no reason to use the semaphore when f2fs submits read and write IOs. Instead, let's use a write mutex and cover the sbi->bio[] by the lock. Change log from v1: o split write_mutex suggested by Chao Yu Chao described, "All DATA/NODE/META bio buffers in superblock is protected by 'sbi->write_mutex', but each bio buffer area is independent, So we should split write_mutex to three for DATA/NODE/META." Signed-off-by: Chao Yu Signed-off-by: Jaegeuk Kim --- fs/f2fs/segment.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'fs/f2fs/segment.c') diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c index d5043bdaa1af..68b8a2bdf6d8 100644 --- a/fs/f2fs/segment.c +++ b/fs/f2fs/segment.c @@ -869,9 +869,14 @@ static void do_submit_bio(struct f2fs_sb_info *sbi, void f2fs_submit_bio(struct f2fs_sb_info *sbi, enum page_type type, bool sync) { - down_write(&sbi->bio_sem); + enum page_type btype = PAGE_TYPE_OF_BIO(type); + + if (!sbi->bio[btype]) + return; + + mutex_lock(&sbi->write_mutex[btype]); do_submit_bio(sbi, type, sync); - up_write(&sbi->bio_sem); + mutex_unlock(&sbi->write_mutex[btype]); } static void submit_write_page(struct f2fs_sb_info *sbi, struct page *page, @@ -882,7 +887,7 @@ static void submit_write_page(struct f2fs_sb_info *sbi, struct page *page, verify_block_addr(sbi, blk_addr); - down_write(&sbi->bio_sem); + mutex_lock(&sbi->write_mutex[type]); inc_page_count(sbi, F2FS_WRITEBACK); @@ -917,7 +922,7 @@ retry: sbi->last_block_in_bio[type] = blk_addr; - up_write(&sbi->bio_sem); + mutex_unlock(&sbi->write_mutex[type]); trace_f2fs_submit_write_page(page, blk_addr, type); } -- cgit v1.2.3