From nobody Mon May 20 02:18:01 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=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1678445721; cv=none; d=zohomail.com; s=zohoarc; b=jCgL6Hh6B0BeoH5p0to6XMOy22pEegkNI9bCdPu8r4f0XzB0dYWD9r8Et4DKAnCo2M6DJ8IWilI34GURrUNV9rne2tgAg1kVV+YARCJGoCtcHmyBQhM9zUplSM5YvIrjXzLqx5HpL2L2YLCO4ySkJV2KNcpNnLlpMNaZGX3DsLY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1678445721; 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=DrzF0vDTto0xuqyb7Vf47oN2UnXwHNqODGgyz6+yxfw=; b=nM+homtQDBWadjDMPlmjJ0AKyc5iv96rMcpxEjlgmKv7iNoKXjVxOLvDtnm1qU12rJycFnSOyAKTEglwAC13YoIZJDEfL4JUMSJ/6NeCbGdGeMFLI8o//YSF8fgWrvCo8r7pXvl050Rk4B6/6SDT/um01AdPKEr0Zs878G7gcV8= 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 1678445721882794.2834022983226; Fri, 10 Mar 2023 02:55:21 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1paaOp-0001lD-Pw; Fri, 10 Mar 2023 05:54:59 -0500 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 1paaOo-0001jz-RR; Fri, 10 Mar 2023 05:54:58 -0500 Received: from mail-pg1-x52d.google.com ([2607:f8b0:4864:20::52d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1paaOe-0001I6-45; Fri, 10 Mar 2023 05:54:51 -0500 Received: by mail-pg1-x52d.google.com with SMTP id d8so2805503pgm.3; Fri, 10 Mar 2023 02:54:46 -0800 (PST) Received: from fedlinux.. ([106.84.129.9]) by smtp.gmail.com with ESMTPSA id j9-20020a654309000000b00502e6bfedc0sm1081397pgq.0.2023.03.10.02.54.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 10 Mar 2023 02:54:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1678445684; 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=DrzF0vDTto0xuqyb7Vf47oN2UnXwHNqODGgyz6+yxfw=; b=EmExaSuud0Pf7TqLmB4vugV7iATeTqcA0aNSvyIU2jV0CKwmsNODXo/CexA4jtHLNt wgst+9L0oFjKhzYgiihms9qRqgFy8nzzaAOYdFyMplsfFyi04TDOnIjmTfq1BbLv9LGN bzdukkUZ0XTjnazEl919MDCXnn4ZQyPVuNc0mtrYmVL9a1Hnnb+5uZLGWbiixlPmTjY6 SaeI9JttWAGGDWfANoSjg7tSaUgtxyJEwALXw7jELeMJAXr08tpMYn0VYGoSCBDwftRX HWb7H/r/T/IN0T5X9333KUsA6gKIdjPyUWTCkrxjmFMAcp9uEOm47nRZzMtsFzZKByaJ r/GA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678445684; 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=DrzF0vDTto0xuqyb7Vf47oN2UnXwHNqODGgyz6+yxfw=; b=PJ81CE1be/n9KKEBdqPsFuEc3CGhschIwlAoHtoPzaqfsoVrEoEd1JH5qOAvBKdkLO MknZKjmBIODfl6+JVqyt+tCOYV+rkeNwSj8oOJfDmCD8U3UHsDvomeZHLt6BWo35gp4I txO2wYZVCYg+Kug0qWWcUQpcdWMNjhCB4xKcSTmAZfpZIITDZQ0rJRtF3XNHrZpAMZib Uk6WIwlqxTegMVOUm5jOWAhs25IsRTJhUqoaMrDtDZDG1ojq6fS4OhjsjP5IaDOpXxCB X6vmvmtSraTt9WzvKpwt+tNDugSoT1kRyolqk1j2SOSL3ZUr0vbF5cO+PwFAXjcGUXw1 5oBg== X-Gm-Message-State: AO0yUKXpFr/a600ITL8Ajdz+fqW8jWfDPiUa8kvaPXUFlH1KPFWTpABz hZdLcNTsupTlttp+YAfYjMNJJ31Jb9HO3/zLyXk= X-Google-Smtp-Source: AK7set8ZvYRVm84DRjNst9lrDDALeLsZcV+FqvfHSYgAgqraX5c3FmZn3BFu6RPAyI3pvRDKHMUdXg== X-Received: by 2002:a62:1d53:0:b0:593:91e4:99e2 with SMTP id d80-20020a621d53000000b0059391e499e2mr21634076pfd.34.1678445684050; Fri, 10 Mar 2023 02:54:44 -0800 (PST) From: Sam Li To: qemu-devel@nongnu.org Cc: stefanha@redhat.com, damien.lemoal@opensource.wdc.com, Hanna Reitz , hare@suse.de, qemu-block@nongnu.org, Eric Blake , Paolo Bonzini , dmitry.fomichev@wdc.com, Cornelia Huck , Markus Armbruster , kvm@vger.kernel.org, "Michael S. Tsirkin" , Kevin Wolf , Raphael Norwitz , Sam Li Subject: [PATCH v7 1/4] include: update virtio_blk headers to v6.3-rc1 Date: Fri, 10 Mar 2023 18:54:28 +0800 Message-Id: <20230310105431.64271-2-faithilikerun@gmail.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230310105431.64271-1-faithilikerun@gmail.com> References: <20230310105431.64271-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::52d; envelope-from=faithilikerun@gmail.com; helo=mail-pg1-x52d.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: 1678445723226100003 Content-Type: text/plain; charset="utf-8" Use scripts/update-linux-headers.sh to update headers to 6.3-rc1. Signed-off-by: Sam Li Reviewed-by: Stefan Hajnoczi Reviewed-by: Dmitry Fomichev --- include/standard-headers/drm/drm_fourcc.h | 12 +++ include/standard-headers/linux/ethtool.h | 48 ++++++++- include/standard-headers/linux/fuse.h | 45 +++++++- include/standard-headers/linux/pci_regs.h | 1 + include/standard-headers/linux/vhost_types.h | 2 + include/standard-headers/linux/virtio_blk.h | 105 +++++++++++++++++++ linux-headers/asm-arm64/kvm.h | 1 + linux-headers/asm-x86/kvm.h | 34 +++++- linux-headers/linux/kvm.h | 9 ++ linux-headers/linux/vfio.h | 15 +-- linux-headers/linux/vhost.h | 8 ++ 11 files changed, 270 insertions(+), 10 deletions(-) diff --git a/include/standard-headers/drm/drm_fourcc.h b/include/standard-h= eaders/drm/drm_fourcc.h index 69cab17b38..dc3e6112c1 100644 --- a/include/standard-headers/drm/drm_fourcc.h +++ b/include/standard-headers/drm/drm_fourcc.h @@ -87,6 +87,18 @@ extern "C" { * * The authoritative list of format modifier codes is found in * `include/uapi/drm/drm_fourcc.h` + * + * Open Source User Waiver + * ----------------------- + * + * Because this is the authoritative source for pixel formats and modifiers + * referenced by GL, Vulkan extensions and other standards and hence used = both + * by open source and closed source driver stacks, the usual requirement f= or an + * upstream in-kernel or open source userspace user does not apply. + * + * To ensure, as much as feasible, compatibility across stacks and avoid + * confusion with incompatible enumerations stakeholders for all relevant = driver + * stacks should approve additions. */ =20 #define fourcc_code(a, b, c, d) ((uint32_t)(a) | ((uint32_t)(b) << 8) | \ diff --git a/include/standard-headers/linux/ethtool.h b/include/standard-he= aders/linux/ethtool.h index 87176ab075..99fcddf04f 100644 --- a/include/standard-headers/linux/ethtool.h +++ b/include/standard-headers/linux/ethtool.h @@ -711,6 +711,24 @@ enum ethtool_stringset { ETH_SS_COUNT }; =20 +/** + * enum ethtool_mac_stats_src - source of ethtool MAC statistics + * @ETHTOOL_MAC_STATS_SRC_AGGREGATE: + * if device supports a MAC merge layer, this retrieves the aggregate + * statistics of the eMAC and pMAC. Otherwise, it retrieves just the + * statistics of the single (express) MAC. + * @ETHTOOL_MAC_STATS_SRC_EMAC: + * if device supports a MM layer, this retrieves the eMAC statistics. + * Otherwise, it retrieves the statistics of the single (express) MAC. + * @ETHTOOL_MAC_STATS_SRC_PMAC: + * if device supports a MM layer, this retrieves the pMAC statistics. + */ +enum ethtool_mac_stats_src { + ETHTOOL_MAC_STATS_SRC_AGGREGATE, + ETHTOOL_MAC_STATS_SRC_EMAC, + ETHTOOL_MAC_STATS_SRC_PMAC, +}; + /** * enum ethtool_module_power_mode_policy - plug-in module power mode policy * @ETHTOOL_MODULE_POWER_MODE_POLICY_HIGH: Module is always in high power = mode. @@ -779,6 +797,31 @@ enum ethtool_podl_pse_pw_d_status { ETHTOOL_PODL_PSE_PW_D_STATUS_ERROR, }; =20 +/** + * enum ethtool_mm_verify_status - status of MAC Merge Verify function + * @ETHTOOL_MM_VERIFY_STATUS_UNKNOWN: + * verification status is unknown + * @ETHTOOL_MM_VERIFY_STATUS_INITIAL: + * the 802.3 Verify State diagram is in the state INIT_VERIFICATION + * @ETHTOOL_MM_VERIFY_STATUS_VERIFYING: + * the Verify State diagram is in the state VERIFICATION_IDLE, + * SEND_VERIFY or WAIT_FOR_RESPONSE + * @ETHTOOL_MM_VERIFY_STATUS_SUCCEEDED: + * indicates that the Verify State diagram is in the state VERIFIED + * @ETHTOOL_MM_VERIFY_STATUS_FAILED: + * the Verify State diagram is in the state VERIFY_FAIL + * @ETHTOOL_MM_VERIFY_STATUS_DISABLED: + * verification of preemption operation is disabled + */ +enum ethtool_mm_verify_status { + ETHTOOL_MM_VERIFY_STATUS_UNKNOWN, + ETHTOOL_MM_VERIFY_STATUS_INITIAL, + ETHTOOL_MM_VERIFY_STATUS_VERIFYING, + ETHTOOL_MM_VERIFY_STATUS_SUCCEEDED, + ETHTOOL_MM_VERIFY_STATUS_FAILED, + ETHTOOL_MM_VERIFY_STATUS_DISABLED, +}; + /** * struct ethtool_gstrings - string set for data tagging * @cmd: Command number =3D %ETHTOOL_GSTRINGS @@ -1183,7 +1226,7 @@ struct ethtool_rxnfc { uint32_t rule_cnt; uint32_t rss_context; }; - uint32_t rule_locs[0]; + uint32_t rule_locs[]; }; =20 =20 @@ -1741,6 +1784,9 @@ enum ethtool_link_mode_bit_indices { ETHTOOL_LINK_MODE_800000baseDR8_2_Full_BIT =3D 96, ETHTOOL_LINK_MODE_800000baseSR8_Full_BIT =3D 97, ETHTOOL_LINK_MODE_800000baseVR8_Full_BIT =3D 98, + ETHTOOL_LINK_MODE_10baseT1S_Full_BIT =3D 99, + ETHTOOL_LINK_MODE_10baseT1S_Half_BIT =3D 100, + ETHTOOL_LINK_MODE_10baseT1S_P2MP_Half_BIT =3D 101, =20 /* must be last entry */ __ETHTOOL_LINK_MODE_MASK_NBITS diff --git a/include/standard-headers/linux/fuse.h b/include/standard-heade= rs/linux/fuse.h index a1af78d989..35c131a107 100644 --- a/include/standard-headers/linux/fuse.h +++ b/include/standard-headers/linux/fuse.h @@ -201,6 +201,11 @@ * 7.38 * - add FUSE_EXPIRE_ONLY flag to fuse_notify_inval_entry * - add FOPEN_PARALLEL_DIRECT_WRITES + * - add total_extlen to fuse_in_header + * - add FUSE_MAX_NR_SECCTX + * - add extension header + * - add FUSE_EXT_GROUPS + * - add FUSE_CREATE_SUPP_GROUP */ =20 #ifndef _LINUX_FUSE_H @@ -358,6 +363,8 @@ struct fuse_file_lock { * FUSE_SECURITY_CTX: add security context to create, mkdir, symlink, and * mknod * FUSE_HAS_INODE_DAX: use per inode DAX + * FUSE_CREATE_SUPP_GROUP: add supplementary group info to create, mkdir, + * symlink and mknod (single group that matches parent) */ #define FUSE_ASYNC_READ (1 << 0) #define FUSE_POSIX_LOCKS (1 << 1) @@ -394,6 +401,7 @@ struct fuse_file_lock { /* bits 32..63 get shifted down 32 bits into the flags2 field */ #define FUSE_SECURITY_CTX (1ULL << 32) #define FUSE_HAS_INODE_DAX (1ULL << 33) +#define FUSE_CREATE_SUPP_GROUP (1ULL << 34) =20 /** * CUSE INIT request/reply flags @@ -499,6 +507,17 @@ struct fuse_file_lock { */ #define FUSE_EXPIRE_ONLY (1 << 0) =20 +/** + * extension type + * FUSE_MAX_NR_SECCTX: maximum value of &fuse_secctx_header.nr_secctx + * FUSE_EXT_GROUPS: &fuse_supp_groups extension + */ +enum fuse_ext_type { + /* Types 0..31 are reserved for fuse_secctx_header */ + FUSE_MAX_NR_SECCTX =3D 31, + FUSE_EXT_GROUPS =3D 32, +}; + enum fuse_opcode { FUSE_LOOKUP =3D 1, FUSE_FORGET =3D 2, /* no reply */ @@ -882,7 +901,8 @@ struct fuse_in_header { uint32_t uid; uint32_t gid; uint32_t pid; - uint32_t padding; + uint16_t total_extlen; /* length of extensions in 8byte units */ + uint16_t padding; }; =20 struct fuse_out_header { @@ -1043,4 +1063,27 @@ struct fuse_secctx_header { uint32_t nr_secctx; }; =20 +/** + * struct fuse_ext_header - extension header + * @size: total size of this extension including this header + * @type: type of extension + * + * This is made compatible with fuse_secctx_header by using type values > + * FUSE_MAX_NR_SECCTX + */ +struct fuse_ext_header { + uint32_t size; + uint32_t type; +}; + +/** + * struct fuse_supp_groups - Supplementary group extension + * @nr_groups: number of supplementary groups + * @groups: flexible array of group IDs + */ +struct fuse_supp_groups { + uint32_t nr_groups; + uint32_t groups[]; +}; + #endif /* _LINUX_FUSE_H */ diff --git a/include/standard-headers/linux/pci_regs.h b/include/standard-h= eaders/linux/pci_regs.h index 85ab127881..dc2000e0fe 100644 --- a/include/standard-headers/linux/pci_regs.h +++ b/include/standard-headers/linux/pci_regs.h @@ -693,6 +693,7 @@ #define PCI_EXP_LNKCTL2_TX_MARGIN 0x0380 /* Transmit Margin */ #define PCI_EXP_LNKCTL2_HASD 0x0020 /* HW Autonomous Speed Disable */ #define PCI_EXP_LNKSTA2 0x32 /* Link Status 2 */ +#define PCI_EXP_LNKSTA2_FLIT 0x0400 /* Flit Mode Status */ #define PCI_CAP_EXP_ENDPOINT_SIZEOF_V2 0x32 /* end of v2 EPs w/ link */ #define PCI_EXP_SLTCAP2 0x34 /* Slot Capabilities 2 */ #define PCI_EXP_SLTCAP2_IBPD 0x00000001 /* In-band PD Disable Supported */ diff --git a/include/standard-headers/linux/vhost_types.h b/include/standar= d-headers/linux/vhost_types.h index c41a73fe36..88600e2d9f 100644 --- a/include/standard-headers/linux/vhost_types.h +++ b/include/standard-headers/linux/vhost_types.h @@ -163,5 +163,7 @@ struct vhost_vdpa_iova_range { #define VHOST_BACKEND_F_IOTLB_ASID 0x3 /* Device can be suspended */ #define VHOST_BACKEND_F_SUSPEND 0x4 +/* Device can be resumed */ +#define VHOST_BACKEND_F_RESUME 0x5 =20 #endif diff --git a/include/standard-headers/linux/virtio_blk.h b/include/standard= -headers/linux/virtio_blk.h index e81715cd70..7155b1a470 100644 --- a/include/standard-headers/linux/virtio_blk.h +++ b/include/standard-headers/linux/virtio_blk.h @@ -41,6 +41,7 @@ #define VIRTIO_BLK_F_DISCARD 13 /* DISCARD is supported */ #define VIRTIO_BLK_F_WRITE_ZEROES 14 /* WRITE ZEROES is supported */ #define VIRTIO_BLK_F_SECURE_ERASE 16 /* Secure Erase is supported */ +#define VIRTIO_BLK_F_ZONED 17 /* Zoned block device */ =20 /* Legacy feature bits */ #ifndef VIRTIO_BLK_NO_LEGACY @@ -135,6 +136,16 @@ struct virtio_blk_config { /* Secure erase commands must be aligned to this number of sectors. */ __virtio32 secure_erase_sector_alignment; =20 + /* Zoned block device characteristics (if VIRTIO_BLK_F_ZONED) */ + struct virtio_blk_zoned_characteristics { + uint32_t zone_sectors; + uint32_t max_open_zones; + uint32_t max_active_zones; + uint32_t max_append_sectors; + uint32_t write_granularity; + uint8_t model; + uint8_t unused2[3]; + } zoned; } QEMU_PACKED; =20 /* @@ -172,6 +183,27 @@ struct virtio_blk_config { /* Secure erase command */ #define VIRTIO_BLK_T_SECURE_ERASE 14 =20 +/* Zone append command */ +#define VIRTIO_BLK_T_ZONE_APPEND 15 + +/* Report zones command */ +#define VIRTIO_BLK_T_ZONE_REPORT 16 + +/* Open zone command */ +#define VIRTIO_BLK_T_ZONE_OPEN 18 + +/* Close zone command */ +#define VIRTIO_BLK_T_ZONE_CLOSE 20 + +/* Finish zone command */ +#define VIRTIO_BLK_T_ZONE_FINISH 22 + +/* Reset zone command */ +#define VIRTIO_BLK_T_ZONE_RESET 24 + +/* Reset All zones command */ +#define VIRTIO_BLK_T_ZONE_RESET_ALL 26 + #ifndef VIRTIO_BLK_NO_LEGACY /* Barrier before this op. */ #define VIRTIO_BLK_T_BARRIER 0x80000000 @@ -191,6 +223,72 @@ struct virtio_blk_outhdr { __virtio64 sector; }; =20 +/* + * Supported zoned device models. + */ + +/* Regular block device */ +#define VIRTIO_BLK_Z_NONE 0 +/* Host-managed zoned device */ +#define VIRTIO_BLK_Z_HM 1 +/* Host-aware zoned device */ +#define VIRTIO_BLK_Z_HA 2 + +/* + * Zone descriptor. A part of VIRTIO_BLK_T_ZONE_REPORT command reply. + */ +struct virtio_blk_zone_descriptor { + /* Zone capacity */ + uint64_t z_cap; + /* The starting sector of the zone */ + uint64_t z_start; + /* Zone write pointer position in sectors */ + uint64_t z_wp; + /* Zone type */ + uint8_t z_type; + /* Zone state */ + uint8_t z_state; + uint8_t reserved[38]; +}; + +struct virtio_blk_zone_report { + uint64_t nr_zones; + uint8_t reserved[56]; + struct virtio_blk_zone_descriptor zones[]; +}; + +/* + * Supported zone types. + */ + +/* Conventional zone */ +#define VIRTIO_BLK_ZT_CONV 1 +/* Sequential Write Required zone */ +#define VIRTIO_BLK_ZT_SWR 2 +/* Sequential Write Preferred zone */ +#define VIRTIO_BLK_ZT_SWP 3 + +/* + * Zone states that are available for zones of all types. + */ + +/* Not a write pointer (conventional zones only) */ +#define VIRTIO_BLK_ZS_NOT_WP 0 +/* Empty */ +#define VIRTIO_BLK_ZS_EMPTY 1 +/* Implicitly Open */ +#define VIRTIO_BLK_ZS_IOPEN 2 +/* Explicitly Open */ +#define VIRTIO_BLK_ZS_EOPEN 3 +/* Closed */ +#define VIRTIO_BLK_ZS_CLOSED 4 +/* Read-Only */ +#define VIRTIO_BLK_ZS_RDONLY 13 +/* Full */ +#define VIRTIO_BLK_ZS_FULL 14 +/* Offline */ +#define VIRTIO_BLK_ZS_OFFLINE 15 + /* Unmap this range (only valid for write zeroes command) */ #define VIRTIO_BLK_WRITE_ZEROES_FLAG_UNMAP 0x00000001 =20 @@ -217,4 +315,11 @@ struct virtio_scsi_inhdr { #define VIRTIO_BLK_S_OK 0 #define VIRTIO_BLK_S_IOERR 1 #define VIRTIO_BLK_S_UNSUPP 2 + +/* Error codes that are specific to zoned block devices */ +#define VIRTIO_BLK_S_ZONE_INVALID_CMD 3 +#define VIRTIO_BLK_S_ZONE_UNALIGNED_WP 4 +#define VIRTIO_BLK_S_ZONE_OPEN_RESOURCE 5 +#define VIRTIO_BLK_S_ZONE_ACTIVE_RESOURCE 6 + #endif /* _LINUX_VIRTIO_BLK_H */ diff --git a/linux-headers/asm-arm64/kvm.h b/linux-headers/asm-arm64/kvm.h index a7cfefb3a8..d7e7bb885e 100644 --- a/linux-headers/asm-arm64/kvm.h +++ b/linux-headers/asm-arm64/kvm.h @@ -109,6 +109,7 @@ struct kvm_regs { #define KVM_ARM_VCPU_SVE 4 /* enable SVE for this CPU */ #define KVM_ARM_VCPU_PTRAUTH_ADDRESS 5 /* VCPU uses address authentication= */ #define KVM_ARM_VCPU_PTRAUTH_GENERIC 6 /* VCPU uses generic authentication= */ +#define KVM_ARM_VCPU_HAS_EL2 7 /* Support nested virtualization */ =20 struct kvm_vcpu_init { __u32 target; diff --git a/linux-headers/asm-x86/kvm.h b/linux-headers/asm-x86/kvm.h index 2747d2ce14..2937e7bf69 100644 --- a/linux-headers/asm-x86/kvm.h +++ b/linux-headers/asm-x86/kvm.h @@ -9,6 +9,7 @@ =20 #include #include +#include =20 #define KVM_PIO_PAGE_OFFSET 1 #define KVM_COALESCED_MMIO_PAGE_OFFSET 2 @@ -505,8 +506,8 @@ struct kvm_nested_state { * KVM_{GET,PUT}_NESTED_STATE ioctl values. */ union { - struct kvm_vmx_nested_state_data vmx[0]; - struct kvm_svm_nested_state_data svm[0]; + __DECLARE_FLEX_ARRAY(struct kvm_vmx_nested_state_data, vmx); + __DECLARE_FLEX_ARRAY(struct kvm_svm_nested_state_data, svm); } data; }; =20 @@ -523,6 +524,35 @@ struct kvm_pmu_event_filter { #define KVM_PMU_EVENT_ALLOW 0 #define KVM_PMU_EVENT_DENY 1 =20 +#define KVM_PMU_EVENT_FLAG_MASKED_EVENTS BIT(0) +#define KVM_PMU_EVENT_FLAGS_VALID_MASK (KVM_PMU_EVENT_FLAG_MASKED_EVENTS) + +/* + * Masked event layout. + * Bits Description + * ---- ----------- + * 7:0 event select (low bits) + * 15:8 umask match + * 31:16 unused + * 35:32 event select (high bits) + * 36:54 unused + * 55 exclude bit + * 63:56 umask mask + */ + +#define KVM_PMU_ENCODE_MASKED_ENTRY(event_select, mask, match, exclude) \ + (((event_select) & 0xFFULL) | (((event_select) & 0XF00ULL) << 24) | \ + (((mask) & 0xFFULL) << 56) | \ + (((match) & 0xFFULL) << 8) | \ + ((__u64)(!!(exclude)) << 55)) + +#define KVM_PMU_MASKED_ENTRY_EVENT_SELECT \ + (GENMASK_ULL(7, 0) | GENMASK_ULL(35, 32)) +#define KVM_PMU_MASKED_ENTRY_UMASK_MASK (GENMASK_ULL(63, 56)) +#define KVM_PMU_MASKED_ENTRY_UMASK_MATCH (GENMASK_ULL(15, 8)) +#define KVM_PMU_MASKED_ENTRY_EXCLUDE (BIT_ULL(55)) +#define KVM_PMU_MASKED_ENTRY_UMASK_MASK_SHIFT (56) + /* for KVM_{GET,SET,HAS}_DEVICE_ATTR */ #define KVM_VCPU_TSC_CTRL 0 /* control group for the timestamp counter (TS= C) */ #define KVM_VCPU_TSC_OFFSET 0 /* attribute for the TSC offset */ diff --git a/linux-headers/linux/kvm.h b/linux-headers/linux/kvm.h index 1e2c16cfe3..599de3c6e3 100644 --- a/linux-headers/linux/kvm.h +++ b/linux-headers/linux/kvm.h @@ -581,6 +581,8 @@ struct kvm_s390_mem_op { struct { __u8 ar; /* the access register number */ __u8 key; /* access key, ignored if flag unset */ + __u8 pad1[6]; /* ignored */ + __u64 old_addr; /* ignored if cmpxchg flag unset */ }; __u32 sida_offset; /* offset into the sida */ __u8 reserved[32]; /* ignored */ @@ -593,11 +595,17 @@ struct kvm_s390_mem_op { #define KVM_S390_MEMOP_SIDA_WRITE 3 #define KVM_S390_MEMOP_ABSOLUTE_READ 4 #define KVM_S390_MEMOP_ABSOLUTE_WRITE 5 +#define KVM_S390_MEMOP_ABSOLUTE_CMPXCHG 6 + /* flags for kvm_s390_mem_op->flags */ #define KVM_S390_MEMOP_F_CHECK_ONLY (1ULL << 0) #define KVM_S390_MEMOP_F_INJECT_EXCEPTION (1ULL << 1) #define KVM_S390_MEMOP_F_SKEY_PROTECTION (1ULL << 2) =20 +/* flags specifying extension support via KVM_CAP_S390_MEM_OP_EXTENSION */ +#define KVM_S390_MEMOP_EXTENSION_CAP_BASE (1 << 0) +#define KVM_S390_MEMOP_EXTENSION_CAP_CMPXCHG (1 << 1) + /* for KVM_INTERRUPT */ struct kvm_interrupt { /* in */ @@ -1173,6 +1181,7 @@ struct kvm_ppc_resize_hpt { #define KVM_CAP_DIRTY_LOG_RING_ACQ_REL 223 #define KVM_CAP_S390_PROTECTED_ASYNC_DISABLE 224 #define KVM_CAP_DIRTY_LOG_RING_WITH_BITMAP 225 +#define KVM_CAP_PMU_EVENT_MASKED_EVENTS 226 =20 #ifdef KVM_CAP_IRQ_ROUTING =20 diff --git a/linux-headers/linux/vfio.h b/linux-headers/linux/vfio.h index c59692ce0b..4a534edbdc 100644 --- a/linux-headers/linux/vfio.h +++ b/linux-headers/linux/vfio.h @@ -49,7 +49,11 @@ /* Supports VFIO_DMA_UNMAP_FLAG_ALL */ #define VFIO_UNMAP_ALL 9 =20 -/* Supports the vaddr flag for DMA map and unmap */ +/* + * Supports the vaddr flag for DMA map and unmap. Not supported for media= ted + * devices, so this capability is subject to change as groups are added or + * removed. + */ #define VFIO_UPDATE_VADDR 10 =20 /* @@ -1343,8 +1347,7 @@ struct vfio_iommu_type1_info_dma_avail { * Map process virtual addresses to IO virtual addresses using the * provided struct vfio_dma_map. Caller sets argsz. READ &/ WRITE required. * - * If flags & VFIO_DMA_MAP_FLAG_VADDR, update the base vaddr for iova, and - * unblock translation of host virtual addresses in the iova range. The v= addr + * If flags & VFIO_DMA_MAP_FLAG_VADDR, update the base vaddr for iova. The= vaddr * must have previously been invalidated with VFIO_DMA_UNMAP_FLAG_VADDR. = To * maintain memory consistency within the user application, the updated va= ddr * must address the same memory object as originally mapped. Failure to d= o so @@ -1395,9 +1398,9 @@ struct vfio_bitmap { * must be 0. This cannot be combined with the get-dirty-bitmap flag. * * If flags & VFIO_DMA_UNMAP_FLAG_VADDR, do not unmap, but invalidate host - * virtual addresses in the iova range. Tasks that attempt to translate an - * iova's vaddr will block. DMA to already-mapped pages continues. This - * cannot be combined with the get-dirty-bitmap flag. + * virtual addresses in the iova range. DMA to already-mapped pages conti= nues. + * Groups may not be added to the container while any addresses are invali= d. + * This cannot be combined with the get-dirty-bitmap flag. */ struct vfio_iommu_type1_dma_unmap { __u32 argsz; diff --git a/linux-headers/linux/vhost.h b/linux-headers/linux/vhost.h index f9f115a7c7..92e1b700b5 100644 --- a/linux-headers/linux/vhost.h +++ b/linux-headers/linux/vhost.h @@ -180,4 +180,12 @@ */ #define VHOST_VDPA_SUSPEND _IO(VHOST_VIRTIO, 0x7D) =20 +/* Resume a device so it can resume processing virtqueue requests + * + * After the return of this ioctl the device will have restored all the + * necessary states and it is fully operational to continue processing the + * virtqueue descriptors. + */ +#define VHOST_VDPA_RESUME _IO(VHOST_VIRTIO, 0x7E) + #endif --=20 2.39.2 From nobody Mon May 20 02:18:01 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=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1678445786; cv=none; d=zohomail.com; s=zohoarc; b=IQ07wzsZZYmAyQyHQBD87W90GGJuO9Dh6le1NViPgMHgFOACSwKl2KgteIm4E6hhjVHCxpvEhplCjrZroNFIX4RIApXufEFk+N0MT1kAnPLPmYSQHbKJ30qiYDgoxguGUWui3R6i1fjDkSTTj5equEPpCC2VtqFI+HbWqdDV7fo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1678445786; 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=mNwa6krx5ks+Ws5c8N+WPAjCnXjlzRdUdskdAiPIYTk=; b=KcRKvEntklSkiCR76wXpF8cev4ZnOYs+b4qutybINpo7cqIopr0Werjxl1aCCm5pm1G9rtY0ZMhrU0Zluurvn707kwcEDL8JesWXHrr5wDSz4UV3gsr+O1CwiY+XjxhV6luKw29UYCVAcD1K7SpkMmi67OKev9Y4rTGRK0tBI/o= 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 1678445786202299.2669377281453; Fri, 10 Mar 2023 02:56:26 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1paaOq-0001lj-UF; Fri, 10 Mar 2023 05:55:00 -0500 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 1paaOo-0001k4-Re; Fri, 10 Mar 2023 05:54:58 -0500 Received: from mail-pj1-x1033.google.com ([2607:f8b0:4864:20::1033]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1paaOh-0001Ik-AK; Fri, 10 Mar 2023 05:54:54 -0500 Received: by mail-pj1-x1033.google.com with SMTP id h17-20020a17090aea9100b0023739b10792so4821491pjz.1; Fri, 10 Mar 2023 02:54:50 -0800 (PST) Received: from fedlinux.. ([106.84.129.9]) by smtp.gmail.com with ESMTPSA id j9-20020a654309000000b00502e6bfedc0sm1081397pgq.0.2023.03.10.02.54.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 10 Mar 2023 02:54:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1678445689; 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=mNwa6krx5ks+Ws5c8N+WPAjCnXjlzRdUdskdAiPIYTk=; b=Vlh5DJZ8FGJw2OYfKnpolau0UU+52do5qVRA3Q6HSWgBaNIdt5m5YuzRq5SqZx3yrq mhk8zd/PBsZ26G1RLkXllwoRBIkpPOp4jKCsf9F/hIXtpImYD2ZOJKbAQwPp2gKmp6TG Z0Pe01e2z0c9VMygqH7TntMchxpk+px7RURHCCsgoJKY/zhXUObCxf3GhmNSVCKcMTSc iUH1FcZ5Kg2DptOja+KIZYfrBAHTe+Dy6UlHA2d5wyhRVaSSf6mwV846e0fZAsTCdSIR Xv1WNlyFMJbWnk0dpSTDLhx+En0EGFmBOny+ohK92ARYrVvUii5mKu5zbubQRBO+lH0E fBRg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678445689; 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=mNwa6krx5ks+Ws5c8N+WPAjCnXjlzRdUdskdAiPIYTk=; b=r7mXQaWWH6/DtpK6kx0G+lp+yq2y6eUjZPIYYc3s1Nen0VoS+VMohpwGnnbnLgIaqh +K+WQBiBX8nhsYWMM3iJfp5E2ZZdo18eDZsIS1UORwTTGOVWACNzg1GMBmhsdzKOeZ8a W0gLZCLNtBSLfiKOcvdiWuLlSCXKhcW8jBrjzxoSYi/5xCoQrMEphGZbV/acVoUTAHoZ oEBgPxs1W5KKgZBieYfPogfOQAzV/0RxW+zYB6Vz3w5s7DZyCmP+LqUE3b0dRIaHZK8L bRD1YYF9Shu7/JMcbBI/HQTzXiYwJOPvYjvxfeTDYc6CcR1Y7HM4m56A5q23h+beufj5 d3yw== X-Gm-Message-State: AO0yUKXFozNcSNKhhuS4JX+VnQ8lV5/nCmYi5Qje057kaa4ZS0u9yb7O MEzZA5BlD9KqdwwFh1ot2ixWqACJpYBM12LhMdk= X-Google-Smtp-Source: AK7set9yLLpF0fDZqBckM+QFT+WA3YLl5/MjhgD9GoWbzSQCxThB1F0GHJIOp+DwocWudoj/f5xnVA== X-Received: by 2002:a17:902:ee46:b0:19e:3725:8fc6 with SMTP id 6-20020a170902ee4600b0019e37258fc6mr22519970plo.20.1678445688837; Fri, 10 Mar 2023 02:54:48 -0800 (PST) From: Sam Li To: qemu-devel@nongnu.org Cc: stefanha@redhat.com, damien.lemoal@opensource.wdc.com, Hanna Reitz , hare@suse.de, qemu-block@nongnu.org, Eric Blake , Paolo Bonzini , dmitry.fomichev@wdc.com, Cornelia Huck , Markus Armbruster , kvm@vger.kernel.org, "Michael S. Tsirkin" , Kevin Wolf , Raphael Norwitz , Sam Li Subject: [PATCH v7 2/4] virtio-blk: add zoned storage emulation for zoned devices Date: Fri, 10 Mar 2023 18:54:29 +0800 Message-Id: <20230310105431.64271-3-faithilikerun@gmail.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230310105431.64271-1-faithilikerun@gmail.com> References: <20230310105431.64271-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::1033; envelope-from=faithilikerun@gmail.com; helo=mail-pj1-x1033.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: 1678445787257100001 Content-Type: text/plain; charset="utf-8" This patch extends virtio-blk emulation to handle zoned device commands by calling the new block layer APIs to perform zoned device I/O on behalf of the guest. It supports Report Zone, four zone oparations (open, close, finish, reset), and Append Zone. The VIRTIO_BLK_F_ZONED feature bit will only be set if the host does support zoned block devices. Regular block devices(conventional zones) will not be set. The guest os can use blktests, fio to test those commands on zoned devices. Furthermore, using zonefs to test zone append write is also supported. Signed-off-by: Sam Li --- hw/block/virtio-blk-common.c | 2 + hw/block/virtio-blk.c | 394 +++++++++++++++++++++++++++++++++++ 2 files changed, 396 insertions(+) diff --git a/hw/block/virtio-blk-common.c b/hw/block/virtio-blk-common.c index ac52d7c176..e2f8e2f6da 100644 --- a/hw/block/virtio-blk-common.c +++ b/hw/block/virtio-blk-common.c @@ -29,6 +29,8 @@ static const VirtIOFeature feature_sizes[] =3D { .end =3D endof(struct virtio_blk_config, discard_sector_alignment)}, {.flags =3D 1ULL << VIRTIO_BLK_F_WRITE_ZEROES, .end =3D endof(struct virtio_blk_config, write_zeroes_may_unmap)}, + {.flags =3D 1ULL << VIRTIO_BLK_F_ZONED, + .end =3D endof(struct virtio_blk_config, zoned)}, {} }; =20 diff --git a/hw/block/virtio-blk.c b/hw/block/virtio-blk.c index cefca93b31..4ded625732 100644 --- a/hw/block/virtio-blk.c +++ b/hw/block/virtio-blk.c @@ -17,6 +17,7 @@ #include "qemu/module.h" #include "qemu/error-report.h" #include "qemu/main-loop.h" +#include "block/block_int.h" #include "trace.h" #include "hw/block/block.h" #include "hw/qdev-properties.h" @@ -601,6 +602,341 @@ err: return err_status; } =20 +typedef struct ZoneCmdData { + VirtIOBlockReq *req; + struct iovec *in_iov; + unsigned in_num; + union { + struct { + unsigned int nr_zones; + BlockZoneDescriptor *zones; + } zone_report_data; + struct { + int64_t offset; + } zone_append_data; + }; +} ZoneCmdData; + +/* + * check zoned_request: error checking before issuing requests. If all che= cks + * passed, return true. + * append: true if only zone append requests issued. + */ +static bool check_zoned_request(VirtIOBlock *s, int64_t offset, int64_t le= n, + bool append, uint8_t *status) { + BlockDriverState *bs =3D blk_bs(s->blk); + int index; + + if (!virtio_has_feature(s->host_features, VIRTIO_BLK_F_ZONED)) { + *status =3D VIRTIO_BLK_S_UNSUPP; + return false; + } + + if (offset < 0 || len < 0 || len > (bs->total_sectors << BDRV_SECTOR_B= ITS) + || offset > (bs->total_sectors << BDRV_SECTOR_BITS) - len) { + *status =3D VIRTIO_BLK_S_ZONE_INVALID_CMD; + return false; + } + + if (append) { + if (bs->bl.write_granularity) { + if ((offset % bs->bl.write_granularity) !=3D 0) { + *status =3D VIRTIO_BLK_S_ZONE_UNALIGNED_WP; + return false; + } + } + + index =3D offset / bs->bl.zone_size; + if (BDRV_ZT_IS_CONV(bs->bl.wps->wp[index])) { + *status =3D VIRTIO_BLK_S_ZONE_INVALID_CMD; + return false; + } + + if (len / 512 > bs->bl.max_append_sectors) { + if (bs->bl.max_append_sectors =3D=3D 0) { + *status =3D VIRTIO_BLK_S_UNSUPP; + } else { + *status =3D VIRTIO_BLK_S_ZONE_INVALID_CMD; + } + return false; + } + } + return true; +} + +static void virtio_blk_zone_report_complete(void *opaque, int ret) +{ + ZoneCmdData *data =3D opaque; + VirtIOBlockReq *req =3D data->req; + VirtIOBlock *s =3D req->dev; + VirtIODevice *vdev =3D VIRTIO_DEVICE(req->dev); + struct iovec *in_iov =3D data->in_iov; + unsigned in_num =3D data->in_num; + int64_t zrp_size, n, j =3D 0; + int64_t nz =3D data->zone_report_data.nr_zones; + int8_t err_status =3D VIRTIO_BLK_S_OK; + + if (ret) { + err_status =3D VIRTIO_BLK_S_ZONE_INVALID_CMD; + goto out; + } + + struct virtio_blk_zone_report zrp_hdr =3D (struct virtio_blk_zone_repo= rt) { + .nr_zones =3D cpu_to_le64(nz), + }; + zrp_size =3D sizeof(struct virtio_blk_zone_report) + + sizeof(struct virtio_blk_zone_descriptor) * nz; + n =3D iov_from_buf(in_iov, in_num, 0, &zrp_hdr, sizeof(zrp_hdr)); + if (n !=3D sizeof(zrp_hdr)) { + virtio_error(vdev, "Driver provided input buffer that is too small= !"); + err_status =3D VIRTIO_BLK_S_ZONE_INVALID_CMD; + goto out; + } + + for (size_t i =3D sizeof(zrp_hdr); i < zrp_size; + i +=3D sizeof(struct virtio_blk_zone_descriptor), ++j) { + struct virtio_blk_zone_descriptor desc =3D + (struct virtio_blk_zone_descriptor) { + .z_start =3D cpu_to_le64(data->zone_report_data.zones[j].s= tart + >> BDRV_SECTOR_BITS), + .z_cap =3D cpu_to_le64(data->zone_report_data.zones[j].cap + >> BDRV_SECTOR_BITS), + .z_wp =3D cpu_to_le64(data->zone_report_data.zones[j].wp + >> BDRV_SECTOR_BITS), + }; + + switch (data->zone_report_data.zones[j].type) { + case BLK_ZT_CONV: + desc.z_type =3D VIRTIO_BLK_ZT_CONV; + break; + case BLK_ZT_SWR: + desc.z_type =3D VIRTIO_BLK_ZT_SWR; + break; + case BLK_ZT_SWP: + desc.z_type =3D VIRTIO_BLK_ZT_SWP; + break; + default: + g_assert_not_reached(); + } + + switch (data->zone_report_data.zones[j].state) { + case BLK_ZS_RDONLY: + desc.z_state =3D VIRTIO_BLK_ZS_RDONLY; + break; + case BLK_ZS_OFFLINE: + desc.z_state =3D VIRTIO_BLK_ZS_OFFLINE; + break; + case BLK_ZS_EMPTY: + desc.z_state =3D VIRTIO_BLK_ZS_EMPTY; + break; + case BLK_ZS_CLOSED: + desc.z_state =3D VIRTIO_BLK_ZS_CLOSED; + break; + case BLK_ZS_FULL: + desc.z_state =3D VIRTIO_BLK_ZS_FULL; + break; + case BLK_ZS_EOPEN: + desc.z_state =3D VIRTIO_BLK_ZS_EOPEN; + break; + case BLK_ZS_IOPEN: + desc.z_state =3D VIRTIO_BLK_ZS_IOPEN; + break; + case BLK_ZS_NOT_WP: + desc.z_state =3D VIRTIO_BLK_ZS_NOT_WP; + break; + default: + g_assert_not_reached(); + } + + /* TODO: it takes O(n^2) time complexity. Optimizations required. = */ + n =3D iov_from_buf(in_iov, in_num, i, &desc, sizeof(desc)); + if (n !=3D sizeof(desc)) { + virtio_error(vdev, "Driver provided input buffer " + "for descriptors that is too small!"); + err_status =3D VIRTIO_BLK_S_ZONE_INVALID_CMD; + } + } + +out: + aio_context_acquire(blk_get_aio_context(s->conf.conf.blk)); + virtio_blk_req_complete(req, err_status); + virtio_blk_free_request(req); + aio_context_release(blk_get_aio_context(s->conf.conf.blk)); + g_free(data->zone_report_data.zones); + g_free(data); +} + +static int virtio_blk_handle_zone_report(VirtIOBlockReq *req, + struct iovec *in_iov, + unsigned in_num) +{ + VirtIOBlock *s =3D req->dev; + VirtIODevice *vdev =3D VIRTIO_DEVICE(s); + unsigned int nr_zones; + ZoneCmdData *data; + int64_t zone_size, offset; + uint8_t err_status; + + if (req->in_len < sizeof(struct virtio_blk_inhdr) + + sizeof(struct virtio_blk_zone_report) + + sizeof(struct virtio_blk_zone_descriptor)) { + virtio_error(vdev, "in buffer too small for zone report"); + return -1; + } + + /* start byte offset of the zone report */ + offset =3D virtio_ldq_p(vdev, &req->out.sector) << BDRV_SECTOR_BITS; + if (!check_zoned_request(s, offset, 0, false, &err_status)) { + goto out; + } + nr_zones =3D (req->in_len - sizeof(struct virtio_blk_inhdr) - + sizeof(struct virtio_blk_zone_report)) / + sizeof(struct virtio_blk_zone_descriptor); + + zone_size =3D sizeof(BlockZoneDescriptor) * nr_zones; + data =3D g_malloc(sizeof(ZoneCmdData)); + data->req =3D req; + data->in_iov =3D in_iov; + data->in_num =3D in_num; + data->zone_report_data.nr_zones =3D nr_zones; + data->zone_report_data.zones =3D g_malloc(zone_size), + + blk_aio_zone_report(s->blk, offset, &data->zone_report_data.nr_zones, + data->zone_report_data.zones, + virtio_blk_zone_report_complete, data); + return 0; + +out: + aio_context_acquire(blk_get_aio_context(s->conf.conf.blk)); + virtio_blk_req_complete(req, err_status); + virtio_blk_free_request(req); + aio_context_release(blk_get_aio_context(s->conf.conf.blk)); + return err_status; +} + +static void virtio_blk_zone_mgmt_complete(void *opaque, int ret) +{ + VirtIOBlockReq *req =3D opaque; + VirtIOBlock *s =3D req->dev; + int8_t err_status =3D VIRTIO_BLK_S_OK; + + if (ret) { + err_status =3D VIRTIO_BLK_S_ZONE_INVALID_CMD; + } + + aio_context_acquire(blk_get_aio_context(s->conf.conf.blk)); + virtio_blk_req_complete(req, err_status); + virtio_blk_free_request(req); + aio_context_release(blk_get_aio_context(s->conf.conf.blk)); +} + +static int virtio_blk_handle_zone_mgmt(VirtIOBlockReq *req, BlockZoneOp op) +{ + VirtIOBlock *s =3D req->dev; + VirtIODevice *vdev =3D VIRTIO_DEVICE(s); + BlockDriverState *bs =3D blk_bs(s->blk); + int64_t offset =3D virtio_ldq_p(vdev, &req->out.sector) << BDRV_SECTOR= _BITS; + uint64_t len; + uint64_t capacity =3D bs->total_sectors << BDRV_SECTOR_BITS; + uint8_t err_status =3D VIRTIO_BLK_S_OK; + + uint32_t type =3D virtio_ldl_p(vdev, &req->out.type); + if (type =3D=3D VIRTIO_BLK_T_ZONE_RESET_ALL) { + /* Entire drive capacity */ + offset =3D 0; + len =3D capacity; + } else { + if (bs->bl.zone_size > capacity - offset) { + /* The zoned device allows the last smaller zone. */ + len =3D capacity - bs->bl.zone_size * (bs->bl.nr_zones - 1); + } else { + len =3D bs->bl.zone_size; + } + } + + if (!check_zoned_request(s, offset, len, false, &err_status)) { + goto out; + } + + blk_aio_zone_mgmt(s->blk, op, offset, len, + virtio_blk_zone_mgmt_complete, req); + + return 0; +out: + aio_context_acquire(blk_get_aio_context(s->conf.conf.blk)); + virtio_blk_req_complete(req, err_status); + virtio_blk_free_request(req); + aio_context_release(blk_get_aio_context(s->conf.conf.blk)); + return err_status; +} + +static void virtio_blk_zone_append_complete(void *opaque, int ret) +{ + ZoneCmdData *data =3D opaque; + VirtIOBlockReq *req =3D data->req; + VirtIOBlock *s =3D req->dev; + VirtIODevice *vdev =3D VIRTIO_DEVICE(req->dev); + int64_t append_sector, n; + uint8_t err_status =3D VIRTIO_BLK_S_OK; + + if (ret) { + err_status =3D VIRTIO_BLK_S_ZONE_INVALID_CMD; + goto out; + } + + virtio_stq_p(vdev, &append_sector, + data->zone_append_data.offset >> BDRV_SECTOR_BITS); + n =3D iov_from_buf(data->in_iov, data->in_num, 0, &append_sector, + sizeof(append_sector)); + if (n !=3D sizeof(append_sector)) { + virtio_error(vdev, "Driver provided input buffer less than size of= " + "append_sector"); + err_status =3D VIRTIO_BLK_S_ZONE_INVALID_CMD; + goto out; + } + +out: + aio_context_acquire(blk_get_aio_context(s->conf.conf.blk)); + virtio_blk_req_complete(req, err_status); + virtio_blk_free_request(req); + aio_context_release(blk_get_aio_context(s->conf.conf.blk)); + g_free(data); +} + +static int virtio_blk_handle_zone_append(VirtIOBlockReq *req, + struct iovec *out_iov, + struct iovec *in_iov, + uint64_t out_num, + unsigned in_num) { + VirtIOBlock *s =3D req->dev; + VirtIODevice *vdev =3D VIRTIO_DEVICE(s); + uint8_t err_status =3D VIRTIO_BLK_S_OK; + + int64_t offset =3D virtio_ldq_p(vdev, &req->out.sector) << BDRV_SECTOR= _BITS; + int64_t len =3D iov_size(out_iov, out_num); + + if (!check_zoned_request(s, offset, len, true, &err_status)) { + goto out; + } + + ZoneCmdData *data =3D g_malloc(sizeof(ZoneCmdData)); + data->req =3D req; + data->in_iov =3D in_iov; + data->in_num =3D in_num; + data->zone_append_data.offset =3D offset; + qemu_iovec_init_external(&req->qiov, out_iov, out_num); + blk_aio_zone_append(s->blk, &data->zone_append_data.offset, &req->qiov= , 0, + virtio_blk_zone_append_complete, data); + return 0; + +out: + aio_context_acquire(blk_get_aio_context(s->conf.conf.blk)); + virtio_blk_req_complete(req, err_status); + virtio_blk_free_request(req); + aio_context_release(blk_get_aio_context(s->conf.conf.blk)); + return err_status; +} + static int virtio_blk_handle_request(VirtIOBlockReq *req, MultiReqBuffer *= mrb) { uint32_t type; @@ -687,6 +1023,24 @@ static int virtio_blk_handle_request(VirtIOBlockReq *= req, MultiReqBuffer *mrb) case VIRTIO_BLK_T_FLUSH: virtio_blk_handle_flush(req, mrb); break; + case VIRTIO_BLK_T_ZONE_REPORT: + virtio_blk_handle_zone_report(req, in_iov, in_num); + break; + case VIRTIO_BLK_T_ZONE_OPEN: + virtio_blk_handle_zone_mgmt(req, BLK_ZO_OPEN); + break; + case VIRTIO_BLK_T_ZONE_CLOSE: + virtio_blk_handle_zone_mgmt(req, BLK_ZO_CLOSE); + break; + case VIRTIO_BLK_T_ZONE_FINISH: + virtio_blk_handle_zone_mgmt(req, BLK_ZO_FINISH); + break; + case VIRTIO_BLK_T_ZONE_RESET: + virtio_blk_handle_zone_mgmt(req, BLK_ZO_RESET); + break; + case VIRTIO_BLK_T_ZONE_RESET_ALL: + virtio_blk_handle_zone_mgmt(req, BLK_ZO_RESET); + break; case VIRTIO_BLK_T_SCSI_CMD: virtio_blk_handle_scsi(req); break; @@ -705,6 +1059,13 @@ static int virtio_blk_handle_request(VirtIOBlockReq *= req, MultiReqBuffer *mrb) virtio_blk_free_request(req); break; } + case VIRTIO_BLK_T_ZONE_APPEND & ~VIRTIO_BLK_T_OUT: + /* + * It is not safe to access req->elem.out_sg directly because it + * may be modified by virtio_blk_handle_request(). + */ + virtio_blk_handle_zone_append(req, out_iov, in_iov, out_num, in_nu= m); + break; /* * VIRTIO_BLK_T_DISCARD and VIRTIO_BLK_T_WRITE_ZEROES are defined with * VIRTIO_BLK_T_OUT flag set. We masked this flag in the switch statem= ent, @@ -890,6 +1251,7 @@ static void virtio_blk_update_config(VirtIODevice *vde= v, uint8_t *config) { VirtIOBlock *s =3D VIRTIO_BLK(vdev); BlockConf *conf =3D &s->conf.conf; + BlockDriverState *bs =3D blk_bs(s->blk); struct virtio_blk_config blkcfg; uint64_t capacity; int64_t length; @@ -954,6 +1316,30 @@ static void virtio_blk_update_config(VirtIODevice *vd= ev, uint8_t *config) blkcfg.write_zeroes_may_unmap =3D 1; virtio_stl_p(vdev, &blkcfg.max_write_zeroes_seg, 1); } + if (bs->bl.zoned !=3D BLK_Z_NONE) { + switch (bs->bl.zoned) { + case BLK_Z_HM: + blkcfg.zoned.model =3D VIRTIO_BLK_Z_HM; + break; + case BLK_Z_HA: + blkcfg.zoned.model =3D VIRTIO_BLK_Z_HA; + break; + default: + g_assert_not_reached(); + } + + virtio_stl_p(vdev, &blkcfg.zoned.zone_sectors, + bs->bl.zone_size / 512); + virtio_stl_p(vdev, &blkcfg.zoned.max_active_zones, + bs->bl.max_active_zones); + virtio_stl_p(vdev, &blkcfg.zoned.max_open_zones, + bs->bl.max_open_zones); + virtio_stl_p(vdev, &blkcfg.zoned.write_granularity, blk_size); + virtio_stl_p(vdev, &blkcfg.zoned.max_append_sectors, + bs->bl.max_append_sectors); + } else { + blkcfg.zoned.model =3D VIRTIO_BLK_Z_NONE; + } memcpy(config, &blkcfg, s->config_size); } =20 @@ -1118,6 +1504,7 @@ static void virtio_blk_device_realize(DeviceState *de= v, Error **errp) VirtIODevice *vdev =3D VIRTIO_DEVICE(dev); VirtIOBlock *s =3D VIRTIO_BLK(dev); VirtIOBlkConf *conf =3D &s->conf; + BlockDriverState *bs =3D blk_bs(conf->conf.blk); Error *err =3D NULL; unsigned i; =20 @@ -1163,6 +1550,13 @@ static void virtio_blk_device_realize(DeviceState *d= ev, Error **errp) return; } =20 + if (bs->bl.zoned !=3D BLK_Z_NONE) { + virtio_add_feature(&s->host_features, VIRTIO_BLK_F_ZONED); + if (bs->bl.zoned =3D=3D BLK_Z_HM) { + virtio_clear_feature(&s->host_features, VIRTIO_BLK_F_DISCARD); + } + } + if (virtio_has_feature(s->host_features, VIRTIO_BLK_F_DISCARD) && (!conf->max_discard_sectors || conf->max_discard_sectors > BDRV_REQUEST_MAX_SECTORS)) { --=20 2.39.2 From nobody Mon May 20 02:18:01 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=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1678445782; cv=none; d=zohomail.com; s=zohoarc; b=CogDuHbd4I0rFUIbKbPZxrBJw7McOKJTv5FqXEZ4DBOTPZWXjX+LqkAOY76Zw1dCwJ5/LPmX+AcTwWUfztLCq7d7o94gy8tVxEabEVOKgfrQYeL7LclKJUpyIiBCpwMj8jGiVUiMYG2WwVANLRujNIxF6nbvxng021lQwqsJaeY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1678445782; 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=6BH9gazG5ST0rT/bBGEWqKqD3sJTxPI5IC5xmQmc7Vw=; b=QT8r51VRe8U1/c5ybKWwKULdOHYkFL16i0bi5rew0L9pPfVRlcByhsYVH3xLVNXeJkpfWqDnHa4guy4EMbqAb5jOpqFHPZ6NUv1RePHMnpOqi/JTJLojM4JL8A/euRkX98La2/2VgLWzFfVXCom5Y7J1eN+3kXWBFG9IJ+rldf0= 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 1678445782206716.3599861398775; Fri, 10 Mar 2023 02:56:22 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1paaOu-0001mt-Vy; Fri, 10 Mar 2023 05:55:05 -0500 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 1paaOt-0001mZ-84; Fri, 10 Mar 2023 05:55:03 -0500 Received: from mail-pl1-x635.google.com ([2607:f8b0:4864:20::635]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1paaOo-0001JD-TN; Fri, 10 Mar 2023 05:55:02 -0500 Received: by mail-pl1-x635.google.com with SMTP id y11so5156537plg.1; Fri, 10 Mar 2023 02:54:55 -0800 (PST) Received: from fedlinux.. ([106.84.129.9]) by smtp.gmail.com with ESMTPSA id j9-20020a654309000000b00502e6bfedc0sm1081397pgq.0.2023.03.10.02.54.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 10 Mar 2023 02:54:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1678445694; 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=6BH9gazG5ST0rT/bBGEWqKqD3sJTxPI5IC5xmQmc7Vw=; b=pGPbLSbyAo12xivPuzUPNit1WI/iT3/ailDzjvvJO1Sj3yLuI/ywicbtbAuCNZyYCe 2E3LQOMOMGNSHVT7ba1POueU1S5NBNx+HUeemYoSWMVoUJiuSRV7mJAEn1vqyQxnw5Cr Oi6hWklUHgfeb5aru3oNr3DlLnqYHui3nHG4WcUGmU8u0N5FGzHTMS//I64ZDUIQ11wZ Rm9tL02Yxr5x7jJ1tOagzHEFYpEYxFaaGhm/v/0AjjTFzDrEK2YvKJjH607jl8IF2+hr VqI+OvbkRfXBXa1XoSVhIcDgaeymhXeFbtJD6ww7czleMHTB4DUrIujjOvKf5PzZgQGe hhHA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678445694; 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=6BH9gazG5ST0rT/bBGEWqKqD3sJTxPI5IC5xmQmc7Vw=; b=K4in2XnWxwcHxRi0Ygf4C6rRPZ/sVDAmKiI6+rZJnYTr7gWOxShFwwopMd2Z3L8zQ+ Up9Rtcdonskk6RLzGLouDpC52Art3rldIYRoqXPa9TN7dhuEh4c4A6oI0D0BeOt2E575 NU7E5u5ll4xOIkbMGD5jvM9Wl9JWuF1i7wevJ9TKfRHAXkjIyx0EqZZbqTTpk7AM2Se/ LXZl5qqc6CU/QfPJMhWS7fJg9DWxIrIicTVLTowAWfOaWrpedPP0KZvmdytX6h0MIlWE sBjG+Kis43/68XS+mTzTE6qOfxsov1V6zM4axjwoePyXV51zX9IhOEIhqqIl/Kjouqgy 7f1Q== X-Gm-Message-State: AO0yUKVrgUEltCTTXDBKNbj3XsYq4ztALcxQXXgDf4SWOvyl1GxU7n77 2wdTdlqd7PEyOX/qpzOmmFJCeGxLzEO6OkMz40w= X-Google-Smtp-Source: AK7set8muyyRufk43pYeZFkb11utgoqhX2c8iMM/rN3g16A+h03iNpgbmgd/gweaxlyJfkRJHHXCNQ== X-Received: by 2002:a17:90a:1a03:b0:236:a1f9:9a8a with SMTP id 3-20020a17090a1a0300b00236a1f99a8amr1543523pjk.8.1678445693896; Fri, 10 Mar 2023 02:54:53 -0800 (PST) From: Sam Li To: qemu-devel@nongnu.org Cc: stefanha@redhat.com, damien.lemoal@opensource.wdc.com, Hanna Reitz , hare@suse.de, qemu-block@nongnu.org, Eric Blake , Paolo Bonzini , dmitry.fomichev@wdc.com, Cornelia Huck , Markus Armbruster , kvm@vger.kernel.org, "Michael S. Tsirkin" , Kevin Wolf , Raphael Norwitz , Sam Li Subject: [PATCH v7 3/4] block: add accounting for zone append operation Date: Fri, 10 Mar 2023 18:54:30 +0800 Message-Id: <20230310105431.64271-4-faithilikerun@gmail.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230310105431.64271-1-faithilikerun@gmail.com> References: <20230310105431.64271-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::635; envelope-from=faithilikerun@gmail.com; helo=mail-pl1-x635.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: 1678445783270100001 Content-Type: text/plain; charset="utf-8" Taking account of the new zone append write operation for zoned devices, BLOCK_ACCT_APPEND enum is introduced as other I/O request type (read, write, flush). Signed-off-by: Sam Li --- block/qapi-sysemu.c | 11 ++++++++ block/qapi.c | 15 ++++++++++ hw/block/virtio-blk.c | 4 +++ include/block/accounting.h | 1 + qapi/block-core.json | 56 ++++++++++++++++++++++++++++++-------- qapi/block.json | 4 +++ 6 files changed, 80 insertions(+), 11 deletions(-) diff --git a/block/qapi-sysemu.c b/block/qapi-sysemu.c index 7bd7554150..f7e56dfeb2 100644 --- a/block/qapi-sysemu.c +++ b/block/qapi-sysemu.c @@ -517,6 +517,7 @@ void qmp_block_latency_histogram_set( bool has_boundaries, uint64List *boundaries, bool has_boundaries_read, uint64List *boundaries_read, bool has_boundaries_write, uint64List *boundaries_write, + bool has_boundaries_append, uint64List *boundaries_append, bool has_boundaries_flush, uint64List *boundaries_flush, Error **errp) { @@ -557,6 +558,16 @@ void qmp_block_latency_histogram_set( } } =20 + if (has_boundaries || has_boundaries_append) { + ret =3D block_latency_histogram_set( + stats, BLOCK_ACCT_APPEND, + has_boundaries_append ? boundaries_append : boundaries); + if (ret) { + error_setg(errp, "Device '%s' set append write boundaries fail= ", id); + return; + } + } + if (has_boundaries || has_boundaries_flush) { ret =3D block_latency_histogram_set( stats, BLOCK_ACCT_FLUSH, diff --git a/block/qapi.c b/block/qapi.c index c84147849d..d4be8ad72e 100644 --- a/block/qapi.c +++ b/block/qapi.c @@ -533,27 +533,33 @@ static void bdrv_query_blk_stats(BlockDeviceStats *ds= , BlockBackend *blk) =20 ds->rd_bytes =3D stats->nr_bytes[BLOCK_ACCT_READ]; ds->wr_bytes =3D stats->nr_bytes[BLOCK_ACCT_WRITE]; + ds->zap_bytes =3D stats->nr_bytes[BLOCK_ACCT_APPEND]; ds->unmap_bytes =3D stats->nr_bytes[BLOCK_ACCT_UNMAP]; ds->rd_operations =3D stats->nr_ops[BLOCK_ACCT_READ]; ds->wr_operations =3D stats->nr_ops[BLOCK_ACCT_WRITE]; + ds->zap_operations =3D stats->nr_ops[BLOCK_ACCT_APPEND]; ds->unmap_operations =3D stats->nr_ops[BLOCK_ACCT_UNMAP]; =20 ds->failed_rd_operations =3D stats->failed_ops[BLOCK_ACCT_READ]; ds->failed_wr_operations =3D stats->failed_ops[BLOCK_ACCT_WRITE]; + ds->failed_zap_operations =3D stats->failed_ops[BLOCK_ACCT_APPEND]; ds->failed_flush_operations =3D stats->failed_ops[BLOCK_ACCT_FLUSH]; ds->failed_unmap_operations =3D stats->failed_ops[BLOCK_ACCT_UNMAP]; =20 ds->invalid_rd_operations =3D stats->invalid_ops[BLOCK_ACCT_READ]; ds->invalid_wr_operations =3D stats->invalid_ops[BLOCK_ACCT_WRITE]; + ds->invalid_zap_operations =3D stats->invalid_ops[BLOCK_ACCT_APPEND]; ds->invalid_flush_operations =3D stats->invalid_ops[BLOCK_ACCT_FLUSH]; ds->invalid_unmap_operations =3D stats->invalid_ops[BLOCK_ACCT_UNMAP]; =20 ds->rd_merged =3D stats->merged[BLOCK_ACCT_READ]; ds->wr_merged =3D stats->merged[BLOCK_ACCT_WRITE]; + ds->zap_merged =3D stats->merged[BLOCK_ACCT_APPEND]; ds->unmap_merged =3D stats->merged[BLOCK_ACCT_UNMAP]; ds->flush_operations =3D stats->nr_ops[BLOCK_ACCT_FLUSH]; ds->wr_total_time_ns =3D stats->total_time_ns[BLOCK_ACCT_WRITE]; + ds->zap_total_time_ns =3D stats->total_time_ns[BLOCK_ACCT_APPEND]; ds->rd_total_time_ns =3D stats->total_time_ns[BLOCK_ACCT_READ]; ds->flush_total_time_ns =3D stats->total_time_ns[BLOCK_ACCT_FLUSH]; ds->unmap_total_time_ns =3D stats->total_time_ns[BLOCK_ACCT_UNMAP]; @@ -571,6 +577,7 @@ static void bdrv_query_blk_stats(BlockDeviceStats *ds, = BlockBackend *blk) =20 TimedAverage *rd =3D &ts->latency[BLOCK_ACCT_READ]; TimedAverage *wr =3D &ts->latency[BLOCK_ACCT_WRITE]; + TimedAverage *zap =3D &ts->latency[BLOCK_ACCT_APPEND]; TimedAverage *fl =3D &ts->latency[BLOCK_ACCT_FLUSH]; =20 dev_stats->interval_length =3D ts->interval_length; @@ -583,6 +590,10 @@ static void bdrv_query_blk_stats(BlockDeviceStats *ds,= BlockBackend *blk) dev_stats->max_wr_latency_ns =3D timed_average_max(wr); dev_stats->avg_wr_latency_ns =3D timed_average_avg(wr); =20 + dev_stats->min_zap_latency_ns =3D timed_average_min(zap); + dev_stats->max_zap_latency_ns =3D timed_average_max(zap); + dev_stats->avg_zap_latency_ns =3D timed_average_avg(zap); + dev_stats->min_flush_latency_ns =3D timed_average_min(fl); dev_stats->max_flush_latency_ns =3D timed_average_max(fl); dev_stats->avg_flush_latency_ns =3D timed_average_avg(fl); @@ -591,6 +602,8 @@ static void bdrv_query_blk_stats(BlockDeviceStats *ds, = BlockBackend *blk) block_acct_queue_depth(ts, BLOCK_ACCT_READ); dev_stats->avg_wr_queue_depth =3D block_acct_queue_depth(ts, BLOCK_ACCT_WRITE); + dev_stats->avg_zap_queue_depth =3D + block_acct_queue_depth(ts, BLOCK_ACCT_APPEND); =20 QAPI_LIST_PREPEND(ds->timed_stats, dev_stats); } @@ -600,6 +613,8 @@ static void bdrv_query_blk_stats(BlockDeviceStats *ds, = BlockBackend *blk) =3D bdrv_latency_histogram_stats(&hgram[BLOCK_ACCT_READ]); ds->wr_latency_histogram =3D bdrv_latency_histogram_stats(&hgram[BLOCK_ACCT_WRITE]); + ds->zap_latency_histogram + =3D bdrv_latency_histogram_stats(&hgram[BLOCK_ACCT_APPEND]); ds->flush_latency_histogram =3D bdrv_latency_histogram_stats(&hgram[BLOCK_ACCT_FLUSH]); } diff --git a/hw/block/virtio-blk.c b/hw/block/virtio-blk.c index 4ded625732..7605ca4f03 100644 --- a/hw/block/virtio-blk.c +++ b/hw/block/virtio-blk.c @@ -925,6 +925,10 @@ static int virtio_blk_handle_zone_append(VirtIOBlockRe= q *req, data->in_num =3D in_num; data->zone_append_data.offset =3D offset; qemu_iovec_init_external(&req->qiov, out_iov, out_num); + + block_acct_start(blk_get_stats(s->blk), &req->acct, len, + BLOCK_ACCT_APPEND); + blk_aio_zone_append(s->blk, &data->zone_append_data.offset, &req->qiov= , 0, virtio_blk_zone_append_complete, data); return 0; diff --git a/include/block/accounting.h b/include/block/accounting.h index b9caad60d5..61cc868666 100644 --- a/include/block/accounting.h +++ b/include/block/accounting.h @@ -37,6 +37,7 @@ enum BlockAcctType { BLOCK_ACCT_READ, BLOCK_ACCT_WRITE, BLOCK_ACCT_FLUSH, + BLOCK_ACCT_APPEND, BLOCK_ACCT_UNMAP, BLOCK_MAX_IOTYPE, }; diff --git a/qapi/block-core.json b/qapi/block-core.json index c05ad0c07e..76fe9c2fca 100644 --- a/qapi/block-core.json +++ b/qapi/block-core.json @@ -849,6 +849,9 @@ # @min_wr_latency_ns: Minimum latency of write operations in the # defined interval, in nanoseconds. # +# @min_zap_latency_ns: Minimum latency of zone append operations in the +# defined interval, in nanoseconds. +# # @min_flush_latency_ns: Minimum latency of flush operations in the # defined interval, in nanoseconds. # @@ -858,6 +861,9 @@ # @max_wr_latency_ns: Maximum latency of write operations in the # defined interval, in nanoseconds. # +# @max_zap_latency_ns: Maximum latency of zone append operations in the +# defined interval, in nanoseconds. +# # @max_flush_latency_ns: Maximum latency of flush operations in the # defined interval, in nanoseconds. # @@ -867,6 +873,9 @@ # @avg_wr_latency_ns: Average latency of write operations in the # defined interval, in nanoseconds. # +# @avg_zap_latency_ns: Average latency of zone append operations in the +# defined interval, in nanoseconds. +# # @avg_flush_latency_ns: Average latency of flush operations in the # defined interval, in nanoseconds. # @@ -876,15 +885,20 @@ # @avg_wr_queue_depth: Average number of pending write operations # in the defined interval. # +# @avg_zap_queue_depth: Average number of pending zone append operations +# in the defined interval. +# # Since: 2.5 ## { 'struct': 'BlockDeviceTimedStats', 'data': { 'interval_length': 'int', 'min_rd_latency_ns': 'int', 'max_rd_latency_ns': 'int', 'avg_rd_latency_ns': 'int', 'min_wr_latency_ns': 'int', 'max_wr_latency_ns': 'int', - 'avg_wr_latency_ns': 'int', 'min_flush_latency_ns': 'int', - 'max_flush_latency_ns': 'int', 'avg_flush_latency_ns': 'int', - 'avg_rd_queue_depth': 'number', 'avg_wr_queue_depth': 'number'= } } + 'avg_wr_latency_ns': 'int', 'min_zap_latency_ns': 'int', + 'max_zap_latency_ns': 'int', 'avg_zap_latency_ns': 'int', + 'min_flush_latency_ns': 'int', 'max_flush_latency_ns': 'int', + 'avg_flush_latency_ns': 'int', 'avg_rd_queue_depth': 'number', + 'avg_wr_queue_depth': 'number', 'avg_zap_queue_depth': 'number= ' } } =20 ## # @BlockDeviceStats: @@ -895,12 +909,16 @@ # # @wr_bytes: The number of bytes written by the device. # +# @zap_bytes: The number of bytes appended by the zoned devices. +# # @unmap_bytes: The number of bytes unmapped by the device (Since 4.2) # # @rd_operations: The number of read operations performed by the device. # # @wr_operations: The number of write operations performed by the device. # +# @zap_operations: The number of zone append operations performed by the z= oned devices. +# # @flush_operations: The number of cache flush operations performed by the # device (since 0.15) # @@ -911,6 +929,8 @@ # # @wr_total_time_ns: Total time spent on writes in nanoseconds (since 0.15= ). # +# @zap_total_time_ns: Total time spent on zone append writes in nanosecond= s. +# # @flush_total_time_ns: Total time spent on cache flushes in nanoseconds # (since 0.15). # @@ -928,6 +948,9 @@ # @wr_merged: Number of write requests that have been merged into another # request (Since 2.3). # +# @zap_merged: Number of zone append requests that have been merged into +# another request. +# # @unmap_merged: Number of unmap requests that have been merged into anoth= er # request (Since 4.2) # @@ -941,6 +964,9 @@ # @failed_wr_operations: The number of failed write operations # performed by the device (Since 2.5) # +# @failed_zap_operations: The number of failed zone append write +# operations performed by the zoned devices +# # @failed_flush_operations: The number of failed flush operations # performed by the device (Since 2.5) # @@ -953,6 +979,9 @@ # @invalid_wr_operations: The number of invalid write operations # performed by the device (Since 2.5) # +# @invalid_zap_operations: The number of invalid zone append operations +# performed by the zoned device +# # @invalid_flush_operations: The number of invalid flush operations # performed by the device (Since 2.5) # @@ -972,27 +1001,32 @@ # # @wr_latency_histogram: @BlockLatencyHistogramInfo. (Since 4.0) # +# @zap_latency_histogram: @BlockLatencyHistogramInfo. +# # @flush_latency_histogram: @BlockLatencyHistogramInfo. (Since 4.0) # # Since: 0.14 ## { 'struct': 'BlockDeviceStats', - 'data': {'rd_bytes': 'int', 'wr_bytes': 'int', 'unmap_bytes' : 'int', - 'rd_operations': 'int', 'wr_operations': 'int', + 'data': {'rd_bytes': 'int', 'wr_bytes': 'int', 'zap_bytes': 'int', + 'unmap_bytes' : 'int', 'rd_operations': 'int', + 'wr_operations': 'int', 'zap_operations': 'int', 'flush_operations': 'int', 'unmap_operations': 'int', 'rd_total_time_ns': 'int', 'wr_total_time_ns': 'int', - 'flush_total_time_ns': 'int', 'unmap_total_time_ns': 'int', - 'wr_highest_offset': 'int', - 'rd_merged': 'int', 'wr_merged': 'int', 'unmap_merged': 'int', - '*idle_time_ns': 'int', + 'zap_total_time_ns': 'int', 'flush_total_time_ns': 'int', + 'unmap_total_time_ns': 'int', 'wr_highest_offset': 'int', + 'rd_merged': 'int', 'wr_merged': 'int', 'zap_merged': 'int', + 'unmap_merged': 'int', '*idle_time_ns': 'int', 'failed_rd_operations': 'int', 'failed_wr_operations': 'int', - 'failed_flush_operations': 'int', 'failed_unmap_operations': 'i= nt', - 'invalid_rd_operations': 'int', 'invalid_wr_operations': 'int', + 'failed_zap_operations': 'int', 'failed_flush_operations': 'int= ', + 'failed_unmap_operations': 'int', 'invalid_rd_operations': 'int= ', + 'invalid_wr_operations': 'int', 'invalid_zap_operations': 'int', 'invalid_flush_operations': 'int', 'invalid_unmap_operations': = 'int', 'account_invalid': 'bool', 'account_failed': 'bool', 'timed_stats': ['BlockDeviceTimedStats'], '*rd_latency_histogram': 'BlockLatencyHistogramInfo', '*wr_latency_histogram': 'BlockLatencyHistogramInfo', + '*zap_latency_histogram': 'BlockLatencyHistogramInfo', '*flush_latency_histogram': 'BlockLatencyHistogramInfo' } } =20 ## diff --git a/qapi/block.json b/qapi/block.json index 5fe068f903..5a57ef4a9f 100644 --- a/qapi/block.json +++ b/qapi/block.json @@ -525,6 +525,9 @@ # @boundaries-write: list of interval boundary values for write latency # histogram. # +# @boundaries-zap: list of interval boundary values for zone append write +# latency histogram. +# # @boundaries-flush: list of interval boundary values for flush latency # histogram. # @@ -573,5 +576,6 @@ '*boundaries': ['uint64'], '*boundaries-read': ['uint64'], '*boundaries-write': ['uint64'], + '*boundaries-zap': ['uint64'], '*boundaries-flush': ['uint64'] }, 'allow-preconfig': true } --=20 2.39.2 From nobody Mon May 20 02:18:01 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=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1678445731; cv=none; d=zohomail.com; s=zohoarc; b=FmUXUkCoCI5CAMSnGQYBtNOZBRxfX0m6dlMouK6zGmh9vbBo1lNx+2QwyVz90bGJ57yQMYa0bNVrstrQHqgqRyKA2WlybtMZA5+C+EF8zKCQwJcDLvwiiXmbZZGd7s2Fhw35fgubXsUjD1QuhXDZM0Rr0CIre83HTWCb/KZ7BGY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1678445731; 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=Gvouo1mnqHL9qVfKSL/y8gLXUs6CkWkQQv524tgmQvQ=; b=MvGrVPzV6jzNm8Fp6KXW2EECMEslqAZ8OG5SYWsZPPPD6VTjoEkt3NBnX2EVmGUNEUWuZrcn+sZ/+e2u/tBfXsTU0UYncBY+hN8p+iiJaoZtcZiQ01h6bywR2vCvMfkwIj4ilKO8g9pyhUefSpXd7Wz/pdG+BuwWVVVjaCVunXQ= 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 1678445731122333.69879140341936; Fri, 10 Mar 2023 02:55:31 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1paaPB-0001oP-Pp; Fri, 10 Mar 2023 05:55:23 -0500 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 1paaOu-0001my-Ui; Fri, 10 Mar 2023 05:55:05 -0500 Received: from mail-pj1-x102a.google.com ([2607:f8b0:4864:20::102a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1paaOs-0001LG-Qq; Fri, 10 Mar 2023 05:55:04 -0500 Received: by mail-pj1-x102a.google.com with SMTP id y15-20020a17090aa40f00b00237ad8ee3a0so4819201pjp.2; Fri, 10 Mar 2023 02:55:00 -0800 (PST) Received: from fedlinux.. ([106.84.129.9]) by smtp.gmail.com with ESMTPSA id j9-20020a654309000000b00502e6bfedc0sm1081397pgq.0.2023.03.10.02.54.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 10 Mar 2023 02:54:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1678445699; 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=Gvouo1mnqHL9qVfKSL/y8gLXUs6CkWkQQv524tgmQvQ=; b=SI2NKHWCeduergFryiNV0Ya5qb6WuAlHZHSq+kYNxYHygy01jtYNBIpwTJlhvwA1ou BmyoZnWjItG3weJqeUz3ymJI3aPzRLVNKvpulq+7JYSMbMfkhj+VOgQEn495TYLdPi9p IShGisn2XJzrid8xQJyMSO9RM8d9WKIGdBdLMf93yLJOYK+F1aZnelb+auPvnrFqisaL +FtJXi2EB9FIrmWT7UkKych93qAbaa29L1U6nq8zw4OTnuvtQ7rbuLI3OklIdx9d+Pnx TOO54qRl+vupzOlHbbLr2EVcJPABeIK15fS+8WNtrIzokdCQrjNAvdQmFjOEIt4SZuq6 KyqQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678445699; 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=Gvouo1mnqHL9qVfKSL/y8gLXUs6CkWkQQv524tgmQvQ=; b=FO94tZ5YCWyPFYH5O8L98gGvhwiS3EYrL4POMsbtK81LKSqzN5Wodb/hqCyuIweCm/ Ns3O7t3S4W8fZkWxgBH3USQ4yv1aZLVfM3jp8DjUwTl8SKm3x71rfWpxXvxOJbOtB6ZM k2ZMLhqPfr3qnjVzquSFdlZq6QIrexe8HkpeV1snFvRCDyEGNXSzTU6FEQafNpMNprJg beUTXCbWC+6LcSyP1nOsBEwO0kNgKqhX715SXr7YKozptv5zCUJaMUake7+4cl1X8C0U Her7hE+y7vevJLpFYgSYeISdVP5ur7R2RLRlmgW53/JyR9wEllSqV7TLK+8Isf/Q7RUJ lD8w== X-Gm-Message-State: AO0yUKXVx0VCd45iwFi+54bg1xMq/++5zWkgq5hTUswoSkkX9GLirst2 qV93Nt57ilnP3967Oagn0QwJ+GWxA/MPTVhbsqg= X-Google-Smtp-Source: AK7set/HvpUfddg0YQ6QfBOggxb5I2H3aqx74KX+cZI2FFSaqaE04Af2RDnAliyDp+jVRfERCsD++g== X-Received: by 2002:a17:902:c103:b0:19e:7611:7162 with SMTP id 3-20020a170902c10300b0019e76117162mr21992880pli.16.1678445698852; Fri, 10 Mar 2023 02:54:58 -0800 (PST) From: Sam Li To: qemu-devel@nongnu.org Cc: stefanha@redhat.com, damien.lemoal@opensource.wdc.com, Hanna Reitz , hare@suse.de, qemu-block@nongnu.org, Eric Blake , Paolo Bonzini , dmitry.fomichev@wdc.com, Cornelia Huck , Markus Armbruster , kvm@vger.kernel.org, "Michael S. Tsirkin" , Kevin Wolf , Raphael Norwitz , Sam Li Subject: [PATCH v7 4/4] virtio-blk: add some trace events for zoned emulation Date: Fri, 10 Mar 2023 18:54:31 +0800 Message-Id: <20230310105431.64271-5-faithilikerun@gmail.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230310105431.64271-1-faithilikerun@gmail.com> References: <20230310105431.64271-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::102a; envelope-from=faithilikerun@gmail.com; helo=mail-pj1-x102a.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: 1678445733190100003 Content-Type: text/plain; charset="utf-8" Signed-off-by: Sam Li Reviewed-by: Stefan Hajnoczi --- hw/block/trace-events | 7 +++++++ hw/block/virtio-blk.c | 12 ++++++++++++ 2 files changed, 19 insertions(+) diff --git a/hw/block/trace-events b/hw/block/trace-events index 2c45a62bd5..34be8b9135 100644 --- a/hw/block/trace-events +++ b/hw/block/trace-events @@ -44,9 +44,16 @@ pflash_write_unknown(const char *name, uint8_t cmd) "%s:= unknown command 0x%02x" # virtio-blk.c virtio_blk_req_complete(void *vdev, void *req, int status) "vdev %p req %p= status %d" virtio_blk_rw_complete(void *vdev, void *req, int ret) "vdev %p req %p ret= %d" +virtio_blk_zone_report_complete(void *vdev, void *req, unsigned int nr_zon= es, int ret) "vdev %p req %p nr_zones %u ret %d" +virtio_blk_zone_mgmt_complete(void *vdev, void *req, int ret) "vdev %p req= %p ret %d" +virtio_blk_zone_append_complete(void *vdev, void *req, int64_t sector, int= ret) "vdev %p req %p, append sector 0x%" PRIx64 " ret %d" virtio_blk_handle_write(void *vdev, void *req, uint64_t sector, size_t nse= ctors) "vdev %p req %p sector %"PRIu64" nsectors %zu" virtio_blk_handle_read(void *vdev, void *req, uint64_t sector, size_t nsec= tors) "vdev %p req %p sector %"PRIu64" nsectors %zu" virtio_blk_submit_multireq(void *vdev, void *mrb, int start, int num_reqs,= uint64_t offset, size_t size, bool is_write) "vdev %p mrb %p start %d num_= reqs %d offset %"PRIu64" size %zu is_write %d" +virtio_blk_handle_zone_report(void *vdev, void *req, int64_t sector, unsig= ned int nr_zones) "vdev %p req %p sector 0x%" PRIx64 " nr_zones %u" +virtio_blk_handle_zone_mgmt(void *vdev, void *req, uint8_t op, int64_t sec= tor, int64_t len) "vdev %p req %p op 0x%x sector 0x%" PRIx64 " len 0x%" PRI= x64 "" +virtio_blk_handle_zone_reset_all(void *vdev, void *req, int64_t sector, in= t64_t len) "vdev %p req %p sector 0x%" PRIx64 " cap 0x%" PRIx64 "" +virtio_blk_handle_zone_append(void *vdev, void *req, int64_t sector) "vdev= %p req %p, append sector 0x%" PRIx64 "" =20 # hd-geometry.c hd_geometry_lchs_guess(void *blk, int cyls, int heads, int secs) "blk %p L= CHS %d %d %d" diff --git a/hw/block/virtio-blk.c b/hw/block/virtio-blk.c index 7605ca4f03..7ad45fda03 100644 --- a/hw/block/virtio-blk.c +++ b/hw/block/virtio-blk.c @@ -676,6 +676,7 @@ static void virtio_blk_zone_report_complete(void *opaqu= e, int ret) int64_t nz =3D data->zone_report_data.nr_zones; int8_t err_status =3D VIRTIO_BLK_S_OK; =20 + trace_virtio_blk_zone_report_complete(vdev, req, nz, ret); if (ret) { err_status =3D VIRTIO_BLK_S_ZONE_INVALID_CMD; goto out; @@ -792,6 +793,8 @@ static int virtio_blk_handle_zone_report(VirtIOBlockReq= *req, nr_zones =3D (req->in_len - sizeof(struct virtio_blk_inhdr) - sizeof(struct virtio_blk_zone_report)) / sizeof(struct virtio_blk_zone_descriptor); + trace_virtio_blk_handle_zone_report(vdev, req, + offset >> BDRV_SECTOR_BITS, nr_zon= es); =20 zone_size =3D sizeof(BlockZoneDescriptor) * nr_zones; data =3D g_malloc(sizeof(ZoneCmdData)); @@ -818,7 +821,9 @@ static void virtio_blk_zone_mgmt_complete(void *opaque,= int ret) { VirtIOBlockReq *req =3D opaque; VirtIOBlock *s =3D req->dev; + VirtIODevice *vdev =3D VIRTIO_DEVICE(s); int8_t err_status =3D VIRTIO_BLK_S_OK; + trace_virtio_blk_zone_mgmt_complete(vdev, req,ret); =20 if (ret) { err_status =3D VIRTIO_BLK_S_ZONE_INVALID_CMD; @@ -845,6 +850,8 @@ static int virtio_blk_handle_zone_mgmt(VirtIOBlockReq *= req, BlockZoneOp op) /* Entire drive capacity */ offset =3D 0; len =3D capacity; + trace_virtio_blk_handle_zone_reset_all(vdev, req, 0, + bs->total_sectors); } else { if (bs->bl.zone_size > capacity - offset) { /* The zoned device allows the last smaller zone. */ @@ -852,6 +859,9 @@ static int virtio_blk_handle_zone_mgmt(VirtIOBlockReq *= req, BlockZoneOp op) } else { len =3D bs->bl.zone_size; } + trace_virtio_blk_handle_zone_mgmt(vdev, req, op, + offset >> BDRV_SECTOR_BITS, + len >> BDRV_SECTOR_BITS); } =20 if (!check_zoned_request(s, offset, len, false, &err_status)) { @@ -894,6 +904,7 @@ static void virtio_blk_zone_append_complete(void *opaqu= e, int ret) err_status =3D VIRTIO_BLK_S_ZONE_INVALID_CMD; goto out; } + trace_virtio_blk_zone_append_complete(vdev, req, append_sector, ret); =20 out: aio_context_acquire(blk_get_aio_context(s->conf.conf.blk)); @@ -915,6 +926,7 @@ static int virtio_blk_handle_zone_append(VirtIOBlockReq= *req, int64_t offset =3D virtio_ldq_p(vdev, &req->out.sector) << BDRV_SECTOR= _BITS; int64_t len =3D iov_size(out_iov, out_num); =20 + trace_virtio_blk_handle_zone_append(vdev, req, offset >> BDRV_SECTOR_B= ITS); if (!check_zoned_request(s, offset, len, true, &err_status)) { goto out; } --=20 2.39.2