summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGreg Kroah-Hartman <gregkh@suse.de>2011-08-02 14:45:26 -0700
committerGreg Kroah-Hartman <gregkh@suse.de>2011-08-08 10:36:06 -0700
commit20befe11b5aae8d20479c0e3a73bace6db5b4a9a (patch)
treee939611e64d5209d3f6b36608c68114b332320cb
parenta01770179c5a37cda3ace94c938a2b7328a15eb0 (diff)
downloadlwn-20befe11b5aae8d20479c0e3a73bace6db5b4a9a.tar.gz
lwn-20befe11b5aae8d20479c0e3a73bace6db5b4a9a.zip
Revert "block: rescan partitions on invalidated devices on -ENOMEDIA too"
This reverts commit 6f31747bfeb8c74e6d0a10ecef0abe2a04c5a6cb (commit 02e352287a40bd456eb78df705bf888bc3161d3f upstream) This should have only been commited on .38 and newer, not older kernels like this one, sorry. Cc: Tejun Heo <tj@kernel.org> Cc: David Zeuthen <zeuthen@gmail.com> Cc: Martin Pitt <martin.pitt@ubuntu.com> Cc: Kay Sievers <kay.sievers@vrfy.org> Cc: Alan Cox <alan@lxorguk.ukuu.org.uk> Cc: Jens Axboe <jaxboe@fusionio.com> Cc: Andi Kleen <ak@linux.intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
-rw-r--r--fs/block_dev.c27
1 files changed, 9 insertions, 18 deletions
diff --git a/fs/block_dev.c b/fs/block_dev.c
index 5d8d311af9f4..8db62b2b6df8 100644
--- a/fs/block_dev.c
+++ b/fs/block_dev.c
@@ -1211,7 +1211,6 @@ static int __blkdev_get(struct block_device *bdev, fmode_t mode, int for_part)
if (!bdev->bd_part)
goto out_clear;
- ret = 0;
if (disk->fops->open) {
ret = disk->fops->open(bdev, mode);
if (ret == -ERESTARTSYS) {
@@ -1227,18 +1226,9 @@ static int __blkdev_get(struct block_device *bdev, fmode_t mode, int for_part)
mutex_unlock(&bdev->bd_mutex);
goto restart;
}
+ if (ret)
+ goto out_clear;
}
- /*
- * If the device is invalidated, rescan partition
- * if open succeeded or failed with -ENOMEDIUM.
- * The latter is necessary to prevent ghost
- * partitions on a removed medium.
- */
- if (bdev->bd_invalidated && (!ret || ret == -ENOMEDIUM))
- rescan_partitions(disk, bdev);
- if (ret)
- goto out_clear;
-
if (!bdev->bd_openers) {
bd_set_size(bdev,(loff_t)get_capacity(disk)<<9);
bdi = blk_get_backing_dev_info(bdev);
@@ -1246,6 +1236,8 @@ static int __blkdev_get(struct block_device *bdev, fmode_t mode, int for_part)
bdi = &default_backing_dev_info;
bdev->bd_inode->i_data.backing_dev_info = bdi;
}
+ if (bdev->bd_invalidated)
+ rescan_partitions(disk, bdev);
} else {
struct block_device *whole;
whole = bdget_disk(disk, 0);
@@ -1272,14 +1264,13 @@ static int __blkdev_get(struct block_device *bdev, fmode_t mode, int for_part)
put_disk(disk);
disk = NULL;
if (bdev->bd_contains == bdev) {
- ret = 0;
- if (bdev->bd_disk->fops->open)
+ if (bdev->bd_disk->fops->open) {
ret = bdev->bd_disk->fops->open(bdev, mode);
- /* the same as first opener case, read comment there */
- if (bdev->bd_invalidated && (!ret || ret == -ENOMEDIUM))
+ if (ret)
+ goto out_unlock_bdev;
+ }
+ if (bdev->bd_invalidated)
rescan_partitions(bdev->bd_disk, bdev);
- if (ret)
- goto out_unlock_bdev;
}
}
bdev->bd_openers++;