linux-block.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] block: Don't revalidate bdev of hidden gendisk
@ 2019-05-15  6:57 Jan Kara
  2019-05-15  7:08 ` Hannes Reinecke
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Jan Kara @ 2019-05-15  6:57 UTC (permalink / raw)
  To: Jens Axboe; +Cc: linux-block, hare, Jan Kara

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(-)

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


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] block: Don't revalidate bdev of hidden gendisk
  2019-05-15  6:57 [PATCH] block: Don't revalidate bdev of hidden gendisk Jan Kara
@ 2019-05-15  7:08 ` Hannes Reinecke
  2019-05-16  7:02 ` Christoph Hellwig
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Hannes Reinecke @ 2019-05-15  7:08 UTC (permalink / raw)
  To: Jan Kara, Jens Axboe; +Cc: linux-block

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
-- 
Dr. Hannes Reinecke		   Teamlead Storage & Networking
hare@suse.de			               +49 911 74053 688
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: Felix Imendörffer, Mary Higgins, Sri Rasiah
HRB 21284 (AG Nürnberg)

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] block: Don't revalidate bdev of hidden gendisk
  2019-05-15  6:57 [PATCH] block: Don't revalidate bdev of hidden gendisk Jan Kara
  2019-05-15  7:08 ` Hannes Reinecke
@ 2019-05-16  7:02 ` Christoph Hellwig
  2019-05-27 12:25 ` Jan Kara
  2019-05-27 13:35 ` Jens Axboe
  3 siblings, 0 replies; 5+ messages in thread
From: Christoph Hellwig @ 2019-05-16  7:02 UTC (permalink / raw)
  To: Jan Kara; +Cc: Jens Axboe, linux-block, hare

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>

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] block: Don't revalidate bdev of hidden gendisk
  2019-05-15  6:57 [PATCH] block: Don't revalidate bdev of hidden gendisk Jan Kara
  2019-05-15  7:08 ` Hannes Reinecke
  2019-05-16  7:02 ` Christoph Hellwig
@ 2019-05-27 12:25 ` Jan Kara
  2019-05-27 13:35 ` Jens Axboe
  3 siblings, 0 replies; 5+ messages in thread
From: Jan Kara @ 2019-05-27 12:25 UTC (permalink / raw)
  To: Jens Axboe; +Cc: linux-block, hare, Jan Kara

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
> 
-- 
Jan Kara <jack@suse.com>
SUSE Labs, CR

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] block: Don't revalidate bdev of hidden gendisk
  2019-05-15  6:57 [PATCH] block: Don't revalidate bdev of hidden gendisk Jan Kara
                   ` (2 preceding siblings ...)
  2019-05-27 12:25 ` Jan Kara
@ 2019-05-27 13:35 ` Jens Axboe
  3 siblings, 0 replies; 5+ messages in thread
From: Jens Axboe @ 2019-05-27 13:35 UTC (permalink / raw)
  To: Jan Kara; +Cc: linux-block, hare

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.

-- 
Jens Axboe


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2019-05-27 13:35 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-05-15  6:57 [PATCH] block: Don't revalidate bdev of hidden gendisk Jan Kara
2019-05-15  7:08 ` Hannes Reinecke
2019-05-16  7:02 ` Christoph Hellwig
2019-05-27 12:25 ` Jan Kara
2019-05-27 13:35 ` Jens Axboe

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).