aboutsummaryrefslogtreecommitdiffstats
path: root/fs/f2fs/super.c
diff options
context:
space:
mode:
authorGu Zheng <guz.fnst@cn.fujitsu.com>2013-09-27 06:08:30 -0400
committerJaegeuk Kim <jaegeuk.kim@samsung.com>2013-10-06 22:33:05 -0400
commite479556bfdd136669854292eb57ed0139d7253d5 (patch)
tree95772ba1ac8cf1e79c89145daf40c417814896da /fs/f2fs/super.c
parent2e5558f4a5cf16a7394fd5770087303db8912c66 (diff)
f2fs: use rw_sem instead of fs_lock(locks mutex)
The fs_locks is used to block other ops(ex, recovery) when doing checkpoint. And each other operate routine(besides checkpoint) needs to acquire a fs_lock, there is a terrible problem here, if these are too many concurrency threads acquiring fs_lock, so that they will block each other and may lead to some performance problem, but this is not the phenomenon we want to see. Though there are some optimization patches introduced to enhance the usage of fs_lock, but the thorough solution is using a *rw_sem* to replace the fs_lock. Checkpoint routine takes write_sem, and other ops take read_sem, so that we can block other ops(ex, recovery) when doing checkpoint, and other ops will not disturb each other, this can avoid the problem described above completely. Because of the weakness of rw_sem, the above change may introduce a potential problem that the checkpoint thread might get starved if other threads are intensively locking the read semaphore for I/O.(Pointed out by Xu Jin) In order to avoid this, a wait_list is introduced, the appending read semaphore ops will be dropped into the wait_list if checkpoint thread is waiting for write semaphore, and will be waked up when checkpoint thread gives up write semaphore. Thanks to Kim's previous review and test, and will be very glad to see other guys' performance tests about this patch. V2: -fix the potential starvation problem. -use more suitable func name suggested by Xu Jin. Signed-off-by: Gu Zheng <guz.fnst@cn.fujitsu.com> [Jaegeuk Kim: adjust minor coding standard] Signed-off-by: Jaegeuk Kim <jaegeuk.kim@samsung.com>
Diffstat (limited to 'fs/f2fs/super.c')
-rw-r--r--fs/f2fs/super.c5
1 files changed, 2 insertions, 3 deletions
diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c
index 13d0a0fe49dd..347d70049288 100644
--- a/fs/f2fs/super.c
+++ b/fs/f2fs/super.c
@@ -760,7 +760,6 @@ static int f2fs_fill_super(struct super_block *sb, void *data, int silent)
760 struct buffer_head *raw_super_buf; 760 struct buffer_head *raw_super_buf;
761 struct inode *root; 761 struct inode *root;
762 long err = -EINVAL; 762 long err = -EINVAL;
763 int i;
764 763
765 /* allocate memory for f2fs-specific super block info */ 764 /* allocate memory for f2fs-specific super block info */
766 sbi = kzalloc(sizeof(struct f2fs_sb_info), GFP_KERNEL); 765 sbi = kzalloc(sizeof(struct f2fs_sb_info), GFP_KERNEL);
@@ -818,12 +817,12 @@ static int f2fs_fill_super(struct super_block *sb, void *data, int silent)
818 mutex_init(&sbi->gc_mutex); 817 mutex_init(&sbi->gc_mutex);
819 mutex_init(&sbi->writepages); 818 mutex_init(&sbi->writepages);
820 mutex_init(&sbi->cp_mutex); 819 mutex_init(&sbi->cp_mutex);
821 for (i = 0; i < NR_GLOBAL_LOCKS; i++)
822 mutex_init(&sbi->fs_lock[i]);
823 mutex_init(&sbi->node_write); 820 mutex_init(&sbi->node_write);
824 sbi->por_doing = 0; 821 sbi->por_doing = 0;
825 spin_lock_init(&sbi->stat_lock); 822 spin_lock_init(&sbi->stat_lock);
826 init_rwsem(&sbi->bio_sem); 823 init_rwsem(&sbi->bio_sem);
824 init_rwsem(&sbi->cp_rwsem);
825 init_waitqueue_head(&sbi->cp_wait);
827 init_sb_info(sbi); 826 init_sb_info(sbi);
828 827
829 /* get an inode for meta space */ 828 /* get an inode for meta space */