diff options
author | Jan Kara <jack@suse.cz> | 2012-05-03 08:47:59 -0400 |
---|---|---|
committer | Fengguang Wu <fengguang.wu@intel.com> | 2012-05-06 01:43:39 -0400 |
commit | f0d07b7ffde758a27a48509ceda9a9ef413e0ea0 (patch) | |
tree | cb02c3a9e662cca039f7093b69f62b4e0838c98f /fs/fs-writeback.c | |
parent | ccb26b5a65867839d95156e02ea4861f64a8cbf3 (diff) |
writeback: Remove wb->list_lock from writeback_single_inode()
writeback_single_inode() doesn't need wb->list_lock for anything on entry now.
So remove the requirement. This makes locking of writeback_single_inode()
temporarily awkward (entering with i_lock, returning with i_lock and
wb->list_lock) but it will be sanitized in the next patch.
Also inode_wait_for_writeback() doesn't need wb->list_lock for anything. It was
just taking it to make usage convenient for callers but with
writeback_single_inode() changing it's not very convenient anymore. So remove
the lock from that function.
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Jan Kara <jack@suse.cz>
Signed-off-by: Fengguang Wu <fengguang.wu@intel.com>
Diffstat (limited to 'fs/fs-writeback.c')
-rw-r--r-- | fs/fs-writeback.c | 17 |
1 files changed, 7 insertions, 10 deletions
diff --git a/fs/fs-writeback.c b/fs/fs-writeback.c index 5d3de002cb8e..3b87dc80fd30 100644 --- a/fs/fs-writeback.c +++ b/fs/fs-writeback.c | |||
@@ -328,8 +328,7 @@ static int write_inode(struct inode *inode, struct writeback_control *wbc) | |||
328 | /* | 328 | /* |
329 | * Wait for writeback on an inode to complete. | 329 | * Wait for writeback on an inode to complete. |
330 | */ | 330 | */ |
331 | static void inode_wait_for_writeback(struct inode *inode, | 331 | static void inode_wait_for_writeback(struct inode *inode) |
332 | struct bdi_writeback *wb) | ||
333 | { | 332 | { |
334 | DEFINE_WAIT_BIT(wq, &inode->i_state, __I_SYNC); | 333 | DEFINE_WAIT_BIT(wq, &inode->i_state, __I_SYNC); |
335 | wait_queue_head_t *wqh; | 334 | wait_queue_head_t *wqh; |
@@ -337,9 +336,7 @@ static void inode_wait_for_writeback(struct inode *inode, | |||
337 | wqh = bit_waitqueue(&inode->i_state, __I_SYNC); | 336 | wqh = bit_waitqueue(&inode->i_state, __I_SYNC); |
338 | while (inode->i_state & I_SYNC) { | 337 | while (inode->i_state & I_SYNC) { |
339 | spin_unlock(&inode->i_lock); | 338 | spin_unlock(&inode->i_lock); |
340 | spin_unlock(&wb->list_lock); | ||
341 | __wait_on_bit(wqh, &wq, inode_wait, TASK_UNINTERRUPTIBLE); | 339 | __wait_on_bit(wqh, &wq, inode_wait, TASK_UNINTERRUPTIBLE); |
342 | spin_lock(&wb->list_lock); | ||
343 | spin_lock(&inode->i_lock); | 340 | spin_lock(&inode->i_lock); |
344 | } | 341 | } |
345 | } | 342 | } |
@@ -418,7 +415,6 @@ writeback_single_inode(struct inode *inode, struct bdi_writeback *wb, | |||
418 | unsigned dirty; | 415 | unsigned dirty; |
419 | int ret; | 416 | int ret; |
420 | 417 | ||
421 | assert_spin_locked(&wb->list_lock); | ||
422 | assert_spin_locked(&inode->i_lock); | 418 | assert_spin_locked(&inode->i_lock); |
423 | 419 | ||
424 | if (!atomic_read(&inode->i_count)) | 420 | if (!atomic_read(&inode->i_count)) |
@@ -432,7 +428,7 @@ writeback_single_inode(struct inode *inode, struct bdi_writeback *wb, | |||
432 | /* | 428 | /* |
433 | * It's a data-integrity sync. We must wait. | 429 | * It's a data-integrity sync. We must wait. |
434 | */ | 430 | */ |
435 | inode_wait_for_writeback(inode, wb); | 431 | inode_wait_for_writeback(inode); |
436 | } | 432 | } |
437 | 433 | ||
438 | BUG_ON(inode->i_state & I_SYNC); | 434 | BUG_ON(inode->i_state & I_SYNC); |
@@ -440,7 +436,6 @@ writeback_single_inode(struct inode *inode, struct bdi_writeback *wb, | |||
440 | /* Set I_SYNC, reset I_DIRTY_PAGES */ | 436 | /* Set I_SYNC, reset I_DIRTY_PAGES */ |
441 | inode->i_state |= I_SYNC; | 437 | inode->i_state |= I_SYNC; |
442 | spin_unlock(&inode->i_lock); | 438 | spin_unlock(&inode->i_lock); |
443 | spin_unlock(&wb->list_lock); | ||
444 | 439 | ||
445 | ret = do_writepages(mapping, wbc); | 440 | ret = do_writepages(mapping, wbc); |
446 | 441 | ||
@@ -587,6 +582,8 @@ static long writeback_sb_inodes(struct super_block *sb, | |||
587 | trace_writeback_sb_inodes_requeue(inode); | 582 | trace_writeback_sb_inodes_requeue(inode); |
588 | continue; | 583 | continue; |
589 | } | 584 | } |
585 | spin_unlock(&wb->list_lock); | ||
586 | |||
590 | __iget(inode); | 587 | __iget(inode); |
591 | write_chunk = writeback_chunk_size(wb->bdi, work); | 588 | write_chunk = writeback_chunk_size(wb->bdi, work); |
592 | wbc.nr_to_write = write_chunk; | 589 | wbc.nr_to_write = write_chunk; |
@@ -803,8 +800,10 @@ static long wb_writeback(struct bdi_writeback *wb, | |||
803 | trace_writeback_wait(wb->bdi, work); | 800 | trace_writeback_wait(wb->bdi, work); |
804 | inode = wb_inode(wb->b_more_io.prev); | 801 | inode = wb_inode(wb->b_more_io.prev); |
805 | spin_lock(&inode->i_lock); | 802 | spin_lock(&inode->i_lock); |
806 | inode_wait_for_writeback(inode, wb); | 803 | spin_unlock(&wb->list_lock); |
804 | inode_wait_for_writeback(inode); | ||
807 | spin_unlock(&inode->i_lock); | 805 | spin_unlock(&inode->i_lock); |
806 | spin_lock(&wb->list_lock); | ||
808 | } | 807 | } |
809 | } | 808 | } |
810 | spin_unlock(&wb->list_lock); | 809 | spin_unlock(&wb->list_lock); |
@@ -1350,7 +1349,6 @@ int write_inode_now(struct inode *inode, int sync) | |||
1350 | wbc.nr_to_write = 0; | 1349 | wbc.nr_to_write = 0; |
1351 | 1350 | ||
1352 | might_sleep(); | 1351 | might_sleep(); |
1353 | spin_lock(&wb->list_lock); | ||
1354 | spin_lock(&inode->i_lock); | 1352 | spin_lock(&inode->i_lock); |
1355 | ret = writeback_single_inode(inode, wb, &wbc); | 1353 | ret = writeback_single_inode(inode, wb, &wbc); |
1356 | spin_unlock(&inode->i_lock); | 1354 | spin_unlock(&inode->i_lock); |
@@ -1375,7 +1373,6 @@ int sync_inode(struct inode *inode, struct writeback_control *wbc) | |||
1375 | struct bdi_writeback *wb = &inode_to_bdi(inode)->wb; | 1373 | struct bdi_writeback *wb = &inode_to_bdi(inode)->wb; |
1376 | int ret; | 1374 | int ret; |
1377 | 1375 | ||
1378 | spin_lock(&wb->list_lock); | ||
1379 | spin_lock(&inode->i_lock); | 1376 | spin_lock(&inode->i_lock); |
1380 | ret = writeback_single_inode(inode, wb, wbc); | 1377 | ret = writeback_single_inode(inode, wb, wbc); |
1381 | spin_unlock(&inode->i_lock); | 1378 | spin_unlock(&inode->i_lock); |