From patchwork Mon Nov 30 03:29:01 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chaitanya Kulkarni X-Patchwork-Id: 11939641 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 6C083C64E7B for ; Mon, 30 Nov 2020 03:30:31 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 38B8620663 for ; Mon, 30 Nov 2020 03:30:31 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=permerror (0-bit key) header.d=wdc.com header.i=@wdc.com header.b="ONWJ7pQ0" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726791AbgK3Daa (ORCPT ); Sun, 29 Nov 2020 22:30:30 -0500 Received: from esa2.hgst.iphmx.com ([68.232.143.124]:10519 "EHLO esa2.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726000AbgK3Daa (ORCPT ); Sun, 29 Nov 2020 22:30:30 -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=1606707779; x=1638243779; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=nbiHUyaUtN1lM/VRyvOM4VWz5z/jZqsgAj2Gp0q3iN4=; b=ONWJ7pQ0P5HVIq8w8RlZjUIOwYYd7TAJKiL0cWV5U8OMDuW5kl9yc0Bt Fgs/IG8fuKsbkobqhP+C+3yTJPfVGsTm2d1xUuF+ZisUXdocLV9J93Gqj yvrOIAp2DKilm2kn1OkRLOGGkljH6XYU7GqPp8PuBMioM+TDDXVS7YdlF CUqhzP4MH1MQh58JSaH0TFdBzNWgbj6YBtSPcuJRgdyLtONvzGRL4GkrU Fx96xHxwYcRubnqbupk31GrueEGlC30yP1K3PRmbE8yQX3Jpn0nEKsIGL G2sEI6DJLHt0C/trkvv1PPIZlbWpkFanr2p60WKBfc/3KyEGrKnRJV/KJ Q==; IronPort-SDR: UtUSb2Wf8Bop/UGiqnW622zqSVci9BSMk8aw9qgkE6BgBbC+hdn8MxZ4rI/aqLBG361P82GSfL ApYd7HeKeukexx8GafLxnB3/8Q30kAUgY2X5FzbzYgZ213oGoDgp4vZ/6bW6BXluhWKLWoq30R 5RCmiop41Klgr42/the02C75IqWR2zfhQ/fLF60DphexdIuMw+COhZ5zMoCjrdLZUBqrfpHBux RLJkXbVpycnHr6fI4SjmefYDKkipeZcH2Xw6wLPtpV7HGd5PMEIw5G65kUvy99pDSp7frTRddh cRA= X-IronPort-AV: E=Sophos;i="5.78,379,1599494400"; d="scan'208";a="257450805" Received: from uls-op-cesaip01.wdc.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 30 Nov 2020 11:41:20 +0800 IronPort-SDR: fWvj0cSG3nkANOnpL4KtZPNsTvKuaPs/lNm1nmMH3mcPd/WkqRJ/npHNiReoiRxhdhHpc2wuOP NeXaIbZ5UHamzT6qZy8cIBFlOuLChnRX4= 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; 29 Nov 2020 19:15:02 -0800 IronPort-SDR: GazJEliYlREQMQuOCVUEF9CAajpza3ubcbWR5sBmkfF2VRciHRbrsmjlR389fDQZ4o9PP5SJeU LFsLbRIPjoFA== 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; 29 Nov 2020 19:29:24 -0800 From: Chaitanya Kulkarni To: linux-block@vger.kernel.org, linux-nvme@lists.infradead.org Cc: hch@lst.de, sagi@grimberg.me, damien.lemoal@wdc.com, Chaitanya Kulkarni Subject: [PATCH V2 1/9] block: export __bio_iov_append_get_pages() Date: Sun, 29 Nov 2020 19:29:01 -0800 Message-Id: <20201130032909.40638-2-chaitanya.kulkarni@wdc.com> X-Mailer: git-send-email 2.22.1 In-Reply-To: <20201130032909.40638-1-chaitanya.kulkarni@wdc.com> References: <20201130032909.40638-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 Mon Nov 30 03:29:02 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chaitanya Kulkarni X-Patchwork-Id: 11939643 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 53D5BC64E7B for ; Mon, 30 Nov 2020 03:30:41 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E98FC20663 for ; Mon, 30 Nov 2020 03:30: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="E91KesgP" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726861AbgK3Dak (ORCPT ); Sun, 29 Nov 2020 22:30:40 -0500 Received: from esa4.hgst.iphmx.com ([216.71.154.42]:38374 "EHLO esa4.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726000AbgK3Dak (ORCPT ); Sun, 29 Nov 2020 22:30: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=1606707037; x=1638243037; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=Ih4d1u4hQxuhrIjjv9m2YMEVWiaNz1KXoZr4A/gSzJ0=; b=E91KesgPyzA/WBBOHRxo/vWSQNOV1gb9xu7ZlaOoWxEgUujUIPIN+3pM tfK322Txf/VkmN2M9lORjBkfxTC4z548YvZsxPBc5OXtip9ZXGM0Y8+GB 2ktMlZhLQH/PyQquiOZzMRG8XVvXy9evTCvFheX8brOgWWBYdK0MmsKhz l8rXD9DhrW4S/s0cb/O3XSnFQ5XUOKnBRhR4pArn340bfCOposVwp+AeB crV5fSvb31au/LQ83PUmfbQEUk4sqKkfsgTofvUuSohc+vzmk+wJdIdVU wM2kLyuBOzXeMRnE015nt1kGgTqjvwbO1eAEqEmhnRQtvm50RvqiiaKUB w==; IronPort-SDR: 56UsCG5xp+WUSx2ch+WSBEL8b71oEYvvUdRUdmfQfs13MvM3CbfABOe+V7oZHVWJZUU2oXtMMm QehuQCvpEkfQMYirCqI+VBZ8sd39uumOmhgxS1WtpicdJpo6YTnY1aWxqi6ltNirEnoz62YzA0 GULYv/evQ6OhfuGV4k5rld2kUpaPWAbkYDKIDuFJvh3AufqQ1rI39F97szMscAKyh36IoHlUbB hQF6ZE8W+6a2mslwH+zrpK0aoACivSP/wOqigfUECca9pAC7cdhEmG1pAThX4tk+jXGnYwuDfF 0iM= X-IronPort-AV: E=Sophos;i="5.78,379,1599494400"; d="scan'208";a="153710323" Received: from uls-op-cesaip01.wdc.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 30 Nov 2020 11:29:32 +0800 IronPort-SDR: HuaOEgtGlMNZ0fCWX7waR5ef7GeHEJQhO+gE245c0dWJ07EYR0mZrRiHjaUNbccqJNU81hjEc4 EHZTyDEY1s2CAiF9l8CZ80V0mayP2Hclw= 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; 29 Nov 2020 19:15:09 -0800 IronPort-SDR: GpU5pdSaJzIH3ZUu0olP2LjBqSzidkDZOGVC3sCL+S7cgNb1iS7lPG0A0IgC2yhSsEO9i2SBBX s9Q57tjEphUQ== 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; 29 Nov 2020 19:29:32 -0800 From: Chaitanya Kulkarni To: linux-block@vger.kernel.org, linux-nvme@lists.infradead.org Cc: hch@lst.de, sagi@grimberg.me, damien.lemoal@wdc.com, Chaitanya Kulkarni Subject: [PATCH V2 2/9] nvmet: add ZNS support for bdev-ns Date: Sun, 29 Nov 2020 19:29:02 -0800 Message-Id: <20201130032909.40638-3-chaitanya.kulkarni@wdc.com> X-Mailer: git-send-email 2.22.1 In-Reply-To: <20201130032909.40638-1-chaitanya.kulkarni@wdc.com> References: <20201130032909.40638-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 | 463 ++++++++++++++++++++++++++++++ 5 files changed, 486 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..40dedfd51fd6 --- /dev/null +++ b/drivers/nvme/target/zns.c @@ -0,0 +1,463 @@ +// 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_zones_to_desc_size(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 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 int nvmet_bdev_validate_zns_zones_cb(struct blk_zone *z, + unsigned int idx, void *data) +{ + struct blk_zone *zone = data; + + memcpy(zone, z, sizeof(struct blk_zone)); + + return 0; +} + +static inline bool nvmet_bdev_validate_zns_zones(struct nvmet_ns *ns) +{ + sector_t last_sect = get_capacity(ns->bdev->bd_disk) - 1; + struct blk_zone last_zone, first_zone; + int reported_zones; + + reported_zones = blkdev_report_zones(ns->bdev, 0, 1, + nvmet_bdev_validate_zns_zones_cb, + &first_zone); + if (reported_zones != 1) + return false; + + reported_zones = blkdev_report_zones(ns->bdev, last_sect, 1, + nvmet_bdev_validate_zns_zones_cb, + &last_zone); + if (reported_zones != 1) + return false; + + return first_zone.capacity == last_zone.capacity ? true : false; +} + +static inline u8 nvmet_zasl(unsigned int zone_append_sects) +{ + unsigned int npages = (zone_append_sects << 9) >> NVMET_MPSMIN_SHIFT; + u8 zasl = ilog2(npages); + + /* + * 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 zasl; +} + +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 appned 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 (ns->bdev->bd_disk->queue->conv_zones_bitmap) { + pr_err("block devices with conventional zones are not supported."); + return false; + } + + 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) +{ + struct nvmet_ctrl *ctrl = req->sq->ctrl; + struct nvme_id_ctrl_zns *id; + u16 status = 0; + u8 mdts; + + 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). + */ + + mdts = ctrl->ops->get_mdts ? ctrl->ops->get_mdts(ctrl) : 0; + + id->zasl = min_t(u8, mdts, req->sq->ctrl->subsys->id_ctrl_zns.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) +{ + u32 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 = bufsize / nvmet_zones_to_desc_size(1); + int reported_zones; + u16 status; + + 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)); + + 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; + 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; + 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; + 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 = op; + + 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 Mon Nov 30 03:29:03 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chaitanya Kulkarni X-Patchwork-Id: 11939669 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 AF42EC71155 for ; Mon, 30 Nov 2020 03:31:22 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 678B520705 for ; Mon, 30 Nov 2020 03:31:22 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=permerror (0-bit key) header.d=wdc.com header.i=@wdc.com header.b="lqBYJl2H" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728240AbgK3DbL (ORCPT ); Sun, 29 Nov 2020 22:31:11 -0500 Received: from esa2.hgst.iphmx.com ([68.232.143.124]:10519 "EHLO esa2.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726304AbgK3DbL (ORCPT ); Sun, 29 Nov 2020 22:31:11 -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=1606707840; x=1638243840; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=AZ0ASPEdFnz/BJCpcrFT1z2buOCvE1xQZBqdQG2WuUM=; b=lqBYJl2HbbnbTW5PVT+9GOcGSp9rjBLuoffslBVpHOG50QPcTM11IXE0 +NheZGHhafVsrT55LozlFDhtlKBrmzhljP8BVaTXxVgmEWQKV5z51rDRR wI+2luEZ32nJa/FcYxALNnf3Qv9yv4z2GX5/L0LVg9CrmHEMmdM0OX+Xx pxuZoetRr1qIh10QqhXdFkXcA+2ybtWFdezhN7sb3ZVcG2jR0USmSfn2n xJ9QZ3YnF7vrk8yd4UQ7/zn3Gq85fgi9BaYaiJu4xIKFqRoiiR/2dxD0W 0rC6rxkH6UEi9Yquj6Nb0GPK8RGIjpo65Bbh2+JYFPeyd1yCAKlXCZpEk A==; IronPort-SDR: iOD7xjCYy1F7DExZRcQIJOXu0OjPBZCFSjD36pFaoGhmiCLrPUeZbCceMpcJZ6ZOaRAdjBAFY2 hoH2A7hErY5fSB1jIHpsjBIT8OcYalpn5zVpMXXBMgk5df1hCqskKqfYf17RRxg6Lf0h+VMKeu tPCjhu1lE75dJvnaAw8VY9Fias6n+88ecXcxgZXO378VTdeYRIR4pMLTvDnbGAzAIVrEgR1/iA 2dHRWvuPreJiKwwCOFRMRBlVpNKe7obQxCgMMRN0FSVkpJziusVQ2KG4Kj6/Gk1gXUrwVVYSPT KoU= X-IronPort-AV: E=Sophos;i="5.78,379,1599494400"; d="scan'208";a="257450823" Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 30 Nov 2020 11:41:43 +0800 IronPort-SDR: hI2I/02BGViqQoImEI3XWhzVXAedpyT8cEH/aSD/+IvdmecZlJNX4lvSUrohZgTXnd0xh2FxX4 AL3Gku13ThfGfmOeJZP2pzdhddGa3xAws= 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; 29 Nov 2020 19:13:53 -0800 IronPort-SDR: yKyMZjhNk/mnExspfaixYDt4y+icg4sZftOOtN/oNyNL08lCZ87fPtnoUGYT879cStE/buz84X PWlWyymkpzAA== 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; 29 Nov 2020 19:29:39 -0800 From: Chaitanya Kulkarni To: linux-block@vger.kernel.org, linux-nvme@lists.infradead.org Cc: hch@lst.de, sagi@grimberg.me, damien.lemoal@wdc.com, Chaitanya Kulkarni Subject: [PATCH V2 3/9] nvmet: trim down id-desclist to use req->ns Date: Sun, 29 Nov 2020 19:29:03 -0800 Message-Id: <20201130032909.40638-4-chaitanya.kulkarni@wdc.com> X-Mailer: git-send-email 2.22.1 In-Reply-To: <20201130032909.40638-1-chaitanya.kulkarni@wdc.com> References: <20201130032909.40638-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 Mon Nov 30 03:29:04 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Chaitanya Kulkarni X-Patchwork-Id: 11939645 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 2D3ABC71155 for ; Mon, 30 Nov 2020 03:31:06 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D206422240 for ; Mon, 30 Nov 2020 03:31:05 +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="IeWxcpjf" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728345AbgK3Daw (ORCPT ); Sun, 29 Nov 2020 22:30:52 -0500 Received: from esa5.hgst.iphmx.com ([216.71.153.144]:7669 "EHLO esa5.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728316AbgK3Dav (ORCPT ); Sun, 29 Nov 2020 22:30: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=1606707051; x=1638243051; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=hpoI1V55y5gwFhJlJIS3F+nAY0E41Z5thazQ0M5y7lA=; b=IeWxcpjfcwrgjAWAWilh+lNL1Rdkq39rrmrAsHu9neWzD0KZk6LrM6Vv +KG+A2cAblguVGBhkWtB8hdi958dWJvkUCEsl27bPySVWnk7eIomtt+Ku sSYcT5LZPQpPJOHf+m5R5L/jqjiGTmRwM/7GVuhDGqgbzillEf1p6r0Lb QRPYIgTHlLkJ7P1bFwkct0otYr+Y9zTzphB/QkROWu9BlICQA2ptpdj8T 9grkTXC/VdCNB9jslNvB0vrXjKjhv4xp22WyDe4LxzTZTVylxpU6szB2z e7XvSklKxWP48xPlS30mUnVyXJXaPylPMH788fNokERYYP6ATQwCyM7IA w==; IronPort-SDR: gc34GLN1gOILGMj2J9NdQxVTnnGgQYhMLKRP3oRliCyTKiio3uVtVdpwicGlaXnzIrZRC5h2Jf w/jIbGPQgksW+KZ5YTF+IFQ0MmO0h6XM6xo+QXmFS2STGV7rvU9rZKMw/oXOPCzLROCKsWtpXw J2+t+UCP8wItc2h32YFIvIeBWp/OR//kbQrbXELLGmfQ1A5dKZj8LsbR4aOzqQCnD9oj34Lbzm rb5XHxIgS7i+i/l+cKkKQocwqa6wP/s9Ap/Tz4ybrntfrZHng2sZb6yxS37U2QfAO2KkMcS47H 8SU= X-IronPort-AV: E=Sophos;i="5.78,379,1599494400"; d="scan'208";a="153844119" Received: from uls-op-cesaip01.wdc.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 30 Nov 2020 11:29:45 +0800 IronPort-SDR: GgeB9HL+m3guBQ/Xyi2DySyvq6UTW8zz9ISY6a11Q86uQvRXncMP8ijrllt/AdHJ6Ok6BpwDJx A5GqGHN4HuGwcnwjER3x+9Zu1rfioqQoA= 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; 29 Nov 2020 19:15:23 -0800 IronPort-SDR: 6xWCH0RaF8WNbAwW/PPWh9osExPyzV/1nidU+0Z3OEJdmdikHsqbn/84veuNpiweFXykiE+nKv w97dQe4exBQg== 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; 29 Nov 2020 19:29:46 -0800 From: Chaitanya Kulkarni To: linux-block@vger.kernel.org, linux-nvme@lists.infradead.org Cc: hch@lst.de, sagi@grimberg.me, damien.lemoal@wdc.com, Chaitanya Kulkarni Subject: [PATCH V2 4/9] nvmet: add NVME_CSI_ZNS in ns-desc for zbdev Date: Sun, 29 Nov 2020 19:29:04 -0800 Message-Id: <20201130032909.40638-5-chaitanya.kulkarni@wdc.com> X-Mailer: git-send-email 2.22.1 In-Reply-To: <20201130032909.40638-1-chaitanya.kulkarni@wdc.com> References: <20201130032909.40638-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 Mon Nov 30 03:29:05 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chaitanya Kulkarni X-Patchwork-Id: 11939671 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 67645C63777 for ; Mon, 30 Nov 2020 03:31:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1838F20757 for ; Mon, 30 Nov 2020 03:31:34 +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="B7zQlVUj" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728606AbgK3Dbd (ORCPT ); Sun, 29 Nov 2020 22:31:33 -0500 Received: from esa5.hgst.iphmx.com ([216.71.153.144]:7669 "EHLO esa5.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728316AbgK3Dbd (ORCPT ); Sun, 29 Nov 2020 22:31:33 -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=1606707092; x=1638243092; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=+iv8i8xvGTKjTFiSy9i/jgbNCBRhvNbZSotD5vVTWDc=; b=B7zQlVUjpQhB+TxGszzissP/i90gyIndK+Z50Pk2el/xVav3hiudQRbs SkW2IhAGqG4AGFP5ubFVewdf/Vyv4y5F8P0SlYLOIHTzUoEkMcVtQPjqX wWiLqBWgysGW9BOF9yGvHr/OvqGBqdMwOwDCRWr4SwaxB+jKMxPKNLysA JnxwLxt6D+XYRN8WUcLB0FhaE8dfUxZV3Ss1vn3wJH90T8x0FHN8UFtKY lLP2Kd19Rglp8gMm4jknAg2EVhOPZMoH4jiGmJDqcXXTmJ6Er9JJmzBhX /QsKXGgnJwlZpxq8rNV33p94KOkB5bm2Ae6K1EFY2YjblycgSDuWI4W6P w==; IronPort-SDR: RfownR/igd/+cQ2lzPzDTDE4DIklwiLMHhoTEWpqPqnZX23q+7JeXFcupm8KayvIGMPMy8MSSI mMoEejbz2CjmRG1f65M3fDRcfn56IUpUvCq2LGEkfZbhGu+zWjmW3Smg1LO2JR7I2k4BAo79aF qMW6qdYNlAvFVtONp45SkaEK15g8XfZ1e7WFLu1pKhHKe7S9vFFyjAicrvO5JBQjaUpwcrnGm2 Mg9LT+QNBDhe9xrneZ59Zk2z5CvtFliaoAkcpXQnk/uAGPKB2lTda5Q2g0DyOevPq0cVKp1dq/ ktI= X-IronPort-AV: E=Sophos;i="5.78,379,1599494400"; d="scan'208";a="153844127" Received: from uls-op-cesaip01.wdc.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 30 Nov 2020 11:29:52 +0800 IronPort-SDR: R5Oe9Tzsnn8GQKn3IpqJfHYiS+d2AkCR9JpSW/lTwcm6J9cEolKj0sRR8Qeo8qFahiO9g9VI1x K9R8htegaVJrGT4MdfXPODhzI66AE22HU= 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; 29 Nov 2020 19:15:29 -0800 IronPort-SDR: ZghdTP2hUjm0I1Qgwto2KfQJ9OGlJkbo1+lSPAJEzbmb15HOrtNBh91W5okyYiyTe/4R+GSkZb 5DTBgMLHPVUw== 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; 29 Nov 2020 19:29:52 -0800 From: Chaitanya Kulkarni To: linux-block@vger.kernel.org, linux-nvme@lists.infradead.org Cc: hch@lst.de, sagi@grimberg.me, damien.lemoal@wdc.com, Chaitanya Kulkarni Subject: [PATCH V2 5/9] nvmet: add cns-cs-ctrl in id-ctrl for ZNS bdev Date: Sun, 29 Nov 2020 19:29:05 -0800 Message-Id: <20201130032909.40638-6-chaitanya.kulkarni@wdc.com> X-Mailer: git-send-email 2.22.1 In-Reply-To: <20201130032909.40638-1-chaitanya.kulkarni@wdc.com> References: <20201130032909.40638-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 Mon Nov 30 03:29:06 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chaitanya Kulkarni X-Patchwork-Id: 11939665 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 564D5C63777 for ; Mon, 30 Nov 2020 03:31:22 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id EF65220705 for ; Mon, 30 Nov 2020 03:31:21 +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="HDdVQZ01" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728491AbgK3DbF (ORCPT ); Sun, 29 Nov 2020 22:31:05 -0500 Received: from esa3.hgst.iphmx.com ([216.71.153.141]:30921 "EHLO esa3.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728316AbgK3DbE (ORCPT ); Sun, 29 Nov 2020 22:31:04 -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=1606707063; x=1638243063; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=m/bvl+lK7ll6HRYiQ0kG1ndR5SFePuzrxfzuz5g9atQ=; b=HDdVQZ01MelWNtD4omtMk96mCMAdp3PoCrbvIsilr9UObMQAvjj2lHqX XRbBl5oktdVwm2eS9qflP/s5b7+BGGt4pS5P4C3rAY5izwi2SbwIVOEta vBwF8CApDSZhlRQEMO6e4ybImHQhxDxeabTslDtTh42aPKuJOviGU9L8/ VgO4tSH7v8/jYjzumGYdXcTlAv4RicdwAXdhSvvKqMthMREugnkaH/taA sIKmx5+5aMZEfcHzRQtmMgBjcrSNfSJoW3x2QlcnJFo+Ptn//zmRuxbvM WXSGBAnUMw/SIft8/6XZw4Cnt3aXKxKrdbj4h2yU6cfYN9c9vTDjJvu3E Q==; IronPort-SDR: TxAlE2An9q/CVwARNiv3zPizoccRASYFHdu6VkWih2bhZ3O/rY+jRdjxJFoCTt+ScanTur48CB NMI8IS32AQdMzMhMRcTf+/ecBfpJqyhoVNs5U1kuWArWdXBEFiAxN/wMvxSc02r/JmuvfrX5x4 709tcp8WaTZ1z2KvjBszRaOaE82LOe0cpfM3i0Vv2CBvd8MnQzPldY7SWJVzdPV7mdX9xhxyZ/ 2jOgNZ/5r2hGDB6Fj5Mhrt7azHBMtoCro1HxJ6MqIZGbZPsFpZjju0M49LaLlz7uW7nVzECnA8 Edc= X-IronPort-AV: E=Sophos;i="5.78,379,1599494400"; d="scan'208";a="158242330" 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; 30 Nov 2020 11:29:58 +0800 IronPort-SDR: 1etDQ/Q0tYF3kMPjJDYy8Le5jbF0l3SN+0HgnXXLyjkEg94TO2igzVAmJWPEKVU7UVWsLiBtap 5Wr5Ot5iJ98JlJbRcHxtx7+xitvEG5BLo= 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; 29 Nov 2020 19:15:35 -0800 IronPort-SDR: 1cd6sDZyQ0eW+cQgh9SqyaYRHq8ZG37xwpOgg+VbZJJk9PztxYllEcyJRy/LJq1CZAp2FZGK55 q0ZDYSBiUV9g== 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; 29 Nov 2020 19:29:58 -0800 From: Chaitanya Kulkarni To: linux-block@vger.kernel.org, linux-nvme@lists.infradead.org Cc: hch@lst.de, sagi@grimberg.me, damien.lemoal@wdc.com, Chaitanya Kulkarni Subject: [PATCH V2 6/9] nvmet: add cns-cs-ns in id-ctrl for ZNS bdev Date: Sun, 29 Nov 2020 19:29:06 -0800 Message-Id: <20201130032909.40638-7-chaitanya.kulkarni@wdc.com> X-Mailer: git-send-email 2.22.1 In-Reply-To: <20201130032909.40638-1-chaitanya.kulkarni@wdc.com> References: <20201130032909.40638-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 Mon Nov 30 03:29:07 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chaitanya Kulkarni X-Patchwork-Id: 11939667 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 88F37C64E7B for ; Mon, 30 Nov 2020 03:31:22 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 287ED20757 for ; Mon, 30 Nov 2020 03:31:22 +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="dxorGgZs" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727069AbgK3DbK (ORCPT ); Sun, 29 Nov 2020 22:31:10 -0500 Received: from esa3.hgst.iphmx.com ([216.71.153.141]:30931 "EHLO esa3.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726304AbgK3DbK (ORCPT ); Sun, 29 Nov 2020 22:31:10 -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=1606707069; x=1638243069; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=hUhzJ651cVoNvniIQeg3wff/FCoz1DE77FDFCSJt0Zk=; b=dxorGgZsqz9bCywuhSQHdWW0TyB0hKDqBniG9Lal/8/7RZerA7378Qdo yrRDorf01uOE5RVn2mg4+p9KEvQjtif8swFx4Vz2MhVsBkLh2/V9/F8WT Qjv9nYWKBCSZZ9OjXCyRhdYDIG/7KDyb2R8XswCHNH6lYiPwNN5M4vKpY pLWvS+qeYjxUg9azKw/wC8OAuN0pZfUTWFs0GcRPj4AF/KKLrct7iNEoN QCAHcq7NH1BlRPD4dQrZTadmZUbHyJ1uHXIIiFTWxdNu4viVK/04dSeXu 0OV221U2pMuI02hvPc0obYojOwBVo56WpRMQldNJLrV5WVgFBXPmBJfAy A==; IronPort-SDR: Vz8pk7GDA89gxZR/83cQca8jfR0YEDNjzzuNPVMukaqufT8+P+6CH+Tf4hOY3ONxp/bTD2e7WA 19GG67rhhB5A7u/BRmPJ6KboGlu3mcH20A17Q1aH9Dfe/6FD3+wwCWthnqdKxNvtPzL4JLXiUQ eEDfL6zC1do8UnB4zzGiTJ+Y6c1bpRBmfFl+yyK3zS/ccK9+tvZQXLltREFGIPY3r9XsJgVdLm 2K6qRRR8E7kHVwCkyrwegg/vEViSb6P4JYnc1UmonwfJZD8JwL413GbgGOsOu3PGGLMjCrUKQI dCU= X-IronPort-AV: E=Sophos;i="5.78,379,1599494400"; d="scan'208";a="158242338" 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; 30 Nov 2020 11:30:04 +0800 IronPort-SDR: UTl6zHH4ouMmnXd1mHWUdzJhQnut1NH3BnTVu1K29s/zs68PFVUjGDGemnudwGlmI0kdZoznfC z1hmp2sMGpFI9p4pb2KUukuBRvrwgyiW4= 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; 29 Nov 2020 19:14:18 -0800 IronPort-SDR: EqveP7U1iUJ9hEUH58pnDm3xDHLqLsQBe/x3lVQjWWaHN8ixfBGO2/LGRJPuSwUIw0LlcpCFMM nHFUoGOxmQaw== 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; 29 Nov 2020 19:30:04 -0800 From: Chaitanya Kulkarni To: linux-block@vger.kernel.org, linux-nvme@lists.infradead.org Cc: hch@lst.de, sagi@grimberg.me, damien.lemoal@wdc.com, Chaitanya Kulkarni Subject: [PATCH V2 7/9] nvmet: add zns cmd effects to support zbdev Date: Sun, 29 Nov 2020 19:29:07 -0800 Message-Id: <20201130032909.40638-8-chaitanya.kulkarni@wdc.com> X-Mailer: git-send-email 2.22.1 In-Reply-To: <20201130032909.40638-1-chaitanya.kulkarni@wdc.com> References: <20201130032909.40638-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 Mon Nov 30 03:29: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: 11939673 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 7E581C63777 for ; Mon, 30 Nov 2020 03:31:59 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 23B3420757 for ; Mon, 30 Nov 2020 03:31:59 +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="LyC+ETmN" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728316AbgK3Db6 (ORCPT ); Sun, 29 Nov 2020 22:31:58 -0500 Received: from esa5.hgst.iphmx.com ([216.71.153.144]:7754 "EHLO esa5.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728166AbgK3Db6 (ORCPT ); Sun, 29 Nov 2020 22:31:58 -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=1606707117; x=1638243117; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=DGst3WtKZogqGUvuhSXY1Do01tQZeR4MGYSWqYweif8=; b=LyC+ETmNEEk75e+9RRVGCR7a58Yte/yqeLiITa3Uajlcgem8P0VEHM1Q GGFHlOpuyYQun33wTw2FfmC6nomwHIseeeIxxxFSiQ2pg8jVHHhBT4sl1 9rjbMBxOnqAZ/pU5wQCA3kB90IgdL7saUzSDls3tre0yFHp4SB6v55DnG Cvb4Vo1gRnQGeKVI2SoAcQKkEy7t/K7A2EeG6Hyps/S9+8+KJ2A74FApm j6QtRvZNtj32GtM9fpYkUsWTBb28JxEloRcrCnlqJIgSH+yXSQRy1ea3m p+fKlbajJHO3vPvAOv7dYatUn5dwpF65swbAnrGkW2SJ23EblHAwvv5aL A==; IronPort-SDR: fWwqKBN5p0sp0weaEZO8F+IgocpMudEyjFkTKZFyG02ayFBNqknYvPq//IU9K/iebaHwUE5nSQ AKg7g3qsO4bHgHHrtgZiCndu8/R5LClcJKIf9rloaV83jyJio6Ace1dzsIyOgzJlrAD51KTTlT qMpeIIDoQNlZsRmvR4WMhXmfBTB6yALuN6pZqdtWtm8mgUcIjCY1JK4mhcXjSX3uKBgx9cH3tY yUDAXRbJz3uwuT6qRaWeOxhRoi/r0Ni+/QXoxRjkJnznCU9L0XSU4PDsSFTgOlbYD+oRYEpn9M fd0= X-IronPort-AV: E=Sophos;i="5.78,379,1599494400"; d="scan'208";a="153844153" 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; 30 Nov 2020 11:30:10 +0800 IronPort-SDR: 3BhrUJ7UJ81MNFjhPIi3V00CqXIowBMgqp6ebfIkRKKM2kjo8TwbrFPQdMPLABDZ6UCo9jQuP2 TAKLd5/8wPEcnKYz4dg1qHgfB6G4R4Za4= 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; 29 Nov 2020 19:14:24 -0800 IronPort-SDR: beHalbNxexlazcYB3ByP8QAzY/houumBdrNcMA4pNHhuKyW7zGlJZqaR49S4z1XNtqkK4G/8If 2/OJqRDFfZEA== 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; 29 Nov 2020 19:30:10 -0800 From: Chaitanya Kulkarni To: linux-block@vger.kernel.org, linux-nvme@lists.infradead.org Cc: hch@lst.de, sagi@grimberg.me, damien.lemoal@wdc.com, Chaitanya Kulkarni Subject: [PATCH V2 8/9] nvmet: add zns bdev config support Date: Sun, 29 Nov 2020 19:29:08 -0800 Message-Id: <20201130032909.40638-9-chaitanya.kulkarni@wdc.com> X-Mailer: git-send-email 2.22.1 In-Reply-To: <20201130032909.40638-1-chaitanya.kulkarni@wdc.com> References: <20201130032909.40638-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 Mon Nov 30 03:29: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: 11939647 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 8357EC83011 for ; Mon, 30 Nov 2020 03:31:06 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 302E722210 for ; Mon, 30 Nov 2020 03:31:06 +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="UBdvyebJ" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728480AbgK3DbD (ORCPT ); Sun, 29 Nov 2020 22:31:03 -0500 Received: from esa1.hgst.iphmx.com ([68.232.141.245]:54598 "EHLO esa1.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728316AbgK3DbC (ORCPT ); Sun, 29 Nov 2020 22:31: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=1606707062; x=1638243062; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=KZvesihZxqvpooUM98Q5I5u1Gk/h9BuWE3/slZ8Ndhs=; b=UBdvyebJc2SOdg+ELh6SZqEifbF43g++iuH7JxGv0x22eiv2p+8sR5Qd sGki3AXkfHh+FCzYlFzuIIcj3OczxrnnvI1cp4SI6I9PR+5fGtb1u+cUa x7G/fGYBKuVimSDbQpU5lOiZvIjJ5Pqj1NwGQYgLYGT4emb984Ug5eOfv hoxWfHN/yH/BkZmz11iQfh6oFCg2GYbJbBOyDrsROkVEfzHzXgIMZ4VIj 8k4pbnZXgZxuiQyxAbgXS1fX3MsC2QF8HLNtdwOuSJKJLRYSMZMIXJQY3 CCzw3vhfVNNB8hM9XD17jxbjIuwY1S7gme7f9Q6a/2PNVvNFI3g3QGyHI g==; IronPort-SDR: q6auArkCvMXP5GfT3QlRBRR58YIruQbcldjguEJSSSJiHez2vQNrADn1bhlyykvg0dxmh031Yk WpC0x1QUZmbSVEXni8Ooj+Q/MipyhcI92oN++h8vLtYXpi2du802rw0f3sBH9G828196mtGhkD SLWgvPAEIjvRCILSGUONNfPQi0GcMYnOyMe3ptJ++w0vAj5EjyOJgv7AwGZQoboHMIzhfiIObz O9OCSCCIuJbFQisJPl7pjgMQSRMBhqydDwUuoRLM3k6q9HT+n3LawobKyg2k+rAtDA+dUCq2zK uQk= X-IronPort-AV: E=Sophos;i="5.78,379,1599494400"; d="scan'208";a="263892556" Received: from uls-op-cesaip01.wdc.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 30 Nov 2020 11:30:17 +0800 IronPort-SDR: M+kG19BmbL9kxF4oLhZ9+t5FHLIr+Qr3z4smG03AWjK9WbMY5zB2OCe9BZ1RDT2Eum2ojx8d+L uYGnG3fBfzEofho2Q8+1D8+wg+IikCilU= 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; 29 Nov 2020 19:15:54 -0800 IronPort-SDR: D/BUOXWv2eTkbgoe7jKf7dg39j2KiXkWrENICF9TxUT2qMl1QE4vc8zXddcDHx96f86j97JzMx xRrVlGunzBPQ== 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; 29 Nov 2020 19:30:17 -0800 From: Chaitanya Kulkarni To: linux-block@vger.kernel.org, linux-nvme@lists.infradead.org Cc: hch@lst.de, sagi@grimberg.me, damien.lemoal@wdc.com, Chaitanya Kulkarni Subject: [PATCH V2 9/9] nvmet: add ZNS based I/O cmds handlers Date: Sun, 29 Nov 2020 19:29:09 -0800 Message-Id: <20201130032909.40638-10-chaitanya.kulkarni@wdc.com> X-Mailer: git-send-email 2.22.1 In-Reply-To: <20201130032909.40638-1-chaitanya.kulkarni@wdc.com> References: <20201130032909.40638-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);