*/
int inode_congested(struct inode *inode, int cong_bits)
{
- if (inode) {
- struct bdi_writeback *wb = inode_to_wb(inode);
- if (wb)
- return wb_congested(wb, cong_bits);
+ /*
+ * Once set, ->i_wb never becomes NULL while the inode is alive.
+ * Start transaction iff ->i_wb is visible.
+ */
+ 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);