Commit 0f1b1fd8 authored by Dave Chinner's avatar Dave Chinner Committed by Al Viro

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: default avatarDave Chinner <dchinner@redhat.com>
Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
parent 67a23c49
...@@ -332,9 +332,9 @@ static void inode_wait_for_writeback(struct inode *inode) ...@@ -332,9 +332,9 @@ static void inode_wait_for_writeback(struct inode *inode)
} }
/* /*
* Write out an inode's dirty pages. Called under inode_wb_list_lock. Either * Write out an inode's dirty pages. Called under inode_wb_list_lock and
* the caller has an active reference on the inode or the inode has I_WILL_FREE * inode->i_lock. Either the caller has an active reference on the inode or
* set. * the inode has I_WILL_FREE set.
* *
* If `wait' is set, wait on the writeout. * If `wait' is set, wait on the writeout.
* *
...@@ -349,7 +349,9 @@ writeback_single_inode(struct inode *inode, struct writeback_control *wbc) ...@@ -349,7 +349,9 @@ writeback_single_inode(struct inode *inode, struct writeback_control *wbc)
unsigned dirty; unsigned dirty;
int ret; int ret;
spin_lock(&inode->i_lock); assert_spin_locked(&inode_wb_list_lock);
assert_spin_locked(&inode->i_lock);
if (!atomic_read(&inode->i_count)) if (!atomic_read(&inode->i_count))
WARN_ON(!(inode->i_state & (I_WILL_FREE|I_FREEING))); WARN_ON(!(inode->i_state & (I_WILL_FREE|I_FREEING)));
else else
...@@ -365,7 +367,6 @@ writeback_single_inode(struct inode *inode, struct writeback_control *wbc) ...@@ -365,7 +367,6 @@ writeback_single_inode(struct inode *inode, struct writeback_control *wbc)
* completed a full scan of b_io. * completed a full scan of b_io.
*/ */
if (wbc->sync_mode != WB_SYNC_ALL) { if (wbc->sync_mode != WB_SYNC_ALL) {
spin_unlock(&inode->i_lock);
requeue_io(inode); requeue_io(inode);
return 0; return 0;
} }
...@@ -456,7 +457,6 @@ writeback_single_inode(struct inode *inode, struct writeback_control *wbc) ...@@ -456,7 +457,6 @@ writeback_single_inode(struct inode *inode, struct writeback_control *wbc)
} }
} }
inode_sync_complete(inode); inode_sync_complete(inode);
spin_unlock(&inode->i_lock);
return ret; return ret;
} }
...@@ -544,7 +544,6 @@ static int writeback_sb_inodes(struct super_block *sb, struct bdi_writeback *wb, ...@@ -544,7 +544,6 @@ static int writeback_sb_inodes(struct super_block *sb, struct bdi_writeback *wb,
} }
__iget(inode); __iget(inode);
spin_unlock(&inode->i_lock);
pages_skipped = wbc->pages_skipped; pages_skipped = wbc->pages_skipped;
writeback_single_inode(inode, wbc); writeback_single_inode(inode, wbc);
...@@ -555,6 +554,7 @@ static int writeback_sb_inodes(struct super_block *sb, struct bdi_writeback *wb, ...@@ -555,6 +554,7 @@ static int writeback_sb_inodes(struct super_block *sb, struct bdi_writeback *wb,
*/ */
redirty_tail(inode); redirty_tail(inode);
} }
spin_unlock(&inode->i_lock);
spin_unlock(&inode_wb_list_lock); spin_unlock(&inode_wb_list_lock);
iput(inode); iput(inode);
cond_resched(); cond_resched();
...@@ -1309,7 +1309,9 @@ int write_inode_now(struct inode *inode, int sync) ...@@ -1309,7 +1309,9 @@ int write_inode_now(struct inode *inode, int sync)
might_sleep(); might_sleep();
spin_lock(&inode_wb_list_lock); spin_lock(&inode_wb_list_lock);
spin_lock(&inode->i_lock);
ret = writeback_single_inode(inode, &wbc); ret = writeback_single_inode(inode, &wbc);
spin_unlock(&inode->i_lock);
spin_unlock(&inode_wb_list_lock); spin_unlock(&inode_wb_list_lock);
if (sync) if (sync)
inode_sync_wait(inode); inode_sync_wait(inode);
...@@ -1333,7 +1335,9 @@ int sync_inode(struct inode *inode, struct writeback_control *wbc) ...@@ -1333,7 +1335,9 @@ int sync_inode(struct inode *inode, struct writeback_control *wbc)
int ret; int ret;
spin_lock(&inode_wb_list_lock); spin_lock(&inode_wb_list_lock);
spin_lock(&inode->i_lock);
ret = writeback_single_inode(inode, wbc); ret = writeback_single_inode(inode, wbc);
spin_unlock(&inode->i_lock);
spin_unlock(&inode_wb_list_lock); spin_unlock(&inode_wb_list_lock);
return ret; return ret;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment