diff options
author | Chao Yu <chao2.yu@samsung.com> | 2014-07-03 06:58:39 -0400 |
---|---|---|
committer | Jaegeuk Kim <jaegeuk@kernel.org> | 2014-07-31 02:28:37 -0400 |
commit | b3582c68920105e29d219714d8a6fbde25a43379 (patch) | |
tree | 200ab9ca194921c8baad9954fee36eee072a772f /fs/f2fs | |
parent | 65b85ccce03f17b3098273192b20885f3fead820 (diff) |
f2fs: reduce competition among node page writes
We do not need to block on ->node_write among different node page writers e.g.
fsync/flush, unless we have a node page writer from write_checkpoint.
So it's better use rw_semaphore instead of mutex type for ->node_write to
promote performance.
Signed-off-by: Chao Yu <chao2.yu@samsung.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
Diffstat (limited to 'fs/f2fs')
-rw-r--r-- | fs/f2fs/checkpoint.c | 6 | ||||
-rw-r--r-- | fs/f2fs/f2fs.h | 2 | ||||
-rw-r--r-- | fs/f2fs/node.c | 4 | ||||
-rw-r--r-- | fs/f2fs/super.c | 2 |
4 files changed, 7 insertions, 7 deletions
diff --git a/fs/f2fs/checkpoint.c b/fs/f2fs/checkpoint.c index cea20b810f44..6aeed5bada52 100644 --- a/fs/f2fs/checkpoint.c +++ b/fs/f2fs/checkpoint.c | |||
@@ -762,10 +762,10 @@ retry_flush_dents: | |||
762 | * until finishing nat/sit flush. | 762 | * until finishing nat/sit flush. |
763 | */ | 763 | */ |
764 | retry_flush_nodes: | 764 | retry_flush_nodes: |
765 | mutex_lock(&sbi->node_write); | 765 | down_write(&sbi->node_write); |
766 | 766 | ||
767 | if (get_pages(sbi, F2FS_DIRTY_NODES)) { | 767 | if (get_pages(sbi, F2FS_DIRTY_NODES)) { |
768 | mutex_unlock(&sbi->node_write); | 768 | up_write(&sbi->node_write); |
769 | sync_node_pages(sbi, 0, &wbc); | 769 | sync_node_pages(sbi, 0, &wbc); |
770 | goto retry_flush_nodes; | 770 | goto retry_flush_nodes; |
771 | } | 771 | } |
@@ -774,7 +774,7 @@ retry_flush_nodes: | |||
774 | 774 | ||
775 | static void unblock_operations(struct f2fs_sb_info *sbi) | 775 | static void unblock_operations(struct f2fs_sb_info *sbi) |
776 | { | 776 | { |
777 | mutex_unlock(&sbi->node_write); | 777 | up_write(&sbi->node_write); |
778 | f2fs_unlock_all(sbi); | 778 | f2fs_unlock_all(sbi); |
779 | } | 779 | } |
780 | 780 | ||
diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h index 80c78695546d..99425675c2f8 100644 --- a/fs/f2fs/f2fs.h +++ b/fs/f2fs/f2fs.h | |||
@@ -452,7 +452,7 @@ struct f2fs_sb_info { | |||
452 | struct inode *meta_inode; /* cache meta blocks */ | 452 | struct inode *meta_inode; /* cache meta blocks */ |
453 | struct mutex cp_mutex; /* checkpoint procedure lock */ | 453 | struct mutex cp_mutex; /* checkpoint procedure lock */ |
454 | struct rw_semaphore cp_rwsem; /* blocking FS operations */ | 454 | struct rw_semaphore cp_rwsem; /* blocking FS operations */ |
455 | struct mutex node_write; /* locking node writes */ | 455 | struct rw_semaphore node_write; /* locking node writes */ |
456 | struct mutex writepages; /* mutex for writepages() */ | 456 | struct mutex writepages; /* mutex for writepages() */ |
457 | bool por_doing; /* recovery is doing or not */ | 457 | bool por_doing; /* recovery is doing or not */ |
458 | wait_queue_head_t cp_wait; | 458 | wait_queue_head_t cp_wait; |
diff --git a/fs/f2fs/node.c b/fs/f2fs/node.c index a90f51d32482..7b5b5def65fe 100644 --- a/fs/f2fs/node.c +++ b/fs/f2fs/node.c | |||
@@ -1231,12 +1231,12 @@ static int f2fs_write_node_page(struct page *page, | |||
1231 | if (wbc->for_reclaim) | 1231 | if (wbc->for_reclaim) |
1232 | goto redirty_out; | 1232 | goto redirty_out; |
1233 | 1233 | ||
1234 | mutex_lock(&sbi->node_write); | 1234 | down_read(&sbi->node_write); |
1235 | set_page_writeback(page); | 1235 | set_page_writeback(page); |
1236 | write_node_page(sbi, page, &fio, nid, ni.blk_addr, &new_addr); | 1236 | write_node_page(sbi, page, &fio, nid, ni.blk_addr, &new_addr); |
1237 | set_node_addr(sbi, &ni, new_addr, is_fsync_dnode(page)); | 1237 | set_node_addr(sbi, &ni, new_addr, is_fsync_dnode(page)); |
1238 | dec_page_count(sbi, F2FS_DIRTY_NODES); | 1238 | dec_page_count(sbi, F2FS_DIRTY_NODES); |
1239 | mutex_unlock(&sbi->node_write); | 1239 | up_read(&sbi->node_write); |
1240 | unlock_page(page); | 1240 | unlock_page(page); |
1241 | return 0; | 1241 | return 0; |
1242 | 1242 | ||
diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c index f253e222dcea..657582fc7601 100644 --- a/fs/f2fs/super.c +++ b/fs/f2fs/super.c | |||
@@ -953,7 +953,7 @@ static int f2fs_fill_super(struct super_block *sb, void *data, int silent) | |||
953 | mutex_init(&sbi->gc_mutex); | 953 | mutex_init(&sbi->gc_mutex); |
954 | mutex_init(&sbi->writepages); | 954 | mutex_init(&sbi->writepages); |
955 | mutex_init(&sbi->cp_mutex); | 955 | mutex_init(&sbi->cp_mutex); |
956 | mutex_init(&sbi->node_write); | 956 | init_rwsem(&sbi->node_write); |
957 | sbi->por_doing = false; | 957 | sbi->por_doing = false; |
958 | spin_lock_init(&sbi->stat_lock); | 958 | spin_lock_init(&sbi->stat_lock); |
959 | 959 | ||