From nobody Fri Nov 7 09:10:08 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1547475760823128.51746400634852; Mon, 14 Jan 2019 06:22:40 -0800 (PST) Received: from localhost ([127.0.0.1]:37912 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gj38R-0007Ty-Gg for importer@patchew.org; Mon, 14 Jan 2019 09:22:39 -0500 Received: from eggs.gnu.org ([209.51.188.92]:47282) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gj2lc-00071X-HM for qemu-devel@nongnu.org; Mon, 14 Jan 2019 08:59:07 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gj2lU-0004mR-9f for qemu-devel@nongnu.org; Mon, 14 Jan 2019 08:59:01 -0500 Received: from smtp03.citrix.com ([162.221.156.55]:1370) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gj2lT-0004ll-As for qemu-devel@nongnu.org; Mon, 14 Jan 2019 08:58:56 -0500 X-IronPort-AV: E=Sophos;i="5.56,477,1539648000"; d="scan'208";a="75507001" From: Anthony PERARD To: Date: Mon, 14 Jan 2019 13:51:42 +0000 Message-ID: <20190114135154.16826-14-anthony.perard@citrix.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190114135154.16826-1-anthony.perard@citrix.com> References: <20190114135154.16826-1-anthony.perard@citrix.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 162.221.156.55 Subject: [Qemu-devel] [PULL 13/25] xen: remove 'XenBlkDev' and 'blkdev' names from dataplane/xen-block 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: Anthony PERARD , xen-devel@lists.xenproject.org, Peter Maydell Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" From: Paul Durrant This is a purely cosmetic patch that substitutes the old 'struct XenBlkDev' name with 'XenBlockDataPlane' 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 Signed-off-by: Anthony PERARD --- hw/block/dataplane/xen-block.c | 352 +++++++++++++++++---------------- hw/block/dataplane/xen-block.h | 2 +- 2 files changed, 183 insertions(+), 171 deletions(-) diff --git a/hw/block/dataplane/xen-block.c b/hw/block/dataplane/xen-block.c index ed2b91ffff..1ff464973c 100644 --- a/hw/block/dataplane/xen-block.c +++ b/hw/block/dataplane/xen-block.c @@ -38,12 +38,12 @@ struct ioreq { int presync; int aio_inflight; int aio_errors; - struct XenBlkDev *blkdev; + XenBlockDataPlane *dataplane; QLIST_ENTRY(ioreq) list; BlockAcctCookie acct; }; =20 -struct XenBlkDev { +struct XenBlockDataPlane { XenDevice *xendev; XenEventChannel *event_channel; unsigned int *ring_ref; @@ -79,33 +79,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(XenBlockDataPlane *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; @@ -113,26 +113,26 @@ static struct ioreq *ioreq_start(struct XenBlkDev *bl= kdev) =20 static void ioreq_finish(struct ioreq *ioreq) { - struct XenBlkDev *blkdev =3D ioreq->blkdev; + XenBlockDataPlane *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; + XenBlockDataPlane *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 @@ -142,7 +142,7 @@ static void ioreq_release(struct ioreq *ioreq, bool fin= ish) */ static int ioreq_parse(struct ioreq *ioreq) { - struct XenBlkDev *blkdev =3D ioreq->blkdev; + XenBlockDataPlane *dataplane =3D ioreq->dataplane; size_t len; int i; =20 @@ -165,12 +165,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"); @@ -180,16 +180,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; } @@ -202,11 +202,11 @@ static int ioreq_parse(struct ioreq *ioreq) =20 static int ioreq_grant_copy(struct ioreq *ioreq) { - struct XenBlkDev *blkdev =3D ioreq->blkdev; - XenDevice *xendev =3D blkdev->xendev; + XenBlockDataPlane *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; @@ -251,9 +251,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; + XenBlockDataPlane *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", @@ -302,25 +302,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; + XenBlockDataPlane *dataplane =3D ioreq->dataplane; int64_t byte_offset; int byte_chunk; uint64_t byte_remaining, limit; @@ -329,18 +329,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; @@ -351,7 +351,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; + XenBlockDataPlane *dataplane =3D ioreq->dataplane; =20 ioreq->buf =3D qemu_memalign(XC_PAGE_SIZE, ioreq->size); if (ioreq->req.nr_segments && @@ -364,17 +364,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: @@ -384,12 +384,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: @@ -417,27 +417,27 @@ static int ioreq_runio_qemu_aio(struct ioreq *ioreq) =20 static int blk_send_response_one(struct ioreq *ioreq) { - struct XenBlkDev *blkdev =3D ioreq->blkdev; + XenBlockDataPlane *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; @@ -447,42 +447,45 @@ static int blk_send_response_one(struct ioreq *ioreq) 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(XenBlockDataPlane *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) { Error *local_err =3D NULL; =20 - xen_device_notify_event_channel(blkdev->xendev, - blkdev->event_channel, + xen_device_notify_event_channel(dataplane->xendev, + dataplane->event_channel, &local_err); if (local_err) { error_report_err(local_err); @@ -490,67 +493,76 @@ static void blk_send_response_all(struct XenBlkDev *b= lkdev) } } =20 -static int blk_get_request(struct XenBlkDev *blkdev, struct ioreq *ioreq, +static int blk_get_request(XenBlockDataPlane *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(XenBlockDataPlane *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; @@ -559,8 +571,8 @@ static void blk_handle_requests(struct XenBlkDev *blkde= v) if (blk_send_response_one(ioreq)) { Error *local_err =3D NULL; =20 - xen_device_notify_event_channel(blkdev->xendev, - blkdev->event_channel, + xen_device_notify_event_channel(dataplane->xendev, + dataplane->event_channel, &local_err); if (local_err) { error_report_err(local_err); @@ -573,173 +585,173 @@ 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; + XenBlockDataPlane *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; + XenBlockDataPlane *dataplane =3D opaque; =20 - qemu_bh_schedule(blkdev->bh); + qemu_bh_schedule(dataplane->bh); } =20 -struct XenBlkDev *xen_block_dataplane_create(XenDevice *xendev, - BlockConf *conf, - IOThread *iothread) +XenBlockDataPlane *xen_block_dataplane_create(XenDevice *xendev, + BlockConf *conf, + IOThread *iothread) { - struct XenBlkDev *blkdev =3D g_new0(struct XenBlkDev, 1); + XenBlockDataPlane *dataplane =3D g_new0(XenBlockDataPlane, 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_block_dataplane_destroy(struct XenBlkDev *blkdev) +void xen_block_dataplane_destroy(XenBlockDataPlane *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_block_dataplane_stop(struct XenBlkDev *blkdev) +void xen_block_dataplane_stop(XenBlockDataPlane *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) { + if (dataplane->event_channel) { Error *local_err =3D NULL; =20 - xen_device_unbind_event_channel(xendev, blkdev->event_channel, + xen_device_unbind_event_channel(xendev, dataplane->event_channel, &local_err); - blkdev->event_channel =3D NULL; + dataplane->event_channel =3D NULL; =20 if (local_err) { error_report_err(local_err); } } =20 - if (blkdev->sring) { + if (dataplane->sring) { Error *local_err =3D NULL; =20 - xen_device_unmap_grant_refs(xendev, blkdev->sring, - blkdev->nr_ring_ref, &local_err); - blkdev->sring =3D NULL; + xen_device_unmap_grant_refs(xendev, dataplane->sring, + dataplane->nr_ring_ref, &local_err); + dataplane->sring =3D NULL; =20 if (local_err) { error_report_err(local_err); } } =20 - g_free(blkdev->ring_ref); - blkdev->ring_ref =3D NULL; + g_free(dataplane->ring_ref); + dataplane->ring_ref =3D NULL; } =20 -void xen_block_dataplane_start(struct XenBlkDev *blkdev, +void xen_block_dataplane_start(XenBlockDataPlane *dataplane, const unsigned int ring_ref[], unsigned int nr_ring_ref, unsigned int event_channel, unsigned int protocol, Error **errp) { - XenDevice *xendev =3D blkdev->xendev; + XenDevice *xendev =3D dataplane->xendev; Error *local_err =3D NULL; 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: - error_setg(errp, "unknown protocol %u", blkdev->protocol); + error_setg(errp, "unknown protocol %u", dataplane->protocol); return; } =20 - xen_device_set_max_grant_refs(xendev, blkdev->nr_ring_ref, + xen_device_set_max_grant_refs(xendev, dataplane->nr_ring_ref, &local_err); if (local_err) { error_propagate(errp, local_err); goto stop; } =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, &local_err); if (local_err) { @@ -747,46 +759,46 @@ void xen_block_dataplane_start(struct XenBlkDev *blkd= ev, goto stop; } =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, &local_err); if (local_err) { error_propagate(errp, local_err); goto stop; } =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); return; =20 stop: - xen_block_dataplane_stop(blkdev); + xen_block_dataplane_stop(dataplane); } diff --git a/hw/block/dataplane/xen-block.h b/hw/block/dataplane/xen-block.h index f31da38464..d6fa6d26dd 100644 --- a/hw/block/dataplane/xen-block.h +++ b/hw/block/dataplane/xen-block.h @@ -12,7 +12,7 @@ #include "hw/xen/xen-bus.h" #include "sysemu/iothread.h" =20 -typedef struct XenBlkDev XenBlockDataPlane; +typedef struct XenBlockDataPlane XenBlockDataPlane; =20 XenBlockDataPlane *xen_block_dataplane_create(XenDevice *xendev, BlockConf *conf, --=20 Anthony PERARD