From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:32797) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Uwr6M-0001Bz-B2 for qemu-devel@nongnu.org; Wed, 10 Jul 2013 05:54:26 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Uwr6G-0008Cy-Mg for qemu-devel@nongnu.org; Wed, 10 Jul 2013 05:54:22 -0400 Received: from mx1.redhat.com ([209.132.183.28]:3803) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Uwr6G-0008CM-EK for qemu-devel@nongnu.org; Wed, 10 Jul 2013 05:54:16 -0400 Date: Wed, 10 Jul 2013 11:54:08 +0200 From: Kevin Wolf Message-ID: <20130710095407.GF3898@dhcp-200-207.str.redhat.com> References: <1372338695-411-1-git-send-email-pl@kamp.de> <1372338695-411-5-git-send-email-pl@kamp.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1372338695-411-5-git-send-email-pl@kamp.de> Subject: Re: [Qemu-devel] [PATCHv2 04/11] iscsi: add bdrv_co_write_zeroes List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Peter Lieven Cc: pbonzini@redhat.com, ronniesahlberg@gmail.com, qemu-devel@nongnu.org, stefanha@redhat.com Am 27.06.2013 um 15:11 hat Peter Lieven geschrieben: > write zeroes is emulated by unmap if the target supports unmapping > an unmapped blocks read as zero. this emulation is only done if the > device was opened with BDRV_O_UNMAP and the request can be handled > within a single request. a failback to writev is performed otherwise. > > Signed-off-by: Peter Lieven > --- > block/iscsi.c | 44 ++++++++++++++++++++++++++++++++++++++++++++ > 1 file changed, 44 insertions(+) > > diff --git a/block/iscsi.c b/block/iscsi.c > index d31ee95..92e66a6 100644 > --- a/block/iscsi.c > +++ b/block/iscsi.c > @@ -928,6 +928,49 @@ fail: > return 0; > } > > +static int > +coroutine_fn iscsi_co_write_zeroes(BlockDriverState *bs, int64_t sector_num, > + int nb_sectors) > +{ > + IscsiLun *iscsilun = bs->opaque; > + struct IscsiTask iTask; > + struct unmap_list list[1]; Why declare an array when it's only one element anyway? > + if (!iscsilun->lbprz || !iscsilun->lbpu || !(bs->open_flags & BDRV_O_UNMAP) || > + nb_sectors * BDRV_SECTOR_SIZE / iscsilun->block_size > iscsilun->max_unmap) { The first part of this line is sector_qemu2lun(). > + /* fall back to writev */ > + return -ENOTSUP; > + } > + > + iscsi_co_init_iscsitask(iscsilun, &iTask); > + > + list[0].lba = sector_qemu2lun(sector_num, iscsilun); > + list[0].num = nb_sectors * BDRV_SECTOR_SIZE / iscsilun->block_size; Same here. Kevin