diff options
Diffstat (limited to 'fs/block_dev.c')
-rw-r--r-- | fs/block_dev.c | 26 |
1 files changed, 21 insertions, 5 deletions
diff --git a/fs/block_dev.c b/fs/block_dev.c index 81972eb34b39..4e847e53051f 100644 --- a/fs/block_dev.c +++ b/fs/block_dev.c | |||
@@ -48,6 +48,21 @@ inline struct block_device *I_BDEV(struct inode *inode) | |||
48 | 48 | ||
49 | EXPORT_SYMBOL(I_BDEV); | 49 | EXPORT_SYMBOL(I_BDEV); |
50 | 50 | ||
51 | /* | ||
52 | * move the inode from it's current bdi to the a new bdi. if the inode is dirty | ||
53 | * we need to move it onto the dirty list of @dst so that the inode is always | ||
54 | * on the right list. | ||
55 | */ | ||
56 | static void bdev_inode_switch_bdi(struct inode *inode, | ||
57 | struct backing_dev_info *dst) | ||
58 | { | ||
59 | spin_lock(&inode_lock); | ||
60 | inode->i_data.backing_dev_info = dst; | ||
61 | if (inode->i_state & I_DIRTY) | ||
62 | list_move(&inode->i_list, &dst->wb.b_dirty); | ||
63 | spin_unlock(&inode_lock); | ||
64 | } | ||
65 | |||
51 | static sector_t max_block(struct block_device *bdev) | 66 | static sector_t max_block(struct block_device *bdev) |
52 | { | 67 | { |
53 | sector_t retval = ~((sector_t)0); | 68 | sector_t retval = ~((sector_t)0); |
@@ -1390,7 +1405,7 @@ static int __blkdev_get(struct block_device *bdev, fmode_t mode, int for_part) | |||
1390 | bdi = blk_get_backing_dev_info(bdev); | 1405 | bdi = blk_get_backing_dev_info(bdev); |
1391 | if (bdi == NULL) | 1406 | if (bdi == NULL) |
1392 | bdi = &default_backing_dev_info; | 1407 | bdi = &default_backing_dev_info; |
1393 | bdev->bd_inode->i_data.backing_dev_info = bdi; | 1408 | bdev_inode_switch_bdi(bdev->bd_inode, bdi); |
1394 | } | 1409 | } |
1395 | if (bdev->bd_invalidated) | 1410 | if (bdev->bd_invalidated) |
1396 | rescan_partitions(disk, bdev); | 1411 | rescan_partitions(disk, bdev); |
@@ -1405,8 +1420,8 @@ static int __blkdev_get(struct block_device *bdev, fmode_t mode, int for_part) | |||
1405 | if (ret) | 1420 | if (ret) |
1406 | goto out_clear; | 1421 | goto out_clear; |
1407 | bdev->bd_contains = whole; | 1422 | bdev->bd_contains = whole; |
1408 | bdev->bd_inode->i_data.backing_dev_info = | 1423 | bdev_inode_switch_bdi(bdev->bd_inode, |
1409 | whole->bd_inode->i_data.backing_dev_info; | 1424 | whole->bd_inode->i_data.backing_dev_info); |
1410 | bdev->bd_part = disk_get_part(disk, partno); | 1425 | bdev->bd_part = disk_get_part(disk, partno); |
1411 | if (!(disk->flags & GENHD_FL_UP) || | 1426 | if (!(disk->flags & GENHD_FL_UP) || |
1412 | !bdev->bd_part || !bdev->bd_part->nr_sects) { | 1427 | !bdev->bd_part || !bdev->bd_part->nr_sects) { |
@@ -1439,7 +1454,7 @@ static int __blkdev_get(struct block_device *bdev, fmode_t mode, int for_part) | |||
1439 | disk_put_part(bdev->bd_part); | 1454 | disk_put_part(bdev->bd_part); |
1440 | bdev->bd_disk = NULL; | 1455 | bdev->bd_disk = NULL; |
1441 | bdev->bd_part = NULL; | 1456 | bdev->bd_part = NULL; |
1442 | bdev->bd_inode->i_data.backing_dev_info = &default_backing_dev_info; | 1457 | bdev_inode_switch_bdi(bdev->bd_inode, &default_backing_dev_info); |
1443 | if (bdev != bdev->bd_contains) | 1458 | if (bdev != bdev->bd_contains) |
1444 | __blkdev_put(bdev->bd_contains, mode, 1); | 1459 | __blkdev_put(bdev->bd_contains, mode, 1); |
1445 | bdev->bd_contains = NULL; | 1460 | bdev->bd_contains = NULL; |
@@ -1533,7 +1548,8 @@ static int __blkdev_put(struct block_device *bdev, fmode_t mode, int for_part) | |||
1533 | disk_put_part(bdev->bd_part); | 1548 | disk_put_part(bdev->bd_part); |
1534 | bdev->bd_part = NULL; | 1549 | bdev->bd_part = NULL; |
1535 | bdev->bd_disk = NULL; | 1550 | bdev->bd_disk = NULL; |
1536 | bdev->bd_inode->i_data.backing_dev_info = &default_backing_dev_info; | 1551 | bdev_inode_switch_bdi(bdev->bd_inode, |
1552 | &default_backing_dev_info); | ||
1537 | if (bdev != bdev->bd_contains) | 1553 | if (bdev != bdev->bd_contains) |
1538 | victim = bdev->bd_contains; | 1554 | victim = bdev->bd_contains; |
1539 | bdev->bd_contains = NULL; | 1555 | bdev->bd_contains = NULL; |