diff mbox series

[v3,3/9] loop: Switch to set_capacity_revalidate_and_notify()

Message ID 20200427074222.65369-4-maco@android.com (mailing list archive)
State New, archived
Headers show
Series Add a new LOOP_SET_FD_AND_STATUS ioctl | expand

Commit Message

Martijn Coenen April 27, 2020, 7:42 a.m. UTC
This was recently added to block/genhd.c, and takes care of both
updating the capacity and notifying userspace of the new size.

Signed-off-by: Martijn Coenen <maco@android.com>
---
 drivers/block/loop.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Christoph Hellwig April 27, 2020, 2:54 p.m. UTC | #1
On Mon, Apr 27, 2020 at 09:42:16AM +0200, Martijn Coenen wrote:
>  	struct block_device *bdev = lo->lo_device;
>  
> -	set_capacity(lo->lo_disk, size);
>  	bd_set_size(bdev, size << SECTOR_SHIFT);
> +
>  	/* let user-space know about the new size */
> -	kobject_uevent(&disk_to_dev(bdev->bd_disk)->kobj, KOBJ_CHANGE);
> +	set_capacity_revalidate_and_notify(lo->lo_disk, size, false);

I'd drop the comment as that is pretty explicit with
set_capacity_revalidate_and_notify.

Otherwise looks good:

Reviewed-by: Christoph Hellwig <hch@lst.de>
diff mbox series

Patch

diff --git a/drivers/block/loop.c b/drivers/block/loop.c
index 4630d098cc54..2e2874318393 100644
--- a/drivers/block/loop.c
+++ b/drivers/block/loop.c
@@ -253,10 +253,10 @@  static void loop_set_size(struct loop_device *lo, loff_t size)
 {
 	struct block_device *bdev = lo->lo_device;
 
-	set_capacity(lo->lo_disk, size);
 	bd_set_size(bdev, size << SECTOR_SHIFT);
+
 	/* let user-space know about the new size */
-	kobject_uevent(&disk_to_dev(bdev->bd_disk)->kobj, KOBJ_CHANGE);
+	set_capacity_revalidate_and_notify(lo->lo_disk, size, false);
 }
 
 static int