From patchwork Thu Nov 26 02:40:35 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chaitanya Kulkarni X-Patchwork-Id: 11932603 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9022BC64E7A for ; Thu, 26 Nov 2020 02:41:10 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 38AB0207BC for ; Thu, 26 Nov 2020 02:41:10 +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="r8gFSLjp" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732088AbgKZClC (ORCPT ); Wed, 25 Nov 2020 21:41:02 -0500 Received: from esa3.hgst.iphmx.com ([216.71.153.141]:20425 "EHLO esa3.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730809AbgKZClC (ORCPT ); Wed, 25 Nov 2020 21:41:02 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1606358461; x=1637894461; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=nbiHUyaUtN1lM/VRyvOM4VWz5z/jZqsgAj2Gp0q3iN4=; b=r8gFSLjpObTuHkKAEP0J0agB/iNIurK7HlqtCF4LY5tBGWVRlPKZLeyI pcC6z4NPu4sbLI/AveBjt7qwcE8/CvRUHP1Jc2+RF8hbJK5xw0i/CJgxI jU3T47XwRpBhqaPbxXIYetU1fN0E+JCTQG0IW3cbozNoP8DP9v3v6TuIT QQh+F7Ov2AFKiRLqwi/nR9yp7cWMxnWZrw56mgVeVvhuNZx4lUYLr3Rho 0F03DR4sWOtB/5jxgOAMstz0ZxwUvEdTdMRabh5UVEe9ns0mzBNEn9aPI udRUPIJhUkNwd1wkZjsGc47gTarCZdJRngfeyyVrUHO7bQ34vwHYE+fZI Q==; IronPort-SDR: 2oN+GLjobd4zx7hs33B2wTlW+1cCDMCC5l1zdTCkm+/iooZXHF5vpc/VXz++iIkXkuDgf1Y3Mm 1foVhD+IYbs3YiduCnBJIBoqrUu3CCOOgP87rl8Kj2i+c07qNO5siJK7/rQ9SU3l3sT4BpwrqF GrzRs/w6iw1eOEYHyEs8vMXIpv9qQHODXXnIY3xi1A/3MjimGSLObTdika0WzKheLHeM0iyxhG ohFBj9c01BW18Jfja2lTW5hEZ714+FuTpEq4Bned7kJQFhHErqk+vVmTsveXC8bUnFoGdHnWsG K4M= X-IronPort-AV: E=Sophos;i="5.78,370,1599494400"; d="scan'208";a="157983081" 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; 26 Nov 2020 10:41:01 +0800 IronPort-SDR: E5OiGdNwnRyIC+EZcyCsjUlbISmQUZCOXZM5H0EjwT7/RviSFVvC6Y6usivNaSo+rq35uMjanS yjzy6DBAfHzSwWVAftJwH2qbRCUA8PhQM= Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Nov 2020 18:25:23 -0800 IronPort-SDR: ZyEMxOWvdD8XQuA7Y526ukWDP9tbl0QoTpA+aWhZCWlxv1AvF4tvB2OK9OVNecmJu91Cw24OXG FgeDloELiWEw== WDCIronportException: Internal Received: from vm.labspan.wdc.com (HELO vm.sc.wdc.com) ([10.6.137.102]) by uls-op-cesaip02.wdc.com with ESMTP; 25 Nov 2020 18:41:01 -0800 From: Chaitanya Kulkarni To: linux-block@vger.kernel.org, linux-nvme@lists.infradead.org Cc: sagi@grimberg.me, hch@lst.de, Chaitanya Kulkarni Subject: [PATCH 1/9] block: export __bio_iov_append_get_pages() Date: Wed, 25 Nov 2020 18:40:35 -0800 Message-Id: <20201126024043.3392-2-chaitanya.kulkarni@wdc.com> X-Mailer: git-send-email 2.22.1 In-Reply-To: <20201126024043.3392-1-chaitanya.kulkarni@wdc.com> References: <20201126024043.3392-1-chaitanya.kulkarni@wdc.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org In this prep patch we exoprt the __bio_iov_append_get_pages() so that NVMeOF target can use the core logic of building Zone Append bios for REQ_OP_ZONE_APPEND without repeating the code. Signed-off-by: Chaitanya Kulkarni --- block/bio.c | 3 ++- include/linux/bio.h | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/block/bio.c b/block/bio.c index fa01bef35bb1..de356fa28315 100644 --- a/block/bio.c +++ b/block/bio.c @@ -1033,7 +1033,7 @@ static int __bio_iov_iter_get_pages(struct bio *bio, struct iov_iter *iter) return 0; } -static int __bio_iov_append_get_pages(struct bio *bio, struct iov_iter *iter) +int __bio_iov_append_get_pages(struct bio *bio, struct iov_iter *iter) { unsigned short nr_pages = bio->bi_max_vecs - bio->bi_vcnt; unsigned short entries_left = bio->bi_max_vecs - bio->bi_vcnt; @@ -1079,6 +1079,7 @@ static int __bio_iov_append_get_pages(struct bio *bio, struct iov_iter *iter) iov_iter_advance(iter, size - left); return ret; } +EXPORT_SYMBOL_GPL(__bio_iov_append_get_pages); /** * bio_iov_iter_get_pages - add user or kernel pages to a bio diff --git a/include/linux/bio.h b/include/linux/bio.h index c6d765382926..47247c1b0b85 100644 --- a/include/linux/bio.h +++ b/include/linux/bio.h @@ -446,6 +446,7 @@ bool __bio_try_merge_page(struct bio *bio, struct page *page, unsigned int len, unsigned int off, bool *same_page); void __bio_add_page(struct bio *bio, struct page *page, unsigned int len, unsigned int off); +int __bio_iov_append_get_pages(struct bio *bio, struct iov_iter *iter); int bio_iov_iter_get_pages(struct bio *bio, struct iov_iter *iter); void bio_release_pages(struct bio *bio, bool mark_dirty); extern void bio_set_pages_dirty(struct bio *bio); From patchwork Thu Nov 26 02:40:36 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chaitanya Kulkarni X-Patchwork-Id: 11932605 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6E186C56202 for ; Thu, 26 Nov 2020 02:41:17 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 00C2B206B5 for ; Thu, 26 Nov 2020 02:41:16 +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="KJbRFEix" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732416AbgKZClQ (ORCPT ); Wed, 25 Nov 2020 21:41:16 -0500 Received: from esa5.hgst.iphmx.com ([216.71.153.144]:45495 "EHLO esa5.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730809AbgKZClQ (ORCPT ); Wed, 25 Nov 2020 21:41:16 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1606358474; x=1637894474; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=Bj+OLadrv7uucl7Q6fHZQHG1Z7SFerHgqVQw5Hdo1u8=; b=KJbRFEixaJEb67vJcEI+7N62cLtxDscyuN6txVhaFqfcBlANQE1pMsyP xBNBBY9DQSMo8+fZmvSvAoSRvtsvijm3AFDowxUtovrIwlEYbOrw8t+99 QNvWGesPyvvd79KihVp6eAhpeo6Mf9ZiTdBq8HXvd1c+FIgeMC6nMjMCw pty/vBxqCBhLSyiN26pdfN9alsHLCpkMUp8fXZaHqC/MYSZ6RV2nVimby /qtX5P8NoaSV0eEyFRGXYo8INwdeQKvVLqw7jJzSyIKcSzQput+ZVnwc1 kxI8NY2SolpUTCpGoPlf8D9+WQAswg0KaS5cfw7oWPOMfFYWhTKFayvTM w==; IronPort-SDR: 7NRx/MNbLAWbDiX1rPRS41i3x2kRQSH+kzRVeur9jJ9uqG3sNUp2e665cvd2aQOpIkej0hyfid 1npKVDSxfsMSwE5BGx8j40LgnwRXJx7vZozsZmS/JeiQLQMKlfHb5eR0758igi4CkKY6M60Ktr mWBfa5rhQV3Zobq5t1cnw8E9wkSUFGdTLHvkcVvvthACM1ugQg6MaBOXEv7gs+c+BqFA0vw3tb 9GtTKouPtOIbzxp2+vDCNUaMyzbWxLWLf4fcg/upcgpq2H4T5wUnLUJ69QQbuyJCsYvnrz8oeJ aDg= X-IronPort-AV: E=Sophos;i="5.78,370,1599494400"; d="scan'208";a="153586884" Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 26 Nov 2020 10:41:14 +0800 IronPort-SDR: OsoEuUFYjXnzC5BUj89iajDnuSrJk1tzqB7kAU8T9Bjwam1ckxhWmH7MSKfpQvTkJr0xknvu3D 4TxUkM3Q3mev1CmaRPOnw258SfLjOfA60= Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Nov 2020 18:25:36 -0800 IronPort-SDR: Lsdo+gCqBB7U8I7HbmK58L0aKroRVMB9b/khpdUBm0RQn8ry35SK1L1gyV7JGOeK/J04fas6lB DGHJ+vfigRyQ== WDCIronportException: Internal Received: from vm.labspan.wdc.com (HELO vm.sc.wdc.com) ([10.6.137.102]) by uls-op-cesaip02.wdc.com with ESMTP; 25 Nov 2020 18:41:14 -0800 From: Chaitanya Kulkarni To: linux-block@vger.kernel.org, linux-nvme@lists.infradead.org Cc: sagi@grimberg.me, hch@lst.de, Chaitanya Kulkarni Subject: [PATCH 2/9] nvmet: add ZNS support for bdev-ns Date: Wed, 25 Nov 2020 18:40:36 -0800 Message-Id: <20201126024043.3392-3-chaitanya.kulkarni@wdc.com> X-Mailer: git-send-email 2.22.1 In-Reply-To: <20201126024043.3392-1-chaitanya.kulkarni@wdc.com> References: <20201126024043.3392-1-chaitanya.kulkarni@wdc.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org Add zns-bdev-config, id-ctrl, id-ns, zns-cmd-effects, zone-mgmt-send, zone-mgmt-recv and zone-append handlers for NVMeOF target to enable ZNS support for bdev. Signed-off-by: Chaitanya Kulkarni --- drivers/nvme/target/Makefile | 2 + drivers/nvme/target/admin-cmd.c | 4 +- drivers/nvme/target/io-cmd-file.c | 2 +- drivers/nvme/target/nvmet.h | 18 ++ drivers/nvme/target/zns.c | 390 ++++++++++++++++++++++++++++++ 5 files changed, 413 insertions(+), 3 deletions(-) create mode 100644 drivers/nvme/target/zns.c diff --git a/drivers/nvme/target/Makefile b/drivers/nvme/target/Makefile index ebf91fc4c72e..bc147ff2df5d 100644 --- a/drivers/nvme/target/Makefile +++ b/drivers/nvme/target/Makefile @@ -12,6 +12,8 @@ obj-$(CONFIG_NVME_TARGET_TCP) += nvmet-tcp.o nvmet-y += core.o configfs.o admin-cmd.o fabrics-cmd.o \ discovery.o io-cmd-file.o io-cmd-bdev.o nvmet-$(CONFIG_NVME_TARGET_PASSTHRU) += passthru.o +nvmet-$(CONFIG_BLK_DEV_ZONED) += zns.o + nvme-loop-y += loop.o nvmet-rdma-y += rdma.o nvmet-fc-y += fc.o diff --git a/drivers/nvme/target/admin-cmd.c b/drivers/nvme/target/admin-cmd.c index dca34489a1dc..509fd8dcca0c 100644 --- a/drivers/nvme/target/admin-cmd.c +++ b/drivers/nvme/target/admin-cmd.c @@ -579,8 +579,8 @@ static void nvmet_execute_identify_nslist(struct nvmet_req *req) nvmet_req_complete(req, status); } -static u16 nvmet_copy_ns_identifier(struct nvmet_req *req, u8 type, u8 len, - void *id, off_t *off) +u16 nvmet_copy_ns_identifier(struct nvmet_req *req, u8 type, u8 len, + void *id, off_t *off) { struct nvme_ns_id_desc desc = { .nidt = type, diff --git a/drivers/nvme/target/io-cmd-file.c b/drivers/nvme/target/io-cmd-file.c index 0abbefd9925e..2bd10960fa50 100644 --- a/drivers/nvme/target/io-cmd-file.c +++ b/drivers/nvme/target/io-cmd-file.c @@ -89,7 +89,7 @@ int nvmet_file_ns_enable(struct nvmet_ns *ns) return ret; } -static void nvmet_file_init_bvec(struct bio_vec *bv, struct scatterlist *sg) +void nvmet_file_init_bvec(struct bio_vec *bv, struct scatterlist *sg) { bv->bv_page = sg_page(sg); bv->bv_offset = sg->offset; diff --git a/drivers/nvme/target/nvmet.h b/drivers/nvme/target/nvmet.h index 592763732065..0542ba672a31 100644 --- a/drivers/nvme/target/nvmet.h +++ b/drivers/nvme/target/nvmet.h @@ -81,6 +81,9 @@ struct nvmet_ns { struct pci_dev *p2p_dev; int pi_type; int metadata_size; +#ifdef CONFIG_BLK_DEV_ZONED + struct nvme_id_ns_zns id_zns; +#endif }; static inline struct nvmet_ns *to_nvmet_ns(struct config_item *item) @@ -251,6 +254,10 @@ struct nvmet_subsys { unsigned int admin_timeout; unsigned int io_timeout; #endif /* CONFIG_NVME_TARGET_PASSTHRU */ + +#ifdef CONFIG_BLK_DEV_ZONED + struct nvme_id_ctrl_zns id_ctrl_zns; +#endif }; static inline struct nvmet_subsys *to_subsys(struct config_item *item) @@ -603,4 +610,15 @@ static inline bool nvmet_ns_has_pi(struct nvmet_ns *ns) return ns->pi_type && ns->metadata_size == sizeof(struct t10_pi_tuple); } +void nvmet_execute_identify_cns_cs_ctrl(struct nvmet_req *req); +void nvmet_execute_identify_cns_cs_ns(struct nvmet_req *req); +u16 nvmet_process_zns_cis(struct nvmet_req *req, off_t *off); +bool nvmet_bdev_zns_config(struct nvmet_ns *ns); +void nvmet_bdev_execute_zone_mgmt_recv(struct nvmet_req *req); +void nvmet_bdev_execute_zone_mgmt_send(struct nvmet_req *req); +void nvmet_bdev_execute_zone_append(struct nvmet_req *req); +void nvmet_zns_add_cmd_effects(struct nvme_effects_log *log); +u16 nvmet_copy_ns_identifier(struct nvmet_req *req, u8 type, u8 len, + void *id, off_t *off); +void nvmet_file_init_bvec(struct bio_vec *bv, struct scatterlist *sg); #endif /* _NVMET_H */ diff --git a/drivers/nvme/target/zns.c b/drivers/nvme/target/zns.c new file mode 100644 index 000000000000..8ea6641a55e3 --- /dev/null +++ b/drivers/nvme/target/zns.c @@ -0,0 +1,390 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * NVMe ZNS-ZBD command implementation. + * Copyright (c) 2020-2021 HGST, a Western Digital Company. + */ +#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt +#include +#include +#include +#include +#include "nvmet.h" + +#ifdef CONFIG_BLK_DEV_ZONED + +static u16 nvmet_bdev_zns_checks(struct nvmet_req *req) +{ + u16 status = 0; + + if (!bdev_is_zoned(req->ns->bdev)) { + status = NVME_SC_INVALID_NS | NVME_SC_DNR; + goto out; + } + + if (req->cmd->zmr.zra != NVME_ZRA_ZONE_REPORT) { + status = NVME_SC_INVALID_FIELD; + goto out; + } + + if (req->cmd->zmr.zrasf != NVME_ZRASF_ZONE_REPORT_ALL) { + status = NVME_SC_INVALID_FIELD; + goto out; + } + + if (req->cmd->zmr.pr != NVME_REPORT_ZONE_PARTIAL) + status = NVME_SC_INVALID_FIELD; +out: + return status; +} + +static struct block_device *nvmet_bdev(struct nvmet_req *req) +{ + return req->ns->bdev; +} + +static u64 nvmet_zones_to_descsize(unsigned int nr_zones) +{ + return sizeof(struct nvme_zone_report) + + (sizeof(struct nvme_zone_descriptor) * nr_zones); +} + +static inline u64 nvmet_sect_to_lba(struct nvmet_ns *ns, sector_t sect) +{ + return sect >> (ns->blksize_shift - SECTOR_SHIFT); +} + +static inline sector_t nvmet_lba_to_sect(struct nvmet_ns *ns, __le64 lba) +{ + return le64_to_cpu(lba) << (ns->blksize_shift - SECTOR_SHIFT); +} + +/* + * ZNS related command implementation and helprs. + */ + +u16 nvmet_process_zns_cis(struct nvmet_req *req, off_t *off) +{ + u16 nvme_cis_zns = NVME_CSI_ZNS; + + if (bdev_is_zoned(nvmet_bdev(req))) { + return nvmet_copy_ns_identifier(req, NVME_NIDT_CSI, + NVME_NIDT_CSI_LEN, + &nvme_cis_zns, off); + } + + return NVME_SC_SUCCESS; +} + +void nvmet_zns_add_cmd_effects(struct nvme_effects_log *log) +{ + log->iocs[nvme_cmd_zone_append] = cpu_to_le32(1 << 0); + log->iocs[nvme_cmd_zone_mgmt_send] = cpu_to_le32(1 << 0); + log->iocs[nvme_cmd_zone_mgmt_recv] = cpu_to_le32(1 << 0); +} + +bool nvmet_bdev_zns_config(struct nvmet_ns *ns) +{ + if (ns->bdev->bd_disk->queue->conv_zones_bitmap) { + pr_err("block device with conventional zones not supported."); + return false; + } + /* + * SMR drives will results in error if writes are not aligned to the + * physical block size just override. + */ + ns->blksize_shift = blksize_bits(bdev_physical_block_size(ns->bdev)); + return true; +} + +static int nvmet_bdev_report_zone_cb(struct blk_zone *zone, unsigned int idx, + void *data) +{ + struct blk_zone *zones = data; + + memcpy(&zones[idx], zone, sizeof(struct blk_zone)); + + return 0; +} + +static void nvmet_get_zone_desc(struct nvmet_ns *ns, struct blk_zone *z, + struct nvme_zone_descriptor *rz) +{ + rz->zcap = cpu_to_le64(nvmet_sect_to_lba(ns, z->capacity)); + rz->zslba = cpu_to_le64(nvmet_sect_to_lba(ns, z->start)); + rz->wp = cpu_to_le64(nvmet_sect_to_lba(ns, z->wp)); + rz->za = z->reset ? 1 << 2 : 0; + rz->zt = z->type; + rz->zs = z->cond << 4; +} + +/* + * ZNS related Admin and I/O command handlers. + */ +void nvmet_execute_identify_cns_cs_ctrl(struct nvmet_req *req) +{ + struct nvme_id_ctrl_zns *id; + u16 status = 0; + + id = kzalloc(sizeof(*id), GFP_KERNEL); + if (!id) { + status = NVME_SC_INTERNAL; + goto out; + } + + /* + * Even though this function sets Zone Append Size Limit to 0, + * the 0 value here indicates that the maximum data transfer size for + * the Zone Append command is indicated by the ctrl + * Maximum Data Transfer Size (MDTS). + */ + id->zasl = 0; + + status = nvmet_copy_to_sgl(req, 0, id, sizeof(*id)); + + kfree(id); +out: + nvmet_req_complete(req, status); +} + +void nvmet_execute_identify_cns_cs_ns(struct nvmet_req *req) +{ + struct nvme_id_ns_zns *id_zns; + u16 status = 0; + u64 zsze; + + if (le32_to_cpu(req->cmd->identify.nsid) == NVME_NSID_ALL) { + req->error_loc = offsetof(struct nvme_identify, nsid); + status = NVME_SC_INVALID_NS | NVME_SC_DNR; + goto out; + } + + id_zns = kzalloc(sizeof(*id_zns), GFP_KERNEL); + if (!id_zns) { + status = NVME_SC_INTERNAL; + goto out; + } + + req->ns = nvmet_find_namespace(req->sq->ctrl, req->cmd->identify.nsid); + if (!req->ns) { + status = NVME_SC_INTERNAL; + goto done; + } + + if (!bdev_is_zoned(nvmet_bdev(req))) { + req->error_loc = offsetof(struct nvme_identify, nsid); + status = NVME_SC_INVALID_NS | NVME_SC_DNR; + goto done; + } + + nvmet_ns_revalidate(req->ns); + zsze = (bdev_zone_sectors(nvmet_bdev(req)) << 9) >> + req->ns->blksize_shift; + id_zns->lbafe[0].zsze = cpu_to_le64(zsze); + id_zns->mor = cpu_to_le32(bdev_max_open_zones(nvmet_bdev(req))); + id_zns->mar = cpu_to_le32(bdev_max_active_zones(nvmet_bdev(req))); + +done: + status = nvmet_copy_to_sgl(req, 0, id_zns, sizeof(*id_zns)); + kfree(id_zns); +out: + nvmet_req_complete(req, status); +} + +void nvmet_bdev_execute_zone_mgmt_recv(struct nvmet_req *req) +{ + struct request_queue *q = nvmet_bdev(req)->bd_disk->queue; + struct nvme_zone_mgmt_recv_cmd *zmr = &req->cmd->zmr; + unsigned int nz = blk_queue_nr_zones(q); + u64 bufsize = (zmr->numd << 2) + 1; + struct nvme_zone_report *rz; + struct blk_zone *zones; + int reported_zones; + sector_t sect; + u64 desc_size; + u16 status; + int i; + + desc_size = nvmet_zones_to_descsize(blk_queue_nr_zones(q)); + status = nvmet_bdev_zns_checks(req); + if (status) + goto out; + + zones = kvcalloc(blkdev_nr_zones(nvmet_bdev(req)->bd_disk), + sizeof(struct blk_zone), GFP_KERNEL); + if (!zones) { + status = NVME_SC_INTERNAL; + goto out; + } + + rz = __vmalloc(bufsize, GFP_KERNEL | __GFP_NORETRY); + if (!rz) { + status = NVME_SC_INTERNAL; + goto out_free_zones; + } + + sect = nvmet_lba_to_sect(req->ns, le64_to_cpu(req->cmd->zmr.slba)); + + for (nz = blk_queue_nr_zones(q); desc_size >= bufsize; nz--) + desc_size = nvmet_zones_to_descsize(nz); + + reported_zones = blkdev_report_zones(nvmet_bdev(req), sect, nz, + nvmet_bdev_report_zone_cb, + zones); + if (reported_zones < 0) { + status = NVME_SC_INTERNAL; + goto out_free_report_zones; + } + + rz->nr_zones = cpu_to_le64(reported_zones); + for (i = 0; i < reported_zones; i++) + nvmet_get_zone_desc(req->ns, &zones[i], &rz->entries[i]); + + status = nvmet_copy_to_sgl(req, 0, rz, bufsize); + +out_free_report_zones: + kvfree(rz); +out_free_zones: + kvfree(zones); +out: + nvmet_req_complete(req, status); +} + +void nvmet_bdev_execute_zone_mgmt_send(struct nvmet_req *req) +{ + sector_t nr_sect = bdev_zone_sectors(nvmet_bdev(req)); + struct nvme_zone_mgmt_send_cmd *c = &req->cmd->zms; + u16 status = NVME_SC_SUCCESS; + enum req_opf op; + sector_t sect; + int ret; + + sect = nvmet_lba_to_sect(req->ns, le64_to_cpu(req->cmd->zms.slba)); + + switch (c->zsa) { + case NVME_ZONE_OPEN: + op = REQ_OP_ZONE_OPEN; + break; + case NVME_ZONE_CLOSE: + op = REQ_OP_ZONE_CLOSE; + break; + case NVME_ZONE_FINISH: + op = REQ_OP_ZONE_FINISH; + break; + case NVME_ZONE_RESET: + if (c->select_all) + nr_sect = get_capacity(nvmet_bdev(req)->bd_disk); + op = REQ_OP_ZONE_RESET; + break; + default: + status = NVME_SC_INVALID_FIELD; + break; + } + + ret = blkdev_zone_mgmt(nvmet_bdev(req), op, sect, nr_sect, GFP_KERNEL); + if (ret) + status = NVME_SC_INTERNAL; + + nvmet_req_complete(req, status); +} + +void nvmet_bdev_execute_zone_append(struct nvmet_req *req) +{ + unsigned long bv_cnt = min(req->sg_cnt, BIO_MAX_PAGES); + int op = REQ_OP_ZONE_APPEND | REQ_SYNC | REQ_IDLE; + u64 slba = le64_to_cpu(req->cmd->rw.slba); + sector_t sect = nvmet_lba_to_sect(req->ns, slba); + u16 status = NVME_SC_SUCCESS; + int sg_cnt = req->sg_cnt; + struct scatterlist *sg; + size_t mapped_data_len; + struct iov_iter from; + struct bio_vec *bvec; + size_t mapped_cnt; + size_t io_len = 0; + struct bio *bio; + int ret; + + if (!nvmet_check_transfer_len(req, nvmet_rw_data_len(req))) + return; + + if (!req->sg_cnt) { + nvmet_req_complete(req, 0); + return; + } + + bvec = kmalloc_array(bv_cnt, sizeof(*bvec), GFP_KERNEL); + if (!bvec) { + status = NVME_SC_INTERNAL; + goto out; + } + + while (sg_cnt) { + mapped_data_len = 0; + for_each_sg(req->sg, sg, req->sg_cnt, mapped_cnt) { + nvmet_file_init_bvec(bvec, sg); + mapped_data_len += bvec[mapped_cnt].bv_len; + sg_cnt--; + if (mapped_cnt == bv_cnt) + break; + } + iov_iter_bvec(&from, WRITE, bvec, mapped_cnt, mapped_data_len); + + bio = bio_alloc(GFP_KERNEL, bv_cnt); + bio_set_dev(bio, nvmet_bdev(req)); + bio->bi_iter.bi_sector = sect; + bio->bi_opf = op; + + ret = __bio_iov_append_get_pages(bio, &from); + if (unlikely(ret)) { + status = NVME_SC_INTERNAL; + bio_io_error(bio); + kfree(bvec); + goto out; + } + + ret = submit_bio_wait(bio); + bio_put(bio); + if (ret < 0) { + status = NVME_SC_INTERNAL; + break; + } + + io_len += mapped_data_len; + } + + sect += (io_len >> 9); + req->cqe->result.u64 = le64_to_cpu(nvmet_sect_to_lba(req->ns, sect)); + kfree(bvec); + +out: + nvmet_req_complete(req, status); +} + +#else /* CONFIG_BLK_DEV_ZONED */ +static void nvmet_execute_identify_cns_cs_ctrl(struct nvmet_req *req) +{ +} +static void nvmet_execute_identify_cns_cs_ns(struct nvmet_req *req) +{ +} +u16 nvmet_process_zns_cis(struct nvmet_req *req, off_t *off) +{ + return 0; +} +static bool nvmet_bdev_zns_config(struct nvmet_ns *ns) +{ + return false; +} +void nvmet_bdev_execute_zone_mgmt_recv(struct nvmet_req *req) +{ +} +void nvmet_bdev_execute_zone_mgmt_send(struct nvmet_req *req) +{ +} +void nvmet_bdev_execute_zone_append(struct nvmet_req *req) +{ +} +void nvmet_zns_add_cmd_effects(struct nvme_effects_log *log) +{ +} +#endif /* CONFIG_BLK_DEV_ZONED */ From patchwork Thu Nov 26 02:40:37 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chaitanya Kulkarni X-Patchwork-Id: 11932607 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2D285C56202 for ; Thu, 26 Nov 2020 02:41:24 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C8DCB207BC for ; Thu, 26 Nov 2020 02:41:23 +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="OWcCyhoZ" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732766AbgKZClX (ORCPT ); Wed, 25 Nov 2020 21:41:23 -0500 Received: from esa4.hgst.iphmx.com ([216.71.154.42]:32149 "EHLO esa4.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732733AbgKZClW (ORCPT ); Wed, 25 Nov 2020 21:41:22 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1606358482; x=1637894482; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=AZ0ASPEdFnz/BJCpcrFT1z2buOCvE1xQZBqdQG2WuUM=; b=OWcCyhoZ418q4EbJpjRMLtAcB/neZD58/tsT1s76UL8Xw87mkSiFLx7F S3EhauNRgNoTcUJRGNwphirbrCKPY9h7Dqi+MvxQ5pa1hwYrj14OxnRrE p4S+A6WgqH7dPZMVVgKCpxIXWgQbkESsVqmFa/93igpLOMk6z2LCBIRGe auFx2++UtzK+yJmozFqBYOpE/fGBwO5KAxyEYicmu1BOF49UXHyg52T0B uyhVrAVDdhS4zbh8aW6BVRKTUQMobNS9QAsE50TIvumv1kAX7vtmPrNor d3iWYv5jy4oYHLV/exmQxyDO0lzpr68mV0vyLPJSCoIar01A1iNymVxzj Q==; IronPort-SDR: Nm41yd8qsMWjBBd06TGwf1LHfNJbmpLwtfs3owEgys5CEloc90tgRoKoxPVUsuDO3Z/Ls4GM4+ TspTSy4qKUfv7JPA0Vs8oDX5EBwK8jco0sN8CDutGKQVsSO52IkMIHQ0qTvFRvqPztWaq1Qiye oeEv7GkNO6smAh6+x+K8v7t7Ml0JBX5WvF4GltPusFnV95PZFknLdacglhoqDKQ2sZbJiaeu3A 4bFgqLTZlmKPIGKpIHbmupu2e1C0Fl4Do6otPkqbQU5jc+oGAOuTgIf3IAFTNqgns4/e2UkzgD UoQ= X-IronPort-AV: E=Sophos;i="5.78,370,1599494400"; d="scan'208";a="153445796" Received: from uls-op-cesaip01.wdc.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 26 Nov 2020 10:41:22 +0800 IronPort-SDR: 0EGGiQuuWz/x3X+U8noF/df0NtuUtSGegwpA/ww1O7rsFYP5Bp2narDarz5BEl/AbrbVpIs908 C1Sx1BJSB/YOcC0PRq1ojcMBu5+em7/ns= Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Nov 2020 18:27:04 -0800 IronPort-SDR: 6M/AGqqa8B8wT+HwqCGGNoUVwG/Vvh+SMKOzt3MgE0GbfsWhRRM+Vg2DtFwiAPAKEgXcQ27FEO Z4EcVAAbeCNw== WDCIronportException: Internal Received: from vm.labspan.wdc.com (HELO vm.sc.wdc.com) ([10.6.137.102]) by uls-op-cesaip02.wdc.com with ESMTP; 25 Nov 2020 18:41:22 -0800 From: Chaitanya Kulkarni To: linux-block@vger.kernel.org, linux-nvme@lists.infradead.org Cc: sagi@grimberg.me, hch@lst.de, Chaitanya Kulkarni Subject: [PATCH 3/9] nvmet: trim down id-desclist to use req->ns Date: Wed, 25 Nov 2020 18:40:37 -0800 Message-Id: <20201126024043.3392-4-chaitanya.kulkarni@wdc.com> X-Mailer: git-send-email 2.22.1 In-Reply-To: <20201126024043.3392-1-chaitanya.kulkarni@wdc.com> References: <20201126024043.3392-1-chaitanya.kulkarni@wdc.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org In this prep patch we remove the extra local variable struct nvmet_ns in nvmet_execute_identify_desclist() since req already has the member that can be reused, this also eliminates the explicit call to nvmet_put_namespace() which is already present in the request completion path. This reduces the arguments to the function in the following patch to implement the ZNS for bdev-ns so we can get away with passing the req argument instead of req and ns. Signed-off-by: Chaitanya Kulkarni --- drivers/nvme/target/admin-cmd.c | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/drivers/nvme/target/admin-cmd.c b/drivers/nvme/target/admin-cmd.c index 509fd8dcca0c..c64b40c631e0 100644 --- a/drivers/nvme/target/admin-cmd.c +++ b/drivers/nvme/target/admin-cmd.c @@ -603,37 +603,35 @@ u16 nvmet_copy_ns_identifier(struct nvmet_req *req, u8 type, u8 len, static void nvmet_execute_identify_desclist(struct nvmet_req *req) { - struct nvmet_ns *ns; u16 status = 0; off_t off = 0; - ns = nvmet_find_namespace(req->sq->ctrl, req->cmd->identify.nsid); - if (!ns) { + req->ns = nvmet_find_namespace(req->sq->ctrl, req->cmd->identify.nsid); + if (!req->ns) { req->error_loc = offsetof(struct nvme_identify, nsid); status = NVME_SC_INVALID_NS | NVME_SC_DNR; goto out; } - if (memchr_inv(&ns->uuid, 0, sizeof(ns->uuid))) { + if (memchr_inv(&req->ns->uuid, 0, sizeof(req->ns->uuid))) { status = nvmet_copy_ns_identifier(req, NVME_NIDT_UUID, NVME_NIDT_UUID_LEN, - &ns->uuid, &off); + &req->ns->uuid, &off); if (status) - goto out_put_ns; + goto out; } - if (memchr_inv(ns->nguid, 0, sizeof(ns->nguid))) { + if (memchr_inv(req->ns->nguid, 0, sizeof(req->ns->nguid))) { status = nvmet_copy_ns_identifier(req, NVME_NIDT_NGUID, NVME_NIDT_NGUID_LEN, - &ns->nguid, &off); + &req->ns->nguid, &off); if (status) - goto out_put_ns; + goto out; } if (sg_zero_buffer(req->sg, req->sg_cnt, NVME_IDENTIFY_DATA_SIZE - off, off) != NVME_IDENTIFY_DATA_SIZE - off) status = NVME_SC_INTERNAL | NVME_SC_DNR; -out_put_ns: - nvmet_put_namespace(ns); + out: nvmet_req_complete(req, status); } From patchwork Thu Nov 26 02:40:38 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Chaitanya Kulkarni X-Patchwork-Id: 11932609 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8E213C56202 for ; Thu, 26 Nov 2020 02:41:33 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3558B206C0 for ; Thu, 26 Nov 2020 02:41:33 +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="RMhGWu22" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732613AbgKZClc (ORCPT ); Wed, 25 Nov 2020 21:41:32 -0500 Received: from esa1.hgst.iphmx.com ([68.232.141.245]:36141 "EHLO esa1.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732531AbgKZClc (ORCPT ); Wed, 25 Nov 2020 21:41:32 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1606358491; x=1637894491; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=hpoI1V55y5gwFhJlJIS3F+nAY0E41Z5thazQ0M5y7lA=; b=RMhGWu22i/AYkX9LAz6ixHcFMI+klOKOrn83dfVnWFAj11R5qeGzm94p 4+YHyqSbv5/AOlUJZaV0FDaBEUQgjmfs6eVtMmuj+WhIejrtckml1Vrid YqTvH1c+k+OCHanb46Xciv0cX7pwi4FCQrR1SWGCpNMDrcjlYPiqeYKk9 Otv11MMWfrfK8ZkEEJPqFTsQBKODL8ZY/j/fVmNwlWxXuRTY0qhufqdqk WIMqScxgrUvZ4KV9g4nRIu/HEUOMqMxkyrfWFVqe8S5smpTReeh+2aZ40 Sm6KZk3bpvHlmo+WH5cSGAxWfchlObq72KovWOf4MmsfPUdzVGxR/0cvH g==; IronPort-SDR: pK/P8cy2BIy6OeUmIxooW/baixnxk2YGEo+gYjXN9PEzYMBqG0uV8ewPisvR/AYkrLvk+t2dN3 LJlhPns8317lPgAA7D7hWsa0avQHErc3rE4QF4Ky4TGeJONpsa4fzgmk7h3ELGyDas3nKxEC8+ Not+Yy+1izwzj+2nNEX+HXXP8A6Ka5GEjzRQ0WJ7m/vl0ckP0EfrVcA+GsdgFo7dj9kzFXW8QC N4n9pIrlcOKjVUFQc1cxjb8iwbb8BN+awZhivftsbvZw9RSHid+8DAuY5MdcoHw8tEj4wgVJCt /lU= X-IronPort-AV: E=Sophos;i="5.78,370,1599494400"; d="scan'208";a="263593234" Received: from uls-op-cesaip01.wdc.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 26 Nov 2020 10:41:31 +0800 IronPort-SDR: rNrbwv/6lfpqn6nOancJ0UOGNS2QXapSim5Q5UHit6Ay/u9t4sTwI1ZNZOU/q0vSsqFadJegEh 89OXjVxtvMGIam/VH+H9D8JJ1k6u7jdYY= Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Nov 2020 18:27:14 -0800 IronPort-SDR: enmtt+Or6DoLJmp0NbpiS6ndWSSk5cAWh1INEVyXm5F8/n67xcFYFIRYGcCIFMEyViN0V8xMdi 0oc8SJcSF1DA== WDCIronportException: Internal Received: from vm.labspan.wdc.com (HELO vm.sc.wdc.com) ([10.6.137.102]) by uls-op-cesaip02.wdc.com with ESMTP; 25 Nov 2020 18:41:31 -0800 From: Chaitanya Kulkarni To: linux-block@vger.kernel.org, linux-nvme@lists.infradead.org Cc: sagi@grimberg.me, hch@lst.de, Chaitanya Kulkarni Subject: [PATCH 4/9] nvmet: add NVME_CSI_ZNS in ns-desc for zbdev Date: Wed, 25 Nov 2020 18:40:38 -0800 Message-Id: <20201126024043.3392-5-chaitanya.kulkarni@wdc.com> X-Mailer: git-send-email 2.22.1 In-Reply-To: <20201126024043.3392-1-chaitanya.kulkarni@wdc.com> References: <20201126024043.3392-1-chaitanya.kulkarni@wdc.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org When discovering the ZNS, the host-side looks for the NVME_CSI_ZNS value in the ns-desc. Update the nvmet_execute_identify_desclist() such that it can now update the ns-desc with NVME_CSI_ZNS if bdev is zoned. Signed-off-by: Chaitanya Kulkarni --- drivers/nvme/target/admin-cmd.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/nvme/target/admin-cmd.c b/drivers/nvme/target/admin-cmd.c index c64b40c631e0..d4fc1bb1a318 100644 --- a/drivers/nvme/target/admin-cmd.c +++ b/drivers/nvme/target/admin-cmd.c @@ -628,6 +628,10 @@ static void nvmet_execute_identify_desclist(struct nvmet_req *req) goto out; } + status = nvmet_process_zns_cis(req, &off); + if (status) + goto out; + if (sg_zero_buffer(req->sg, req->sg_cnt, NVME_IDENTIFY_DATA_SIZE - off, off) != NVME_IDENTIFY_DATA_SIZE - off) status = NVME_SC_INTERNAL | NVME_SC_DNR; From patchwork Thu Nov 26 02:40:39 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chaitanya Kulkarni X-Patchwork-Id: 11932611 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 43AB9C56201 for ; Thu, 26 Nov 2020 02:41:41 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id F3ADE206C0 for ; Thu, 26 Nov 2020 02:41:40 +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="XE+SdTKy" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732531AbgKZClk (ORCPT ); Wed, 25 Nov 2020 21:41:40 -0500 Received: from esa3.hgst.iphmx.com ([216.71.153.141]:20484 "EHLO esa3.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730809AbgKZClk (ORCPT ); Wed, 25 Nov 2020 21:41:40 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1606358499; x=1637894499; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=+iv8i8xvGTKjTFiSy9i/jgbNCBRhvNbZSotD5vVTWDc=; b=XE+SdTKylP+W4dvPQIPWVm2X/afHnaSIliU/AuCEcPW/4Wz+PNOP2TcZ FiDDGASsK1MCygbSyKDsUTbhL67zq2IJU/U5es44MaoWLaiS0PpXRHal2 BPiZM9Xq+TrOxql0k89/73054ALUlV4GOc6HefCQItL9UiNKUEg0Z2F0A rqXQvgc7uX9tpPSEd7Tbw+Cw1rIkNzt9RMKKja6uVY5REzBdYPpxvWMTV 2YNqKENwXflFidPfMEAjzjNoIh5Zp68Q4cpoIl26XA9TgAKQBFE+1Bmcp JS+JNIvnp+iXMAAxVhUFHEG/X+PqAuOHmNl06EAtATO5S1Slpm5akb7SL g==; IronPort-SDR: 6D9GnFGZLJfBrmFN7IW5q5mEtrYEwr9mUmaUDoCbyLs4rSXpyqBDTWGZEysHVo6MBkrug7NbMF zRmZx4/U24Mc+3OqoykDnai7eMpI8+jj+rvJSG4tRGKLPPGhJWUtsdAd96Bmy3Jwq4HHqgHTpg SRtEwvPj3BTNvUBGZZB61JlTP9btSy24tSnLOtKWg/4+nS56DyhcImTqvnIdQ/9R0yBq7CUIEu KhMFNFAW8ulBKoprxAT4ifEOpPZN947y6CWxyV0JpdWGzeaZHf/mYnr5hJhiBt1MTXdEyX/z+I 3OU= X-IronPort-AV: E=Sophos;i="5.78,370,1599494400"; d="scan'208";a="157983135" Received: from h199-255-45-14.hgst.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 26 Nov 2020 10:41:39 +0800 IronPort-SDR: guL9Z+4mtRBQ/AX5M7YVcL0LrLSBleJA+X5MaEH2+oLSx+3bCQa2un6IHL2lOoDDgeEDeoMjXJ nuikTfOw5bAcAjv7MifmHO/4mifZiXXVA= Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Nov 2020 18:27:21 -0800 IronPort-SDR: gZMRNQ2cNMFz1CREp9nYzKUzsorrmFdbbsr9pGLbBkjJO79U8qt5N5saEET0FYQ9oODFC1IVYl NZyXdF/lcCmQ== WDCIronportException: Internal Received: from vm.labspan.wdc.com (HELO vm.sc.wdc.com) ([10.6.137.102]) by uls-op-cesaip02.wdc.com with ESMTP; 25 Nov 2020 18:41:39 -0800 From: Chaitanya Kulkarni To: linux-block@vger.kernel.org, linux-nvme@lists.infradead.org Cc: sagi@grimberg.me, hch@lst.de, Chaitanya Kulkarni Subject: [PATCH 5/9] nvmet: add cns-cs-ctrl in id-ctrl for ZNS bdev Date: Wed, 25 Nov 2020 18:40:39 -0800 Message-Id: <20201126024043.3392-6-chaitanya.kulkarni@wdc.com> X-Mailer: git-send-email 2.22.1 In-Reply-To: <20201126024043.3392-1-chaitanya.kulkarni@wdc.com> References: <20201126024043.3392-1-chaitanya.kulkarni@wdc.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org Update the nvmet_execute_identify() such that it can now handle NVME_ID_CNS_CS_CTRL when identify.cis is set to ZNS. This allows host to identify the support for ZNS. Signed-off-by: Chaitanya Kulkarni --- drivers/nvme/target/admin-cmd.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/nvme/target/admin-cmd.c b/drivers/nvme/target/admin-cmd.c index d4fc1bb1a318..e7d2b96cda6b 100644 --- a/drivers/nvme/target/admin-cmd.c +++ b/drivers/nvme/target/admin-cmd.c @@ -650,6 +650,10 @@ static void nvmet_execute_identify(struct nvmet_req *req) return nvmet_execute_identify_ns(req); case NVME_ID_CNS_CTRL: return nvmet_execute_identify_ctrl(req); + case NVME_ID_CNS_CS_CTRL: + if (req->cmd->identify.csi == NVME_CSI_ZNS) + return nvmet_execute_identify_cns_cs_ctrl(req); + break; case NVME_ID_CNS_NS_ACTIVE_LIST: return nvmet_execute_identify_nslist(req); case NVME_ID_CNS_NS_DESC_LIST: From patchwork Thu Nov 26 02:40:40 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chaitanya Kulkarni X-Patchwork-Id: 11932613 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4AFAFC56201 for ; Thu, 26 Nov 2020 02:41:49 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id EB177206C0 for ; Thu, 26 Nov 2020 02:41: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="RLsKpijx" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732814AbgKZCls (ORCPT ); Wed, 25 Nov 2020 21:41:48 -0500 Received: from esa4.hgst.iphmx.com ([216.71.154.42]:32166 "EHLO esa4.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732808AbgKZCls (ORCPT ); Wed, 25 Nov 2020 21:41:48 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1606358507; x=1637894507; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=m/bvl+lK7ll6HRYiQ0kG1ndR5SFePuzrxfzuz5g9atQ=; b=RLsKpijxeoWaCjPEJqwuwUcZWiNLLreRm42sdMgesQ0xmNRo1J5PejFu tSlwJp4l2n6LEXpojuK2BFaLga2EmBR7WPr5eGA6Q2R8O2ntD6YreL1HH 7Pglrb4kecQkyKnYhZ6yDfgkqsebhZgUF+CLdpkag9CsIv1do08Fslbyg Z4pePU1DnvVKvdVaGem6dyVZc01hv3nZgfOjgD+Lzx0JQMXWYiTnjqaGB yG3k791lL6xT1OBuV9Esi7E594p+jiaURQU4iSnqfGkm2rpzKcxTrZj/u K8nsCaWgZj4HTDLsLgo5C7oWXUoqLFDnElKKY0t1gggHvsSbcb+id3UBK w==; IronPort-SDR: atUXOjgOc+XeNH3a4uwaT8W47/4Od4jlUYNSTs1zdl/stiqECLDfFUTsfGS+jzHboUVl68Ixy+ NgupnI//zLtKVCcQ+qxXrNSx0tvMs0bIQm7Tqq4d7lnEDEUNUuSTXCfdb02Mj8il2eKJ5S2Nt7 9LlgokzPveQISz6DoYmQLrHn87o/aKvQi6YrSsz7XjyiIZAnyt56mTPLAtlLNYu2GLy3uv+kvi 0Nz70g0RLeE50fNumYcxx176//ouZFCCYrr9wef3GkQaG4nmdVxODIDTqjY2aHSm5kWpIbc85l GZg= X-IronPort-AV: E=Sophos;i="5.78,370,1599494400"; d="scan'208";a="153445815" Received: from uls-op-cesaip01.wdc.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 26 Nov 2020 10:41:47 +0800 IronPort-SDR: GPqklYS4MhXPtuFScMcMrlLheJHOKS+ztswqH/HCKAIeUS4KASJ3mjXqDAgTDzPTCW+AaYmyyn C+a6BD9zgnGmAdaq6sANjDXFZE8tg9Vog= Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Nov 2020 18:27:29 -0800 IronPort-SDR: +iWkemWLEus9/qEDz+arSjP994rS0injMOm4Whacc+3WhZcSMUYFyUUIhPFKqwO10GgcjboJCV 6FfkLyZHkgLQ== WDCIronportException: Internal Received: from vm.labspan.wdc.com (HELO vm.sc.wdc.com) ([10.6.137.102]) by uls-op-cesaip02.wdc.com with ESMTP; 25 Nov 2020 18:41:47 -0800 From: Chaitanya Kulkarni To: linux-block@vger.kernel.org, linux-nvme@lists.infradead.org Cc: sagi@grimberg.me, hch@lst.de, Chaitanya Kulkarni Subject: [PATCH 6/9] nvmet: add cns-cs-ns in id-ctrl for ZNS bdev Date: Wed, 25 Nov 2020 18:40:40 -0800 Message-Id: <20201126024043.3392-7-chaitanya.kulkarni@wdc.com> X-Mailer: git-send-email 2.22.1 In-Reply-To: <20201126024043.3392-1-chaitanya.kulkarni@wdc.com> References: <20201126024043.3392-1-chaitanya.kulkarni@wdc.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org Update the nvmet_execute_identify() such that it can now handle NVME_ID_CNS_CS_NS when identify.cis is set to ZNS. This allows host to identify the ns with ZNS capabilities. Signed-off-by: Chaitanya Kulkarni --- drivers/nvme/target/admin-cmd.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/nvme/target/admin-cmd.c b/drivers/nvme/target/admin-cmd.c index e7d2b96cda6b..cd368cbe3855 100644 --- a/drivers/nvme/target/admin-cmd.c +++ b/drivers/nvme/target/admin-cmd.c @@ -648,6 +648,10 @@ static void nvmet_execute_identify(struct nvmet_req *req) switch (req->cmd->identify.cns) { case NVME_ID_CNS_NS: return nvmet_execute_identify_ns(req); + case NVME_ID_CNS_CS_NS: + if (req->cmd->identify.csi == NVME_CSI_ZNS) + return nvmet_execute_identify_cns_cs_ns(req); + break; case NVME_ID_CNS_CTRL: return nvmet_execute_identify_ctrl(req); case NVME_ID_CNS_CS_CTRL: From patchwork Thu Nov 26 02:40:41 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chaitanya Kulkarni X-Patchwork-Id: 11932615 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D1BE4C56202 for ; Thu, 26 Nov 2020 02:41:57 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 80DBC207BC for ; Thu, 26 Nov 2020 02:41:57 +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="AbymjKwb" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732885AbgKZCl4 (ORCPT ); Wed, 25 Nov 2020 21:41:56 -0500 Received: from esa5.hgst.iphmx.com ([216.71.153.144]:45550 "EHLO esa5.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732808AbgKZCl4 (ORCPT ); Wed, 25 Nov 2020 21:41:56 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1606358516; x=1637894516; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=hUhzJ651cVoNvniIQeg3wff/FCoz1DE77FDFCSJt0Zk=; b=AbymjKwbriq99Wl5+l3BtZxFiC5rdvEl1/51whE2+r2BFhQp9pfjClop pXdOdP2Uv4O+P5IvhpTrVe2iMAtPTTSlcggugWxsA2Lt6APuwJFbaLQf/ obK3VW3vIEa2P5McV9XFDPZcRtJsZwr8g2etuQZurBVmz/y/bSALXyxGI Rl0N90rBLcw4CEfjPjJ/1KIq1Lao4v7Z1EQoDzKj1ibqEGPzX/rzjRt/R S8RK8GhPg3xVCgOhMJq2T7FDQtJM9rp8UHd5WRZIIvgYXtAlVrpS2UOC9 xWoGPvbkc+N++upAVsljkGEun7T5dOilnO9garjLq1nJO8lWbtG23ZKQq A==; IronPort-SDR: 4ZyCK2pCEC3NuGoZq4GDMfasXQaAjrT26tbqjD7pQM6AHxOTYacSsqApYJD8ZqcxrBD7oCjnU6 EKEr7/MW2eR0uSPDemthjIDFHpUT9a2rY0WfZKM9Xg/jsmcLiDZOrPCiTi7dk19kTEJZiphakS 8vccOaB+UiX0zgl5zWuPG+E2OR3tL45qv37KmVP+8U0iFvl18x3Yc0+G6Zo7RR8vP+EqmuLBR2 nYqOqqFlX5Awytm53RbtDsPEYFVgvLNNUIY+QmPyRXbS24+ZH7YA7m889rvotJAaHSuV3TJdT1 DGM= X-IronPort-AV: E=Sophos;i="5.78,370,1599494400"; d="scan'208";a="153586939" Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 26 Nov 2020 10:41:56 +0800 IronPort-SDR: Cpz6QEw6r6NLt9JC8Q93CW12ac8EfdCpijyexasu0m3+a3zj0L+uWNV6HYMZlq1g6jiEWt4CeD CYH2C4Mx2fC6ZlaX4mZslSZZqyW4lydxM= Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Nov 2020 18:26:18 -0800 IronPort-SDR: OQvfIqn9EiwcYC7awggW4nUlJ1jJ8l8UvELmdegT05BX7QVx4OJyNRt0t/Ln3dOxKG4z0K6RKU OXzggKKmNl7Q== WDCIronportException: Internal Received: from vm.labspan.wdc.com (HELO vm.sc.wdc.com) ([10.6.137.102]) by uls-op-cesaip02.wdc.com with ESMTP; 25 Nov 2020 18:41:55 -0800 From: Chaitanya Kulkarni To: linux-block@vger.kernel.org, linux-nvme@lists.infradead.org Cc: sagi@grimberg.me, hch@lst.de, Chaitanya Kulkarni Subject: [PATCH 7/9] nvmet: add zns cmd effects to support zbdev Date: Wed, 25 Nov 2020 18:40:41 -0800 Message-Id: <20201126024043.3392-8-chaitanya.kulkarni@wdc.com> X-Mailer: git-send-email 2.22.1 In-Reply-To: <20201126024043.3392-1-chaitanya.kulkarni@wdc.com> References: <20201126024043.3392-1-chaitanya.kulkarni@wdc.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org Update the target side command effects logs with support for ZNS commands for zbdev. Signed-off-by: Chaitanya Kulkarni --- drivers/nvme/target/admin-cmd.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/nvme/target/admin-cmd.c b/drivers/nvme/target/admin-cmd.c index cd368cbe3855..0099275951da 100644 --- a/drivers/nvme/target/admin-cmd.c +++ b/drivers/nvme/target/admin-cmd.c @@ -191,6 +191,8 @@ static void nvmet_execute_get_log_cmd_effects_ns(struct nvmet_req *req) log->iocs[nvme_cmd_dsm] = cpu_to_le32(1 << 0); log->iocs[nvme_cmd_write_zeroes] = cpu_to_le32(1 << 0); + nvmet_zns_add_cmd_effects(log); + status = nvmet_copy_to_sgl(req, 0, log, sizeof(*log)); kfree(log); From patchwork Thu Nov 26 02:40:42 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chaitanya Kulkarni X-Patchwork-Id: 11932617 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id F00BBC56202 for ; Thu, 26 Nov 2020 02:42:08 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9B07020B1F for ; Thu, 26 Nov 2020 02:42:08 +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="aw0OXOY+" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1733007AbgKZCmI (ORCPT ); Wed, 25 Nov 2020 21:42:08 -0500 Received: from esa5.hgst.iphmx.com ([216.71.153.144]:45567 "EHLO esa5.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732947AbgKZCmH (ORCPT ); Wed, 25 Nov 2020 21:42:07 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1606358527; x=1637894527; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=5Iw7w/DZLZaDG8VLkQP5pskn7Zl3Ct/yjTxMj+mxhCQ=; b=aw0OXOY+o6o5AU6i07lYZhOA8/o/yQW60P1t1jo9IIUOet+P1No+VHQC QfVKWswci9ACeUeEzqDaickCDUX/Umu16y6a1kxYd/5oLUwM5iqCh1VRc w5VAqgEY5J/QuXPI8lEF0BRGVKymaxiKEcSarvNUPMDCf9WSitNgGEMki WH+Um64duZzn3Ye8yvkQEt4yShUQpRtjMlKue3xKY5AgLwSd8oNfX9YsQ KeFObQ8C3OdvhjhIAbDrU1BXlikNZ9gpucm7jPGVTIkCzItKVTyLptjKC OEl908fH5YUXJ7uMmbMKjsPr1l3Z9b/iMAn4AT3x1vnSKcR6jWKeSPfYo g==; IronPort-SDR: lCEqps9FanX2TrF2s+gSVhOD7LZHYdeTu5LJlCu8VrVVrQ3iHn677h9IcolzD12featiu67fu+ WV7UlL/x5EtfgOY9O6o4D50IGgS2RA/DBTIyA6rpYQIrFGjcEgYU4TCxPPAGeQz/EFCXkceV9d myx9d3hszkG4lXhvEwkhN4jT20Qerbet/kTa/bt37Vvac2msqYLajdG5U4mbNIF2IVld5DY4/T 9o0Y6AGLFVH8B1UxMX7YH70L95i2QZ5ibUxWcDgcEkZTVyTwn0AsNeTPSaaODeoPM3yvS8IC7k eDw= X-IronPort-AV: E=Sophos;i="5.78,370,1599494400"; d="scan'208";a="153586948" Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 26 Nov 2020 10:42:07 +0800 IronPort-SDR: KVSIO1TS52XX/8e0Cs/F/UDgdptx3lxVdaO3KvIMUp6nzOeNtE5yfeibXwsSa/K/bBBGuVJx4A NtFI4ltrMZ9T7DHww1bpGzoai9OXMHGYM= Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Nov 2020 18:26:29 -0800 IronPort-SDR: OT+ipo9IUtxLKQzFh1Yo+PY1jKiSNkSqbQL8MrcRG0FJM8iIsfre24ixAEpDApW2GE+fu8X2+1 8sVkgdza+FfA== WDCIronportException: Internal Received: from vm.labspan.wdc.com (HELO vm.sc.wdc.com) ([10.6.137.102]) by uls-op-cesaip02.wdc.com with ESMTP; 25 Nov 2020 18:42:07 -0800 From: Chaitanya Kulkarni To: linux-block@vger.kernel.org, linux-nvme@lists.infradead.org Cc: sagi@grimberg.me, hch@lst.de, Chaitanya Kulkarni Subject: [PATCH 8/9] nvmet: add zns bdev config support Date: Wed, 25 Nov 2020 18:40:42 -0800 Message-Id: <20201126024043.3392-9-chaitanya.kulkarni@wdc.com> X-Mailer: git-send-email 2.22.1 In-Reply-To: <20201126024043.3392-1-chaitanya.kulkarni@wdc.com> References: <20201126024043.3392-1-chaitanya.kulkarni@wdc.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org For zbd based bdev backend we need to override the ns->blksize_shift with the physical block size instead of using the logical block size so that SMR drives will not result in an error. Update the nvmet_bdev_ns_enable() to reflect that. Signed-off-by: Chaitanya Kulkarni --- drivers/nvme/target/io-cmd-bdev.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/nvme/target/io-cmd-bdev.c b/drivers/nvme/target/io-cmd-bdev.c index 125dde3f410e..f8a500983abd 100644 --- a/drivers/nvme/target/io-cmd-bdev.c +++ b/drivers/nvme/target/io-cmd-bdev.c @@ -86,6 +86,9 @@ int nvmet_bdev_ns_enable(struct nvmet_ns *ns) if (IS_ENABLED(CONFIG_BLK_DEV_INTEGRITY_T10)) nvmet_bdev_ns_enable_integrity(ns); + if (bdev_is_zoned(ns->bdev) && !nvmet_bdev_zns_config(ns)) + return -EINVAL; + return 0; } From patchwork Thu Nov 26 02:40:43 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chaitanya Kulkarni X-Patchwork-Id: 11932619 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 473BDC56201 for ; Thu, 26 Nov 2020 02:42:27 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id DF2C0207BC for ; Thu, 26 Nov 2020 02:42:26 +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="C9NGNvY4" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732733AbgKZCm0 (ORCPT ); Wed, 25 Nov 2020 21:42:26 -0500 Received: from esa3.hgst.iphmx.com ([216.71.153.141]:20535 "EHLO esa3.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730809AbgKZCm0 (ORCPT ); Wed, 25 Nov 2020 21:42:26 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1606358545; x=1637894545; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=qeI8OkQ2C+8qF4W8aVLYYaL1+taXca5eouvg6P6Gos4=; b=C9NGNvY4oxAOqneMofUiMq1U9I6IQtrXvP9iN0ijY9XWC8/ixHXw/wzC hQqo28JZ+K+kBcxe6VMR9tPW4PXcWoA+gLGpEGUAnVPDoPn16QWv2VTck 0MGBfKa1OOXT2nJt3+eD6VO6vxTMHAxb4rLkGpCGYumQBeU/XoSEqwj6x fIe6G3zRkHfU0JG/wRbr58IbJAaz297Ye8PqYGnqWHvc3EG/rHioNFQB5 VkBhcJaNwPr6OjF8OuSa6cuyF3nu1I+qtXy7Rt3+xpCtFsV3G8m2BT+ak 8aQraRnN9yq+WmwzL5ry91ZM9V+S4JUJk666VxfpaT8GQ55EXoK1ETl3P g==; IronPort-SDR: q2UqC5cQ3xDHhO12p+14N+GxzOyF1rsDDt25fD6s4kmDad4u2X14j/Rl4xnHawNiTOQ8BSp3sI 7/IOfHLVWcJbEn+f9mIPj015KeIqXimsaQiAkoLn+yLWB+XoYYcCgzVxjpVONoCv++CapFX7eV kJ79Qk5DzH3jkoXFnhu8ba1t4Mauc4rvhJBmIrc+vEvUS3AlAiRSE9u35kBXGJDfyl0i15CrZJ bkBbXrdpL373wYRgL4+vSnacGgsdgh+K2DnJalqlLkfEeAWMaWdJNFWwZjbu1rgBbKKrwFvVdx FF8= X-IronPort-AV: E=Sophos;i="5.78,370,1599494400"; d="scan'208";a="157983172" Received: from h199-255-45-14.hgst.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 26 Nov 2020 10:42:25 +0800 IronPort-SDR: /unS0tfmQLgVGbpAkBDKfNn2JHtTfqOKwMUlqgGPbavBawHTUJIK0PrpLUmc7+6q36YwpXJORt ZPqNPSuPBc51p+kF6G7CjoCV4j9hDO7WU= Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Nov 2020 18:28:07 -0800 IronPort-SDR: /qUJeynUYlB2tGsiF3eBwSQA1RSvV7doTJnStkhrjI95IQtpqlEChvvEj3rYMPFM5RSRvHvUXK lx5jkLdKAkhQ== WDCIronportException: Internal Received: from vm.labspan.wdc.com (HELO vm.sc.wdc.com) ([10.6.137.102]) by uls-op-cesaip02.wdc.com with ESMTP; 25 Nov 2020 18:42:25 -0800 From: Chaitanya Kulkarni To: linux-block@vger.kernel.org, linux-nvme@lists.infradead.org Cc: sagi@grimberg.me, hch@lst.de, Chaitanya Kulkarni Subject: [PATCH 9/9] nvmet: add ZNS based I/O cmds handlers Date: Wed, 25 Nov 2020 18:40:43 -0800 Message-Id: <20201126024043.3392-10-chaitanya.kulkarni@wdc.com> X-Mailer: git-send-email 2.22.1 In-Reply-To: <20201126024043.3392-1-chaitanya.kulkarni@wdc.com> References: <20201126024043.3392-1-chaitanya.kulkarni@wdc.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org Add zone-mgmt-send, zone-mgmt-recv and zone-zppend handlers for the bdev backend so that it can support zbd. Signed-off-by: Chaitanya Kulkarni --- drivers/nvme/target/Makefile | 3 +-- drivers/nvme/target/io-cmd-bdev.c | 9 +++++++++ drivers/nvme/target/zns.c | 6 +++--- 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/drivers/nvme/target/Makefile b/drivers/nvme/target/Makefile index bc147ff2df5d..15307b1cc713 100644 --- a/drivers/nvme/target/Makefile +++ b/drivers/nvme/target/Makefile @@ -10,9 +10,8 @@ obj-$(CONFIG_NVME_TARGET_FCLOOP) += nvme-fcloop.o obj-$(CONFIG_NVME_TARGET_TCP) += nvmet-tcp.o nvmet-y += core.o configfs.o admin-cmd.o fabrics-cmd.o \ - discovery.o io-cmd-file.o io-cmd-bdev.o + zns.o discovery.o io-cmd-file.o io-cmd-bdev.o nvmet-$(CONFIG_NVME_TARGET_PASSTHRU) += passthru.o -nvmet-$(CONFIG_BLK_DEV_ZONED) += zns.o nvme-loop-y += loop.o nvmet-rdma-y += rdma.o diff --git a/drivers/nvme/target/io-cmd-bdev.c b/drivers/nvme/target/io-cmd-bdev.c index f8a500983abd..4fcc8374b857 100644 --- a/drivers/nvme/target/io-cmd-bdev.c +++ b/drivers/nvme/target/io-cmd-bdev.c @@ -453,6 +453,15 @@ u16 nvmet_bdev_parse_io_cmd(struct nvmet_req *req) case nvme_cmd_write_zeroes: req->execute = nvmet_bdev_execute_write_zeroes; return 0; + case nvme_cmd_zone_append: + req->execute = nvmet_bdev_execute_zone_append; + return 0; + case nvme_cmd_zone_mgmt_recv: + req->execute = nvmet_bdev_execute_zone_mgmt_recv; + return 0; + case nvme_cmd_zone_mgmt_send: + req->execute = nvmet_bdev_execute_zone_mgmt_send; + return 0; default: pr_err("unhandled cmd %d on qid %d\n", cmd->common.opcode, req->sq->qid); diff --git a/drivers/nvme/target/zns.c b/drivers/nvme/target/zns.c index 8ea6641a55e3..efd11d7a6f96 100644 --- a/drivers/nvme/target/zns.c +++ b/drivers/nvme/target/zns.c @@ -361,17 +361,17 @@ void nvmet_bdev_execute_zone_append(struct nvmet_req *req) } #else /* CONFIG_BLK_DEV_ZONED */ -static void nvmet_execute_identify_cns_cs_ctrl(struct nvmet_req *req) +void nvmet_execute_identify_cns_cs_ctrl(struct nvmet_req *req) { } -static void nvmet_execute_identify_cns_cs_ns(struct nvmet_req *req) +void nvmet_execute_identify_cns_cs_ns(struct nvmet_req *req) { } u16 nvmet_process_zns_cis(struct nvmet_req *req, off_t *off) { return 0; } -static bool nvmet_bdev_zns_config(struct nvmet_ns *ns) +bool nvmet_bdev_zns_config(struct nvmet_ns *ns) { return false; }