Re: [PATCH 3/3] nbd: Use invalidate_gendisk() helper on disconnect
On Mon, Sep 13, 2021 at 09:04:12PM +0800, Yongji Xie wrote:
> On Mon, Sep 13, 2021 at 8:43 PM Christoph Hellwig <hch@infradead.org> wrote:
> >
> > On Mon, Sep 13, 2021 at 07:25:57PM +0800, Xie Yongji wrote:
> > > + invalidate_gendisk(nbd->disk);
> > > + if (nbd->config->bytesize)
> > > + kobject_uevent(&nbd_to_dev(nbd)->kobj, KOBJ_CHANGE);
> >
> > I wonder if the invalidate helper should just use
> > set_capacity_and_notify to take care of the notification in the proper
> > way. This adds an uevent to loop, and adds the RESIZE=1 argument to
> > nbd, but it feels like the right thing to do.
>
> Looks like set_capacity_and_notify() would not do notification if we
> set capacity to zero.
True.
> How about calling kobject_uevent() directly in
> the helper?
That's probably and improvement over letting the driver do it, so let's
go with that for now instead of adding ever more work to your plate.
Reply to: