From patchwork Fri Aug 23 19:20:53 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Fomichev X-Patchwork-Id: 11112321 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 7329614DE for ; Fri, 23 Aug 2019 19:36:58 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 492EF21874 for ; Fri, 23 Aug 2019 19:36:58 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=wdc.com header.i=@wdc.com header.b="SyjKMzYF" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 492EF21874 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=wdc.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:33514 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i1FMn-00045C-Cc for patchwork-qemu-devel@patchwork.kernel.org; Fri, 23 Aug 2019 15:36:57 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:47675) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i1F7U-0005li-UB for qemu-devel@nongnu.org; Fri, 23 Aug 2019 15:21:10 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i1F7T-0003QB-Mx for qemu-devel@nongnu.org; Fri, 23 Aug 2019 15:21:08 -0400 Received: from esa5.hgst.iphmx.com ([216.71.153.144]:37516) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1i1F7P-0003Ie-5s; Fri, 23 Aug 2019 15:21:03 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1566588064; x=1598124064; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=wDuJg/PXjCdmnfQAHj6RMyp+qTSDniP3cOnxGOeYBNk=; b=SyjKMzYF40uicmoVIK1ZcRb26TbVy/jAr+3Wh5fKlLYZ1Il5zk0Ut3YS tLQvD9GQR2tIIncnb0d5w78/TnbidPV8pz85G1ZO/Atr2jMZU3AtA/w5Y dOxuReg/vKxh1BwUZHSiYBvzSlGgInoI9f+ro8xWEbN5iIuaEP7l40PKM mXeTGodgg/ewi1w7A1jdX6a3ZoBgwRC2ZdKihd6yVLnAJbQscvplkP5T0 GLZ8O7HNg/0IY2HP1cFKli1lXUC9mkEUAVCNwXuXzMUN0OjBG3nkbp72+ ZYx+AiCYtFk+5Wru1OhUiICuY8KX/JDVwTagh3u/3/09k8lg14bWZzbeG Q==; IronPort-SDR: /WUzUQYpkA6pld/+Q4MeyYBrUmf7N9ut5H5AM2e1be9BQ8RNxMmM0elJuvmK1pMschUnw4PpKW FRRfErF/GKhivesHWbwbFvuNOHM+CO1jcApmwEhwYoHiun/pcSKcXh2FVXuFUauAgYOfZDn8gC ORe+sznZuHcBQL9LtaJLOcOfEAYro8T36tpgLXNdQfOTGbNYQEVMuGTPxw6Tp8jYoQdTKpvzde X5PZDNSe0ug6gm70kS+o6SCYY1lGAc1471sOPeqZ9Rg/SRu2LTysPdV22uxhdnRKURdrUQkOgD ihM= X-IronPort-AV: E=Sophos;i="5.64,422,1559491200"; d="scan'208";a="117476226" Received: from h199-255-45-15.hgst.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 24 Aug 2019 03:20:58 +0800 IronPort-SDR: pPQMLKhr8bE1+eOC3uxIuhcUMHypN7DZv1Wk9qa4cHfc8hxlNa0hgbHq3oEawcbf6rthLqsDID Mat31aCuL0wvG24W4i8n+bRugBCOtj7TjveL7TwsfMB/f/u2CHaxbS9ICjjvUio3SMcsN5SpZy EEDnb1duFvNrKpKRq9tFQx17JHKXEF1uQbBAsY1DHR5z3A6B045KFguZTld/nrzE4SrrZyW1He qF4g8z/ruUC/RLyoVCmDreR2JHxLEcsYpEskCAcNdtUjMh1Mls4fVESlZvAv3hww50Z41GFjpe snODrE9nzYwPjQEicneoMUhS Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Aug 2019 12:18:15 -0700 IronPort-SDR: qZmXvRvPOqwLXGIJgyZsRvfnWKj0mgUAbvvzjjdtHQm1rmpdHPUhZwuaDe76JK0KAAKGfjS40m pXivsxxnexPuYMrc3HSr+QDt5AgfjByFbh6wvSyXbz3C15SBAjWM5EURfC4kesk4aFLTG7ZJGh nzP8JUiQ/DfdnPA/pXpDWOa062tATvF1WIeb28olvbQKAhxOpRCXWscHTT+bZ1Os+fS6oIa/UV dn9VlDJNH/denkOLV8RoAuP+5E6OHC5o3AcqOY7xTm5btvBCCC9y95dJhAGGkkf9b6GPQGbcwJ F0U= WDCIronportException: Internal Received: from dhcp-10-88-173-43.hgst.com ([10.88.173.43]) by uls-op-cesaip01.wdc.com with ESMTP; 23 Aug 2019 12:20:57 -0700 From: Dmitry Fomichev To: Paolo Bonzini , Kevin Wolf , Max Reitz , "Michael S . Tsirkin" , Stefan Hajnoczi , John Snow Date: Fri, 23 Aug 2019 15:20:53 -0400 Message-Id: <20190823192056.21091-1-dmitry.fomichev@wdc.com> X-Mailer: git-send-email 2.21.0 MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: FreeBSD 9.x X-Received-From: 216.71.153.144 Subject: [Qemu-devel] [PATCH v4 1/4] block: Add zoned device model property X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Dmitry Fomichev , Alistair Francis , qemu-devel@nongnu.org, qemu-block@nongnu.org Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" This commit adds Zoned Device Model (as defined in T10 ZBC and T13 ZAC standards) as a block driver property, along with some useful access functions. A new backend driver permission, BLK_PERM_SUPPORT_ZONED, is also introduced. Only the drivers having this permission will be allowed to open zoned block devices. No code is added yet to initialize or check the value of this new property, therefore this commit doesn't change any functionality. Signed-off-by: Dmitry Fomichev --- block.c | 19 +++++++++++++++++++ include/block/block.h | 21 ++++++++++++++++++++- include/block/block_int.h | 4 ++++ 3 files changed, 43 insertions(+), 1 deletion(-) diff --git a/block.c b/block.c index 874a29a983..6dd4cecded 100644 --- a/block.c +++ b/block.c @@ -4679,6 +4679,25 @@ void bdrv_get_geometry(BlockDriverState *bs, uint64_t *nb_sectors_ptr) *nb_sectors_ptr = nb_sectors < 0 ? 0 : nb_sectors; } +uint8_t bdrv_get_zoned_model(BlockDriverState *bs) +{ + if (bs->drv->bdrv_get_zoned_info) { + bs->drv->bdrv_get_zoned_info(bs); + } + + return bs->bl.zoned_model; +} + +uint8_t bdrv_is_zoned(BlockDriverState *bs) +{ + /* + * Host Aware zone devices are supposed to be able to work + * just like regular block devices. Thus, we only consider + * Host Managed devices to be zoned here. + */ + return bdrv_get_zoned_model(bs) == BLK_ZONED_MODEL_HM; +} + bool bdrv_is_sg(BlockDriverState *bs) { return bs->sg; diff --git a/include/block/block.h b/include/block/block.h index 124ad40809..238c0f5ed7 100644 --- a/include/block/block.h +++ b/include/block/block.h @@ -271,18 +271,35 @@ enum { */ BLK_PERM_GRAPH_MOD = 0x10, + /** This permission is required to open zoned block devices. */ + BLK_PERM_SUPPORT_ZONED = 0x20, + BLK_PERM_ALL = 0x1f, DEFAULT_PERM_PASSTHROUGH = BLK_PERM_CONSISTENT_READ | BLK_PERM_WRITE | BLK_PERM_WRITE_UNCHANGED - | BLK_PERM_RESIZE, + | BLK_PERM_RESIZE + | BLK_PERM_SUPPORT_ZONED, DEFAULT_PERM_UNCHANGED = BLK_PERM_ALL & ~DEFAULT_PERM_PASSTHROUGH, }; char *bdrv_perm_names(uint64_t perm); +/* + * Known zoned device models. + * + * TODO For a Linux host, it could be preferrable to include + * /usr/include/linux/blkzoned.h instead of defining ZBD-specific + * values here. + */ +enum blk_zoned_model { + BLK_ZONED_MODEL_NONE, /* Regular block device */ + BLK_ZONED_MODEL_HA, /* Host-aware zoned block device */ + BLK_ZONED_MODEL_HM, /* Host-managed zoned block device */ +}; + /* disk I/O throttling */ void bdrv_init(void); void bdrv_init_with_whitelist(void); @@ -359,6 +376,8 @@ int64_t bdrv_get_allocated_file_size(BlockDriverState *bs); BlockMeasureInfo *bdrv_measure(BlockDriver *drv, QemuOpts *opts, BlockDriverState *in_bs, Error **errp); void bdrv_get_geometry(BlockDriverState *bs, uint64_t *nb_sectors_ptr); +uint8_t bdrv_get_zoned_model(BlockDriverState *bs); +uint8_t bdrv_is_zoned(BlockDriverState *bs); void bdrv_refresh_limits(BlockDriverState *bs, Error **errp); int bdrv_commit(BlockDriverState *bs); int bdrv_change_backing_file(BlockDriverState *bs, diff --git a/include/block/block_int.h b/include/block/block_int.h index ceec8c2f56..91496e8149 100644 --- a/include/block/block_int.h +++ b/include/block/block_int.h @@ -415,6 +415,7 @@ struct BlockDriver { bool (*bdrv_debug_is_suspended)(BlockDriverState *bs, const char *tag); void (*bdrv_refresh_limits)(BlockDriverState *bs, Error **errp); + void (*bdrv_get_zoned_info)(BlockDriverState *bs); /* * Returns 1 if newly created images are guaranteed to contain only @@ -620,6 +621,9 @@ typedef struct BlockLimits { /* maximum number of iovec elements */ int max_iov; + + /* Zoned device model. Zero value indicates a regular block device */ + uint8_t zoned_model; } BlockLimits; typedef struct BdrvOpBlocker BdrvOpBlocker; From patchwork Fri Aug 23 19:20:54 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Fomichev X-Patchwork-Id: 11112303 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id B029313B1 for ; Fri, 23 Aug 2019 19:29:48 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 859FA21874 for ; Fri, 23 Aug 2019 19:29:48 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=wdc.com header.i=@wdc.com header.b="SSk87Ni7" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 859FA21874 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=wdc.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:33418 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i1FFq-0005pl-R4 for patchwork-qemu-devel@patchwork.kernel.org; Fri, 23 Aug 2019 15:29:46 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:47679) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i1F7V-0005ly-3V for qemu-devel@nongnu.org; Fri, 23 Aug 2019 15:21:10 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i1F7T-0003QA-Mv for qemu-devel@nongnu.org; Fri, 23 Aug 2019 15:21:09 -0400 Received: from esa5.hgst.iphmx.com ([216.71.153.144]:37516) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1i1F7Q-0003Ie-B0; Fri, 23 Aug 2019 15:21:04 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1566588065; x=1598124065; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=WrGHKVduBl42d9CD8UFRTIZ6FP7W7UcEwBBJuvUCUsc=; b=SSk87Ni7Wkv9PnaWC44SGc/7oNxI6HmTeAA0O+xlp62lypnS7IQPnnIA LK6qTvyL/1LMsVMRmpL2UmB8JPRHzCwh8lQiK4zOo7RGqJagqoddCbaM4 nRlUnjy7vrBWbyAMaG1q6yX48dWY9sgXGBqC1HqwZ4lEqXNRAxLmvfH48 Wsjy9/Pem64hegVltkKcFZx6NOvbsbSHy/4q4jogaBthCkf3m1oWHqY+t lQxQhgUntAEE+Bc/vioaZQxFnIrA92MUW1Vl0zs2iaAJq5OVC+Aeyj1WX IM/H7b3cTct3gt1AL1oh9tiZwNdP5t/K6STBMQLOhq+2iYbj82cf89gRT A==; IronPort-SDR: 7TDxJkkY80ftGRUZDVWUKGrMO1rB06Ma78l8uZ/JVQ19vlAEW442gb9VbRk8JQ7xu/nDvUyJ1s 8ANHb4Dh8uhxyXWhbrxG54VTsKtQdI9SAJNP1KCzTeysZkNO4TMPMhQc6Yd6cQAuXrLBLwwUqR geG6TbBvk9vdc+DHH8YQWcpkK0laivfwdD8QeEZTh1CvzHd69RAYkhi+VDE/U53VLvBGyuv/eg cG7pWtbGh0Sd8b9Q0XlnmMtheDza6szikPurkTvlhen5kJ3LV+iIz/zl5sCjHOcGL37WSg1/qA 9JA= X-IronPort-AV: E=Sophos;i="5.64,422,1559491200"; d="scan'208";a="117476227" Received: from h199-255-45-15.hgst.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 24 Aug 2019 03:21:00 +0800 IronPort-SDR: IRIgi8xKDjfNlG7G6m9TnMNSStlPVwRkuxAyo4Nb1Ot/8Wm3deTvvFf1x6/Q9qLMwywaXKwPPK r17eym4OUj/TwsSuUARXCXZnhHtZnqd5/g8p+5BPpXNehq/ZwNRqJ4VJi1WUbUbJxeQqcYtxT1 JfvydMzBu2wyTC+lQjss8P7pKGCOxJ+DwzcfmoMpjPo+CWs/KDenYnMI4Q4cgiOOJMeQhmem4F eHjles3kvYdeEjlbTxn/X0oQci7PWdGkDxh3nU8sTEXMJlAHqWCpEFSWVmMD4D7g9W67dzo6hu KIYYqHO2aifc8vZsDEN2dGMk Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Aug 2019 12:18:16 -0700 IronPort-SDR: jur9OoZSeAp8O+ImqrN5n2zeyG8Dxi7NXzjrwIxQxrND6ITGuwYW5bHr3LRk2m4w7fBcwBKAGO +ZumTmoJMd8SFCPXAIY7m1jfO8iOs9o2oM8gjR/vGfw8zEM6NU5bOnnF+pbICvP5XDpCUPrb4X 7h0PIOMSt97hlI4nc55VScJUF75CxUtGkOI2FsfmTn5dRIQn8PfwTqqrPQ6C73wglrljxh3ohN I91O54xbo4sJ8FDpQ+tWZBfgZvbCmunn/O+D3WqdvYAAmQm5VJO0fRPFbNaAohCuv07i4Vdr8a /eo= WDCIronportException: Internal Received: from dhcp-10-88-173-43.hgst.com ([10.88.173.43]) by uls-op-cesaip01.wdc.com with ESMTP; 23 Aug 2019 12:20:58 -0700 From: Dmitry Fomichev To: Paolo Bonzini , Kevin Wolf , Max Reitz , "Michael S . Tsirkin" , Stefan Hajnoczi , John Snow Date: Fri, 23 Aug 2019 15:20:54 -0400 Message-Id: <20190823192056.21091-2-dmitry.fomichev@wdc.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190823192056.21091-1-dmitry.fomichev@wdc.com> References: <20190823192056.21091-1-dmitry.fomichev@wdc.com> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: FreeBSD 9.x X-Received-From: 216.71.153.144 Subject: [Qemu-devel] [PATCH v4 2/4] raw: Recognize zoned backing devices X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Dmitry Fomichev , Alistair Francis , qemu-devel@nongnu.org, qemu-block@nongnu.org Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" The purpose of this patch is to recognize a zoned block device (ZBD) when it is opened as a raw file. The new code initializes the zoned model propery introduced by the previous commit. This commit is Linux-specific as it gets the Zoned Block Device Model value (none/host-managed/host-aware) from sysfs on the host. In order to avoid code duplication in file-posix.c, a common helper function is added to read values of sysfs entries under /sys/block//queue. This way, the existing function that reads the value of "max_segments" entry and the the new function that reads "zoned" value both share the same helper code. Signed-off-by: Dmitry Fomichev --- block/file-posix.c | 74 ++++++++++++++++++++++++++++++++++++++-------- block/raw-format.c | 8 +++++ 2 files changed, 70 insertions(+), 12 deletions(-) diff --git a/block/file-posix.c b/block/file-posix.c index fbeb0068db..d9f2fc5e46 100644 --- a/block/file-posix.c +++ b/block/file-posix.c @@ -1067,15 +1067,13 @@ static int sg_get_max_transfer_length(int fd) #endif } -static int sg_get_max_segments(int fd) +static int hdev_read_blk_queue_entry(int fd, const char *key, + char *buf, int buf_len) { #ifdef CONFIG_LINUX - char buf[32]; - const char *end; char *sysfspath = NULL; int ret; int sysfd = -1; - long max_segments; struct stat st; if (fstat(fd, &st)) { @@ -1083,23 +1081,45 @@ static int sg_get_max_segments(int fd) goto out; } - sysfspath = g_strdup_printf("/sys/dev/block/%u:%u/queue/max_segments", - major(st.st_rdev), minor(st.st_rdev)); + sysfspath = g_strdup_printf("/sys/dev/block/%u:%u/queue/%s", + major(st.st_rdev), minor(st.st_rdev), key); sysfd = open(sysfspath, O_RDONLY); if (sysfd == -1) { ret = -errno; goto out; } do { - ret = read(sysfd, buf, sizeof(buf) - 1); + ret = read(sysfd, buf, buf_len - 1); } while (ret == -1 && errno == EINTR); if (ret < 0) { ret = -errno; - goto out; } else if (ret == 0) { ret = -EIO; + } +out: + if (sysfd != -1) { + close(sysfd); + } + g_free(sysfspath); + return ret; +#else + return -ENOTSUP; +#endif +} + +static int sg_get_max_segments(int fd) +{ +#ifdef CONFIG_LINUX + char buf[32]; + const char *end; + int ret; + long max_segments; + + ret = hdev_read_blk_queue_entry(fd, "max_segments", buf, sizeof(buf)); + if (ret < 0) { goto out; } + buf[ret] = 0; /* The file is ended with '\n', pass 'end' to accept that. */ ret = qemu_strtol(buf, &end, 10, &max_segments); @@ -1108,10 +1128,33 @@ static int sg_get_max_segments(int fd) } out: - if (sysfd != -1) { - close(sysfd); + return ret; +#else + return -ENOTSUP; +#endif +} + +static int hdev_get_zoned_model(int fd) +{ +#ifdef CONFIG_LINUX + char buf[32]; + int ret; + + ret = hdev_read_blk_queue_entry(fd, "zoned", buf, sizeof(buf)); + if (ret < 0) { + ret = BLK_ZONED_MODEL_NONE; + goto out; } - g_free(sysfspath); + + buf[ret - 1] = 0; + ret = BLK_ZONED_MODEL_NONE; + if (strcmp(buf, "host-managed") == 0) { + ret = BLK_ZONED_MODEL_HM; + } else if (strcmp(buf, "host-aware") == 0) { + ret = BLK_ZONED_MODEL_HA; + } + +out: return ret; #else return -ENOTSUP; @@ -1121,9 +1164,10 @@ out: static void raw_refresh_limits(BlockDriverState *bs, Error **errp) { BDRVRawState *s = bs->opaque; + int ret; if (bs->sg) { - int ret = sg_get_max_transfer_length(s->fd); + ret = sg_get_max_transfer_length(s->fd); if (ret > 0 && ret <= BDRV_REQUEST_MAX_BYTES) { bs->bl.max_transfer = pow2floor(ret); @@ -1133,6 +1177,12 @@ static void raw_refresh_limits(BlockDriverState *bs, Error **errp) if (ret > 0) { bs->bl.max_transfer = MIN(bs->bl.max_transfer, ret * getpagesize()); } + + } + + ret = hdev_get_zoned_model(s->fd); + if (ret >= 0) { + bs->bl.zoned_model = ret; } raw_probe_alignment(bs, s->fd, errp); diff --git a/block/raw-format.c b/block/raw-format.c index 42c28cc29a..a606e4a7fe 100644 --- a/block/raw-format.c +++ b/block/raw-format.c @@ -369,6 +369,13 @@ static void raw_refresh_limits(BlockDriverState *bs, Error **errp) } } +static void raw_get_zoned_info(BlockDriverState *bs) +{ + if (!bs->probed) { + bs->bl.zoned_model = bs->file->bs->bl.zoned_model; + } +} + static int coroutine_fn raw_co_truncate(BlockDriverState *bs, int64_t offset, PreallocMode prealloc, Error **errp) { @@ -578,6 +585,7 @@ BlockDriver bdrv_raw = { .create_opts = &raw_create_opts, .bdrv_has_zero_init = &raw_has_zero_init, .bdrv_has_zero_init_truncate = &raw_has_zero_init_truncate, + .bdrv_get_zoned_info = &raw_get_zoned_info, .strong_runtime_opts = raw_strong_runtime_opts, .mutable_opts = mutable_opts, };