aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
Diffstat (limited to 'fs')
-rw-r--r--fs/block_dev.c34
-rw-r--r--fs/btrfs/disk-io.c2
-rw-r--r--fs/xfs/xfs_buf.c2
3 files changed, 12 insertions, 26 deletions
diff --git a/fs/block_dev.c b/fs/block_dev.c
index 6d7274619bf9..cc8d68ac29aa 100644
--- a/fs/block_dev.c
+++ b/fs/block_dev.c
@@ -50,32 +50,22 @@ inline struct block_device *I_BDEV(struct inode *inode)
50EXPORT_SYMBOL(I_BDEV); 50EXPORT_SYMBOL(I_BDEV);
51 51
52/* 52/*
53 * Move the inode from its current bdi to a new bdi. If the inode is dirty we 53 * Move the inode from its current bdi to a new bdi. Make sure the inode
54 * need to move it onto the dirty list of @dst so that the inode is always on 54 * is clean before moving so that it doesn't linger on the old bdi.
55 * the right list.
56 */ 55 */
57static void bdev_inode_switch_bdi(struct inode *inode, 56static void bdev_inode_switch_bdi(struct inode *inode,
58 struct backing_dev_info *dst) 57 struct backing_dev_info *dst)
59{ 58{
60 struct backing_dev_info *old = inode->i_data.backing_dev_info; 59 while (true) {
61 bool wakeup_bdi = false; 60 spin_lock(&inode->i_lock);
62 61 if (!(inode->i_state & I_DIRTY)) {
63 if (unlikely(dst == old)) /* deadlock avoidance */ 62 inode->i_data.backing_dev_info = dst;
64 return; 63 spin_unlock(&inode->i_lock);
65 bdi_lock_two(&old->wb, &dst->wb); 64 return;
66 spin_lock(&inode->i_lock); 65 }
67 inode->i_data.backing_dev_info = dst; 66 spin_unlock(&inode->i_lock);
68 if (inode->i_state & I_DIRTY) { 67 WARN_ON_ONCE(write_inode_now(inode, true));
69 if (bdi_cap_writeback_dirty(dst) && !wb_has_dirty_io(&dst->wb))
70 wakeup_bdi = true;
71 list_move(&inode->i_wb_list, &dst->wb.b_dirty);
72 } 68 }
73 spin_unlock(&inode->i_lock);
74 spin_unlock(&old->wb.list_lock);
75 spin_unlock(&dst->wb.list_lock);
76
77 if (wakeup_bdi)
78 bdi_wakeup_thread_delayed(dst);
79} 69}
80 70
81/* Kill _all_ buffers and pagecache , dirty or not.. */ 71/* Kill _all_ buffers and pagecache , dirty or not.. */
@@ -1173,8 +1163,6 @@ static int __blkdev_get(struct block_device *bdev, fmode_t mode, int for_part)
1173 if (!ret) { 1163 if (!ret) {
1174 bd_set_size(bdev,(loff_t)get_capacity(disk)<<9); 1164 bd_set_size(bdev,(loff_t)get_capacity(disk)<<9);
1175 bdi = blk_get_backing_dev_info(bdev); 1165 bdi = blk_get_backing_dev_info(bdev);
1176 if (bdi == NULL)
1177 bdi = &default_backing_dev_info;
1178 bdev_inode_switch_bdi(bdev->bd_inode, bdi); 1166 bdev_inode_switch_bdi(bdev->bd_inode, bdi);
1179 } 1167 }
1180 1168
diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c
index a1d36e62179c..7e221b090308 100644
--- a/fs/btrfs/disk-io.c
+++ b/fs/btrfs/disk-io.c
@@ -1699,7 +1699,7 @@ static int btrfs_congested_fn(void *congested_data, int bdi_bits)
1699 if (!device->bdev) 1699 if (!device->bdev)
1700 continue; 1700 continue;
1701 bdi = blk_get_backing_dev_info(device->bdev); 1701 bdi = blk_get_backing_dev_info(device->bdev);
1702 if (bdi && bdi_congested(bdi, bdi_bits)) { 1702 if (bdi_congested(bdi, bdi_bits)) {
1703 ret = 1; 1703 ret = 1;
1704 break; 1704 break;
1705 } 1705 }
diff --git a/fs/xfs/xfs_buf.c b/fs/xfs/xfs_buf.c
index cd7b8ca9b064..497fcde381d7 100644
--- a/fs/xfs/xfs_buf.c
+++ b/fs/xfs/xfs_buf.c
@@ -1678,8 +1678,6 @@ xfs_alloc_buftarg(
1678 btp->bt_dev = bdev->bd_dev; 1678 btp->bt_dev = bdev->bd_dev;
1679 btp->bt_bdev = bdev; 1679 btp->bt_bdev = bdev;
1680 btp->bt_bdi = blk_get_backing_dev_info(bdev); 1680 btp->bt_bdi = blk_get_backing_dev_info(bdev);
1681 if (!btp->bt_bdi)
1682 goto error;
1683 1681
1684 if (xfs_setsize_buftarg_early(btp, bdev)) 1682 if (xfs_setsize_buftarg_early(btp, bdev))
1685 goto error; 1683 goto error;