Message ID | 20170306163404.1238-2-jack@suse.cz (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
On Mon, Mar 06, 2017 at 05:33:54PM +0100, Jan Kara wrote: > When disk->fops->open() in __blkdev_get() returns -ERESTARTSYS, we > restart the process of opening the block device. However we forget to > switch bdev->bd_bdi back to noop_backing_dev_info and as a result bdev > inode will be pointing to a stale bdi. Fix the problem by setting > bdev->bd_bdi later when __blkdev_get() is already guaranteed to succeed. > > Signed-off-by: Jan Kara <jack@suse.cz> Acked-by: Tejun Heo <tj@kernel.org> Thanks.
On 03/06/2017 05:33 PM, Jan Kara wrote: > When disk->fops->open() in __blkdev_get() returns -ERESTARTSYS, we > restart the process of opening the block device. However we forget to > switch bdev->bd_bdi back to noop_backing_dev_info and as a result bdev > inode will be pointing to a stale bdi. Fix the problem by setting > bdev->bd_bdi later when __blkdev_get() is already guaranteed to succeed. > > Signed-off-by: Jan Kara <jack@suse.cz> > --- > fs/block_dev.c | 7 +++---- > 1 file changed, 3 insertions(+), 4 deletions(-) > Reviewed-by: Hannes Reinecke <hare@suse.com> Cheers, Hannes
diff --git a/fs/block_dev.c b/fs/block_dev.c index 2eca00ec4370..53e2389ae4d4 100644 --- a/fs/block_dev.c +++ b/fs/block_dev.c @@ -1556,8 +1556,6 @@ static int __blkdev_get(struct block_device *bdev, fmode_t mode, int for_part) bdev->bd_disk = disk; bdev->bd_queue = disk->queue; bdev->bd_contains = bdev; - if (bdev->bd_bdi == &noop_backing_dev_info) - bdev->bd_bdi = bdi_get(disk->queue->backing_dev_info); if (!partno) { ret = -ENXIO; @@ -1622,6 +1620,9 @@ static int __blkdev_get(struct block_device *bdev, fmode_t mode, int for_part) } bd_set_size(bdev, (loff_t)bdev->bd_part->nr_sects << 9); } + + if (bdev->bd_bdi == &noop_backing_dev_info) + bdev->bd_bdi = bdi_get(disk->queue->backing_dev_info); } else { if (bdev->bd_contains == bdev) { ret = 0; @@ -1653,8 +1654,6 @@ static int __blkdev_get(struct block_device *bdev, fmode_t mode, int for_part) bdev->bd_disk = NULL; bdev->bd_part = NULL; bdev->bd_queue = NULL; - bdi_put(bdev->bd_bdi); - bdev->bd_bdi = &noop_backing_dev_info; if (bdev != bdev->bd_contains) __blkdev_put(bdev->bd_contains, mode, 1); bdev->bd_contains = NULL;
When disk->fops->open() in __blkdev_get() returns -ERESTARTSYS, we restart the process of opening the block device. However we forget to switch bdev->bd_bdi back to noop_backing_dev_info and as a result bdev inode will be pointing to a stale bdi. Fix the problem by setting bdev->bd_bdi later when __blkdev_get() is already guaranteed to succeed. Signed-off-by: Jan Kara <jack@suse.cz> --- fs/block_dev.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)