From nobody Tue Feb 10 22:18:33 2026 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=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1679548863; cv=none; d=zohomail.com; s=zohoarc; b=BCThxHagIjBeuploQBlNvP0BT2920YEAXk9Z4LhF53Qx/Aao92odLqeu+2f0c4PUUBySGgUUJuh5OKSZoTzDtTanHMJz9RFQ9KK875FWYAoATSKa2RgAlPIOBpvJ7gV6QkyVtv+CpZNyVfNDwxAhi7QswnBFfEe9QuxaHlMVAXM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1679548863; 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=/ikPBy/a9360N/Znl3i7EG46vLU6pO8IUJ+7aDjsMi0=; b=UPrhEDz165jVLGNn/hYaeAUFsV9LaUoCj6tF5sXwE+pBURLBImOm3gmWTAPzSH+ZKV6I6wbGAGXNZBfnnI5xD09O0R920J4cGsmOBr77G7v7U3Yds5FCSTWBOii4nwctSp71/52M/1v9T3pTxz70LwaC+uE9x7oqLb88Zep0fWc= 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 1679548863303346.54092551298845; Wed, 22 Mar 2023 22:21:03 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pfDNP-0005S9-2p; Thu, 23 Mar 2023 01:20:39 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pfDNN-0005Rg-Al; Thu, 23 Mar 2023 01:20:37 -0400 Received: from mail-pj1-x1034.google.com ([2607:f8b0:4864:20::1034]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pfDNL-0000hL-CL; Thu, 23 Mar 2023 01:20:37 -0400 Received: by mail-pj1-x1034.google.com with SMTP id l7so3447326pjg.5; Wed, 22 Mar 2023 22:20:34 -0700 (PDT) Received: from fedlinux.. ([106.84.129.82]) by smtp.gmail.com with ESMTPSA id c10-20020a170902b68a00b0019edf07eb06sm11428073pls.122.2023.03.22.22.20.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Mar 2023 22:20:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1679548833; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=/ikPBy/a9360N/Znl3i7EG46vLU6pO8IUJ+7aDjsMi0=; b=ne10cCFkCJwKzJ780qm+ro2UFRoIgNICNNJGhr19wrtN7nse3gLAF6edEE6zhAZ1+q 7KRwwZ+YoWk5K2n4JfDK2um5zz9yNytvq2pPc0WSg8ydPbvb+tvLUywthZmULNSCAU7Y d0yRXtfMoqVq7YLrNGLaLZvJbE+TdfuArutoY6p5NJrsjp2UxLsWjqtHlVwO05D0tbTV 6uPJBHFTTBR7iwQQ/u9x8ksazTQY1Nuk8k2w99BMoqkP/pzKkdfBtpSafyeKkEEc/8VX 5cVvPuuIRhy9ZB9cYCaPB+fyXbmMDS5TlQwP1DAnjp0Ox/mzQmpeJvJIUzlLAJgd0tl5 wSIg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679548833; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=/ikPBy/a9360N/Znl3i7EG46vLU6pO8IUJ+7aDjsMi0=; b=4Zh/uJmhyCp9E+mbOQHMbxNP6ZUdkQiiDeQE9I872eJudlAjpMt/HDr73l6ZitTDxL xu3bZkOrUIOF7jggAjPiZpT/54540K8XI/pQ1ALHflg4qNA3KrwNDUsOzNzFK9sApjIf tfNvA6ePgkWGBZv2g840R+xlsmU6qLD3/gMkkyzuEGAIxUsEddyxoRCZiPPZvxtX/vym xJallNR94FHqIF+8Adf+cS52oq3ylNZcA9Fw09pdxzbyCJmg2TDEUh+SXd8wb3Jtznrm 9zPelLwPMfS1PJJDmGmneOyPw3lUtSCY4B/oI/JqmW8tzn5qg1Sv/427sEJ8uCzwzGPI oOfg== X-Gm-Message-State: AO0yUKXhHVBp5lqtGSbgOKlVSY3QAl/ShaA5qArYbBbXgI89W+pq+91f sB5TZsIUzVlfbdrjBo1KEorj7dAliztNtWGUaJQ= X-Google-Smtp-Source: AK7set8kk04sYAxjwMM63uGOUjbjFRoROFQq6JAuhvujHtjWLwF4xNNX6isKRe+6g2rlxziIkp8dqA== X-Received: by 2002:a17:903:2846:b0:19a:a9d8:e48a with SMTP id kq6-20020a170903284600b0019aa9d8e48amr4410054plb.22.1679548832782; Wed, 22 Mar 2023 22:20:32 -0700 (PDT) From: Sam Li To: qemu-devel@nongnu.org Cc: Kevin Wolf , Stefan Hajnoczi , Hanna Reitz , Stefano Garzarella , hare@suse.de, Fam Zheng , dmitry.fomichev@wdc.com, damien.lemoal@opensource.wdc.com, Julia Suvorova , Aarushi Mehta , qemu-block@nongnu.org, Sam Li Subject: [PATCH v7 3/4] qemu-iotests: test zone append operation Date: Thu, 23 Mar 2023 13:19:06 +0800 Message-Id: <20230323051907.5948-4-faithilikerun@gmail.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230323051907.5948-1-faithilikerun@gmail.com> References: <20230323051907.5948-1-faithilikerun@gmail.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=2607:f8b0:4864:20::1034; envelope-from=faithilikerun@gmail.com; helo=mail-pj1-x1034.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1679548864222100012 Content-Type: text/plain; charset="utf-8" The patch tests zone append writes by reporting the zone wp after the completion of the call. "zap -p" option can print the sector offset value after completion, which should be the start sector where the append write begins. Signed-off-by: Sam Li Reviewed-by: Stefan Hajnoczi --- qemu-io-cmds.c | 75 ++++++++++++++++++++++++++++++ tests/qemu-iotests/tests/zoned | 16 +++++++ tests/qemu-iotests/tests/zoned.out | 16 +++++++ 3 files changed, 107 insertions(+) diff --git a/qemu-io-cmds.c b/qemu-io-cmds.c index f35ea627d7..3f75d2f5a6 100644 --- a/qemu-io-cmds.c +++ b/qemu-io-cmds.c @@ -1874,6 +1874,80 @@ static const cmdinfo_t zone_reset_cmd =3D { .oneline =3D "reset a zone write pointer in zone block device", }; =20 +static int do_aio_zone_append(BlockBackend *blk, QEMUIOVector *qiov, + int64_t *offset, int flags, int *total) +{ + int async_ret =3D NOT_DONE; + + blk_aio_zone_append(blk, offset, qiov, flags, aio_rw_done, &async_ret); + while (async_ret =3D=3D NOT_DONE) { + main_loop_wait(false); + } + + *total =3D qiov->size; + return async_ret < 0 ? async_ret : 1; +} + +static int zone_append_f(BlockBackend *blk, int argc, char **argv) +{ + int ret; + bool pflag =3D false; + int flags =3D 0; + int total =3D 0; + int64_t offset; + char *buf; + int c, nr_iov; + int pattern =3D 0xcd; + QEMUIOVector qiov; + + if (optind > argc - 3) { + return -EINVAL; + } + + if ((c =3D getopt(argc, argv, "p")) !=3D -1) { + pflag =3D true; + } + + offset =3D cvtnum(argv[optind]); + if (offset < 0) { + print_cvtnum_err(offset, argv[optind]); + return offset; + } + optind++; + nr_iov =3D argc - optind; + buf =3D create_iovec(blk, &qiov, &argv[optind], nr_iov, pattern, + flags & BDRV_REQ_REGISTERED_BUF); + if (buf =3D=3D NULL) { + return -EINVAL; + } + ret =3D do_aio_zone_append(blk, &qiov, &offset, flags, &total); + if (ret < 0) { + printf("zone append failed: %s\n", strerror(-ret)); + goto out; + } + + if (pflag) { + printf("After zap done, the append sector is 0x%" PRIx64 "\n", + tosector(offset)); + } + +out: + qemu_io_free(blk, buf, qiov.size, + flags & BDRV_REQ_REGISTERED_BUF); + qemu_iovec_destroy(&qiov); + return ret; +} + +static const cmdinfo_t zone_append_cmd =3D { + .name =3D "zone_append", + .altname =3D "zap", + .cfunc =3D zone_append_f, + .argmin =3D 3, + .argmax =3D 4, + .args =3D "offset len [len..]", + .oneline =3D "append write a number of bytes at a specified offset", +}; + static int truncate_f(BlockBackend *blk, int argc, char **argv); static const cmdinfo_t truncate_cmd =3D { .name =3D "truncate", @@ -2672,6 +2746,7 @@ static void __attribute((constructor)) init_qemuio_co= mmands(void) qemuio_add_command(&zone_close_cmd); qemuio_add_command(&zone_finish_cmd); qemuio_add_command(&zone_reset_cmd); + qemuio_add_command(&zone_append_cmd); qemuio_add_command(&truncate_cmd); qemuio_add_command(&length_cmd); qemuio_add_command(&info_cmd); diff --git a/tests/qemu-iotests/tests/zoned b/tests/qemu-iotests/tests/zoned index 53097e44d9..46e4f25919 100755 --- a/tests/qemu-iotests/tests/zoned +++ b/tests/qemu-iotests/tests/zoned @@ -79,6 +79,22 @@ echo "(5) resetting the second zone" $QEMU_IO $IMG -c "zrs 268435456 268435456" echo "After resetting a zone:" $QEMU_IO $IMG -c "zrp 268435456 1" +echo +echo +echo "(6) append write" # the physical block size of the device is 4096 +$QEMU_IO $IMG -c "zrp 0 1" +$QEMU_IO $IMG -c "zap -p 0 0x1000 0x2000" +echo "After appending the first zone firstly:" +$QEMU_IO $IMG -c "zrp 0 1" +$QEMU_IO $IMG -c "zap -p 0 0x1000 0x2000" +echo "After appending the first zone secondly:" +$QEMU_IO $IMG -c "zrp 0 1" +$QEMU_IO $IMG -c "zap -p 268435456 0x1000 0x2000" +echo "After appending the second zone firstly:" +$QEMU_IO $IMG -c "zrp 268435456 1" +$QEMU_IO $IMG -c "zap -p 268435456 0x1000 0x2000" +echo "After appending the second zone secondly:" +$QEMU_IO $IMG -c "zrp 268435456 1" =20 # success, all done echo "*** done" diff --git a/tests/qemu-iotests/tests/zoned.out b/tests/qemu-iotests/tests/= zoned.out index b2d061da49..fe53ba4744 100644 --- a/tests/qemu-iotests/tests/zoned.out +++ b/tests/qemu-iotests/tests/zoned.out @@ -50,4 +50,20 @@ start: 0x80000, len 0x80000, cap 0x80000, wptr 0x100000,= zcond:14, [type: 2] (5) resetting the second zone After resetting a zone: start: 0x80000, len 0x80000, cap 0x80000, wptr 0x80000, zcond:1, [type: 2] + + +(6) append write +start: 0x0, len 0x80000, cap 0x80000, wptr 0x0, zcond:1, [type: 2] +After zap done, the append sector is 0x0 +After appending the first zone firstly: +start: 0x0, len 0x80000, cap 0x80000, wptr 0x18, zcond:2, [type: 2] +After zap done, the append sector is 0x18 +After appending the first zone secondly: +start: 0x0, len 0x80000, cap 0x80000, wptr 0x30, zcond:2, [type: 2] +After zap done, the append sector is 0x80000 +After appending the second zone firstly: +start: 0x80000, len 0x80000, cap 0x80000, wptr 0x80018, zcond:2, [type: 2] +After zap done, the append sector is 0x80018 +After appending the second zone secondly: +start: 0x80000, len 0x80000, cap 0x80000, wptr 0x80030, zcond:2, [type: 2] *** done --=20 2.39.2