From: Samuel Thibault Subject: Re: [PATCH 2/12] VTPM mini-os: posix IO layer for blkfront in mini-os Date: Sat, 12 Mar 2011 02:05:26 +0100 Message-ID: <20110312010526.GK4922@const.famille.thibault.fr> References: <4D7AA372.4040506@jhuapl.edu> Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable Return-path: Resent-Message-ID: <20110312014012.GO4922@const.famille.thibault.fr> Resent-To: xen-devel@lists.xensource.com Content-Disposition: inline In-Reply-To: <4D7AA372.4040506@jhuapl.edu> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: Matthew Fioravante Cc: "xen-devel@lists.xensource.com" List-Id: xen-devel@lists.xenproject.org Matthew Fioravante, le Fri 11 Mar 2011 17:34:26 -0500, a =E9crit : > + /*Make sure we have write permission */ > + if(dev->info.info & VDISK_READONLY || dev->info.mode !=3D O_RDWR= ) { O_WRONLY too. > + aiocb.aio_dev =3D dev; > + aiocb.aio_buf =3D _xmalloc(blocksize, dev->info.sector_size); > + aiocb.aio_nbytes =3D blocksize; > + aiocb.aio_offset =3D blknum * blocksize; > + aiocb.aio_cb =3D NULL; > + aiocb.data =3D NULL; > + > + /* read operation */ > + if(!write) { > + aiocb.aio_cb =3D NULL; > + blkfront_read(&aiocb); > + memcpy(buf, &aiocb.aio_buf[blkoff], bytes); > + }=20 Could you perhaps optimize when buf is actually aligned? That would save a copy. > + /* Write operation */ > + else { > + /* If we're writing a partial block, we need to read the current con= tents first > + * so we don't overwrite the extra bits with garbage */ > + if(blkoff !=3D 0 || bytes < blocksize) { > + aiocb.aio_cb =3D NULL; Maybe blkfront_aio_cb should do it itself? It looks odd to have to do it when reusing an aiocb structure. Apart from that it looks good. Samuel