diff mbox series

[12/78] dm: use set_capacity_and_notify

Message ID 20201116145809.410558-13-hch@lst.de
State New
Headers show
Series [01/78] block: remove the call to __invalidate_device in check_disk_size_change | expand

Commit Message

Christoph Hellwig Nov. 16, 2020, 2:57 p.m. UTC
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>
Reviewed-by: Hannes Reinecke <hare@suse.de>
---
 drivers/md/dm.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

Comments

Mike Snitzer Feb. 12, 2021, 3:45 p.m. UTC | #1
On Mon, Nov 16, 2020 at 10:05 AM Christoph Hellwig <hch@lst.de> 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>

> Reviewed-by: Hannes Reinecke <hare@suse.de>

> ---

>  drivers/md/dm.c | 3 +--

>  1 file changed, 1 insertion(+), 2 deletions(-)

>

> diff --git a/drivers/md/dm.c b/drivers/md/dm.c

> index c18fc25485186d..62ad44925e73ec 100644

> --- a/drivers/md/dm.c

> +++ b/drivers/md/dm.c

> @@ -1971,8 +1971,7 @@ static struct dm_table *__bind(struct mapped_device *md, struct dm_table *t,

>         if (size != dm_get_size(md))

>                 memset(&md->geometry, 0, sizeof(md->geometry));

>

> -       set_capacity(md->disk, size);

> -       bd_set_nr_sectors(md->bdev, size);

> +       set_capacity_and_notify(md->disk, size);

>

>         dm_table_event_callback(t, event_callback, md);

>


Not yet pinned down _why_ DM is calling set_capacity_and_notify() with
a size of 0 but, when running various DM regression tests, I'm seeing
a lot of noise like:

[  689.240037] dm-2: detected capacity change from 2097152 to 0

Is this pr_info really useful?  Should it be moved to below: if
(!capacity || !size) so that it only prints if a uevent is sent?

Mike
Christoph Hellwig Feb. 16, 2021, 11:46 a.m. UTC | #2
On Fri, Feb 12, 2021 at 10:45:32AM -0500, Mike Snitzer wrote:
> On Mon, Nov 16, 2020 at 10:05 AM Christoph Hellwig <hch@lst.de> 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>

> > Reviewed-by: Hannes Reinecke <hare@suse.de>

> > ---

> >  drivers/md/dm.c | 3 +--

> >  1 file changed, 1 insertion(+), 2 deletions(-)

> >

> > diff --git a/drivers/md/dm.c b/drivers/md/dm.c

> > index c18fc25485186d..62ad44925e73ec 100644

> > --- a/drivers/md/dm.c

> > +++ b/drivers/md/dm.c

> > @@ -1971,8 +1971,7 @@ static struct dm_table *__bind(struct mapped_device *md, struct dm_table *t,

> >         if (size != dm_get_size(md))

> >                 memset(&md->geometry, 0, sizeof(md->geometry));

> >

> > -       set_capacity(md->disk, size);

> > -       bd_set_nr_sectors(md->bdev, size);

> > +       set_capacity_and_notify(md->disk, size);

> >

> >         dm_table_event_callback(t, event_callback, md);

> >

> 

> Not yet pinned down _why_ DM is calling set_capacity_and_notify() with

> a size of 0 but, when running various DM regression tests, I'm seeing

> a lot of noise like:

> 

> [  689.240037] dm-2: detected capacity change from 2097152 to 0

> 

> Is this pr_info really useful?  Should it be moved to below: if

> (!capacity || !size) so that it only prints if a uevent is sent?


In general I suspect such a size change might be interesting to users
if it e.g. comes from a remote event.  So I'd be curious why this happens
with DM, and if we can detect some higher level gendisk state to supress
it if it is indeed spurious.
diff mbox series

Patch

diff --git a/drivers/md/dm.c b/drivers/md/dm.c
index c18fc25485186d..62ad44925e73ec 100644
--- a/drivers/md/dm.c
+++ b/drivers/md/dm.c
@@ -1971,8 +1971,7 @@  static struct dm_table *__bind(struct mapped_device *md, struct dm_table *t,
 	if (size != dm_get_size(md))
 		memset(&md->geometry, 0, sizeof(md->geometry));
 
-	set_capacity(md->disk, size);
-	bd_set_nr_sectors(md->bdev, size);
+	set_capacity_and_notify(md->disk, size);
 
 	dm_table_event_callback(t, event_callback, md);