Received: from eggs.gnu.org ([208.118.235.92]:46841) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Tqln5-0002T5-LS for qemu-devel@nongnu.org; Thu, 03 Jan 2013 09:29:07 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Tqln2-0007iu-K4 for qemu-devel@nongnu.org; Thu, 03 Jan 2013 09:29:03 -0500 Received: from smtp.eu.citrix.com ([46.33.159.39]:43629) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Tqln2-0007if-ES for qemu-devel@nongnu.org; Thu, 03 Jan 2013 09:29:00 -0500 Message-ID: <1357223336.10985.132.camel@zakaz.uk.xensource.com> From: Ian Campbell Date: Thu, 3 Jan 2013 14:28:56 +0000 In-Reply-To: <1356956174-23548-2-git-send-email-roger.pau@citrix.com> References: <1356956174-23548-1-git-send-email-roger.pau@citrix.com> <1356956174-23548-2-git-send-email-roger.pau@citrix.com> Content-Type: text/plain; charset="UTF-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: Re: [Qemu-devel] [Xen-devel] [PATCH RFC 1/3] xen_disk: handle disk files on ramfs/tmpfs List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Roger Pau Monne Cc: Anthony Perard , Stefano Stabellini , "qemu-devel@nongnu.org" , "xen-devel@lists.xen.org" On Mon, 2012-12-31 at 12:16 +0000, Roger Pau Monne wrote: > Files that reside on ramfs or tmpfs cannot be opened with O_DIRECT, > if first call to bdrv_open fails with errno = EINVAL, try a second > call without BDRV_O_NOCACHE. Doesn't that risk spuriously turning of NOCACHE on other sorts of devices as well which (potentially) opens up a data loss issue? > Signed-off-by: Roger Pau Monné > Cc: xen-devel@lists.xen.org > Cc: Stefano Stabellini > Cc: Anthony PERARD > --- > hw/xen_disk.c | 16 +++++++++++++--- > 1 files changed, 13 insertions(+), 3 deletions(-) > > diff --git a/hw/xen_disk.c b/hw/xen_disk.c > index e6bb2f2..a159ee5 100644 > --- a/hw/xen_disk.c > +++ b/hw/xen_disk.c > @@ -562,7 +562,7 @@ static void blk_alloc(struct XenDevice *xendev) > static int blk_init(struct XenDevice *xendev) > { > struct XenBlkDev *blkdev = container_of(xendev, struct XenBlkDev, xendev); > - int index, qflags, info = 0; > + int index, qflags, info = 0, rc; > > /* read xenstore entries */ > if (blkdev->params == NULL) { > @@ -625,8 +625,18 @@ static int blk_init(struct XenDevice *xendev) > xen_be_printf(&blkdev->xendev, 2, "create new bdrv (xenbus setup)\n"); > blkdev->bs = bdrv_new(blkdev->dev); > if (blkdev->bs) { > - if (bdrv_open(blkdev->bs, blkdev->filename, qflags, > - bdrv_find_whitelisted_format(blkdev->fileproto)) != 0) { > + rc = bdrv_open(blkdev->bs, blkdev->filename, qflags, > + bdrv_find_whitelisted_format(blkdev->fileproto)); > + if (rc != 0 && errno == EINVAL) { > + /* Files on ramfs or tmpfs cannot be opened with O_DIRECT, > + * remove the BDRV_O_NOCACHE flag, and try to open > + * the file again. > + */ > + qflags &= ~BDRV_O_NOCACHE; > + rc = bdrv_open(blkdev->bs, blkdev->filename, qflags, > + bdrv_find_whitelisted_format(blkdev->fileproto)); > + } > + if (rc != 0) { > bdrv_delete(blkdev->bs); > blkdev->bs = NULL; > }