linux-scsi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Amit Shah <amit.shah@redhat.com>
To: Stefan Hajnoczi <stefanha@gmail.com>
Cc: Tejun Heo <tj@kernel.org>,
	linux-kernel@vger.kernel.org, Jens Axboe <axboe@kernel.dk>,
	"James E.J. Bottomley" <James.Bottomley@suse.de>,
	linux-scsi@vger.kernel.org, Markus Armbruster <armbru@redhat.com>
Subject: Re: [PATCH] sr: Ensure disk is revalidated when media changes
Date: Tue, 12 Apr 2011 14:06:13 +0530	[thread overview]
Message-ID: <20110412083613.GI26678@amit-x200.redhat.com> (raw)
In-Reply-To: <BANLkTi=2344xaNM=YjY_GZbyp8yayyM2nA@mail.gmail.com>

On (Tue) 12 Apr 2011 [09:16:41], Stefan Hajnoczi wrote:
> On Tue, Apr 12, 2011 at 5:51 AM, Amit Shah <amit.shah@redhat.com> wrote:
> > On (Fri) 08 Apr 2011 [09:52:07], Tejun Heo wrote:
> >> Hello,
> >>
> >> On Fri, Apr 08, 2011 at 05:43:16PM +0100, Stefan Hajnoczi wrote:
> >> > >> I think it would make sense to refresh the inode size on media change
> >> > >> so that even open file descriptors see the new size and a single
> >> > >> process cannot force a stale value for all other userspace processes
> >> > >> on the system.
> >> > >
> >> > > Hmmm... I don't know.  Maybe we can but I'm not sure whether there's a
> >> > > good reason for it.  cdrom is locked while opened after all.  Are
> >> > > there actual problems?
> >> >
> >> > Yeah, sorry I didn't explain what the use case was.  With QEMU you can
> >> > pass through the physical CD-ROM into the virtual machine.
> >> >
> >> > QEMU opens /dev/cdrom with O_NONBLOCK | O_RDONLY.  The guest can test
> >> > if the medium is present and QEMU will do ioctl(fd,
> >> > CDROM_DRIVE_STATUS, CDSL_CURRENT).  The guest can also lock the tray
> >> > and eject, again using the respective ioctls.  Read operations are
> >> > serviced by performing a read on the file descriptor in QEMU.  And
> >> > finally the medium size is queried by QEMU using lseek(fd, 0,
> >> > SEEK_END).
> >> >
> >> > Today QEMU cannot keep /dev/cdrom open across media change because it
> >> > will have an outdated inode size returned from lseek(fd, 0, SEEK_END).
> >> >  But if the cdrom driver (or sr) refresh the inode size on media
> >> > change then there is no need to work around this from userspace.
> >>
> >> Hmmm... ISTR there was some discussion about changing inode size on
> >> the fly quite a while ago.  I didn't follow the discussion but it
> >> seemed to have rather nasty/delicate implications.
> >
> > I don't necessarily agree with having to modify inode sizes on the
> > fly, but the main bug here is that the inode doesn't get invalidated
> > if a CDROM is ejected while a process has an fd to the CDROM device
> > opened.  So as in the original case, if a CD is swapped with one
> > having more data, lseek continues to report the original media's size
> > in the process that keeps the fd open across eject/insert.
> >
> > I haven't tried this on physical systems, so can't count out it being
> > a qemu bug as well.
> 
> Amit,
> This sounds exactly like the bug that I described and it happens on
> bare metal without virtualization.

Oh OK -- just wanted to get the qemu passthrough out of the equation.

Thanks.

		Amit

  reply	other threads:[~2011-04-12  8:36 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-03-31 18:20 [PATCH] sr: Ensure disk is revalidated when media changes Amit Shah
2011-04-01 15:43 ` Tejun Heo
2011-04-05  6:51   ` Amit Shah
2011-04-06 10:06     ` Tejun Heo
2011-04-06 11:02       ` Amit Shah
2011-04-08 11:37       ` Stefan Hajnoczi
2011-04-08 16:20         ` Tejun Heo
2011-04-08 16:43           ` Stefan Hajnoczi
2011-04-08 16:52             ` Tejun Heo
2011-04-12  4:51               ` Amit Shah
2011-04-12  8:16                 ` Stefan Hajnoczi
2011-04-12  8:36                   ` Amit Shah [this message]
2011-04-05 14:46   ` Amit Shah

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20110412083613.GI26678@amit-x200.redhat.com \
    --to=amit.shah@redhat.com \
    --cc=James.Bottomley@suse.de \
    --cc=armbru@redhat.com \
    --cc=axboe@kernel.dk \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=stefanha@gmail.com \
    --cc=tj@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).