From: Christoph Hellwig <hch@lst.de> Date: 2020-11-11 08:27:26
There is no good reason to call revalidate_disk_size separately.
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
drivers/nvme/host/core.c | 5 +----
1 file changed, 1 insertion(+), 4 deletions(-)
From: Christoph Hellwig <hch@lst.de> Date: 2020-11-11 08:27:34
Return if the function ended up sending an uevent or not.
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
block/genhd.c | 7 +++++--
include/linux/genhd.h | 2 +-
2 files changed, 6 insertions(+), 3 deletions(-)
From: Christoph Hellwig <hch@lst.de> Date: 2020-11-11 08:27:51
revalidate_disk_size just updates the block device size from the disk
size. Thus calling it from virtblk_update_cache_mode doesn't actually
do anything.
Signed-off-by: Christoph Hellwig <hch@lst.de>
Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
Acked-by: Michael S. Tsirkin <mst@redhat.com>
---
drivers/block/virtio_blk.c | 1 -
1 file changed, 1 deletion(-)
From: Christoph Hellwig <hch@lst.de> Date: 2020-11-11 08:27:56
revalidate_disk_size is now only called from set_capacity_and_notify,
so drop the export.
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
fs/block_dev.c | 1 -
1 file changed, 1 deletion(-)
From: Christoph Hellwig <hch@lst.de> Date: 2020-11-11 08:27:58
None of the ->resize methods updates the disk size, so calling
revalidate_disk_size here won't do anything.
Signed-off-by: Christoph Hellwig <hch@lst.de>
Acked-by: Song Liu <song@kernel.org>
---
drivers/md/md-cluster.c | 2 --
1 file changed, 2 deletions(-)
From: Christoph Hellwig <hch@lst.de> Date: 2020-11-11 08:28:08
Use set_capacity_and_notify to set the size of both the disk and block
device. This also gets the uevent notifications for the resize for free.
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
drivers/md/dm-raid.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
From: Christoph Hellwig <hch@lst.de> Date: 2020-11-11 08:28:10
Use set_capacity_and_notify to set the size of both the disk and block
device. This also gets the uevent notifications for the resize for free.
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
drivers/block/rnbd/rnbd-clt.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
From: Christoph Hellwig <hch@lst.de> Date: 2020-11-11 08:28:15
Use the block layer helper to update both the disk and block device
sizes. Contrary to the name no notification is sent in this case,
as a size 0 is special cased.
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
drivers/nvme/host/core.c | 13 +------------
1 file changed, 1 insertion(+), 12 deletions(-)
From: Christoph Hellwig <hch@lst.de> Date: 2020-11-11 08:28:19
Use set_capacity_and_notify to set the size of both the disk and block
device. This also gets the uevent notifications for the resize for free.
Signed-off-by: Christoph Hellwig <hch@lst.de>
Acked-by: Ilya Dryomov <idryomov@gmail.com>
---
drivers/block/drbd/drbd_main.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
From: Christoph Hellwig <hch@lst.de> Date: 2020-11-11 08:28:26
Use set_capacity_and_notify to set the size of both the disk and block
device. This also gets the uevent notifications for the resize for free.
Signed-off-by: Christoph Hellwig <hch@lst.de>
Acked-by: Song Liu <song@kernel.org>
---
drivers/md/md-cluster.c | 6 ++----
drivers/md/md-linear.c | 3 +--
drivers/md/md.c | 24 ++++++++++--------------
3 files changed, 13 insertions(+), 20 deletions(-)
@@ -6107,8 +6106,7 @@ int do_md_run(struct mddev *mddev)md_wakeup_thread(mddev->thread);md_wakeup_thread(mddev->sync_thread);/* possibly kick off a reshape */-set_capacity(mddev->gendisk,mddev->array_sectors);-revalidate_disk_size(mddev->gendisk,true);+set_capacity_and_notify(mddev->gendisk,mddev->array_sectors);clear_bit(MD_NOT_READY,&mddev->flags);mddev->changed=1;kobject_uevent(&disk_to_dev(mddev->gendisk)->kobj,KOBJ_CHANGE);
@@ -6423,10 +6421,9 @@ static int do_md_stop(struct mddev *mddev, int mode,if(rdev->raid_disk>=0)sysfs_unlink_rdev(mddev,rdev);-set_capacity(disk,0);+set_capacity_and_notify(disk,0);mutex_unlock(&mddev->open_mutex);mddev->changed=1;-revalidate_disk_size(disk,true);if(mddev->ro)mddev->ro=0;
From: Christoph Hellwig <hch@lst.de> Date: 2020-11-11 08:28:36
Use set_capacity_and_notify to set the size of both the disk and block
device. This also gets the uevent notifications for the resize for free.
Signed-off-by: Christoph Hellwig <hch@lst.de>
Acked-by: Jack Wang <jinpu.wang@cloud.ionos.com>
---
drivers/block/rbd.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
From: Christoph Hellwig <hch@lst.de> Date: 2020-11-11 08:28:40
Use set_capacity_and_notify to set the size of both the disk and block
device. This also gets the uevent notifications for the resize for free.
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
drivers/block/zram/zram_drv.c | 7 ++-----
1 file changed, 2 insertions(+), 5 deletions(-)
@@ -1790,7 +1788,6 @@ static ssize_t reset_store(struct device *dev,/* Make sure all the pending I/O are finished */fsync_bdev(bdev);zram_reset_device(zram);-revalidate_disk_size(zram->disk,true);bdput(bdev);mutex_lock(&bdev->bd_mutex);
From: Christoph Hellwig <hch@lst.de> Date: 2020-11-11 08:28:43
Updating the block device size from irq context can lead to torn
writes of the 64-bit value, and prevents us from using normal
process context locking primitives to serialize access to the 64-bit
nr_sectors value. Defer the set_capacity to the already existing
workqueue handler, where it can be merged with the update of the
block device size by using set_capacity_and_notify. As an extra
bonus this also adds proper uevent notifications for the resize.
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
drivers/block/aoe/aoecmd.c | 15 ++++-----------
1 file changed, 4 insertions(+), 11 deletions(-)
From: Christoph Hellwig <hch@lst.de> Date: 2020-11-11 08:28:49
Use set_capacity_and_notify to set the size of both the disk and block
device. This also gets the uevent notifications for the resize for free.
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
drivers/block/pktcdvd.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
From: Christoph Hellwig <hch@lst.de> Date: 2020-11-11 08:28:56
Use set_capacity_and_notify to set the size of both the disk and block
device. This also gets the uevent notifications for the resize for free.
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
drivers/md/dm.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
From: Christoph Hellwig <hch@lst.de> Date: 2020-11-11 08:29:05
Move the validation of the block from the callers into nbd_set_size.
Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Josef Bacik <josef@toxicpanda.com>
---
drivers/block/nbd.c | 47 +++++++++++++++------------------------------
1 file changed, 15 insertions(+), 32 deletions(-)
From: Christoph Hellwig <hch@lst.de> Date: 2020-11-11 08:29:06
Use set_capacity_and_notify to update the disk and block device sizes and
send a RESIZE uevent to userspace. Note that blktests relies on uevents
being sent also for updates that did not change the device size, so the
explicit kobject_uevent remains for that case.
Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Josef Bacik <josef@toxicpanda.com>
---
drivers/block/nbd.c | 15 +++------------
1 file changed, 3 insertions(+), 12 deletions(-)
From: Christoph Hellwig <hch@lst.de> Date: 2020-11-11 08:29:13
Merge nbd_size_set and nbd_size_update into a single function that also
updates the nbd_config fields. This new function takes the device size
in bytes as the first argument, and the blocksize as the second argument,
simplifying the calculations required in most callers.
Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Josef Bacik <josef@toxicpanda.com>
---
drivers/block/nbd.c | 44 ++++++++++++++++++--------------------------
1 file changed, 18 insertions(+), 26 deletions(-)
From: Christoph Hellwig <hch@lst.de> Date: 2020-11-11 08:29:17
The update_bdev argument is always set to true, so remove it. Also
rename the function to the slighly less verbose set_capacity_and_notify,
as propagating the disk size to the block device isn't really
revalidation.
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
block/genhd.c | 13 +++++--------
drivers/block/loop.c | 11 +++++------
drivers/block/virtio_blk.c | 2 +-
drivers/block/xen-blkfront.c | 2 +-
drivers/nvme/host/core.c | 2 +-
drivers/scsi/sd.c | 5 ++---
include/linux/genhd.h | 3 +--
7 files changed, 16 insertions(+), 22 deletions(-)
From: Christoph Hellwig <hch@lst.de> Date: 2020-11-11 08:29:22
This avoids the extra call to revalidate_disk_size in sd_rescan and
is otherwise a no-op because the size did not change, or we are in
the probe path.
Signed-off-by: Christoph Hellwig <hch@lst.de>
Acked-by: Martin K. Petersen <martin.petersen@oracle.com>
---
drivers/scsi/sd.c | 8 +++-----
1 file changed, 3 insertions(+), 5 deletions(-)
From: Christoph Hellwig <hch@lst.de> Date: 2020-11-11 08:29:25
nbd_size_update is about to acquire a few more callers, so lift the check
into the function.
Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Josef Bacik <josef@toxicpanda.com>
---
drivers/block/nbd.c | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
From: Christoph Hellwig <hch@lst.de> Date: 2020-11-11 08:29:35
Just use set_capacity_revalidate_and_notify directly, as this function
can update the block device size as well when the last parameter is set
to true.
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
drivers/block/loop.c | 37 +++++++------------------------------
1 file changed, 7 insertions(+), 30 deletions(-)
From: Christoph Hellwig <hch@lst.de> Date: 2020-11-11 08:29:37
__invalidate_device without the kill_dirty parameter just invalidates
various clean entries in caches, which doesn't really help us with
anything, but can cause all kinds of horrible lock orders due to how
it calls into the file system. The only reason this hasn't been a
major issue is because so many people use partitions, for which no
invalidation was performed anyway.
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
fs/block_dev.c | 6 ------
1 file changed, 6 deletions(-)
From: Christoph Hellwig <hch@lst.de> Date: 2020-11-11 08:29:56
Block driver have no business setting the file system concept of a
block size.
Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Josef Bacik <josef@toxicpanda.com>
---
drivers/block/nbd.c | 12 +++++-------
1 file changed, 5 insertions(+), 7 deletions(-)
On Wed, Nov 11, 2020 at 9:27 AM Christoph Hellwig [off-list ref] wrote:
quoted hunk
Use set_capacity_and_notify to set the size of both the disk and block
device. This also gets the uevent notifications for the resize for free.
Signed-off-by: Christoph Hellwig <hch@lst.de>
Acked-by: Jack Wang <jinpu.wang@cloud.ionos.com>
---
drivers/block/rbd.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
From: Jinpu Wang <jinpu.wang@cloud.ionos.com> Date: 2020-11-11 10:07:04
On Wed, Nov 11, 2020 at 10:55 AM Ilya Dryomov [off-list ref] wrote:
On Wed, Nov 11, 2020 at 9:27 AM Christoph Hellwig [off-list ref] wrote:
quoted
Use set_capacity_and_notify to set the size of both the disk and block
device. This also gets the uevent notifications for the resize for free.
Signed-off-by: Christoph Hellwig <hch@lst.de>
Acked-by: Jack Wang <jinpu.wang@cloud.ionos.com>
---
drivers/block/rbd.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
From: Hannes Reinecke <hare@suse.de> Date: 2020-11-11 12:46:33
On 11/11/20 9:26 AM, Christoph Hellwig wrote:
__invalidate_device without the kill_dirty parameter just invalidates
various clean entries in caches, which doesn't really help us with
anything, but can cause all kinds of horrible lock orders due to how
it calls into the file system. The only reason this hasn't been a
major issue is because so many people use partitions, for which no
invalidation was performed anyway.
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
fs/block_dev.c | 6 ------
1 file changed, 6 deletions(-)
Reviewed-by: Hannes Reinecke <hare@suse.de>
Cheers,
Hannes
--
Dr. Hannes Reinecke Kernel Storage Architect
hare@suse.de +49 911 74053 688
SUSE Software Solutions GmbH, Maxfeldstr. 5, 90409 Nürnberg
HRB 36809 (AG Nürnberg), Geschäftsführer: Felix Imendörffer
From: Hannes Reinecke <hare@suse.de> Date: 2020-11-11 12:47:26
On 11/11/20 9:26 AM, Christoph Hellwig wrote:
Just use set_capacity_revalidate_and_notify directly, as this function
can update the block device size as well when the last parameter is set
to true.
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
drivers/block/loop.c | 37 +++++++------------------------------
1 file changed, 7 insertions(+), 30 deletions(-)
Reviewed-by: Hannes Reinecke <hare@suse.de>
Cheers,
Hannes
--
Dr. Hannes Reinecke Kernel Storage Architect
hare@suse.de +49 911 74053 688
SUSE Software Solutions GmbH, Maxfeldstr. 5, 90409 Nürnberg
HRB 36809 (AG Nürnberg), Geschäftsführer: Felix Imendörffer
From: Hannes Reinecke <hare@suse.de> Date: 2020-11-11 13:06:18
On 11/11/20 9:26 AM, Christoph Hellwig wrote:
There is no good reason to call revalidate_disk_size separately.
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
drivers/nvme/host/core.c | 5 +----
1 file changed, 1 insertion(+), 4 deletions(-)
Reviewed-by: Hannes Reinecke <hare@suse.de>
Cheers,
Hannes
--
Dr. Hannes Reinecke Kernel Storage Architect
hare@suse.de +49 911 74053 688
SUSE Software Solutions GmbH, Maxfeldstr. 5, 90409 Nürnberg
HRB 36809 (AG Nürnberg), Geschäftsführer: Felix Imendörffer
From: Hannes Reinecke <hare@suse.de> Date: 2020-11-11 13:07:18
On 11/11/20 9:26 AM, Christoph Hellwig wrote:
This avoids the extra call to revalidate_disk_size in sd_rescan and
is otherwise a no-op because the size did not change, or we are in
the probe path.
Signed-off-by: Christoph Hellwig <hch@lst.de>
Acked-by: Martin K. Petersen <martin.petersen@oracle.com>
---
drivers/scsi/sd.c | 8 +++-----
1 file changed, 3 insertions(+), 5 deletions(-)
Reviewed-by: Hannes Reinecke <hare@suse.de>
Cheers.
Hannes
--
Dr. Hannes Reinecke Kernel Storage Architect
hare@suse.de +49 911 74053 688
SUSE Software Solutions GmbH, Maxfeldstr. 5, 90409 Nürnberg
HRB 36809 (AG Nürnberg), Geschäftsführer: Felix Imendörffer
From: Hannes Reinecke <hare@suse.de> Date: 2020-11-11 13:07:52
On 11/11/20 9:26 AM, Christoph Hellwig wrote:
The update_bdev argument is always set to true, so remove it. Also
rename the function to the slighly less verbose set_capacity_and_notify,
as propagating the disk size to the block device isn't really
revalidation.
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
block/genhd.c | 13 +++++--------
drivers/block/loop.c | 11 +++++------
drivers/block/virtio_blk.c | 2 +-
drivers/block/xen-blkfront.c | 2 +-
drivers/nvme/host/core.c | 2 +-
drivers/scsi/sd.c | 5 ++---
include/linux/genhd.h | 3 +--
7 files changed, 16 insertions(+), 22 deletions(-)
Reviewed-by: Hannes Reinecke <hare@suse.de>
Cheers,
Hannes
--
Dr. Hannes Reinecke Kernel Storage Architect
hare@suse.de +49 911 74053 688
SUSE Software Solutions GmbH, Maxfeldstr. 5, 90409 Nürnberg
HRB 36809 (AG Nürnberg), Geschäftsführer: Felix Imendörffer
From: Hannes Reinecke <hare@suse.de> Date: 2020-11-11 13:08:23
On 11/11/20 9:26 AM, Christoph Hellwig wrote:
Return if the function ended up sending an uevent or not.
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
block/genhd.c | 7 +++++--
include/linux/genhd.h | 2 +-
2 files changed, 6 insertions(+), 3 deletions(-)
Reviewed-by: Hannes Reinecke <hare@suse.de>
Cheers,
Hannes
--
Dr. Hannes Reinecke Kernel Storage Architect
hare@suse.de +49 911 74053 688
SUSE Software Solutions GmbH, Maxfeldstr. 5, 90409 Nürnberg
HRB 36809 (AG Nürnberg), Geschäftsführer: Felix Imendörffer
From: Hannes Reinecke <hare@suse.de> Date: 2020-11-11 13:57:56
On 11/11/20 9:26 AM, Christoph Hellwig wrote:
Use set_capacity_and_notify to set the size of both the disk and block
device. This also gets the uevent notifications for the resize for free.
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
drivers/md/dm.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
Reviewed-by: Hannes Reinecke <hare@suse.de>
Cheers,
Hannes
--
Dr. Hannes Reinecke Kernel Storage Architect
hare@suse.de +49 911 74053 688
SUSE Software Solutions GmbH, Maxfeldstr. 5, 90409 Nürnberg
HRB 36809 (AG Nürnberg), Geschäftsführer: Felix Imendörffer
From: Hannes Reinecke <hare@suse.de> Date: 2020-11-11 14:00:12
On 11/11/20 9:26 AM, Christoph Hellwig wrote:
Use the block layer helper to update both the disk and block device
sizes. Contrary to the name no notification is sent in this case,
as a size 0 is special cased.
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
drivers/nvme/host/core.c | 13 +------------
1 file changed, 1 insertion(+), 12 deletions(-)
Reviewed-by: Hannes Reinecke <hare@suse.de>
Cheers,
Hannes
--
Dr. Hannes Reinecke Kernel Storage Architect
hare@suse.de +49 911 74053 688
SUSE Software Solutions GmbH, Maxfeldstr. 5, 90409 Nürnberg
HRB 36809 (AG Nürnberg), Geschäftsführer: Felix Imendörffer
From: Hannes Reinecke <hare@suse.de> Date: 2020-11-11 14:01:57
On 11/11/20 9:26 AM, Christoph Hellwig wrote:
Use set_capacity_and_notify to set the size of both the disk and block
device. This also gets the uevent notifications for the resize for free.
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
drivers/md/dm-raid.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
Reviewed-by: Hannes Reinecke <hare@suse.de>
Cheers,
Hannes
--
Dr. Hannes Reinecke Kernel Storage Architect
hare@suse.de +49 911 74053 688
SUSE Software Solutions GmbH, Maxfeldstr. 5, 90409 Nürnberg
HRB 36809 (AG Nürnberg), Geschäftsführer: Felix Imendörffer
From: Petr Vorel <pvorel@suse.cz> Date: 2020-11-12 19:22:30
Hi Christoph,
The update_bdev argument is always set to true, so remove it. Also
rename the function to the slighly less verbose set_capacity_and_notify,
as propagating the disk size to the block device isn't really
revalidation.
Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Petr Vorel <pvorel@suse.cz>
Nice cleanup.
Kind regards,
Petr