From nobody Wed Dec 17 21:47:32 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) 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 1498236554468720.437457210301; Fri, 23 Jun 2017 09:49:14 -0700 (PDT) Received: from localhost ([::1]:36366 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dORle-0001oy-Sz for importer@patchew.org; Fri, 23 Jun 2017 12:49:10 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60109) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dORMI-0001aF-Nc for qemu-devel@nongnu.org; Fri, 23 Jun 2017 12:23:00 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dORMH-0007qf-Aw for qemu-devel@nongnu.org; Fri, 23 Jun 2017 12:22:58 -0400 Received: from mx1.redhat.com ([209.132.183.28]:39854) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dORMB-0007mt-HI; Fri, 23 Jun 2017 12:22:51 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 8885481235; Fri, 23 Jun 2017 16:22:50 +0000 (UTC) Received: from noname.redhat.com (ovpn-117-196.ams2.redhat.com [10.36.117.196]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9B05A6EC9C; Fri, 23 Jun 2017 16:22:49 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 8885481235 Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=kwolf@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 8885481235 From: Kevin Wolf To: qemu-block@nongnu.org Date: Fri, 23 Jun 2017 18:21:35 +0200 Message-Id: <1498234919-27316-38-git-send-email-kwolf@redhat.com> In-Reply-To: <1498234919-27316-1-git-send-email-kwolf@redhat.com> References: <1498234919-27316-1-git-send-email-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Fri, 23 Jun 2017 16:22:50 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 37/61] qed: Remove callback from qed_write_table() 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: kwolf@redhat.com, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Kevin Wolf Reviewed-by: Stefan Hajnoczi --- block/qed-table.c | 47 ++++++++++++----------------------------------- block/qed.c | 12 +++++++----- block/qed.h | 8 +++----- 3 files changed, 22 insertions(+), 45 deletions(-) diff --git a/block/qed-table.c b/block/qed-table.c index 0cc93a7..ebee2c5 100644 --- a/block/qed-table.c +++ b/block/qed-table.c @@ -61,12 +61,9 @@ out: * @index: Index of first element * @n: Number of elements * @flush: Whether or not to sync to disk - * @cb: Completion function - * @opaque: Argument for completion function */ -static void qed_write_table(BDRVQEDState *s, uint64_t offset, QEDTable *ta= ble, - unsigned int index, unsigned int n, bool flush, - BlockCompletionFunc *cb, void *opaque) +static int qed_write_table(BDRVQEDState *s, uint64_t offset, QEDTable *tab= le, + unsigned int index, unsigned int n, bool flush) { unsigned int sector_mask =3D BDRV_SECTOR_SIZE / sizeof(uint64_t) - 1; unsigned int start, end, i; @@ -118,15 +115,7 @@ static void qed_write_table(BDRVQEDState *s, uint64_t = offset, QEDTable *table, ret =3D 0; out: qemu_vfree(new_table); - cb(opaque, ret); -} - -/** - * Propagate return value from async callback - */ -static void qed_sync_cb(void *opaque, int ret) -{ - *(int *)opaque =3D ret; + return ret; } =20 int qed_read_l1_table_sync(BDRVQEDState *s) @@ -134,23 +123,17 @@ int qed_read_l1_table_sync(BDRVQEDState *s) return qed_read_table(s, s->header.l1_table_offset, s->l1_table); } =20 -void qed_write_l1_table(BDRVQEDState *s, unsigned int index, unsigned int = n, - BlockCompletionFunc *cb, void *opaque) +int qed_write_l1_table(BDRVQEDState *s, unsigned int index, unsigned int n) { BLKDBG_EVENT(s->bs->file, BLKDBG_L1_UPDATE); - qed_write_table(s, s->header.l1_table_offset, - s->l1_table, index, n, false, cb, opaque); + return qed_write_table(s, s->header.l1_table_offset, + s->l1_table, index, n, false); } =20 int qed_write_l1_table_sync(BDRVQEDState *s, unsigned int index, unsigned int n) { - int ret =3D -EINPROGRESS; - - qed_write_l1_table(s, index, n, qed_sync_cb, &ret); - BDRV_POLL_WHILE(s->bs, ret =3D=3D -EINPROGRESS); - - return ret; + return qed_write_l1_table(s, index, n); } =20 int qed_read_l2_table(BDRVQEDState *s, QEDRequest *request, uint64_t offse= t) @@ -197,22 +180,16 @@ int qed_read_l2_table_sync(BDRVQEDState *s, QEDReques= t *request, uint64_t offset return qed_read_l2_table(s, request, offset); } =20 -void qed_write_l2_table(BDRVQEDState *s, QEDRequest *request, - unsigned int index, unsigned int n, bool flush, - BlockCompletionFunc *cb, void *opaque) +int qed_write_l2_table(BDRVQEDState *s, QEDRequest *request, + unsigned int index, unsigned int n, bool flush) { BLKDBG_EVENT(s->bs->file, BLKDBG_L2_UPDATE); - qed_write_table(s, request->l2_table->offset, - request->l2_table->table, index, n, flush, cb, opaque); + return qed_write_table(s, request->l2_table->offset, + request->l2_table->table, index, n, flush); } =20 int qed_write_l2_table_sync(BDRVQEDState *s, QEDRequest *request, unsigned int index, unsigned int n, bool flush) { - int ret =3D -EINPROGRESS; - - qed_write_l2_table(s, request, index, n, flush, qed_sync_cb, &ret); - BDRV_POLL_WHILE(s->bs, ret =3D=3D -EINPROGRESS); - - return ret; + return qed_write_l2_table(s, request, index, n, flush); } diff --git a/block/qed.c b/block/qed.c index 95f1050..8c493bb 100644 --- a/block/qed.c +++ b/block/qed.c @@ -1000,7 +1000,8 @@ static void qed_aio_write_l1_update(void *opaque, int= ret) index =3D qed_l1_index(s, acb->cur_pos); s->l1_table->offsets[index] =3D acb->request.l2_table->offset; =20 - qed_write_l1_table(s, index, 1, qed_commit_l2_update, acb); + ret =3D qed_write_l1_table(s, index, 1); + qed_commit_l2_update(acb, ret); } =20 /** @@ -1027,12 +1028,13 @@ static void qed_aio_write_l2_update(QEDAIOCB *acb, = int ret, uint64_t offset) =20 if (need_alloc) { /* Write out the whole new L2 table */ - qed_write_l2_table(s, &acb->request, 0, s->table_nelems, true, - qed_aio_write_l1_update, acb); + ret =3D qed_write_l2_table(s, &acb->request, 0, s->table_nelems, t= rue); + qed_aio_write_l1_update(acb, ret); } else { /* Write out only the updated part of the L2 table */ - qed_write_l2_table(s, &acb->request, index, acb->cur_nclusters, fa= lse, - qed_aio_next_io_cb, acb); + ret =3D qed_write_l2_table(s, &acb->request, index, acb->cur_nclus= ters, + false); + qed_aio_next_io(acb, ret); } return; =20 diff --git a/block/qed.h b/block/qed.h index 46843c4..51443fa 100644 --- a/block/qed.h +++ b/block/qed.h @@ -220,16 +220,14 @@ void qed_commit_l2_cache_entry(L2TableCache *l2_cache= , CachedL2Table *l2_table); * Table I/O functions */ int qed_read_l1_table_sync(BDRVQEDState *s); -void qed_write_l1_table(BDRVQEDState *s, unsigned int index, unsigned int = n, - BlockCompletionFunc *cb, void *opaque); +int qed_write_l1_table(BDRVQEDState *s, unsigned int index, unsigned int n= ); int qed_write_l1_table_sync(BDRVQEDState *s, unsigned int index, unsigned int n); int qed_read_l2_table_sync(BDRVQEDState *s, QEDRequest *request, uint64_t offset); int qed_read_l2_table(BDRVQEDState *s, QEDRequest *request, uint64_t offse= t); -void qed_write_l2_table(BDRVQEDState *s, QEDRequest *request, - unsigned int index, unsigned int n, bool flush, - BlockCompletionFunc *cb, void *opaque); +int qed_write_l2_table(BDRVQEDState *s, QEDRequest *request, + unsigned int index, unsigned int n, bool flush); int qed_write_l2_table_sync(BDRVQEDState *s, QEDRequest *request, unsigned int index, unsigned int n, bool flush= ); =20 --=20 1.8.3.1