From patchwork Tue Dec 1 04:14:08 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chaitanya Kulkarni X-Patchwork-Id: 11941877 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 C75BBC8300F for ; Tue, 1 Dec 2020 04:15:35 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 621B520725 for ; Tue, 1 Dec 2020 04:15:35 +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="khAtHA/6" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726614AbgLAEPe (ORCPT ); Mon, 30 Nov 2020 23:15:34 -0500 Received: from esa6.hgst.iphmx.com ([216.71.154.45]:13185 "EHLO esa6.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728049AbgLAEPe (ORCPT ); Mon, 30 Nov 2020 23:15:34 -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=1606796133; x=1638332133; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=nbiHUyaUtN1lM/VRyvOM4VWz5z/jZqsgAj2Gp0q3iN4=; b=khAtHA/6pHAkidZdzAz48666wBU/8U7w0Agdof7Fa1HMjDIBSLxSVAfi IrSTRqgWu+qKXbB989VxBX7AJk3CNrMrfH3E3+Iw91eNVUgnYdrH3LiQj cmfN57OwOM4rTjlVCP2xlQXCkrTBsJLcuiJw6I0V3DLtQvt9nZpQJOnBP mncYOlF8ygXJp3Jjo0K50z3/CUwYqFR0xM9P8KPF1T0Bk9uYaMKIqVNZo 3/Ult+yyYXYKmr0tzuJfqfbO+rx6uEUMkGc9Ss48w1J5xY1o4LZA+7F9s Y1OxVIaaQe1zg/B0Fnxz4howDGiTLV88Kwo7YyzY7Fni5MM4nRVOBYJQQ A==; IronPort-SDR: ADdpqweOsyhpZffTrbyyt5moCDLw4dB5rrqCPyYzfi1Lz75O9zn9VeLEwcgB7DSezvuVqGcxmK Ea17mY/3pIbPdiDyK8uV0bzVzF7MMG/6fKXAT20DngvwlbtDPOYOuQCpDNOhgaRLoBZy49whxQ Iu2GUWFxYRUTkT0E5JYfsEV0zgazdKXHS0StkTmm3LBrMD2qWNpS2bVe/uZ0yi8d/o3f8YakD8 A7dRj0HTljXQAzvKIN10FW8XmYEV+73qnbr+6UuxXOuaNyRRx6sb1u6oRZzOq/MNxYw4YCmJ8F UiA= X-IronPort-AV: E=Sophos;i="5.78,383,1599494400"; d="scan'208";a="155078130" Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 01 Dec 2020 12:14:28 +0800 IronPort-SDR: LSc8Yh8lyafz2yBIO5cDtM2zkReDGuK5V3cC/3fkqBA56f9msty3Khmal6URecByw9NEK0d9HP IbyOx2C64axqo4WxkMoreRjc1fpPWA0BM= 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; 30 Nov 2020 19:58:40 -0800 IronPort-SDR: VgyZr1dQ9IL+lQ3EYcsF1xF7+2m6lLNNxK3KWDsAtNWYHmk1L6m/D3IuS2lpPizuVBeEj6m33O 8nuMzvl3jPaA== WDCIronportException: Internal Received: from vm.labspan.wdc.com (HELO vm.sc.wdc.com) ([10.6.137.102]) by uls-op-cesaip01.wdc.com with ESMTP; 30 Nov 2020 20:14:28 -0800 From: Chaitanya Kulkarni To: linux-block@vger.kernel.org, linux-nvme@lists.infradead.org Cc: sagi@grimberg.me, hch@lst.de, damien.lemoal@wdc.com, Chaitanya Kulkarni Subject: [PATCH V3 1/9] block: export __bio_iov_append_get_pages() Date: Mon, 30 Nov 2020 20:14:08 -0800 Message-Id: <20201201041416.16293-2-chaitanya.kulkarni@wdc.com> X-Mailer: git-send-email 2.22.1 In-Reply-To: <20201201041416.16293-1-chaitanya.kulkarni@wdc.com> References: <20201201041416.16293-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 Tue Dec 1 04:14:09 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chaitanya Kulkarni X-Patchwork-Id: 11941879 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=unavailable 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 9CF14C64E8A for ; Tue, 1 Dec 2020 04:15:44 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3965D20796 for ; Tue, 1 Dec 2020 04:15:44 +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="VJNb8aM+" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728005AbgLAEPn (ORCPT ); Mon, 30 Nov 2020 23:15:43 -0500 Received: from esa5.hgst.iphmx.com ([216.71.153.144]:49045 "EHLO esa5.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727973AbgLAEPn (ORCPT ); Mon, 30 Nov 2020 23:15:43 -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=1606796142; x=1638332142; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=IbhFgyygJ5NSmgqlsuEUA8KxxUfUDKGG9QcwKU4tpWE=; b=VJNb8aM+jmCE35cqV4hZluLy6oC1AsYp7TGSO9kXtzLc3w7TqJRSgKnX f5NgSHBVl28QobEEmqOvA1hLw06MJYa90iVVxozPzIsidlIZBiMCoJ/u4 aOXycTxVqttw26zN2mKni2vYAReMyRa3Eqlsbv6xyX8/SrHYW4Fxy4ZBT /Srkh8n7ve9KZ/tT7PQI0gOlleXCIVRdl4DIBZgcB4wJVfmJI1d8dbmII KEr4CsR13Nzegq3U86kc9mb8DaJ5OsKuQwFGEKHj8+8hLK8IgC95Vnqn1 VurfJNV7BBU58U0ctocb+lgxB9SLWjtftvWtNznhIS1y+Zsm07T6M20KG A==; IronPort-SDR: 8sZ9bg4PKcJCQfOSpdrx1C+1LEwUN910C/iX/eRqKi1HKIaFEIAZKe42uveQhnfcvwQXtWwi94 aUI92dfzt5r8Ajzn+IM6+VrWgph4wrD9gd4c8rAAKVtI8aYtprcaEj7JaPZWmGbXNHb1nApI/B wUy4mWaidfdtpRFZoQRq2hYdz67pjcd1zyI9RVb1Z4iGI8bChrQjegMVYqLAzHETHOcs4ZFvlq EWaaZS7kX9ZCP25jghIcBymXt6TsNAIL6V93vyD+bSpqLszHYPHTnc2QY1IpT912uwaAzaM3PE hg8= X-IronPort-AV: E=Sophos;i="5.78,383,1599494400"; d="scan'208";a="153948667" 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; 01 Dec 2020 12:14:36 +0800 IronPort-SDR: Micm1bsTh5Iezi7o52iZKSHYawHyIZiIhgTjIRWe2u2TVzGAoBIrdyxSUnz/fE7sFkZ3i98y4t ladsOfBcVlAOMYB5dnD9uaa/Oe0XqI7I0= 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; 30 Nov 2020 19:58:49 -0800 IronPort-SDR: 7LFTu6WLrrCxENQ1Fh9Ynx4Ti5F/VSoeX7Fw4+wD27LffDAjfBsUXcOBtRwPyF9b9KodeYlb17 5dEwlhTOZMsQ== WDCIronportException: Internal Received: from vm.labspan.wdc.com (HELO vm.sc.wdc.com) ([10.6.137.102]) by uls-op-cesaip01.wdc.com with ESMTP; 30 Nov 2020 20:14:37 -0800 From: Chaitanya Kulkarni To: linux-block@vger.kernel.org, linux-nvme@lists.infradead.org Cc: sagi@grimberg.me, hch@lst.de, damien.lemoal@wdc.com, Chaitanya Kulkarni Subject: [PATCH V3 2/9] nvmet: add ZNS support for bdev-ns Date: Mon, 30 Nov 2020 20:14:09 -0800 Message-Id: <20201201041416.16293-3-chaitanya.kulkarni@wdc.com> X-Mailer: git-send-email 2.22.1 In-Reply-To: <20201201041416.16293-1-chaitanya.kulkarni@wdc.com> References: <20201201041416.16293-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 | 19 ++ drivers/nvme/target/zns.c | 426 ++++++++++++++++++++++++++++++ 5 files changed, 449 insertions(+), 4 deletions(-) create mode 100644 drivers/nvme/target/zns.c diff --git a/drivers/nvme/target/Makefile b/drivers/nvme/target/Makefile index ebf91fc4c72e..d050f829b43a 100644 --- a/drivers/nvme/target/Makefile +++ b/drivers/nvme/target/Makefile @@ -10,7 +10,7 @@ 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 nvme-loop-y += loop.o nvmet-rdma-y += rdma.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..eee7866ae512 100644 --- a/drivers/nvme/target/nvmet.h +++ b/drivers/nvme/target/nvmet.h @@ -81,6 +81,10 @@ 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; + unsigned int zasl; +#endif }; static inline struct nvmet_ns *to_nvmet_ns(struct config_item *item) @@ -251,6 +255,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 +611,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_enable(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..f6927f7ef4d2 --- /dev/null +++ b/drivers/nvme/target/zns.c @@ -0,0 +1,426 @@ +// 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 +#include "nvmet.h" + +#ifdef CONFIG_BLK_DEV_ZONED +#define NVMET_MPSMIN_SHIFT 12 + +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 inline struct block_device *nvmet_bdev(struct nvmet_req *req) +{ + return req->ns->bdev; +} + +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 helpers. + */ + +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 NVME_SC_SUCCESS; + + return nvmet_copy_ns_identifier(req, NVME_NIDT_CSI, NVME_NIDT_CSI_LEN, + &nvme_cis_zns, off); +} + +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); +} + +static inline bool nvmet_bdev_validate_zns_zones(struct nvmet_ns *ns) +{ + if (ns->bdev->bd_disk->queue->conv_zones_bitmap) { + pr_err("block devices with conventional zones are not supported."); + return false; + } + + return !(get_capacity(ns->bdev->bd_disk) & + (bdev_zone_sectors(ns->bdev) - 1)); +} + +static inline u8 nvmet_zasl(unsigned int zone_append_sects) +{ + /* + * Zone Append Size Limit is the value experessed in the units + * of minimum memory page size (i.e. 12) and is reported power of 2. + */ + return ilog2((zone_append_sects << 9) >> NVMET_MPSMIN_SHIFT); +} + +static inline void nvmet_zns_update_zasl(struct nvmet_ns *ns) +{ + u8 bio_max_zasl = nvmet_zasl((BIO_MAX_PAGES * PAGE_SIZE) >> 9); + struct request_queue *q = ns->bdev->bd_disk->queue; + struct nvmet_ns *ins; + unsigned long idx; + u8 min_zasl; + + /* + * Calculate new ctrl->zasl value when enabling the new ns. This value + * has to be the minimum of the max_zone_append values from available + * namespaces. + */ + min_zasl = ns->zasl = nvmet_zasl(queue_max_zone_append_sectors(q)); + + xa_for_each(&(ns->subsys->namespaces), idx, ins) { + struct request_queue *iq = ins->bdev->bd_disk->queue; + unsigned int imax_za_sects = queue_max_zone_append_sectors(iq); + u8 izasl = nvmet_zasl(imax_za_sects); + + if (!bdev_is_zoned(ins->bdev)) + continue; + + min_zasl = min_zasl > izasl ? izasl : min_zasl; + } + + ns->subsys->id_ctrl_zns.zasl = min_t(u8, min_zasl, bio_max_zasl); +} + +bool nvmet_bdev_zns_enable(struct nvmet_ns *ns) +{ + if (!nvmet_bdev_validate_zns_zones(ns)) + return false; + + /* + * For ZBC and ZAC devices, writes into sequential zones must be aligned + * to the device physical block size. So use this value as the logical + * block size to avoid errors. + */ + ns->blksize_shift = blksize_bits(bdev_physical_block_size(ns->bdev)); + + nvmet_zns_update_zasl(ns); + + return true; +} + +/* + * ZNS related Admin and I/O command handlers. + */ +void nvmet_execute_identify_cns_cs_ctrl(struct nvmet_req *req) +{ + u8 zasl = req->sq->ctrl->subsys->id_ctrl_zns.zasl; + struct nvmet_ctrl *ctrl = req->sq->ctrl; + struct nvme_id_ctrl_zns *id; + u16 status; + + id = kzalloc(sizeof(*id), GFP_KERNEL); + if (!id) { + status = NVME_SC_INTERNAL; + goto out; + } + + if (ctrl->ops->get_mdts) + id->zasl = min_t(u8, ctrl->ops->get_mdts(ctrl), zasl); + else + id->zasl = zasl; + + 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); +} + +struct nvmet_report_zone_data { + struct nvmet_ns *ns; + struct nvme_zone_report *rz; +}; + +static int nvmet_bdev_report_zone_cb(struct blk_zone *z, unsigned int idx, + void *data) +{ + struct nvmet_report_zone_data *report_zone_data = data; + struct nvme_zone_descriptor *entries = report_zone_data->rz->entries; + struct nvmet_ns *ns = report_zone_data->ns; + + entries[idx].zcap = cpu_to_le64(nvmet_sect_to_lba(ns, z->capacity)); + entries[idx].zslba = cpu_to_le64(nvmet_sect_to_lba(ns, z->start)); + entries[idx].wp = cpu_to_le64(nvmet_sect_to_lba(ns, z->wp)); + entries[idx].za = z->reset ? 1 << 2 : 0; + entries[idx].zt = z->type; + entries[idx].zs = z->cond << 4; + + return 0; +} + +void nvmet_bdev_execute_zone_mgmt_recv(struct nvmet_req *req) +{ + u64 bufsize = (le32_to_cpu(req->cmd->zmr.numd) + 1) << 2; + struct nvmet_report_zone_data data = { .ns = req->ns }; + struct nvme_zone_mgmt_recv_cmd *zmr = &req->cmd->zmr; + sector_t sect = nvmet_lba_to_sect(req->ns, le64_to_cpu(zmr->slba)); + unsigned int nr_zones; + int reported_zones; + u16 status; + + nr_zones = (bufsize - sizeof(struct nvme_zone_report)) / + sizeof(struct nvme_zone_descriptor); + + status = nvmet_bdev_zns_checks(req); + if (status) + goto out; + + data.rz = __vmalloc(bufsize, GFP_KERNEL | __GFP_NORETRY); + if (!data.rz) { + status = NVME_SC_INTERNAL; + goto out; + } + + reported_zones = blkdev_report_zones(nvmet_bdev(req), sect, nr_zones, + nvmet_bdev_report_zone_cb, + &data); + if (reported_zones < 0) { + status = NVME_SC_INTERNAL; + goto out_free_report_zones; + } + + data.rz->nr_zones = cpu_to_le64(reported_zones); + + status = nvmet_copy_to_sgl(req, 0, data.rz, bufsize); + +out_free_report_zones: + kvfree(data.rz); +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; + enum req_opf op = REQ_OP_LAST; + u16 status = NVME_SC_SUCCESS; + sector_t sect; + int ret; + + sect = nvmet_lba_to_sect(req->ns, le64_to_cpu(req->cmd->zms.slba)); + + if (c->select_all) + nr_sect = get_capacity(nvmet_bdev(req)->bd_disk); + + 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: + op = REQ_OP_ZONE_RESET; + break; + default: + status = NVME_SC_INVALID_FIELD; + goto out; + } + + ret = blkdev_zone_mgmt(nvmet_bdev(req), op, sect, nr_sect, GFP_KERNEL); + if (ret) + status = NVME_SC_INTERNAL; + +out: + nvmet_req_complete(req, status); +} + +void nvmet_bdev_execute_zone_append(struct nvmet_req *req) +{ + unsigned long bv_cnt = req->sg_cnt; + u64 slba = le64_to_cpu(req->cmd->rw.slba); + sector_t sect = nvmet_lba_to_sect(req->ns, slba); + u16 status = NVME_SC_SUCCESS; + size_t mapped_data_len = 0; + int sg_cnt = req->sg_cnt; + struct scatterlist *sg; + struct iov_iter from; + struct bio_vec *bvec; + size_t mapped_cnt; + struct bio *bio; + int ret; + + if (!nvmet_check_transfer_len(req, nvmet_rw_data_len(req))) + return; + + /* + * When setting the ctrl->zasl we consider the BIO_MAX_PAGES so that we + * don't have to split the bio, i.e. we shouldn't get + * sg_cnt > BIO_MAX_PAGES since zasl on the host will limit the I/Os + * with the size that considers the BIO_MAX_PAGES. + */ + if (!req->sg_cnt) + goto out; + + if (WARN_ON(req->sg_cnt > BIO_MAX_PAGES)) { + status = NVME_SC_INTERNAL | NVME_SC_DNR; + goto out; + } + + bvec = kmalloc_array(bv_cnt, sizeof(*bvec), GFP_KERNEL); + if (!bvec) { + status = NVME_SC_INTERNAL | NVME_SC_DNR; + goto out; + } + + 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; + } + + if (WARN_ON(sg_cnt)) { + status = NVME_SC_INTERNAL | NVME_SC_DNR; + goto out; + } + + 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 = REQ_OP_ZONE_APPEND | REQ_SYNC | REQ_IDLE; + + ret = __bio_iov_append_get_pages(bio, &from); + if (unlikely(ret)) { + status = NVME_SC_INTERNAL | NVME_SC_DNR; + bio_io_error(bio); + goto bvec_free; + } + + ret = submit_bio_wait(bio); + status = ret < 0 ? NVME_SC_INTERNAL : status; + bio_put(bio); + + sect += (mapped_data_len >> 9); + req->cqe->result.u64 = le64_to_cpu(nvmet_sect_to_lba(req->ns, sect)); + +bvec_free: + kfree(bvec); + +out: + nvmet_req_complete(req, status); +} + +#else /* CONFIG_BLK_DEV_ZONED */ +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) +{ + return 0; +} +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 Tue Dec 1 04:14:10 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chaitanya Kulkarni X-Patchwork-Id: 11941881 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=unavailable 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 C4182C64E7A for ; Tue, 1 Dec 2020 04:15:52 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 631B620796 for ; Tue, 1 Dec 2020 04:15:52 +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="S2U7WHUu" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728025AbgLAEPv (ORCPT ); Mon, 30 Nov 2020 23:15:51 -0500 Received: from esa1.hgst.iphmx.com ([68.232.141.245]:21420 "EHLO esa1.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727973AbgLAEPv (ORCPT ); Mon, 30 Nov 2020 23:15:51 -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=1606796151; x=1638332151; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=AZ0ASPEdFnz/BJCpcrFT1z2buOCvE1xQZBqdQG2WuUM=; b=S2U7WHUuVv9rNCvZ6d9/56llFmIeuBA5y+aVb1jiKvOPjbpGJmG5u5DL V6vCca1odLzeBz6T/HYdbxfEDRIaksxtA3xX8O2yWBdne2MwMdpa/nf0P jw51MpIv5N7L7j1hjR8VPdHkX2bQ6c9ibtw1J2EwVh1ictNHgXWO/iwoM h07J6mfvI9dAoevOzxRfldmkPKoAPALLk3vS7BHU+mhry3CjBAExINK2S cRiQl0QK0adTIRrboGD5sEx6D/+PFCmYquFRKtk/gWT8xoJ4cMvx7LS3N hBBFYyKsBEyRvllHhm8KzzkiycNV5c9PpAI20tyPa89naRCYWIKHr+f5b g==; IronPort-SDR: vPo+zzEAi2w8tyblE86A/fl80m7TY7iidQxPO/jKwZISTYo2r9hkrzD4ER8pdUiAGxQjk4gBF5 93iJR5oA62q9faikss/a1dtntvH15FlYe522N+koglMQP2LnEOFeLtevP6aHBEoJJjYHp/46NQ KEkpR3h8dRk6Trj4bbxAyjbUfImhMf1l0aWLxm7eNMfGOAYHTBPtkub/cVIzGXupoHyDIUMz86 QOx4ryDg/VhH43L92zmY/FMT8LGKkCd4g+D3BVoLDnNDOmheuMHTYcJd4TrCOoXGlKiihih4Gw xms= X-IronPort-AV: E=Sophos;i="5.78,383,1599494400"; d="scan'208";a="264005871" 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; 01 Dec 2020 12:14:45 +0800 IronPort-SDR: fNKvf890FM/Gmur8DEm99DEBgNnJhbv+0e/My9nR3p9Z6Aex3fVuL3m+MhHmM7xr15ZABFbt2v EFVMP3yOUmhi2hkhwiaBCuj061vfYgsoc= 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; 30 Nov 2020 19:58:58 -0800 IronPort-SDR: YvkqHILlm6UWCuUEr04BRGq+HsD/5gFFCyYnGnQb47az3BFy7WnmUU7GIP53Lz78rLo1DN91hP I5qbVG31pwJA== WDCIronportException: Internal Received: from vm.labspan.wdc.com (HELO vm.sc.wdc.com) ([10.6.137.102]) by uls-op-cesaip01.wdc.com with ESMTP; 30 Nov 2020 20:14:46 -0800 From: Chaitanya Kulkarni To: linux-block@vger.kernel.org, linux-nvme@lists.infradead.org Cc: sagi@grimberg.me, hch@lst.de, damien.lemoal@wdc.com, Chaitanya Kulkarni Subject: [PATCH V3 3/9] nvmet: trim down id-desclist to use req->ns Date: Mon, 30 Nov 2020 20:14:10 -0800 Message-Id: <20201201041416.16293-4-chaitanya.kulkarni@wdc.com> X-Mailer: git-send-email 2.22.1 In-Reply-To: <20201201041416.16293-1-chaitanya.kulkarni@wdc.com> References: <20201201041416.16293-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 Tue Dec 1 04:14:11 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Chaitanya Kulkarni X-Patchwork-Id: 11941883 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 D88E9C64E8A for ; Tue, 1 Dec 2020 04:16:00 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7918E20796 for ; Tue, 1 Dec 2020 04:16:00 +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="U6j0KcC4" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728008AbgLAEQA (ORCPT ); Mon, 30 Nov 2020 23:16:00 -0500 Received: from esa4.hgst.iphmx.com ([216.71.154.42]:19764 "EHLO esa4.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727973AbgLAEP7 (ORCPT ); Mon, 30 Nov 2020 23:15:59 -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=1606796159; x=1638332159; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=hpoI1V55y5gwFhJlJIS3F+nAY0E41Z5thazQ0M5y7lA=; b=U6j0KcC4z8M4J6iZnTSo7GT88QNX9QXJKUurKhz0QYZfrls3tkOKc7/R Qgk9Sx0HY2fczuVPh7AfnmHnbaA4Ye/qIHo+RO6zh8rEVEJKHak7N2jbi B8LsEFexNlPSHvCaR0i/wkQH+2WSyAdC3T4lWY0jkw7AqLoYycryO8ZrO f3S1wE6y/7Z6gm+72wSURjUxoqTcoLrQqyjzmbtu3kvxM1DLYonOul28r Rdn6La4znez0JEpwcMhoA4WSiWogPjAaCzjaCuteYb0LxGHGWe/Y1tho0 6t4XADQPyljg2Xo2UqSLzjJVe9LQXQhzWD95Q84VUts0pMA7uEReJe4vC A==; IronPort-SDR: l6KQ5wBbQruii7E7o803hMgR3YW1tIDXepIB4Rs2yWr/YaHpHP+UU9WSgqmxfABanNl4lYNhBa lZ4wUqcY8brWoBt9f/ymGzmBOa90mwFgVM5jd7yAw2LYIEgs42r23wL0mKoq6Lz5ctpGTLR3R6 TO86YHGFMZkjN9OomBs2O5gR0wk648nwxwdvX7M3uaPKwZpxxbBJIo8nYacdPKgpdIJqN9Cdbp HG3boA3BX8T1sFrZwcY1RRFCh6dCdmFmG3tXUh/giCEiXghq29ei7ZEBi+5v9QlrWXwISALk4l Juo= X-IronPort-AV: E=Sophos;i="5.78,383,1599494400"; d="scan'208";a="153814555" 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; 01 Dec 2020 12:14:53 +0800 IronPort-SDR: T3D3pWuj2lJsNtYC4XCQ1MPKRM9AYTGU3ZxeU/+rFLmlm7/WzJYiS3ukoA9YkSMhQyRze6Sra1 z7qKHrdL7PFACexJ8CHnG3vBknaA1pIqk= Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Nov 2020 20:00:29 -0800 IronPort-SDR: 5htoikVM1SkY+ej8If5dpDTgcxoRwylrhnTsqR9sjWeSXn0Wk4fe7mQrlNd1wtGAyq8PXTCm/X aJRr4nVlpHSQ== WDCIronportException: Internal Received: from vm.labspan.wdc.com (HELO vm.sc.wdc.com) ([10.6.137.102]) by uls-op-cesaip01.wdc.com with ESMTP; 30 Nov 2020 20:14:54 -0800 From: Chaitanya Kulkarni To: linux-block@vger.kernel.org, linux-nvme@lists.infradead.org Cc: sagi@grimberg.me, hch@lst.de, damien.lemoal@wdc.com, Chaitanya Kulkarni Subject: [PATCH V3 4/9] nvmet: add NVME_CSI_ZNS in ns-desc for zbdev Date: Mon, 30 Nov 2020 20:14:11 -0800 Message-Id: <20201201041416.16293-5-chaitanya.kulkarni@wdc.com> X-Mailer: git-send-email 2.22.1 In-Reply-To: <20201201041416.16293-1-chaitanya.kulkarni@wdc.com> References: <20201201041416.16293-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 Tue Dec 1 04:14:12 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chaitanya Kulkarni X-Patchwork-Id: 11941885 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 35D6EC64E8A for ; Tue, 1 Dec 2020 04:16:09 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id BE6DE20796 for ; Tue, 1 Dec 2020 04:16: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="AuAExG45" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728044AbgLAEQI (ORCPT ); Mon, 30 Nov 2020 23:16:08 -0500 Received: from esa6.hgst.iphmx.com ([216.71.154.45]:54598 "EHLO esa6.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728039AbgLAEQI (ORCPT ); Mon, 30 Nov 2020 23:16:08 -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=1606796167; x=1638332167; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=+iv8i8xvGTKjTFiSy9i/jgbNCBRhvNbZSotD5vVTWDc=; b=AuAExG45bUlIXxBXdsLaOqPxFrlopDvTLKFo44r7A/vcxA41xLhHWLO4 VsOf+ODNfSEmO4RlsJkdjSt5M1c/SbuOLEf/66TgtlEfpTYhRZWbQaPl0 +B7Q7oA4jnQzciOwz25fUyZU47XX2rtRqSV2Re8GIXX5QcqTlOUB/h2Hw PYRO6VoAj9+5h2BrLMFbELp7oudS2Ju6JLaAEi7Iv6ToMT0RikqpfhD7T 1Tbr/Q9cIMjeuL84MnUENdFCe+Oa6jaRMVr/2QxVErG0eJC2uFKnYjQWE SkVVFmlgdv0sqTbT5xfVTYLUYUFmYjdM7vQnB/gBBSh+1ALiT18bTQ7QR w==; IronPort-SDR: ne4kq4KBbNA/HoBMKXueltX0bMvGr4lxClY8x+ztm+vMfVkzns2VXb/wRB9Lpd0GFbSK2FT+oJ hD3/mmU+aGwqn4mTUFFGqYqyUs7bNcwFpPXAlw6uMgw4K2C/F9eCILfadGx0F7Lfl90bi9bpuV WSasD9aGHZD5+kFfqRSCQgQoT7PfDwGKN1C7bt1I54eSinCL7G+aTS1QjhSCRN6wp0d4fnt0Tb /LddekYk8KZaFUW2TLwFQixUNjdZhTTxsvcZKO57y8tq228m/0UW3TjyWp4dptQXZaoCi1oZwW HVE= X-IronPort-AV: E=Sophos;i="5.78,383,1599494400"; d="scan'208";a="155078165" Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 01 Dec 2020 12:15:02 +0800 IronPort-SDR: v5JmhFzi2DuU3/mGFYsFA0VbWOA6/m23T5Q3nH67xDMKw7oAPiCTBZGAdcMaHso5toboI6C470 PmbPOLlwG5Wl5JRTH9w2hakUmH7+B6GfA= 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; 30 Nov 2020 19:59:14 -0800 IronPort-SDR: h5fnJ21debZvfkYEpcq0/DTqM3DTdw5CsfIEjan+M57FL6ex5KKZqiMpE9cwEY+RPNchNVn0+t z3PNOaostPmw== WDCIronportException: Internal Received: from vm.labspan.wdc.com (HELO vm.sc.wdc.com) ([10.6.137.102]) by uls-op-cesaip01.wdc.com with ESMTP; 30 Nov 2020 20:15:02 -0800 From: Chaitanya Kulkarni To: linux-block@vger.kernel.org, linux-nvme@lists.infradead.org Cc: sagi@grimberg.me, hch@lst.de, damien.lemoal@wdc.com, Chaitanya Kulkarni Subject: [PATCH V3 5/9] nvmet: add cns-cs-ctrl in id-ctrl for ZNS bdev Date: Mon, 30 Nov 2020 20:14:12 -0800 Message-Id: <20201201041416.16293-6-chaitanya.kulkarni@wdc.com> X-Mailer: git-send-email 2.22.1 In-Reply-To: <20201201041416.16293-1-chaitanya.kulkarni@wdc.com> References: <20201201041416.16293-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 Tue Dec 1 04:14:13 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chaitanya Kulkarni X-Patchwork-Id: 11941889 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 784C7C64E8A for ; Tue, 1 Dec 2020 04:16:17 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1E18220658 for ; Tue, 1 Dec 2020 04:16:17 +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="aHxX5iMd" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728058AbgLAEQQ (ORCPT ); Mon, 30 Nov 2020 23:16:16 -0500 Received: from esa2.hgst.iphmx.com ([68.232.143.124]:32041 "EHLO esa2.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728039AbgLAEQQ (ORCPT ); Mon, 30 Nov 2020 23:16: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=1606796219; x=1638332219; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=m/bvl+lK7ll6HRYiQ0kG1ndR5SFePuzrxfzuz5g9atQ=; b=aHxX5iMddtB73hy0d1LICLjrrlhqMLemkYKmdtlyKwktBS0VV5zrdbnn GzidwIoIrDWWewbVTGzwNCT3ACXQdcrzwbAwdZB9lixek0oOCNSVigE4K VW1a4cy5a6AnpangYjXA8JnH3OQxcS+uxpBkoc+urDbsqF2S04nNT54P3 IRfjaswSgCazIm3WAM1bmlR2KzR3Tznn/waChmRT0GOf3KrePDHAjFAig dYRxYBL3+2gEKtxBI7kW3Em3RqioLG3gjEaoJ5TgvmnKbnnhdwagsdd3e rRGCbLNDkvMl6AntLVWqEr5AHvGYws7AaIgmqXV9pghDjB3RbtctbZjI7 g==; IronPort-SDR: mdvZ2r2JLHCHj/13DeW4qdSAMJu1whEQGt90cdRBKfdBih4AhbBD2WB59KC7VW+4GM1RlvY0Pp 7y6z3LZihxM7AdwBAFBgekBz9YU1uK9VemtC94ZS0D+ELEcrEKMQ/5yCIMlBmngpJaz8YPyDVh /PBs4goamankQ9Lve3q8ZOS7B7+mbiFLchPsLnE+59S9J+sUzYJAmFGuV86w9OcN3sXUp0P+4b 67SlkAyaDL6GC82iG7WXcgpHCsvi5QoQw217Em/qQNTQcLbbS4dQUbiDivv1pNl6xG+gZqIF7d G0Y= X-IronPort-AV: E=Sophos;i="5.78,383,1599494400"; d="scan'208";a="257559124" Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 01 Dec 2020 12:15:20 +0800 IronPort-SDR: Ou0i3QaP2qhYmnKcnHdUh1a5EcffKD3fpJL2ajmbHjUCWWKcZOtOPIxe37/c9tZkNsUn4dxlmJ n7GjArqndF7jllnB7Ob66eykAhbyDtPh4= 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; 30 Nov 2020 19:59:23 -0800 IronPort-SDR: lTm+QtIHs4AZ5pzzJM/3sLQrBkSC4brkGHWf+hZR2x8+VWNdXZgumZWRj6AQH6VdoUpas9u0yH RDvNCidrDHlQ== WDCIronportException: Internal Received: from vm.labspan.wdc.com (HELO vm.sc.wdc.com) ([10.6.137.102]) by uls-op-cesaip01.wdc.com with ESMTP; 30 Nov 2020 20:15:11 -0800 From: Chaitanya Kulkarni To: linux-block@vger.kernel.org, linux-nvme@lists.infradead.org Cc: sagi@grimberg.me, hch@lst.de, damien.lemoal@wdc.com, Chaitanya Kulkarni Subject: [PATCH V3 6/9] nvmet: add cns-cs-ns in id-ctrl for ZNS bdev Date: Mon, 30 Nov 2020 20:14:13 -0800 Message-Id: <20201201041416.16293-7-chaitanya.kulkarni@wdc.com> X-Mailer: git-send-email 2.22.1 In-Reply-To: <20201201041416.16293-1-chaitanya.kulkarni@wdc.com> References: <20201201041416.16293-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 Tue Dec 1 04:14:14 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chaitanya Kulkarni X-Patchwork-Id: 11941895 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 0EA56C64E8A for ; Tue, 1 Dec 2020 04:16:26 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A79A4206C1 for ; Tue, 1 Dec 2020 04:16:25 +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="L8th+e4Z" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728066AbgLAEQZ (ORCPT ); Mon, 30 Nov 2020 23:16:25 -0500 Received: from esa1.hgst.iphmx.com ([68.232.141.245]:21474 "EHLO esa1.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728039AbgLAEQZ (ORCPT ); Mon, 30 Nov 2020 23:16:25 -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=1606796184; x=1638332184; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=hUhzJ651cVoNvniIQeg3wff/FCoz1DE77FDFCSJt0Zk=; b=L8th+e4ZXzJS1i3QJZPgxvVb3a1I/DCHS5izxrMsXxGFOD31UhQiAD6F wxrXilTG0+xwcEmTsIdG3EUUDW2pW8WXgJwu2F2MCO6n1g0Q7rPPPqElR F3NCB1Z3ybp1d22d1Yvb5M4dMkQP/JxMM3kARo6viLR7QfvWZMWIVwb3j voGBsTsNNlIkj0MnIHBluf0eNZMk51GVWYAxElt4t4Xe1KE0fkSMlCL1W kJe6YTvctO9DJAatBYKkfgGNqMqD2RIxOpIDcL1onm/GgtjkNTZieoDes 4UUwm3Z7y0PyTdKOcEknkB7xjmW6VTzSVVHJHofzKcgGClsZEFIc1Cebe Q==; IronPort-SDR: 53w5cCa5sRJK5NzY39J9XwRunGhqO2IzhJYQD7pM4YprOVRVTLjdUpt3Oryd+IhDv1rrOreVy/ RDSWiS/V4JGkV9wM5CbWE1LfHmfvrRq7XAsd2WhymNxzXn0wErqcsRJqhgx+diEYPi9OCKuVdk NPfZQ75XUgzgZI1uibUCdwoqI3D01987/C6y8Eqi5WZTLsnfXAp8vTBzHKdkzFWqd30a3JAJmu Pa8APl0w2gq1NwHyE6HQcSf8F8p/72pLvf56DIiXpfxD+6SxlG0Gqm8bbwlyUsMW57+s/8iex9 LTo= X-IronPort-AV: E=Sophos;i="5.78,383,1599494400"; d="scan'208";a="264005915" Received: from uls-op-cesaip01.wdc.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 01 Dec 2020 12:15:19 +0800 IronPort-SDR: UqEen0blP2gIFgKZV2ap2uXdX9PGwE1wqVWGaNt0kUgL5gLBIkiojg/OpVbDdudGBahNChkCXA 4EPKc5QvVbSnufeRo3hNBCtH6OyEKhxuA= Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Nov 2020 20:00:55 -0800 IronPort-SDR: //xZ+qNsQRcAGeKCluZYuo0aHD1Fp1gdnJAggnvul6GPdSwObZMVXcGJymVr1bni4SUp1y9Rwi 3XYh8f/KljCg== WDCIronportException: Internal Received: from vm.labspan.wdc.com (HELO vm.sc.wdc.com) ([10.6.137.102]) by uls-op-cesaip01.wdc.com with ESMTP; 30 Nov 2020 20:15:19 -0800 From: Chaitanya Kulkarni To: linux-block@vger.kernel.org, linux-nvme@lists.infradead.org Cc: sagi@grimberg.me, hch@lst.de, damien.lemoal@wdc.com, Chaitanya Kulkarni Subject: [PATCH V3 7/9] nvmet: add zns cmd effects to support zbdev Date: Mon, 30 Nov 2020 20:14:14 -0800 Message-Id: <20201201041416.16293-8-chaitanya.kulkarni@wdc.com> X-Mailer: git-send-email 2.22.1 In-Reply-To: <20201201041416.16293-1-chaitanya.kulkarni@wdc.com> References: <20201201041416.16293-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 Tue Dec 1 04:14:15 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chaitanya Kulkarni X-Patchwork-Id: 11941887 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 526C9C64E7A for ; Tue, 1 Dec 2020 04:16:16 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D6FAB20715 for ; Tue, 1 Dec 2020 04:16:15 +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="pPJovK4F" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728049AbgLAEQP (ORCPT ); Mon, 30 Nov 2020 23:16:15 -0500 Received: from esa6.hgst.iphmx.com ([216.71.154.45]:13185 "EHLO esa6.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728039AbgLAEQP (ORCPT ); Mon, 30 Nov 2020 23:16:15 -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=1606796175; x=1638332175; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=DGst3WtKZogqGUvuhSXY1Do01tQZeR4MGYSWqYweif8=; b=pPJovK4FH9VSlnr7Li2pHPWKsdbPUWJlOXEPksRtZD2OqjzAOZl408cr YHVBsaLlH6DQxewhlRM5GABVoUZLSBv+x5e/ac5Th4lqaLiberLoDxSD1 QQ+o3EA1XOySvRgerjPQjiz8x24F5LZdAhJlS6r9wTEWFDzRR+FG83Y74 Usy/KRJ9uay6/S9Hgisf5D+EGKYQrMXu5u0jAEymDRAK2NQAnekPefQ0f /UpBvHPznYhsbKk0hHvMqMH1V1GMZLkMPGJPp7zSQrxsh6Qg3k1lvhZCC 2Xxobfs76Xxc6M1p/h/xb2LN631trfW4A4wf+8N0MUAVHDKi6FRSnLT25 A==; IronPort-SDR: 3dbcpKrfSkblsgJUAVASGjMzc7ODDoO29Jz1FIkNvUVoNpYtRWgzrgQTNzZxunIligKdAihh8B wPSPD4T1Nr/JX9lfqtz9PFQDHf1rgzIbwn1okA+OnYa2DMSSCKEjwtkiLqET34LHuphZnMN/KV LNNSPkgIR9qkbqMpGWfr4SOnjrHp0UCE/pPTOf3Xu2Zl4ZtkINvFEjyAKjaPeVDmCcvcRL4p8e dnJGhQLKy1OawvsRl6Y7iXZJ2P6sm8oTrK0AQHRd1xSJgSwNSb4vahNLwfno0M0Fs4T+rLog2Q ycA= X-IronPort-AV: E=Sophos;i="5.78,383,1599494400"; d="scan'208";a="155078201" Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 01 Dec 2020 12:15:27 +0800 IronPort-SDR: P+kmGW8GUScSXbGJXHtxlaV8GNbSLQz7XxLZPjcQVEGv/ksHK8dmbguNp0bikAocsQ/mqqsk5d aBQ2K4stmFy/ylW/hsW8P1B4I2g4eWflU= 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; 30 Nov 2020 19:59:39 -0800 IronPort-SDR: oOK355WftzbW+cpLDbRUEOgaJ9Q54PUztkfR5GVdew0njI760zH51zNV2nucOhyUy42YzZnvQf NVwIxHV2/ttw== WDCIronportException: Internal Received: from vm.labspan.wdc.com (HELO vm.sc.wdc.com) ([10.6.137.102]) by uls-op-cesaip01.wdc.com with ESMTP; 30 Nov 2020 20:15:27 -0800 From: Chaitanya Kulkarni To: linux-block@vger.kernel.org, linux-nvme@lists.infradead.org Cc: sagi@grimberg.me, hch@lst.de, damien.lemoal@wdc.com, Chaitanya Kulkarni Subject: [PATCH V3 8/9] nvmet: add zns bdev config support Date: Mon, 30 Nov 2020 20:14:15 -0800 Message-Id: <20201201041416.16293-9-chaitanya.kulkarni@wdc.com> X-Mailer: git-send-email 2.22.1 In-Reply-To: <20201201041416.16293-1-chaitanya.kulkarni@wdc.com> References: <20201201041416.16293-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..e1f6d59dd341 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_enable(ns)) + return -EINVAL; + return 0; } From patchwork Tue Dec 1 04:14:16 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chaitanya Kulkarni X-Patchwork-Id: 11941897 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 1B72DC64E8A for ; Tue, 1 Dec 2020 04:16:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B2FC0206C1 for ; Tue, 1 Dec 2020 04:16: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="FO0ia798" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728074AbgLAEQd (ORCPT ); Mon, 30 Nov 2020 23:16:33 -0500 Received: from esa6.hgst.iphmx.com ([216.71.154.45]:54620 "EHLO esa6.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728039AbgLAEQc (ORCPT ); Mon, 30 Nov 2020 23:16: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=1606796192; x=1638332192; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=KZvesihZxqvpooUM98Q5I5u1Gk/h9BuWE3/slZ8Ndhs=; b=FO0ia7980e+O4hWlx1QkVEwHXZzAXnh/yPQSWsnRI3U3RM0SJpXqE4E+ y2Rf443k/TDXjuNrofxP5+8VYqkWuVq+kOa7mA+nkGAO+05uJwk2dS4Rw YhN5CzuwCr5u2yBAZTM92XOkY+27mXPQOYpvnmc+QXdmULJEQvJhp4uBO v1dZGFqP6QmtRMKPASj3ykUFTuzSc/LegMek0VIgZ55lSPkQjhIFUYohh KpJz4gfqD5xgLOhhW/pQ1VQkBHIJQhXD4CmLK9rv4dj9OdI21Dl7mw+GW jcCk6Ei3BAwhTn2gIsN8w9CwZx1PhWEwmonRdIsVGNwpZOhsSSDeiiAUN g==; IronPort-SDR: IqOdSwI2y53EnAuBNek2++oNTfqz0NxhbUbTXAvfmO4cIdwRQibTSX/QhoDEZeyjI9/aqD3Jfo +kdHC3wCpggsMYo0BxvYMRSiJrdR2vpvv+w465K9Yjq8PWM2PCB3cG9V7vBu9Wflmz4IZD0dWP +fS5lL0VYnqp7GqEEo1DCj/0sJsZ0XIy8BACUh1topRvo5ws+kILvNaRA4ovVGcxcTdr0feo9f UIdTz7GTzP4yrn01FXa//YQ7zeaY5jUDKARJgNlbTt0AHaXKGLQJFjUMsW52EnXBsM9Gl7GKID jXM= X-IronPort-AV: E=Sophos;i="5.78,383,1599494400"; d="scan'208";a="155078210" Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 01 Dec 2020 12:15:36 +0800 IronPort-SDR: fko7w8PeT46ja1Gw2XY8+lt7ii93zy4mZCKRF/vJ76nBniheEwVRtI9f/T1vTlojWDpO+MePAm 1BvZyd3In2c1xHpqlMqrrFQBlmmpRTpD0= 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; 30 Nov 2020 19:59:48 -0800 IronPort-SDR: nb5WqBJEDzev6Bbho0xCLsxDriknavT5buwPk4zbaeOYOwmzpRPRosFSFyiFKBwhO1T1zPIUrW ACs1nuPZch+g== WDCIronportException: Internal Received: from vm.labspan.wdc.com (HELO vm.sc.wdc.com) ([10.6.137.102]) by uls-op-cesaip01.wdc.com with ESMTP; 30 Nov 2020 20:15:36 -0800 From: Chaitanya Kulkarni To: linux-block@vger.kernel.org, linux-nvme@lists.infradead.org Cc: sagi@grimberg.me, hch@lst.de, damien.lemoal@wdc.com, Chaitanya Kulkarni Subject: [PATCH V3 9/9] nvmet: add ZNS based I/O cmds handlers Date: Mon, 30 Nov 2020 20:14:16 -0800 Message-Id: <20201201041416.16293-10-chaitanya.kulkarni@wdc.com> X-Mailer: git-send-email 2.22.1 In-Reply-To: <20201201041416.16293-1-chaitanya.kulkarni@wdc.com> References: <20201201041416.16293-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/io-cmd-bdev.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/drivers/nvme/target/io-cmd-bdev.c b/drivers/nvme/target/io-cmd-bdev.c index e1f6d59dd341..25dcd0544d5d 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);