diff mbox series

block: Don't revalidate bdev of hidden gendisk

Message ID 20190515065740.12397-1-jack@suse.cz (mailing list archive)
State New, archived
Headers show
Series block: Don't revalidate bdev of hidden gendisk | expand

Commit Message

Jan Kara May 15, 2019, 6:57 a.m. UTC
When hidden gendisk is revalidated, there's no point in revalidating
associated block device as there's none. We would thus just create new
bdev inode, report "detected capacity change from 0 to XXX" message and
evict the bdev inode again. Avoid this pointless dance and confusing
message in the kernel log.

Signed-off-by: Jan Kara <jack@suse.cz>
---
 fs/block_dev.c | 25 ++++++++++++++++---------
 1 file changed, 16 insertions(+), 9 deletions(-)

Comments

Hannes Reinecke May 15, 2019, 7:08 a.m. UTC | #1
On 5/15/19 8:57 AM, Jan Kara wrote:
> When hidden gendisk is revalidated, there's no point in revalidating
> associated block device as there's none. We would thus just create new
> bdev inode, report "detected capacity change from 0 to XXX" message and
> evict the bdev inode again. Avoid this pointless dance and confusing
> message in the kernel log.
> 
> Signed-off-by: Jan Kara <jack@suse.cz>
> ---
>   fs/block_dev.c | 25 ++++++++++++++++---------
>   1 file changed, 16 insertions(+), 9 deletions(-)
> 
Reviewed-by: Hannes Reinecke <hare@suse.com>

Cheers,

Hannes
Christoph Hellwig May 16, 2019, 7:02 a.m. UTC | #2
On Wed, May 15, 2019 at 08:57:40AM +0200, Jan Kara wrote:
> When hidden gendisk is revalidated, there's no point in revalidating
> associated block device as there's none. We would thus just create new
> bdev inode, report "detected capacity change from 0 to XXX" message and
> evict the bdev inode again. Avoid this pointless dance and confusing
> message in the kernel log.

Personally I'd do an early return instead of the indent, but
functionally this looks fine:

Reviewed-by: Christoph Hellwig <hch@lst.de>
Jan Kara May 27, 2019, 12:25 p.m. UTC | #3
On Wed 15-05-19 08:57:40, Jan Kara wrote:
> When hidden gendisk is revalidated, there's no point in revalidating
> associated block device as there's none. We would thus just create new
> bdev inode, report "detected capacity change from 0 to XXX" message and
> evict the bdev inode again. Avoid this pointless dance and confusing
> message in the kernel log.
> 
> Signed-off-by: Jan Kara <jack@suse.cz>

Jens, ping?

								Honza

> ---
>  fs/block_dev.c | 25 ++++++++++++++++---------
>  1 file changed, 16 insertions(+), 9 deletions(-)
> 
> diff --git a/fs/block_dev.c b/fs/block_dev.c
> index 0f7552a87d54..9e671bbf7362 100644
> --- a/fs/block_dev.c
> +++ b/fs/block_dev.c
> @@ -1405,20 +1405,27 @@ void check_disk_size_change(struct gendisk *disk, struct block_device *bdev,
>   */
>  int revalidate_disk(struct gendisk *disk)
>  {
> -	struct block_device *bdev;
>  	int ret = 0;
>  
>  	if (disk->fops->revalidate_disk)
>  		ret = disk->fops->revalidate_disk(disk);
> -	bdev = bdget_disk(disk, 0);
> -	if (!bdev)
> -		return ret;
>  
> -	mutex_lock(&bdev->bd_mutex);
> -	check_disk_size_change(disk, bdev, ret == 0);
> -	bdev->bd_invalidated = 0;
> -	mutex_unlock(&bdev->bd_mutex);
> -	bdput(bdev);
> +	/*
> +	 * Hidden disks don't have associated bdev so there's no point in
> +	 * revalidating it.
> +	 */
> +	if (!(disk->flags & GENHD_FL_HIDDEN)) {
> +		struct block_device *bdev = bdget_disk(disk, 0);
> +
> +		if (!bdev)
> +			return ret;
> +
> +		mutex_lock(&bdev->bd_mutex);
> +		check_disk_size_change(disk, bdev, ret == 0);
> +		bdev->bd_invalidated = 0;
> +		mutex_unlock(&bdev->bd_mutex);
> +		bdput(bdev);
> +	}
>  	return ret;
>  }
>  EXPORT_SYMBOL(revalidate_disk);
> -- 
> 2.16.4
>
Jens Axboe May 27, 2019, 1:35 p.m. UTC | #4
On 5/15/19 12:57 AM, Jan Kara wrote:
> When hidden gendisk is revalidated, there's no point in revalidating
> associated block device as there's none. We would thus just create new
> bdev inode, report "detected capacity change from 0 to XXX" message and
> evict the bdev inode again. Avoid this pointless dance and confusing
> message in the kernel log.

Applied, thanks.
diff mbox series

Patch

diff --git a/fs/block_dev.c b/fs/block_dev.c
index 0f7552a87d54..9e671bbf7362 100644
--- a/fs/block_dev.c
+++ b/fs/block_dev.c
@@ -1405,20 +1405,27 @@  void check_disk_size_change(struct gendisk *disk, struct block_device *bdev,
  */
 int revalidate_disk(struct gendisk *disk)
 {
-	struct block_device *bdev;
 	int ret = 0;
 
 	if (disk->fops->revalidate_disk)
 		ret = disk->fops->revalidate_disk(disk);
-	bdev = bdget_disk(disk, 0);
-	if (!bdev)
-		return ret;
 
-	mutex_lock(&bdev->bd_mutex);
-	check_disk_size_change(disk, bdev, ret == 0);
-	bdev->bd_invalidated = 0;
-	mutex_unlock(&bdev->bd_mutex);
-	bdput(bdev);
+	/*
+	 * Hidden disks don't have associated bdev so there's no point in
+	 * revalidating it.
+	 */
+	if (!(disk->flags & GENHD_FL_HIDDEN)) {
+		struct block_device *bdev = bdget_disk(disk, 0);
+
+		if (!bdev)
+			return ret;
+
+		mutex_lock(&bdev->bd_mutex);
+		check_disk_size_change(disk, bdev, ret == 0);
+		bdev->bd_invalidated = 0;
+		mutex_unlock(&bdev->bd_mutex);
+		bdput(bdev);
+	}
 	return ret;
 }
 EXPORT_SYMBOL(revalidate_disk);