aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJaegeuk Kim <jaegeuk.kim@samsung.com>2013-11-18 17:16:17 +0900
committerAndreas Blaesius <skate4life@gmx.de>2016-06-05 21:20:52 +0200
commit2770b1a1d1ddeccbdbd53033fbe7c7ec6522a343 (patch)
treea36ab53b18b0cb988f6768597f08751e4854bbb5
parentffe1b71c4b268bcdce0e7de0da9c9e535ef0bda4 (diff)
downloadkernel_samsung_espresso10-2770b1a1d1ddeccbdbd53033fbe7c7ec6522a343.zip
kernel_samsung_espresso10-2770b1a1d1ddeccbdbd53033fbe7c7ec6522a343.tar.gz
kernel_samsung_espresso10-2770b1a1d1ddeccbdbd53033fbe7c7ec6522a343.tar.bz2
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 <chao2.yu@samsung.com> Signed-off-by: Jaegeuk Kim <jaegeuk.kim@samsung.com>
-rw-r--r--fs/f2fs/data.c4
-rw-r--r--fs/f2fs/f2fs.h2
-rw-r--r--fs/f2fs/segment.c13
-rw-r--r--fs/f2fs/super.c6
4 files changed, 15 insertions, 10 deletions
diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c
index 633d0f9..9275bad 100644
--- a/fs/f2fs/data.c
+++ b/fs/f2fs/data.c
@@ -382,8 +382,6 @@ int f2fs_readpage(struct f2fs_sb_info *sbi, struct page *page,
trace_f2fs_readpage(page, blk_addr, type);
- down_read(&sbi->bio_sem);
-
/* Allocate a new bio */
bio = f2fs_bio_alloc(bdev, 1);
@@ -393,13 +391,11 @@ int f2fs_readpage(struct f2fs_sb_info *sbi, struct page *page,
if (bio_add_page(bio, page, PAGE_CACHE_SIZE, 0) < PAGE_CACHE_SIZE) {
bio_put(bio);
- up_read(&sbi->bio_sem);
f2fs_put_page(page, 1);
return -EFAULT;
}
submit_bio(type, bio);
- up_read(&sbi->bio_sem);
return 0;
}
diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h
index 65d4989..9178c10 100644
--- a/fs/f2fs/f2fs.h
+++ b/fs/f2fs/f2fs.h
@@ -374,7 +374,7 @@ struct f2fs_sb_info {
struct f2fs_sm_info *sm_info; /* segment manager */
struct bio *bio[NR_PAGE_TYPE]; /* bios to merge */
sector_t last_block_in_bio[NR_PAGE_TYPE]; /* last block number */
- struct rw_semaphore bio_sem; /* IO semaphore */
+ struct mutex write_mutex[NR_PAGE_TYPE]; /* mutex for writing IOs */
/* for checkpoint */
struct f2fs_checkpoint *ckpt; /* raw checkpoint pointer */
diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c
index d5043bd..68b8a2b 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);
}
diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c
index 420f8de..1d71931 100644
--- a/fs/f2fs/super.c
+++ b/fs/f2fs/super.c
@@ -802,6 +802,7 @@ static int f2fs_fill_super(struct super_block *sb, void *data, int silent)
struct buffer_head *raw_super_buf;
struct inode *root;
long err = -EINVAL;
+ int i;
/* allocate memory for f2fs-specific super block info */
sbi = kzalloc(sizeof(struct f2fs_sb_info), GFP_KERNEL);
@@ -858,7 +859,10 @@ static int f2fs_fill_super(struct super_block *sb, void *data, int silent)
mutex_init(&sbi->node_write);
sbi->por_doing = false;
spin_lock_init(&sbi->stat_lock);
- init_rwsem(&sbi->bio_sem);
+
+ for (i = 0; i < NR_PAGE_TYPE; i++)
+ mutex_init(&sbi->write_mutex[i]);
+
init_rwsem(&sbi->cp_rwsem);
init_waitqueue_head(&sbi->cp_wait);
init_sb_info(sbi);