[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <ZICzXbJeLj56NRYB@itl-email>
Date: Wed, 7 Jun 2023 12:42:00 -0400
From: Demi Marie Obenour <demi@...isiblethingslab.com>
To: Christoph Hellwig <hch@...radead.org>
Cc: Jens Axboe <axboe@...nel.dk>, linux-block@...r.kernel.org,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH] block, loop: Increment diskseq when releasing a loop
device
On Wed, Jun 07, 2023 at 11:23:00AM -0400, Demi Marie Obenour wrote:
> > > --- a/drivers/block/loop.c
> > > +++ b/drivers/block/loop.c
> > > @@ -1205,6 +1205,12 @@ static void __loop_clr_fd(struct loop_device *lo, bool release)
> > > if (!part_shift)
> > > set_bit(GD_SUPPRESS_PART_SCAN, &lo->lo_disk->state);
> > > mutex_lock(&lo->lo_mutex);
> > > +
> > > + /*
> > > + * Increment the disk sequence number, so that userspace knows this
> > > + * device now points to something else.
> > > + */
> > > + inc_diskseq(lo->lo_disk);
> >
> > And I'm not sure why we even need this. __loop_clr_fd
> > already calls disk_force_media_change, which calls inc_diskseq.
> > Why do we need an extra increment?
>
> How does disk_force_media_change() call inc_diskseq()? I don’t see any
> calls in the source code. I’m going to use systemtap to see if there is
> an indirect call chain.
Were you thinking of bdev_check_media_change()? That can call
inc_diskseq() via this call chain:
bdev_check_media_change()
disk_clear_events()
disk_check_events()
inc_diskseq()
disk_force_media_change() does not call inc_diskseq(), and I checked
that calling losetup -D does not change the diskseq of a loop device.
From what you have writte, I’m pretty sure that’s a bug in
disk_force_media_change(), though. I’ll send a v3 that adds this call.
--
Sincerely,
Demi Marie Obenour (she/her/hers)
Invisible Things Lab
Download attachment "signature.asc" of type "application/pgp-signature" (834 bytes)
Powered by blists - more mailing lists