aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDave Chinner <dchinner@redhat.com>2011-03-22 07:23:43 -0400
committerAl Viro <viro@zeniv.linux.org.uk>2011-03-24 21:17:51 -0400
commit0f1b1fd86f6fd662e04da3e82a6780b226fcd0d1 (patch)
tree422e2923193f5ac4ea2a6864a6635878ad58c43b
parent67a23c494621ff1d5431c3bc320947865b224625 (diff)
fs: pull inode->i_lock up out of writeback_single_inode
First thing we do in writeback_single_inode() is take the i_lock and the last thing we do is drop it. A caller already holds the i_lock, so pull the i_lock out of writeback_single_inode() to reduce the round trips on this lock during inode writeback. Signed-off-by: Dave Chinner <dchinner@redhat.com> Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
-rw-r--r--fs/fs-writeback.c18
1 files changed, 11 insertions, 7 deletions
diff --git a/fs/fs-writeback.c b/fs/fs-writeback.c
index ed800656356b..b5ed541fb137 100644
--- a/fs/fs-writeback.c
+++ b/fs/fs-writeback.c
@@ -332,9 +332,9 @@ static void inode_wait_for_writeback(struct inode *inode)
332} 332}
333 333
334/* 334/*
335 * Write out an inode's dirty pages. Called under inode_wb_list_lock. Either 335 * Write out an inode's dirty pages. Called under inode_wb_list_lock and
336 * the caller has an active reference on the inode or the inode has I_WILL_FREE 336 * inode->i_lock. Either the caller has an active reference on the inode or
337 * set. 337 * the inode has I_WILL_FREE set.
338 * 338 *
339 * If `wait' is set, wait on the writeout. 339 * If `wait' is set, wait on the writeout.
340 * 340 *
@@ -349,7 +349,9 @@ writeback_single_inode(struct inode *inode, struct writeback_control *wbc)
349 unsigned dirty; 349 unsigned dirty;
350 int ret; 350 int ret;
351 351
352 spin_lock(&inode->i_lock); 352 assert_spin_locked(&inode_wb_list_lock);
353 assert_spin_locked(&inode->i_lock);
354
353 if (!atomic_read(&inode->i_count)) 355 if (!atomic_read(&inode->i_count))
354 WARN_ON(!(inode->i_state & (I_WILL_FREE|I_FREEING))); 356 WARN_ON(!(inode->i_state & (I_WILL_FREE|I_FREEING)));
355 else 357 else
@@ -365,7 +367,6 @@ writeback_single_inode(struct inode *inode, struct writeback_control *wbc)
365 * completed a full scan of b_io. 367 * completed a full scan of b_io.
366 */ 368 */
367 if (wbc->sync_mode != WB_SYNC_ALL) { 369 if (wbc->sync_mode != WB_SYNC_ALL) {
368 spin_unlock(&inode->i_lock);
369 requeue_io(inode); 370 requeue_io(inode);
370 return 0; 371 return 0;
371 } 372 }
@@ -456,7 +457,6 @@ writeback_single_inode(struct inode *inode, struct writeback_control *wbc)
456 } 457 }
457 } 458 }
458 inode_sync_complete(inode); 459 inode_sync_complete(inode);
459 spin_unlock(&inode->i_lock);
460 return ret; 460 return ret;
461} 461}
462 462
@@ -544,7 +544,6 @@ static int writeback_sb_inodes(struct super_block *sb, struct bdi_writeback *wb,
544 } 544 }
545 545
546 __iget(inode); 546 __iget(inode);
547 spin_unlock(&inode->i_lock);
548 547
549 pages_skipped = wbc->pages_skipped; 548 pages_skipped = wbc->pages_skipped;
550 writeback_single_inode(inode, wbc); 549 writeback_single_inode(inode, wbc);
@@ -555,6 +554,7 @@ static int writeback_sb_inodes(struct super_block *sb, struct bdi_writeback *wb,
555 */ 554 */
556 redirty_tail(inode); 555 redirty_tail(inode);
557 } 556 }
557 spin_unlock(&inode->i_lock);
558 spin_unlock(&inode_wb_list_lock); 558 spin_unlock(&inode_wb_list_lock);
559 iput(inode); 559 iput(inode);
560 cond_resched(); 560 cond_resched();
@@ -1309,7 +1309,9 @@ int write_inode_now(struct inode *inode, int sync)
1309 1309
1310 might_sleep(); 1310 might_sleep();
1311 spin_lock(&inode_wb_list_lock); 1311 spin_lock(&inode_wb_list_lock);
1312 spin_lock(&inode->i_lock);
1312 ret = writeback_single_inode(inode, &wbc); 1313 ret = writeback_single_inode(inode, &wbc);
1314 spin_unlock(&inode->i_lock);
1313 spin_unlock(&inode_wb_list_lock); 1315 spin_unlock(&inode_wb_list_lock);
1314 if (sync) 1316 if (sync)
1315 inode_sync_wait(inode); 1317 inode_sync_wait(inode);
@@ -1333,7 +1335,9 @@ int sync_inode(struct inode *inode, struct writeback_control *wbc)
1333 int ret; 1335 int ret;
1334 1336
1335 spin_lock(&inode_wb_list_lock); 1337 spin_lock(&inode_wb_list_lock);
1338 spin_lock(&inode->i_lock);
1336 ret = writeback_single_inode(inode, wbc); 1339 ret = writeback_single_inode(inode, wbc);
1340 spin_unlock(&inode->i_lock);
1337 spin_unlock(&inode_wb_list_lock); 1341 spin_unlock(&inode_wb_list_lock);
1338 return ret; 1342 return ret;
1339} 1343}