From nobody Thu Nov 6 19:39:03 2025 Delivered-To: importer@patchew.org Received-SPF: temperror (zoho.com: Error in retrieving data from DNS) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=temperror (zoho.com: Error in retrieving data from DNS) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1542814281895754.9553968259225; Wed, 21 Nov 2018 07:31:21 -0800 (PST) Received: from localhost ([::1]:39796 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gPUTF-0002re-Cz for importer@patchew.org; Wed, 21 Nov 2018 10:31:17 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52400) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gPUR9-0001Y2-Nz for qemu-devel@nongnu.org; Wed, 21 Nov 2018 10:29:10 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gPUR4-0007cf-SS for qemu-devel@nongnu.org; Wed, 21 Nov 2018 10:29:05 -0500 Received: from smtp03.citrix.com ([162.221.156.55]:57320) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gPUR4-0007ZM-Ds; Wed, 21 Nov 2018 10:29:02 -0500 X-IronPort-AV: E=Sophos;i="5.56,261,1539648000"; d="scan'208";a="71207552" From: Paul Durrant To: , , Date: Wed, 21 Nov 2018 15:12:04 +0000 Message-ID: <20181121151211.15997-12-paul.durrant@citrix.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20181121151211.15997-1-paul.durrant@citrix.com> References: <20181121151211.15997-1-paul.durrant@citrix.com> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 162.221.156.55 Subject: [Qemu-devel] [PATCH 11/18] xen: remove 'XenBlkDev' and 'blkdev' names from dataplane/xen-qdisk X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Stefano Stabellini , Max Reitz , Paul Durrant , Stefan Hajnoczi , Anthony Perard Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" This is a purely cosmetic patch that substitutes the old 'struct XenBlkDev' name with 'XenQdiskDataPlane' and 'blkdev' field/variable names with 'dataplane', and then does necessary fix-up to adhere to coding style. No functional change. Signed-off-by: Paul Durrant Acked-by: Anthony PERARD --- Cc: Stefano Stabellini Cc: Anthony Perard Cc: Stefan Hajnoczi Cc: Kevin Wolf Cc: Max Reitz --- hw/block/dataplane/xen-qdisk.c | 342 +++++++++++++++++++++----------------= ---- hw/block/dataplane/xen-qdisk.h | 2 +- 2 files changed, 179 insertions(+), 165 deletions(-) diff --git a/hw/block/dataplane/xen-qdisk.c b/hw/block/dataplane/xen-qdisk.c index b075aa975d..2214455ff9 100644 --- a/hw/block/dataplane/xen-qdisk.c +++ b/hw/block/dataplane/xen-qdisk.c @@ -28,12 +28,12 @@ struct ioreq { int presync; int aio_inflight; int aio_errors; - struct XenBlkDev *blkdev; + XenQdiskDataPlane *dataplane; QLIST_ENTRY(ioreq) list; BlockAcctCookie acct; }; =20 -struct XenBlkDev { +struct XenQdiskDataPlane { XenDevice *xendev; XenEventChannel *event_channel; unsigned int *ring_ref; @@ -69,33 +69,33 @@ static void ioreq_reset(struct ioreq *ioreq) ioreq->aio_inflight =3D 0; ioreq->aio_errors =3D 0; =20 - ioreq->blkdev =3D NULL; + ioreq->dataplane =3D NULL; memset(&ioreq->list, 0, sizeof(ioreq->list)); memset(&ioreq->acct, 0, sizeof(ioreq->acct)); =20 qemu_iovec_reset(&ioreq->v); } =20 -static struct ioreq *ioreq_start(struct XenBlkDev *blkdev) +static struct ioreq *ioreq_start(XenQdiskDataPlane *dataplane) { struct ioreq *ioreq =3D NULL; =20 - if (QLIST_EMPTY(&blkdev->freelist)) { - if (blkdev->requests_total >=3D blkdev->max_requests) { + if (QLIST_EMPTY(&dataplane->freelist)) { + if (dataplane->requests_total >=3D dataplane->max_requests) { goto out; } /* allocate new struct */ ioreq =3D g_malloc0(sizeof(*ioreq)); - ioreq->blkdev =3D blkdev; - blkdev->requests_total++; + ioreq->dataplane =3D dataplane; + dataplane->requests_total++; qemu_iovec_init(&ioreq->v, 1); } else { /* get one from freelist */ - ioreq =3D QLIST_FIRST(&blkdev->freelist); + ioreq =3D QLIST_FIRST(&dataplane->freelist); QLIST_REMOVE(ioreq, list); } - QLIST_INSERT_HEAD(&blkdev->inflight, ioreq, list); - blkdev->requests_inflight++; + QLIST_INSERT_HEAD(&dataplane->inflight, ioreq, list); + dataplane->requests_inflight++; =20 out: return ioreq; @@ -103,26 +103,26 @@ out: =20 static void ioreq_finish(struct ioreq *ioreq) { - struct XenBlkDev *blkdev =3D ioreq->blkdev; + XenQdiskDataPlane *dataplane =3D ioreq->dataplane; =20 QLIST_REMOVE(ioreq, list); - QLIST_INSERT_HEAD(&blkdev->finished, ioreq, list); - blkdev->requests_inflight--; - blkdev->requests_finished++; + QLIST_INSERT_HEAD(&dataplane->finished, ioreq, list); + dataplane->requests_inflight--; + dataplane->requests_finished++; } =20 static void ioreq_release(struct ioreq *ioreq, bool finish) { - struct XenBlkDev *blkdev =3D ioreq->blkdev; + XenQdiskDataPlane *dataplane =3D ioreq->dataplane; =20 QLIST_REMOVE(ioreq, list); ioreq_reset(ioreq); - ioreq->blkdev =3D blkdev; - QLIST_INSERT_HEAD(&blkdev->freelist, ioreq, list); + ioreq->dataplane =3D dataplane; + QLIST_INSERT_HEAD(&dataplane->freelist, ioreq, list); if (finish) { - blkdev->requests_finished--; + dataplane->requests_finished--; } else { - blkdev->requests_inflight--; + dataplane->requests_inflight--; } } =20 @@ -132,7 +132,7 @@ static void ioreq_release(struct ioreq *ioreq, bool fin= ish) */ static int ioreq_parse(struct ioreq *ioreq) { - struct XenBlkDev *blkdev =3D ioreq->blkdev; + XenQdiskDataPlane *dataplane =3D ioreq->dataplane; size_t len; int i; =20 @@ -155,12 +155,12 @@ static int ioreq_parse(struct ioreq *ioreq) }; =20 if (ioreq->req.operation !=3D BLKIF_OP_READ && - blk_is_read_only(blkdev->blk)) { + blk_is_read_only(dataplane->blk)) { error_report("error: write req for ro device"); goto err; } =20 - ioreq->start =3D ioreq->req.sector_number * blkdev->file_blk; + ioreq->start =3D ioreq->req.sector_number * dataplane->file_blk; for (i =3D 0; i < ioreq->req.nr_segments; i++) { if (i =3D=3D BLKIF_MAX_SEGMENTS_PER_REQUEST) { error_report("error: nr_segments too big"); @@ -170,16 +170,16 @@ static int ioreq_parse(struct ioreq *ioreq) error_report("error: first > last sector"); goto err; } - if (ioreq->req.seg[i].last_sect * blkdev->file_blk >=3D XC_PAGE_SI= ZE) { + if (ioreq->req.seg[i].last_sect * dataplane->file_blk >=3D XC_PAGE= _SIZE) { error_report("error: page crossing"); goto err; } =20 len =3D (ioreq->req.seg[i].last_sect - - ioreq->req.seg[i].first_sect + 1) * blkdev->file_blk; + ioreq->req.seg[i].first_sect + 1) * dataplane->file_blk; ioreq->size +=3D len; } - if (ioreq->start + ioreq->size > blkdev->file_size) { + if (ioreq->start + ioreq->size > dataplane->file_size) { error_report("error: access beyond end of file"); goto err; } @@ -192,11 +192,11 @@ err: =20 static int ioreq_grant_copy(struct ioreq *ioreq) { - struct XenBlkDev *blkdev =3D ioreq->blkdev; - XenDevice *xendev =3D blkdev->xendev; + XenQdiskDataPlane *dataplane =3D ioreq->dataplane; + XenDevice *xendev =3D dataplane->xendev; XenDeviceGrantCopySegment segs[BLKIF_MAX_SEGMENTS_PER_REQUEST]; int i, count; - int64_t file_blk =3D blkdev->file_blk; + int64_t file_blk =3D dataplane->file_blk; bool to_domain =3D (ioreq->req.operation =3D=3D BLKIF_OP_READ); void *virt =3D ioreq->buf; Error *local_err =3D NULL; @@ -244,9 +244,9 @@ static int ioreq_runio_qemu_aio(struct ioreq *ioreq); static void qemu_aio_complete(void *opaque, int ret) { struct ioreq *ioreq =3D opaque; - struct XenBlkDev *blkdev =3D ioreq->blkdev; + XenQdiskDataPlane *dataplane =3D ioreq->dataplane; =20 - aio_context_acquire(blkdev->ctx); + aio_context_acquire(dataplane->ctx); =20 if (ret !=3D 0) { error_report("%s I/O error", @@ -295,25 +295,25 @@ static void qemu_aio_complete(void *opaque, int ret) } case BLKIF_OP_READ: if (ioreq->status =3D=3D BLKIF_RSP_OKAY) { - block_acct_done(blk_get_stats(blkdev->blk), &ioreq->acct); + block_acct_done(blk_get_stats(dataplane->blk), &ioreq->acct); } else { - block_acct_failed(blk_get_stats(blkdev->blk), &ioreq->acct); + block_acct_failed(blk_get_stats(dataplane->blk), &ioreq->acct); } break; case BLKIF_OP_DISCARD: default: break; } - qemu_bh_schedule(blkdev->bh); + qemu_bh_schedule(dataplane->bh); =20 done: - aio_context_release(blkdev->ctx); + aio_context_release(dataplane->ctx); } =20 static bool blk_split_discard(struct ioreq *ioreq, blkif_sector_t sector_n= umber, uint64_t nr_sectors) { - struct XenBlkDev *blkdev =3D ioreq->blkdev; + XenQdiskDataPlane *dataplane =3D ioreq->dataplane; int64_t byte_offset; int byte_chunk; uint64_t byte_remaining, limit; @@ -322,18 +322,18 @@ static bool blk_split_discard(struct ioreq *ioreq, bl= kif_sector_t sector_number, =20 /* Wrap around, or overflowing byte limit? */ if (sec_start + sec_count < sec_count || - sec_start + sec_count > INT64_MAX / blkdev->file_blk) { + sec_start + sec_count > INT64_MAX / dataplane->file_blk) { return false; } =20 - limit =3D BDRV_REQUEST_MAX_SECTORS * blkdev->file_blk; - byte_offset =3D sec_start * blkdev->file_blk; - byte_remaining =3D sec_count * blkdev->file_blk; + limit =3D BDRV_REQUEST_MAX_SECTORS * dataplane->file_blk; + byte_offset =3D sec_start * dataplane->file_blk; + byte_remaining =3D sec_count * dataplane->file_blk; =20 do { byte_chunk =3D byte_remaining > limit ? limit : byte_remaining; ioreq->aio_inflight++; - blk_aio_pdiscard(blkdev->blk, byte_offset, byte_chunk, + blk_aio_pdiscard(dataplane->blk, byte_offset, byte_chunk, qemu_aio_complete, ioreq); byte_remaining -=3D byte_chunk; byte_offset +=3D byte_chunk; @@ -344,7 +344,7 @@ static bool blk_split_discard(struct ioreq *ioreq, blki= f_sector_t sector_number, =20 static int ioreq_runio_qemu_aio(struct ioreq *ioreq) { - struct XenBlkDev *blkdev =3D ioreq->blkdev; + XenQdiskDataPlane *dataplane =3D ioreq->dataplane; =20 ioreq->buf =3D qemu_memalign(XC_PAGE_SIZE, ioreq->size); if (ioreq->req.nr_segments && @@ -357,17 +357,17 @@ static int ioreq_runio_qemu_aio(struct ioreq *ioreq) =20 ioreq->aio_inflight++; if (ioreq->presync) { - blk_aio_flush(ioreq->blkdev->blk, qemu_aio_complete, ioreq); + blk_aio_flush(ioreq->dataplane->blk, qemu_aio_complete, ioreq); return 0; } =20 switch (ioreq->req.operation) { case BLKIF_OP_READ: qemu_iovec_add(&ioreq->v, ioreq->buf, ioreq->size); - block_acct_start(blk_get_stats(blkdev->blk), &ioreq->acct, + block_acct_start(blk_get_stats(dataplane->blk), &ioreq->acct, ioreq->v.size, BLOCK_ACCT_READ); ioreq->aio_inflight++; - blk_aio_preadv(blkdev->blk, ioreq->start, &ioreq->v, 0, + blk_aio_preadv(dataplane->blk, ioreq->start, &ioreq->v, 0, qemu_aio_complete, ioreq); break; case BLKIF_OP_WRITE: @@ -377,12 +377,12 @@ static int ioreq_runio_qemu_aio(struct ioreq *ioreq) } =20 qemu_iovec_add(&ioreq->v, ioreq->buf, ioreq->size); - block_acct_start(blk_get_stats(blkdev->blk), &ioreq->acct, + block_acct_start(blk_get_stats(dataplane->blk), &ioreq->acct, ioreq->v.size, ioreq->req.operation =3D=3D BLKIF_OP_WRITE ? BLOCK_ACCT_WRITE : BLOCK_ACCT_FLUSH); ioreq->aio_inflight++; - blk_aio_pwritev(blkdev->blk, ioreq->start, &ioreq->v, 0, + blk_aio_pwritev(dataplane->blk, ioreq->start, &ioreq->v, 0, qemu_aio_complete, ioreq); break; case BLKIF_OP_DISCARD: @@ -410,27 +410,27 @@ err: =20 static int blk_send_response_one(struct ioreq *ioreq) { - struct XenBlkDev *blkdev =3D ioreq->blkdev; + XenQdiskDataPlane *dataplane =3D ioreq->dataplane; int send_notify =3D 0; int have_requests =3D 0; blkif_response_t *resp; =20 /* Place on the response ring for the relevant domain. */ - switch (blkdev->protocol) { + switch (dataplane->protocol) { case BLKIF_PROTOCOL_NATIVE: resp =3D (blkif_response_t *)RING_GET_RESPONSE( - &blkdev->rings.native, - blkdev->rings.native.rsp_prod_pvt); + &dataplane->rings.native, + dataplane->rings.native.rsp_prod_pvt); break; case BLKIF_PROTOCOL_X86_32: resp =3D (blkif_response_t *)RING_GET_RESPONSE( - &blkdev->rings.x86_32_part, - blkdev->rings.x86_32_part.rsp_prod_pvt); + &dataplane->rings.x86_32_part, + dataplane->rings.x86_32_part.rsp_prod_pvt); break; case BLKIF_PROTOCOL_X86_64: resp =3D (blkif_response_t *)RING_GET_RESPONSE( - &blkdev->rings.x86_64_part, - blkdev->rings.x86_64_part.rsp_prod_pvt); + &dataplane->rings.x86_64_part, + dataplane->rings.x86_64_part.rsp_prod_pvt); break; default: return 0; @@ -440,111 +440,124 @@ static int blk_send_response_one(struct ioreq *iore= q) resp->operation =3D ioreq->req.operation; resp->status =3D ioreq->status; =20 - blkdev->rings.common.rsp_prod_pvt++; + dataplane->rings.common.rsp_prod_pvt++; =20 - RING_PUSH_RESPONSES_AND_CHECK_NOTIFY(&blkdev->rings.common, send_notif= y); - if (blkdev->rings.common.rsp_prod_pvt =3D=3D blkdev->rings.common.req_= cons) { + RING_PUSH_RESPONSES_AND_CHECK_NOTIFY(&dataplane->rings.common, + send_notify); + if (dataplane->rings.common.rsp_prod_pvt =3D=3D + dataplane->rings.common.req_cons) { /* * Tail check for pending requests. Allows frontend to avoid * notifications if requests are already in flight (lower * overheads and promotes batching). */ - RING_FINAL_CHECK_FOR_REQUESTS(&blkdev->rings.common, have_requests= ); - } else if (RING_HAS_UNCONSUMED_REQUESTS(&blkdev->rings.common)) { + RING_FINAL_CHECK_FOR_REQUESTS(&dataplane->rings.common, + have_requests); + } else if (RING_HAS_UNCONSUMED_REQUESTS(&dataplane->rings.common)) { have_requests =3D 1; } =20 if (have_requests) { - blkdev->more_work++; + dataplane->more_work++; } return send_notify; } =20 /* walk finished list, send outstanding responses, free requests */ -static void blk_send_response_all(struct XenBlkDev *blkdev) +static void blk_send_response_all(XenQdiskDataPlane *dataplane) { struct ioreq *ioreq; int send_notify =3D 0; =20 - while (!QLIST_EMPTY(&blkdev->finished)) { - ioreq =3D QLIST_FIRST(&blkdev->finished); + while (!QLIST_EMPTY(&dataplane->finished)) { + ioreq =3D QLIST_FIRST(&dataplane->finished); send_notify +=3D blk_send_response_one(ioreq); ioreq_release(ioreq, true); } if (send_notify) { - xen_device_notify_event_channel(blkdev->xendev, blkdev->event_chan= nel); + xen_device_notify_event_channel(dataplane->xendev, + dataplane->event_channel); } } =20 -static int blk_get_request(struct XenBlkDev *blkdev, struct ioreq *ioreq, +static int blk_get_request(XenQdiskDataPlane *dataplane, struct ioreq *ior= eq, RING_IDX rc) { - switch (blkdev->protocol) { - case BLKIF_PROTOCOL_NATIVE: - memcpy(&ioreq->req, RING_GET_REQUEST(&blkdev->rings.native, rc), - sizeof(ioreq->req)); + switch (dataplane->protocol) { + case BLKIF_PROTOCOL_NATIVE: { + blkif_request_t *req =3D + RING_GET_REQUEST(&dataplane->rings.native, rc); + + memcpy(&ioreq->req, req, sizeof(ioreq->req)); break; - case BLKIF_PROTOCOL_X86_32: - blkif_get_x86_32_req(&ioreq->req, - RING_GET_REQUEST(&blkdev->rings.x86_32_part, = rc)); + } + case BLKIF_PROTOCOL_X86_32: { + blkif_x86_32_request_t *req =3D + RING_GET_REQUEST(&dataplane->rings.x86_32_part, rc); + + blkif_get_x86_32_req(&ioreq->req, req); break; - case BLKIF_PROTOCOL_X86_64: - blkif_get_x86_64_req(&ioreq->req, - RING_GET_REQUEST(&blkdev->rings.x86_64_part, = rc)); + } + case BLKIF_PROTOCOL_X86_64: { + blkif_x86_64_request_t *req =3D + RING_GET_REQUEST(&dataplane->rings.x86_64_part, rc); + + blkif_get_x86_64_req(&ioreq->req, req); break; } + } /* Prevent the compiler from accessing the on-ring fields instead. */ barrier(); return 0; } =20 -static void blk_handle_requests(struct XenBlkDev *blkdev) +static void blk_handle_requests(XenQdiskDataPlane *dataplane) { RING_IDX rc, rp; struct ioreq *ioreq; =20 - blkdev->more_work =3D 0; + dataplane->more_work =3D 0; =20 - rc =3D blkdev->rings.common.req_cons; - rp =3D blkdev->rings.common.sring->req_prod; + rc =3D dataplane->rings.common.req_cons; + rp =3D dataplane->rings.common.sring->req_prod; xen_rmb(); /* Ensure we see queued requests up to 'rp'. */ =20 - blk_send_response_all(blkdev); + blk_send_response_all(dataplane); while (rc !=3D rp) { /* pull request from ring */ - if (RING_REQUEST_CONS_OVERFLOW(&blkdev->rings.common, rc)) { + if (RING_REQUEST_CONS_OVERFLOW(&dataplane->rings.common, rc)) { break; } - ioreq =3D ioreq_start(blkdev); + ioreq =3D ioreq_start(dataplane); if (ioreq =3D=3D NULL) { - blkdev->more_work++; + dataplane->more_work++; break; } - blk_get_request(blkdev, ioreq, rc); - blkdev->rings.common.req_cons =3D ++rc; + blk_get_request(dataplane, ioreq, rc); + dataplane->rings.common.req_cons =3D ++rc; =20 /* parse them */ if (ioreq_parse(ioreq) !=3D 0) { =20 switch (ioreq->req.operation) { case BLKIF_OP_READ: - block_acct_invalid(blk_get_stats(blkdev->blk), + block_acct_invalid(blk_get_stats(dataplane->blk), BLOCK_ACCT_READ); break; case BLKIF_OP_WRITE: - block_acct_invalid(blk_get_stats(blkdev->blk), + block_acct_invalid(blk_get_stats(dataplane->blk), BLOCK_ACCT_WRITE); break; case BLKIF_OP_FLUSH_DISKCACHE: - block_acct_invalid(blk_get_stats(blkdev->blk), + block_acct_invalid(blk_get_stats(dataplane->blk), BLOCK_ACCT_FLUSH); default: break; }; =20 if (blk_send_response_one(ioreq)) { - xen_device_notify_event_channel(blkdev->xendev, - blkdev->event_channel); + xen_device_notify_event_channel(dataplane->xendev, + dataplane->event_channel); } ioreq_release(ioreq, false); continue; @@ -553,111 +566,112 @@ static void blk_handle_requests(struct XenBlkDev *b= lkdev) ioreq_runio_qemu_aio(ioreq); } =20 - if (blkdev->more_work && blkdev->requests_inflight < blkdev->max_reque= sts) { - qemu_bh_schedule(blkdev->bh); + if (dataplane->more_work && + dataplane->requests_inflight < dataplane->max_requests) { + qemu_bh_schedule(dataplane->bh); } } =20 static void blk_bh(void *opaque) { - struct XenBlkDev *blkdev =3D opaque; + XenQdiskDataPlane *dataplane =3D opaque; =20 - aio_context_acquire(blkdev->ctx); - blk_handle_requests(blkdev); - aio_context_release(blkdev->ctx); + aio_context_acquire(dataplane->ctx); + blk_handle_requests(dataplane); + aio_context_release(dataplane->ctx); } =20 static void blk_event(void *opaque) { - struct XenBlkDev *blkdev =3D opaque; + XenQdiskDataPlane *dataplane =3D opaque; =20 - qemu_bh_schedule(blkdev->bh); + qemu_bh_schedule(dataplane->bh); } =20 -struct XenBlkDev *xen_qdisk_dataplane_create(XenDevice *xendev, +XenQdiskDataPlane *xen_qdisk_dataplane_create(XenDevice *xendev, BlockConf *conf, IOThread *iothread) { - struct XenBlkDev *blkdev =3D g_new0(struct XenBlkDev, 1); + XenQdiskDataPlane *dataplane =3D g_new0(XenQdiskDataPlane, 1); =20 - blkdev->xendev =3D xendev; - blkdev->file_blk =3D conf->logical_block_size; - blkdev->blk =3D conf->blk; - blkdev->file_size =3D blk_getlength(blkdev->blk); + dataplane->xendev =3D xendev; + dataplane->file_blk =3D conf->logical_block_size; + dataplane->blk =3D conf->blk; + dataplane->file_size =3D blk_getlength(dataplane->blk); =20 - QLIST_INIT(&blkdev->inflight); - QLIST_INIT(&blkdev->finished); - QLIST_INIT(&blkdev->freelist); + QLIST_INIT(&dataplane->inflight); + QLIST_INIT(&dataplane->finished); + QLIST_INIT(&dataplane->freelist); =20 if (iothread) { - blkdev->iothread =3D iothread; - object_ref(OBJECT(blkdev->iothread)); - blkdev->ctx =3D iothread_get_aio_context(blkdev->iothread); + dataplane->iothread =3D iothread; + object_ref(OBJECT(dataplane->iothread)); + dataplane->ctx =3D iothread_get_aio_context(dataplane->iothread); } else { - blkdev->ctx =3D qemu_get_aio_context(); + dataplane->ctx =3D qemu_get_aio_context(); } - blkdev->bh =3D aio_bh_new(blkdev->ctx, blk_bh, blkdev); + dataplane->bh =3D aio_bh_new(dataplane->ctx, blk_bh, dataplane); =20 - return blkdev; + return dataplane; } =20 -void xen_qdisk_dataplane_destroy(struct XenBlkDev *blkdev) +void xen_qdisk_dataplane_destroy(XenQdiskDataPlane *dataplane) { struct ioreq *ioreq; =20 - if (!blkdev) { + if (!dataplane) { return; } =20 - while (!QLIST_EMPTY(&blkdev->freelist)) { - ioreq =3D QLIST_FIRST(&blkdev->freelist); + while (!QLIST_EMPTY(&dataplane->freelist)) { + ioreq =3D QLIST_FIRST(&dataplane->freelist); QLIST_REMOVE(ioreq, list); qemu_iovec_destroy(&ioreq->v); g_free(ioreq); } =20 - qemu_bh_delete(blkdev->bh); - if (blkdev->iothread) { - object_unref(OBJECT(blkdev->iothread)); + qemu_bh_delete(dataplane->bh); + if (dataplane->iothread) { + object_unref(OBJECT(dataplane->iothread)); } =20 - g_free(blkdev); + g_free(dataplane); } =20 -void xen_qdisk_dataplane_start(struct XenBlkDev *blkdev, +void xen_qdisk_dataplane_start(XenQdiskDataPlane *dataplane, const unsigned int ring_ref[], unsigned int nr_ring_ref, unsigned int event_channel, unsigned int protocol) { - XenDevice *xendev =3D blkdev->xendev; + XenDevice *xendev =3D dataplane->xendev; unsigned int ring_size; unsigned int i; =20 - blkdev->nr_ring_ref =3D nr_ring_ref; - blkdev->ring_ref =3D g_new(unsigned int, nr_ring_ref); + dataplane->nr_ring_ref =3D nr_ring_ref; + dataplane->ring_ref =3D g_new(unsigned int, nr_ring_ref); =20 for (i =3D 0; i < nr_ring_ref; i++) { - blkdev->ring_ref[i] =3D ring_ref[i]; + dataplane->ring_ref[i] =3D ring_ref[i]; } =20 - blkdev->protocol =3D protocol; + dataplane->protocol =3D protocol; =20 - ring_size =3D XC_PAGE_SIZE * blkdev->nr_ring_ref; - switch (blkdev->protocol) { + ring_size =3D XC_PAGE_SIZE * dataplane->nr_ring_ref; + switch (dataplane->protocol) { case BLKIF_PROTOCOL_NATIVE: { - blkdev->max_requests =3D __CONST_RING_SIZE(blkif, ring_size); + dataplane->max_requests =3D __CONST_RING_SIZE(blkif, ring_size); break; } case BLKIF_PROTOCOL_X86_32: { - blkdev->max_requests =3D __CONST_RING_SIZE(blkif_x86_32, ring_size= ); + dataplane->max_requests =3D __CONST_RING_SIZE(blkif_x86_32, ring_s= ize); break; } case BLKIF_PROTOCOL_X86_64: { - blkdev->max_requests =3D __CONST_RING_SIZE(blkif_x86_64, ring_size= ); + dataplane->max_requests =3D __CONST_RING_SIZE(blkif_x86_64, ring_s= ize); break; } default: @@ -665,76 +679,76 @@ void xen_qdisk_dataplane_start(struct XenBlkDev *blkd= ev, break; } =20 - xen_device_set_max_grant_refs(xendev, blkdev->nr_ring_ref, + xen_device_set_max_grant_refs(xendev, dataplane->nr_ring_ref, &error_fatal); =20 - blkdev->sring =3D xen_device_map_grant_refs(xendev, - blkdev->ring_ref, - blkdev->nr_ring_ref, + dataplane->sring =3D xen_device_map_grant_refs(xendev, + dataplane->ring_ref, + dataplane->nr_ring_ref, PROT_READ | PROT_WRITE, &error_fatal); =20 - switch (blkdev->protocol) { + switch (dataplane->protocol) { case BLKIF_PROTOCOL_NATIVE: { - blkif_sring_t *sring_native =3D blkdev->sring; + blkif_sring_t *sring_native =3D dataplane->sring; =20 - BACK_RING_INIT(&blkdev->rings.native, sring_native, ring_size); + BACK_RING_INIT(&dataplane->rings.native, sring_native, ring_size); break; } case BLKIF_PROTOCOL_X86_32: { - blkif_x86_32_sring_t *sring_x86_32 =3D blkdev->sring; + blkif_x86_32_sring_t *sring_x86_32 =3D dataplane->sring; =20 - BACK_RING_INIT(&blkdev->rings.x86_32_part, sring_x86_32, + BACK_RING_INIT(&dataplane->rings.x86_32_part, sring_x86_32, ring_size); break; } case BLKIF_PROTOCOL_X86_64: { - blkif_x86_64_sring_t *sring_x86_64 =3D blkdev->sring; + blkif_x86_64_sring_t *sring_x86_64 =3D dataplane->sring; =20 - BACK_RING_INIT(&blkdev->rings.x86_64_part, sring_x86_64, + BACK_RING_INIT(&dataplane->rings.x86_64_part, sring_x86_64, ring_size); break; } } =20 - blkdev->event_channel =3D + dataplane->event_channel =3D xen_device_bind_event_channel(xendev, event_channel, - blk_event, blkdev, + blk_event, dataplane, &error_fatal); =20 - aio_context_acquire(blkdev->ctx); - blk_set_aio_context(blkdev->blk, blkdev->ctx); - aio_context_release(blkdev->ctx); + aio_context_acquire(dataplane->ctx); + blk_set_aio_context(dataplane->blk, dataplane->ctx); + aio_context_release(dataplane->ctx); } =20 -void xen_qdisk_dataplane_stop(struct XenBlkDev *blkdev) +void xen_qdisk_dataplane_stop(XenQdiskDataPlane *dataplane) { XenDevice *xendev; =20 - if (!blkdev) { + if (!dataplane) { return; } =20 - aio_context_acquire(blkdev->ctx); - blk_set_aio_context(blkdev->blk, qemu_get_aio_context()); - aio_context_release(blkdev->ctx); + aio_context_acquire(dataplane->ctx); + blk_set_aio_context(dataplane->blk, qemu_get_aio_context()); + aio_context_release(dataplane->ctx); =20 - xendev =3D blkdev->xendev; + xendev =3D dataplane->xendev; =20 - if (blkdev->event_channel) { - xen_device_unbind_event_channel(xendev, blkdev->event_channel); - blkdev->event_channel =3D NULL; + if (dataplane->event_channel) { + xen_device_unbind_event_channel(xendev, dataplane->event_channel); + dataplane->event_channel =3D NULL; } =20 - if (blkdev->sring) { - xen_device_unmap_grant_refs(xendev, blkdev->sring, - blkdev->nr_ring_ref, &error_fatal); - blkdev->sring =3D NULL; + if (dataplane->sring) { + xen_device_unmap_grant_refs(xendev, dataplane->sring, + dataplane->nr_ring_ref, &error_fatal); + dataplane->sring =3D NULL; } =20 - g_free(blkdev->ring_ref); - blkdev->ring_ref =3D NULL; + g_free(dataplane->ring_ref); + dataplane->ring_ref =3D NULL; } diff --git a/hw/block/dataplane/xen-qdisk.h b/hw/block/dataplane/xen-qdisk.h index 16bcd500bf..cfa555af61 100644 --- a/hw/block/dataplane/xen-qdisk.h +++ b/hw/block/dataplane/xen-qdisk.h @@ -9,7 +9,7 @@ #include "hw/xen/xen-bus.h" #include "sysemu/iothread.h" =20 -typedef struct XenBlkDev XenQdiskDataPlane; +typedef struct XenQdiskDataPlane XenQdiskDataPlane; =20 XenQdiskDataPlane *xen_qdisk_dataplane_create(XenDevice *xendev, BlockConf *conf, --=20 2.11.0