From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from [140.186.70.92] (port=55957 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Q71o1-0001CF-Kk for qemu-devel@nongnu.org; Tue, 05 Apr 2011 04:40:10 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Q71nz-0000e4-Ct for qemu-devel@nongnu.org; Tue, 05 Apr 2011 04:40:09 -0400 Received: from mail-gy0-f173.google.com ([209.85.160.173]:38724) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Q71nz-0000dx-4q for qemu-devel@nongnu.org; Tue, 05 Apr 2011 04:40:07 -0400 Received: by gyg4 with SMTP id 4so60039gyg.4 for ; Tue, 05 Apr 2011 01:40:06 -0700 (PDT) MIME-Version: 1.0 In-Reply-To: <20110405064120.GB2872@amit-x200.redhat.com> References: <1301425482-8722-1-git-send-email-stefanha@linux.vnet.ibm.com> <1301425482-8722-4-git-send-email-stefanha@linux.vnet.ibm.com> <4D99C61E.3080600@redhat.com> <4D99C9ED.3020602@codemonkey.ws> <4D99CC74.9070703@redhat.com> <20110405064120.GB2872@amit-x200.redhat.com> Date: Tue, 5 Apr 2011 09:40:05 +0100 Message-ID: Subject: Re: [Qemu-devel] [PATCH v2 3/3] raw-posix: Re-open host CD-ROM after media change From: Stefan Hajnoczi Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Amit Shah Cc: Kevin Wolf , Stefan Hajnoczi , Juan Quintela , libvir-list@redhat.com, qemu-devel@nongnu.org, Ryan Harper , Avi Kivity On Tue, Apr 5, 2011 at 7:41 AM, Amit Shah wrote: > On (Mon) 04 Apr 2011 [16:09:05], Stefan Hajnoczi wrote: >> On Mon, Apr 4, 2011 at 2:49 PM, Avi Kivity wrote: >> > On 04/04/2011 04:38 PM, Anthony Liguori wrote: >> >> >> >> On 04/04/2011 08:22 AM, Avi Kivity wrote: >> >>> >> >>> On 04/03/2011 02:57 PM, Stefan Hajnoczi wrote: >> >>>> >> >>>> In order for media change to work with Linux host CD-ROM it is >> >>>> necessary to reopen the file (otherwise the inode size will not >> >>>> refresh, this is an issue with existing kernels). >> >>>> >> >>> >> >>> Maybe we should fix the bug in Linux (and backport as necessary)? >> >>> >> >>> I think cd-rom assignment is sufficiently obscure that we can requir= e a >> >>> fixed kernel instead of providing a workaround. >> >> >> >> Do reads fail after CD change? =A0Or do they succeed and the size is = just >> >> reported incorrectly? >> >> >> >> If it's the later, I'd agree that it needs fixing in the kernel. =A0I= f it's >> >> the former, I'd say it's clearly a feature. >> >> >> > >> > Even if it's a documented or intentional feature, we can add an ioctl = to >> > "refresh" the device with up-to-date data. >> >> It's possible to fix this in the kernel. =A0I just haven't written the >> patch yet. =A0The inode size needs to be updated when the new medium is >> detected. >> >> I haven't tested but I suspect reads within the size of the previous >> medium will succeed. =A0But if the new medium is larger then reads >> beyond the old medium size will fail. > > See http://www.spinics.net/lists/linux-scsi/msg51504.html I don't think that patch updates the block inode size. We'd need to call fs/block_dev.c:revalidate_disk() instead of directly calling cdi->disk->fops->revalidate_disk(cdi->disk). fs/block_dev.c:revalidate_disk() calls check_disk_size_change(), which will update the inode size. Here are the steps to reproduce the issue: https://lkml.org/lkml/2011/3/23/= 156 Stefan