From: Konrad Rzeszutek Wilk Subject: Re: [PATCH RFC 1/3] xen_disk: handle disk files on ramfs/tmpfs Date: Thu, 3 Jan 2013 09:21:30 -0500 Message-ID: <20130103142129.GA6690@localhost.localdomain> References: <1356956174-23548-1-git-send-email-roger.pau@citrix.com> <1356956174-23548-2-git-send-email-roger.pau@citrix.com> Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Return-path: Content-Disposition: inline In-Reply-To: <1356956174-23548-2-git-send-email-roger.pau@citrix.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Roger Pau Monne Cc: Anthony PERARD , Stefano Stabellini , qemu-devel@nongnu.org, xen-devel@lists.xen.org List-Id: xen-devel@lists.xenproject.org On Mon, Dec 31, 2012 at 01:16:12PM +0100, Roger Pau Monne wrote: > Files that reside on ramfs or tmpfs cannot be opened with O_DIRECT, That is not entirely true. There are patches floating around (LKML) to make tmpfs/ramfs be able to do this. > if first call to bdrv_open fails with errno =3D EINVAL, try a second > call without BDRV_O_NOCACHE. > = > Signed-off-by: Roger Pau Monn=E9 > 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 =3D container_of(xendev, struct XenBlkDev, = xendev); > - int index, qflags, info =3D 0; > + int index, qflags, info =3D 0, rc; > = > /* read xenstore entries */ > if (blkdev->params =3D=3D 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 =3D bdrv_new(blkdev->dev); > if (blkdev->bs) { > - if (bdrv_open(blkdev->bs, blkdev->filename, qflags, > - bdrv_find_whitelisted_format(blkdev->fileproto))= !=3D 0) { > + rc =3D bdrv_open(blkdev->bs, blkdev->filename, qflags, > + bdrv_find_whitelisted_format(blkdev->fileproto)); > + if (rc !=3D 0 && errno =3D=3D EINVAL) { > + /* Files on ramfs or tmpfs cannot be opened with O_DIREC= T, > + * remove the BDRV_O_NOCACHE flag, and try to open > + * the file again. > + */ > + qflags &=3D ~BDRV_O_NOCACHE; > + rc =3D bdrv_open(blkdev->bs, blkdev->filename, qflags, > + bdrv_find_whitelisted_format(blkdev->fileproto)); > + } > + if (rc !=3D 0) { > bdrv_delete(blkdev->bs); > blkdev->bs =3D NULL; > } > -- = > 1.7.7.5 (Apple Git-26) > = > = > _______________________________________________ > Xen-devel mailing list > Xen-devel@lists.xen.org > http://lists.xen.org/xen-devel > =