From: Samuel Thibault Subject: Re: [PATCH 2/12] VTPM mini-os: posix IO layer for blkfront in mini-os Date: Mon, 14 Mar 2011 20:29:45 +0100 Message-ID: <20110314192945.GG4370@const.famille.thibault.fr> References: <4D7AA372.4040506@jhuapl.edu> <20110312010526.GK4922@const.famille.thibault.fr> <4D7E6772.2040606@jhuapl.edu> 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: <4D7E6772.2040606@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 Mon 14 Mar 2011 15:07:30 -0400, a =E9crit : > On 03/11/2011 08:05 PM, Samuel Thibault wrote: > >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_RD= WR) { > >O_WRONLY too. > Good catch, actually testing a bitfield with !=3D is a bad idea to begi= n=20 > with anyway. Err, it's not a bitfield, in mini-os it's a {0,1,2} enum. > >Could you perhaps optimize when buf is actually aligned? That would > >save a copy. > > > This can be done but only if in the current iteration of the loop an=20 > entire block is being read. Sure. > Since aiocb only operates on sectors it'll=20 > read at minimum a whole sector into buf. If buf isnt big enough to hold= =20 > the data a secondary buffer with a copy operation will have to be done. Sure. But I expect people using that interface to tend to allocate big aligned buffers. > >>+ /* Write operation */ > >>+ else { > >>+ /* If we're writing a partial block, we need to read the current=20 > >>contents 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. > > > It could, but then that changes the design of aiocb. Was it supposed to= =20 > be a very low level interface for just reading and writing blocks onto=20 > the disk? Well, I'd say the whole blkfront itself is a low-level interrface, and your patch actually provides a higher one :) This particular change in the design shouldn't break anything, since aio_cb is actually filled by blkfront itself, so it makes sense that it cleans it since it expects it to be cleaned. > Right now you have to set aio_nbytes and aio_offset to a multiple of=20 > sector size. This could be changed to allow variable sizes.=20 > Alternatively 2 new fields could be added to specify which portion=20 > inside a block to operate on. >=20 > Can you send a partial block through the xen block frontend and backend= =20 > interface? No. > If not we would have to queue up a read and then a write=20 > internally when the user requests a write. Its possible some users may=20 > not want this forced behavior of 2 operations. That's why I wouldn't recommend aio_nbytes/offset to be allowed to be non-multiples of the sector size. That interface is meant to be an efficient sector-transfer interface. Your posix layer can handle flexibility for the user. Samuel