diff mbox series

[resend,v1,4/5] drivers/nvme/host/core.c: Convert to use disk_set_capacity

Message ID 20200102075315.22652-5-sblbir@amazon.com (mailing list archive)
State New, archived
Headers show
Series Add support for block disk resize notification | expand

Commit Message

Singh, Balbir Jan. 2, 2020, 7:53 a.m. UTC
block/genhd provides disk_set_capacity() for sending
RESIZE notifications via uevents. This notification is
newly added to NVME devices

Signed-off-by: Balbir Singh <sblbir@amazon.com>
---
 drivers/nvme/host/core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Chaitanya Kulkarni Jan. 4, 2020, 10:27 p.m. UTC | #1
Quick question here if user executes nvme ns-rescan /dev/nvme1
will following code result in triggering uevent(s) for
the namespace(s( for which there is no change in the size ?

If so is that an expected behavior ?

On 01/01/2020 11:54 PM, Balbir Singh wrote:
> block/genhd provides disk_set_capacity() for sending
> RESIZE notifications via uevents. This notification is
> newly added to NVME devices
>
> Signed-off-by: Balbir Singh <sblbir@amazon.com>
> ---
>   drivers/nvme/host/core.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
> index 667f18f465be..cb214e914fc2 100644
> --- a/drivers/nvme/host/core.c
> +++ b/drivers/nvme/host/core.c
> @@ -1808,7 +1808,7 @@ static void nvme_update_disk_info(struct gendisk *disk,
>   	    ns->lba_shift > PAGE_SHIFT)
>   		capacity = 0;
>
> -	set_capacity(disk, capacity);
> +	disk_set_capacity(disk, capacity);
>
>   	nvme_config_discard(disk, ns);
>   	nvme_config_write_zeroes(disk, ns);
>
Singh, Balbir Jan. 6, 2020, 12:46 a.m. UTC | #2
On Sat, 2020-01-04 at 22:27 +0000, Chaitanya Kulkarni wrote:
> Quick question here if user executes nvme ns-rescan /dev/nvme1
> will following code result in triggering uevent(s) for
> the namespace(s( for which there is no change in the size ?
> 
> If so is that an expected behavior ?
> 

My old code had a check to see if old_capacity != new_capacity as well.
I can redo those bits if needed.

The expected behaviour is not clear, but the functionality is not broken, user
space should be able to deal with a resize event where the previous capacity
== new capacity IMHO.

Balbir Singh.


> On 01/01/2020 11:54 PM, Balbir Singh wrote:
> > block/genhd provides disk_set_capacity() for sending
> > RESIZE notifications via uevents. This notification is
> > newly added to NVME devices
> > 
> > Signed-off-by: Balbir Singh <sblbir@amazon.com>
> > ---
> >   drivers/nvme/host/core.c | 2 +-
> >   1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
> > index 667f18f465be..cb214e914fc2 100644
> > --- a/drivers/nvme/host/core.c
> > +++ b/drivers/nvme/host/core.c
> > @@ -1808,7 +1808,7 @@ static void nvme_update_disk_info(struct gendisk
> > *disk,
> >   	    ns->lba_shift > PAGE_SHIFT)
> >   		capacity = 0;
> > 
> > -	set_capacity(disk, capacity);
> > +	disk_set_capacity(disk, capacity);


> > 
> >   	nvme_config_discard(disk, ns);
> >   	nvme_config_write_zeroes(disk, ns);
> > 
> 
>
Christoph Hellwig Jan. 8, 2020, 3:04 p.m. UTC | #3
On Mon, Jan 06, 2020 at 12:46:26AM +0000, Singh, Balbir wrote:
> On Sat, 2020-01-04 at 22:27 +0000, Chaitanya Kulkarni wrote:
> > Quick question here if user executes nvme ns-rescan /dev/nvme1
> > will following code result in triggering uevent(s) for
> > the namespace(s( for which there is no change in the size ?
> > 
> > If so is that an expected behavior ?
> > 
> 
> My old code had a check to see if old_capacity != new_capacity as well.
> I can redo those bits if needed.
> 
> The expected behaviour is not clear, but the functionality is not broken, user
> space should be able to deal with a resize event where the previous capacity
> == new capacity IMHO.

I think it makes sense to not bother with a notification unless there
is an actual change.
Martin K. Petersen Jan. 9, 2020, 3:33 a.m. UTC | #4
Christoph,

>> The expected behaviour is not clear, but the functionality is not
>> broken, user space should be able to deal with a resize event where
>> the previous capacity == new capacity IMHO.
>
> I think it makes sense to not bother with a notification unless there
> is an actual change.

I agree.
Ewan Milne Jan. 9, 2020, 1:12 p.m. UTC | #5
On Wed, 2020-01-08 at 22:33 -0500, Martin K. Petersen wrote:
> Christoph,
> 
> > > The expected behaviour is not clear, but the functionality is not
> > > broken, user space should be able to deal with a resize event where
> > > the previous capacity == new capacity IMHO.
> > 
> > I think it makes sense to not bother with a notification unless there
> > is an actual change.
> 
> I agree.
> 

Yes, absolutely.
Singh, Balbir Jan. 21, 2020, 7:52 p.m. UTC | #6
On Wed, 2020-01-08 at 16:04 +0100, hch@lst.de wrote:
> On Mon, Jan 06, 2020 at 12:46:26AM +0000, Singh, Balbir wrote:
> > On Sat, 2020-01-04 at 22:27 +0000, Chaitanya Kulkarni wrote:
> > > Quick question here if user executes nvme ns-rescan /dev/nvme1
> > > will following code result in triggering uevent(s) for
> > > the namespace(s( for which there is no change in the size ?
> > > 
> > > If so is that an expected behavior ?
> > > 
> > 
> > My old code had a check to see if old_capacity != new_capacity as well.
> > I can redo those bits if needed.
> > 
> > The expected behaviour is not clear, but the functionality is not broken,
> > user
> > space should be able to deal with a resize event where the previous
> > capacity
> > == new capacity IMHO.
> 
> I think it makes sense to not bother with a notification unless there
> is an actual change.

[Sorry for the delayed response, just back from LCA]

Agreed!

Balbir Singh
diff mbox series

Patch

diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
index 667f18f465be..cb214e914fc2 100644
--- a/drivers/nvme/host/core.c
+++ b/drivers/nvme/host/core.c
@@ -1808,7 +1808,7 @@  static void nvme_update_disk_info(struct gendisk *disk,
 	    ns->lba_shift > PAGE_SHIFT)
 		capacity = 0;
 
-	set_capacity(disk, capacity);
+	disk_set_capacity(disk, capacity);
 
 	nvme_config_discard(disk, ns);
 	nvme_config_write_zeroes(disk, ns);