From nobody Sat Apr 27 06:34:22 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1652791475; cv=none; d=zohomail.com; s=zohoarc; b=cxEC0PRmqXNFfAmKq2i2ZGfmBbCrPYBQg6EffZqe2NfbUx3XGb0Zo98Zt5rthTyb4ffE/CJfQFb3aOjMQjp9ioiJsNWWMakXVNv1HbT3CcOWUz1mM0NdzjuBp4LpBLA/SbwFgO+Qn/bYj9/C5fWQYiOZSZFqFWxmaArZxUBWZKA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1652791475; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=ZohTqFWC54JIuT7s66fgfkfA8f7r+NmGjP5PQl4wb8s=; b=nZHk9Dd0/UK+vT1TaoYRiUgd/kA0CtW20p3SvsbBbbgb2u+F3c/sGQqxv7FFzS8tVmgYjHRQfnLTk+8nH3gan7DAqUT8uyC/+Mzarnz2D6KJpqNNjLcmosoMlgkxv9NA8zUasNKTK5WC3vz7FkeSaXv+0xXInuPkOAFjlRUJ3Zg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1652791475765879.8384687738434; Tue, 17 May 2022 05:44:35 -0700 (PDT) Received: from localhost ([::1]:42314 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nqwZ0-0006KB-KB for importer@patchew.org; Tue, 17 May 2022 08:44:34 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41694) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nqvUI-0007FZ-3l for qemu-devel@nongnu.org; Tue, 17 May 2022 07:35:40 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:36748) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nqvUD-0002cT-PV for qemu-devel@nongnu.org; Tue, 17 May 2022 07:35:36 -0400 Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-624-0dmsy1jNOTi7dW0l8VUCMg-1; Tue, 17 May 2022 07:35:32 -0400 Received: by mail-wm1-f72.google.com with SMTP id i18-20020a1c5412000000b0039491a8298cso832798wmb.5 for ; Tue, 17 May 2022 04:35:31 -0700 (PDT) Received: from fedora.redhat.com ([2001:8a0:f4d9:2101:a4fa:5f93:755f:6249]) by smtp.gmail.com with ESMTPSA id m14-20020a5d64ae000000b0020d0fbf578esm4570177wrp.7.2022.05.17.04.35.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 May 2022 04:35:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1652787333; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ZohTqFWC54JIuT7s66fgfkfA8f7r+NmGjP5PQl4wb8s=; b=PcEXkJSfLx+gfu0fdIH+uyX6HACW8xeNoEttdVZa3Z0LaeUFgbBjHsnbiq/r8GI4+aYhHd 5NyPWlci0CXLT+FjUg3m2W67LO8ZbfnJSeqfDDFVYunTROVO13QLy7SNzfVqR6DKxdYPsi WBqBEHHRwlmUCUTKfeGfcSFY/aX3ydE= X-MC-Unique: 0dmsy1jNOTi7dW0l8VUCMg-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ZohTqFWC54JIuT7s66fgfkfA8f7r+NmGjP5PQl4wb8s=; b=lmp7hwFasVEEKKqUOEEOM/PSvyFXKdfQ12QZIvFUxUv9/cHAS0Xs/15BTU3RdJvH2S IBt5l9y3CZzAkPLCTpK7Td0g+GLWHOd/tYCOIc5DWKZz4D41zCSa60B3BAVvJpG6m1m2 Pj9JmAUrUk64VATLPtHwSTHFYy7tnHD4sXx6hNHehRC8TVKSzw+nhbY7vkSSrMeU90w4 6ypuGbdPV7FUtoEweAyBOFk5kExcssmtROqxkRmJWshiGmg3ODMiNiSdHoxPdXr1hBdi SGUJyJ8o9y2i2Zh8TNJlK9nXHAV03Axfhf3VlqeKHzCkI8r+CUMIBBjbfUYSs3Gg+/pP szvQ== X-Gm-Message-State: AOAM530mWoGjxo9AIXCbMppZ7DOjUcr0PisABQfMYGYr3olSek95t+yV WWCjCiGjcnopiYoeZAZ7QtypWbFy2VzuJYnsKoOkbOa+p+p8Z1gu9zdRi93YfUt7HNhCnW4ES5d nvIdDBiSvlX01vJ6GT5M5G7U+D2pX0MdFNBJO6Jx6tIazYNKPe4Qf7owhuCyQetmI X-Received: by 2002:adf:d1c1:0:b0:20c:ba83:d57e with SMTP id b1-20020adfd1c1000000b0020cba83d57emr18522032wrd.87.1652787330397; Tue, 17 May 2022 04:35:30 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwDpe5vgCcpurb7ukn9U6GgN6wPDlUfLcyFwxEh3cBm2ckaQNF78H9cghg4dHa2zhKNgDNUcQ== X-Received: by 2002:adf:d1c1:0:b0:20c:ba83:d57e with SMTP id b1-20020adfd1c1000000b0020cba83d57emr18521970wrd.87.1652787329949; Tue, 17 May 2022 04:35:29 -0700 (PDT) From: Alberto Faria To: qemu-devel@nongnu.org Cc: Andrew Jeffery , Peter Maydell , qemu-block@nongnu.org, Palmer Dabbelt , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , qemu-ppc@nongnu.org, Eric Blake , Vladimir Sementsov-Ogievskiy , Hanna Reitz , John Snow , Stefan Hajnoczi , Jeff Cody , qemu-riscv@nongnu.org, =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Joel Stanley , Stefan Weil , Laurent Vivier , "Denis V. Lunev" , Juan Quintela , "Dr. David Alan Gilbert" , Niek Linnenbank , Greg Kurz , Daniel Henrique Barboza , Kevin Wolf , "Edgar E. Iglesias" , qemu-arm@nongnu.org, Fam Zheng , Alistair Francis , Beniamino Galvani , Bin Meng , David Gibson , Alberto Faria Subject: [PATCH 01/18] block: Make blk_{pread,pwrite}() return 0 on success Date: Tue, 17 May 2022 12:35:07 +0100 Message-Id: <20220517113524.197910-2-afaria@redhat.com> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20220517113524.197910-1-afaria@redhat.com> References: <20220517113524.197910-1-afaria@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.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; Received-SPF: pass client-ip=170.10.133.124; envelope-from=afaria@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1652791477359100001 Content-Type: text/plain; charset="utf-8" They currently return the value of their 'bytes' parameter on success. Make them return 0 instead, for consistency with other I/O functions and in preparation to implement them using generated_co_wrapper. This also makes it clear that short reads/writes are not possible. Signed-off-by: Alberto Faria Reviewed-by: Eric Blake Reviewed-by: Greg Kurz Reviewed-by: Hanna Reitz --- block.c | 8 +++++--- block/block-backend.c | 7 ++----- block/qcow.c | 6 +++--- hw/block/m25p80.c | 2 +- hw/misc/mac_via.c | 2 +- hw/misc/sifive_u_otp.c | 2 +- hw/nvram/eeprom_at24c.c | 4 ++-- hw/nvram/spapr_nvram.c | 12 ++++++------ hw/ppc/pnv_pnor.c | 2 +- qemu-img.c | 17 +++++++---------- qemu-io-cmds.c | 18 ++++++++++++------ tests/unit/test-block-iothread.c | 4 ++-- 12 files changed, 43 insertions(+), 41 deletions(-) diff --git a/block.c b/block.c index 2c00dddd80..0fd830e2e2 100644 --- a/block.c +++ b/block.c @@ -1045,14 +1045,16 @@ static int find_image_format(BlockBackend *file, co= nst char *filename, return ret; } =20 - drv =3D bdrv_probe_all(buf, ret, filename); + drv =3D bdrv_probe_all(buf, sizeof(buf), filename); if (!drv) { error_setg(errp, "Could not determine image format: No compatible " "driver found"); - ret =3D -ENOENT; + *pdrv =3D NULL; + return -ENOENT; } + *pdrv =3D drv; - return ret; + return 0; } =20 /** diff --git a/block/block-backend.c b/block/block-backend.c index e0e1aff4b1..c1c367bf9e 100644 --- a/block/block-backend.c +++ b/block/block-backend.c @@ -1577,19 +1577,16 @@ int blk_pread(BlockBackend *blk, int64_t offset, vo= id *buf, int bytes) ret =3D blk_do_preadv(blk, offset, bytes, &qiov, 0); blk_dec_in_flight(blk); =20 - return ret < 0 ? ret : bytes; + return ret; } =20 int blk_pwrite(BlockBackend *blk, int64_t offset, const void *buf, int byt= es, BdrvRequestFlags flags) { - int ret; QEMUIOVector qiov =3D QEMU_IOVEC_INIT_BUF(qiov, buf, bytes); IO_OR_GS_CODE(); =20 - ret =3D blk_pwritev_part(blk, offset, bytes, &qiov, 0, flags); - - return ret < 0 ? ret : bytes; + return blk_pwritev_part(blk, offset, bytes, &qiov, 0, flags); } =20 int64_t blk_getlength(BlockBackend *blk) diff --git a/block/qcow.c b/block/qcow.c index c646d6b16d..25a43353c1 100644 --- a/block/qcow.c +++ b/block/qcow.c @@ -891,14 +891,14 @@ static int coroutine_fn qcow_co_create(BlockdevCreate= Options *opts, =20 /* write all the data */ ret =3D blk_pwrite(qcow_blk, 0, &header, sizeof(header), 0); - if (ret !=3D sizeof(header)) { + if (ret < 0) { goto exit; } =20 if (qcow_opts->has_backing_file) { ret =3D blk_pwrite(qcow_blk, sizeof(header), qcow_opts->backing_file, backing_filename_len, 0); - if (ret !=3D backing_filename_len) { + if (ret < 0) { goto exit; } } @@ -908,7 +908,7 @@ static int coroutine_fn qcow_co_create(BlockdevCreateOp= tions *opts, i++) { ret =3D blk_pwrite(qcow_blk, header_size + BDRV_SECTOR_SIZE * i, tmp, BDRV_SECTOR_SIZE, 0); - if (ret !=3D BDRV_SECTOR_SIZE) { + if (ret < 0) { g_free(tmp); goto exit; } diff --git a/hw/block/m25p80.c b/hw/block/m25p80.c index 7d3d8b12e0..bd58c07bb6 100644 --- a/hw/block/m25p80.c +++ b/hw/block/m25p80.c @@ -1506,7 +1506,7 @@ static void m25p80_realize(SSIPeripheral *ss, Error *= *errp) trace_m25p80_binding(s); s->storage =3D blk_blockalign(s->blk, s->size); =20 - if (blk_pread(s->blk, 0, s->storage, s->size) !=3D s->size) { + if (blk_pread(s->blk, 0, s->storage, s->size) < 0) { error_setg(errp, "failed to read the initial flash content"); return; } diff --git a/hw/misc/mac_via.c b/hw/misc/mac_via.c index 525e38ce93..0515d1818e 100644 --- a/hw/misc/mac_via.c +++ b/hw/misc/mac_via.c @@ -1030,7 +1030,7 @@ static void mos6522_q800_via1_realize(DeviceState *de= v, Error **errp) } =20 len =3D blk_pread(v1s->blk, 0, v1s->PRAM, sizeof(v1s->PRAM)); - if (len !=3D sizeof(v1s->PRAM)) { + if (len < 0) { error_setg(errp, "can't read PRAM contents"); return; } diff --git a/hw/misc/sifive_u_otp.c b/hw/misc/sifive_u_otp.c index 6d5f84e6c2..535acde08b 100644 --- a/hw/misc/sifive_u_otp.c +++ b/hw/misc/sifive_u_otp.c @@ -240,7 +240,7 @@ static void sifive_u_otp_realize(DeviceState *dev, Erro= r **errp) return; } =20 - if (blk_pread(s->blk, 0, s->fuse, filesize) !=3D filesize) { + if (blk_pread(s->blk, 0, s->fuse, filesize) < 0) { error_setg(errp, "failed to read the initial flash content= "); return; } diff --git a/hw/nvram/eeprom_at24c.c b/hw/nvram/eeprom_at24c.c index 01a3093600..84acd71f5a 100644 --- a/hw/nvram/eeprom_at24c.c +++ b/hw/nvram/eeprom_at24c.c @@ -65,7 +65,7 @@ int at24c_eeprom_event(I2CSlave *s, enum i2c_event event) DPRINTK("clear\n"); if (ee->blk && ee->changed) { int len =3D blk_pwrite(ee->blk, 0, ee->mem, ee->rsize, 0); - if (len !=3D ee->rsize) { + if (len < 0) { ERR(TYPE_AT24C_EE " : failed to write backing file\n"); } @@ -165,7 +165,7 @@ void at24c_eeprom_reset(DeviceState *state) if (ee->blk) { int len =3D blk_pread(ee->blk, 0, ee->mem, ee->rsize); =20 - if (len !=3D ee->rsize) { + if (len < 0) { ERR(TYPE_AT24C_EE " : Failed initial sync with backing file\n"); } diff --git a/hw/nvram/spapr_nvram.c b/hw/nvram/spapr_nvram.c index 18b43be7f6..6000b945c3 100644 --- a/hw/nvram/spapr_nvram.c +++ b/hw/nvram/spapr_nvram.c @@ -103,7 +103,7 @@ static void rtas_nvram_store(PowerPCCPU *cpu, SpaprMach= ineState *spapr, { SpaprNvram *nvram =3D spapr->nvram; hwaddr offset, buffer, len; - int alen; + int ret; void *membuf; =20 if ((nargs !=3D 3) || (nret !=3D 2)) { @@ -128,9 +128,9 @@ static void rtas_nvram_store(PowerPCCPU *cpu, SpaprMach= ineState *spapr, =20 membuf =3D cpu_physical_memory_map(buffer, &len, false); =20 - alen =3D len; + ret =3D 0; if (nvram->blk) { - alen =3D blk_pwrite(nvram->blk, offset, membuf, len, 0); + ret =3D blk_pwrite(nvram->blk, offset, membuf, len, 0); } =20 assert(nvram->buf); @@ -138,8 +138,8 @@ static void rtas_nvram_store(PowerPCCPU *cpu, SpaprMach= ineState *spapr, =20 cpu_physical_memory_unmap(membuf, len, 0, len); =20 - rtas_st(rets, 0, (alen < len) ? RTAS_OUT_HW_ERROR : RTAS_OUT_SUCCESS); - rtas_st(rets, 1, (alen < 0) ? 0 : alen); + rtas_st(rets, 0, (ret < 0) ? RTAS_OUT_HW_ERROR : RTAS_OUT_SUCCESS); + rtas_st(rets, 1, (ret < 0) ? 0 : len); } =20 static void spapr_nvram_realize(SpaprVioDevice *dev, Error **errp) @@ -181,7 +181,7 @@ static void spapr_nvram_realize(SpaprVioDevice *dev, Er= ror **errp) if (nvram->blk) { int alen =3D blk_pread(nvram->blk, 0, nvram->buf, nvram->size); =20 - if (alen !=3D nvram->size) { + if (alen < 0) { error_setg(errp, "can't read spapr-nvram contents"); return; } diff --git a/hw/ppc/pnv_pnor.c b/hw/ppc/pnv_pnor.c index 83ecccca28..1fb748afef 100644 --- a/hw/ppc/pnv_pnor.c +++ b/hw/ppc/pnv_pnor.c @@ -99,7 +99,7 @@ static void pnv_pnor_realize(DeviceState *dev, Error **er= rp) =20 s->storage =3D blk_blockalign(s->blk, s->size); =20 - if (blk_pread(s->blk, 0, s->storage, s->size) !=3D s->size) { + if (blk_pread(s->blk, 0, s->storage, s->size) < 0) { error_setg(errp, "failed to read the initial flash content"); return; } diff --git a/qemu-img.c b/qemu-img.c index 4cf4d2423d..9d98ef63ac 100644 --- a/qemu-img.c +++ b/qemu-img.c @@ -5120,30 +5120,27 @@ static int img_dd(int argc, char **argv) in.buf =3D g_new(uint8_t, in.bsz); =20 for (out_pos =3D 0; in_pos < size; block_count++) { - int in_ret, out_ret; + int bytes, in_ret, out_ret; =20 - if (in_pos + in.bsz > size) { - in_ret =3D blk_pread(blk1, in_pos, in.buf, size - in_pos); - } else { - in_ret =3D blk_pread(blk1, in_pos, in.buf, in.bsz); - } + bytes =3D (in_pos + in.bsz > size) ? size - in_pos : in.bsz; + + in_ret =3D blk_pread(blk1, in_pos, in.buf, bytes); if (in_ret < 0) { error_report("error while reading from input image file: %s", strerror(-in_ret)); ret =3D -1; goto out; } - in_pos +=3D in_ret; - - out_ret =3D blk_pwrite(blk2, out_pos, in.buf, in_ret, 0); + in_pos +=3D bytes; =20 + out_ret =3D blk_pwrite(blk2, out_pos, in.buf, bytes, 0); if (out_ret < 0) { error_report("error while writing to output image file: %s", strerror(-out_ret)); ret =3D -1; goto out; } - out_pos +=3D out_ret; + out_pos +=3D bytes; } =20 out: diff --git a/qemu-io-cmds.c b/qemu-io-cmds.c index 2f0d8ac25a..443f22c732 100644 --- a/qemu-io-cmds.c +++ b/qemu-io-cmds.c @@ -541,28 +541,34 @@ fail: static int do_pread(BlockBackend *blk, char *buf, int64_t offset, int64_t bytes, int64_t *total) { + int ret; + if (bytes > INT_MAX) { return -ERANGE; } =20 - *total =3D blk_pread(blk, offset, (uint8_t *)buf, bytes); - if (*total < 0) { - return *total; + ret =3D blk_pread(blk, offset, (uint8_t *)buf, bytes); + if (ret < 0) { + return ret; } + *total =3D bytes; return 1; } =20 static int do_pwrite(BlockBackend *blk, char *buf, int64_t offset, int64_t bytes, int flags, int64_t *total) { + int ret; + if (bytes > INT_MAX) { return -ERANGE; } =20 - *total =3D blk_pwrite(blk, offset, (uint8_t *)buf, bytes, flags); - if (*total < 0) { - return *total; + ret =3D blk_pwrite(blk, offset, (uint8_t *)buf, bytes, flags); + if (ret < 0) { + return ret; } + *total =3D bytes; return 1; } =20 diff --git a/tests/unit/test-block-iothread.c b/tests/unit/test-block-iothr= ead.c index a5c163af7e..3c1a3f64a2 100644 --- a/tests/unit/test-block-iothread.c +++ b/tests/unit/test-block-iothread.c @@ -117,7 +117,7 @@ static void test_sync_op_blk_pread(BlockBackend *blk) =20 /* Success */ ret =3D blk_pread(blk, 0, buf, sizeof(buf)); - g_assert_cmpint(ret, =3D=3D, 512); + g_assert_cmpint(ret, =3D=3D, 0); =20 /* Early error: Negative offset */ ret =3D blk_pread(blk, -2, buf, sizeof(buf)); @@ -131,7 +131,7 @@ static void test_sync_op_blk_pwrite(BlockBackend *blk) =20 /* Success */ ret =3D blk_pwrite(blk, 0, buf, sizeof(buf), 0); - g_assert_cmpint(ret, =3D=3D, 512); + g_assert_cmpint(ret, =3D=3D, 0); =20 /* Early error: Negative offset */ ret =3D blk_pwrite(blk, -2, buf, sizeof(buf), 0); --=20 2.35.3 From nobody Sat Apr 27 06:34:22 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1652792871; cv=none; d=zohomail.com; s=zohoarc; b=N1v3ZeqdebAK0fknBouneonzu4YnRgV2bC7WSrQ/xDD+rwZ/afxlz5X3rUI1aCbj8V4MiGgDZIMuZ1hY/ppX8bn5M/NZ65p5soRyrW52aW/57ivCGUPWf6f2tarw254kitOMGjfRt9x8wFBJNz2ZGQup0jueVZid3Mvgm7H/PIk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1652792871; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=/spn7qNTtD3lckTp4fAl+CzLsDyHAsboq6Idj6mzE24=; b=QDdeQoskLUGw/JL1bM4ZTPPbxiWzZ5iA6VF17xsAyW5XwbBWF5TyrfxUSsjg1d/YnCiLE7UfuIa1lSky0a/dD3nIO87xhye4WPTEo6Bgl8wIhpRvBKzyiRNSd4+zY2kEcHZa5MYyjqxBGSUH6J6mGAe80SF/qMvijPJ0xyq6Rc0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 165279287108975.8177094294748; Tue, 17 May 2022 06:07:51 -0700 (PDT) Received: from localhost ([::1]:56066 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nqwvV-0003Dc-PQ for importer@patchew.org; Tue, 17 May 2022 09:07:49 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41758) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nqvUL-0007I1-MM for qemu-devel@nongnu.org; Tue, 17 May 2022 07:35:41 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:47673) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nqvUH-0002dJ-PG for qemu-devel@nongnu.org; Tue, 17 May 2022 07:35:41 -0400 Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-29-r1h3Px8eNKaYbPzLFTK30w-1; Tue, 17 May 2022 07:35:34 -0400 Received: by mail-wm1-f70.google.com with SMTP id v124-20020a1cac82000000b003948b870a8dso1145620wme.2 for ; Tue, 17 May 2022 04:35:34 -0700 (PDT) Received: from fedora.redhat.com ([2001:8a0:f4d9:2101:a4fa:5f93:755f:6249]) by smtp.gmail.com with ESMTPSA id m14-20020a5d64ae000000b0020d0fbf578esm4570177wrp.7.2022.05.17.04.35.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 May 2022 04:35:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1652787336; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=/spn7qNTtD3lckTp4fAl+CzLsDyHAsboq6Idj6mzE24=; b=Rxaxi1bYSUa1AbaNkIEOM9oe7ptlC3HiVzxdoysZWBA1wPJHMqwTgWDJq9Y0hCjChESLZf Gseyondti9QahKUaRab3C0+OcL7po1+iZLWlzZfeMBUemUw02e4sP2U0LCvL7ASMTElKhM 05fjN1z8HiWS7v6SbRr5ODdl/yh29YQ= X-MC-Unique: r1h3Px8eNKaYbPzLFTK30w-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=/spn7qNTtD3lckTp4fAl+CzLsDyHAsboq6Idj6mzE24=; b=NaJAHDAby94qaE9oxMKJjMrB8GmosxuqRP1HhZfLCtwZuNLHM1vdqQDDNUhWnZozPb XeWvkcwL3W/tTSNsnUUivMROaDINHi/4b17KXb4GMXAE0KiEtIt817cFOS8Kl+zd3TCw dfwIv8Gq+hotyi5oFQD72uCS2LcJC5BRwKJ4LrNVK6hmmyrGtjNH0gQHEKvOms7XHtdL hVT/U5B75yRGoQG1sDvEdxmwTxcxE1o8+Mwl1Hhs2w0KdQOvkdspw9NaWAxpibHMhZzL b61da1PS9YCYAqX8WJB9HpWT9Ck/siqJEeOiQW7oV9vemB/YeFeeLiA1NxzH7R9YZZhu mBZg== X-Gm-Message-State: AOAM530GxBr92WJ+U2HRifu44T3e0Xk+FF6HaavOSW6McIiK4XRWpa/T 1GIA8Od5yOWB/1BAy21ZrRC4ag6XKnbgFWqFFYiyD0CCydYF1dyF8OQ0B0bh7nXN1SKr22Mo4Xt 8FjdRWeLQyatasrs9r8imkROdA6GWjdfYSChKwdzUmW1wO/djxOwXGiiWDC6hxdZj X-Received: by 2002:a05:600c:3b04:b0:394:6150:db8f with SMTP id m4-20020a05600c3b0400b003946150db8fmr20851585wms.183.1652787333121; Tue, 17 May 2022 04:35:33 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzRcVLLksH4jcqoFwD2+6Ssdnoj/z5p95KZTB4ITf9haKrEwP12lda9gw9VKsZhJPqiVtJ42A== X-Received: by 2002:a05:600c:3b04:b0:394:6150:db8f with SMTP id m4-20020a05600c3b0400b003946150db8fmr20851505wms.183.1652787332376; Tue, 17 May 2022 04:35:32 -0700 (PDT) From: Alberto Faria To: qemu-devel@nongnu.org Cc: Andrew Jeffery , Peter Maydell , qemu-block@nongnu.org, Palmer Dabbelt , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , qemu-ppc@nongnu.org, Eric Blake , Vladimir Sementsov-Ogievskiy , Hanna Reitz , John Snow , Stefan Hajnoczi , Jeff Cody , qemu-riscv@nongnu.org, =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Joel Stanley , Stefan Weil , Laurent Vivier , "Denis V. Lunev" , Juan Quintela , "Dr. David Alan Gilbert" , Niek Linnenbank , Greg Kurz , Daniel Henrique Barboza , Kevin Wolf , "Edgar E. Iglesias" , qemu-arm@nongnu.org, Fam Zheng , Alistair Francis , Beniamino Galvani , Bin Meng , David Gibson , Alberto Faria Subject: [PATCH 02/18] block: Add a 'flags' param to blk_pread() Date: Tue, 17 May 2022 12:35:08 +0100 Message-Id: <20220517113524.197910-3-afaria@redhat.com> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20220517113524.197910-1-afaria@redhat.com> References: <20220517113524.197910-1-afaria@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.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; Received-SPF: pass client-ip=170.10.129.124; envelope-from=afaria@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1652792872330100001 Content-Type: text/plain; charset="utf-8" For consistency with other I/O functions, and in preparation to implement it using generated_co_wrapper. Callers were updated using this Coccinelle script: @@ expression blk, offset, buf, bytes; @@ - blk_pread(blk, offset, buf, bytes) + blk_pread(blk, offset, buf, bytes, 0) It had no effect on hw/block/nand.c, presumably due to the #if, so that file was updated manually. Overly-long lines were then fixed by hand. Signed-off-by: Alberto Faria Reviewed-by: Greg Kurz Reviewed-by: Hanna Reitz Reviewed-by: Paolo Bonzini --- block.c | 2 +- block/block-backend.c | 5 +++-- block/commit.c | 2 +- block/export/fuse.c | 2 +- hw/arm/allwinner-h3.c | 2 +- hw/arm/aspeed.c | 2 +- hw/block/block.c | 2 +- hw/block/fdc.c | 6 +++--- hw/block/hd-geometry.c | 2 +- hw/block/m25p80.c | 2 +- hw/block/nand.c | 12 ++++++------ hw/block/onenand.c | 12 ++++++------ hw/ide/atapi.c | 4 ++-- hw/misc/mac_via.c | 2 +- hw/misc/sifive_u_otp.c | 4 ++-- hw/nvram/eeprom_at24c.c | 2 +- hw/nvram/spapr_nvram.c | 2 +- hw/nvram/xlnx-bbram.c | 2 +- hw/nvram/xlnx-efuse.c | 2 +- hw/ppc/pnv_pnor.c | 2 +- hw/sd/sd.c | 2 +- include/sysemu/block-backend-io.h | 3 ++- migration/block.c | 4 ++-- nbd/server.c | 4 ++-- qemu-img.c | 12 ++++++------ qemu-io-cmds.c | 2 +- tests/unit/test-block-iothread.c | 4 ++-- 27 files changed, 52 insertions(+), 50 deletions(-) diff --git a/block.c b/block.c index 0fd830e2e2..ed701b4889 100644 --- a/block.c +++ b/block.c @@ -1037,7 +1037,7 @@ static int find_image_format(BlockBackend *file, cons= t char *filename, return ret; } =20 - ret =3D blk_pread(file, 0, buf, sizeof(buf)); + ret =3D blk_pread(file, 0, buf, sizeof(buf), 0); if (ret < 0) { error_setg_errno(errp, -ret, "Could not read image for determining= its " "format"); diff --git a/block/block-backend.c b/block/block-backend.c index c1c367bf9e..da89450861 100644 --- a/block/block-backend.c +++ b/block/block-backend.c @@ -1567,14 +1567,15 @@ BlockAIOCB *blk_aio_pwrite_zeroes(BlockBackend *blk= , int64_t offset, flags | BDRV_REQ_ZERO_WRITE, cb, opaque); } =20 -int blk_pread(BlockBackend *blk, int64_t offset, void *buf, int bytes) +int blk_pread(BlockBackend *blk, int64_t offset, void *buf, int bytes, + BdrvRequestFlags flags) { int ret; QEMUIOVector qiov =3D QEMU_IOVEC_INIT_BUF(qiov, buf, bytes); IO_OR_GS_CODE(); =20 blk_inc_in_flight(blk); - ret =3D blk_do_preadv(blk, offset, bytes, &qiov, 0); + ret =3D blk_do_preadv(blk, offset, bytes, &qiov, flags); blk_dec_in_flight(blk); =20 return ret; diff --git a/block/commit.c b/block/commit.c index 851d1c557a..e5b3ad08da 100644 --- a/block/commit.c +++ b/block/commit.c @@ -527,7 +527,7 @@ int bdrv_commit(BlockDriverState *bs) goto ro_cleanup; } if (ret) { - ret =3D blk_pread(src, offset, buf, n); + ret =3D blk_pread(src, offset, buf, n, 0); if (ret < 0) { goto ro_cleanup; } diff --git a/block/export/fuse.c b/block/export/fuse.c index e80b24a867..dcf8f225f3 100644 --- a/block/export/fuse.c +++ b/block/export/fuse.c @@ -554,7 +554,7 @@ static void fuse_read(fuse_req_t req, fuse_ino_t inode, return; } =20 - ret =3D blk_pread(exp->common.blk, offset, buf, size); + ret =3D blk_pread(exp->common.blk, offset, buf, size, 0); if (ret >=3D 0) { fuse_reply_buf(req, buf, size); } else { diff --git a/hw/arm/allwinner-h3.c b/hw/arm/allwinner-h3.c index 318ed4348c..788083b6fa 100644 --- a/hw/arm/allwinner-h3.c +++ b/hw/arm/allwinner-h3.c @@ -174,7 +174,7 @@ void allwinner_h3_bootrom_setup(AwH3State *s, BlockBack= end *blk) const int64_t rom_size =3D 32 * KiB; g_autofree uint8_t *buffer =3D g_new0(uint8_t, rom_size); =20 - if (blk_pread(blk, 8 * KiB, buffer, rom_size) < 0) { + if (blk_pread(blk, 8 * KiB, buffer, rom_size, 0) < 0) { error_setg(&error_fatal, "%s: failed to read BlockBackend data", __func__); return; diff --git a/hw/arm/aspeed.c b/hw/arm/aspeed.c index a74c13ab0f..06ab8cd0a5 100644 --- a/hw/arm/aspeed.c +++ b/hw/arm/aspeed.c @@ -269,7 +269,7 @@ static void write_boot_rom(DriveInfo *dinfo, hwaddr add= r, size_t rom_size, } =20 storage =3D g_malloc0(rom_size); - if (blk_pread(blk, 0, storage, rom_size) < 0) { + if (blk_pread(blk, 0, storage, rom_size, 0) < 0) { error_setg(errp, "failed to read the initial flash content"); return; } diff --git a/hw/block/block.c b/hw/block/block.c index 25f45df723..effb89910c 100644 --- a/hw/block/block.c +++ b/hw/block/block.c @@ -53,7 +53,7 @@ bool blk_check_size_and_read_all(BlockBackend *blk, void = *buf, hwaddr size, * block device and read only on demand. */ assert(size <=3D BDRV_REQUEST_MAX_BYTES); - ret =3D blk_pread(blk, 0, buf, size); + ret =3D blk_pread(blk, 0, buf, size, 0); if (ret < 0) { error_setg_errno(errp, -ret, "can't read block backend"); return false; diff --git a/hw/block/fdc.c b/hw/block/fdc.c index 57bb355794..52f278ed82 100644 --- a/hw/block/fdc.c +++ b/hw/block/fdc.c @@ -1628,8 +1628,8 @@ int fdctrl_transfer_handler(void *opaque, int nchan, = int dma_pos, int dma_len) if (fdctrl->data_dir !=3D FD_DIR_WRITE || len < FD_SECTOR_LEN || rel_pos !=3D 0) { /* READ & SCAN commands and realign to a sector for WRITE */ - if (blk_pread(cur_drv->blk, fd_offset(cur_drv), - fdctrl->fifo, BDRV_SECTOR_SIZE) < 0) { + if (blk_pread(cur_drv->blk, fd_offset(cur_drv), fdctrl->fifo, + BDRV_SECTOR_SIZE, 0) < 0) { FLOPPY_DPRINTF("Floppy: error getting sector %d\n", fd_sector(cur_drv)); /* Sure, image size is too small... */ @@ -1741,7 +1741,7 @@ static uint32_t fdctrl_read_data(FDCtrl *fdctrl) return 0; } if (blk_pread(cur_drv->blk, fd_offset(cur_drv), fdctrl->fifo, - BDRV_SECTOR_SIZE) + BDRV_SECTOR_SIZE, 0) < 0) { FLOPPY_DPRINTF("error getting sector %d\n", fd_sector(cur_drv)); diff --git a/hw/block/hd-geometry.c b/hw/block/hd-geometry.c index dcbccee294..24933eae82 100644 --- a/hw/block/hd-geometry.c +++ b/hw/block/hd-geometry.c @@ -63,7 +63,7 @@ static int guess_disk_lchs(BlockBackend *blk, =20 blk_get_geometry(blk, &nb_sectors); =20 - if (blk_pread(blk, 0, buf, BDRV_SECTOR_SIZE) < 0) { + if (blk_pread(blk, 0, buf, BDRV_SECTOR_SIZE, 0) < 0) { return -1; } /* test msdos magic */ diff --git a/hw/block/m25p80.c b/hw/block/m25p80.c index bd58c07bb6..3e93769fed 100644 --- a/hw/block/m25p80.c +++ b/hw/block/m25p80.c @@ -1506,7 +1506,7 @@ static void m25p80_realize(SSIPeripheral *ss, Error *= *errp) trace_m25p80_binding(s); s->storage =3D blk_blockalign(s->blk, s->size); =20 - if (blk_pread(s->blk, 0, s->storage, s->size) < 0) { + if (blk_pread(s->blk, 0, s->storage, s->size, 0) < 0) { error_setg(errp, "failed to read the initial flash content"); return; } diff --git a/hw/block/nand.c b/hw/block/nand.c index 8bc80e3514..ea3d33adf4 100644 --- a/hw/block/nand.c +++ b/hw/block/nand.c @@ -667,7 +667,7 @@ static void glue(nand_blk_write_, NAND_PAGE_SIZE)(NANDF= lashState *s) off =3D (s->addr & PAGE_MASK) + s->offset; soff =3D SECTOR_OFFSET(s->addr); if (blk_pread(s->blk, sector << BDRV_SECTOR_BITS, iobuf, - PAGE_SECTORS << BDRV_SECTOR_BITS) < 0) { + PAGE_SECTORS << BDRV_SECTOR_BITS, 0) < 0) { printf("%s: read error in sector %" PRIu64 "\n", __func__, sec= tor); return; } @@ -688,7 +688,7 @@ static void glue(nand_blk_write_, NAND_PAGE_SIZE)(NANDF= lashState *s) sector =3D off >> 9; soff =3D off & 0x1ff; if (blk_pread(s->blk, sector << BDRV_SECTOR_BITS, iobuf, - (PAGE_SECTORS + 2) << BDRV_SECTOR_BITS) < 0) { + (PAGE_SECTORS + 2) << BDRV_SECTOR_BITS, 0) < 0) { printf("%s: read error in sector %" PRIu64 "\n", __func__, sec= tor); return; } @@ -731,7 +731,7 @@ static void glue(nand_blk_erase_, NAND_PAGE_SIZE)(NANDF= lashState *s) addr =3D PAGE_START(addr); page =3D addr >> 9; if (blk_pread(s->blk, page << BDRV_SECTOR_BITS, iobuf, - BDRV_SECTOR_SIZE) < 0) { + BDRV_SECTOR_SIZE, 0) < 0) { printf("%s: read error in sector %" PRIu64 "\n", __func__, pag= e); } memset(iobuf + (addr & 0x1ff), 0xff, (~addr & 0x1ff) + 1); @@ -752,7 +752,7 @@ static void glue(nand_blk_erase_, NAND_PAGE_SIZE)(NANDF= lashState *s) =20 page =3D i >> 9; if (blk_pread(s->blk, page << BDRV_SECTOR_BITS, iobuf, - BDRV_SECTOR_SIZE) < 0) { + BDRV_SECTOR_SIZE, 0) < 0) { printf("%s: read error in sector %" PRIu64 "\n", __func__, pag= e); } memset(iobuf, 0xff, ((addr - 1) & 0x1ff) + 1); @@ -773,7 +773,7 @@ static void glue(nand_blk_load_, NAND_PAGE_SIZE)(NANDFl= ashState *s, if (s->blk) { if (s->mem_oob) { if (blk_pread(s->blk, SECTOR(addr) << BDRV_SECTOR_BITS, s->io, - PAGE_SECTORS << BDRV_SECTOR_BITS) < 0) { + PAGE_SECTORS << BDRV_SECTOR_BITS, 0) < 0) { printf("%s: read error in sector %" PRIu64 "\n", __func__, SECTOR(addr)); } @@ -783,7 +783,7 @@ static void glue(nand_blk_load_, NAND_PAGE_SIZE)(NANDFl= ashState *s, s->ioaddr =3D s->io + SECTOR_OFFSET(s->addr) + offset; } else { if (blk_pread(s->blk, PAGE_START(addr), s->io, - (PAGE_SECTORS + 2) << BDRV_SECTOR_BITS) < 0) { + (PAGE_SECTORS + 2) << BDRV_SECTOR_BITS, 0) < 0) { printf("%s: read error in sector %" PRIu64 "\n", __func__, PAGE_START(addr) >> 9); } diff --git a/hw/block/onenand.c b/hw/block/onenand.c index afc0cd3a0f..1225ec8076 100644 --- a/hw/block/onenand.c +++ b/hw/block/onenand.c @@ -230,7 +230,7 @@ static void onenand_reset(OneNANDState *s, int cold) memset(s->blockwp, ONEN_LOCK_LOCKED, s->blocks); =20 if (s->blk_cur && blk_pread(s->blk_cur, 0, s->boot[0], - 8 << BDRV_SECTOR_BITS) < 0) { + 8 << BDRV_SECTOR_BITS, 0) < 0) { hw_error("%s: Loading the BootRAM failed.\n", __func__); } } @@ -250,7 +250,7 @@ static inline int onenand_load_main(OneNANDState *s, in= t sec, int secn, assert(UINT32_MAX >> BDRV_SECTOR_BITS > secn); if (s->blk_cur) { return blk_pread(s->blk_cur, sec << BDRV_SECTOR_BITS, dest, - secn << BDRV_SECTOR_BITS) < 0; + secn << BDRV_SECTOR_BITS, 0) < 0; } else if (sec + secn > s->secs_cur) { return 1; } @@ -274,7 +274,7 @@ static inline int onenand_prog_main(OneNANDState *s, in= t sec, int secn, uint8_t *dp =3D 0; if (s->blk_cur) { dp =3D g_malloc(size); - if (!dp || blk_pread(s->blk_cur, offset, dp, size) < 0) { + if (!dp || blk_pread(s->blk_cur, offset, dp, size, 0) < 0) { result =3D 1; } } else { @@ -308,7 +308,7 @@ static inline int onenand_load_spare(OneNANDState *s, i= nt sec, int secn, =20 if (s->blk_cur) { uint32_t offset =3D (s->secs_cur + (sec >> 5)) << BDRV_SECTOR_BITS; - if (blk_pread(s->blk_cur, offset, buf, BDRV_SECTOR_SIZE) < 0) { + if (blk_pread(s->blk_cur, offset, buf, BDRV_SECTOR_SIZE, 0) < 0) { return 1; } memcpy(dest, buf + ((sec & 31) << 4), secn << 4); @@ -333,7 +333,7 @@ static inline int onenand_prog_spare(OneNANDState *s, i= nt sec, int secn, if (s->blk_cur) { dp =3D g_malloc(512); if (!dp - || blk_pread(s->blk_cur, offset, dp, BDRV_SECTOR_SIZE) < 0= ) { + || blk_pread(s->blk_cur, offset, dp, BDRV_SECTOR_SIZE, 0) = < 0) { result =3D 1; } else { dpp =3D dp + ((sec & 31) << 4); @@ -375,7 +375,7 @@ static inline int onenand_erase(OneNANDState *s, int se= c, int num) goto fail; } if (blk_pread(s->blk_cur, erasesec << BDRV_SECTOR_BITS, tmpbuf, - BDRV_SECTOR_SIZE) < 0) { + BDRV_SECTOR_SIZE, 0) < 0) { goto fail; } memcpy(tmpbuf + ((sec & 31) << 4), blankbuf, 1 << 4); diff --git a/hw/ide/atapi.c b/hw/ide/atapi.c index b626199e3d..7e405657df 100644 --- a/hw/ide/atapi.c +++ b/hw/ide/atapi.c @@ -98,11 +98,11 @@ cd_read_sector_sync(IDEState *s) switch (s->cd_sector_size) { case 2048: ret =3D blk_pread(s->blk, (int64_t)s->lba << ATAPI_SECTOR_BITS, - s->io_buffer, ATAPI_SECTOR_SIZE); + s->io_buffer, ATAPI_SECTOR_SIZE, 0); break; case 2352: ret =3D blk_pread(s->blk, (int64_t)s->lba << ATAPI_SECTOR_BITS, - s->io_buffer + 16, ATAPI_SECTOR_SIZE); + s->io_buffer + 16, ATAPI_SECTOR_SIZE, 0); if (ret >=3D 0) { cd_data_to_raw(s->io_buffer, s->lba); } diff --git a/hw/misc/mac_via.c b/hw/misc/mac_via.c index 0515d1818e..d259def2d2 100644 --- a/hw/misc/mac_via.c +++ b/hw/misc/mac_via.c @@ -1029,7 +1029,7 @@ static void mos6522_q800_via1_realize(DeviceState *de= v, Error **errp) return; } =20 - len =3D blk_pread(v1s->blk, 0, v1s->PRAM, sizeof(v1s->PRAM)); + len =3D blk_pread(v1s->blk, 0, v1s->PRAM, sizeof(v1s->PRAM), 0); if (len < 0) { error_setg(errp, "can't read PRAM contents"); return; diff --git a/hw/misc/sifive_u_otp.c b/hw/misc/sifive_u_otp.c index 535acde08b..c730bb1ae0 100644 --- a/hw/misc/sifive_u_otp.c +++ b/hw/misc/sifive_u_otp.c @@ -65,7 +65,7 @@ static uint64_t sifive_u_otp_read(void *opaque, hwaddr ad= dr, unsigned int size) int32_t buf; =20 if (blk_pread(s->blk, s->pa * SIFIVE_U_OTP_FUSE_WORD, &buf, - SIFIVE_U_OTP_FUSE_WORD) < 0) { + SIFIVE_U_OTP_FUSE_WORD, 0) < 0) { error_report("read error index<%d>", s->pa); return 0xff; } @@ -240,7 +240,7 @@ static void sifive_u_otp_realize(DeviceState *dev, Erro= r **errp) return; } =20 - if (blk_pread(s->blk, 0, s->fuse, filesize) < 0) { + if (blk_pread(s->blk, 0, s->fuse, filesize, 0) < 0) { error_setg(errp, "failed to read the initial flash content= "); return; } diff --git a/hw/nvram/eeprom_at24c.c b/hw/nvram/eeprom_at24c.c index 84acd71f5a..876b3dd5dc 100644 --- a/hw/nvram/eeprom_at24c.c +++ b/hw/nvram/eeprom_at24c.c @@ -163,7 +163,7 @@ void at24c_eeprom_reset(DeviceState *state) memset(ee->mem, 0, ee->rsize); =20 if (ee->blk) { - int len =3D blk_pread(ee->blk, 0, ee->mem, ee->rsize); + int len =3D blk_pread(ee->blk, 0, ee->mem, ee->rsize, 0); =20 if (len < 0) { ERR(TYPE_AT24C_EE diff --git a/hw/nvram/spapr_nvram.c b/hw/nvram/spapr_nvram.c index 6000b945c3..4d32d92ad4 100644 --- a/hw/nvram/spapr_nvram.c +++ b/hw/nvram/spapr_nvram.c @@ -179,7 +179,7 @@ static void spapr_nvram_realize(SpaprVioDevice *dev, Er= ror **errp) } =20 if (nvram->blk) { - int alen =3D blk_pread(nvram->blk, 0, nvram->buf, nvram->size); + int alen =3D blk_pread(nvram->blk, 0, nvram->buf, nvram->size, 0); =20 if (alen < 0) { error_setg(errp, "can't read spapr-nvram contents"); diff --git a/hw/nvram/xlnx-bbram.c b/hw/nvram/xlnx-bbram.c index 6ed32adad9..cb245b864c 100644 --- a/hw/nvram/xlnx-bbram.c +++ b/hw/nvram/xlnx-bbram.c @@ -124,7 +124,7 @@ static void bbram_bdrv_read(XlnxBBRam *s, Error **errp) blk_name(s->blk)); } =20 - if (blk_pread(s->blk, 0, ram, nr) < 0) { + if (blk_pread(s->blk, 0, ram, nr, 0) < 0) { error_setg(errp, "%s: Failed to read %u bytes from BBRAM backstore.", blk_name(s->blk), nr); diff --git a/hw/nvram/xlnx-efuse.c b/hw/nvram/xlnx-efuse.c index a0fd77b586..edaac9cf7c 100644 --- a/hw/nvram/xlnx-efuse.c +++ b/hw/nvram/xlnx-efuse.c @@ -77,7 +77,7 @@ static int efuse_bdrv_read(XlnxEFuse *s, Error **errp) blk_name(s->blk)); } =20 - if (blk_pread(s->blk, 0, ram, nr) < 0) { + if (blk_pread(s->blk, 0, ram, nr, 0) < 0) { error_setg(errp, "%s: Failed to read %u bytes from eFUSE backstore= .", blk_name(s->blk), nr); return -1; diff --git a/hw/ppc/pnv_pnor.c b/hw/ppc/pnv_pnor.c index 1fb748afef..f341f5a9c9 100644 --- a/hw/ppc/pnv_pnor.c +++ b/hw/ppc/pnv_pnor.c @@ -99,7 +99,7 @@ static void pnv_pnor_realize(DeviceState *dev, Error **er= rp) =20 s->storage =3D blk_blockalign(s->blk, s->size); =20 - if (blk_pread(s->blk, 0, s->storage, s->size) < 0) { + if (blk_pread(s->blk, 0, s->storage, s->size, 0) < 0) { error_setg(errp, "failed to read the initial flash content"); return; } diff --git a/hw/sd/sd.c b/hw/sd/sd.c index 8e6fa09151..701170bf37 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -752,7 +752,7 @@ void sd_set_cb(SDState *sd, qemu_irq readonly, qemu_irq= insert) static void sd_blk_read(SDState *sd, uint64_t addr, uint32_t len) { trace_sdcard_read_block(addr, len); - if (!sd->blk || blk_pread(sd->blk, addr, sd->data, len) < 0) { + if (!sd->blk || blk_pread(sd->blk, addr, sd->data, len, 0) < 0) { fprintf(stderr, "sd_blk_read: read error on host side\n"); } } diff --git a/include/sysemu/block-backend-io.h b/include/sysemu/block-backe= nd-io.h index 6517c39295..288bf39be1 100644 --- a/include/sysemu/block-backend-io.h +++ b/include/sysemu/block-backend-io.h @@ -102,7 +102,8 @@ int coroutine_fn blk_co_copy_range(BlockBackend *blk_in= , int64_t off_in, * the "I/O or GS" API. */ =20 -int blk_pread(BlockBackend *blk, int64_t offset, void *buf, int bytes); +int blk_pread(BlockBackend *blk, int64_t offset, void *buf, int bytes, + BdrvRequestFlags flags); int blk_pwrite(BlockBackend *blk, int64_t offset, const void *buf, int byt= es, BdrvRequestFlags flags); int coroutine_fn blk_co_preadv(BlockBackend *blk, int64_t offset, diff --git a/migration/block.c b/migration/block.c index 077a413325..fa216af025 100644 --- a/migration/block.c +++ b/migration/block.c @@ -568,8 +568,8 @@ static int mig_save_device_dirty(QEMUFile *f, BlkMigDev= State *bmds, bmds_set_aio_inflight(bmds, sector, nr_sectors, 1); blk_mig_unlock(); } else { - ret =3D blk_pread(bmds->blk, sector * BDRV_SECTOR_SIZE, bl= k->buf, - nr_sectors * BDRV_SECTOR_SIZE); + ret =3D blk_pread(bmds->blk, sector * BDRV_SECTOR_SIZE, + blk->buf, nr_sectors * BDRV_SECTOR_SIZE, 0= ); if (ret < 0) { goto error; } diff --git a/nbd/server.c b/nbd/server.c index 213e00e761..849433aa3a 100644 --- a/nbd/server.c +++ b/nbd/server.c @@ -2040,7 +2040,7 @@ static int coroutine_fn nbd_co_send_sparse_read(NBDCl= ient *client, ret =3D nbd_co_send_iov(client, iov, 1, errp); } else { ret =3D blk_pread(exp->common.blk, offset + progress, - data + progress, pnum); + data + progress, pnum, 0); if (ret < 0) { error_setg_errno(errp, -ret, "reading from file failed"); break; @@ -2444,7 +2444,7 @@ static coroutine_fn int nbd_do_cmd_read(NBDClient *cl= ient, NBDRequest *request, data, request->len, errp); } =20 - ret =3D blk_pread(exp->common.blk, request->from, data, request->len); + ret =3D blk_pread(exp->common.blk, request->from, data, request->len, = 0); if (ret < 0) { return nbd_send_generic_reply(client, request->handle, ret, "reading from file failed", errp); diff --git a/qemu-img.c b/qemu-img.c index 9d98ef63ac..edec9e4097 100644 --- a/qemu-img.c +++ b/qemu-img.c @@ -1309,7 +1309,7 @@ static int check_empty_sectors(BlockBackend *blk, int= 64_t offset, int ret =3D 0; int64_t idx; =20 - ret =3D blk_pread(blk, offset, buffer, bytes); + ret =3D blk_pread(blk, offset, buffer, bytes, 0); if (ret < 0) { error_report("Error while reading offset %" PRId64 " of %s: %s", offset, filename, strerror(-ret)); @@ -1526,7 +1526,7 @@ static int img_compare(int argc, char **argv) int64_t pnum; =20 chunk =3D MIN(chunk, IO_BUF_SIZE); - ret =3D blk_pread(blk1, offset, buf1, chunk); + ret =3D blk_pread(blk1, offset, buf1, chunk, 0); if (ret < 0) { error_report("Error while reading offset %" PRId64 " of %s: %s", @@ -1534,7 +1534,7 @@ static int img_compare(int argc, char **argv) ret =3D 4; goto out; } - ret =3D blk_pread(blk2, offset, buf2, chunk); + ret =3D blk_pread(blk2, offset, buf2, chunk, 0); if (ret < 0) { error_report("Error while reading offset %" PRId64 " of %s: %s", @@ -3779,7 +3779,7 @@ static int img_rebase(int argc, char **argv) n =3D old_backing_size - offset; } =20 - ret =3D blk_pread(blk_old_backing, offset, buf_old, n); + ret =3D blk_pread(blk_old_backing, offset, buf_old, n, 0); if (ret < 0) { error_report("error while reading from old backing fil= e"); goto out; @@ -3793,7 +3793,7 @@ static int img_rebase(int argc, char **argv) n =3D new_backing_size - offset; } =20 - ret =3D blk_pread(blk_new_backing, offset, buf_new, n); + ret =3D blk_pread(blk_new_backing, offset, buf_new, n, 0); if (ret < 0) { error_report("error while reading from new backing fil= e"); goto out; @@ -5124,7 +5124,7 @@ static int img_dd(int argc, char **argv) =20 bytes =3D (in_pos + in.bsz > size) ? size - in_pos : in.bsz; =20 - in_ret =3D blk_pread(blk1, in_pos, in.buf, bytes); + in_ret =3D blk_pread(blk1, in_pos, in.buf, bytes, 0); if (in_ret < 0) { error_report("error while reading from input image file: %s", strerror(-in_ret)); diff --git a/qemu-io-cmds.c b/qemu-io-cmds.c index 443f22c732..582e1a7090 100644 --- a/qemu-io-cmds.c +++ b/qemu-io-cmds.c @@ -547,7 +547,7 @@ static int do_pread(BlockBackend *blk, char *buf, int64= _t offset, return -ERANGE; } =20 - ret =3D blk_pread(blk, offset, (uint8_t *)buf, bytes); + ret =3D blk_pread(blk, offset, (uint8_t *)buf, bytes, 0); if (ret < 0) { return ret; } diff --git a/tests/unit/test-block-iothread.c b/tests/unit/test-block-iothr= ead.c index 3c1a3f64a2..bfd12c9c15 100644 --- a/tests/unit/test-block-iothread.c +++ b/tests/unit/test-block-iothread.c @@ -116,11 +116,11 @@ static void test_sync_op_blk_pread(BlockBackend *blk) int ret; =20 /* Success */ - ret =3D blk_pread(blk, 0, buf, sizeof(buf)); + ret =3D blk_pread(blk, 0, buf, sizeof(buf), 0); g_assert_cmpint(ret, =3D=3D, 0); =20 /* Early error: Negative offset */ - ret =3D blk_pread(blk, -2, buf, sizeof(buf)); + ret =3D blk_pread(blk, -2, buf, sizeof(buf), 0); g_assert_cmpint(ret, =3D=3D, -EIO); } =20 --=20 2.35.3 From nobody Sat Apr 27 06:34:23 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1652792068; cv=none; d=zohomail.com; s=zohoarc; b=bX4wXznEHkUuDLUxS3RCeMYpG3+IJP7IIlnKlYpqdBpc3tYjIKc9PgQY1pImh5b7EoDSIntuAbJNTKX6QS8r4i/6CTJ5OMDbIf6QBVC36Lzue8NgcrYAJPp4lzw4km/Yjf8j9VuqerTyz2bwEi2fTjGw9+tV5yleoRgow5ipcgA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1652792068; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=YRojY9lIXcpfNsOOweJvLuPXUfuKOJHXWsW9ZCzI9PE=; b=BIU80T7DZ4rAKVnfKRmmWk1hFJcNbFhY56iUkkF4/8Y1pND349EA1BxU0CWOkHzEwcfJbo3haig0Yv88Y4smIM+r76TjBpCEztrQBYeaEjRP9x8fQ1nknWF1EnjsJSejOFHiGFg9/G+SbbJWwuWwPQhRVaxTbm4tdlg3NL9s0gg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1652792068769970.5533109787845; Tue, 17 May 2022 05:54:28 -0700 (PDT) Received: from localhost ([::1]:33872 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nqwiY-0003lp-FV for importer@patchew.org; Tue, 17 May 2022 08:54:26 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42242) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nqvWc-000109-IX for qemu-devel@nongnu.org; Tue, 17 May 2022 07:38:03 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:57063) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nqvWV-0002vX-Tw for qemu-devel@nongnu.org; Tue, 17 May 2022 07:38:02 -0400 Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-572-2b1S4UcqMfCInInKnoZEDQ-1; Tue, 17 May 2022 07:37:54 -0400 Received: by mail-wr1-f71.google.com with SMTP id w4-20020adfbac4000000b0020acba4b779so4609567wrg.22 for ; Tue, 17 May 2022 04:37:53 -0700 (PDT) Received: from fedora.redhat.com ([2001:8a0:f4d9:2101:a4fa:5f93:755f:6249]) by smtp.gmail.com with ESMTPSA id r7-20020adfab47000000b0020d0a57af5esm4838047wrc.79.2022.05.17.04.37.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 May 2022 04:37:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1652787475; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=YRojY9lIXcpfNsOOweJvLuPXUfuKOJHXWsW9ZCzI9PE=; b=i4dJf2QikVIROjUbhZoFzBy6LK8wBRCe6GsMq5R7b4uBDOysmgi/4kYmOPSA7ZfELDXqWx XP5u7a4/SwMCMM8SQGVXVVBOGrT0b/qEvCaoprYMfsF/49hWwSj/s7gJLlL0IrUsx432yT AhOmPTkz3IsdlPYx4Ia60agzXF5FOgI= X-MC-Unique: 2b1S4UcqMfCInInKnoZEDQ-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=YRojY9lIXcpfNsOOweJvLuPXUfuKOJHXWsW9ZCzI9PE=; b=zVkSuoAt5458IEB5dd/l+8u5Cpw+8at0iWQZ1jWuY8Btd+RUigE0gBOqI5A2DjKGMc rhzmq0TwdWIMtVmukCFdaR65y2NH64h3W70XvAv/SN38vv8xr9jmCspyv/gB2nfQHMMS Kr83dr+xEmC+DqFmSurJjJbI1GeFQvjibJVANK8xVQHni6s+8EiSqw0dFO8pLQeE1Lrx ldVUfv87SY0iSZ06/VEh4SNYt7J+r3huo4mQIZIabTwau8MESaioXu3HDS+fV16k6WxD gRx+BBGHL/Sr7xHTOnV8T4nAFjWrETJzmisZq/0zwf49CUg3wtSVa8UAZUNGGB9RJbnK 7opw== X-Gm-Message-State: AOAM530uEpOGiB+Dz1UvcSxhE1GA/rur0uyo5XsjQwHQkyNXuJbYzEWc KzQOj/WNnt1sT6yNmSMu2H+rdzBgOpyp2RPD7ofa95aCGXHaXXIPR9dq4MzAT3pVYMHu0wh7Zre aaauZ6/ThW7GNEvR9k03u8k2bvVB+A7TYu5vVhSJEfa1MYFbSZn1ljSInbJsRYlqi X-Received: by 2002:adf:ed01:0:b0:20c:c137:aaeb with SMTP id a1-20020adfed01000000b0020cc137aaebmr18540429wro.638.1652787470411; Tue, 17 May 2022 04:37:50 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxZOsHO0RWHhVfiZ5RD6hy5otyV3cOh1LEJ15q+v6T9FsHuff933+1+D08yeaK6HUEbmV+uYw== X-Received: by 2002:adf:ed01:0:b0:20c:c137:aaeb with SMTP id a1-20020adfed01000000b0020cc137aaebmr18540331wro.638.1652787469422; Tue, 17 May 2022 04:37:49 -0700 (PDT) From: Alberto Faria To: qemu-devel@nongnu.org Cc: John Snow , Stefan Weil , Andrew Jeffery , Beniamino Galvani , qemu-block@nongnu.org, Fam Zheng , Niek Linnenbank , "Dr. David Alan Gilbert" , Kevin Wolf , Stefan Hajnoczi , Eric Blake , Alistair Francis , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , qemu-arm@nongnu.org, qemu-riscv@nongnu.org, Jeff Cody , Daniel Henrique Barboza , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , "Edgar E. Iglesias" , Juan Quintela , Joel Stanley , Peter Maydell , Laurent Vivier , Bin Meng , Greg Kurz , Vladimir Sementsov-Ogievskiy , Hanna Reitz , qemu-ppc@nongnu.org, Palmer Dabbelt , David Gibson , "Denis V. Lunev" , Alberto Faria Subject: [PATCH 03/18] block: Change blk_{pread,pwrite}() param order Date: Tue, 17 May 2022 12:37:31 +0100 Message-Id: <20220517113746.198993-1-afaria@redhat.com> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20220517113524.197910-1-afaria@redhat.com> References: <20220517113524.197910-1-afaria@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.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; Received-SPF: pass client-ip=170.10.133.124; envelope-from=afaria@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1652792069785100001 Content-Type: text/plain; charset="utf-8" Swap 'buf' and 'bytes' around for consistency with blk_co_{pread,pwrite}(), and in preparation to implement these functions using generated_co_wrapper. Callers were updated using this Coccinelle script: @@ expression blk, offset, buf, bytes, flags; @@ - blk_pread(blk, offset, buf, bytes, flags) + blk_pread(blk, offset, bytes, buf, flags) @@ expression blk, offset, buf, bytes, flags; @@ - blk_pwrite(blk, offset, buf, bytes, flags) + blk_pwrite(blk, offset, bytes, buf, flags) It had no effect on hw/block/nand.c, presumably due to the #if, so that file was updated manually. Overly-long lines were then fixed by hand. Signed-off-by: Alberto Faria Reviewed-by: Eric Blake Reviewed-by: Hanna Reitz --- block.c | 2 +- block/block-backend.c | 4 +-- block/commit.c | 4 +-- block/crypto.c | 2 +- block/export/fuse.c | 4 +-- block/parallels.c | 2 +- block/qcow.c | 8 +++--- block/qcow2.c | 4 +-- block/qed.c | 8 +++--- block/vdi.c | 4 +-- block/vhdx.c | 20 ++++++------- block/vmdk.c | 10 +++---- block/vpc.c | 12 ++++---- hw/arm/allwinner-h3.c | 2 +- hw/arm/aspeed.c | 2 +- hw/block/block.c | 2 +- hw/block/fdc.c | 20 ++++++------- hw/block/hd-geometry.c | 2 +- hw/block/m25p80.c | 2 +- hw/block/nand.c | 47 ++++++++++++++++--------------- hw/block/onenand.c | 32 ++++++++++----------- hw/block/pflash_cfi01.c | 4 +-- hw/block/pflash_cfi02.c | 4 +-- hw/ide/atapi.c | 4 +-- hw/misc/mac_via.c | 4 +-- hw/misc/sifive_u_otp.c | 14 ++++----- hw/nvram/eeprom_at24c.c | 4 +-- hw/nvram/spapr_nvram.c | 6 ++-- hw/nvram/xlnx-bbram.c | 4 +-- hw/nvram/xlnx-efuse.c | 4 +-- hw/ppc/pnv_pnor.c | 6 ++-- hw/sd/sd.c | 4 +-- include/sysemu/block-backend-io.h | 4 +-- migration/block.c | 6 ++-- nbd/server.c | 8 +++--- qemu-img.c | 18 ++++++------ qemu-io-cmds.c | 4 +-- tests/unit/test-block-iothread.c | 8 +++--- 38 files changed, 150 insertions(+), 149 deletions(-) diff --git a/block.c b/block.c index ed701b4889..bc85f46eed 100644 --- a/block.c +++ b/block.c @@ -1037,7 +1037,7 @@ static int find_image_format(BlockBackend *file, cons= t char *filename, return ret; } =20 - ret =3D blk_pread(file, 0, buf, sizeof(buf), 0); + ret =3D blk_pread(file, 0, sizeof(buf), buf, 0); if (ret < 0) { error_setg_errno(errp, -ret, "Could not read image for determining= its " "format"); diff --git a/block/block-backend.c b/block/block-backend.c index da89450861..16a0093c52 100644 --- a/block/block-backend.c +++ b/block/block-backend.c @@ -1567,7 +1567,7 @@ BlockAIOCB *blk_aio_pwrite_zeroes(BlockBackend *blk, = int64_t offset, flags | BDRV_REQ_ZERO_WRITE, cb, opaque); } =20 -int blk_pread(BlockBackend *blk, int64_t offset, void *buf, int bytes, +int blk_pread(BlockBackend *blk, int64_t offset, int bytes, void *buf, BdrvRequestFlags flags) { int ret; @@ -1581,7 +1581,7 @@ int blk_pread(BlockBackend *blk, int64_t offset, void= *buf, int bytes, return ret; } =20 -int blk_pwrite(BlockBackend *blk, int64_t offset, const void *buf, int byt= es, +int blk_pwrite(BlockBackend *blk, int64_t offset, int bytes, const void *b= uf, BdrvRequestFlags flags) { QEMUIOVector qiov =3D QEMU_IOVEC_INIT_BUF(qiov, buf, bytes); diff --git a/block/commit.c b/block/commit.c index e5b3ad08da..38571510cb 100644 --- a/block/commit.c +++ b/block/commit.c @@ -527,12 +527,12 @@ int bdrv_commit(BlockDriverState *bs) goto ro_cleanup; } if (ret) { - ret =3D blk_pread(src, offset, buf, n, 0); + ret =3D blk_pread(src, offset, n, buf, 0); if (ret < 0) { goto ro_cleanup; } =20 - ret =3D blk_pwrite(backing, offset, buf, n, 0); + ret =3D blk_pwrite(backing, offset, n, buf, 0); if (ret < 0) { goto ro_cleanup; } diff --git a/block/crypto.c b/block/crypto.c index 11c3ddbc73..7a57774b76 100644 --- a/block/crypto.c +++ b/block/crypto.c @@ -109,7 +109,7 @@ static int block_crypto_create_write_func(QCryptoBlock = *block, struct BlockCryptoCreateData *data =3D opaque; ssize_t ret; =20 - ret =3D blk_pwrite(data->blk, offset, buf, buflen, 0); + ret =3D blk_pwrite(data->blk, offset, buflen, buf, 0); if (ret < 0) { error_setg_errno(errp, -ret, "Could not write encryption header"); return ret; diff --git a/block/export/fuse.c b/block/export/fuse.c index dcf8f225f3..1b26ddfcf3 100644 --- a/block/export/fuse.c +++ b/block/export/fuse.c @@ -554,7 +554,7 @@ static void fuse_read(fuse_req_t req, fuse_ino_t inode, return; } =20 - ret =3D blk_pread(exp->common.blk, offset, buf, size, 0); + ret =3D blk_pread(exp->common.blk, offset, size, buf, 0); if (ret >=3D 0) { fuse_reply_buf(req, buf, size); } else { @@ -607,7 +607,7 @@ static void fuse_write(fuse_req_t req, fuse_ino_t inode= , const char *buf, } } =20 - ret =3D blk_pwrite(exp->common.blk, offset, buf, size, 0); + ret =3D blk_pwrite(exp->common.blk, offset, size, buf, 0); if (ret >=3D 0) { fuse_reply_write(req, size); } else { diff --git a/block/parallels.c b/block/parallels.c index 8b23b9580d..8b235b9505 100644 --- a/block/parallels.c +++ b/block/parallels.c @@ -599,7 +599,7 @@ static int coroutine_fn parallels_co_create(BlockdevCre= ateOptions* opts, memset(tmp, 0, sizeof(tmp)); memcpy(tmp, &header, sizeof(header)); =20 - ret =3D blk_pwrite(blk, 0, tmp, BDRV_SECTOR_SIZE, 0); + ret =3D blk_pwrite(blk, 0, BDRV_SECTOR_SIZE, tmp, 0); if (ret < 0) { goto exit; } diff --git a/block/qcow.c b/block/qcow.c index 25a43353c1..311aaa8705 100644 --- a/block/qcow.c +++ b/block/qcow.c @@ -890,14 +890,14 @@ static int coroutine_fn qcow_co_create(BlockdevCreate= Options *opts, } =20 /* write all the data */ - ret =3D blk_pwrite(qcow_blk, 0, &header, sizeof(header), 0); + ret =3D blk_pwrite(qcow_blk, 0, sizeof(header), &header, 0); if (ret < 0) { goto exit; } =20 if (qcow_opts->has_backing_file) { - ret =3D blk_pwrite(qcow_blk, sizeof(header), - qcow_opts->backing_file, backing_filename_len, 0); + ret =3D blk_pwrite(qcow_blk, sizeof(header), backing_filename_len, + qcow_opts->backing_file, 0); if (ret < 0) { goto exit; } @@ -907,7 +907,7 @@ static int coroutine_fn qcow_co_create(BlockdevCreateOp= tions *opts, for (i =3D 0; i < DIV_ROUND_UP(sizeof(uint64_t) * l1_size, BDRV_SECTOR= _SIZE); i++) { ret =3D blk_pwrite(qcow_blk, header_size + BDRV_SECTOR_SIZE * i, - tmp, BDRV_SECTOR_SIZE, 0); + BDRV_SECTOR_SIZE, tmp, 0); if (ret < 0) { g_free(tmp); goto exit; diff --git a/block/qcow2.c b/block/qcow2.c index 90a2dd406b..c6c6692fb7 100644 --- a/block/qcow2.c +++ b/block/qcow2.c @@ -3666,7 +3666,7 @@ qcow2_co_create(BlockdevCreateOptions *create_options= , Error **errp) cpu_to_be64(QCOW2_INCOMPAT_EXTL2); } =20 - ret =3D blk_pwrite(blk, 0, header, cluster_size, 0); + ret =3D blk_pwrite(blk, 0, cluster_size, header, 0); g_free(header); if (ret < 0) { error_setg_errno(errp, -ret, "Could not write qcow2 header"); @@ -3676,7 +3676,7 @@ qcow2_co_create(BlockdevCreateOptions *create_options= , Error **errp) /* Write a refcount table with one refcount block */ refcount_table =3D g_malloc0(2 * cluster_size); refcount_table[0] =3D cpu_to_be64(2 * cluster_size); - ret =3D blk_pwrite(blk, cluster_size, refcount_table, 2 * cluster_size= , 0); + ret =3D blk_pwrite(blk, cluster_size, 2 * cluster_size, refcount_table= , 0); g_free(refcount_table); =20 if (ret < 0) { diff --git a/block/qed.c b/block/qed.c index 55da91eb72..40943e679b 100644 --- a/block/qed.c +++ b/block/qed.c @@ -705,18 +705,18 @@ static int coroutine_fn bdrv_qed_co_create(BlockdevCr= eateOptions *opts, } =20 qed_header_cpu_to_le(&header, &le_header); - ret =3D blk_pwrite(blk, 0, &le_header, sizeof(le_header), 0); + ret =3D blk_pwrite(blk, 0, sizeof(le_header), &le_header, 0); if (ret < 0) { goto out; } - ret =3D blk_pwrite(blk, sizeof(le_header), qed_opts->backing_file, - header.backing_filename_size, 0); + ret =3D blk_pwrite(blk, sizeof(le_header), header.backing_filename_siz= e, + qed_opts->backing_file, 0); if (ret < 0) { goto out; } =20 l1_table =3D g_malloc0(l1_size); - ret =3D blk_pwrite(blk, header.l1_table_offset, l1_table, l1_size, 0); + ret =3D blk_pwrite(blk, header.l1_table_offset, l1_size, l1_table, 0); if (ret < 0) { goto out; } diff --git a/block/vdi.c b/block/vdi.c index a0be2a23b9..e942325455 100644 --- a/block/vdi.c +++ b/block/vdi.c @@ -845,7 +845,7 @@ static int coroutine_fn vdi_co_do_create(BlockdevCreate= Options *create_options, vdi_header_print(&header); } vdi_header_to_le(&header); - ret =3D blk_pwrite(blk, offset, &header, sizeof(header), 0); + ret =3D blk_pwrite(blk, offset, sizeof(header), &header, 0); if (ret < 0) { error_setg(errp, "Error writing header"); goto exit; @@ -866,7 +866,7 @@ static int coroutine_fn vdi_co_do_create(BlockdevCreate= Options *create_options, bmap[i] =3D VDI_UNALLOCATED; } } - ret =3D blk_pwrite(blk, offset, bmap, bmap_size, 0); + ret =3D blk_pwrite(blk, offset, bmap_size, bmap, 0); if (ret < 0) { error_setg(errp, "Error writing bmap"); goto exit; diff --git a/block/vhdx.c b/block/vhdx.c index 12f5261f80..e10e78ebfd 100644 --- a/block/vhdx.c +++ b/block/vhdx.c @@ -1665,13 +1665,13 @@ static int vhdx_create_new_metadata(BlockBackend *b= lk, VHDX_META_FLAGS_IS_VIRTUAL_DISK; vhdx_metadata_entry_le_export(&md_table_entry[4]); =20 - ret =3D blk_pwrite(blk, metadata_offset, buffer, VHDX_HEADER_BLOCK_SIZ= E, 0); + ret =3D blk_pwrite(blk, metadata_offset, VHDX_HEADER_BLOCK_SIZE, buffe= r, 0); if (ret < 0) { goto exit; } =20 - ret =3D blk_pwrite(blk, metadata_offset + (64 * KiB), entry_buffer, - VHDX_METADATA_ENTRY_BUFFER_SIZE, 0); + ret =3D blk_pwrite(blk, metadata_offset + (64 * KiB), + VHDX_METADATA_ENTRY_BUFFER_SIZE, entry_buffer, 0); if (ret < 0) { goto exit; } @@ -1756,7 +1756,7 @@ static int vhdx_create_bat(BlockBackend *blk, BDRVVHD= XState *s, s->bat[sinfo.bat_idx] =3D cpu_to_le64(s->bat[sinfo.bat_idx]); sector_num +=3D s->sectors_per_block; } - ret =3D blk_pwrite(blk, file_offset, s->bat, length, 0); + ret =3D blk_pwrite(blk, file_offset, length, s->bat, 0); if (ret < 0) { error_setg_errno(errp, -ret, "Failed to write the BAT"); goto exit; @@ -1860,15 +1860,15 @@ static int vhdx_create_new_region_table(BlockBacken= d *blk, } =20 /* Now write out the region headers to disk */ - ret =3D blk_pwrite(blk, VHDX_REGION_TABLE_OFFSET, buffer, - VHDX_HEADER_BLOCK_SIZE, 0); + ret =3D blk_pwrite(blk, VHDX_REGION_TABLE_OFFSET, VHDX_HEADER_BLOCK_SI= ZE, + buffer, 0); if (ret < 0) { error_setg_errno(errp, -ret, "Failed to write first region table"); goto exit; } =20 - ret =3D blk_pwrite(blk, VHDX_REGION_TABLE2_OFFSET, buffer, - VHDX_HEADER_BLOCK_SIZE, 0); + ret =3D blk_pwrite(blk, VHDX_REGION_TABLE2_OFFSET, VHDX_HEADER_BLOCK_S= IZE, + buffer, 0); if (ret < 0) { error_setg_errno(errp, -ret, "Failed to write second region table"= ); goto exit; @@ -2012,7 +2012,7 @@ static int coroutine_fn vhdx_co_create(BlockdevCreate= Options *opts, creator =3D g_utf8_to_utf16("QEMU v" QEMU_VERSION, -1, NULL, &creator_items, NULL); signature =3D cpu_to_le64(VHDX_FILE_SIGNATURE); - ret =3D blk_pwrite(blk, VHDX_FILE_ID_OFFSET, &signature, sizeof(signat= ure), + ret =3D blk_pwrite(blk, VHDX_FILE_ID_OFFSET, sizeof(signature), &signa= ture, 0); if (ret < 0) { error_setg_errno(errp, -ret, "Failed to write file signature"); @@ -2020,7 +2020,7 @@ static int coroutine_fn vhdx_co_create(BlockdevCreate= Options *opts, } if (creator) { ret =3D blk_pwrite(blk, VHDX_FILE_ID_OFFSET + sizeof(signature), - creator, creator_items * sizeof(gunichar2), 0); + creator_items * sizeof(gunichar2), creator, 0); if (ret < 0) { error_setg_errno(errp, -ret, "Failed to write creator field"); goto delete_and_exit; diff --git a/block/vmdk.c b/block/vmdk.c index 332565c80f..fe07a54866 100644 --- a/block/vmdk.c +++ b/block/vmdk.c @@ -2236,12 +2236,12 @@ static int vmdk_init_extent(BlockBackend *blk, header.check_bytes[3] =3D 0xa; =20 /* write all the data */ - ret =3D blk_pwrite(blk, 0, &magic, sizeof(magic), 0); + ret =3D blk_pwrite(blk, 0, sizeof(magic), &magic, 0); if (ret < 0) { error_setg(errp, QERR_IO_ERROR); goto exit; } - ret =3D blk_pwrite(blk, sizeof(magic), &header, sizeof(header), 0); + ret =3D blk_pwrite(blk, sizeof(magic), sizeof(header), &header, 0); if (ret < 0) { error_setg(errp, QERR_IO_ERROR); goto exit; @@ -2261,7 +2261,7 @@ static int vmdk_init_extent(BlockBackend *blk, gd_buf[i] =3D cpu_to_le32(tmp); } ret =3D blk_pwrite(blk, le64_to_cpu(header.rgd_offset) * BDRV_SECTOR_S= IZE, - gd_buf, gd_buf_size, 0); + gd_buf_size, gd_buf, 0); if (ret < 0) { error_setg(errp, QERR_IO_ERROR); goto exit; @@ -2273,7 +2273,7 @@ static int vmdk_init_extent(BlockBackend *blk, gd_buf[i] =3D cpu_to_le32(tmp); } ret =3D blk_pwrite(blk, le64_to_cpu(header.gd_offset) * BDRV_SECTOR_SI= ZE, - gd_buf, gd_buf_size, 0); + gd_buf_size, gd_buf, 0); if (ret < 0) { error_setg(errp, QERR_IO_ERROR); } @@ -2584,7 +2584,7 @@ static int coroutine_fn vmdk_co_do_create(int64_t siz= e, desc_offset =3D 0x200; } =20 - ret =3D blk_pwrite(blk, desc_offset, desc, desc_len, 0); + ret =3D blk_pwrite(blk, desc_offset, desc_len, desc, 0); if (ret < 0) { error_setg_errno(errp, -ret, "Could not write description"); goto exit; diff --git a/block/vpc.c b/block/vpc.c index 7f20820193..4f49ef207f 100644 --- a/block/vpc.c +++ b/block/vpc.c @@ -834,13 +834,13 @@ static int create_dynamic_disk(BlockBackend *blk, VHD= Footer *footer, block_size =3D 0x200000; num_bat_entries =3D DIV_ROUND_UP(total_sectors, block_size / 512); =20 - ret =3D blk_pwrite(blk, offset, footer, sizeof(*footer), 0); + ret =3D blk_pwrite(blk, offset, sizeof(*footer), footer, 0); if (ret < 0) { goto fail; } =20 offset =3D 1536 + ((num_bat_entries * 4 + 511) & ~511); - ret =3D blk_pwrite(blk, offset, footer, sizeof(*footer), 0); + ret =3D blk_pwrite(blk, offset, sizeof(*footer), footer, 0); if (ret < 0) { goto fail; } @@ -850,7 +850,7 @@ static int create_dynamic_disk(BlockBackend *blk, VHDFo= oter *footer, =20 memset(bat_sector, 0xFF, 512); for (i =3D 0; i < DIV_ROUND_UP(num_bat_entries * 4, 512); i++) { - ret =3D blk_pwrite(blk, offset, bat_sector, 512, 0); + ret =3D blk_pwrite(blk, offset, 512, bat_sector, 0); if (ret < 0) { goto fail; } @@ -878,7 +878,7 @@ static int create_dynamic_disk(BlockBackend *blk, VHDFo= oter *footer, /* Write the header */ offset =3D 512; =20 - ret =3D blk_pwrite(blk, offset, &dyndisk_header, sizeof(dyndisk_header= ), 0); + ret =3D blk_pwrite(blk, offset, sizeof(dyndisk_header), &dyndisk_heade= r, 0); if (ret < 0) { goto fail; } @@ -901,8 +901,8 @@ static int create_fixed_disk(BlockBackend *blk, VHDFoot= er *footer, return ret; } =20 - ret =3D blk_pwrite(blk, total_size - sizeof(*footer), - footer, sizeof(*footer), 0); + ret =3D blk_pwrite(blk, total_size - sizeof(*footer), sizeof(*footer), + footer, 0); if (ret < 0) { error_setg_errno(errp, -ret, "Unable to write VHD header"); return ret; diff --git a/hw/arm/allwinner-h3.c b/hw/arm/allwinner-h3.c index 788083b6fa..308ed15552 100644 --- a/hw/arm/allwinner-h3.c +++ b/hw/arm/allwinner-h3.c @@ -174,7 +174,7 @@ void allwinner_h3_bootrom_setup(AwH3State *s, BlockBack= end *blk) const int64_t rom_size =3D 32 * KiB; g_autofree uint8_t *buffer =3D g_new0(uint8_t, rom_size); =20 - if (blk_pread(blk, 8 * KiB, buffer, rom_size, 0) < 0) { + if (blk_pread(blk, 8 * KiB, rom_size, buffer, 0) < 0) { error_setg(&error_fatal, "%s: failed to read BlockBackend data", __func__); return; diff --git a/hw/arm/aspeed.c b/hw/arm/aspeed.c index 06ab8cd0a5..4853d78236 100644 --- a/hw/arm/aspeed.c +++ b/hw/arm/aspeed.c @@ -269,7 +269,7 @@ static void write_boot_rom(DriveInfo *dinfo, hwaddr add= r, size_t rom_size, } =20 storage =3D g_malloc0(rom_size); - if (blk_pread(blk, 0, storage, rom_size, 0) < 0) { + if (blk_pread(blk, 0, rom_size, storage, 0) < 0) { error_setg(errp, "failed to read the initial flash content"); return; } diff --git a/hw/block/block.c b/hw/block/block.c index effb89910c..04279166ee 100644 --- a/hw/block/block.c +++ b/hw/block/block.c @@ -53,7 +53,7 @@ bool blk_check_size_and_read_all(BlockBackend *blk, void = *buf, hwaddr size, * block device and read only on demand. */ assert(size <=3D BDRV_REQUEST_MAX_BYTES); - ret =3D blk_pread(blk, 0, buf, size, 0); + ret =3D blk_pread(blk, 0, size, buf, 0); if (ret < 0) { error_setg_errno(errp, -ret, "can't read block backend"); return false; diff --git a/hw/block/fdc.c b/hw/block/fdc.c index 52f278ed82..64ae4a6899 100644 --- a/hw/block/fdc.c +++ b/hw/block/fdc.c @@ -1628,8 +1628,8 @@ int fdctrl_transfer_handler(void *opaque, int nchan, = int dma_pos, int dma_len) if (fdctrl->data_dir !=3D FD_DIR_WRITE || len < FD_SECTOR_LEN || rel_pos !=3D 0) { /* READ & SCAN commands and realign to a sector for WRITE */ - if (blk_pread(cur_drv->blk, fd_offset(cur_drv), fdctrl->fifo, - BDRV_SECTOR_SIZE, 0) < 0) { + if (blk_pread(cur_drv->blk, fd_offset(cur_drv), BDRV_SECTOR_SI= ZE, + fdctrl->fifo, 0) < 0) { FLOPPY_DPRINTF("Floppy: error getting sector %d\n", fd_sector(cur_drv)); /* Sure, image size is too small... */ @@ -1656,8 +1656,8 @@ int fdctrl_transfer_handler(void *opaque, int nchan, = int dma_pos, int dma_len) =20 k->read_memory(fdctrl->dma, nchan, fdctrl->fifo + rel_pos, fdctrl->data_pos, len); - if (blk_pwrite(cur_drv->blk, fd_offset(cur_drv), - fdctrl->fifo, BDRV_SECTOR_SIZE, 0) < 0) { + if (blk_pwrite(cur_drv->blk, fd_offset(cur_drv), BDRV_SECTOR_S= IZE, + fdctrl->fifo, 0) < 0) { FLOPPY_DPRINTF("error writing sector %d\n", fd_sector(cur_drv)); fdctrl_stop_transfer(fdctrl, FD_SR0_ABNTERM | FD_SR0_SEEK,= 0x00, 0x00); @@ -1740,8 +1740,8 @@ static uint32_t fdctrl_read_data(FDCtrl *fdctrl) fd_sector(cur_drv)); return 0; } - if (blk_pread(cur_drv->blk, fd_offset(cur_drv), fdctrl->fifo, - BDRV_SECTOR_SIZE, 0) + if (blk_pread(cur_drv->blk, fd_offset(cur_drv), BDRV_SECTOR_SI= ZE, + fdctrl->fifo, 0) < 0) { FLOPPY_DPRINTF("error getting sector %d\n", fd_sector(cur_drv)); @@ -1820,8 +1820,8 @@ static void fdctrl_format_sector(FDCtrl *fdctrl) } memset(fdctrl->fifo, 0, FD_SECTOR_LEN); if (cur_drv->blk =3D=3D NULL || - blk_pwrite(cur_drv->blk, fd_offset(cur_drv), fdctrl->fifo, - BDRV_SECTOR_SIZE, 0) < 0) { + blk_pwrite(cur_drv->blk, fd_offset(cur_drv), BDRV_SECTOR_SIZE, + fdctrl->fifo, 0) < 0) { FLOPPY_DPRINTF("error formatting sector %d\n", fd_sector(cur_drv)); fdctrl_stop_transfer(fdctrl, FD_SR0_ABNTERM | FD_SR0_SEEK, 0x00, 0= x00); } else { @@ -2244,8 +2244,8 @@ static void fdctrl_write_data(FDCtrl *fdctrl, uint32_= t value) if (pos =3D=3D FD_SECTOR_LEN - 1 || fdctrl->data_pos =3D=3D fdctrl->data_len) { cur_drv =3D get_cur_drv(fdctrl); - if (blk_pwrite(cur_drv->blk, fd_offset(cur_drv), fdctrl->fifo, - BDRV_SECTOR_SIZE, 0) < 0) { + if (blk_pwrite(cur_drv->blk, fd_offset(cur_drv), BDRV_SECTOR_S= IZE, + fdctrl->fifo, 0) < 0) { FLOPPY_DPRINTF("error writing sector %d\n", fd_sector(cur_drv)); break; diff --git a/hw/block/hd-geometry.c b/hw/block/hd-geometry.c index 24933eae82..112094358e 100644 --- a/hw/block/hd-geometry.c +++ b/hw/block/hd-geometry.c @@ -63,7 +63,7 @@ static int guess_disk_lchs(BlockBackend *blk, =20 blk_get_geometry(blk, &nb_sectors); =20 - if (blk_pread(blk, 0, buf, BDRV_SECTOR_SIZE, 0) < 0) { + if (blk_pread(blk, 0, BDRV_SECTOR_SIZE, buf, 0) < 0) { return -1; } /* test msdos magic */ diff --git a/hw/block/m25p80.c b/hw/block/m25p80.c index 3e93769fed..3e3e142d83 100644 --- a/hw/block/m25p80.c +++ b/hw/block/m25p80.c @@ -1506,7 +1506,7 @@ static void m25p80_realize(SSIPeripheral *ss, Error *= *errp) trace_m25p80_binding(s); s->storage =3D blk_blockalign(s->blk, s->size); =20 - if (blk_pread(s->blk, 0, s->storage, s->size, 0) < 0) { + if (blk_pread(s->blk, 0, s->size, s->storage, 0) < 0) { error_setg(errp, "failed to read the initial flash content"); return; } diff --git a/hw/block/nand.c b/hw/block/nand.c index ea3d33adf4..1aee1cb2b1 100644 --- a/hw/block/nand.c +++ b/hw/block/nand.c @@ -666,8 +666,8 @@ static void glue(nand_blk_write_, NAND_PAGE_SIZE)(NANDF= lashState *s) sector =3D SECTOR(s->addr); off =3D (s->addr & PAGE_MASK) + s->offset; soff =3D SECTOR_OFFSET(s->addr); - if (blk_pread(s->blk, sector << BDRV_SECTOR_BITS, iobuf, - PAGE_SECTORS << BDRV_SECTOR_BITS, 0) < 0) { + if (blk_pread(s->blk, sector << BDRV_SECTOR_BITS, + PAGE_SECTORS << BDRV_SECTOR_BITS, iobuf, 0) < 0) { printf("%s: read error in sector %" PRIu64 "\n", __func__, sec= tor); return; } @@ -679,24 +679,24 @@ static void glue(nand_blk_write_, NAND_PAGE_SIZE)(NAN= DFlashState *s) MIN(OOB_SIZE, off + s->iolen - NAND_PAGE_SIZE)= ); } =20 - if (blk_pwrite(s->blk, sector << BDRV_SECTOR_BITS, iobuf, - PAGE_SECTORS << BDRV_SECTOR_BITS, 0) < 0) { + if (blk_pwrite(s->blk, sector << BDRV_SECTOR_BITS, + PAGE_SECTORS << BDRV_SECTOR_BITS, iobuf, 0) < 0) { printf("%s: write error in sector %" PRIu64 "\n", __func__, se= ctor); } } else { off =3D PAGE_START(s->addr) + (s->addr & PAGE_MASK) + s->offset; sector =3D off >> 9; soff =3D off & 0x1ff; - if (blk_pread(s->blk, sector << BDRV_SECTOR_BITS, iobuf, - (PAGE_SECTORS + 2) << BDRV_SECTOR_BITS, 0) < 0) { + if (blk_pread(s->blk, sector << BDRV_SECTOR_BITS, + (PAGE_SECTORS + 2) << BDRV_SECTOR_BITS, iobuf, 0) < = 0) { printf("%s: read error in sector %" PRIu64 "\n", __func__, sec= tor); return; } =20 mem_and(iobuf + soff, s->io, s->iolen); =20 - if (blk_pwrite(s->blk, sector << BDRV_SECTOR_BITS, iobuf, - (PAGE_SECTORS + 2) << BDRV_SECTOR_BITS, 0) < 0) { + if (blk_pwrite(s->blk, sector << BDRV_SECTOR_BITS, + (PAGE_SECTORS + 2) << BDRV_SECTOR_BITS, iobuf, 0) <= 0) { printf("%s: write error in sector %" PRIu64 "\n", __func__, se= ctor); } } @@ -723,20 +723,20 @@ static void glue(nand_blk_erase_, NAND_PAGE_SIZE)(NAN= DFlashState *s) i =3D SECTOR(addr); page =3D SECTOR(addr + (1 << (ADDR_SHIFT + s->erase_shift))); for (; i < page; i ++) - if (blk_pwrite(s->blk, i << BDRV_SECTOR_BITS, iobuf, - BDRV_SECTOR_SIZE, 0) < 0) { + if (blk_pwrite(s->blk, i << BDRV_SECTOR_BITS, + BDRV_SECTOR_SIZE, iobuf, 0) < 0) { printf("%s: write error in sector %" PRIu64 "\n", __func__= , i); } } else { addr =3D PAGE_START(addr); page =3D addr >> 9; - if (blk_pread(s->blk, page << BDRV_SECTOR_BITS, iobuf, - BDRV_SECTOR_SIZE, 0) < 0) { + if (blk_pread(s->blk, page << BDRV_SECTOR_BITS, + BDRV_SECTOR_SIZE, iobuf, 0) < 0) { printf("%s: read error in sector %" PRIu64 "\n", __func__, pag= e); } memset(iobuf + (addr & 0x1ff), 0xff, (~addr & 0x1ff) + 1); - if (blk_pwrite(s->blk, page << BDRV_SECTOR_BITS, iobuf, - BDRV_SECTOR_SIZE, 0) < 0) { + if (blk_pwrite(s->blk, page << BDRV_SECTOR_BITS, + BDRV_SECTOR_SIZE, iobuf, 0) < 0) { printf("%s: write error in sector %" PRIu64 "\n", __func__, pa= ge); } =20 @@ -744,20 +744,20 @@ static void glue(nand_blk_erase_, NAND_PAGE_SIZE)(NAN= DFlashState *s) i =3D (addr & ~0x1ff) + 0x200; for (addr +=3D ((NAND_PAGE_SIZE + OOB_SIZE) << s->erase_shift) - 0= x200; i < addr; i +=3D 0x200) { - if (blk_pwrite(s->blk, i, iobuf, BDRV_SECTOR_SIZE, 0) < 0) { + if (blk_pwrite(s->blk, i, BDRV_SECTOR_SIZE, iobuf, 0) < 0) { printf("%s: write error in sector %" PRIu64 "\n", __func__, i >> 9); } } =20 page =3D i >> 9; - if (blk_pread(s->blk, page << BDRV_SECTOR_BITS, iobuf, - BDRV_SECTOR_SIZE, 0) < 0) { + if (blk_pread(s->blk, page << BDRV_SECTOR_BITS, + BDRV_SECTOR_SIZE, iobuf, 0) < 0) { printf("%s: read error in sector %" PRIu64 "\n", __func__, pag= e); } memset(iobuf, 0xff, ((addr - 1) & 0x1ff) + 1); - if (blk_pwrite(s->blk, page << BDRV_SECTOR_BITS, iobuf, - BDRV_SECTOR_SIZE, 0) < 0) { + if (blk_pwrite(s->blk, page << BDRV_SECTOR_BITS, + BDRV_SECTOR_SIZE, iobuf, 0) < 0) { printf("%s: write error in sector %" PRIu64 "\n", __func__, pa= ge); } } @@ -772,8 +772,8 @@ static void glue(nand_blk_load_, NAND_PAGE_SIZE)(NANDFl= ashState *s, =20 if (s->blk) { if (s->mem_oob) { - if (blk_pread(s->blk, SECTOR(addr) << BDRV_SECTOR_BITS, s->io, - PAGE_SECTORS << BDRV_SECTOR_BITS, 0) < 0) { + if (blk_pread(s->blk, SECTOR(addr) << BDRV_SECTOR_BITS, + PAGE_SECTORS << BDRV_SECTOR_BITS, s->io, 0) < 0)= { printf("%s: read error in sector %" PRIu64 "\n", __func__, SECTOR(addr)); } @@ -782,8 +782,9 @@ static void glue(nand_blk_load_, NAND_PAGE_SIZE)(NANDFl= ashState *s, OOB_SIZE); s->ioaddr =3D s->io + SECTOR_OFFSET(s->addr) + offset; } else { - if (blk_pread(s->blk, PAGE_START(addr), s->io, - (PAGE_SECTORS + 2) << BDRV_SECTOR_BITS, 0) < 0) { + if (blk_pread(s->blk, PAGE_START(addr), + (PAGE_SECTORS + 2) << BDRV_SECTOR_BITS, s->io, 0) + < 0) { printf("%s: read error in sector %" PRIu64 "\n", __func__, PAGE_START(addr) >> 9); } diff --git a/hw/block/onenand.c b/hw/block/onenand.c index 1225ec8076..1fde975024 100644 --- a/hw/block/onenand.c +++ b/hw/block/onenand.c @@ -229,8 +229,8 @@ static void onenand_reset(OneNANDState *s, int cold) /* Lock the whole flash */ memset(s->blockwp, ONEN_LOCK_LOCKED, s->blocks); =20 - if (s->blk_cur && blk_pread(s->blk_cur, 0, s->boot[0], - 8 << BDRV_SECTOR_BITS, 0) < 0) { + if (s->blk_cur && blk_pread(s->blk_cur, 0, 8 << BDRV_SECTOR_BITS, + s->boot[0], 0) < 0) { hw_error("%s: Loading the BootRAM failed.\n", __func__); } } @@ -249,8 +249,8 @@ static inline int onenand_load_main(OneNANDState *s, in= t sec, int secn, assert(UINT32_MAX >> BDRV_SECTOR_BITS > sec); assert(UINT32_MAX >> BDRV_SECTOR_BITS > secn); if (s->blk_cur) { - return blk_pread(s->blk_cur, sec << BDRV_SECTOR_BITS, dest, - secn << BDRV_SECTOR_BITS, 0) < 0; + return blk_pread(s->blk_cur, sec << BDRV_SECTOR_BITS, + secn << BDRV_SECTOR_BITS, dest, 0) < 0; } else if (sec + secn > s->secs_cur) { return 1; } @@ -274,7 +274,7 @@ static inline int onenand_prog_main(OneNANDState *s, in= t sec, int secn, uint8_t *dp =3D 0; if (s->blk_cur) { dp =3D g_malloc(size); - if (!dp || blk_pread(s->blk_cur, offset, dp, size, 0) < 0) { + if (!dp || blk_pread(s->blk_cur, offset, size, dp, 0) < 0) { result =3D 1; } } else { @@ -290,7 +290,7 @@ static inline int onenand_prog_main(OneNANDState *s, in= t sec, int secn, dp[i] &=3D sp[i]; } if (s->blk_cur) { - result =3D blk_pwrite(s->blk_cur, offset, dp, size, 0) < 0; + result =3D blk_pwrite(s->blk_cur, offset, size, dp, 0) < 0; } } if (dp && s->blk_cur) { @@ -308,7 +308,7 @@ static inline int onenand_load_spare(OneNANDState *s, i= nt sec, int secn, =20 if (s->blk_cur) { uint32_t offset =3D (s->secs_cur + (sec >> 5)) << BDRV_SECTOR_BITS; - if (blk_pread(s->blk_cur, offset, buf, BDRV_SECTOR_SIZE, 0) < 0) { + if (blk_pread(s->blk_cur, offset, BDRV_SECTOR_SIZE, buf, 0) < 0) { return 1; } memcpy(dest, buf + ((sec & 31) << 4), secn << 4); @@ -333,7 +333,7 @@ static inline int onenand_prog_spare(OneNANDState *s, i= nt sec, int secn, if (s->blk_cur) { dp =3D g_malloc(512); if (!dp - || blk_pread(s->blk_cur, offset, dp, BDRV_SECTOR_SIZE, 0) = < 0) { + || blk_pread(s->blk_cur, offset, BDRV_SECTOR_SIZE, dp, 0) = < 0) { result =3D 1; } else { dpp =3D dp + ((sec & 31) << 4); @@ -351,8 +351,8 @@ static inline int onenand_prog_spare(OneNANDState *s, i= nt sec, int secn, dpp[i] &=3D sp[i]; } if (s->blk_cur) { - result =3D blk_pwrite(s->blk_cur, offset, dp, - BDRV_SECTOR_SIZE, 0) < 0; + result =3D blk_pwrite(s->blk_cur, offset, BDRV_SECTOR_SIZE= , dp, + 0) < 0; } } g_free(dp); @@ -370,17 +370,17 @@ static inline int onenand_erase(OneNANDState *s, int = sec, int num) for (; num > 0; num--, sec++) { if (s->blk_cur) { int erasesec =3D s->secs_cur + (sec >> 5); - if (blk_pwrite(s->blk_cur, sec << BDRV_SECTOR_BITS, blankbuf, - BDRV_SECTOR_SIZE, 0) < 0) { + if (blk_pwrite(s->blk_cur, sec << BDRV_SECTOR_BITS, + BDRV_SECTOR_SIZE, blankbuf, 0) < 0) { goto fail; } - if (blk_pread(s->blk_cur, erasesec << BDRV_SECTOR_BITS, tmpbuf, - BDRV_SECTOR_SIZE, 0) < 0) { + if (blk_pread(s->blk_cur, erasesec << BDRV_SECTOR_BITS, + BDRV_SECTOR_SIZE, tmpbuf, 0) < 0) { goto fail; } memcpy(tmpbuf + ((sec & 31) << 4), blankbuf, 1 << 4); - if (blk_pwrite(s->blk_cur, erasesec << BDRV_SECTOR_BITS, tmpbu= f, - BDRV_SECTOR_SIZE, 0) < 0) { + if (blk_pwrite(s->blk_cur, erasesec << BDRV_SECTOR_BITS, + BDRV_SECTOR_SIZE, tmpbuf, 0) < 0) { goto fail; } } else { diff --git a/hw/block/pflash_cfi01.c b/hw/block/pflash_cfi01.c index 74c7190302..0cbc2fb4cb 100644 --- a/hw/block/pflash_cfi01.c +++ b/hw/block/pflash_cfi01.c @@ -392,8 +392,8 @@ static void pflash_update(PFlashCFI01 *pfl, int offset, /* widen to sector boundaries */ offset =3D QEMU_ALIGN_DOWN(offset, BDRV_SECTOR_SIZE); offset_end =3D QEMU_ALIGN_UP(offset_end, BDRV_SECTOR_SIZE); - ret =3D blk_pwrite(pfl->blk, offset, pfl->storage + offset, - offset_end - offset, 0); + ret =3D blk_pwrite(pfl->blk, offset, offset_end - offset, + pfl->storage + offset, 0); if (ret < 0) { /* TODO set error bit in status */ error_report("Could not update PFLASH: %s", strerror(-ret)); diff --git a/hw/block/pflash_cfi02.c b/hw/block/pflash_cfi02.c index 02c514fb6e..2a99b286b0 100644 --- a/hw/block/pflash_cfi02.c +++ b/hw/block/pflash_cfi02.c @@ -400,8 +400,8 @@ static void pflash_update(PFlashCFI02 *pfl, int offset,= int size) /* widen to sector boundaries */ offset =3D QEMU_ALIGN_DOWN(offset, BDRV_SECTOR_SIZE); offset_end =3D QEMU_ALIGN_UP(offset_end, BDRV_SECTOR_SIZE); - ret =3D blk_pwrite(pfl->blk, offset, pfl->storage + offset, - offset_end - offset, 0); + ret =3D blk_pwrite(pfl->blk, offset, offset_end - offset, + pfl->storage + offset, 0); if (ret < 0) { /* TODO set error bit in status */ error_report("Could not update PFLASH: %s", strerror(-ret)); diff --git a/hw/ide/atapi.c b/hw/ide/atapi.c index 7e405657df..49b648f980 100644 --- a/hw/ide/atapi.c +++ b/hw/ide/atapi.c @@ -98,11 +98,11 @@ cd_read_sector_sync(IDEState *s) switch (s->cd_sector_size) { case 2048: ret =3D blk_pread(s->blk, (int64_t)s->lba << ATAPI_SECTOR_BITS, - s->io_buffer, ATAPI_SECTOR_SIZE, 0); + ATAPI_SECTOR_SIZE, s->io_buffer, 0); break; case 2352: ret =3D blk_pread(s->blk, (int64_t)s->lba << ATAPI_SECTOR_BITS, - s->io_buffer + 16, ATAPI_SECTOR_SIZE, 0); + ATAPI_SECTOR_SIZE, s->io_buffer + 16, 0); if (ret >=3D 0) { cd_data_to_raw(s->io_buffer, s->lba); } diff --git a/hw/misc/mac_via.c b/hw/misc/mac_via.c index d259def2d2..1e749999ed 100644 --- a/hw/misc/mac_via.c +++ b/hw/misc/mac_via.c @@ -351,7 +351,7 @@ static void via1_one_second(void *opaque) static void pram_update(MOS6522Q800VIA1State *v1s) { if (v1s->blk) { - if (blk_pwrite(v1s->blk, 0, v1s->PRAM, sizeof(v1s->PRAM), 0) < 0) { + if (blk_pwrite(v1s->blk, 0, sizeof(v1s->PRAM), v1s->PRAM, 0) < 0) { qemu_log("pram_update: cannot write to file\n"); } } @@ -1029,7 +1029,7 @@ static void mos6522_q800_via1_realize(DeviceState *de= v, Error **errp) return; } =20 - len =3D blk_pread(v1s->blk, 0, v1s->PRAM, sizeof(v1s->PRAM), 0); + len =3D blk_pread(v1s->blk, 0, sizeof(v1s->PRAM), v1s->PRAM, 0); if (len < 0) { error_setg(errp, "can't read PRAM contents"); return; diff --git a/hw/misc/sifive_u_otp.c b/hw/misc/sifive_u_otp.c index c730bb1ae0..6d7fdb040a 100644 --- a/hw/misc/sifive_u_otp.c +++ b/hw/misc/sifive_u_otp.c @@ -64,8 +64,8 @@ static uint64_t sifive_u_otp_read(void *opaque, hwaddr ad= dr, unsigned int size) if (s->blk) { int32_t buf; =20 - if (blk_pread(s->blk, s->pa * SIFIVE_U_OTP_FUSE_WORD, &buf, - SIFIVE_U_OTP_FUSE_WORD, 0) < 0) { + if (blk_pread(s->blk, s->pa * SIFIVE_U_OTP_FUSE_WORD, + SIFIVE_U_OTP_FUSE_WORD, &buf, 0) < 0) { error_report("read error index<%d>", s->pa); return 0xff; } @@ -167,8 +167,8 @@ static void sifive_u_otp_write(void *opaque, hwaddr add= r, /* write to backend */ if (s->blk) { if (blk_pwrite(s->blk, s->pa * SIFIVE_U_OTP_FUSE_WORD, - &s->fuse[s->pa], SIFIVE_U_OTP_FUSE_WORD, - 0) < 0) { + SIFIVE_U_OTP_FUSE_WORD, &s->fuse[s->pa], 0) + < 0) { error_report("write error index<%d>", s->pa); } } @@ -240,7 +240,7 @@ static void sifive_u_otp_realize(DeviceState *dev, Erro= r **errp) return; } =20 - if (blk_pread(s->blk, 0, s->fuse, filesize, 0) < 0) { + if (blk_pread(s->blk, 0, filesize, s->fuse, 0) < 0) { error_setg(errp, "failed to read the initial flash content= "); return; } @@ -261,14 +261,14 @@ static void sifive_u_otp_realize(DeviceState *dev, Er= ror **errp) =20 serial_data =3D s->serial; if (blk_pwrite(s->blk, index * SIFIVE_U_OTP_FUSE_WORD, - &serial_data, SIFIVE_U_OTP_FUSE_WORD, 0) < 0) { + SIFIVE_U_OTP_FUSE_WORD, &serial_data, 0) < 0) { error_setg(errp, "failed to write index<%d>", index); return; } =20 serial_data =3D ~(s->serial); if (blk_pwrite(s->blk, (index + 1) * SIFIVE_U_OTP_FUSE_WORD, - &serial_data, SIFIVE_U_OTP_FUSE_WORD, 0) < 0) { + SIFIVE_U_OTP_FUSE_WORD, &serial_data, 0) < 0) { error_setg(errp, "failed to write index<%d>", index + 1); return; } diff --git a/hw/nvram/eeprom_at24c.c b/hw/nvram/eeprom_at24c.c index 876b3dd5dc..b480c8193c 100644 --- a/hw/nvram/eeprom_at24c.c +++ b/hw/nvram/eeprom_at24c.c @@ -64,7 +64,7 @@ int at24c_eeprom_event(I2CSlave *s, enum i2c_event event) case I2C_START_RECV: DPRINTK("clear\n"); if (ee->blk && ee->changed) { - int len =3D blk_pwrite(ee->blk, 0, ee->mem, ee->rsize, 0); + int len =3D blk_pwrite(ee->blk, 0, ee->rsize, ee->mem, 0); if (len < 0) { ERR(TYPE_AT24C_EE " : failed to write backing file\n"); @@ -163,7 +163,7 @@ void at24c_eeprom_reset(DeviceState *state) memset(ee->mem, 0, ee->rsize); =20 if (ee->blk) { - int len =3D blk_pread(ee->blk, 0, ee->mem, ee->rsize, 0); + int len =3D blk_pread(ee->blk, 0, ee->rsize, ee->mem, 0); =20 if (len < 0) { ERR(TYPE_AT24C_EE diff --git a/hw/nvram/spapr_nvram.c b/hw/nvram/spapr_nvram.c index 4d32d92ad4..34f25afd4a 100644 --- a/hw/nvram/spapr_nvram.c +++ b/hw/nvram/spapr_nvram.c @@ -130,7 +130,7 @@ static void rtas_nvram_store(PowerPCCPU *cpu, SpaprMach= ineState *spapr, =20 ret =3D 0; if (nvram->blk) { - ret =3D blk_pwrite(nvram->blk, offset, membuf, len, 0); + ret =3D blk_pwrite(nvram->blk, offset, len, membuf, 0); } =20 assert(nvram->buf); @@ -179,7 +179,7 @@ static void spapr_nvram_realize(SpaprVioDevice *dev, Er= ror **errp) } =20 if (nvram->blk) { - int alen =3D blk_pread(nvram->blk, 0, nvram->buf, nvram->size, 0); + int alen =3D blk_pread(nvram->blk, 0, nvram->size, nvram->buf, 0); =20 if (alen < 0) { error_setg(errp, "can't read spapr-nvram contents"); @@ -224,7 +224,7 @@ static void postload_update_cb(void *opaque, bool runni= ng, RunState state) qemu_del_vm_change_state_handler(nvram->vmstate); nvram->vmstate =3D NULL; =20 - blk_pwrite(nvram->blk, 0, nvram->buf, nvram->size, 0); + blk_pwrite(nvram->blk, 0, nvram->size, nvram->buf, 0); } =20 static int spapr_nvram_post_load(void *opaque, int version_id) diff --git a/hw/nvram/xlnx-bbram.c b/hw/nvram/xlnx-bbram.c index cb245b864c..c6b484cc85 100644 --- a/hw/nvram/xlnx-bbram.c +++ b/hw/nvram/xlnx-bbram.c @@ -124,7 +124,7 @@ static void bbram_bdrv_read(XlnxBBRam *s, Error **errp) blk_name(s->blk)); } =20 - if (blk_pread(s->blk, 0, ram, nr, 0) < 0) { + if (blk_pread(s->blk, 0, nr, ram, 0) < 0) { error_setg(errp, "%s: Failed to read %u bytes from BBRAM backstore.", blk_name(s->blk), nr); @@ -159,7 +159,7 @@ static void bbram_bdrv_sync(XlnxBBRam *s, uint64_t hwad= dr) } =20 offset =3D hwaddr - A_BBRAM_0; - rc =3D blk_pwrite(s->blk, offset, &le32, 4, 0); + rc =3D blk_pwrite(s->blk, offset, 4, &le32, 0); if (rc < 0) { bbram_bdrv_error(s, rc, g_strdup_printf("write to offset %u", offs= et)); } diff --git a/hw/nvram/xlnx-efuse.c b/hw/nvram/xlnx-efuse.c index edaac9cf7c..fdfffaab99 100644 --- a/hw/nvram/xlnx-efuse.c +++ b/hw/nvram/xlnx-efuse.c @@ -77,7 +77,7 @@ static int efuse_bdrv_read(XlnxEFuse *s, Error **errp) blk_name(s->blk)); } =20 - if (blk_pread(s->blk, 0, ram, nr, 0) < 0) { + if (blk_pread(s->blk, 0, nr, ram, 0) < 0) { error_setg(errp, "%s: Failed to read %u bytes from eFUSE backstore= .", blk_name(s->blk), nr); return -1; @@ -105,7 +105,7 @@ static void efuse_bdrv_sync(XlnxEFuse *s, unsigned int = bit) le32 =3D cpu_to_le32(xlnx_efuse_get_row(s, bit)); =20 row_offset =3D (bit / 32) * 4; - if (blk_pwrite(s->blk, row_offset, &le32, 4, 0) < 0) { + if (blk_pwrite(s->blk, row_offset, 4, &le32, 0) < 0) { error_report("%s: Failed to write offset %u of eFUSE backstore.", blk_name(s->blk), row_offset); } diff --git a/hw/ppc/pnv_pnor.c b/hw/ppc/pnv_pnor.c index f341f5a9c9..6280408299 100644 --- a/hw/ppc/pnv_pnor.c +++ b/hw/ppc/pnv_pnor.c @@ -44,8 +44,8 @@ static void pnv_pnor_update(PnvPnor *s, int offset, int s= ize) offset =3D QEMU_ALIGN_DOWN(offset, BDRV_SECTOR_SIZE); offset_end =3D QEMU_ALIGN_UP(offset_end, BDRV_SECTOR_SIZE); =20 - ret =3D blk_pwrite(s->blk, offset, s->storage + offset, - offset_end - offset, 0); + ret =3D blk_pwrite(s->blk, offset, offset_end - offset, s->storage + o= ffset, + 0); if (ret < 0) { error_report("Could not update PNOR offset=3D0x%" PRIx32" : %s", o= ffset, strerror(-ret)); @@ -99,7 +99,7 @@ static void pnv_pnor_realize(DeviceState *dev, Error **er= rp) =20 s->storage =3D blk_blockalign(s->blk, s->size); =20 - if (blk_pread(s->blk, 0, s->storage, s->size, 0) < 0) { + if (blk_pread(s->blk, 0, s->size, s->storage, 0) < 0) { error_setg(errp, "failed to read the initial flash content"); return; } diff --git a/hw/sd/sd.c b/hw/sd/sd.c index 701170bf37..da5bdd134a 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -752,7 +752,7 @@ void sd_set_cb(SDState *sd, qemu_irq readonly, qemu_irq= insert) static void sd_blk_read(SDState *sd, uint64_t addr, uint32_t len) { trace_sdcard_read_block(addr, len); - if (!sd->blk || blk_pread(sd->blk, addr, sd->data, len, 0) < 0) { + if (!sd->blk || blk_pread(sd->blk, addr, len, sd->data, 0) < 0) { fprintf(stderr, "sd_blk_read: read error on host side\n"); } } @@ -760,7 +760,7 @@ static void sd_blk_read(SDState *sd, uint64_t addr, uin= t32_t len) static void sd_blk_write(SDState *sd, uint64_t addr, uint32_t len) { trace_sdcard_write_block(addr, len); - if (!sd->blk || blk_pwrite(sd->blk, addr, sd->data, len, 0) < 0) { + if (!sd->blk || blk_pwrite(sd->blk, addr, len, sd->data, 0) < 0) { fprintf(stderr, "sd_blk_write: write error on host side\n"); } } diff --git a/include/sysemu/block-backend-io.h b/include/sysemu/block-backe= nd-io.h index 288bf39be1..357534e3de 100644 --- a/include/sysemu/block-backend-io.h +++ b/include/sysemu/block-backend-io.h @@ -102,9 +102,9 @@ int coroutine_fn blk_co_copy_range(BlockBackend *blk_in= , int64_t off_in, * the "I/O or GS" API. */ =20 -int blk_pread(BlockBackend *blk, int64_t offset, void *buf, int bytes, +int blk_pread(BlockBackend *blk, int64_t offset, int bytes, void *buf, BdrvRequestFlags flags); -int blk_pwrite(BlockBackend *blk, int64_t offset, const void *buf, int byt= es, +int blk_pwrite(BlockBackend *blk, int64_t offset, int bytes, const void *b= uf, BdrvRequestFlags flags); int coroutine_fn blk_co_preadv(BlockBackend *blk, int64_t offset, int64_t bytes, QEMUIOVector *qiov, diff --git a/migration/block.c b/migration/block.c index fa216af025..9de7d4d20b 100644 --- a/migration/block.c +++ b/migration/block.c @@ -569,7 +569,7 @@ static int mig_save_device_dirty(QEMUFile *f, BlkMigDev= State *bmds, blk_mig_unlock(); } else { ret =3D blk_pread(bmds->blk, sector * BDRV_SECTOR_SIZE, - blk->buf, nr_sectors * BDRV_SECTOR_SIZE, 0= ); + nr_sectors * BDRV_SECTOR_SIZE, blk->buf, 0= ); if (ret < 0) { goto error; } @@ -976,8 +976,8 @@ static int block_load(QEMUFile *f, void *opaque, int ve= rsion_id) cluster_size, BDRV_REQ_MAY_UNMAP); } else { - ret =3D blk_pwrite(blk, cur_addr, cur_buf, - cluster_size, 0); + ret =3D blk_pwrite(blk, cur_addr, cluster_size, cu= r_buf, + 0); } if (ret < 0) { break; diff --git a/nbd/server.c b/nbd/server.c index 849433aa3a..ada16089f3 100644 --- a/nbd/server.c +++ b/nbd/server.c @@ -2039,8 +2039,8 @@ static int coroutine_fn nbd_co_send_sparse_read(NBDCl= ient *client, stl_be_p(&chunk.length, pnum); ret =3D nbd_co_send_iov(client, iov, 1, errp); } else { - ret =3D blk_pread(exp->common.blk, offset + progress, - data + progress, pnum, 0); + ret =3D blk_pread(exp->common.blk, offset + progress, pnum, + data + progress, 0); if (ret < 0) { error_setg_errno(errp, -ret, "reading from file failed"); break; @@ -2444,7 +2444,7 @@ static coroutine_fn int nbd_do_cmd_read(NBDClient *cl= ient, NBDRequest *request, data, request->len, errp); } =20 - ret =3D blk_pread(exp->common.blk, request->from, data, request->len, = 0); + ret =3D blk_pread(exp->common.blk, request->from, request->len, data, = 0); if (ret < 0) { return nbd_send_generic_reply(client, request->handle, ret, "reading from file failed", errp); @@ -2511,7 +2511,7 @@ static coroutine_fn int nbd_handle_request(NBDClient = *client, if (request->flags & NBD_CMD_FLAG_FUA) { flags |=3D BDRV_REQ_FUA; } - ret =3D blk_pwrite(exp->common.blk, request->from, data, request->= len, + ret =3D blk_pwrite(exp->common.blk, request->from, request->len, d= ata, flags); return nbd_send_generic_reply(client, request->handle, ret, "writing to file failed", errp); diff --git a/qemu-img.c b/qemu-img.c index edec9e4097..8d214e649e 100644 --- a/qemu-img.c +++ b/qemu-img.c @@ -1309,7 +1309,7 @@ static int check_empty_sectors(BlockBackend *blk, int= 64_t offset, int ret =3D 0; int64_t idx; =20 - ret =3D blk_pread(blk, offset, buffer, bytes, 0); + ret =3D blk_pread(blk, offset, bytes, buffer, 0); if (ret < 0) { error_report("Error while reading offset %" PRId64 " of %s: %s", offset, filename, strerror(-ret)); @@ -1526,7 +1526,7 @@ static int img_compare(int argc, char **argv) int64_t pnum; =20 chunk =3D MIN(chunk, IO_BUF_SIZE); - ret =3D blk_pread(blk1, offset, buf1, chunk, 0); + ret =3D blk_pread(blk1, offset, chunk, buf1, 0); if (ret < 0) { error_report("Error while reading offset %" PRId64 " of %s: %s", @@ -1534,7 +1534,7 @@ static int img_compare(int argc, char **argv) ret =3D 4; goto out; } - ret =3D blk_pread(blk2, offset, buf2, chunk, 0); + ret =3D blk_pread(blk2, offset, chunk, buf2, 0); if (ret < 0) { error_report("Error while reading offset %" PRId64 " of %s: %s", @@ -3779,7 +3779,7 @@ static int img_rebase(int argc, char **argv) n =3D old_backing_size - offset; } =20 - ret =3D blk_pread(blk_old_backing, offset, buf_old, n, 0); + ret =3D blk_pread(blk_old_backing, offset, n, buf_old, 0); if (ret < 0) { error_report("error while reading from old backing fil= e"); goto out; @@ -3793,7 +3793,7 @@ static int img_rebase(int argc, char **argv) n =3D new_backing_size - offset; } =20 - ret =3D blk_pread(blk_new_backing, offset, buf_new, n, 0); + ret =3D blk_pread(blk_new_backing, offset, n, buf_new, 0); if (ret < 0) { error_report("error while reading from new backing fil= e"); goto out; @@ -3812,8 +3812,8 @@ static int img_rebase(int argc, char **argv) if (buf_old_is_zero) { ret =3D blk_pwrite_zeroes(blk, offset + written, p= num, 0); } else { - ret =3D blk_pwrite(blk, offset + written, - buf_old + written, pnum, 0); + ret =3D blk_pwrite(blk, offset + written, pnum, + buf_old + written, 0); } if (ret < 0) { error_report("Error while writing to COW image: %s= ", @@ -5124,7 +5124,7 @@ static int img_dd(int argc, char **argv) =20 bytes =3D (in_pos + in.bsz > size) ? size - in_pos : in.bsz; =20 - in_ret =3D blk_pread(blk1, in_pos, in.buf, bytes, 0); + in_ret =3D blk_pread(blk1, in_pos, bytes, in.buf, 0); if (in_ret < 0) { error_report("error while reading from input image file: %s", strerror(-in_ret)); @@ -5133,7 +5133,7 @@ static int img_dd(int argc, char **argv) } in_pos +=3D bytes; =20 - out_ret =3D blk_pwrite(blk2, out_pos, in.buf, bytes, 0); + out_ret =3D blk_pwrite(blk2, out_pos, bytes, in.buf, 0); if (out_ret < 0) { error_report("error while writing to output image file: %s", strerror(-out_ret)); diff --git a/qemu-io-cmds.c b/qemu-io-cmds.c index 582e1a7090..c8cbaed0cd 100644 --- a/qemu-io-cmds.c +++ b/qemu-io-cmds.c @@ -547,7 +547,7 @@ static int do_pread(BlockBackend *blk, char *buf, int64= _t offset, return -ERANGE; } =20 - ret =3D blk_pread(blk, offset, (uint8_t *)buf, bytes, 0); + ret =3D blk_pread(blk, offset, bytes, (uint8_t *)buf, 0); if (ret < 0) { return ret; } @@ -564,7 +564,7 @@ static int do_pwrite(BlockBackend *blk, char *buf, int6= 4_t offset, return -ERANGE; } =20 - ret =3D blk_pwrite(blk, offset, (uint8_t *)buf, bytes, flags); + ret =3D blk_pwrite(blk, offset, bytes, (uint8_t *)buf, flags); if (ret < 0) { return ret; } diff --git a/tests/unit/test-block-iothread.c b/tests/unit/test-block-iothr= ead.c index bfd12c9c15..0ced5333ff 100644 --- a/tests/unit/test-block-iothread.c +++ b/tests/unit/test-block-iothread.c @@ -116,11 +116,11 @@ static void test_sync_op_blk_pread(BlockBackend *blk) int ret; =20 /* Success */ - ret =3D blk_pread(blk, 0, buf, sizeof(buf), 0); + ret =3D blk_pread(blk, 0, sizeof(buf), buf, 0); g_assert_cmpint(ret, =3D=3D, 0); =20 /* Early error: Negative offset */ - ret =3D blk_pread(blk, -2, buf, sizeof(buf), 0); + ret =3D blk_pread(blk, -2, sizeof(buf), buf, 0); g_assert_cmpint(ret, =3D=3D, -EIO); } =20 @@ -130,11 +130,11 @@ static void test_sync_op_blk_pwrite(BlockBackend *blk) int ret; =20 /* Success */ - ret =3D blk_pwrite(blk, 0, buf, sizeof(buf), 0); + ret =3D blk_pwrite(blk, 0, sizeof(buf), buf, 0); g_assert_cmpint(ret, =3D=3D, 0); =20 /* Early error: Negative offset */ - ret =3D blk_pwrite(blk, -2, buf, sizeof(buf), 0); + ret =3D blk_pwrite(blk, -2, sizeof(buf), buf, 0); g_assert_cmpint(ret, =3D=3D, -EIO); } =20 --=20 2.35.3 From nobody Sat Apr 27 06:34:23 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1652791736905310.6888321776747; Tue, 17 May 2022 05:48:56 -0700 (PDT) Received: from localhost ([::1]:52150 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nqwdD-0005N5-N2 for importer@patchew.org; Tue, 17 May 2022 08:48:55 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42350) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nqvWt-0001Hx-6z for qemu-devel@nongnu.org; Tue, 17 May 2022 07:38:19 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:58539) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nqvWr-0002y3-FZ for qemu-devel@nongnu.org; Tue, 17 May 2022 07:38:18 -0400 Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-656-oBlIRUJfMeSmJZG2msw3JQ-1; Tue, 17 May 2022 07:38:16 -0400 Received: by mail-wm1-f69.google.com with SMTP id g14-20020a1c4e0e000000b0039425ef54d6so828973wmh.9 for ; Tue, 17 May 2022 04:38:15 -0700 (PDT) Received: from fedora.redhat.com ([2001:8a0:f4d9:2101:a4fa:5f93:755f:6249]) by smtp.gmail.com with ESMTPSA id 22-20020a05600c229600b003970b2fa72dsm1648177wmf.22.2022.05.17.04.38.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 May 2022 04:38:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1652787497; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=p8fubifgvUx4aKzc12MRBVGC/H09uzZcP6aLv24/EHk=; b=NgUK1NoyviaW3AIqWTPSOMxYpONEDn9azECs3QyY7LJYsKolfFU5dt7npDFHBy31xQ0Gdz l+wFqu9oDfwBhCyJlvvrA605raeVvEPw94FmO4IkDuqgWZAUYv4ER0G8+psnr57OVSLpzy WhXTrRHAMLbG5909hBaoDJj8o6l4ebc= X-MC-Unique: oBlIRUJfMeSmJZG2msw3JQ-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=p8fubifgvUx4aKzc12MRBVGC/H09uzZcP6aLv24/EHk=; b=gfQvgF9Yfn47IpOHIhVZm/rxPBrPeSeaEG4P/QkJK2Y+E2wLjIvscK393Tdv2GJimW 8XCQN9WyTayMw+sYtHkrJ97cyKb7EI1w4TfhhrsmoI1tAkP3lvgcLFSj1gjib3gGt5Nd CBeinrg1QkUadX23ugfJeWUA0AoXLOhhqaBY5Z4J7vdV3680ELGmsCJD3+CeTo95VQAS V+SdEI+gkmCoei0Q70WMGs/bwn0s2IgPJlJl4PS9U9BsyAjyaw2hGKA3MEj/+JxrS5WV K3sirUSCly/kzKy22eCT3baZKN/R9Uh76vweSE3fkOd9uibGKO1pUj0YeeyWa0nOBYCB m4Kw== X-Gm-Message-State: AOAM531GS4SyoyFdAoC81oMhdJm3mdIMn3/+Z+VplJWlOdKDb36w7iX7 upLb8bY+NcqOM9emS+C6VJGW5A5xSefVhPa/zjpBAU1t+L5r/FXe6S/tsFXwsFG3dfwEecIF4FK nfOoiCzhUgv3EuneCS6Ru2YLfyGBBwEkZxG78iSrjUnHOnTDAetOH4m7jJ0rGoReQ X-Received: by 2002:a05:600c:3d8c:b0:394:6097:9994 with SMTP id bi12-20020a05600c3d8c00b0039460979994mr31319819wmb.29.1652787494342; Tue, 17 May 2022 04:38:14 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwG4cuLQUNbg7eAMbCWRnjL3o4kUxo72cbTgvdikjlqnhrcrvqMmEM3jifXwgTf9OCCqO8xUQ== X-Received: by 2002:a05:600c:3d8c:b0:394:6097:9994 with SMTP id bi12-20020a05600c3d8c00b0039460979994mr31319797wmb.29.1652787494058; Tue, 17 May 2022 04:38:14 -0700 (PDT) From: Alberto Faria To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, Hanna Reitz , Kevin Wolf , Alberto Faria Subject: [PATCH 04/18] block: Make 'bytes' param of blk_{pread, pwrite}() an int64_t Date: Tue, 17 May 2022 12:37:58 +0100 Message-Id: <20220517113812.199312-1-afaria@redhat.com> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20220517113524.197910-1-afaria@redhat.com> References: <20220517113524.197910-1-afaria@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.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; Received-SPF: pass client-ip=170.10.133.124; envelope-from=afaria@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1652791737936100001 Content-Type: text/plain; charset="utf-8" For consistency with other I/O functions, and in preparation to implement them using generated_co_wrapper. Signed-off-by: Alberto Faria Reviewed-by: Hanna Reitz Reviewed-by: Paolo Bonzini --- block/block-backend.c | 6 +++--- include/sysemu/block-backend-io.h | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/block/block-backend.c b/block/block-backend.c index 16a0093c52..5b9706c443 100644 --- a/block/block-backend.c +++ b/block/block-backend.c @@ -1567,7 +1567,7 @@ BlockAIOCB *blk_aio_pwrite_zeroes(BlockBackend *blk, = int64_t offset, flags | BDRV_REQ_ZERO_WRITE, cb, opaque); } =20 -int blk_pread(BlockBackend *blk, int64_t offset, int bytes, void *buf, +int blk_pread(BlockBackend *blk, int64_t offset, int64_t bytes, void *buf, BdrvRequestFlags flags) { int ret; @@ -1581,8 +1581,8 @@ int blk_pread(BlockBackend *blk, int64_t offset, int = bytes, void *buf, return ret; } =20 -int blk_pwrite(BlockBackend *blk, int64_t offset, int bytes, const void *b= uf, - BdrvRequestFlags flags) +int blk_pwrite(BlockBackend *blk, int64_t offset, int64_t bytes, + const void *buf, BdrvRequestFlags flags) { QEMUIOVector qiov =3D QEMU_IOVEC_INIT_BUF(qiov, buf, bytes); IO_OR_GS_CODE(); diff --git a/include/sysemu/block-backend-io.h b/include/sysemu/block-backe= nd-io.h index 357534e3de..6630316795 100644 --- a/include/sysemu/block-backend-io.h +++ b/include/sysemu/block-backend-io.h @@ -102,10 +102,10 @@ int coroutine_fn blk_co_copy_range(BlockBackend *blk_= in, int64_t off_in, * the "I/O or GS" API. */ =20 -int blk_pread(BlockBackend *blk, int64_t offset, int bytes, void *buf, +int blk_pread(BlockBackend *blk, int64_t offset, int64_t bytes, void *buf, BdrvRequestFlags flags); -int blk_pwrite(BlockBackend *blk, int64_t offset, int bytes, const void *b= uf, - BdrvRequestFlags flags); +int blk_pwrite(BlockBackend *blk, int64_t offset, int64_t bytes, + const void *buf, BdrvRequestFlags flags); int coroutine_fn blk_co_preadv(BlockBackend *blk, int64_t offset, int64_t bytes, QEMUIOVector *qiov, BdrvRequestFlags flags); --=20 2.35.3 From nobody Sat Apr 27 06:34:23 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1652793109; cv=none; d=zohomail.com; s=zohoarc; b=fDnIfDFlfPwVE7ObtL9romO26bSB/GYZdWmnt/oZuIh8B5j8c7vTqAc2OXR51KJRmg1RPNzm4fY+owCBM+SD1VwdueGm5wYAGcNammzVR4aqpH4S21JMCkBo9s5j1ERDe2WuOsD5iMx+vB4zCrfZgoW9LtCib00xr3/CTgZz1bg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1652793109; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=8ZGn1mwRF5eJYBssPx5tCYlzvjVCDP6Amd7KTebTKFI=; b=n7HhZA+5GEmSP2Ddp8Ohk/7qBZ7KxomYjLPT6X0aSz1W1PFzkq+AGzkKGAqF5PsrM/3GIfc663GabKVfRzs6dH/TSG5NpDQ2qC5cp8InTh9sXJJ9CbpSirWzCa1VpB7NjuWwhrvTggobUX+481iQbA74y/K2phS0r83qQX7gYjA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1652793109434264.0569822904487; Tue, 17 May 2022 06:11:49 -0700 (PDT) Received: from localhost ([::1]:37266 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nqwzM-0001PG-4l for importer@patchew.org; Tue, 17 May 2022 09:11:48 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42486) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nqvXH-0001Pw-VS for qemu-devel@nongnu.org; Tue, 17 May 2022 07:38:45 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:36587) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nqvXG-00030N-AO for qemu-devel@nongnu.org; Tue, 17 May 2022 07:38:43 -0400 Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-235-TcbPv75RNZ-Sq28z6rZHKw-1; Tue, 17 May 2022 07:38:40 -0400 Received: by mail-wr1-f72.google.com with SMTP id e11-20020adffc4b000000b0020d059c2347so1205766wrs.18 for ; Tue, 17 May 2022 04:38:40 -0700 (PDT) Received: from fedora.redhat.com ([2001:8a0:f4d9:2101:a4fa:5f93:755f:6249]) by smtp.gmail.com with ESMTPSA id d24-20020adfa358000000b0020d02cbbb87sm8090317wrb.16.2022.05.17.04.38.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 May 2022 04:38:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1652787521; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=8ZGn1mwRF5eJYBssPx5tCYlzvjVCDP6Amd7KTebTKFI=; b=KQpAeNGxXwlH/4rIJcRsHRDLTVY8ifSic5goe9sH0nYZjX9v/6x9HE1xRogZ0mg1Ih6HU5 SJj+kVOz8xL6tqSiGFqaKWl0TEdAAyCCl9ZWqUHDPoUO4m5scXRAC7U8ugO6iGv7b46T2P Qa62jVdfOZkuVxYg8+t47srEXPkpRwI= X-MC-Unique: TcbPv75RNZ-Sq28z6rZHKw-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=8ZGn1mwRF5eJYBssPx5tCYlzvjVCDP6Amd7KTebTKFI=; b=e/XRIH99+qY8l+sE04hXfncpruiKbibx4LLrkJrMlzCa8LbuNHLGxauh3DqDDRLyT5 CIUnwxYlN0e0oxCXdp6AcNanRzJAv0fuwGoe8PXrBzSp5DpEefYnsZAiHelGqDFk+tXJ 9qpE6y6Blw+PzWPxxskrMolHr7LFhCYJHw2JRxPsLzhMdko4McSIi/DUhn4FrtoHzxPI xhYa3mwyzxX/sya2bR1gJeaeFRkhEaY5r2NAqk8tL1zx36oIIDWrsuMhEn0wh+Xs95c+ HfmuVMik1DLiKF22tB/SG050Z6UpCRR00TzdYDupysiiabIlCr9vfooeDFGJNYGe055+ /7gQ== X-Gm-Message-State: AOAM53211YV/635nVkvAKSbV6WJHVSX1XI98cjIoRNVlWM5iZAddrLeI x6yrTNaNSSGVw6GcF/ulHjCsQb8v07Y/ufpUxtkXoAuYdpL9OJFheC80dGksEERaN9SaKo5EM9G byg/jtQBLEueoG1G3LXPUAfGiEo2lhbewdSRCXxV6YEH9FO6VxYQrzVaOp7MilBG1 X-Received: by 2002:adf:d1e3:0:b0:20c:6684:9b10 with SMTP id g3-20020adfd1e3000000b0020c66849b10mr18574481wrd.53.1652787519147; Tue, 17 May 2022 04:38:39 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxBZnPlObsyzuXXHiR/Tr/X2gI3mOYQ6oMGSW1Zo5xG98cbknZ+YgjRoS7klgM2FjOBB22DWw== X-Received: by 2002:adf:d1e3:0:b0:20c:6684:9b10 with SMTP id g3-20020adfd1e3000000b0020c66849b10mr18574460wrd.53.1652787518980; Tue, 17 May 2022 04:38:38 -0700 (PDT) From: Alberto Faria To: qemu-devel@nongnu.org Cc: Hanna Reitz , Kevin Wolf , qemu-block@nongnu.org, Alberto Faria Subject: [PATCH 05/18] block: Make blk_co_pwrite() take a const buffer Date: Tue, 17 May 2022 12:38:24 +0100 Message-Id: <20220517113837.199696-1-afaria@redhat.com> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20220517113524.197910-1-afaria@redhat.com> References: <20220517113524.197910-1-afaria@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.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; Received-SPF: pass client-ip=170.10.129.124; envelope-from=afaria@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1652793111597100001 Content-Type: text/plain; charset="utf-8" It does not mutate the buffer. Signed-off-by: Alberto Faria Reviewed-by: Hanna Reitz Reviewed-by: Paolo Bonzini --- include/sysemu/block-backend-io.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/sysemu/block-backend-io.h b/include/sysemu/block-backe= nd-io.h index 6630316795..6440e92028 100644 --- a/include/sysemu/block-backend-io.h +++ b/include/sysemu/block-backend-io.h @@ -130,7 +130,7 @@ static inline int coroutine_fn blk_co_pread(BlockBacken= d *blk, int64_t offset, } =20 static inline int coroutine_fn blk_co_pwrite(BlockBackend *blk, int64_t of= fset, - int64_t bytes, void *buf, + int64_t bytes, const void *bu= f, BdrvRequestFlags flags) { QEMUIOVector qiov =3D QEMU_IOVEC_INIT_BUF(qiov, buf, bytes); --=20 2.35.3 From nobody Sat Apr 27 06:34:23 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1652793403258421.13410840738015; Tue, 17 May 2022 06:16:43 -0700 (PDT) Received: from localhost ([::1]:45614 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nqx45-00078o-VO for importer@patchew.org; Tue, 17 May 2022 09:16:42 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42542) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nqvXK-0001QH-5l for qemu-devel@nongnu.org; Tue, 17 May 2022 07:38:47 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:34695) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nqvXH-00030g-Mc for qemu-devel@nongnu.org; Tue, 17 May 2022 07:38:45 -0400 Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-135-eMC4qDDzOxy10E2sU2Vflw-1; Tue, 17 May 2022 07:38:42 -0400 Received: by mail-wm1-f70.google.com with SMTP id 205-20020a1c02d6000000b003928cd3853aso1127139wmc.9 for ; Tue, 17 May 2022 04:38:41 -0700 (PDT) Received: from fedora.redhat.com ([2001:8a0:f4d9:2101:a4fa:5f93:755f:6249]) by smtp.gmail.com with ESMTPSA id d24-20020adfa358000000b0020d02cbbb87sm8090317wrb.16.2022.05.17.04.38.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 May 2022 04:38:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1652787523; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Z8mb+gRmFTLQXI0zNFsxMV+BAGi19v6JSSrvt+VUkCU=; b=EReyIUtwB/hxJs195shU09E22X0kvt7Ri9iMP7pfmePm2tVVj+gBvde16ZqyXn+1eTX9QG MUOwa3B0ypRmI0a+H6EwbpmA7srGPuUGGPsYb2/Z+V3v1gBJyr7Mp57NtiQnSxmKxlJdaj b6+hCFGRjvzge6DXdTvvzFCO4PhDo3M= X-MC-Unique: eMC4qDDzOxy10E2sU2Vflw-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Z8mb+gRmFTLQXI0zNFsxMV+BAGi19v6JSSrvt+VUkCU=; b=i14zMRhJ3Da878Tfq3Lnrz/kNFM0n6wgqqAkHLuKvJCywNUk+aSLaMyKXb249dNXK7 A7KF05j7XrQQ+gKrAoYwuqlWJAdDa/8CEg03+5qGYug7vtXOAhBPFoKg/bgO2BSmVKyh NxfLAvs5P7y49w0U7cZJZIucc7PCxwSRyTXnTOtvPaxsIg2nFkaoMRKxKJK/NR+2EI+l 3IZnNVCHNdYdcEnkqo1dHik3vRgmnsptT+7dfghVsNW3Q8DT3bJbCAD4Aaj0y0FQSn6R dx8GY4iountlHwPK6DDNtLX1FMXxww5Sw3D5O0cjPsg65GFLfyrhdH/F6If/CBxRiO5e 87gw== X-Gm-Message-State: AOAM530KsLHUTZbuZ4V7gRLXYscUZYsIh+IRoYMPoTryYXRlImRAhlwB cRiqtD3ZmtW/KWDNnF1QMfFMFxB8Pm9yeunSHv24TzoH2MOKv0KYkKBj2yoBz0lGYgVUb5IUmev M8ZB8QfSLcLZwIbZCHQdmR7g1nVi+ymy+btRKVqHBOPk3N9qr6b6aRuumTDTXbS0P X-Received: by 2002:a05:600c:29c7:b0:394:79dd:6cf2 with SMTP id s7-20020a05600c29c700b0039479dd6cf2mr31149303wmd.78.1652787520563; Tue, 17 May 2022 04:38:40 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwH6uOT/tPHX5neZhsdNebL6GxVd8gzp9p/+OUdnWGcz/YsF8o+hK9MBd8UOE0Mb+BEc58+9A== X-Received: by 2002:a05:600c:29c7:b0:394:79dd:6cf2 with SMTP id s7-20020a05600c29c700b0039479dd6cf2mr31149280wmd.78.1652787520251; Tue, 17 May 2022 04:38:40 -0700 (PDT) From: Alberto Faria To: qemu-devel@nongnu.org Cc: Hanna Reitz , Kevin Wolf , qemu-block@nongnu.org, Alberto Faria Subject: [PATCH 06/18] block: Implement blk_{pread, pwrite}() using generated_co_wrapper Date: Tue, 17 May 2022 12:38:25 +0100 Message-Id: <20220517113837.199696-2-afaria@redhat.com> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20220517113524.197910-1-afaria@redhat.com> References: <20220517113524.197910-1-afaria@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.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; Received-SPF: pass client-ip=170.10.129.124; envelope-from=afaria@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1652793404773100001 Content-Type: text/plain; charset="utf-8" We need to add include/sysemu/block-backend-io.h to the inputs of the block-gen.c target defined in block/meson.build. Signed-off-by: Alberto Faria Reviewed-by: Hanna Reitz --- block/block-backend.c | 23 ----------------------- block/coroutines.h | 4 ---- block/meson.build | 1 + include/sysemu/block-backend-io.h | 10 ++++++---- 4 files changed, 7 insertions(+), 31 deletions(-) diff --git a/block/block-backend.c b/block/block-backend.c index 5b9706c443..c2a4c44a99 100644 --- a/block/block-backend.c +++ b/block/block-backend.c @@ -1567,29 +1567,6 @@ BlockAIOCB *blk_aio_pwrite_zeroes(BlockBackend *blk,= int64_t offset, flags | BDRV_REQ_ZERO_WRITE, cb, opaque); } =20 -int blk_pread(BlockBackend *blk, int64_t offset, int64_t bytes, void *buf, - BdrvRequestFlags flags) -{ - int ret; - QEMUIOVector qiov =3D QEMU_IOVEC_INIT_BUF(qiov, buf, bytes); - IO_OR_GS_CODE(); - - blk_inc_in_flight(blk); - ret =3D blk_do_preadv(blk, offset, bytes, &qiov, flags); - blk_dec_in_flight(blk); - - return ret; -} - -int blk_pwrite(BlockBackend *blk, int64_t offset, int64_t bytes, - const void *buf, BdrvRequestFlags flags) -{ - QEMUIOVector qiov =3D QEMU_IOVEC_INIT_BUF(qiov, buf, bytes); - IO_OR_GS_CODE(); - - return blk_pwritev_part(blk, offset, bytes, &qiov, 0, flags); -} - int64_t blk_getlength(BlockBackend *blk) { IO_CODE(); diff --git a/block/coroutines.h b/block/coroutines.h index 3f41238b33..443ef2f2e6 100644 --- a/block/coroutines.h +++ b/block/coroutines.h @@ -112,10 +112,6 @@ bdrv_common_block_status_above(BlockDriverState *bs, int generated_co_wrapper nbd_do_establish_connection(BlockDriverState *bs, bool blocking, Error **e= rrp); =20 -int generated_co_wrapper -blk_do_preadv(BlockBackend *blk, int64_t offset, int64_t bytes, - QEMUIOVector *qiov, BdrvRequestFlags flags); - int generated_co_wrapper blk_do_pwritev_part(BlockBackend *blk, int64_t offset, int64_t bytes, QEMUIOVector *qiov, size_t qiov_offset, diff --git a/block/meson.build b/block/meson.build index 0b2a60c99b..60bc305597 100644 --- a/block/meson.build +++ b/block/meson.build @@ -136,6 +136,7 @@ block_gen_c =3D custom_target('block-gen.c', input: files( '../include/block/block-io.h', '../include/block/block-global-state= .h', + '../include/sysemu/block-backend-io.= h', 'coroutines.h' ), command: [wrapper_py, '@OUTPUT@', '@INPUT@']) diff --git a/include/sysemu/block-backend-io.h b/include/sysemu/block-backe= nd-io.h index 6440e92028..0804ce1c1d 100644 --- a/include/sysemu/block-backend-io.h +++ b/include/sysemu/block-backend-io.h @@ -102,10 +102,12 @@ int coroutine_fn blk_co_copy_range(BlockBackend *blk_= in, int64_t off_in, * the "I/O or GS" API. */ =20 -int blk_pread(BlockBackend *blk, int64_t offset, int64_t bytes, void *buf, - BdrvRequestFlags flags); -int blk_pwrite(BlockBackend *blk, int64_t offset, int64_t bytes, - const void *buf, BdrvRequestFlags flags); +int generated_co_wrapper blk_pread(BlockBackend *blk, int64_t offset, + int64_t bytes, void *buf, + BdrvRequestFlags flags); +int generated_co_wrapper blk_pwrite(BlockBackend *blk, int64_t offset, + int64_t bytes, const void *buf, + BdrvRequestFlags flags); int coroutine_fn blk_co_preadv(BlockBackend *blk, int64_t offset, int64_t bytes, QEMUIOVector *qiov, BdrvRequestFlags flags); --=20 2.35.3 From nobody Sat Apr 27 06:34:23 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1652793740; cv=none; d=zohomail.com; s=zohoarc; b=IfG51+F7oFNmJ1nqS8zjOPERX3LSHr368yfLyLGoaLXvkQusm2jlCRN121YX+VhOG8fGUDwh1W+/ksDv98u7h5+PNEtdCm9CSUMHjn6Oz2nZRMOfHUDSgMowsbX/5Vn1/pN/1QGGAU5Nr+HyxRV3lBzsD30WXVpqgdS/TwRO0hs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1652793740; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=M27/cDTXrZ53KC3THWHhHW0gI2qs/rOhIIFhyPNKSHA=; b=H6lsQz9gIPqt3dfVECE13/IZFsBy2NrZgw3WCQzSl2Fz9QQ9Na+b+RyqSTwvTAErX7jgyBhwmhrHeT6+ruMXfIwAP2RzlpTDldfBrmPC2TBHGhbO085l5chvPOOrImOWhRMFlf/+V9AWeLdlqyUy72qjM8aplv864VpxPPGFteY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1652793740190650.9152731471504; Tue, 17 May 2022 06:22:20 -0700 (PDT) Received: from localhost ([::1]:53826 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nqx9W-0004eZ-Qr for importer@patchew.org; Tue, 17 May 2022 09:22:18 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42554) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nqvXK-0001QK-Hb for qemu-devel@nongnu.org; Tue, 17 May 2022 07:38:47 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:34249) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nqvXI-00030r-K6 for qemu-devel@nongnu.org; Tue, 17 May 2022 07:38:46 -0400 Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-107-KENQ6gRZMsi3LqL0oDGJZg-1; Tue, 17 May 2022 07:38:42 -0400 Received: by mail-wm1-f71.google.com with SMTP id r6-20020a1c4406000000b00393f52ed5ceso856667wma.7 for ; Tue, 17 May 2022 04:38:42 -0700 (PDT) Received: from fedora.redhat.com ([2001:8a0:f4d9:2101:a4fa:5f93:755f:6249]) by smtp.gmail.com with ESMTPSA id d24-20020adfa358000000b0020d02cbbb87sm8090317wrb.16.2022.05.17.04.38.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 May 2022 04:38:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1652787523; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=M27/cDTXrZ53KC3THWHhHW0gI2qs/rOhIIFhyPNKSHA=; b=T6OVyNdvgkMUyPbtqzC+i5Hz93uLnE/BoJrw0Sig9077ks6MA5hnAyvq6WC1kDUOjFHpm3 84XRWuF8PBNUqV/2u/KMWw9K6XjJ36/lI35LXKBfcjvkSo2nUT2uH/ufbDLDoxseuvIgMf FYUm8KyhdrfDAghEtU0/TvRiOGimi3A= X-MC-Unique: KENQ6gRZMsi3LqL0oDGJZg-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=M27/cDTXrZ53KC3THWHhHW0gI2qs/rOhIIFhyPNKSHA=; b=oKQ+lAVZ4J/utmukxPDlSptYiu4Mkl8aS6jtsI0AYwIgI3mMyGiTUF804jgcgAH06V WgdrqYOms0bSUGkXpWAik1Oif3ZdOT6jBP14x6w5IFw9xkeo7dFM/RO+8jFmAsQjAqSs 3X2AxtNPqk1xJqBUg3f2oKvvn0Ro9B1rk8luoxoGgikYIlBpOhQNzTHE8WB/FOxl2uyg HiSI7LF5sXCF1ryb/SDcTmqETZvvYgDHdi7hGj+GfSEdz+ijhbqLlUvD0deE4rPT09Ti qu954Q1vrKpxfHD98547D2PUYxr767914G+bOjMZkYprr71ZKzGmvTStuVdJi8dwUMdH VXfA== X-Gm-Message-State: AOAM531Z/NkQWMCgJP90NJDJpe3FQ30Ii1YOrTKGqkResKVcrr6UElrl mbkin6Q0yhS8LV0R7LBkshhF426I0yYU/58U+bApfx+vIOQ/ObWs5oOW7j9r1kd+sT+Qg+DxBff ESLHnfQI84q2uwcacwQC/LW4Guj4hR5IUZ6yl/CrkWSZV/QGh9BuZ75qNFbjh/v8E X-Received: by 2002:a1c:7919:0:b0:392:a630:286c with SMTP id l25-20020a1c7919000000b00392a630286cmr20997658wme.72.1652787521513; Tue, 17 May 2022 04:38:41 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyL0gDrWuwsZyQTrtVEnh7efTRonSqcbweh893hH7Ym2BsxGnSImw4By9jhmKcJ+TT4Geg9kg== X-Received: by 2002:a1c:7919:0:b0:392:a630:286c with SMTP id l25-20020a1c7919000000b00392a630286cmr20997636wme.72.1652787521252; Tue, 17 May 2022 04:38:41 -0700 (PDT) From: Alberto Faria To: qemu-devel@nongnu.org Cc: Hanna Reitz , Kevin Wolf , qemu-block@nongnu.org, Alberto Faria Subject: [PATCH 07/18] block: Add blk_{preadv,pwritev}() Date: Tue, 17 May 2022 12:38:26 +0100 Message-Id: <20220517113837.199696-3-afaria@redhat.com> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20220517113524.197910-1-afaria@redhat.com> References: <20220517113524.197910-1-afaria@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.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; Received-SPF: pass client-ip=170.10.129.124; envelope-from=afaria@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1652793741535100001 Content-Type: text/plain; charset="utf-8" Implement them using generated_co_wrapper. Signed-off-by: Alberto Faria Reviewed-by: Hanna Reitz Reviewed-by: Paolo Bonzini --- include/sysemu/block-backend-io.h | 6 +++++ tests/unit/test-block-iothread.c | 42 ++++++++++++++++++++++++++++++- 2 files changed, 47 insertions(+), 1 deletion(-) diff --git a/include/sysemu/block-backend-io.h b/include/sysemu/block-backe= nd-io.h index 0804ce1c1d..3b548a8ae1 100644 --- a/include/sysemu/block-backend-io.h +++ b/include/sysemu/block-backend-io.h @@ -108,6 +108,9 @@ int generated_co_wrapper blk_pread(BlockBackend *blk, i= nt64_t offset, int generated_co_wrapper blk_pwrite(BlockBackend *blk, int64_t offset, int64_t bytes, const void *buf, BdrvRequestFlags flags); +int generated_co_wrapper blk_preadv(BlockBackend *blk, int64_t offset, + int64_t bytes, QEMUIOVector *qiov, + BdrvRequestFlags flags); int coroutine_fn blk_co_preadv(BlockBackend *blk, int64_t offset, int64_t bytes, QEMUIOVector *qiov, BdrvRequestFlags flags); @@ -115,6 +118,9 @@ int coroutine_fn blk_co_pwritev_part(BlockBackend *blk,= int64_t offset, int64_t bytes, QEMUIOVector *qiov, size_t qiov_offse= t, BdrvRequestFlags flags); +int generated_co_wrapper blk_pwritev(BlockBackend *blk, int64_t offset, + int64_t bytes, QEMUIOVector *qiov, + BdrvRequestFlags flags); int coroutine_fn blk_co_pwritev(BlockBackend *blk, int64_t offset, int64_t bytes, QEMUIOVector *qiov, BdrvRequestFlags flags); diff --git a/tests/unit/test-block-iothread.c b/tests/unit/test-block-iothr= ead.c index 0ced5333ff..b9c5da3a87 100644 --- a/tests/unit/test-block-iothread.c +++ b/tests/unit/test-block-iothread.c @@ -138,6 +138,36 @@ static void test_sync_op_blk_pwrite(BlockBackend *blk) g_assert_cmpint(ret, =3D=3D, -EIO); } =20 +static void test_sync_op_blk_preadv(BlockBackend *blk) +{ + uint8_t buf[512]; + QEMUIOVector qiov =3D QEMU_IOVEC_INIT_BUF(qiov, buf, sizeof(buf)); + int ret; + + /* Success */ + ret =3D blk_preadv(blk, 0, sizeof(buf), &qiov, 0); + g_assert_cmpint(ret, =3D=3D, 0); + + /* Early error: Negative offset */ + ret =3D blk_preadv(blk, -2, sizeof(buf), &qiov, 0); + g_assert_cmpint(ret, =3D=3D, -EIO); +} + +static void test_sync_op_blk_pwritev(BlockBackend *blk) +{ + uint8_t buf[512] =3D { 0 }; + QEMUIOVector qiov =3D QEMU_IOVEC_INIT_BUF(qiov, buf, sizeof(buf)); + int ret; + + /* Success */ + ret =3D blk_pwritev(blk, 0, sizeof(buf), &qiov, 0); + g_assert_cmpint(ret, =3D=3D, 0); + + /* Early error: Negative offset */ + ret =3D blk_pwritev(blk, -2, sizeof(buf), &qiov, 0); + g_assert_cmpint(ret, =3D=3D, -EIO); +} + static void test_sync_op_load_vmstate(BdrvChild *c) { uint8_t buf[512]; @@ -301,6 +331,14 @@ const SyncOpTest sync_op_tests[] =3D { .name =3D "/sync-op/pwrite", .fn =3D test_sync_op_pwrite, .blkfn =3D test_sync_op_blk_pwrite, + }, { + .name =3D "/sync-op/preadv", + .fn =3D NULL, + .blkfn =3D test_sync_op_blk_preadv, + }, { + .name =3D "/sync-op/pwritev", + .fn =3D NULL, + .blkfn =3D test_sync_op_blk_pwritev, }, { .name =3D "/sync-op/load_vmstate", .fn =3D test_sync_op_load_vmstate, @@ -349,7 +387,9 @@ static void test_sync_op(const void *opaque) =20 blk_set_aio_context(blk, ctx, &error_abort); aio_context_acquire(ctx); - t->fn(c); + if (t->fn) { + t->fn(c); + } if (t->blkfn) { t->blkfn(blk); } --=20 2.35.3 From nobody Sat Apr 27 06:34:23 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1652793946; cv=none; d=zohomail.com; s=zohoarc; b=OUnLOMqjy7ZDHYy8ZzVRDRVONYejOBuBa8P5wwMUTSdhXMwkXklQKvcz3hgFGyVkKdsur7K7Rum6pJKU54cS19wU5g/ZB/CSS1HUx849YA0zfYxREXWM0pR6oaYPPfexqigpoFbMM7ivz+X0aYID1TBUMfIf7uys4lpN9+VbrPI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1652793946; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=EIdk1TsYa8maC4Z/9m45vZrNJTsagxHINtxx3CxqRcI=; b=KRYqv41jCEJLF5488xjD/dV5Dd3XnjyXZ0rLVNTN7z0198LUc0mil1MMjUIaTv/MBqtWjv1Ahps7eSQmzv9HBw3gckmfylzkQmTx8ARC/ZRc16Od9NU+1dxKysnaudDQNxCCwQdT4uTiwVwpyA8fzIFLk6PKSVoKxAIOOm0p6xA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1652793946635591.4864830738126; Tue, 17 May 2022 06:25:46 -0700 (PDT) Received: from localhost ([::1]:34142 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nqxCr-0002Fa-Ew for importer@patchew.org; Tue, 17 May 2022 09:25:45 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42680) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nqvXQ-0001SN-87 for qemu-devel@nongnu.org; Tue, 17 May 2022 07:38:57 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:47799) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nqvXK-00031E-9m for qemu-devel@nongnu.org; Tue, 17 May 2022 07:38:51 -0400 Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-132-u_IbI-h6Muu41sjjctbhUA-1; Tue, 17 May 2022 07:38:44 -0400 Received: by mail-wm1-f69.google.com with SMTP id bg7-20020a05600c3c8700b0039468585269so8064090wmb.3 for ; Tue, 17 May 2022 04:38:44 -0700 (PDT) Received: from fedora.redhat.com ([2001:8a0:f4d9:2101:a4fa:5f93:755f:6249]) by smtp.gmail.com with ESMTPSA id d24-20020adfa358000000b0020d02cbbb87sm8090317wrb.16.2022.05.17.04.38.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 May 2022 04:38:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1652787525; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=EIdk1TsYa8maC4Z/9m45vZrNJTsagxHINtxx3CxqRcI=; b=JshwQF+haZ8Yhe+wdveLzQUpYyzKtEW4bG0KulxiOOQXAs05QwVCl1Zw7RU6x49Lxfybbp rwjO5X2g7R4sdI9JUQOpoHkFwKku5tPl434QDBi3jB8AmfQM7HJ1tzbOdPzBFNE70xDPAK aLmzkAkV8CMoOZ+zNUV8FQY/Qf83rZc= X-MC-Unique: u_IbI-h6Muu41sjjctbhUA-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=EIdk1TsYa8maC4Z/9m45vZrNJTsagxHINtxx3CxqRcI=; b=4laTLAuXzpYAg1Ck7824aK0ECXnCVEKrrL+GGTQ7kGy3nWKA3N8IgP3xuNQfaN2SsK kHQMMxDeIGP7lBdPuBMYmvNS+SUaIZfEEobk+EXZR5rKQcq6FuBHP913PpUayde0AURk Ci1id1xh/6s4JQyCbCR7UjUhjTXfVGtCs4uXY7RwaJ2342P71v7e8YhG/vC5oqAaGvQx T5QGRr5UXfmy0x+I/d0otCV5/oYW87SHUneOnLt1a6d/Wx/UGV1CLXNELPCOm2Yx7EVt SjnIIjodV8ODUqhc22eM/YL1njZ4UZzV+3UcgE2Iz+q9iQ7FH6EP1oD1iTX37XMuzI49 hPow== X-Gm-Message-State: AOAM532Oxwo79OvzGrRSzzZ5HCePUQ/qZnlf//E9TEKDxT5ppPumoLD+ YNV36M/CcZ/SmRwN0Gm/8O3HlHPGD3pSLiTT3IsKwLjUXwhm0WDW/DDcqPlsSfksEc9LngCPtVk N3BCHzENw2P8sJiKoYL9hxIYjzn94pGUhipwjqYr+QyRdemaD0gsAOhEroXRR0zlb X-Received: by 2002:adf:dd8a:0:b0:20d:ff7:ce01 with SMTP id x10-20020adfdd8a000000b0020d0ff7ce01mr5624445wrl.242.1652787523078; Tue, 17 May 2022 04:38:43 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwU3lohNCIpp6kqoS7jQiiownu9p/diiEQqi8+Oc7nQOc6t4Suz9ojd2y79xnySNkdCqS5qWQ== X-Received: by 2002:adf:dd8a:0:b0:20d:ff7:ce01 with SMTP id x10-20020adfdd8a000000b0020d0ff7ce01mr5624420wrl.242.1652787522779; Tue, 17 May 2022 04:38:42 -0700 (PDT) From: Alberto Faria To: qemu-devel@nongnu.org Cc: Hanna Reitz , Kevin Wolf , qemu-block@nongnu.org, Alberto Faria Subject: [PATCH 08/18] block: Add blk_[co_]preadv_part() Date: Tue, 17 May 2022 12:38:27 +0100 Message-Id: <20220517113837.199696-4-afaria@redhat.com> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20220517113524.197910-1-afaria@redhat.com> References: <20220517113524.197910-1-afaria@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.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; Received-SPF: pass client-ip=170.10.133.124; envelope-from=afaria@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1652793948471100001 Content-Type: text/plain; charset="utf-8" Implement blk_preadv_part() using generated_co_wrapper. Signed-off-by: Alberto Faria Reviewed-by: Hanna Reitz Reviewed-by: Paolo Bonzini --- block/block-backend.c | 30 +++++++++++++++++++++++------- block/coroutines.h | 5 ----- include/sysemu/block-backend-io.h | 7 +++++++ tests/unit/test-block-iothread.c | 19 +++++++++++++++++++ 4 files changed, 49 insertions(+), 12 deletions(-) diff --git a/block/block-backend.c b/block/block-backend.c index c2a4c44a99..3920e1f45e 100644 --- a/block/block-backend.c +++ b/block/block-backend.c @@ -1284,9 +1284,10 @@ static void coroutine_fn blk_wait_while_drained(Bloc= kBackend *blk) } =20 /* To be called between exactly one pair of blk_inc/dec_in_flight() */ -int coroutine_fn -blk_co_do_preadv(BlockBackend *blk, int64_t offset, int64_t bytes, - QEMUIOVector *qiov, BdrvRequestFlags flags) +static int coroutine_fn +blk_co_do_preadv_part(BlockBackend *blk, int64_t offset, int64_t bytes, + QEMUIOVector *qiov, size_t qiov_offset, + BdrvRequestFlags flags) { int ret; BlockDriverState *bs; @@ -1311,7 +1312,8 @@ blk_co_do_preadv(BlockBackend *blk, int64_t offset, i= nt64_t bytes, bytes, false); } =20 - ret =3D bdrv_co_preadv(blk->root, offset, bytes, qiov, flags); + ret =3D bdrv_co_preadv_part(blk->root, offset, bytes, qiov, qiov_offse= t, + flags); bdrv_dec_in_flight(bs); return ret; } @@ -1324,7 +1326,21 @@ int coroutine_fn blk_co_preadv(BlockBackend *blk, in= t64_t offset, IO_OR_GS_CODE(); =20 blk_inc_in_flight(blk); - ret =3D blk_co_do_preadv(blk, offset, bytes, qiov, flags); + ret =3D blk_co_do_preadv_part(blk, offset, bytes, qiov, 0, flags); + blk_dec_in_flight(blk); + + return ret; +} + +int coroutine_fn blk_co_preadv_part(BlockBackend *blk, int64_t offset, + int64_t bytes, QEMUIOVector *qiov, + size_t qiov_offset, BdrvRequestFlags f= lags) +{ + int ret; + IO_OR_GS_CODE(); + + blk_inc_in_flight(blk); + ret =3D blk_co_do_preadv_part(blk, offset, bytes, qiov, qiov_offset, f= lags); blk_dec_in_flight(blk); =20 return ret; @@ -1541,8 +1557,8 @@ static void blk_aio_read_entry(void *opaque) QEMUIOVector *qiov =3D rwco->iobuf; =20 assert(qiov->size =3D=3D acb->bytes); - rwco->ret =3D blk_co_do_preadv(rwco->blk, rwco->offset, acb->bytes, - qiov, rwco->flags); + rwco->ret =3D blk_co_do_preadv_part(rwco->blk, rwco->offset, acb->byte= s, qiov, + 0, rwco->flags); blk_aio_complete(acb); } =20 diff --git a/block/coroutines.h b/block/coroutines.h index 443ef2f2e6..85423f8db6 100644 --- a/block/coroutines.h +++ b/block/coroutines.h @@ -63,11 +63,6 @@ nbd_co_do_establish_connection(BlockDriverState *bs, boo= l blocking, Error **errp); =20 =20 -int coroutine_fn -blk_co_do_preadv(BlockBackend *blk, int64_t offset, int64_t bytes, - QEMUIOVector *qiov, BdrvRequestFlags flags); - - int coroutine_fn blk_co_do_pwritev_part(BlockBackend *blk, int64_t offset, int64_t bytes, QEMUIOVector *qiov, size_t qiov_offset, diff --git a/include/sysemu/block-backend-io.h b/include/sysemu/block-backe= nd-io.h index 3b548a8ae1..29954a466c 100644 --- a/include/sysemu/block-backend-io.h +++ b/include/sysemu/block-backend-io.h @@ -108,6 +108,13 @@ int generated_co_wrapper blk_pread(BlockBackend *blk, = int64_t offset, int generated_co_wrapper blk_pwrite(BlockBackend *blk, int64_t offset, int64_t bytes, const void *buf, BdrvRequestFlags flags); +int generated_co_wrapper blk_preadv_part(BlockBackend *blk, int64_t offset, + int64_t bytes, QEMUIOVector *qiov, + size_t qiov_offset, + BdrvRequestFlags flags); +int coroutine_fn blk_co_preadv_part(BlockBackend *blk, int64_t offset, + int64_t bytes, QEMUIOVector *qiov, + size_t qiov_offset, BdrvRequestFlags f= lags); int generated_co_wrapper blk_preadv(BlockBackend *blk, int64_t offset, int64_t bytes, QEMUIOVector *qiov, BdrvRequestFlags flags); diff --git a/tests/unit/test-block-iothread.c b/tests/unit/test-block-iothr= ead.c index b9c5da3a87..2fa1248445 100644 --- a/tests/unit/test-block-iothread.c +++ b/tests/unit/test-block-iothread.c @@ -168,6 +168,21 @@ static void test_sync_op_blk_pwritev(BlockBackend *blk) g_assert_cmpint(ret, =3D=3D, -EIO); } =20 +static void test_sync_op_blk_preadv_part(BlockBackend *blk) +{ + uint8_t buf[512]; + QEMUIOVector qiov =3D QEMU_IOVEC_INIT_BUF(qiov, buf, sizeof(buf)); + int ret; + + /* Success */ + ret =3D blk_preadv_part(blk, 0, sizeof(buf), &qiov, 0, 0); + g_assert_cmpint(ret, =3D=3D, 0); + + /* Early error: Negative offset */ + ret =3D blk_preadv_part(blk, -2, sizeof(buf), &qiov, 0, 0); + g_assert_cmpint(ret, =3D=3D, -EIO); +} + static void test_sync_op_load_vmstate(BdrvChild *c) { uint8_t buf[512]; @@ -339,6 +354,10 @@ const SyncOpTest sync_op_tests[] =3D { .name =3D "/sync-op/pwritev", .fn =3D NULL, .blkfn =3D test_sync_op_blk_pwritev, + }, { + .name =3D "/sync-op/preadv_part", + .fn =3D NULL, + .blkfn =3D test_sync_op_blk_preadv_part, }, { .name =3D "/sync-op/load_vmstate", .fn =3D test_sync_op_load_vmstate, --=20 2.35.3 From nobody Sat Apr 27 06:34:23 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1652791661; cv=none; d=zohomail.com; s=zohoarc; b=Cqux22Jv+XbXwv8bQXrqTHkr4MGT686r99Uua5XnClCeLLiaXgPNfS+pFeHSXfibRdH4O0AzqBfiFTpMQZ+r8gvcM5gx8rKG16Ph1FBnZIl0Cyv86TXkEKFVXTyps8s+JTGOrP2IxRGvw7nS9u+sNi0zVuvSd78dJSEBuT64Xj4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1652791661; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=ekMzNy+MhsgyK2ckfwNyB5/S23fthhn9rEIdCX/jnVI=; b=DvNt6ihEE+x8L8YBKQaPDhVkCGqCMAGEzQ3cFZx3nkyD9Q4J+Zfw6ZHfyE9Wp2R6hj07J1C/ul8I30s8O6qGwQnbdsgb2OT6hFWtncfv8ebrXyYOmZyQwaUOtnIUbKqXSVUysY+42uJhNDGKWSM8yFa6YYo7dR4AxACO41drshQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1652791661048129.30061301656156; Tue, 17 May 2022 05:47:41 -0700 (PDT) Received: from localhost ([::1]:48670 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nqwbz-0002g4-Th for importer@patchew.org; Tue, 17 May 2022 08:47:39 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42624) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nqvXM-0001RS-W5 for qemu-devel@nongnu.org; Tue, 17 May 2022 07:38:51 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:21903) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nqvXL-00031Z-AG for qemu-devel@nongnu.org; Tue, 17 May 2022 07:38:48 -0400 Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-177-Aswc45RYMW-vfj1aNJFWZg-1; Tue, 17 May 2022 07:38:45 -0400 Received: by mail-wm1-f71.google.com with SMTP id p24-20020a1c5458000000b003945d2ffc6eso8065213wmi.5 for ; Tue, 17 May 2022 04:38:45 -0700 (PDT) Received: from fedora.redhat.com ([2001:8a0:f4d9:2101:a4fa:5f93:755f:6249]) by smtp.gmail.com with ESMTPSA id d24-20020adfa358000000b0020d02cbbb87sm8090317wrb.16.2022.05.17.04.38.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 May 2022 04:38:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1652787526; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ekMzNy+MhsgyK2ckfwNyB5/S23fthhn9rEIdCX/jnVI=; b=LcM6ssfvfvqQUoPGOlDF7k9Wg5hUEi2NGmNBUfszXYdPzAre4WrEqg34FmHQkJvxvkTw2Z FmwCozlUCHxnp/8ZRlMsllKFH+s15B8socrltMejgV6Kep2ViWq4XNsfV9bYZt4lpm/KJR 4vIXDjtibi2ETyUiw5JQ0nG9VeeG0M8= X-MC-Unique: Aswc45RYMW-vfj1aNJFWZg-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ekMzNy+MhsgyK2ckfwNyB5/S23fthhn9rEIdCX/jnVI=; b=t4RiF7ID4jbm04tdca+Sm9vikTJD+2q6/LYZRGIVjxR+M1A7DywirkfH59Kp7FlOVm PUxIVttjBW7HqLaWJitwVz2BBsXI3FhKYsQyMHPSz3Dab7hs0Q7j17QdHIy10vw58fd+ vM7qMunbi7HIrgYO5Kn8t/1p/FZdSLgNQqZgjGub1AgNjT1k2Ja/M0hJ8rVkeaoOIi4m Hs+ah9XrQFIkZFaOSUxVb+yQH5/grEaogw5beqT032dYg2/DGF84Vj/4S98tbVW6Jtf0 94HBIyW3bTf6X6pT6hfMBQjQmhF04sT+yQEtchAtcJTMlLKvNdLSXUkHEN6aS3tT9PJW DWjw== X-Gm-Message-State: AOAM531y5Q02sgZ5qSlJoL9rdsDKkPI2w6YtZLb0Rzki1vg2OcWAYtxN 4S4Za21YuNzMsemvXSllON9cHmzpNYpGeG6VaeF+X7ul2WVxY5tgr/un2/gr5cZkAF389tRWA2/ JqbiDstPn20+WrZNN5WqmmDph96aiw1Gu39g5xpM+BKXxw4DmVGuEbWzwYaMzs8en X-Received: by 2002:a5d:620c:0:b0:20c:f50a:dafa with SMTP id y12-20020a5d620c000000b0020cf50adafamr15300755wru.460.1652787524097; Tue, 17 May 2022 04:38:44 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw/gvfn+7xTwWMxlBTDCq5ikev7B22GlAnmrhj+6hy0iSpUNkvLwdPXsva9b4Y6Xa7mR48Wqg== X-Received: by 2002:a5d:620c:0:b0:20c:f50a:dafa with SMTP id y12-20020a5d620c000000b0020cf50adafamr15300738wru.460.1652787523888; Tue, 17 May 2022 04:38:43 -0700 (PDT) From: Alberto Faria To: qemu-devel@nongnu.org Cc: Hanna Reitz , Kevin Wolf , qemu-block@nongnu.org, Alberto Faria Subject: [PATCH 09/18] block: Export blk_pwritev_part() in block-backend-io.h Date: Tue, 17 May 2022 12:38:28 +0100 Message-Id: <20220517113837.199696-5-afaria@redhat.com> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20220517113524.197910-1-afaria@redhat.com> References: <20220517113524.197910-1-afaria@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.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; Received-SPF: pass client-ip=170.10.129.124; envelope-from=afaria@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1652791661470100001 Content-Type: text/plain; charset="utf-8" Also convert it into a generated_co_wrapper. Signed-off-by: Alberto Faria Reviewed-by: Hanna Reitz Reviewed-by: Paolo Bonzini --- block/block-backend.c | 14 -------------- block/coroutines.h | 5 ----- include/sysemu/block-backend-io.h | 4 ++++ tests/unit/test-block-iothread.c | 19 +++++++++++++++++++ 4 files changed, 23 insertions(+), 19 deletions(-) diff --git a/block/block-backend.c b/block/block-backend.c index 3920e1f45e..35bf35aadd 100644 --- a/block/block-backend.c +++ b/block/block-backend.c @@ -1407,20 +1407,6 @@ int coroutine_fn blk_co_pwritev(BlockBackend *blk, i= nt64_t offset, return blk_co_pwritev_part(blk, offset, bytes, qiov, 0, flags); } =20 -static int coroutine_fn blk_pwritev_part(BlockBackend *blk, int64_t offset, - int64_t bytes, - QEMUIOVector *qiov, size_t qiov_o= ffset, - BdrvRequestFlags flags) -{ - int ret; - - blk_inc_in_flight(blk); - ret =3D blk_do_pwritev_part(blk, offset, bytes, qiov, qiov_offset, fla= gs); - blk_dec_in_flight(blk); - - return ret; -} - typedef struct BlkRwCo { BlockBackend *blk; int64_t offset; diff --git a/block/coroutines.h b/block/coroutines.h index 85423f8db6..94fd283f62 100644 --- a/block/coroutines.h +++ b/block/coroutines.h @@ -107,11 +107,6 @@ bdrv_common_block_status_above(BlockDriverState *bs, int generated_co_wrapper nbd_do_establish_connection(BlockDriverState *bs, bool blocking, Error **e= rrp); =20 -int generated_co_wrapper -blk_do_pwritev_part(BlockBackend *blk, int64_t offset, int64_t bytes, - QEMUIOVector *qiov, size_t qiov_offset, - BdrvRequestFlags flags); - int generated_co_wrapper blk_do_ioctl(BlockBackend *blk, unsigned long int req, void *buf); =20 diff --git a/include/sysemu/block-backend-io.h b/include/sysemu/block-backe= nd-io.h index 29954a466c..31ebd8b6cf 100644 --- a/include/sysemu/block-backend-io.h +++ b/include/sysemu/block-backend-io.h @@ -121,6 +121,10 @@ int generated_co_wrapper blk_preadv(BlockBackend *blk,= int64_t offset, int coroutine_fn blk_co_preadv(BlockBackend *blk, int64_t offset, int64_t bytes, QEMUIOVector *qiov, BdrvRequestFlags flags); +int generated_co_wrapper blk_pwritev_part(BlockBackend *blk, int64_t offse= t, + int64_t bytes, QEMUIOVector *qio= v, + size_t qiov_offset, + BdrvRequestFlags flags); int coroutine_fn blk_co_pwritev_part(BlockBackend *blk, int64_t offset, int64_t bytes, QEMUIOVector *qiov, size_t qiov_offse= t, diff --git a/tests/unit/test-block-iothread.c b/tests/unit/test-block-iothr= ead.c index 2fa1248445..6061762c97 100644 --- a/tests/unit/test-block-iothread.c +++ b/tests/unit/test-block-iothread.c @@ -183,6 +183,21 @@ static void test_sync_op_blk_preadv_part(BlockBackend = *blk) g_assert_cmpint(ret, =3D=3D, -EIO); } =20 +static void test_sync_op_blk_pwritev_part(BlockBackend *blk) +{ + uint8_t buf[512]; + QEMUIOVector qiov =3D QEMU_IOVEC_INIT_BUF(qiov, buf, sizeof(buf)); + int ret; + + /* Success */ + ret =3D blk_pwritev_part(blk, 0, sizeof(buf), &qiov, 0, 0); + g_assert_cmpint(ret, =3D=3D, 0); + + /* Early error: Negative offset */ + ret =3D blk_pwritev_part(blk, -2, sizeof(buf), &qiov, 0, 0); + g_assert_cmpint(ret, =3D=3D, -EIO); +} + static void test_sync_op_load_vmstate(BdrvChild *c) { uint8_t buf[512]; @@ -358,6 +373,10 @@ const SyncOpTest sync_op_tests[] =3D { .name =3D "/sync-op/preadv_part", .fn =3D NULL, .blkfn =3D test_sync_op_blk_preadv_part, + }, { + .name =3D "/sync-op/pwritev_part", + .fn =3D NULL, + .blkfn =3D test_sync_op_blk_pwritev_part, }, { .name =3D "/sync-op/load_vmstate", .fn =3D test_sync_op_load_vmstate, --=20 2.35.3 From nobody Sat Apr 27 06:34:23 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1652792460; cv=none; d=zohomail.com; s=zohoarc; b=RUNiDO3K0swtjuDZ6AyY4i8Avs84MpB06Rv4TOZXEsE/kiwagiaxk16FEUVz7JjyQ3+3Mv+WrajV0MK1BmkCAD1bo+0NQgsIXRrcVQmFEhOHjPBM6VfH/ErJ8C1BNRfRjD6Ooavh4tBZw9TlLCIlGMe0iUxfleXcCbLv3R2elwU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1652792460; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=sbHjgAuBiTIZfhuyF7aCBmD3cJYURuCRHR+mofh519Y=; b=hSdo4yjmmNi+Rgy98PhWuXMzKPHQ2Avm6masrNY1cHAHBkcxc5bLG5wnVB07xYxz2GPiWLGgYl43SslcJhMT1aNoG+JfXhNRqVC1g9jlZYSOXeL560iCtRwej72X9Hp/U5Uymk31DtwmCImGhzBqBrrsivOA8WUD8NeXmAitcAw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1652792460496897.2004349341471; Tue, 17 May 2022 06:01:00 -0700 (PDT) Received: from localhost ([::1]:43518 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nqwot-0002AF-DX for importer@patchew.org; Tue, 17 May 2022 09:00:59 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42656) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nqvXO-0001RV-UN for qemu-devel@nongnu.org; Tue, 17 May 2022 07:38:51 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:39392) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nqvXM-00031p-A4 for qemu-devel@nongnu.org; Tue, 17 May 2022 07:38:49 -0400 Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-262-OYUyt9ELMoClI9sIBcfxjA-1; Tue, 17 May 2022 07:38:46 -0400 Received: by mail-wm1-f69.google.com with SMTP id c187-20020a1c35c4000000b003970013833aso3618276wma.1 for ; Tue, 17 May 2022 04:38:46 -0700 (PDT) Received: from fedora.redhat.com ([2001:8a0:f4d9:2101:a4fa:5f93:755f:6249]) by smtp.gmail.com with ESMTPSA id d24-20020adfa358000000b0020d02cbbb87sm8090317wrb.16.2022.05.17.04.38.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 May 2022 04:38:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1652787527; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=sbHjgAuBiTIZfhuyF7aCBmD3cJYURuCRHR+mofh519Y=; b=UoB1/cDbzLiQgmGgH1NqDP3J7DWl7VXfyjcdissiW8Jfv6nEWWnXUREMjXR4HGOOsyuq5J bxETy9in8GiZbSsOaQuL8cqtmPx4PtJ/EYBzdgfxJJVhiEmiqp99lhJRZwZPzMwAx+izv1 razG6H4MEkCpH8ayOvtpRxaJduDEbKE= X-MC-Unique: OYUyt9ELMoClI9sIBcfxjA-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=sbHjgAuBiTIZfhuyF7aCBmD3cJYURuCRHR+mofh519Y=; b=BXOhyzkKTcGZuBn9012aFFo4rBdCAf5uYTxPV9iQ+8Ps0IzNvpVif1nKArUVUD6/Dy fl5Lr4NR9s1jV7BQ88+7uhDcrM7hknc8gPNpxR8xFcgE0Yevct2WeccjY4dcf5jl/NkX 1mvTg2ddergwXtYUUBrQDEskRsZyG61L/xzyuAKSTln4IaWB07IWaqYIeSL5yQ0K7/qd 9vYl4os1xV87sZJ1li1Xv/7g+/N8ouVSGohSttOS6T0P1RcScdqp+s7YPIc89PaQyVUZ TyiJusVTHjjNZW197X8/EHCZekSSCpmqpV440W1ZSFPhy8e5X6y1AVtQBJ5DuIRA2odg HdRg== X-Gm-Message-State: AOAM532BZlTkhoXPYkNjglFAYEAVsZUK4dwNXTLAJg+bJ4WYzuQtCDRh drfgfpE8urmwYj0Qs34uelOqiuMTlQQ3yAhlNzzhiilqhoFn2sFUY+e2B91sfX5irc4YBCMvd2h ZqSf27mGtf265OAIUv1AYVOKsQ/AkLcRn4+nWdMtzgEq7GPE5g/xlckALsLpE2eXw X-Received: by 2002:a05:600c:a03:b0:395:bb63:b457 with SMTP id z3-20020a05600c0a0300b00395bb63b457mr27802667wmp.192.1652787525189; Tue, 17 May 2022 04:38:45 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzF4ufcpf4xgwoYUxlyp1+62RuTTnQRWHlxohNjJtNR2EMdt9QMFgUkUWblzprpB+w3aQ2o8Q== X-Received: by 2002:a05:600c:a03:b0:395:bb63:b457 with SMTP id z3-20020a05600c0a0300b00395bb63b457mr27802641wmp.192.1652787524892; Tue, 17 May 2022 04:38:44 -0700 (PDT) From: Alberto Faria To: qemu-devel@nongnu.org Cc: Hanna Reitz , Kevin Wolf , qemu-block@nongnu.org, Alberto Faria Subject: [PATCH 10/18] block: Change blk_pwrite_compressed() param order Date: Tue, 17 May 2022 12:38:29 +0100 Message-Id: <20220517113837.199696-6-afaria@redhat.com> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20220517113524.197910-1-afaria@redhat.com> References: <20220517113524.197910-1-afaria@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.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; Received-SPF: pass client-ip=170.10.133.124; envelope-from=afaria@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1652792462309100001 Content-Type: text/plain; charset="utf-8" Swap 'buf' and 'bytes' around for consistency with other I/O functions. Signed-off-by: Alberto Faria Reviewed-by: Hanna Reitz Reviewed-by: Paolo Bonzini --- block/block-backend.c | 4 ++-- include/sysemu/block-backend-io.h | 4 ++-- qemu-img.c | 2 +- qemu-io-cmds.c | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/block/block-backend.c b/block/block-backend.c index 35bf35aadd..ddb1d4e179 100644 --- a/block/block-backend.c +++ b/block/block-backend.c @@ -2324,8 +2324,8 @@ int coroutine_fn blk_co_pwrite_zeroes(BlockBackend *b= lk, int64_t offset, flags | BDRV_REQ_ZERO_WRITE); } =20 -int blk_pwrite_compressed(BlockBackend *blk, int64_t offset, const void *b= uf, - int64_t bytes) +int blk_pwrite_compressed(BlockBackend *blk, int64_t offset, int64_t bytes, + const void *buf) { QEMUIOVector qiov =3D QEMU_IOVEC_INIT_BUF(qiov, buf, bytes); IO_OR_GS_CODE(); diff --git a/include/sysemu/block-backend-io.h b/include/sysemu/block-backe= nd-io.h index 31ebd8b6cf..c64207cdcb 100644 --- a/include/sysemu/block-backend-io.h +++ b/include/sysemu/block-backend-io.h @@ -168,8 +168,8 @@ int blk_flush(BlockBackend *blk); =20 int blk_ioctl(BlockBackend *blk, unsigned long int req, void *buf); =20 -int blk_pwrite_compressed(BlockBackend *blk, int64_t offset, const void *b= uf, - int64_t bytes); +int blk_pwrite_compressed(BlockBackend *blk, int64_t offset, int64_t bytes, + const void *buf); int blk_pdiscard(BlockBackend *blk, int64_t offset, int64_t bytes); int blk_pwrite_zeroes(BlockBackend *blk, int64_t offset, int64_t bytes, BdrvRequestFlags flags); diff --git a/qemu-img.c b/qemu-img.c index 8d214e649e..52f3aeed9b 100644 --- a/qemu-img.c +++ b/qemu-img.c @@ -2114,7 +2114,7 @@ static int convert_do_copy(ImgConvertState *s) =20 if (s->compressed && !s->ret) { /* signal EOF to align */ - ret =3D blk_pwrite_compressed(s->target, 0, NULL, 0); + ret =3D blk_pwrite_compressed(s->target, 0, 0, NULL); if (ret < 0) { return ret; } diff --git a/qemu-io-cmds.c b/qemu-io-cmds.c index c8cbaed0cd..952dc940f1 100644 --- a/qemu-io-cmds.c +++ b/qemu-io-cmds.c @@ -631,7 +631,7 @@ static int do_write_compressed(BlockBackend *blk, char = *buf, int64_t offset, return -ERANGE; } =20 - ret =3D blk_pwrite_compressed(blk, offset, buf, bytes); + ret =3D blk_pwrite_compressed(blk, offset, bytes, buf); if (ret < 0) { return ret; } --=20 2.35.3 From nobody Sat Apr 27 06:34:23 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1652791862; cv=none; d=zohomail.com; s=zohoarc; b=RQkwTRSInYap0HKTjVtyEyYALwwu0ABSkJfWGn2SMOFlsa4xdJuhwnbdq76GIl7ie3+hT2c24YZdh3jNWT2sXYgCrlDxhwJjVjy5IQOIR9jIkaSLB4V2fyD4wN5VvVjP6nEHxi203ri1bKyCqeoC4mhAUgQQU1m48J7jX31HEPo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1652791862; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=c3lcwBoLTLuaNOQ8RGcxe/VH4ulA8BV9VeQWgrV5tek=; b=SqCkd6tsY7DsBh6v+NIxkq8yc8afeswGSxwaGC1RfFZOG8Lsl9zTiXjUQKA2ZOr+N7/ma0WrGJ3PlYo1Kr/RlsxZViMehyhd4YH/zw5snldpdp4VxQMRgE7Di5oFYscLAxRJE8NFd6pp8fdQcXmcr684hNRRcpHdHloCIOW72vE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1652791862378455.9418488275388; Tue, 17 May 2022 05:51:02 -0700 (PDT) Received: from localhost ([::1]:57170 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nqwfF-0000Kt-Ai for importer@patchew.org; Tue, 17 May 2022 08:51:01 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42690) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nqvXQ-0001Sd-BR for qemu-devel@nongnu.org; Tue, 17 May 2022 07:38:57 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:21581) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nqvXO-00032F-2I for qemu-devel@nongnu.org; Tue, 17 May 2022 07:38:52 -0400 Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-308-9353SQepPMWdNesBrNg2PQ-1; Tue, 17 May 2022 07:38:47 -0400 Received: by mail-wm1-f69.google.com with SMTP id n26-20020a1c721a000000b003941ea1ced7so833629wmc.7 for ; Tue, 17 May 2022 04:38:47 -0700 (PDT) Received: from fedora.redhat.com ([2001:8a0:f4d9:2101:a4fa:5f93:755f:6249]) by smtp.gmail.com with ESMTPSA id d24-20020adfa358000000b0020d02cbbb87sm8090317wrb.16.2022.05.17.04.38.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 May 2022 04:38:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1652787528; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=c3lcwBoLTLuaNOQ8RGcxe/VH4ulA8BV9VeQWgrV5tek=; b=bzPurilIQ4I2ssv7YqtkCQeaVwngjRvS8WHWona8wEwVUCzO7S9cTY8Qw5EYjxycDGyj/h PlgRcufBL/atEju11f7CO/eCJqssbnZJtV4y8PvmyoDnwpPr7wgiMRQ0DFV46CkumDMIQo iSh4Dr+UCMBqzsWPTIyLp0gZ3XQdFEQ= X-MC-Unique: 9353SQepPMWdNesBrNg2PQ-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=c3lcwBoLTLuaNOQ8RGcxe/VH4ulA8BV9VeQWgrV5tek=; b=1CdFbtcG48vgsVS0OjR21n3Vf7EoF28Xd1NNFn0J+1a3+TGMpOm5cn+MhFuFbIm3JR 9tPjc/QhhQAMOTsxhsPsbUISRk7esWl9wNQsuGfJ0Tjz4wsrMchmkOgSm/LZkr+sr4aw Y1KRUDF9NF8+mUNbeddwoKcO9/HqtF3QussAA+oQ034KEBjKPpvNaay/zkbQvqWIVGN8 4taK0k38EcoITsE0+khKQ6FMuI7yPWKTOfBGfUFqWOcYSFDM5LVrY7DmQuV0Whmgq+b4 4jLIBKuoVW9AoYGGZ9Ffd+IdHxKzZVp0lGxgR0KJRyjPBz/rdd8YkZtcXJNZWhv8XXNy MZBg== X-Gm-Message-State: AOAM532kVUMViRPzVr9kKVCOki/P3+vj/BS+Z1psunPywpXifaUNqcB5 yRr+kIu4UFRDkePrTtlA+XsLHVo1cFPwS3RTo9E3/ARyz4ux8k5+0NpvspjgwUdbcUOC+MDlL2f n8uNsnJ3exfygY/glAZixo21V7jsPgXH9Qa873pQwKHC53ckNj4JVtpyNQwhFW+lz X-Received: by 2002:a5d:4d07:0:b0:20e:5aa1:3acd with SMTP id z7-20020a5d4d07000000b0020e5aa13acdmr1609793wrt.186.1652787526266; Tue, 17 May 2022 04:38:46 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwRHGN2CAmkbEUEqmhOv8kJeq5GNOcj7kv97YKhkvAMcfdQLIvxjfAptJhtzy+3R1vdRByZSw== X-Received: by 2002:a5d:4d07:0:b0:20e:5aa1:3acd with SMTP id z7-20020a5d4d07000000b0020e5aa13acdmr1609771wrt.186.1652787526022; Tue, 17 May 2022 04:38:46 -0700 (PDT) From: Alberto Faria To: qemu-devel@nongnu.org Cc: Hanna Reitz , Kevin Wolf , qemu-block@nongnu.org, Alberto Faria Subject: [PATCH 11/18] block: Add blk_co_pwrite_compressed() Date: Tue, 17 May 2022 12:38:30 +0100 Message-Id: <20220517113837.199696-7-afaria@redhat.com> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20220517113524.197910-1-afaria@redhat.com> References: <20220517113524.197910-1-afaria@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.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; Received-SPF: pass client-ip=170.10.133.124; envelope-from=afaria@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1652791864032100001 Content-Type: text/plain; charset="utf-8" Also convert blk_pwrite_compressed() into a generated_co_wrapper. Signed-off-by: Alberto Faria Reviewed-by: Hanna Reitz Reviewed-by: Paolo Bonzini --- block/block-backend.c | 8 ++++---- include/sysemu/block-backend-io.h | 7 +++++-- tests/unit/test-block-iothread.c | 18 ++++++++++++++++++ 3 files changed, 27 insertions(+), 6 deletions(-) diff --git a/block/block-backend.c b/block/block-backend.c index ddb1d4e179..cc85558813 100644 --- a/block/block-backend.c +++ b/block/block-backend.c @@ -2324,13 +2324,13 @@ int coroutine_fn blk_co_pwrite_zeroes(BlockBackend = *blk, int64_t offset, flags | BDRV_REQ_ZERO_WRITE); } =20 -int blk_pwrite_compressed(BlockBackend *blk, int64_t offset, int64_t bytes, - const void *buf) +int coroutine_fn blk_co_pwrite_compressed(BlockBackend *blk, int64_t offse= t, + int64_t bytes, const void *buf) { QEMUIOVector qiov =3D QEMU_IOVEC_INIT_BUF(qiov, buf, bytes); IO_OR_GS_CODE(); - return blk_pwritev_part(blk, offset, bytes, &qiov, 0, - BDRV_REQ_WRITE_COMPRESSED); + return blk_co_pwritev_part(blk, offset, bytes, &qiov, 0, + BDRV_REQ_WRITE_COMPRESSED); } =20 int blk_truncate(BlockBackend *blk, int64_t offset, bool exact, diff --git a/include/sysemu/block-backend-io.h b/include/sysemu/block-backe= nd-io.h index c64207cdcb..d129e2bed3 100644 --- a/include/sysemu/block-backend-io.h +++ b/include/sysemu/block-backend-io.h @@ -168,8 +168,11 @@ int blk_flush(BlockBackend *blk); =20 int blk_ioctl(BlockBackend *blk, unsigned long int req, void *buf); =20 -int blk_pwrite_compressed(BlockBackend *blk, int64_t offset, int64_t bytes, - const void *buf); +int generated_co_wrapper blk_pwrite_compressed(BlockBackend *blk, + int64_t offset, int64_t byt= es, + const void *buf); +int coroutine_fn blk_co_pwrite_compressed(BlockBackend *blk, int64_t offse= t, + int64_t bytes, const void *buf); int blk_pdiscard(BlockBackend *blk, int64_t offset, int64_t bytes); int blk_pwrite_zeroes(BlockBackend *blk, int64_t offset, int64_t bytes, BdrvRequestFlags flags); diff --git a/tests/unit/test-block-iothread.c b/tests/unit/test-block-iothr= ead.c index 6061762c97..b3e79d7698 100644 --- a/tests/unit/test-block-iothread.c +++ b/tests/unit/test-block-iothread.c @@ -198,6 +198,20 @@ static void test_sync_op_blk_pwritev_part(BlockBackend= *blk) g_assert_cmpint(ret, =3D=3D, -EIO); } =20 +static void test_sync_op_blk_pwrite_compressed(BlockBackend *blk) +{ + uint8_t buf[512] =3D { 0 }; + int ret; + + /* Late error: Not supported */ + ret =3D blk_pwrite_compressed(blk, 0, sizeof(buf), buf); + g_assert_cmpint(ret, =3D=3D, -ENOTSUP); + + /* Early error: Negative offset */ + ret =3D blk_pwrite_compressed(blk, -2, sizeof(buf), buf); + g_assert_cmpint(ret, =3D=3D, -EIO); +} + static void test_sync_op_load_vmstate(BdrvChild *c) { uint8_t buf[512]; @@ -377,6 +391,10 @@ const SyncOpTest sync_op_tests[] =3D { .name =3D "/sync-op/pwritev_part", .fn =3D NULL, .blkfn =3D test_sync_op_blk_pwritev_part, + }, { + .name =3D "/sync-op/pwrite_compressed", + .fn =3D NULL, + .blkfn =3D test_sync_op_blk_pwrite_compressed, }, { .name =3D "/sync-op/load_vmstate", .fn =3D test_sync_op_load_vmstate, --=20 2.35.3 From nobody Sat Apr 27 06:34:23 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1652792705; cv=none; d=zohomail.com; s=zohoarc; b=BvkHKG8B9GwiKAA5fTaohMatLoGSuKPHAwLl0CWGJijF5RCdEwjm6iM5luSm1tOID3TArkCWdKYXhMgSbaLj2ek9e9w8ezz9vkrpMNd2spY+DR51SC+dJC54LoV51p9DiGT++opG5ZSdFZdz74EarsuwG+T09S3Glede1a1uvNM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1652792705; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=1K9YX/bnY0vNj6WfRpg/0XfaygNH4IeMrvODSQz9mjM=; b=Any0klGckJv98oi3cEq8NvVmb2UWtuPhe+Y4Y9REa1ikwzx6voQcBGk3am2bf8imY108GYAXrKGri93jK5nSi2h3h4U0Xdczv7igTQvxkvZ2DfzfngAJXv1WhjqB4UuNOtUYeg60o40ddpu+l5fY5YmckDDOJ+J+KxwWXe26vyM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1652792705539329.39126260121736; Tue, 17 May 2022 06:05:05 -0700 (PDT) Received: from localhost ([::1]:49826 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nqwsq-00074E-Gr for importer@patchew.org; Tue, 17 May 2022 09:05:04 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42978) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nqvXn-0001ZO-QD for qemu-devel@nongnu.org; Tue, 17 May 2022 07:39:17 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:41197) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nqvXl-00036w-8z for qemu-devel@nongnu.org; Tue, 17 May 2022 07:39:14 -0400 Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-3-ng2TuzkMNuu4nJs59KmKww-1; Tue, 17 May 2022 07:39:10 -0400 Received: by mail-wm1-f69.google.com with SMTP id c62-20020a1c3541000000b0038ec265155fso1135151wma.6 for ; Tue, 17 May 2022 04:39:10 -0700 (PDT) Received: from fedora.redhat.com ([2001:8a0:f4d9:2101:a4fa:5f93:755f:6249]) by smtp.gmail.com with ESMTPSA id x9-20020adfae09000000b0020c5253d8edsm12093321wrc.57.2022.05.17.04.39.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 May 2022 04:39:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1652787552; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=1K9YX/bnY0vNj6WfRpg/0XfaygNH4IeMrvODSQz9mjM=; b=VmoBVng2G14u8Fq+adS+oxPKoIu4/o/7N1rK7O1pnD2e/79348quvvcaccwEJwqEBHgIFz faLs4i8GOk/MmnETgL6KlftUuWCWstn1LOXxQlF+jdc2qfHHpyf9jpscqQUTTbHus9UioM vSh8yAuama01aSU+MoxGHvmMeI1bp2E= X-MC-Unique: ng2TuzkMNuu4nJs59KmKww-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=1K9YX/bnY0vNj6WfRpg/0XfaygNH4IeMrvODSQz9mjM=; b=0ec5FRF0kW0IcdQvAW6uJKv5iIIJoy0GzkUZ3isnyTGU/UNr+4ryUR4IyHXSpjaHbB 0KV8+UMJ7AQxIuejJ4lwMzms5lfJoqtkDn9gak+n7J/gfgL3vg9T1HnugL4sv6rX/lJU ZAqKynKZ3SAsgMYvMklMXeF2C0fAlIadgHaYd7s940XbhCFLyBWu6p7mEBVbBho8CyyQ X5QQDk5z6AJTRavY7ScEAsT/Gb+NkqK0ChO1fJIitqW6cxlSORfCptLqfmBANIVhKM5u vG7g1cgggfFX4A36JCBvM8bctM8KMWCBnr+ZKCk9zMMN8sUVwqHEFWAMmtR54iWjNh6h uT8w== X-Gm-Message-State: AOAM531w1rhq40RzVegcTFclqXu6am6uRH/4KBrPd+VyPLBecYtTz9Yj pe+hXBVQXxwbur0EiNa9qMHdjSf6pOjsS6gVi1W5vVjwpQ0Jy98151UsFZrMRa7OIFaiL/8a786 OF9ywOmEyEBBggXW5Mae363uJhh1r5tGi6U//llODynSdIof0m8eOBeBpkf4Lcw+l X-Received: by 2002:a7b:c5ca:0:b0:394:7a03:48b6 with SMTP id n10-20020a7bc5ca000000b003947a0348b6mr21045635wmk.104.1652787549297; Tue, 17 May 2022 04:39:09 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy6j72fWijXeDTbPhMK04DqrWH54Bow7bhVwVlrHs7tx7go6ivZMy/bswHmdY7YIzFRZYElKA== X-Received: by 2002:a7b:c5ca:0:b0:394:7a03:48b6 with SMTP id n10-20020a7bc5ca000000b003947a0348b6mr21045616wmk.104.1652787549051; Tue, 17 May 2022 04:39:09 -0700 (PDT) From: Alberto Faria To: qemu-devel@nongnu.org Cc: Kevin Wolf , qemu-block@nongnu.org, Hanna Reitz , Alberto Faria Subject: [PATCH 12/18] block: Implement blk_pwrite_zeroes() using generated_co_wrapper Date: Tue, 17 May 2022 12:39:01 +0100 Message-Id: <20220517113907.200001-1-afaria@redhat.com> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20220517113524.197910-1-afaria@redhat.com> References: <20220517113524.197910-1-afaria@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.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; Received-SPF: pass client-ip=170.10.129.124; envelope-from=afaria@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1652792705945100001 Content-Type: text/plain; charset="utf-8" Signed-off-by: Alberto Faria Reviewed-by: Hanna Reitz Reviewed-by: Paolo Bonzini --- block/block-backend.c | 8 -------- include/sysemu/block-backend-io.h | 5 +++-- tests/unit/test-block-iothread.c | 17 +++++++++++++++++ 3 files changed, 20 insertions(+), 10 deletions(-) diff --git a/block/block-backend.c b/block/block-backend.c index cc85558813..8129259e50 100644 --- a/block/block-backend.c +++ b/block/block-backend.c @@ -1415,14 +1415,6 @@ typedef struct BlkRwCo { BdrvRequestFlags flags; } BlkRwCo; =20 -int blk_pwrite_zeroes(BlockBackend *blk, int64_t offset, - int64_t bytes, BdrvRequestFlags flags) -{ - IO_OR_GS_CODE(); - return blk_pwritev_part(blk, offset, bytes, NULL, 0, - flags | BDRV_REQ_ZERO_WRITE); -} - int blk_make_zero(BlockBackend *blk, BdrvRequestFlags flags) { GLOBAL_STATE_CODE(); diff --git a/include/sysemu/block-backend-io.h b/include/sysemu/block-backe= nd-io.h index d129e2bed3..5ce9b80023 100644 --- a/include/sysemu/block-backend-io.h +++ b/include/sysemu/block-backend-io.h @@ -174,8 +174,9 @@ int generated_co_wrapper blk_pwrite_compressed(BlockBac= kend *blk, int coroutine_fn blk_co_pwrite_compressed(BlockBackend *blk, int64_t offse= t, int64_t bytes, const void *buf); int blk_pdiscard(BlockBackend *blk, int64_t offset, int64_t bytes); -int blk_pwrite_zeroes(BlockBackend *blk, int64_t offset, - int64_t bytes, BdrvRequestFlags flags); +int generated_co_wrapper blk_pwrite_zeroes(BlockBackend *blk, int64_t offs= et, + int64_t bytes, + BdrvRequestFlags flags); int coroutine_fn blk_co_pwrite_zeroes(BlockBackend *blk, int64_t offset, int64_t bytes, BdrvRequestFlags flag= s); int blk_truncate(BlockBackend *blk, int64_t offset, bool exact, diff --git a/tests/unit/test-block-iothread.c b/tests/unit/test-block-iothr= ead.c index b3e79d7698..d701c5a056 100644 --- a/tests/unit/test-block-iothread.c +++ b/tests/unit/test-block-iothread.c @@ -212,6 +212,19 @@ static void test_sync_op_blk_pwrite_compressed(BlockBa= ckend *blk) g_assert_cmpint(ret, =3D=3D, -EIO); } =20 +static void test_sync_op_blk_pwrite_zeroes(BlockBackend *blk) +{ + int ret; + + /* Success */ + ret =3D blk_pwrite_zeroes(blk, 0, 512, 0); + g_assert_cmpint(ret, =3D=3D, 0); + + /* Early error: Negative offset */ + ret =3D blk_pwrite_zeroes(blk, -2, 512, 0); + g_assert_cmpint(ret, =3D=3D, -EIO); +} + static void test_sync_op_load_vmstate(BdrvChild *c) { uint8_t buf[512]; @@ -395,6 +408,10 @@ const SyncOpTest sync_op_tests[] =3D { .name =3D "/sync-op/pwrite_compressed", .fn =3D NULL, .blkfn =3D test_sync_op_blk_pwrite_compressed, + }, { + .name =3D "/sync-op/pwrite_zeroes", + .fn =3D NULL, + .blkfn =3D test_sync_op_blk_pwrite_zeroes, }, { .name =3D "/sync-op/load_vmstate", .fn =3D test_sync_op_load_vmstate, --=20 2.35.3 From nobody Sat Apr 27 06:34:23 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1652792222; cv=none; d=zohomail.com; s=zohoarc; b=LBFKYDG2DIMqGhk8YQa5K7mufUrifjcmdBlWe2beBCg6/ypGS7UtzuHaEBLyKKWJCqbfEMArlv1Vayg+fTi/jsHSKJGFwWUJCauR4slFo6en5LVq80xI7p/gG2/2K/6TcOZFmGmq6CRDtYl9NPfuqsU8WRJ/QNBRxVpc6p/d3W8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1652792222; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=Yzjg25PH8o6SrBkZxOxzOWN4JOb5UzXrxYVAvPdLiSU=; b=XAw5s2ksUZLJBfr+IqaGLJrRdMZre3vFtOZ/IY0wYS4ovduILmdu5mWIvQRW5PTHa3Lz5C531DidLyOGfi3JZkaeQfxHHwkRPwkHkiZFnndwpWc+d+jfN15p0Lfvjb7nnB0xhf4K3fCavKcKnj8feIfqqdHV08VUj8xEXDP35hI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1652792222849112.00604098151575; Tue, 17 May 2022 05:57:02 -0700 (PDT) Received: from localhost ([::1]:38556 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nqwl3-0007AR-P8 for importer@patchew.org; Tue, 17 May 2022 08:57:01 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42980) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nqvXn-0001ZP-RE for qemu-devel@nongnu.org; Tue, 17 May 2022 07:39:17 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:44897) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nqvXl-00037R-Hf for qemu-devel@nongnu.org; Tue, 17 May 2022 07:39:15 -0400 Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-671-78eF0HazMfOhcT4dAAK23w-1; Tue, 17 May 2022 07:39:11 -0400 Received: by mail-wm1-f69.google.com with SMTP id v126-20020a1cac84000000b00396fe5959d2so3550840wme.8 for ; Tue, 17 May 2022 04:39:11 -0700 (PDT) Received: from fedora.redhat.com ([2001:8a0:f4d9:2101:a4fa:5f93:755f:6249]) by smtp.gmail.com with ESMTPSA id x9-20020adfae09000000b0020c5253d8edsm12093321wrc.57.2022.05.17.04.39.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 May 2022 04:39:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1652787552; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Yzjg25PH8o6SrBkZxOxzOWN4JOb5UzXrxYVAvPdLiSU=; b=aHi4GSlfLBIrzP33NRHXy8GKGKkImXNtus64rllicNwudeXvybua4XRsCpiAXp+pSDPy2j I2O05udC2XYijETgSYcMxVoOaznHGQMNw9+xQ/NwLzh+YYMm4qNCs+qm3GXWQlqX4musEk s9jaIR6NDL47C+M53XDfPFJ9H/8c3UU= X-MC-Unique: 78eF0HazMfOhcT4dAAK23w-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Yzjg25PH8o6SrBkZxOxzOWN4JOb5UzXrxYVAvPdLiSU=; b=kAoPdTADTc4CpHuBAS1i+qrxp1X3jJ1InWyB1LpM1LNwR1qcAZfhz2sJAdcz1tJGJS +skFZzL924WFAgNlCQQCU7j1bqrmhwXrTwjhNFwQO93B5UmimHdUBuxF6O1OzMzIDUyD nkTXQAoXAUgOn3dL9qP/EzAq7S/HXihFZvLoTJDiobH9te+U0+dqlRxG50iMymvdlWmD e1KGU+QJ43sxZDIzqCtIGBWFKDHkAW5fnlJGrjEo2rDHPQ6UhBP9kInAjrqMgiNf6Ino sboJY58vfZKZeApTAPajgjukiqzo8UYYKlLONIdj9uue6Mzy66ha5WSLG9ApVygoZSAD Wmog== X-Gm-Message-State: AOAM532cYvdiKinMMxYhLupLLqlH8xqweSxZ7OYmMaggF35FrTSCn1VP QBbWn6q0te7kxu3GCyht+Ll03Buc/VqqkziZbc+G/47iPlZrZE5eCvu4CHgB4K8fpnrJg3dV9GG VIs6tCdmKaruLoOU3BXlPDrngBbX8bt9gyFWwRHkAy8hyFdQk9A2JhaRHN8moRlgD X-Received: by 2002:a05:600c:3512:b0:394:7c3b:53d1 with SMTP id h18-20020a05600c351200b003947c3b53d1mr31500037wmq.197.1652787550606; Tue, 17 May 2022 04:39:10 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwutqUqsq9RgcHISSXeT2p1DuuElNtuSxW+Tn6ifjMX3heJaub8RCaS0zVHjL7Y99CX/fUK8g== X-Received: by 2002:a05:600c:3512:b0:394:7c3b:53d1 with SMTP id h18-20020a05600c351200b003947c3b53d1mr31500013wmq.197.1652787550354; Tue, 17 May 2022 04:39:10 -0700 (PDT) From: Alberto Faria To: qemu-devel@nongnu.org Cc: Kevin Wolf , qemu-block@nongnu.org, Hanna Reitz , Alberto Faria Subject: [PATCH 13/18] block: Implement blk_pdiscard() using generated_co_wrapper Date: Tue, 17 May 2022 12:39:02 +0100 Message-Id: <20220517113907.200001-2-afaria@redhat.com> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20220517113524.197910-1-afaria@redhat.com> References: <20220517113524.197910-1-afaria@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.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; Received-SPF: pass client-ip=170.10.129.124; envelope-from=afaria@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1652792224467100003 Content-Type: text/plain; charset="utf-8" Signed-off-by: Alberto Faria Reviewed-by: Hanna Reitz Reviewed-by: Paolo Bonzini --- block/block-backend.c | 12 ------------ block/coroutines.h | 3 --- include/sysemu/block-backend-io.h | 3 ++- 3 files changed, 2 insertions(+), 16 deletions(-) diff --git a/block/block-backend.c b/block/block-backend.c index 8129259e50..823c98a031 100644 --- a/block/block-backend.c +++ b/block/block-backend.c @@ -1715,18 +1715,6 @@ int coroutine_fn blk_co_pdiscard(BlockBackend *blk, = int64_t offset, return ret; } =20 -int blk_pdiscard(BlockBackend *blk, int64_t offset, int64_t bytes) -{ - int ret; - IO_OR_GS_CODE(); - - blk_inc_in_flight(blk); - ret =3D blk_do_pdiscard(blk, offset, bytes); - blk_dec_in_flight(blk); - - return ret; -} - /* To be called between exactly one pair of blk_inc/dec_in_flight() */ int coroutine_fn blk_co_do_flush(BlockBackend *blk) { diff --git a/block/coroutines.h b/block/coroutines.h index 94fd283f62..2693ecabfb 100644 --- a/block/coroutines.h +++ b/block/coroutines.h @@ -110,9 +110,6 @@ nbd_do_establish_connection(BlockDriverState *bs, bool = blocking, Error **errp); int generated_co_wrapper blk_do_ioctl(BlockBackend *blk, unsigned long int req, void *buf); =20 -int generated_co_wrapper -blk_do_pdiscard(BlockBackend *blk, int64_t offset, int64_t bytes); - int generated_co_wrapper blk_do_flush(BlockBackend *blk); =20 #endif /* BLOCK_COROUTINES_H */ diff --git a/include/sysemu/block-backend-io.h b/include/sysemu/block-backe= nd-io.h index 5ce9b80023..5c56737453 100644 --- a/include/sysemu/block-backend-io.h +++ b/include/sysemu/block-backend-io.h @@ -160,6 +160,8 @@ static inline int coroutine_fn blk_co_pwrite(BlockBacke= nd *blk, int64_t offset, return blk_co_pwritev(blk, offset, bytes, &qiov, flags); } =20 +int generated_co_wrapper blk_pdiscard(BlockBackend *blk, int64_t offset, + int64_t bytes); int coroutine_fn blk_co_pdiscard(BlockBackend *blk, int64_t offset, int64_t bytes); =20 @@ -173,7 +175,6 @@ int generated_co_wrapper blk_pwrite_compressed(BlockBac= kend *blk, const void *buf); int coroutine_fn blk_co_pwrite_compressed(BlockBackend *blk, int64_t offse= t, int64_t bytes, const void *buf); -int blk_pdiscard(BlockBackend *blk, int64_t offset, int64_t bytes); int generated_co_wrapper blk_pwrite_zeroes(BlockBackend *blk, int64_t offs= et, int64_t bytes, BdrvRequestFlags flags); --=20 2.35.3 From nobody Sat Apr 27 06:34:23 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1652794470; cv=none; d=zohomail.com; s=zohoarc; b=EXjisG5P+IJ4euLa8BSvUh+E2n5MbSkpFgVwoKDl5INl8LpUVLu44PB+bGRASlCgEjWqOkcxuigCJTkyoWlz4QcNs9c7gvy5CoNjb5jQko8Hv4f+luL++i5JrGxlEzjCOV5gi2d5Ct2tUgglgi3wtSA7h9Xe5g0lU+CLY+bsn4Q= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1652794470; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=8fbq+318HP7oongP67aWO1SVNAxIjGKD5T0PAUYwWnU=; b=FI0vp4ZHUrjAqTv5KE7wAZWuiw4fSzfQtQyN1XsQj540r0xgDslB1YDATL8hbTF0YgaKgeGUuFsFhmjvt5cYk6IbfqVLuxgQuhhnr7+AfGit275RPKg9bIzSX2/KGuZFTzrO0t/qcYPwLbYkbFSU7Ioak+BtZkx5zvacOQq4S9c= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 165279447094540.217970374166384; Tue, 17 May 2022 06:34:30 -0700 (PDT) Received: from localhost ([::1]:51910 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nqxLG-0006h1-2Z for importer@patchew.org; Tue, 17 May 2022 09:34:29 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43020) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nqvXp-0001aL-Ri for qemu-devel@nongnu.org; Tue, 17 May 2022 07:39:19 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:33848) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nqvXn-00037z-Hn for qemu-devel@nongnu.org; Tue, 17 May 2022 07:39:16 -0400 Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-644-4IQ4wmTONYu2FoUQjqlqPw-1; Tue, 17 May 2022 07:39:13 -0400 Received: by mail-wr1-f71.google.com with SMTP id o11-20020adfca0b000000b0020adc114131so4580751wrh.8 for ; Tue, 17 May 2022 04:39:12 -0700 (PDT) Received: from fedora.redhat.com ([2001:8a0:f4d9:2101:a4fa:5f93:755f:6249]) by smtp.gmail.com with ESMTPSA id x9-20020adfae09000000b0020c5253d8edsm12093321wrc.57.2022.05.17.04.39.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 May 2022 04:39:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1652787554; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=8fbq+318HP7oongP67aWO1SVNAxIjGKD5T0PAUYwWnU=; b=MeWRI48Nl3akvHXes3cU1P63C9p8v0WXLKR2IZV04gbiU/MKc6PLt+K3dnQiyDzmRfuBZ7 RRCNNFTgU3t9XOH2Pn3wtmmkhg8s7nItVExG8RgN4POosVW1+L7JrURoYZ8MCYI2ixY5ph 5/NfF6376S26Aw49OXcsx90PybpUwJg= X-MC-Unique: 4IQ4wmTONYu2FoUQjqlqPw-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=8fbq+318HP7oongP67aWO1SVNAxIjGKD5T0PAUYwWnU=; b=TIunL9fuutWOdVx5fkse1i+FsoFkzvRvVTuF6cRcEhU7CCQ6zrZN1cthJKfo7UlhAO bXi8PpaVuWY3pN2lvG4nyrc8HDEZW+diYkel1hSNiceI6qToaoimtTacqnrfUtoP1dQA ewIu7IL8rKz+dqS7sbzkDg1GesDGhw1lChkg3Vq4Fq5mOMFRODROel6sJHb25N9IzcR6 wh5B/W3f7nZuW6JddKl0nbeXdUdQOtLgPltCe9ypQc6epK13TIY9dvMWNeBHet6INxf8 E5t0mmmNfvAkEYXABfIlKs9icIW0nq03G8nl4W0DZWmXwCLCjJwHcolSvG1f+qB0in6L WEPQ== X-Gm-Message-State: AOAM530Lol1KHIdfBID5E3FDRywWaXhYpz02XGj1Akb3udLISqK+8QM4 +mjY8Yw7LjZQfX4d1Ici4wBPmvyLAbKSo5obPnc83WN79X0lJGN8VourXD5xKUMPWiH59uWvf8I xetpmESYiM6PrvFSy79wdojZ0/0RBS1zhRHdVQcYHas25SIp2H2LaXoSmVvhG4ugy X-Received: by 2002:a05:6000:144d:b0:20c:7829:2a44 with SMTP id v13-20020a056000144d00b0020c78292a44mr18237276wrx.663.1652787551539; Tue, 17 May 2022 04:39:11 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxOS9K1sM9XWBr/Gn7VLkfXjpRY7dF9PZJuVLNucDpa4OWHJ39bHMFxjWh++owUeIRd8Coa5A== X-Received: by 2002:a05:6000:144d:b0:20c:7829:2a44 with SMTP id v13-20020a056000144d00b0020c78292a44mr18237250wrx.663.1652787551342; Tue, 17 May 2022 04:39:11 -0700 (PDT) From: Alberto Faria To: qemu-devel@nongnu.org Cc: Kevin Wolf , qemu-block@nongnu.org, Hanna Reitz , Alberto Faria Subject: [PATCH 14/18] block: Implement blk_flush() using generated_co_wrapper Date: Tue, 17 May 2022 12:39:03 +0100 Message-Id: <20220517113907.200001-3-afaria@redhat.com> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20220517113524.197910-1-afaria@redhat.com> References: <20220517113524.197910-1-afaria@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.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; Received-SPF: pass client-ip=170.10.133.124; envelope-from=afaria@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1652794472579100001 Content-Type: text/plain; charset="utf-8" Signed-off-by: Alberto Faria Reviewed-by: Hanna Reitz Reviewed-by: Paolo Bonzini --- block/block-backend.c | 11 ----------- block/coroutines.h | 2 -- include/sysemu/block-backend-io.h | 2 +- 3 files changed, 1 insertion(+), 14 deletions(-) diff --git a/block/block-backend.c b/block/block-backend.c index 823c98a031..0718441b37 100644 --- a/block/block-backend.c +++ b/block/block-backend.c @@ -1756,17 +1756,6 @@ int coroutine_fn blk_co_flush(BlockBackend *blk) return ret; } =20 -int blk_flush(BlockBackend *blk) -{ - int ret; - - blk_inc_in_flight(blk); - ret =3D blk_do_flush(blk); - blk_dec_in_flight(blk); - - return ret; -} - void blk_drain(BlockBackend *blk) { BlockDriverState *bs =3D blk_bs(blk); diff --git a/block/coroutines.h b/block/coroutines.h index 2693ecabfb..7e94b9fa83 100644 --- a/block/coroutines.h +++ b/block/coroutines.h @@ -110,6 +110,4 @@ nbd_do_establish_connection(BlockDriverState *bs, bool = blocking, Error **errp); int generated_co_wrapper blk_do_ioctl(BlockBackend *blk, unsigned long int req, void *buf); =20 -int generated_co_wrapper blk_do_flush(BlockBackend *blk); - #endif /* BLOCK_COROUTINES_H */ diff --git a/include/sysemu/block-backend-io.h b/include/sysemu/block-backe= nd-io.h index 5c56737453..e6af0d0ed0 100644 --- a/include/sysemu/block-backend-io.h +++ b/include/sysemu/block-backend-io.h @@ -165,8 +165,8 @@ int generated_co_wrapper blk_pdiscard(BlockBackend *blk= , int64_t offset, int coroutine_fn blk_co_pdiscard(BlockBackend *blk, int64_t offset, int64_t bytes); =20 +int generated_co_wrapper blk_flush(BlockBackend *blk); int coroutine_fn blk_co_flush(BlockBackend *blk); -int blk_flush(BlockBackend *blk); =20 int blk_ioctl(BlockBackend *blk, unsigned long int req, void *buf); =20 --=20 2.35.3 From nobody Sat Apr 27 06:34:23 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1652794172; cv=none; d=zohomail.com; s=zohoarc; b=HR/gMWYcAwQ9llRyKklnD6Ej547FF3nK7aLDw581I10zAmcEPLcxbrYm/GtvVS1uNq8sblPbfP0bxiQVN828b2wxptv8vW4IY7lQ9eHcAlr3WAvDQlmIaCYsQZafjOZdQQ8ci6EIAe36uOM4kwSdd5QEesQcFShFlKd+8uVfTkE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1652794172; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=blUimc3XmEF7g3rqPtaCfbTdUc25QM11axvZia9Qqd4=; b=UMxv9Jo53LI2p005XGB5wY2yozLt25jUAjyZC/Ho4JoOPyc8Fikzu7c8uVnwGXTW8NV1JhJlGo0PfD9W/6gOtym6y8GY6ya2QOD43ZkYkD4rINdHgw/cJxlKPMeKyWdGlQ7u6SQNoJbblvu6L+jomCCfo5sfrEejV60pxT3NOvI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1652794172699615.0875759323118; Tue, 17 May 2022 06:29:32 -0700 (PDT) Received: from localhost ([::1]:43216 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nqxGU-000075-Sr for importer@patchew.org; Tue, 17 May 2022 09:29:30 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43050) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nqvXq-0001b0-VH for qemu-devel@nongnu.org; Tue, 17 May 2022 07:39:19 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:57333) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nqvXn-00038O-KV for qemu-devel@nongnu.org; Tue, 17 May 2022 07:39:18 -0400 Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-664-COvPteuKMgCxz7o-9EvtVQ-1; Tue, 17 May 2022 07:39:14 -0400 Received: by mail-wr1-f69.google.com with SMTP id u26-20020adfb21a000000b0020ac48a9aa4so4599590wra.5 for ; Tue, 17 May 2022 04:39:13 -0700 (PDT) Received: from fedora.redhat.com ([2001:8a0:f4d9:2101:a4fa:5f93:755f:6249]) by smtp.gmail.com with ESMTPSA id x9-20020adfae09000000b0020c5253d8edsm12093321wrc.57.2022.05.17.04.39.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 May 2022 04:39:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1652787555; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=blUimc3XmEF7g3rqPtaCfbTdUc25QM11axvZia9Qqd4=; b=efuwLTStF4a2QxMyP9ovaeUZ2RhZcVmGgijaSt9kn0a7GC92Jpjj3Xnw0lVJOoj4D20U+L fsaxG+ksi8wCIYdj7ZAtHNmhDyrHq4FPk5G44UlkPmIZB8lPzLWbSFc2DL0bwidXS0VOws 74+x2YtNjx8e4bqQHRoxajty0STPbeM= X-MC-Unique: COvPteuKMgCxz7o-9EvtVQ-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=blUimc3XmEF7g3rqPtaCfbTdUc25QM11axvZia9Qqd4=; b=gI3F+TlYRY+lsMHLy9NsuSToh9LpnQti2bgLGFeC1UINVi3FqDLXA/V03K+TsqItAx +uUWRDXJNMr/+zLux33y3LgDzQb7/PQ3GoJwbXfNKNQsisXs8nxiS82MzK06IgJi/PG2 JgPnYIwKoxkScnbRhUZimyDOH+klQZhi/aGXPcxzyHPEukVM0Sdq3v0upURJt+QNJeeo uWe7HzdT1x/DP8KsF0umYvl7BnFfyPr+p5FGDLKkjxekqQKvY6JR+DSZ0AeriT5oG7OT BKkRh+7/2GB2EILB04diOVwv8t2Cbw1hD+IPxETjs9B5/1kkIqPgeWfPD74uaBbdBgyg +1sg== X-Gm-Message-State: AOAM533qeAummzXdO53eP+FOksHiaTXY8hdmUUQHTu0oiSMFC4Lr/fQ+ QuWEFo9uHCVKJIQ7/Kzkq/qZn7+dsx3+9tR8kwAIGgar8jV7t14PGX6dvwxuHexV3gzYsc98Fnl asDOnJocNnYn4az6HaMX28ZlTLO2qBTnKKFAJjHq22z4iaWHSJkQ+bKPG0QAywkET X-Received: by 2002:a05:6000:11cc:b0:20c:fecc:3a44 with SMTP id i12-20020a05600011cc00b0020cfecc3a44mr2376447wrx.366.1652787552676; Tue, 17 May 2022 04:39:12 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzH/mBti0B4ufVhaqm74YCfmugx1oR4KkxFJvEGxuP0tKxxZtZlnAYjScg3+ztroYGI0tkvoQ== X-Received: by 2002:a05:6000:11cc:b0:20c:fecc:3a44 with SMTP id i12-20020a05600011cc00b0020cfecc3a44mr2376432wrx.366.1652787552482; Tue, 17 May 2022 04:39:12 -0700 (PDT) From: Alberto Faria To: qemu-devel@nongnu.org Cc: Kevin Wolf , qemu-block@nongnu.org, Hanna Reitz , Alberto Faria Subject: [PATCH 15/18] block: Add blk_co_ioctl() Date: Tue, 17 May 2022 12:39:04 +0100 Message-Id: <20220517113907.200001-4-afaria@redhat.com> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20220517113524.197910-1-afaria@redhat.com> References: <20220517113524.197910-1-afaria@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.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; Received-SPF: pass client-ip=170.10.133.124; envelope-from=afaria@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1652794173993100001 Content-Type: text/plain; charset="utf-8" Also convert blk_ioctl() into a generated_co_wrapper. Signed-off-by: Alberto Faria Reviewed-by: Hanna Reitz Reviewed-by: Paolo Bonzini --- block/block-backend.c | 7 ++++--- block/coroutines.h | 6 ------ include/sysemu/block-backend-io.h | 5 ++++- 3 files changed, 8 insertions(+), 10 deletions(-) diff --git a/block/block-backend.c b/block/block-backend.c index 0718441b37..7bad42259e 100644 --- a/block/block-backend.c +++ b/block/block-backend.c @@ -1624,7 +1624,7 @@ void blk_aio_cancel_async(BlockAIOCB *acb) } =20 /* To be called between exactly one pair of blk_inc/dec_in_flight() */ -int coroutine_fn +static int coroutine_fn blk_co_do_ioctl(BlockBackend *blk, unsigned long int req, void *buf) { IO_CODE(); @@ -1638,13 +1638,14 @@ blk_co_do_ioctl(BlockBackend *blk, unsigned long in= t req, void *buf) return bdrv_co_ioctl(blk_bs(blk), req, buf); } =20 -int blk_ioctl(BlockBackend *blk, unsigned long int req, void *buf) +int coroutine_fn blk_co_ioctl(BlockBackend *blk, unsigned long int req, + void *buf) { int ret; IO_OR_GS_CODE(); =20 blk_inc_in_flight(blk); - ret =3D blk_do_ioctl(blk, req, buf); + ret =3D blk_co_do_ioctl(blk, req, buf); blk_dec_in_flight(blk); =20 return ret; diff --git a/block/coroutines.h b/block/coroutines.h index 7e94b9fa83..d66551a277 100644 --- a/block/coroutines.h +++ b/block/coroutines.h @@ -68,9 +68,6 @@ blk_co_do_pwritev_part(BlockBackend *blk, int64_t offset,= int64_t bytes, QEMUIOVector *qiov, size_t qiov_offset, BdrvRequestFlags flags); =20 -int coroutine_fn -blk_co_do_ioctl(BlockBackend *blk, unsigned long int req, void *buf); - int coroutine_fn blk_co_do_pdiscard(BlockBackend *blk, int64_t offset, int64_t bytes); =20 @@ -107,7 +104,4 @@ bdrv_common_block_status_above(BlockDriverState *bs, int generated_co_wrapper nbd_do_establish_connection(BlockDriverState *bs, bool blocking, Error **e= rrp); =20 -int generated_co_wrapper -blk_do_ioctl(BlockBackend *blk, unsigned long int req, void *buf); - #endif /* BLOCK_COROUTINES_H */ diff --git a/include/sysemu/block-backend-io.h b/include/sysemu/block-backe= nd-io.h index e6af0d0ed0..bb1ae25863 100644 --- a/include/sysemu/block-backend-io.h +++ b/include/sysemu/block-backend-io.h @@ -168,7 +168,10 @@ int coroutine_fn blk_co_pdiscard(BlockBackend *blk, in= t64_t offset, int generated_co_wrapper blk_flush(BlockBackend *blk); int coroutine_fn blk_co_flush(BlockBackend *blk); =20 -int blk_ioctl(BlockBackend *blk, unsigned long int req, void *buf); +int generated_co_wrapper blk_ioctl(BlockBackend *blk, unsigned long int re= q, + void *buf); +int coroutine_fn blk_co_ioctl(BlockBackend *blk, unsigned long int req, + void *buf); =20 int generated_co_wrapper blk_pwrite_compressed(BlockBackend *blk, int64_t offset, int64_t byt= es, --=20 2.35.3 From nobody Sat Apr 27 06:34:23 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1652792954; cv=none; d=zohomail.com; s=zohoarc; b=PxI7BYni0HK9XvqukJdQDC5WDhqohW3w0ot8ItldCRC0R3b5IE3cRGSSPnUweWLzoMda5R6Rt1iD1wtGdgX18ToraQh35bdDcUHPRE6vk4LfnY7nsM11yRHoRZBB4hiNDIE4E9g2CJalCI5NbCRfEYXw+88BX9gUDnvG4VfrBPQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1652792954; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=+MzNVCHZRdz0nkZ6awBt8eY9uV6vS0a5ZCRNKcrECJM=; b=IQSnsUl1MkCvguDbeeZ+MmKbY1jIeVZrStgAS4HJG26DhGQxQy2xoNl8rAxn00NcYqg/5IUqZwg3nD+I1ie0Tna9rL+UPWyDNj7E7a68+UKRTtF4lnY59V2dxs4wILlYpcQT/SiDT/BEWcqDnyPDrzyFmBxHC/nOdXz7WCqFEEs= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1652792954668231.2385898373268; Tue, 17 May 2022 06:09:14 -0700 (PDT) Received: from localhost ([::1]:60574 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nqwwr-0006Oe-K0 for importer@patchew.org; Tue, 17 May 2022 09:09:13 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43086) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nqvXr-0001bV-U8 for qemu-devel@nongnu.org; Tue, 17 May 2022 07:39:21 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:20269) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nqvXp-000391-Gi for qemu-devel@nongnu.org; Tue, 17 May 2022 07:39:19 -0400 Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-226-weEo2SfcMuC-yRMmYzLqDw-1; Tue, 17 May 2022 07:39:15 -0400 Received: by mail-wm1-f69.google.com with SMTP id o24-20020a05600c379800b003943412e81dso834164wmr.6 for ; Tue, 17 May 2022 04:39:15 -0700 (PDT) Received: from fedora.redhat.com ([2001:8a0:f4d9:2101:a4fa:5f93:755f:6249]) by smtp.gmail.com with ESMTPSA id x9-20020adfae09000000b0020c5253d8edsm12093321wrc.57.2022.05.17.04.39.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 May 2022 04:39:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1652787556; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=+MzNVCHZRdz0nkZ6awBt8eY9uV6vS0a5ZCRNKcrECJM=; b=SvDdgUf1Rx6wDwnZ5u38+V6YuLO0RQ5KLI+wMhBguQZOfwYChY/si912WM7syBLp/aDDQ5 hiVGpnskBQfDkQV27ripuNUF757DLA1IJr7JFCSfwNQirdKt7vZnDQIO2PKXsGz5Zz8syS WInT7FEFuCMHe6UhTAj8ud7+YScTrjY= X-MC-Unique: weEo2SfcMuC-yRMmYzLqDw-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=+MzNVCHZRdz0nkZ6awBt8eY9uV6vS0a5ZCRNKcrECJM=; b=ItQtpwFdFiEnHglICv1ZHKfhKttWwoNDgGrfCB4ZqGw96IEyLfMEa+FCiBJza7bKG7 NTX4k2pjB8cH+C6mmXRWl4ds0sxGBykZBxGHXPTgVV9Me9vkHEEXqebPLn8e3UsOaX3H pheP6g4mG+W2VAOPNjSSJcigo3mNBSRzqSD9Yk+2YW3lCDqfMJJSLBHq3fUl8vvs7KR4 UilKh6ljfHbOwDclXTBmkfjbnn6ZG3PG3m5InBSzGi2N3bEjcIcyWYEWPRseIhPCW9OQ 9NpdfLfvX6drDAj/hUebKHP9ydrlUrE/sDowVHfGRigseGEle04kJNaSWyRufz4IdeiN yuEQ== X-Gm-Message-State: AOAM5303RE7laosKGXoYYt3JlsAdt2Sht90wTh5EtIikbKSuIT5kTMzY 00jdcNAZTFUDSJ9NcQmc/uk7lCaEcpCsC4trUEDrHKU4B+eTEpXcIJ9Lno77mc4qxraHvdhAwpm hjKLhdhpeoOoC6BpzbMWS8PpubB0SLQQa5TlNOPeYNUiIraGTPzvMknAudXS+8xQ0 X-Received: by 2002:a05:6000:2aa:b0:20c:5a12:20dc with SMTP id l10-20020a05600002aa00b0020c5a1220dcmr18761352wry.316.1652787553879; Tue, 17 May 2022 04:39:13 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyijHEck4TzHalCT+J8FFxm0xKUX9KpR1NNln+3v8/SmA5S58218/xmmdTUhhzi7wF4Vw4diw== X-Received: by 2002:a05:6000:2aa:b0:20c:5a12:20dc with SMTP id l10-20020a05600002aa00b0020c5a1220dcmr18761333wry.316.1652787553618; Tue, 17 May 2022 04:39:13 -0700 (PDT) From: Alberto Faria To: qemu-devel@nongnu.org Cc: Kevin Wolf , qemu-block@nongnu.org, Hanna Reitz , Alberto Faria Subject: [PATCH 16/18] block: Add blk_co_truncate() Date: Tue, 17 May 2022 12:39:05 +0100 Message-Id: <20220517113907.200001-5-afaria@redhat.com> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20220517113524.197910-1-afaria@redhat.com> References: <20220517113524.197910-1-afaria@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.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; Received-SPF: pass client-ip=170.10.133.124; envelope-from=afaria@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1652792956815100001 Content-Type: text/plain; charset="utf-8" Also convert blk_truncate() into a generated_co_wrapper. Signed-off-by: Alberto Faria Reviewed-by: Hanna Reitz Reviewed-by: Paolo Bonzini --- block/block-backend.c | 7 ++++--- include/sysemu/block-backend-io.h | 8 ++++++-- tests/unit/test-block-iothread.c | 14 ++++++++++++++ 3 files changed, 24 insertions(+), 5 deletions(-) diff --git a/block/block-backend.c b/block/block-backend.c index 7bad42259e..52be1d9116 100644 --- a/block/block-backend.c +++ b/block/block-backend.c @@ -2303,8 +2303,9 @@ int coroutine_fn blk_co_pwrite_compressed(BlockBacken= d *blk, int64_t offset, BDRV_REQ_WRITE_COMPRESSED); } =20 -int blk_truncate(BlockBackend *blk, int64_t offset, bool exact, - PreallocMode prealloc, BdrvRequestFlags flags, Error **er= rp) +int coroutine_fn blk_co_truncate(BlockBackend *blk, int64_t offset, bool e= xact, + PreallocMode prealloc, BdrvRequestFlags f= lags, + Error **errp) { IO_OR_GS_CODE(); if (!blk_is_available(blk)) { @@ -2312,7 +2313,7 @@ int blk_truncate(BlockBackend *blk, int64_t offset, b= ool exact, return -ENOMEDIUM; } =20 - return bdrv_truncate(blk->root, offset, exact, prealloc, flags, errp); + return bdrv_co_truncate(blk->root, offset, exact, prealloc, flags, err= p); } =20 int blk_save_vmstate(BlockBackend *blk, const uint8_t *buf, diff --git a/include/sysemu/block-backend-io.h b/include/sysemu/block-backe= nd-io.h index bb1ae25863..004493ec36 100644 --- a/include/sysemu/block-backend-io.h +++ b/include/sysemu/block-backend-io.h @@ -183,7 +183,11 @@ int generated_co_wrapper blk_pwrite_zeroes(BlockBacken= d *blk, int64_t offset, BdrvRequestFlags flags); int coroutine_fn blk_co_pwrite_zeroes(BlockBackend *blk, int64_t offset, int64_t bytes, BdrvRequestFlags flag= s); -int blk_truncate(BlockBackend *blk, int64_t offset, bool exact, - PreallocMode prealloc, BdrvRequestFlags flags, Error **er= rp); +int generated_co_wrapper blk_truncate(BlockBackend *blk, int64_t offset, + bool exact, PreallocMode prealloc, + BdrvRequestFlags flags, Error **errp= ); +int coroutine_fn blk_co_truncate(BlockBackend *blk, int64_t offset, bool e= xact, + PreallocMode prealloc, BdrvRequestFlags f= lags, + Error **errp); =20 #endif /* BLOCK_BACKEND_IO_H */ diff --git a/tests/unit/test-block-iothread.c b/tests/unit/test-block-iothr= ead.c index d701c5a056..9b7353ce89 100644 --- a/tests/unit/test-block-iothread.c +++ b/tests/unit/test-block-iothread.c @@ -298,6 +298,19 @@ static void test_sync_op_truncate(BdrvChild *c) c->bs->open_flags |=3D BDRV_O_RDWR; } =20 +static void test_sync_op_blk_truncate(BlockBackend *blk) +{ + int ret; + + /* Normal success path */ + ret =3D blk_truncate(blk, 65536, false, PREALLOC_MODE_OFF, 0, NULL); + g_assert_cmpint(ret, =3D=3D, 0); + + /* Early error: Negative offset */ + ret =3D blk_truncate(blk, -2, false, PREALLOC_MODE_OFF, 0, NULL); + g_assert_cmpint(ret, =3D=3D, -EINVAL); +} + static void test_sync_op_block_status(BdrvChild *c) { int ret; @@ -425,6 +438,7 @@ const SyncOpTest sync_op_tests[] =3D { }, { .name =3D "/sync-op/truncate", .fn =3D test_sync_op_truncate, + .blkfn =3D test_sync_op_blk_truncate, }, { .name =3D "/sync-op/block_status", .fn =3D test_sync_op_block_status, --=20 2.35.3 From nobody Sat Apr 27 06:34:23 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1652793251; cv=none; d=zohomail.com; s=zohoarc; b=GpB8G2JXW7NSyiyqXk8DsEtir8zsXsLRr8y08STilg0K2erJ926JAEYVmEVQTW6gOMJGQg4wRj7HJDZJtkh5N2hTedERzWWJt1eGS0Jpd8dMs8bO4GV9/szA3TJINMXAJP55GsKZ6LDAiwvLl4Clly+iPkPEEPSV8CA4CwhpXkQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1652793251; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=zbMHvTWarh5Fplmojo7XHSGTjFpUSUXGkquTW4UAX70=; b=Q+ek8qJPFXfUThkbk4OuqxWAfTxQjFbmnO3Ys4ITaNIZM4xt6AcF04MoWSnJ8X+ZoQyK3L91skrxQ5bVmW0X0FMfvntZ66anwn1PBXvGOOASQj7svaWHhw+KgetpfyL84YsC8BRpn+z7JVA86dAagbFeEOU/stIU7tUTBdeX8oM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1652793251990143.18372270669124; Tue, 17 May 2022 06:14:11 -0700 (PDT) Received: from localhost ([::1]:40830 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nqx1e-0003xd-S9 for importer@patchew.org; Tue, 17 May 2022 09:14:10 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43240) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nqvY2-0001gq-As for qemu-devel@nongnu.org; Tue, 17 May 2022 07:39:32 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:32893) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nqvXv-0003CW-QD for qemu-devel@nongnu.org; Tue, 17 May 2022 07:39:26 -0400 Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-461-gBGlzdWQPA6oLfK3ljZXpQ-1; Tue, 17 May 2022 07:39:16 -0400 Received: by mail-wm1-f72.google.com with SMTP id bg7-20020a05600c3c8700b0039468585269so8064649wmb.3 for ; Tue, 17 May 2022 04:39:16 -0700 (PDT) Received: from fedora.redhat.com ([2001:8a0:f4d9:2101:a4fa:5f93:755f:6249]) by smtp.gmail.com with ESMTPSA id x9-20020adfae09000000b0020c5253d8edsm12093321wrc.57.2022.05.17.04.39.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 May 2022 04:39:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1652787563; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=zbMHvTWarh5Fplmojo7XHSGTjFpUSUXGkquTW4UAX70=; b=VPfvDFHA/KfCth6+DvmMuvOQ1MNNLDFfCby5MlprKJIfl4xC0+05OEpVkTF0NazrGI4e/h JmhdSZXSKWDk+LrBod4gdTsd07W+2fKs12o5nKRCQ3d3j6jVTpdQZgPees44VAkElRphnB TVIDpd18X4f8tjlTIAexrycC+LB2j5E= X-MC-Unique: gBGlzdWQPA6oLfK3ljZXpQ-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=zbMHvTWarh5Fplmojo7XHSGTjFpUSUXGkquTW4UAX70=; b=r4JsQNbfoH/+alSvsMc9cTaqu55hH+D9S/MoqXoVU9Aua0kIkr7X6iKci97IREmSn7 IS2ZZdIEoXcTUsck74bXy+Dg3Sk+KwiVeWDPOABTpRE5iniP1DmLJt2Q3z74Rfo5xEfZ kPFqViCCT9wXF+BEIiod+UYHwAxT100psYlzuybo3M3vwnnWEl7UnJh8nxci3rPu6Yxb aNdfZn9BuuUJeECEn3H59qobPXetR5mKikbs0k8AjPKxs1VuYSMbqOrIlpXS8PBwnVmq oILLL/jbbxQDWPpayIDsySNhOKyDQGzTTyFiT1tTVCmqZ1F2jOyfbm9P/UfcNNnFpvvc ZA5Q== X-Gm-Message-State: AOAM533JzRa4z5S6Ky87qc6r50mn0S58tsLMh6+d1tRkTQecrPr4cODB 0JEagjFyZTfmzp0Ulmup465TRdslgtzzwvQEVLGa9enzEChIMLPEpAHCA0DI7jJW55xDwv/eZD/ YVzPGYqKZIf8GSZUzis33bh9rcntEd/Zw1Y0p/pt49pDrLiMt6pC6fxdUEDx8bzZ1 X-Received: by 2002:a05:600c:48b:b0:394:2ee9:5847 with SMTP id d11-20020a05600c048b00b003942ee95847mr32777794wme.117.1652787555066; Tue, 17 May 2022 04:39:15 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzTzGLhxMeCaQb7GgKc8kSz8zBQxzCMFYjrWzQzEYx5/MRpg0yzOAuaIwT6J2WSlwdfp6gVSA== X-Received: by 2002:a05:600c:48b:b0:394:2ee9:5847 with SMTP id d11-20020a05600c048b00b003942ee95847mr32777761wme.117.1652787554739; Tue, 17 May 2022 04:39:14 -0700 (PDT) From: Alberto Faria To: qemu-devel@nongnu.org Cc: Kevin Wolf , qemu-block@nongnu.org, Hanna Reitz , Alberto Faria Subject: [PATCH 17/18] block: Reorganize some declarations in block-backend-io.h Date: Tue, 17 May 2022 12:39:06 +0100 Message-Id: <20220517113907.200001-6-afaria@redhat.com> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20220517113524.197910-1-afaria@redhat.com> References: <20220517113524.197910-1-afaria@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.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; Received-SPF: pass client-ip=170.10.129.124; envelope-from=afaria@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1652793252385100001 Content-Type: text/plain; charset="utf-8" Keep generated_co_wrapper and coroutine_fn pairs together. This should make it clear that each I/O function has these two versions. Also move blk_co_{pread,pwrite}()'s implementations out of the header file for consistency. Signed-off-by: Alberto Faria Reviewed-by: Paolo Bonzini --- block/block-backend.c | 22 ++++++++ include/sysemu/block-backend-io.h | 87 +++++++++++++------------------ 2 files changed, 59 insertions(+), 50 deletions(-) diff --git a/block/block-backend.c b/block/block-backend.c index 52be1d9116..920ba0dd1f 100644 --- a/block/block-backend.c +++ b/block/block-backend.c @@ -1318,6 +1318,17 @@ blk_co_do_preadv_part(BlockBackend *blk, int64_t off= set, int64_t bytes, return ret; } =20 +int coroutine_fn blk_co_pread(BlockBackend *blk, int64_t offset, int64_t b= ytes, + void *buf, BdrvRequestFlags flags) +{ + QEMUIOVector qiov =3D QEMU_IOVEC_INIT_BUF(qiov, buf, bytes); + IO_OR_GS_CODE(); + + assert(bytes <=3D SIZE_MAX); + + return blk_co_preadv(blk, offset, bytes, &qiov, flags); +} + int coroutine_fn blk_co_preadv(BlockBackend *blk, int64_t offset, int64_t bytes, QEMUIOVector *qiov, BdrvRequestFlags flags) @@ -1399,6 +1410,17 @@ int coroutine_fn blk_co_pwritev_part(BlockBackend *b= lk, int64_t offset, return ret; } =20 +int coroutine_fn blk_co_pwrite(BlockBackend *blk, int64_t offset, int64_t = bytes, + const void *buf, BdrvRequestFlags flags) +{ + QEMUIOVector qiov =3D QEMU_IOVEC_INIT_BUF(qiov, buf, bytes); + IO_OR_GS_CODE(); + + assert(bytes <=3D SIZE_MAX); + + return blk_co_pwritev(blk, offset, bytes, &qiov, flags); +} + int coroutine_fn blk_co_pwritev(BlockBackend *blk, int64_t offset, int64_t bytes, QEMUIOVector *qiov, BdrvRequestFlags flags) diff --git a/include/sysemu/block-backend-io.h b/include/sysemu/block-backe= nd-io.h index 004493ec36..30ed979fb1 100644 --- a/include/sysemu/block-backend-io.h +++ b/include/sysemu/block-backend-io.h @@ -88,11 +88,6 @@ uint32_t blk_get_request_alignment(BlockBackend *blk); uint32_t blk_get_max_transfer(BlockBackend *blk); uint64_t blk_get_max_hw_transfer(BlockBackend *blk); =20 -int coroutine_fn blk_co_copy_range(BlockBackend *blk_in, int64_t off_in, - BlockBackend *blk_out, int64_t off_out, - int64_t bytes, BdrvRequestFlags read_fl= ags, - BdrvRequestFlags write_flags); - =20 /* * "I/O or GS" API functions. These functions can run without @@ -105,9 +100,16 @@ int coroutine_fn blk_co_copy_range(BlockBackend *blk_i= n, int64_t off_in, int generated_co_wrapper blk_pread(BlockBackend *blk, int64_t offset, int64_t bytes, void *buf, BdrvRequestFlags flags); -int generated_co_wrapper blk_pwrite(BlockBackend *blk, int64_t offset, - int64_t bytes, const void *buf, +int coroutine_fn blk_co_pread(BlockBackend *blk, int64_t offset, int64_t b= ytes, + void *buf, BdrvRequestFlags flags); + +int generated_co_wrapper blk_preadv(BlockBackend *blk, int64_t offset, + int64_t bytes, QEMUIOVector *qiov, BdrvRequestFlags flags); +int coroutine_fn blk_co_preadv(BlockBackend *blk, int64_t offset, + int64_t bytes, QEMUIOVector *qiov, + BdrvRequestFlags flags); + int generated_co_wrapper blk_preadv_part(BlockBackend *blk, int64_t offset, int64_t bytes, QEMUIOVector *qiov, size_t qiov_offset, @@ -115,12 +117,20 @@ int generated_co_wrapper blk_preadv_part(BlockBackend= *blk, int64_t offset, int coroutine_fn blk_co_preadv_part(BlockBackend *blk, int64_t offset, int64_t bytes, QEMUIOVector *qiov, size_t qiov_offset, BdrvRequestFlags f= lags); -int generated_co_wrapper blk_preadv(BlockBackend *blk, int64_t offset, - int64_t bytes, QEMUIOVector *qiov, + +int generated_co_wrapper blk_pwrite(BlockBackend *blk, int64_t offset, + int64_t bytes, const void *buf, BdrvRequestFlags flags); -int coroutine_fn blk_co_preadv(BlockBackend *blk, int64_t offset, - int64_t bytes, QEMUIOVector *qiov, - BdrvRequestFlags flags); +int coroutine_fn blk_co_pwrite(BlockBackend *blk, int64_t offset, int64_t = bytes, + const void *buf, BdrvRequestFlags flags); + +int generated_co_wrapper blk_pwritev(BlockBackend *blk, int64_t offset, + int64_t bytes, QEMUIOVector *qiov, + BdrvRequestFlags flags); +int coroutine_fn blk_co_pwritev(BlockBackend *blk, int64_t offset, + int64_t bytes, QEMUIOVector *qiov, + BdrvRequestFlags flags); + int generated_co_wrapper blk_pwritev_part(BlockBackend *blk, int64_t offse= t, int64_t bytes, QEMUIOVector *qio= v, size_t qiov_offset, @@ -129,36 +139,18 @@ int coroutine_fn blk_co_pwritev_part(BlockBackend *bl= k, int64_t offset, int64_t bytes, QEMUIOVector *qiov, size_t qiov_offse= t, BdrvRequestFlags flags); -int generated_co_wrapper blk_pwritev(BlockBackend *blk, int64_t offset, - int64_t bytes, QEMUIOVector *qiov, - BdrvRequestFlags flags); -int coroutine_fn blk_co_pwritev(BlockBackend *blk, int64_t offset, - int64_t bytes, QEMUIOVector *qiov, - BdrvRequestFlags flags); - -static inline int coroutine_fn blk_co_pread(BlockBackend *blk, int64_t off= set, - int64_t bytes, void *buf, - BdrvRequestFlags flags) -{ - QEMUIOVector qiov =3D QEMU_IOVEC_INIT_BUF(qiov, buf, bytes); - IO_OR_GS_CODE(); =20 - assert(bytes <=3D SIZE_MAX); - - return blk_co_preadv(blk, offset, bytes, &qiov, flags); -} - -static inline int coroutine_fn blk_co_pwrite(BlockBackend *blk, int64_t of= fset, - int64_t bytes, const void *bu= f, - BdrvRequestFlags flags) -{ - QEMUIOVector qiov =3D QEMU_IOVEC_INIT_BUF(qiov, buf, bytes); - IO_OR_GS_CODE(); - - assert(bytes <=3D SIZE_MAX); +int generated_co_wrapper blk_pwrite_compressed(BlockBackend *blk, + int64_t offset, int64_t byt= es, + const void *buf); +int coroutine_fn blk_co_pwrite_compressed(BlockBackend *blk, int64_t offse= t, + int64_t bytes, const void *buf); =20 - return blk_co_pwritev(blk, offset, bytes, &qiov, flags); -} +int generated_co_wrapper blk_pwrite_zeroes(BlockBackend *blk, int64_t offs= et, + int64_t bytes, + BdrvRequestFlags flags); +int coroutine_fn blk_co_pwrite_zeroes(BlockBackend *blk, int64_t offset, + int64_t bytes, BdrvRequestFlags flag= s); =20 int generated_co_wrapper blk_pdiscard(BlockBackend *blk, int64_t offset, int64_t bytes); @@ -173,16 +165,6 @@ int generated_co_wrapper blk_ioctl(BlockBackend *blk, = unsigned long int req, int coroutine_fn blk_co_ioctl(BlockBackend *blk, unsigned long int req, void *buf); =20 -int generated_co_wrapper blk_pwrite_compressed(BlockBackend *blk, - int64_t offset, int64_t byt= es, - const void *buf); -int coroutine_fn blk_co_pwrite_compressed(BlockBackend *blk, int64_t offse= t, - int64_t bytes, const void *buf); -int generated_co_wrapper blk_pwrite_zeroes(BlockBackend *blk, int64_t offs= et, - int64_t bytes, - BdrvRequestFlags flags); -int coroutine_fn blk_co_pwrite_zeroes(BlockBackend *blk, int64_t offset, - int64_t bytes, BdrvRequestFlags flag= s); int generated_co_wrapper blk_truncate(BlockBackend *blk, int64_t offset, bool exact, PreallocMode prealloc, BdrvRequestFlags flags, Error **errp= ); @@ -190,4 +172,9 @@ int coroutine_fn blk_co_truncate(BlockBackend *blk, int= 64_t offset, bool exact, PreallocMode prealloc, BdrvRequestFlags f= lags, Error **errp); =20 +int coroutine_fn blk_co_copy_range(BlockBackend *blk_in, int64_t off_in, + BlockBackend *blk_out, int64_t off_out, + int64_t bytes, BdrvRequestFlags read_fl= ags, + BdrvRequestFlags write_flags); + #endif /* BLOCK_BACKEND_IO_H */ --=20 2.35.3 From nobody Sat Apr 27 06:34:23 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1652793902; cv=none; d=zohomail.com; s=zohoarc; b=VzfzAjpD0hLVJ/GWMy2XcCg/vb4PuHpIDqHRXW99a4l7vs0quocdTW2/IzcpOpPAb81DTej0l5KIrE+nYgASecP231el015c8qpKo/mR8KKWK0VllSlOrbXJwKo+ge1uaLa6vORpCXEchFdzBHLBFVD79gtBbbkLQkEM3pus/do= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1652793902; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=hxOUHMZMmu/4q4OF5Ul5T0x6eryF0yzszdtPqGch5nE=; b=QrQaFi18Z5x8eB028LfGVy+GdrbQvWUTeeb3Nv6U7y1dHKLHZnOv30kMxBnSPIHwkcXUakpcS36M48Mczqvbmhl1LN+RGH/uHfSBKwxuI/CRxZAop6N+hQ1P+cbYpgBujg44+RemFDZk2be0hKf2W7iMOl5Vd8nwBMGuoFAgWVM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1652793902218567.3280339837428; Tue, 17 May 2022 06:25:02 -0700 (PDT) Received: from localhost ([::1]:60530 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nqxC8-0000uE-Mc for importer@patchew.org; Tue, 17 May 2022 09:25:00 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43098) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nqvXs-0001bZ-VO for qemu-devel@nongnu.org; Tue, 17 May 2022 07:39:21 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:34154) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nqvXr-00039v-8t for qemu-devel@nongnu.org; Tue, 17 May 2022 07:39:20 -0400 Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-522-l9RWOuETPDiTsSN8tTAf0w-1; Tue, 17 May 2022 07:39:17 -0400 Received: by mail-wm1-f72.google.com with SMTP id q128-20020a1c4386000000b003942fe15835so8066420wma.6 for ; Tue, 17 May 2022 04:39:17 -0700 (PDT) Received: from fedora.redhat.com ([2001:8a0:f4d9:2101:a4fa:5f93:755f:6249]) by smtp.gmail.com with ESMTPSA id x9-20020adfae09000000b0020c5253d8edsm12093321wrc.57.2022.05.17.04.39.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 May 2022 04:39:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1652787558; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=hxOUHMZMmu/4q4OF5Ul5T0x6eryF0yzszdtPqGch5nE=; b=QXf7zdXwjy0RgVj5smQfCUqQ/32KTEKsqfk05YhHrBzOZ90487wpmnPvpVfzUprZQv3ChL NOquvsno993tYhS07fWfIqppoDTpTSTc2l6HPm12/GkbJm3LeXGzZO8UyvzRDH6aH3RO22 xAkIukS0Yn97r/nbhFDcc/BQV219KZo= X-MC-Unique: l9RWOuETPDiTsSN8tTAf0w-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=hxOUHMZMmu/4q4OF5Ul5T0x6eryF0yzszdtPqGch5nE=; b=X9ORvjB2q53B3Od0qZuEljKMV77Lk9JaRbevIjheyNdBfF93CW2bL3ApjKMKF5yKJO 737OQBvProkPaZAa7/I+4gKobhtsUl+41UpDw4HZoPdtm9KK2x8C55tgsOExh4sncfeY 4desCZS+EsfNk/dRI+xpywRo3f+Qi9qvmjFvIsRdnwDDTMbHCPndr6zWMEvn4Wnkon8v 2FzagPwn9S8Wt7gARJB4kCD2LRXMWVearhHc8U0O89l3RO87rDKr48pPlCDJcr2tt+NR WhQFSFuHBTWbi1nOLaTRgrGfETgUFN5DyuQOh7tksZ8qTGPyMrzbHfudJHSSMRL9eA01 X2jQ== X-Gm-Message-State: AOAM533q5/u5jbLe4ioG+ZLEuKNVVFIl61SiAplOrq1pbFxZMuBa9HSe DvLr95rhfClHPQAOA+P3gohpdkwGj/UOnPRbC/9TTx3ZPixcMKOqpmiinVDhJJ+FZ0P/oE3bS5i fs/NijqRSvm77/VibwW+DqY3p37DqlUOZDmxlDhuhYWwgIHy2N7Rcbf1LXzhaFREU X-Received: by 2002:adf:e70a:0:b0:20d:e3e:f79f with SMTP id c10-20020adfe70a000000b0020d0e3ef79fmr6189725wrm.105.1652787556177; Tue, 17 May 2022 04:39:16 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxHe2drs2W5VYjKFKknTW9e2yR/X2GF73MpKKlpTwr+Y5WNNgdVLN1EORC3Nka+CfyXia1bgQ== X-Received: by 2002:adf:e70a:0:b0:20d:e3e:f79f with SMTP id c10-20020adfe70a000000b0020d0e3ef79fmr6189700wrm.105.1652787555895; Tue, 17 May 2022 04:39:15 -0700 (PDT) From: Alberto Faria To: qemu-devel@nongnu.org Cc: Kevin Wolf , qemu-block@nongnu.org, Hanna Reitz , Alberto Faria Subject: [PATCH 18/18] block: Remove remaining unused symbols in coroutines.h Date: Tue, 17 May 2022 12:39:07 +0100 Message-Id: <20220517113907.200001-7-afaria@redhat.com> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20220517113524.197910-1-afaria@redhat.com> References: <20220517113524.197910-1-afaria@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.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; Received-SPF: pass client-ip=170.10.133.124; envelope-from=afaria@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1652793904341100001 Content-Type: text/plain; charset="utf-8" Some can be made static, others are unused generated_co_wrappers. Signed-off-by: Alberto Faria Reviewed-by: Hanna Reitz Reviewed-by: Paolo Bonzini --- block/block-backend.c | 6 +++--- block/coroutines.h | 19 ------------------- 2 files changed, 3 insertions(+), 22 deletions(-) diff --git a/block/block-backend.c b/block/block-backend.c index 920ba0dd1f..bf63f187ef 100644 --- a/block/block-backend.c +++ b/block/block-backend.c @@ -1358,7 +1358,7 @@ int coroutine_fn blk_co_preadv_part(BlockBackend *blk= , int64_t offset, } =20 /* To be called between exactly one pair of blk_inc/dec_in_flight() */ -int coroutine_fn +static int coroutine_fn blk_co_do_pwritev_part(BlockBackend *blk, int64_t offset, int64_t bytes, QEMUIOVector *qiov, size_t qiov_offset, BdrvRequestFlags flags) @@ -1691,7 +1691,7 @@ BlockAIOCB *blk_aio_ioctl(BlockBackend *blk, unsigned= long int req, void *buf, } =20 /* To be called between exactly one pair of blk_inc/dec_in_flight() */ -int coroutine_fn +static int coroutine_fn blk_co_do_pdiscard(BlockBackend *blk, int64_t offset, int64_t bytes) { int ret; @@ -1739,7 +1739,7 @@ int coroutine_fn blk_co_pdiscard(BlockBackend *blk, i= nt64_t offset, } =20 /* To be called between exactly one pair of blk_inc/dec_in_flight() */ -int coroutine_fn blk_co_do_flush(BlockBackend *blk) +static int coroutine_fn blk_co_do_flush(BlockBackend *blk) { blk_wait_while_drained(blk); IO_CODE(); diff --git a/block/coroutines.h b/block/coroutines.h index d66551a277..3a2bad564f 100644 --- a/block/coroutines.h +++ b/block/coroutines.h @@ -63,17 +63,6 @@ nbd_co_do_establish_connection(BlockDriverState *bs, boo= l blocking, Error **errp); =20 =20 -int coroutine_fn -blk_co_do_pwritev_part(BlockBackend *blk, int64_t offset, int64_t bytes, - QEMUIOVector *qiov, size_t qiov_offset, - BdrvRequestFlags flags); - -int coroutine_fn -blk_co_do_pdiscard(BlockBackend *blk, int64_t offset, int64_t bytes); - -int coroutine_fn blk_co_do_flush(BlockBackend *blk); - - /* * "I/O or GS" API functions. These functions can run without * the BQL, but only in one specific iothread/main loop. @@ -82,14 +71,6 @@ int coroutine_fn blk_co_do_flush(BlockBackend *blk); * the "I/O or GS" API. */ =20 -int generated_co_wrapper -bdrv_preadv(BdrvChild *child, int64_t offset, int64_t bytes, - QEMUIOVector *qiov, BdrvRequestFlags flags); - -int generated_co_wrapper -bdrv_pwritev(BdrvChild *child, int64_t offset, int64_t bytes, - QEMUIOVector *qiov, BdrvRequestFlags flags); - int generated_co_wrapper bdrv_common_block_status_above(BlockDriverState *bs, BlockDriverState *base, --=20 2.35.3