From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49147) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WguxG-0002vv-B6 for qemu-devel@nongnu.org; Sun, 04 May 2014 07:51:44 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WguxA-0007Yi-5j for qemu-devel@nongnu.org; Sun, 04 May 2014 07:51:38 -0400 Received: from mx1.redhat.com ([209.132.183.28]:7986) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Wgux9-0007Y7-TW for qemu-devel@nongnu.org; Sun, 04 May 2014 07:51:32 -0400 Date: Sun, 4 May 2014 19:51:40 +0800 From: Fam Zheng Message-ID: <20140504115140.GI1124@T430.nay.redhat.com> References: <1398956086-20171-1-git-send-email-stefanha@redhat.com> <1398956086-20171-20-git-send-email-stefanha@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1398956086-20171-20-git-send-email-stefanha@redhat.com> Subject: Re: [Qemu-devel] [PATCH 19/22] dataplane: use the QEMU block layer for I/O List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Stefan Hajnoczi Cc: Kevin Wolf , Paolo Bonzini , "Shergill, Gurinder" , "Vinod, Chegu" , qemu-devel@nongnu.org On Thu, 05/01 16:54, Stefan Hajnoczi wrote: > @@ -152,51 +132,53 @@ static void do_get_id_cmd(VirtIOBlockDataPlane *s, > complete_request_early(s, elem, inhdr, VIRTIO_BLK_S_OK); > } > > -static int do_rdwr_cmd(VirtIOBlockDataPlane *s, bool read, > - struct iovec *iov, unsigned iov_cnt, > - long long offset, VirtQueueElement *elem, > - QEMUIOVector *inhdr) > +static void do_rdwr_cmd(VirtIOBlockDataPlane *s, bool read, > + struct iovec *iov, unsigned iov_cnt, > + int64_t sector_num, VirtQueueElement *elem, > + QEMUIOVector *inhdr) > { > - struct iocb *iocb; > - QEMUIOVector qiov; > - struct iovec *bounce_iov = NULL; > - QEMUIOVector *read_qiov = NULL; > - > - qemu_iovec_init_external(&qiov, iov, iov_cnt); > - if (!bdrv_qiov_is_aligned(s->blk->conf.bs, &qiov)) { > - void *bounce_buffer = qemu_blockalign(s->blk->conf.bs, qiov.size); > - > - if (read) { > - /* Need to copy back from bounce buffer on completion */ > - read_qiov = g_slice_new(QEMUIOVector); > - qemu_iovec_init(read_qiov, iov_cnt); > - qemu_iovec_concat_iov(read_qiov, iov, iov_cnt, 0, qiov.size); > - } else { > - qemu_iovec_to_buf(&qiov, 0, bounce_buffer, qiov.size); > + VirtIOBlockRequest *req = g_slice_new(VirtIOBlockRequest); Could be g_slice_new0, > + QEMUIOVector *qiov; > + int nb_sectors; > + > + /* Fill in virtio block metadata needed for completion */ > + memset(req, 0, sizeof(*req)); so this memset is not needed. > + req->s = s; > + req->elem = elem; > + req->inhdr = inhdr; > + req->read = read; > + qemu_iovec_init_external(&req->qiov, iov, iov_cnt); > + > + qiov = &req->qiov; > + > + if (!bdrv_qiov_is_aligned(s->blk->conf.bs, qiov)) { > + void *bounce_buffer = qemu_blockalign(s->blk->conf.bs, qiov->size); > + > + /* Populate bounce buffer with data for writes */ > + if (!read) { > + qemu_iovec_to_buf(qiov, 0, bounce_buffer, qiov->size); > } > Fam