[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <BANLkTimYBDvcUO9Z2wdk4VFk88NpGJiZJA@mail.gmail.com>
Date: Fri, 8 Apr 2011 17:43:16 +0100
From: Stefan Hajnoczi <stefanha@...il.com>
To: Tejun Heo <tj@...nel.org>
Cc: Amit Shah <amit.shah@...hat.com>, linux-kernel@...r.kernel.org,
Jens Axboe <axboe@...nel.dk>,
"James E.J. Bottomley" <James.Bottomley@...e.de>,
linux-scsi@...r.kernel.org, Markus Armbruster <armbru@...hat.com>
Subject: Re: [PATCH] sr: Ensure disk is revalidated when media changes
On Fri, Apr 8, 2011 at 5:20 PM, Tejun Heo <tj@...nel.org> wrote:
> Hello,
>
> On Fri, Apr 08, 2011 at 12:37:56PM +0100, Stefan Hajnoczi wrote:
>> There is a related issue I have been discussing with Amit:
>> https://lkml.org/lkml/2011/3/23/156
>>
>> On media change the inode size is not updated by the sr driver or the
>> universal cdrom driver. A userspace process that holds a /dev/sr0
>> file descriptor open across media change causes all processes on the
>> system to see the old medium size when they do lseek(fd, 0, SEEK_END).
>>
>> 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.
Stefan
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists