diff options
author | Chao Yu <yuchao0@huawei.com> | 2017-10-30 17:49:53 +0800 |
---|---|---|
committer | Jaegeuk Kim <jaegeuk@kernel.org> | 2017-11-05 16:42:03 -0800 |
commit | 3d26fa6be3c487fac7d87dc4a6f02a9ff0f6b1ef (patch) | |
tree | 2c09c5713e9c038bfa46697fb1bcd6375cbe2470 /fs/f2fs/gc.c | |
parent | ea6767337f86312ebe473585899a159bf50ef1b7 (diff) | |
download | linux-3d26fa6be3c487fac7d87dc4a6f02a9ff0f6b1ef.tar.bz2 |
f2fs: use rw_semaphore to protect SIT cache
There are some cases user didn't update SIT cache under this lock,
so let's use rw_semaphore instead of mutex to enhance concurrently
accessing.
Signed-off-by: Chao Yu <yuchao0@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
Diffstat (limited to 'fs/f2fs/gc.c')
-rw-r--r-- | fs/f2fs/gc.c | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/fs/f2fs/gc.c b/fs/f2fs/gc.c index c7b1d704846a..ff8f0012888d 100644 --- a/fs/f2fs/gc.c +++ b/fs/f2fs/gc.c @@ -456,10 +456,10 @@ static int check_valid_map(struct f2fs_sb_info *sbi, struct seg_entry *sentry; int ret; - mutex_lock(&sit_i->sentry_lock); + down_read(&sit_i->sentry_lock); sentry = get_seg_entry(sbi, segno); ret = f2fs_test_bit(offset, sentry->cur_valid_map); - mutex_unlock(&sit_i->sentry_lock); + up_read(&sit_i->sentry_lock); return ret; } @@ -893,10 +893,10 @@ static int __get_victim(struct f2fs_sb_info *sbi, unsigned int *victim, struct sit_info *sit_i = SIT_I(sbi); int ret; - mutex_lock(&sit_i->sentry_lock); + down_write(&sit_i->sentry_lock); ret = DIRTY_I(sbi)->v_ops->get_victim(sbi, victim, gc_type, NO_CHECK_TYPE, LFS); - mutex_unlock(&sit_i->sentry_lock); + up_write(&sit_i->sentry_lock); return ret; } @@ -944,8 +944,8 @@ static int do_garbage_collect(struct f2fs_sb_info *sbi, /* * this is to avoid deadlock: * - lock_page(sum_page) - f2fs_replace_block - * - check_valid_map() - mutex_lock(sentry_lock) - * - mutex_lock(sentry_lock) - change_curseg() + * - check_valid_map() - down_write(sentry_lock) + * - down_read(sentry_lock) - change_curseg() * - lock_page(sum_page) */ if (type == SUM_TYPE_NODE) |