1aaf2e048SChaitanya Kulkarni // SPDX-License-Identifier: GPL-2.0 2aaf2e048SChaitanya Kulkarni /* 3aaf2e048SChaitanya Kulkarni * NVMe ZNS-ZBD command implementation. 4aaf2e048SChaitanya Kulkarni * Copyright (C) 2021 Western Digital Corporation or its affiliates. 5aaf2e048SChaitanya Kulkarni */ 6aaf2e048SChaitanya Kulkarni #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt 7aaf2e048SChaitanya Kulkarni #include <linux/nvme.h> 8aaf2e048SChaitanya Kulkarni #include <linux/blkdev.h> 9aaf2e048SChaitanya Kulkarni #include "nvmet.h" 10aaf2e048SChaitanya Kulkarni 11aaf2e048SChaitanya Kulkarni /* 12aaf2e048SChaitanya Kulkarni * We set the Memory Page Size Minimum (MPSMIN) for target controller to 0 13aaf2e048SChaitanya Kulkarni * which gets added by 12 in the nvme_enable_ctrl() which results in 2^12 = 4k 14aaf2e048SChaitanya Kulkarni * as page_shift value. When calculating the ZASL use shift by 12. 15aaf2e048SChaitanya Kulkarni */ 16aaf2e048SChaitanya Kulkarni #define NVMET_MPSMIN_SHIFT 12 17aaf2e048SChaitanya Kulkarni 18aaf2e048SChaitanya Kulkarni static inline u8 nvmet_zasl(unsigned int zone_append_sects) 19aaf2e048SChaitanya Kulkarni { 20aaf2e048SChaitanya Kulkarni /* 21aaf2e048SChaitanya Kulkarni * Zone Append Size Limit (zasl) is expressed as a power of 2 value 22aaf2e048SChaitanya Kulkarni * with the minimum memory page size (i.e. 12) as unit. 23aaf2e048SChaitanya Kulkarni */ 24aaf2e048SChaitanya Kulkarni return ilog2(zone_append_sects >> (NVMET_MPSMIN_SHIFT - 9)); 25aaf2e048SChaitanya Kulkarni } 26aaf2e048SChaitanya Kulkarni 27aaf2e048SChaitanya Kulkarni static int validate_conv_zones_cb(struct blk_zone *z, 28aaf2e048SChaitanya Kulkarni unsigned int i, void *data) 29aaf2e048SChaitanya Kulkarni { 30aaf2e048SChaitanya Kulkarni if (z->type == BLK_ZONE_TYPE_CONVENTIONAL) 31aaf2e048SChaitanya Kulkarni return -EOPNOTSUPP; 32aaf2e048SChaitanya Kulkarni return 0; 33aaf2e048SChaitanya Kulkarni } 34aaf2e048SChaitanya Kulkarni 35aaf2e048SChaitanya Kulkarni bool nvmet_bdev_zns_enable(struct nvmet_ns *ns) 36aaf2e048SChaitanya Kulkarni { 372aba0d19SChristoph Hellwig u8 zasl = nvmet_zasl(bdev_max_zone_append_sectors(ns->bdev)); 38aaf2e048SChaitanya Kulkarni struct gendisk *bd_disk = ns->bdev->bd_disk; 39aaf2e048SChaitanya Kulkarni int ret; 40aaf2e048SChaitanya Kulkarni 41aaf2e048SChaitanya Kulkarni if (ns->subsys->zasl) { 42aaf2e048SChaitanya Kulkarni if (ns->subsys->zasl > zasl) 43aaf2e048SChaitanya Kulkarni return false; 44aaf2e048SChaitanya Kulkarni } 45aaf2e048SChaitanya Kulkarni ns->subsys->zasl = zasl; 46aaf2e048SChaitanya Kulkarni 47aaf2e048SChaitanya Kulkarni /* 48aaf2e048SChaitanya Kulkarni * Generic zoned block devices may have a smaller last zone which is 49aaf2e048SChaitanya Kulkarni * not supported by ZNS. Exclude zoned drives that have such smaller 50aaf2e048SChaitanya Kulkarni * last zone. 51aaf2e048SChaitanya Kulkarni */ 52aaf2e048SChaitanya Kulkarni if (get_capacity(bd_disk) & (bdev_zone_sectors(ns->bdev) - 1)) 53aaf2e048SChaitanya Kulkarni return false; 54aaf2e048SChaitanya Kulkarni /* 55aaf2e048SChaitanya Kulkarni * ZNS does not define a conventional zone type. If the underlying 56aaf2e048SChaitanya Kulkarni * device has a bitmap set indicating the existence of conventional 57aaf2e048SChaitanya Kulkarni * zones, reject the device. Otherwise, use report zones to detect if 58aaf2e048SChaitanya Kulkarni * the device has conventional zones. 59aaf2e048SChaitanya Kulkarni */ 60d86e716aSChristoph Hellwig if (ns->bdev->bd_disk->conv_zones_bitmap) 61aaf2e048SChaitanya Kulkarni return false; 62aaf2e048SChaitanya Kulkarni 63b623e347SChristoph Hellwig ret = blkdev_report_zones(ns->bdev, 0, bdev_nr_zones(ns->bdev), 64aaf2e048SChaitanya Kulkarni validate_conv_zones_cb, NULL); 65aaf2e048SChaitanya Kulkarni if (ret < 0) 66aaf2e048SChaitanya Kulkarni return false; 67aaf2e048SChaitanya Kulkarni 68aaf2e048SChaitanya Kulkarni ns->blksize_shift = blksize_bits(bdev_logical_block_size(ns->bdev)); 69aaf2e048SChaitanya Kulkarni 70aaf2e048SChaitanya Kulkarni return true; 71aaf2e048SChaitanya Kulkarni } 72aaf2e048SChaitanya Kulkarni 73aaf2e048SChaitanya Kulkarni void nvmet_execute_identify_cns_cs_ctrl(struct nvmet_req *req) 74aaf2e048SChaitanya Kulkarni { 75aaf2e048SChaitanya Kulkarni u8 zasl = req->sq->ctrl->subsys->zasl; 76aaf2e048SChaitanya Kulkarni struct nvmet_ctrl *ctrl = req->sq->ctrl; 77aaf2e048SChaitanya Kulkarni struct nvme_id_ctrl_zns *id; 78aaf2e048SChaitanya Kulkarni u16 status; 79aaf2e048SChaitanya Kulkarni 80aaf2e048SChaitanya Kulkarni id = kzalloc(sizeof(*id), GFP_KERNEL); 81aaf2e048SChaitanya Kulkarni if (!id) { 82aaf2e048SChaitanya Kulkarni status = NVME_SC_INTERNAL; 83aaf2e048SChaitanya Kulkarni goto out; 84aaf2e048SChaitanya Kulkarni } 85aaf2e048SChaitanya Kulkarni 86aaf2e048SChaitanya Kulkarni if (ctrl->ops->get_mdts) 87aaf2e048SChaitanya Kulkarni id->zasl = min_t(u8, ctrl->ops->get_mdts(ctrl), zasl); 88aaf2e048SChaitanya Kulkarni else 89aaf2e048SChaitanya Kulkarni id->zasl = zasl; 90aaf2e048SChaitanya Kulkarni 91aaf2e048SChaitanya Kulkarni status = nvmet_copy_to_sgl(req, 0, id, sizeof(*id)); 92aaf2e048SChaitanya Kulkarni 93aaf2e048SChaitanya Kulkarni kfree(id); 94aaf2e048SChaitanya Kulkarni out: 95aaf2e048SChaitanya Kulkarni nvmet_req_complete(req, status); 96aaf2e048SChaitanya Kulkarni } 97aaf2e048SChaitanya Kulkarni 98aaf2e048SChaitanya Kulkarni void nvmet_execute_identify_cns_cs_ns(struct nvmet_req *req) 99aaf2e048SChaitanya Kulkarni { 100aaf2e048SChaitanya Kulkarni struct nvme_id_ns_zns *id_zns; 101aaf2e048SChaitanya Kulkarni u64 zsze; 102aaf2e048SChaitanya Kulkarni u16 status; 103b7e97872SDennis Maisenbacher u32 mar, mor; 104aaf2e048SChaitanya Kulkarni 105aaf2e048SChaitanya Kulkarni if (le32_to_cpu(req->cmd->identify.nsid) == NVME_NSID_ALL) { 106aaf2e048SChaitanya Kulkarni req->error_loc = offsetof(struct nvme_identify, nsid); 107aaf2e048SChaitanya Kulkarni status = NVME_SC_INVALID_NS | NVME_SC_DNR; 108aaf2e048SChaitanya Kulkarni goto out; 109aaf2e048SChaitanya Kulkarni } 110aaf2e048SChaitanya Kulkarni 111aaf2e048SChaitanya Kulkarni id_zns = kzalloc(sizeof(*id_zns), GFP_KERNEL); 112aaf2e048SChaitanya Kulkarni if (!id_zns) { 113aaf2e048SChaitanya Kulkarni status = NVME_SC_INTERNAL; 114aaf2e048SChaitanya Kulkarni goto out; 115aaf2e048SChaitanya Kulkarni } 116aaf2e048SChaitanya Kulkarni 117aaf2e048SChaitanya Kulkarni status = nvmet_req_find_ns(req); 118ad0e9a80SColin Ian King if (status) 119aaf2e048SChaitanya Kulkarni goto done; 120aaf2e048SChaitanya Kulkarni 121aaf2e048SChaitanya Kulkarni if (!bdev_is_zoned(req->ns->bdev)) { 122aaf2e048SChaitanya Kulkarni req->error_loc = offsetof(struct nvme_identify, nsid); 123aaf2e048SChaitanya Kulkarni goto done; 124aaf2e048SChaitanya Kulkarni } 125aaf2e048SChaitanya Kulkarni 126da783733SChristoph Hellwig if (nvmet_ns_revalidate(req->ns)) { 127da783733SChristoph Hellwig mutex_lock(&req->ns->subsys->lock); 128da783733SChristoph Hellwig nvmet_ns_changed(req->ns->subsys, req->ns->nsid); 129da783733SChristoph Hellwig mutex_unlock(&req->ns->subsys->lock); 130da783733SChristoph Hellwig } 131aaf2e048SChaitanya Kulkarni zsze = (bdev_zone_sectors(req->ns->bdev) << 9) >> 132aaf2e048SChaitanya Kulkarni req->ns->blksize_shift; 133aaf2e048SChaitanya Kulkarni id_zns->lbafe[0].zsze = cpu_to_le64(zsze); 134b7e97872SDennis Maisenbacher 135b7e97872SDennis Maisenbacher mor = bdev_max_open_zones(req->ns->bdev); 136b7e97872SDennis Maisenbacher if (!mor) 137b7e97872SDennis Maisenbacher mor = U32_MAX; 138b7e97872SDennis Maisenbacher else 139b7e97872SDennis Maisenbacher mor--; 140b7e97872SDennis Maisenbacher id_zns->mor = cpu_to_le32(mor); 141b7e97872SDennis Maisenbacher 142b7e97872SDennis Maisenbacher mar = bdev_max_active_zones(req->ns->bdev); 143b7e97872SDennis Maisenbacher if (!mar) 144b7e97872SDennis Maisenbacher mar = U32_MAX; 145b7e97872SDennis Maisenbacher else 146b7e97872SDennis Maisenbacher mar--; 147b7e97872SDennis Maisenbacher id_zns->mar = cpu_to_le32(mar); 148aaf2e048SChaitanya Kulkarni 149aaf2e048SChaitanya Kulkarni done: 150aaf2e048SChaitanya Kulkarni status = nvmet_copy_to_sgl(req, 0, id_zns, sizeof(*id_zns)); 151aaf2e048SChaitanya Kulkarni kfree(id_zns); 152aaf2e048SChaitanya Kulkarni out: 153aaf2e048SChaitanya Kulkarni nvmet_req_complete(req, status); 154aaf2e048SChaitanya Kulkarni } 155aaf2e048SChaitanya Kulkarni 156aaf2e048SChaitanya Kulkarni static u16 nvmet_bdev_validate_zone_mgmt_recv(struct nvmet_req *req) 157aaf2e048SChaitanya Kulkarni { 158aaf2e048SChaitanya Kulkarni sector_t sect = nvmet_lba_to_sect(req->ns, req->cmd->zmr.slba); 159aaf2e048SChaitanya Kulkarni u32 out_bufsize = (le32_to_cpu(req->cmd->zmr.numd) + 1) << 2; 160aaf2e048SChaitanya Kulkarni 161aaf2e048SChaitanya Kulkarni if (sect >= get_capacity(req->ns->bdev->bd_disk)) { 162aaf2e048SChaitanya Kulkarni req->error_loc = offsetof(struct nvme_zone_mgmt_recv_cmd, slba); 163aaf2e048SChaitanya Kulkarni return NVME_SC_LBA_RANGE | NVME_SC_DNR; 164aaf2e048SChaitanya Kulkarni } 165aaf2e048SChaitanya Kulkarni 166aaf2e048SChaitanya Kulkarni if (out_bufsize < sizeof(struct nvme_zone_report)) { 167aaf2e048SChaitanya Kulkarni req->error_loc = offsetof(struct nvme_zone_mgmt_recv_cmd, numd); 168aaf2e048SChaitanya Kulkarni return NVME_SC_INVALID_FIELD | NVME_SC_DNR; 169aaf2e048SChaitanya Kulkarni } 170aaf2e048SChaitanya Kulkarni 171aaf2e048SChaitanya Kulkarni if (req->cmd->zmr.zra != NVME_ZRA_ZONE_REPORT) { 172aaf2e048SChaitanya Kulkarni req->error_loc = offsetof(struct nvme_zone_mgmt_recv_cmd, zra); 173aaf2e048SChaitanya Kulkarni return NVME_SC_INVALID_FIELD | NVME_SC_DNR; 174aaf2e048SChaitanya Kulkarni } 175aaf2e048SChaitanya Kulkarni 176aaf2e048SChaitanya Kulkarni switch (req->cmd->zmr.pr) { 177aaf2e048SChaitanya Kulkarni case 0: 178aaf2e048SChaitanya Kulkarni case 1: 179aaf2e048SChaitanya Kulkarni break; 180aaf2e048SChaitanya Kulkarni default: 181aaf2e048SChaitanya Kulkarni req->error_loc = offsetof(struct nvme_zone_mgmt_recv_cmd, pr); 182aaf2e048SChaitanya Kulkarni return NVME_SC_INVALID_FIELD | NVME_SC_DNR; 183aaf2e048SChaitanya Kulkarni } 184aaf2e048SChaitanya Kulkarni 185aaf2e048SChaitanya Kulkarni switch (req->cmd->zmr.zrasf) { 186aaf2e048SChaitanya Kulkarni case NVME_ZRASF_ZONE_REPORT_ALL: 187aaf2e048SChaitanya Kulkarni case NVME_ZRASF_ZONE_STATE_EMPTY: 188aaf2e048SChaitanya Kulkarni case NVME_ZRASF_ZONE_STATE_IMP_OPEN: 189aaf2e048SChaitanya Kulkarni case NVME_ZRASF_ZONE_STATE_EXP_OPEN: 190aaf2e048SChaitanya Kulkarni case NVME_ZRASF_ZONE_STATE_CLOSED: 191aaf2e048SChaitanya Kulkarni case NVME_ZRASF_ZONE_STATE_FULL: 192aaf2e048SChaitanya Kulkarni case NVME_ZRASF_ZONE_STATE_READONLY: 193aaf2e048SChaitanya Kulkarni case NVME_ZRASF_ZONE_STATE_OFFLINE: 194aaf2e048SChaitanya Kulkarni break; 195aaf2e048SChaitanya Kulkarni default: 196aaf2e048SChaitanya Kulkarni req->error_loc = 197aaf2e048SChaitanya Kulkarni offsetof(struct nvme_zone_mgmt_recv_cmd, zrasf); 198aaf2e048SChaitanya Kulkarni return NVME_SC_INVALID_FIELD | NVME_SC_DNR; 199aaf2e048SChaitanya Kulkarni } 200aaf2e048SChaitanya Kulkarni 201aaf2e048SChaitanya Kulkarni return NVME_SC_SUCCESS; 202aaf2e048SChaitanya Kulkarni } 203aaf2e048SChaitanya Kulkarni 204aaf2e048SChaitanya Kulkarni struct nvmet_report_zone_data { 205aaf2e048SChaitanya Kulkarni struct nvmet_req *req; 206aaf2e048SChaitanya Kulkarni u64 out_buf_offset; 207aaf2e048SChaitanya Kulkarni u64 out_nr_zones; 208aaf2e048SChaitanya Kulkarni u64 nr_zones; 209aaf2e048SChaitanya Kulkarni u8 zrasf; 210aaf2e048SChaitanya Kulkarni }; 211aaf2e048SChaitanya Kulkarni 212aaf2e048SChaitanya Kulkarni static int nvmet_bdev_report_zone_cb(struct blk_zone *z, unsigned i, void *d) 213aaf2e048SChaitanya Kulkarni { 214aaf2e048SChaitanya Kulkarni static const unsigned int nvme_zrasf_to_blk_zcond[] = { 215aaf2e048SChaitanya Kulkarni [NVME_ZRASF_ZONE_STATE_EMPTY] = BLK_ZONE_COND_EMPTY, 216aaf2e048SChaitanya Kulkarni [NVME_ZRASF_ZONE_STATE_IMP_OPEN] = BLK_ZONE_COND_IMP_OPEN, 217aaf2e048SChaitanya Kulkarni [NVME_ZRASF_ZONE_STATE_EXP_OPEN] = BLK_ZONE_COND_EXP_OPEN, 218aaf2e048SChaitanya Kulkarni [NVME_ZRASF_ZONE_STATE_CLOSED] = BLK_ZONE_COND_CLOSED, 219aaf2e048SChaitanya Kulkarni [NVME_ZRASF_ZONE_STATE_READONLY] = BLK_ZONE_COND_READONLY, 220aaf2e048SChaitanya Kulkarni [NVME_ZRASF_ZONE_STATE_FULL] = BLK_ZONE_COND_FULL, 221aaf2e048SChaitanya Kulkarni [NVME_ZRASF_ZONE_STATE_OFFLINE] = BLK_ZONE_COND_OFFLINE, 222aaf2e048SChaitanya Kulkarni }; 223aaf2e048SChaitanya Kulkarni struct nvmet_report_zone_data *rz = d; 224aaf2e048SChaitanya Kulkarni 225aaf2e048SChaitanya Kulkarni if (rz->zrasf != NVME_ZRASF_ZONE_REPORT_ALL && 226aaf2e048SChaitanya Kulkarni z->cond != nvme_zrasf_to_blk_zcond[rz->zrasf]) 227aaf2e048SChaitanya Kulkarni return 0; 228aaf2e048SChaitanya Kulkarni 229aaf2e048SChaitanya Kulkarni if (rz->nr_zones < rz->out_nr_zones) { 230aaf2e048SChaitanya Kulkarni struct nvme_zone_descriptor zdesc = { }; 231aaf2e048SChaitanya Kulkarni u16 status; 232aaf2e048SChaitanya Kulkarni 233aaf2e048SChaitanya Kulkarni zdesc.zcap = nvmet_sect_to_lba(rz->req->ns, z->capacity); 234aaf2e048SChaitanya Kulkarni zdesc.zslba = nvmet_sect_to_lba(rz->req->ns, z->start); 235aaf2e048SChaitanya Kulkarni zdesc.wp = nvmet_sect_to_lba(rz->req->ns, z->wp); 236aaf2e048SChaitanya Kulkarni zdesc.za = z->reset ? 1 << 2 : 0; 237aaf2e048SChaitanya Kulkarni zdesc.zs = z->cond << 4; 238aaf2e048SChaitanya Kulkarni zdesc.zt = z->type; 239aaf2e048SChaitanya Kulkarni 240aaf2e048SChaitanya Kulkarni status = nvmet_copy_to_sgl(rz->req, rz->out_buf_offset, &zdesc, 241aaf2e048SChaitanya Kulkarni sizeof(zdesc)); 242aaf2e048SChaitanya Kulkarni if (status) 243aaf2e048SChaitanya Kulkarni return -EINVAL; 244aaf2e048SChaitanya Kulkarni 245aaf2e048SChaitanya Kulkarni rz->out_buf_offset += sizeof(zdesc); 246aaf2e048SChaitanya Kulkarni } 247aaf2e048SChaitanya Kulkarni 248aaf2e048SChaitanya Kulkarni rz->nr_zones++; 249aaf2e048SChaitanya Kulkarni 250aaf2e048SChaitanya Kulkarni return 0; 251aaf2e048SChaitanya Kulkarni } 252aaf2e048SChaitanya Kulkarni 253aaf2e048SChaitanya Kulkarni static unsigned long nvmet_req_nr_zones_from_slba(struct nvmet_req *req) 254aaf2e048SChaitanya Kulkarni { 255aaf2e048SChaitanya Kulkarni unsigned int sect = nvmet_lba_to_sect(req->ns, req->cmd->zmr.slba); 256aaf2e048SChaitanya Kulkarni 257*d67ea690SPankaj Raghav return bdev_nr_zones(req->ns->bdev) - bdev_zone_no(req->ns->bdev, sect); 258aaf2e048SChaitanya Kulkarni } 259aaf2e048SChaitanya Kulkarni 260aaf2e048SChaitanya Kulkarni static unsigned long get_nr_zones_from_buf(struct nvmet_req *req, u32 bufsize) 261aaf2e048SChaitanya Kulkarni { 262aaf2e048SChaitanya Kulkarni if (bufsize <= sizeof(struct nvme_zone_report)) 263aaf2e048SChaitanya Kulkarni return 0; 264aaf2e048SChaitanya Kulkarni 265aaf2e048SChaitanya Kulkarni return (bufsize - sizeof(struct nvme_zone_report)) / 266aaf2e048SChaitanya Kulkarni sizeof(struct nvme_zone_descriptor); 267aaf2e048SChaitanya Kulkarni } 268aaf2e048SChaitanya Kulkarni 269aaf2e048SChaitanya Kulkarni static void nvmet_bdev_zone_zmgmt_recv_work(struct work_struct *w) 270aaf2e048SChaitanya Kulkarni { 271aaf2e048SChaitanya Kulkarni struct nvmet_req *req = container_of(w, struct nvmet_req, z.zmgmt_work); 272aaf2e048SChaitanya Kulkarni sector_t start_sect = nvmet_lba_to_sect(req->ns, req->cmd->zmr.slba); 273aaf2e048SChaitanya Kulkarni unsigned long req_slba_nr_zones = nvmet_req_nr_zones_from_slba(req); 274aaf2e048SChaitanya Kulkarni u32 out_bufsize = (le32_to_cpu(req->cmd->zmr.numd) + 1) << 2; 275aaf2e048SChaitanya Kulkarni __le64 nr_zones; 276aaf2e048SChaitanya Kulkarni u16 status; 277aaf2e048SChaitanya Kulkarni int ret; 278aaf2e048SChaitanya Kulkarni struct nvmet_report_zone_data rz_data = { 279aaf2e048SChaitanya Kulkarni .out_nr_zones = get_nr_zones_from_buf(req, out_bufsize), 280aaf2e048SChaitanya Kulkarni /* leave the place for report zone header */ 281aaf2e048SChaitanya Kulkarni .out_buf_offset = sizeof(struct nvme_zone_report), 282aaf2e048SChaitanya Kulkarni .zrasf = req->cmd->zmr.zrasf, 283aaf2e048SChaitanya Kulkarni .nr_zones = 0, 284aaf2e048SChaitanya Kulkarni .req = req, 285aaf2e048SChaitanya Kulkarni }; 286aaf2e048SChaitanya Kulkarni 287aaf2e048SChaitanya Kulkarni status = nvmet_bdev_validate_zone_mgmt_recv(req); 288aaf2e048SChaitanya Kulkarni if (status) 289aaf2e048SChaitanya Kulkarni goto out; 290aaf2e048SChaitanya Kulkarni 291aaf2e048SChaitanya Kulkarni if (!req_slba_nr_zones) { 292aaf2e048SChaitanya Kulkarni status = NVME_SC_SUCCESS; 293aaf2e048SChaitanya Kulkarni goto out; 294aaf2e048SChaitanya Kulkarni } 295aaf2e048SChaitanya Kulkarni 296aaf2e048SChaitanya Kulkarni ret = blkdev_report_zones(req->ns->bdev, start_sect, req_slba_nr_zones, 297aaf2e048SChaitanya Kulkarni nvmet_bdev_report_zone_cb, &rz_data); 298aaf2e048SChaitanya Kulkarni if (ret < 0) { 299aaf2e048SChaitanya Kulkarni status = NVME_SC_INTERNAL; 300aaf2e048SChaitanya Kulkarni goto out; 301aaf2e048SChaitanya Kulkarni } 302aaf2e048SChaitanya Kulkarni 303aaf2e048SChaitanya Kulkarni /* 304aaf2e048SChaitanya Kulkarni * When partial bit is set nr_zones must indicate the number of zone 305aaf2e048SChaitanya Kulkarni * descriptors actually transferred. 306aaf2e048SChaitanya Kulkarni */ 307aaf2e048SChaitanya Kulkarni if (req->cmd->zmr.pr) 308aaf2e048SChaitanya Kulkarni rz_data.nr_zones = min(rz_data.nr_zones, rz_data.out_nr_zones); 309aaf2e048SChaitanya Kulkarni 310aaf2e048SChaitanya Kulkarni nr_zones = cpu_to_le64(rz_data.nr_zones); 311aaf2e048SChaitanya Kulkarni status = nvmet_copy_to_sgl(req, 0, &nr_zones, sizeof(nr_zones)); 312aaf2e048SChaitanya Kulkarni 313aaf2e048SChaitanya Kulkarni out: 314aaf2e048SChaitanya Kulkarni nvmet_req_complete(req, status); 315aaf2e048SChaitanya Kulkarni } 316aaf2e048SChaitanya Kulkarni 317aaf2e048SChaitanya Kulkarni void nvmet_bdev_execute_zone_mgmt_recv(struct nvmet_req *req) 318aaf2e048SChaitanya Kulkarni { 319aaf2e048SChaitanya Kulkarni INIT_WORK(&req->z.zmgmt_work, nvmet_bdev_zone_zmgmt_recv_work); 320aaf2e048SChaitanya Kulkarni queue_work(zbd_wq, &req->z.zmgmt_work); 321aaf2e048SChaitanya Kulkarni } 322aaf2e048SChaitanya Kulkarni 323ff07a02eSBart Van Assche static inline enum req_op zsa_req_op(u8 zsa) 324aaf2e048SChaitanya Kulkarni { 325aaf2e048SChaitanya Kulkarni switch (zsa) { 326aaf2e048SChaitanya Kulkarni case NVME_ZONE_OPEN: 327aaf2e048SChaitanya Kulkarni return REQ_OP_ZONE_OPEN; 328aaf2e048SChaitanya Kulkarni case NVME_ZONE_CLOSE: 329aaf2e048SChaitanya Kulkarni return REQ_OP_ZONE_CLOSE; 330aaf2e048SChaitanya Kulkarni case NVME_ZONE_FINISH: 331aaf2e048SChaitanya Kulkarni return REQ_OP_ZONE_FINISH; 332aaf2e048SChaitanya Kulkarni case NVME_ZONE_RESET: 333aaf2e048SChaitanya Kulkarni return REQ_OP_ZONE_RESET; 334aaf2e048SChaitanya Kulkarni default: 335aaf2e048SChaitanya Kulkarni return REQ_OP_LAST; 336aaf2e048SChaitanya Kulkarni } 337aaf2e048SChaitanya Kulkarni } 338aaf2e048SChaitanya Kulkarni 339aaf2e048SChaitanya Kulkarni static u16 blkdev_zone_mgmt_errno_to_nvme_status(int ret) 340aaf2e048SChaitanya Kulkarni { 341aaf2e048SChaitanya Kulkarni switch (ret) { 342aaf2e048SChaitanya Kulkarni case 0: 343aaf2e048SChaitanya Kulkarni return NVME_SC_SUCCESS; 344aaf2e048SChaitanya Kulkarni case -EINVAL: 345aaf2e048SChaitanya Kulkarni case -EIO: 346aaf2e048SChaitanya Kulkarni return NVME_SC_ZONE_INVALID_TRANSITION | NVME_SC_DNR; 347aaf2e048SChaitanya Kulkarni default: 348aaf2e048SChaitanya Kulkarni return NVME_SC_INTERNAL; 349aaf2e048SChaitanya Kulkarni } 350aaf2e048SChaitanya Kulkarni } 351aaf2e048SChaitanya Kulkarni 352aaf2e048SChaitanya Kulkarni struct nvmet_zone_mgmt_send_all_data { 353aaf2e048SChaitanya Kulkarni unsigned long *zbitmap; 354aaf2e048SChaitanya Kulkarni struct nvmet_req *req; 355aaf2e048SChaitanya Kulkarni }; 356aaf2e048SChaitanya Kulkarni 357aaf2e048SChaitanya Kulkarni static int zmgmt_send_scan_cb(struct blk_zone *z, unsigned i, void *d) 358aaf2e048SChaitanya Kulkarni { 359aaf2e048SChaitanya Kulkarni struct nvmet_zone_mgmt_send_all_data *data = d; 360aaf2e048SChaitanya Kulkarni 361aaf2e048SChaitanya Kulkarni switch (zsa_req_op(data->req->cmd->zms.zsa)) { 362aaf2e048SChaitanya Kulkarni case REQ_OP_ZONE_OPEN: 363aaf2e048SChaitanya Kulkarni switch (z->cond) { 364aaf2e048SChaitanya Kulkarni case BLK_ZONE_COND_CLOSED: 365aaf2e048SChaitanya Kulkarni break; 366aaf2e048SChaitanya Kulkarni default: 367aaf2e048SChaitanya Kulkarni return 0; 368aaf2e048SChaitanya Kulkarni } 369aaf2e048SChaitanya Kulkarni break; 370aaf2e048SChaitanya Kulkarni case REQ_OP_ZONE_CLOSE: 371aaf2e048SChaitanya Kulkarni switch (z->cond) { 372aaf2e048SChaitanya Kulkarni case BLK_ZONE_COND_IMP_OPEN: 373aaf2e048SChaitanya Kulkarni case BLK_ZONE_COND_EXP_OPEN: 374aaf2e048SChaitanya Kulkarni break; 375aaf2e048SChaitanya Kulkarni default: 376aaf2e048SChaitanya Kulkarni return 0; 377aaf2e048SChaitanya Kulkarni } 378aaf2e048SChaitanya Kulkarni break; 379aaf2e048SChaitanya Kulkarni case REQ_OP_ZONE_FINISH: 380aaf2e048SChaitanya Kulkarni switch (z->cond) { 381aaf2e048SChaitanya Kulkarni case BLK_ZONE_COND_IMP_OPEN: 382aaf2e048SChaitanya Kulkarni case BLK_ZONE_COND_EXP_OPEN: 383aaf2e048SChaitanya Kulkarni case BLK_ZONE_COND_CLOSED: 384aaf2e048SChaitanya Kulkarni break; 385aaf2e048SChaitanya Kulkarni default: 386aaf2e048SChaitanya Kulkarni return 0; 387aaf2e048SChaitanya Kulkarni } 388aaf2e048SChaitanya Kulkarni break; 389aaf2e048SChaitanya Kulkarni default: 390aaf2e048SChaitanya Kulkarni return -EINVAL; 391aaf2e048SChaitanya Kulkarni } 392aaf2e048SChaitanya Kulkarni 393aaf2e048SChaitanya Kulkarni set_bit(i, data->zbitmap); 394aaf2e048SChaitanya Kulkarni 395aaf2e048SChaitanya Kulkarni return 0; 396aaf2e048SChaitanya Kulkarni } 397aaf2e048SChaitanya Kulkarni 398aaf2e048SChaitanya Kulkarni static u16 nvmet_bdev_zone_mgmt_emulate_all(struct nvmet_req *req) 399aaf2e048SChaitanya Kulkarni { 400aaf2e048SChaitanya Kulkarni struct block_device *bdev = req->ns->bdev; 401b623e347SChristoph Hellwig unsigned int nr_zones = bdev_nr_zones(bdev); 402aaf2e048SChaitanya Kulkarni struct bio *bio = NULL; 403aaf2e048SChaitanya Kulkarni sector_t sector = 0; 404aaf2e048SChaitanya Kulkarni int ret; 405aaf2e048SChaitanya Kulkarni struct nvmet_zone_mgmt_send_all_data d = { 406aaf2e048SChaitanya Kulkarni .req = req, 407aaf2e048SChaitanya Kulkarni }; 408aaf2e048SChaitanya Kulkarni 409aaf2e048SChaitanya Kulkarni d.zbitmap = kcalloc_node(BITS_TO_LONGS(nr_zones), sizeof(*(d.zbitmap)), 4108df20252SChristoph Hellwig GFP_NOIO, bdev->bd_disk->node_id); 411aaf2e048SChaitanya Kulkarni if (!d.zbitmap) { 412aaf2e048SChaitanya Kulkarni ret = -ENOMEM; 413aaf2e048SChaitanya Kulkarni goto out; 414aaf2e048SChaitanya Kulkarni } 415aaf2e048SChaitanya Kulkarni 416aaf2e048SChaitanya Kulkarni /* Scan and build bitmap of the eligible zones */ 417aaf2e048SChaitanya Kulkarni ret = blkdev_report_zones(bdev, 0, nr_zones, zmgmt_send_scan_cb, &d); 418aaf2e048SChaitanya Kulkarni if (ret != nr_zones) { 419aaf2e048SChaitanya Kulkarni if (ret > 0) 420aaf2e048SChaitanya Kulkarni ret = -EIO; 421aaf2e048SChaitanya Kulkarni goto out; 422aaf2e048SChaitanya Kulkarni } else { 423aaf2e048SChaitanya Kulkarni /* We scanned all the zones */ 424aaf2e048SChaitanya Kulkarni ret = 0; 425aaf2e048SChaitanya Kulkarni } 426aaf2e048SChaitanya Kulkarni 427a239145aSChristoph Hellwig while (sector < bdev_nr_sectors(bdev)) { 428d86e716aSChristoph Hellwig if (test_bit(disk_zone_no(bdev->bd_disk, sector), d.zbitmap)) { 4290a3140eaSChaitanya Kulkarni bio = blk_next_bio(bio, bdev, 0, 4300a3140eaSChaitanya Kulkarni zsa_req_op(req->cmd->zms.zsa) | REQ_SYNC, 4310a3140eaSChaitanya Kulkarni GFP_KERNEL); 432aaf2e048SChaitanya Kulkarni bio->bi_iter.bi_sector = sector; 433aaf2e048SChaitanya Kulkarni /* This may take a while, so be nice to others */ 434aaf2e048SChaitanya Kulkarni cond_resched(); 435aaf2e048SChaitanya Kulkarni } 436a239145aSChristoph Hellwig sector += bdev_zone_sectors(bdev); 437aaf2e048SChaitanya Kulkarni } 438aaf2e048SChaitanya Kulkarni 439aaf2e048SChaitanya Kulkarni if (bio) { 440aaf2e048SChaitanya Kulkarni ret = submit_bio_wait(bio); 441aaf2e048SChaitanya Kulkarni bio_put(bio); 442aaf2e048SChaitanya Kulkarni } 443aaf2e048SChaitanya Kulkarni 444aaf2e048SChaitanya Kulkarni out: 445aaf2e048SChaitanya Kulkarni kfree(d.zbitmap); 446aaf2e048SChaitanya Kulkarni 447aaf2e048SChaitanya Kulkarni return blkdev_zone_mgmt_errno_to_nvme_status(ret); 448aaf2e048SChaitanya Kulkarni } 449aaf2e048SChaitanya Kulkarni 450aaf2e048SChaitanya Kulkarni static u16 nvmet_bdev_execute_zmgmt_send_all(struct nvmet_req *req) 451aaf2e048SChaitanya Kulkarni { 452aaf2e048SChaitanya Kulkarni int ret; 453aaf2e048SChaitanya Kulkarni 454aaf2e048SChaitanya Kulkarni switch (zsa_req_op(req->cmd->zms.zsa)) { 455aaf2e048SChaitanya Kulkarni case REQ_OP_ZONE_RESET: 456aaf2e048SChaitanya Kulkarni ret = blkdev_zone_mgmt(req->ns->bdev, REQ_OP_ZONE_RESET, 0, 457aaf2e048SChaitanya Kulkarni get_capacity(req->ns->bdev->bd_disk), 458aaf2e048SChaitanya Kulkarni GFP_KERNEL); 459aaf2e048SChaitanya Kulkarni if (ret < 0) 460aaf2e048SChaitanya Kulkarni return blkdev_zone_mgmt_errno_to_nvme_status(ret); 461aaf2e048SChaitanya Kulkarni break; 462aaf2e048SChaitanya Kulkarni case REQ_OP_ZONE_OPEN: 463aaf2e048SChaitanya Kulkarni case REQ_OP_ZONE_CLOSE: 464aaf2e048SChaitanya Kulkarni case REQ_OP_ZONE_FINISH: 465aaf2e048SChaitanya Kulkarni return nvmet_bdev_zone_mgmt_emulate_all(req); 466aaf2e048SChaitanya Kulkarni default: 467aaf2e048SChaitanya Kulkarni /* this is needed to quiet compiler warning */ 468aaf2e048SChaitanya Kulkarni req->error_loc = offsetof(struct nvme_zone_mgmt_send_cmd, zsa); 469aaf2e048SChaitanya Kulkarni return NVME_SC_INVALID_FIELD | NVME_SC_DNR; 470aaf2e048SChaitanya Kulkarni } 471aaf2e048SChaitanya Kulkarni 472aaf2e048SChaitanya Kulkarni return NVME_SC_SUCCESS; 473aaf2e048SChaitanya Kulkarni } 474aaf2e048SChaitanya Kulkarni 475aaf2e048SChaitanya Kulkarni static void nvmet_bdev_zmgmt_send_work(struct work_struct *w) 476aaf2e048SChaitanya Kulkarni { 477aaf2e048SChaitanya Kulkarni struct nvmet_req *req = container_of(w, struct nvmet_req, z.zmgmt_work); 478aaf2e048SChaitanya Kulkarni sector_t sect = nvmet_lba_to_sect(req->ns, req->cmd->zms.slba); 479ff07a02eSBart Van Assche enum req_op op = zsa_req_op(req->cmd->zms.zsa); 480aaf2e048SChaitanya Kulkarni struct block_device *bdev = req->ns->bdev; 481aaf2e048SChaitanya Kulkarni sector_t zone_sectors = bdev_zone_sectors(bdev); 482aaf2e048SChaitanya Kulkarni u16 status = NVME_SC_SUCCESS; 483aaf2e048SChaitanya Kulkarni int ret; 484aaf2e048SChaitanya Kulkarni 485aaf2e048SChaitanya Kulkarni if (op == REQ_OP_LAST) { 486aaf2e048SChaitanya Kulkarni req->error_loc = offsetof(struct nvme_zone_mgmt_send_cmd, zsa); 487aaf2e048SChaitanya Kulkarni status = NVME_SC_ZONE_INVALID_TRANSITION | NVME_SC_DNR; 488aaf2e048SChaitanya Kulkarni goto out; 489aaf2e048SChaitanya Kulkarni } 490aaf2e048SChaitanya Kulkarni 491aaf2e048SChaitanya Kulkarni /* when select all bit is set slba field is ignored */ 492aaf2e048SChaitanya Kulkarni if (req->cmd->zms.select_all) { 493aaf2e048SChaitanya Kulkarni status = nvmet_bdev_execute_zmgmt_send_all(req); 494aaf2e048SChaitanya Kulkarni goto out; 495aaf2e048SChaitanya Kulkarni } 496aaf2e048SChaitanya Kulkarni 497aaf2e048SChaitanya Kulkarni if (sect >= get_capacity(bdev->bd_disk)) { 498aaf2e048SChaitanya Kulkarni req->error_loc = offsetof(struct nvme_zone_mgmt_send_cmd, slba); 499aaf2e048SChaitanya Kulkarni status = NVME_SC_LBA_RANGE | NVME_SC_DNR; 500aaf2e048SChaitanya Kulkarni goto out; 501aaf2e048SChaitanya Kulkarni } 502aaf2e048SChaitanya Kulkarni 503aaf2e048SChaitanya Kulkarni if (sect & (zone_sectors - 1)) { 504aaf2e048SChaitanya Kulkarni req->error_loc = offsetof(struct nvme_zone_mgmt_send_cmd, slba); 505aaf2e048SChaitanya Kulkarni status = NVME_SC_INVALID_FIELD | NVME_SC_DNR; 506aaf2e048SChaitanya Kulkarni goto out; 507aaf2e048SChaitanya Kulkarni } 508aaf2e048SChaitanya Kulkarni 509aaf2e048SChaitanya Kulkarni ret = blkdev_zone_mgmt(bdev, op, sect, zone_sectors, GFP_KERNEL); 510aaf2e048SChaitanya Kulkarni if (ret < 0) 511aaf2e048SChaitanya Kulkarni status = blkdev_zone_mgmt_errno_to_nvme_status(ret); 512aaf2e048SChaitanya Kulkarni 513aaf2e048SChaitanya Kulkarni out: 514aaf2e048SChaitanya Kulkarni nvmet_req_complete(req, status); 515aaf2e048SChaitanya Kulkarni } 516aaf2e048SChaitanya Kulkarni 517aaf2e048SChaitanya Kulkarni void nvmet_bdev_execute_zone_mgmt_send(struct nvmet_req *req) 518aaf2e048SChaitanya Kulkarni { 519aaf2e048SChaitanya Kulkarni INIT_WORK(&req->z.zmgmt_work, nvmet_bdev_zmgmt_send_work); 520aaf2e048SChaitanya Kulkarni queue_work(zbd_wq, &req->z.zmgmt_work); 521aaf2e048SChaitanya Kulkarni } 522aaf2e048SChaitanya Kulkarni 523aaf2e048SChaitanya Kulkarni static void nvmet_bdev_zone_append_bio_done(struct bio *bio) 524aaf2e048SChaitanya Kulkarni { 525aaf2e048SChaitanya Kulkarni struct nvmet_req *req = bio->bi_private; 526aaf2e048SChaitanya Kulkarni 527aaf2e048SChaitanya Kulkarni if (bio->bi_status == BLK_STS_OK) { 528aaf2e048SChaitanya Kulkarni req->cqe->result.u64 = 529aaf2e048SChaitanya Kulkarni nvmet_sect_to_lba(req->ns, bio->bi_iter.bi_sector); 530aaf2e048SChaitanya Kulkarni } 531aaf2e048SChaitanya Kulkarni 532aaf2e048SChaitanya Kulkarni nvmet_req_complete(req, blk_to_nvme_status(req, bio->bi_status)); 533aaf2e048SChaitanya Kulkarni nvmet_req_bio_put(req, bio); 534aaf2e048SChaitanya Kulkarni } 535aaf2e048SChaitanya Kulkarni 536aaf2e048SChaitanya Kulkarni void nvmet_bdev_execute_zone_append(struct nvmet_req *req) 537aaf2e048SChaitanya Kulkarni { 538aaf2e048SChaitanya Kulkarni sector_t sect = nvmet_lba_to_sect(req->ns, req->cmd->rw.slba); 539a288000fSBart Van Assche const blk_opf_t opf = REQ_OP_ZONE_APPEND | REQ_SYNC | REQ_IDLE; 540aaf2e048SChaitanya Kulkarni u16 status = NVME_SC_SUCCESS; 541aaf2e048SChaitanya Kulkarni unsigned int total_len = 0; 542aaf2e048SChaitanya Kulkarni struct scatterlist *sg; 543aaf2e048SChaitanya Kulkarni struct bio *bio; 544aaf2e048SChaitanya Kulkarni int sg_cnt; 545aaf2e048SChaitanya Kulkarni 546aaf2e048SChaitanya Kulkarni /* Request is completed on len mismatch in nvmet_check_transter_len() */ 547aaf2e048SChaitanya Kulkarni if (!nvmet_check_transfer_len(req, nvmet_rw_data_len(req))) 548aaf2e048SChaitanya Kulkarni return; 549aaf2e048SChaitanya Kulkarni 550aaf2e048SChaitanya Kulkarni if (!req->sg_cnt) { 551aaf2e048SChaitanya Kulkarni nvmet_req_complete(req, 0); 552aaf2e048SChaitanya Kulkarni return; 553aaf2e048SChaitanya Kulkarni } 554aaf2e048SChaitanya Kulkarni 555aaf2e048SChaitanya Kulkarni if (sect >= get_capacity(req->ns->bdev->bd_disk)) { 556aaf2e048SChaitanya Kulkarni req->error_loc = offsetof(struct nvme_rw_command, slba); 557aaf2e048SChaitanya Kulkarni status = NVME_SC_LBA_RANGE | NVME_SC_DNR; 558aaf2e048SChaitanya Kulkarni goto out; 559aaf2e048SChaitanya Kulkarni } 560aaf2e048SChaitanya Kulkarni 561aaf2e048SChaitanya Kulkarni if (sect & (bdev_zone_sectors(req->ns->bdev) - 1)) { 562aaf2e048SChaitanya Kulkarni req->error_loc = offsetof(struct nvme_rw_command, slba); 563aaf2e048SChaitanya Kulkarni status = NVME_SC_INVALID_FIELD | NVME_SC_DNR; 564aaf2e048SChaitanya Kulkarni goto out; 565aaf2e048SChaitanya Kulkarni } 566aaf2e048SChaitanya Kulkarni 567aaf2e048SChaitanya Kulkarni if (nvmet_use_inline_bvec(req)) { 568aaf2e048SChaitanya Kulkarni bio = &req->z.inline_bio; 56949add496SChristoph Hellwig bio_init(bio, req->ns->bdev, req->inline_bvec, 570a288000fSBart Van Assche ARRAY_SIZE(req->inline_bvec), opf); 571aaf2e048SChaitanya Kulkarni } else { 572a288000fSBart Van Assche bio = bio_alloc(req->ns->bdev, req->sg_cnt, opf, GFP_KERNEL); 573aaf2e048SChaitanya Kulkarni } 574aaf2e048SChaitanya Kulkarni 575aaf2e048SChaitanya Kulkarni bio->bi_end_io = nvmet_bdev_zone_append_bio_done; 576aaf2e048SChaitanya Kulkarni bio->bi_iter.bi_sector = sect; 577aaf2e048SChaitanya Kulkarni bio->bi_private = req; 578aaf2e048SChaitanya Kulkarni if (req->cmd->rw.control & cpu_to_le16(NVME_RW_FUA)) 579aaf2e048SChaitanya Kulkarni bio->bi_opf |= REQ_FUA; 580aaf2e048SChaitanya Kulkarni 581aaf2e048SChaitanya Kulkarni for_each_sg(req->sg, sg, req->sg_cnt, sg_cnt) { 582aaf2e048SChaitanya Kulkarni struct page *p = sg_page(sg); 583aaf2e048SChaitanya Kulkarni unsigned int l = sg->length; 584aaf2e048SChaitanya Kulkarni unsigned int o = sg->offset; 585aaf2e048SChaitanya Kulkarni unsigned int ret; 586aaf2e048SChaitanya Kulkarni 587aaf2e048SChaitanya Kulkarni ret = bio_add_zone_append_page(bio, p, l, o); 588aaf2e048SChaitanya Kulkarni if (ret != sg->length) { 589aaf2e048SChaitanya Kulkarni status = NVME_SC_INTERNAL; 590aaf2e048SChaitanya Kulkarni goto out_put_bio; 591aaf2e048SChaitanya Kulkarni } 592aaf2e048SChaitanya Kulkarni total_len += sg->length; 593aaf2e048SChaitanya Kulkarni } 594aaf2e048SChaitanya Kulkarni 595aaf2e048SChaitanya Kulkarni if (total_len != nvmet_rw_data_len(req)) { 596aaf2e048SChaitanya Kulkarni status = NVME_SC_INTERNAL | NVME_SC_DNR; 597aaf2e048SChaitanya Kulkarni goto out_put_bio; 598aaf2e048SChaitanya Kulkarni } 599aaf2e048SChaitanya Kulkarni 600aaf2e048SChaitanya Kulkarni submit_bio(bio); 601aaf2e048SChaitanya Kulkarni return; 602aaf2e048SChaitanya Kulkarni 603aaf2e048SChaitanya Kulkarni out_put_bio: 604aaf2e048SChaitanya Kulkarni nvmet_req_bio_put(req, bio); 605aaf2e048SChaitanya Kulkarni out: 606aaf2e048SChaitanya Kulkarni nvmet_req_complete(req, status); 607aaf2e048SChaitanya Kulkarni } 608aaf2e048SChaitanya Kulkarni 609aaf2e048SChaitanya Kulkarni u16 nvmet_bdev_zns_parse_io_cmd(struct nvmet_req *req) 610aaf2e048SChaitanya Kulkarni { 611aaf2e048SChaitanya Kulkarni struct nvme_command *cmd = req->cmd; 612aaf2e048SChaitanya Kulkarni 613aaf2e048SChaitanya Kulkarni switch (cmd->common.opcode) { 614aaf2e048SChaitanya Kulkarni case nvme_cmd_zone_append: 615aaf2e048SChaitanya Kulkarni req->execute = nvmet_bdev_execute_zone_append; 616aaf2e048SChaitanya Kulkarni return 0; 617aaf2e048SChaitanya Kulkarni case nvme_cmd_zone_mgmt_recv: 618aaf2e048SChaitanya Kulkarni req->execute = nvmet_bdev_execute_zone_mgmt_recv; 619aaf2e048SChaitanya Kulkarni return 0; 620aaf2e048SChaitanya Kulkarni case nvme_cmd_zone_mgmt_send: 621aaf2e048SChaitanya Kulkarni req->execute = nvmet_bdev_execute_zone_mgmt_send; 622aaf2e048SChaitanya Kulkarni return 0; 623aaf2e048SChaitanya Kulkarni default: 624aaf2e048SChaitanya Kulkarni return nvmet_bdev_parse_io_cmd(req); 625aaf2e048SChaitanya Kulkarni } 626aaf2e048SChaitanya Kulkarni } 627