Commit 5cb8b824 authored by Tejun Heo's avatar Tejun Heo Committed by Jens Axboe

writeback: use unlocked_inode_to_wb transaction in inode_congested()

Similar to wb stat updates, inode_congested() accesses the associated
wb of an inode locklessly, which will break with foreign inode wb
switching.  This path updates inode_congested() to use unlocked inode
wb access transaction introduced by the previous patch.

Combined with the previous two patches, this makes all wb list and
access operations to be protected by either of inode->i_lock,
wb->list_lock, or mapping->tree_lock while wb switching is in
progress.
Signed-off-by: default avatarTejun Heo <tj@kernel.org>
Cc: Jens Axboe <axboe@kernel.dk>
Cc: Jan Kara <jack@suse.cz>
Cc: Wu Fengguang <fengguang.wu@intel.com>
Cc: Greg Thelen <gthelen@google.com>
Signed-off-by: default avatarJens Axboe <axboe@fb.com>
parent 682aa8e1
...@@ -618,10 +618,18 @@ void wbc_account_io(struct writeback_control *wbc, struct page *page, ...@@ -618,10 +618,18 @@ void wbc_account_io(struct writeback_control *wbc, struct page *page,
*/ */
int inode_congested(struct inode *inode, int cong_bits) int inode_congested(struct inode *inode, int cong_bits)
{ {
if (inode) { /*
struct bdi_writeback *wb = inode_to_wb(inode); * Once set, ->i_wb never becomes NULL while the inode is alive.
if (wb) * Start transaction iff ->i_wb is visible.
return wb_congested(wb, cong_bits); */
if (inode && inode_to_wb(inode)) {
struct bdi_writeback *wb;
bool locked, congested;
wb = unlocked_inode_to_wb_begin(inode, &locked);
congested = wb_congested(wb, cong_bits);
unlocked_inode_to_wb_end(inode, locked);
return congested;
} }
return wb_congested(&inode_to_bdi(inode)->wb, cong_bits); return wb_congested(&inode_to_bdi(inode)->wb, cong_bits);
......
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