Re: [PATCH 12/78] dm: use set_capacity_and_notify

Christoph Hellwig
2021-02-16T11:46:59Z

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.