aboutsummaryrefslogtreecommitdiffstats
path: root/fs/f2fs/inode.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/inode.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/inode.c')
-rw-r--r--fs/f2fs/inode.c11
1 files changed, 5 insertions, 6 deletions
diff --git a/fs/f2fs/inode.c b/fs/f2fs/inode.c
index 9339cd292047..c8c058024af8 100644
--- a/fs/f2fs/inode.c
+++ b/fs/f2fs/inode.c
@@ -214,7 +214,7 @@ int update_inode_page(struct inode *inode)
214int f2fs_write_inode(struct inode *inode, struct writeback_control *wbc) 214int f2fs_write_inode(struct inode *inode, struct writeback_control *wbc)
215{ 215{
216 struct f2fs_sb_info *sbi = F2FS_SB(inode->i_sb); 216 struct f2fs_sb_info *sbi = F2FS_SB(inode->i_sb);
217 int ret, ilock; 217 int ret;
218 218
219 if (inode->i_ino == F2FS_NODE_INO(sbi) || 219 if (inode->i_ino == F2FS_NODE_INO(sbi) ||
220 inode->i_ino == F2FS_META_INO(sbi)) 220 inode->i_ino == F2FS_META_INO(sbi))
@@ -227,9 +227,9 @@ int f2fs_write_inode(struct inode *inode, struct writeback_control *wbc)
227 * We need to lock here to prevent from producing dirty node pages 227 * We need to lock here to prevent from producing dirty node pages
228 * during the urgent cleaning time when runing out of free sections. 228 * during the urgent cleaning time when runing out of free sections.
229 */ 229 */
230 ilock = mutex_lock_op(sbi); 230 f2fs_lock_op(sbi);
231 ret = update_inode_page(inode); 231 ret = update_inode_page(inode);
232 mutex_unlock_op(sbi, ilock); 232 f2fs_unlock_op(sbi);
233 233
234 if (wbc) 234 if (wbc)
235 f2fs_balance_fs(sbi); 235 f2fs_balance_fs(sbi);
@@ -243,7 +243,6 @@ int f2fs_write_inode(struct inode *inode, struct writeback_control *wbc)
243void f2fs_evict_inode(struct inode *inode) 243void f2fs_evict_inode(struct inode *inode)
244{ 244{
245 struct f2fs_sb_info *sbi = F2FS_SB(inode->i_sb); 245 struct f2fs_sb_info *sbi = F2FS_SB(inode->i_sb);
246 int ilock;
247 246
248 trace_f2fs_evict_inode(inode); 247 trace_f2fs_evict_inode(inode);
249 truncate_inode_pages(&inode->i_data, 0); 248 truncate_inode_pages(&inode->i_data, 0);
@@ -265,9 +264,9 @@ void f2fs_evict_inode(struct inode *inode)
265 if (F2FS_HAS_BLOCKS(inode)) 264 if (F2FS_HAS_BLOCKS(inode))
266 f2fs_truncate(inode); 265 f2fs_truncate(inode);
267 266
268 ilock = mutex_lock_op(sbi); 267 f2fs_lock_op(sbi);
269 remove_inode_page(inode); 268 remove_inode_page(inode);
270 mutex_unlock_op(sbi, ilock); 269 f2fs_unlock_op(sbi);
271 270
272 sb_end_intwrite(inode->i_sb); 271 sb_end_intwrite(inode->i_sb);
273no_delete: 272no_delete: