From patchwork Wed Dec 2 06:22:19 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chaitanya Kulkarni X-Patchwork-Id: 11944769 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.5 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 B649DC64E7C for ; Wed, 2 Dec 2020 06:23:59 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 66E2E20637 for ; Wed, 2 Dec 2020 06:23:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727932AbgLBGX6 (ORCPT ); Wed, 2 Dec 2020 01:23:58 -0500 Received: from esa5.hgst.iphmx.com ([216.71.153.144]:45258 "EHLO esa5.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725984AbgLBGX6 (ORCPT ); Wed, 2 Dec 2020 01:23: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=1606890238; x=1638426238; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=82+/5kJqGP6zI/njb0x75RSCgHH8h3QmrRRPprctKjs=; b=GtfmKMq5mCM6EVYauSfxl/2SudGYJY2r6azQ0ebzMgUTTovoo2mw0jDz xdvFbabSN8nHmIjyXHGFBfFu/7pu5vZK/EYDtvxQ13ckvpJt3M7OlJqC+ 3ghWU2kU7gMDV+PJrbE4jLY0ohlWkoU5VUv9oUbvbARL54pVdnNChnjCq O/S/AiFrRvOmItj//A0unykSZAu8DUwWnB7aazeruzZ8pgQLHQHoWgZTq U0U5NFwm8T341BHAiL+GZHYC5uomMUjRTVn4JkqVxFFe93vqmW26BZyNE 3L/WwzW2ninl8zYGaroTxKMdY7e86kT3salqRfCdLh+9cbqKlTEJEHQLG A==; IronPort-SDR: ZM7h9AecU8IOD28UkbQ4fpL1cFnRjETrqdrS2yljUSQ7XNNSP0XvVWZLbdpqi2AwIza61XlUJH LJ2CEAi/M9twMCgSRpyHM80VIavq8/7jdmWkmzhoigIcIze2TkoqKzZNXnvIgKkwS2WcYPuhM7 Ck26ouQc/YDxhpgfMT5GKt1cQy3I/gEhG/VglqThLBiVkAMKc1ZckYinRVlUFnar+B3WQ5QuDL v/8BYOt956Ld3UgY61S+87KFlrSdNne19J2dDhlAwv4r7vC2jjfy9UG5jpGAhaSJXb1U5YxFja 2PE= X-IronPort-AV: E=Sophos;i="5.78,385,1599494400"; d="scan'208";a="154060448" 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; 02 Dec 2020 14:22:52 +0800 IronPort-SDR: cwD9WDsh7jnEw7VG4K0SqcZ0hEko0uIECUbdhUX5tqpZ0PbV/dUxBOotCowxM3lNJCE582WT3s kTCkH7MttpGjL2KUHVc5KR9pcxAG2Vtr4= 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; 01 Dec 2020 22:08:27 -0800 IronPort-SDR: FNXPoB4WvPAm0gJxkZMp4eSWXqfhXKyjMr67/9mErB6XiLHz3b0Vx13uYOkiOCzfVzrFFyfv2F OVk0pD3ek5Fw== 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; 01 Dec 2020 22:22:52 -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, johannes.thumshirn@wdc.com, Chaitanya Kulkarni Subject: [PATCH V4 1/9] block: allow bvec for zone append get pages Date: Tue, 1 Dec 2020 22:22:19 -0800 Message-Id: <20201202062227.9826-2-chaitanya.kulkarni@wdc.com> X-Mailer: git-send-email 2.22.1 In-Reply-To: <20201202062227.9826-1-chaitanya.kulkarni@wdc.com> References: <20201202062227.9826-1-chaitanya.kulkarni@wdc.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org Remove the bvec check in the bio_iov_iter_get_pages() for REQ_OP_ZONE_APPEND so that we can reuse the code and build iter from bvec. Signed-off-by: Chaitanya Kulkarni Reviewed-by: Johannes Thumshirn --- block/bio.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/block/bio.c b/block/bio.c index fa01bef35bb1..54b532bb39f3 100644 --- a/block/bio.c +++ b/block/bio.c @@ -1110,8 +1110,6 @@ int bio_iov_iter_get_pages(struct bio *bio, struct iov_iter *iter) do { if (bio_op(bio) == REQ_OP_ZONE_APPEND) { - if (WARN_ON_ONCE(is_bvec)) - return -EINVAL; ret = __bio_iov_append_get_pages(bio, iter); } else { if (is_bvec) From patchwork Wed Dec 2 06:22:20 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chaitanya Kulkarni X-Patchwork-Id: 11944773 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.5 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 0F5A9C64E7C for ; Wed, 2 Dec 2020 06:24:24 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A576822202 for ; Wed, 2 Dec 2020 06:24:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728503AbgLBGYS (ORCPT ); Wed, 2 Dec 2020 01:24:18 -0500 Received: from esa6.hgst.iphmx.com ([216.71.154.45]:36485 "EHLO esa6.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728462AbgLBGYR (ORCPT ); Wed, 2 Dec 2020 01:24:17 -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=1606890256; x=1638426256; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=tuoj9/cGY2HMMSvukzu63HXembj9n6Wi7yHksMNwbuk=; b=D2e8MsZPCHneX0uw4m24rzk+vyAwFPvzzoKLnOHaXIxZmUC54OEXeArb QqC5856VfNKUAuGuZhYLCIbf1VbzUiIb/zRZmN4ZRvUImyxjs3cuA9K/T gaH+r4yVKIyJrECZpQc0jWJWiYcrTOG5MFFwsmCpZg9Q7akqOkXolCTj6 gTEA3PshXRcJKfnia/9mEThLX5SL8ffksdS7CTkWvM4+LpOT3IA5mBRdI KXyj6SsapjdRZwA/y7DSa3CiZoJHJQriQAXLRVaeWERkmwKzswihJ6KyA y39/VcuOfB7UjmCXDblznnwbzQ9wgmIVFCuZuixTnTeZ7mE196YZv3f0n Q==; IronPort-SDR: kiLZWMCJneNZ6d6hs5lnvzyIKxNha9ia11m1BUAT46WSBqzTfjCmwywnlv3XCvEaMa8QQC60DT /1vpqiiyacru05Fur16jfFn7kKud/4S5bEp4b/utB1MyPeAyr8/IpklfcaHoDXpUrOHoI+/4oW Fa22jH+nvXOMjCEuQV6iyh4CAdUBDjcs7gkjIANhOQ8jY67nnv9+sQmk0TdIAI7B037YkAvuAF 898Wp2a+ktEWp00mrCKUt2Y6tUw6frMAeAbfbN8TFPJBCB5IRG3/3JnIbV4s//aUGSwu+Me848 7Yg= X-IronPort-AV: E=Sophos;i="5.78,385,1599494400"; d="scan'208";a="155194672" Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 02 Dec 2020 14:23:11 +0800 IronPort-SDR: dqqhvhnTXelU7mp+VhtkDQ7tkBIIttsKB+UkpikVoVcbuHu0xdLGxWkNa3x/VOVpGjO3ktCZgx AY3mEK6KAH4QmUpIxAgbIbjFoRuUuU7CE= 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; 01 Dec 2020 22:07:22 -0800 IronPort-SDR: YMolA2gwpYx5i0N9RvCWDU3W/uqYxuBDnZPrURQYMNBXQAZ5ILdErH2jiyHCZ3Eb2MXH+PYSpv +P/86CCV0jOQ== 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; 01 Dec 2020 22:23:10 -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, johannes.thumshirn@wdc.com, Chaitanya Kulkarni Subject: [PATCH V4 2/9] nvmet: add ZNS support for bdev-ns Date: Tue, 1 Dec 2020 22:22:20 -0800 Message-Id: <20201202062227.9826-3-chaitanya.kulkarni@wdc.com> X-Mailer: git-send-email 2.22.1 In-Reply-To: <20201202062227.9826-1-chaitanya.kulkarni@wdc.com> References: <20201202062227.9826-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 | 417 ++++++++++++++++++++++++++++++ 5 files changed, 440 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..300e85a02854 --- /dev/null +++ b/drivers/nvme/target/zns.c @@ -0,0 +1,417 @@ +// 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) +{ + 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_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) +{ + u64 slba = le64_to_cpu(req->cmd->rw.slba); + sector_t sect = nvmet_lba_to_sect(req->ns, slba); + unsigned long bv_cnt = req->sg_cnt; + u16 status = NVME_SC_SUCCESS; + size_t mapped_data_len = 0; + int sg_cnt = req->sg_cnt; + struct scatterlist *sg; + struct iov_iter iter; + 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; + + 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[mapped_cnt], 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(&iter, 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_iter_get_pages(bio, &iter); + 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 Wed Dec 2 06:22:21 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chaitanya Kulkarni X-Patchwork-Id: 11944775 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.5 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 C6896C64E8A for ; Wed, 2 Dec 2020 06:24:24 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 71C3622202 for ; Wed, 2 Dec 2020 06:24:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728524AbgLBGYX (ORCPT ); Wed, 2 Dec 2020 01:24:23 -0500 Received: from esa6.hgst.iphmx.com ([216.71.154.45]:36496 "EHLO esa6.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728462AbgLBGYX (ORCPT ); Wed, 2 Dec 2020 01:24:23 -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=1606890264; x=1638426264; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=AZ0ASPEdFnz/BJCpcrFT1z2buOCvE1xQZBqdQG2WuUM=; b=KiX+g7t3T19GCfGMRbK306rCchJB9qoZyMmB2uvuQBP43eQMHgGnpNXY kQnUuZzUtqv4GQOyUgTZNL3sFbiZ1c8ZykZgBt0dF8OkHDHeXKp9p3RAe hajIu6aCDs2dAclv6bP7jBVFky31Ej3lrtE8KkIh7rWUkXSVR0cFr+qw4 eqxT9i/OhzItViN6UhL+BwaQIDq/iZlvLX99oxQxRxqMZ8q8Q6bRcpWJO /8XdqNwe1JLjEUxysjSFIRFgVDLgjpBUN5W6GSM6AxBDoWM64x7buSAj0 5SBjwl6s78pcVTQi0Xu9Puwncdd03mSSqa2ldwFXhFGW7EvZuq7sTkXgX g==; IronPort-SDR: hwkmERT3yucNFKHcJJ4ZAw0Js1XY4YQ0BF5Mypk86W1rOB+0C+bN+9VdASNyNTMRvQBZwEZLpl SwQbs+MyDvF8STSmUu6EuwmLip/sMWMpmQ+3Lo9tkXRhdwjxg5FbkGBMO//HZwI6s1rLQ2bpGX FEG21tRsn6GOEekvf4cx/PWeXxoHUapPn2ysQUe9FaYc7SaDWR62GTjHeZcZdm/a0sNPuvzZ8D xsor5nPXM0AXW02X3BnU2VmA4t52uRvZ3I8mRPa7DzBYMEBCRejaXR+6qBZE7ZSSezDxVVcP4L kBo= X-IronPort-AV: E=Sophos;i="5.78,385,1599494400"; d="scan'208";a="155194682" 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; 02 Dec 2020 14:23:18 +0800 IronPort-SDR: rhY/RBUgcK1NxhxjiN5sOMu/4zsOyf6M480cu3cHaKKpaJOTYjw2j3ag4KTcHiHfcnD956wF0F g3kuxPrtf3fBjCXNc0P3a2BhOErCFk0Sc= 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; 01 Dec 2020 22:08:53 -0800 IronPort-SDR: fvXvnYvW9CCbCNopboqCW4f6IOoKH6Nck7dA8qsIR76ZNVYo2e/bbbjNBVwvIGFL5YW+QXrNLm ves4U1GKZuQQ== 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; 01 Dec 2020 22:23:18 -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, johannes.thumshirn@wdc.com, Chaitanya Kulkarni Subject: [PATCH V4 3/9] nvmet: trim down id-desclist to use req->ns Date: Tue, 1 Dec 2020 22:22:21 -0800 Message-Id: <20201202062227.9826-4-chaitanya.kulkarni@wdc.com> X-Mailer: git-send-email 2.22.1 In-Reply-To: <20201202062227.9826-1-chaitanya.kulkarni@wdc.com> References: <20201202062227.9826-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 Wed Dec 2 06:22:22 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Chaitanya Kulkarni X-Patchwork-Id: 11944771 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.5 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 DDA05C64E8A for ; Wed, 2 Dec 2020 06:24:18 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8A5DE22202 for ; Wed, 2 Dec 2020 06:24:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728508AbgLBGYS (ORCPT ); Wed, 2 Dec 2020 01:24:18 -0500 Received: from esa1.hgst.iphmx.com ([68.232.141.245]:48080 "EHLO esa1.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728503AbgLBGYR (ORCPT ); Wed, 2 Dec 2020 01:24:17 -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=1606890256; x=1638426256; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=hpoI1V55y5gwFhJlJIS3F+nAY0E41Z5thazQ0M5y7lA=; b=FUlL5Air6Ufw1SNg2fSg+Xj0pQJNadyeOScOADeNVtbt7zC2ivw6GlMF 1Xbp7ThqG9jF0BFAJCs66IrRHv2Nk82iRRMm1f1RbzpKAKB1OrG6Qe6X4 mv1ckyyzz4zJoAL0j+hxtRjJdlEROzvZD8z+ZT3cV+tFqGUZUqBrhDvKL fcEmUUPxnjXYPNAefSrl2FdCdNfCN97KPYF5o1M/fGi4BjPAr1W5tUfqJ wiwi8r0tdQhB9vu//J7aUIpiTgVqP9QZgN+AafXBbaJyx5QCefMwseUOf yNiqoZXUiTUT2fX/vLRFhSc/yT29oknlzV1QmvAz1TxdLxPK9I/2OSJTZ A==; IronPort-SDR: sojTEOo5/HBO9N1ijjyYjac3MDVweNDY+VQK4v1qmBKELP4enAuGpjaE89Y6ARNwBcMxXbtSFA 5wHVxK02m/qnVJhgbjKbHLi0wEQpGVm65BPbP4OxZNiqcrrO6HauFUO9YCIjjOZjc7be7eizbt KXq9m/UnVNUIfjW5LoGgcu4mSkReK49KFeSXh70VR6wX7SF+jspEIRSvDyp01jYUxndJCEnKq5 i6RsHCDnVGBb7B2cyCRi9CvMDBhlhXgIQIUmjHmcNzE76Qpl27Vv1tCuaP0jtAfW5ME1gX8p0R 3RU= X-IronPort-AV: E=Sophos;i="5.78,385,1599494400"; d="scan'208";a="264126127" 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; 02 Dec 2020 14:23:25 +0800 IronPort-SDR: 8rFljIzY8tp7VmS/9rdL9LDtHdLI+E/DCSeUuJj4kr7HlujjEGvWM3QU83RetOdZuRg2Z3Uevy 2fpcGY2P66VVKieFKnNa3i1cKhtc5V5Hw= 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; 01 Dec 2020 22:07:37 -0800 IronPort-SDR: hBYFBf+pPzvg+2AAdZ7UtHZh9yFsJPwZOETn77uGbTPq2L7oVh4ulBd2/rSv9txkxiTWLPLEJc HKdbicUob75w== 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; 01 Dec 2020 22:23:25 -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, johannes.thumshirn@wdc.com, Chaitanya Kulkarni Subject: [PATCH V4 4/9] nvmet: add NVME_CSI_ZNS in ns-desc for zbdev Date: Tue, 1 Dec 2020 22:22:22 -0800 Message-Id: <20201202062227.9826-5-chaitanya.kulkarni@wdc.com> X-Mailer: git-send-email 2.22.1 In-Reply-To: <20201202062227.9826-1-chaitanya.kulkarni@wdc.com> References: <20201202062227.9826-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 Wed Dec 2 06:22:23 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chaitanya Kulkarni X-Patchwork-Id: 11944779 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.5 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 C8A25C71156 for ; Wed, 2 Dec 2020 06:24:40 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7D92622202 for ; Wed, 2 Dec 2020 06:24:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728517AbgLBGYk (ORCPT ); Wed, 2 Dec 2020 01:24:40 -0500 Received: from esa2.hgst.iphmx.com ([68.232.143.124]:47407 "EHLO esa2.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728462AbgLBGYj (ORCPT ); Wed, 2 Dec 2020 01:24:39 -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=1606890935; x=1638426935; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=+iv8i8xvGTKjTFiSy9i/jgbNCBRhvNbZSotD5vVTWDc=; b=dUARt9xo9Q+7z+VIdjWVMT1ewKYfXZZRzcbcKtXoNsMddjFfx2kNsB9c /s6vkJaOvxQFm8Yn84Z5kjmMmfmibnzESur6DNUxtgVtzYMsVGqrhM61i Xzoj/poqT4mqVc8BQDOkqDfSnQWfPOH6n3OKGu4qiBSIvNf3RiIPr33WJ KpULKQWVliRTYZZvATYAsArZMvPug3KQUuOuOBT7Df82OTHL8IDfBcEK9 9aM9ZeaOEX0WX3vn7XJ/DovOiX5hHMwOUVYEotsOcBKR1VIEQjmT4nry9 kZAi6BvvZntrpOVtezjLzgsq5uln28zLiZdxZKLM8/UC2g3ohtk2l5sP7 A==; IronPort-SDR: UhYhGebHjfTZq2Rn1S++ooG60AakmS/6va+SGjFUPakZZ3Supqln2EgvTNYVsup2/raFF07ULt aRiqhS/QQuGNIyEAfjevQOXnjJGfCC90q+xvFKJw4w2tKY6225YrVSlONzVzxuAt2diTRmmF5x /HxggZPzwSfJaFQ0x4RemZxQ4XYGPM5Qlv6bA1eJuuJqe5IpKx9TbBbFH17q+24bATgRRlf+/N uWOXfyF7Q1oE7lV7S+DN8bVDtBHr4ppvdLgJkh797/snAej24Fwr8CXEUsKSOm9PRo3JoEK/R+ rXE= X-IronPort-AV: E=Sophos;i="5.78,385,1599494400"; d="scan'208";a="257684127" Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 02 Dec 2020 14:33:55 +0800 IronPort-SDR: rGHMopqz6WLyUWxpnBR+qe+byti/we73b2HpGcpp38S42QtJ6J+F0/o02uGE3/T4NiSuVGqSbv Ccr2vnEldh1IGrH3lQudM1lyEaMqWczz0= 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; 01 Dec 2020 22:07:44 -0800 IronPort-SDR: zg3/OKT+VIIk3PyMmu7C/7OanNewa7QdNcxm71LM5rsyPJTpP40GpRbnVlBsOFpZUF+u2EvEYI KgII++6f+sTg== 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; 01 Dec 2020 22:23:33 -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, johannes.thumshirn@wdc.com, Chaitanya Kulkarni Subject: [PATCH V4 5/9] nvmet: add cns-cs-ctrl in id-ctrl for ZNS bdev Date: Tue, 1 Dec 2020 22:22:23 -0800 Message-Id: <20201202062227.9826-6-chaitanya.kulkarni@wdc.com> X-Mailer: git-send-email 2.22.1 In-Reply-To: <20201202062227.9826-1-chaitanya.kulkarni@wdc.com> References: <20201202062227.9826-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 Wed Dec 2 06:22:24 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chaitanya Kulkarni X-Patchwork-Id: 11944781 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.5 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 A4149C64E8A for ; Wed, 2 Dec 2020 06:24:47 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4538722202 for ; Wed, 2 Dec 2020 06:24:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728528AbgLBGYq (ORCPT ); Wed, 2 Dec 2020 01:24:46 -0500 Received: from esa4.hgst.iphmx.com ([216.71.154.42]:64091 "EHLO esa4.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728462AbgLBGYq (ORCPT ); Wed, 2 Dec 2020 01:24:46 -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=1606890285; x=1638426285; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=m/bvl+lK7ll6HRYiQ0kG1ndR5SFePuzrxfzuz5g9atQ=; b=UmMT1AHjF+PQ6W1tX+5Ve9nuL3LrlN+uqpMc9PkPaKxiRhHBuXyKfz5W KWvBRmaL1XCcMom3W4MyJXY55HEr+P/65xm7cIftlO/nKADC6z6ykWHUE VecpQkgPkvOpwDgT+LSMjEID+hnfSBS0eXLFQ5W9JMy7E91il5G/zdI4c bMcR7ehmwLh9NRhTIc8GHUZsc42wer8qVathm5BwaKlKh4EZbgR9n4Su3 gkwzpzNEYB06XBOTzGEXc+bo2CvbhNyAxDMWo1cpIKBHgc1d2VJ0aZmnc vcWgxmxmXNjo1mleSnXD3/iX0591LXANjiwsMDuNsSb8iG1walfXm/w2A A==; IronPort-SDR: N9Q0JKyxBY2Mm2bReMOXRpqlAvv3j9wCcai/yoR+1u23pfM8QenfBhRANyH0lkyyG0tf7VxveM XuZp35caUapKy4UW5gxeNV0BX4Vtl8yFAW8ToiaRo2pUn/fLDjOqJ68T9a4qGdXh8/4SZD3RWF EMr9/uaZJ/M4FqxL/X8wEk9kc/ruoWL/G6TSM+qBwkGSZp8P19k7SzSXzo+P7UNZSQr104ygqy rV2hJ5yi0bBauxKTudweRNuNAdcW0S29N5n6OM1p3qEjbfZOW+5MfTfU/wvo+xnhg8k3SWdyM9 dZ0= X-IronPort-AV: E=Sophos;i="5.78,385,1599494400"; d="scan'208";a="153932884" 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; 02 Dec 2020 14:23:40 +0800 IronPort-SDR: /uWq/Wyl2fIeqLakbDkMLsFRiqYmfxzVPsbe80zjs9i6lxBErjnKAvbDLCLLcfPnRAEfydOect NxJDxCGlD7p9ABfoPjYCCWOIu0WWPlFpw= 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; 01 Dec 2020 22:07:52 -0800 IronPort-SDR: uAvQnVjL1BD+KQuTygNy/y8RUkvVQGlyDCNHcfrpeh6fTnotxPc4aT5mSLjG9SdiUup1AE/oVO gYiUxrgjPNWg== 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; 01 Dec 2020 22:23:40 -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, johannes.thumshirn@wdc.com, Chaitanya Kulkarni Subject: [PATCH V4 6/9] nvmet: add cns-cs-ns in id-ctrl for ZNS bdev Date: Tue, 1 Dec 2020 22:22:24 -0800 Message-Id: <20201202062227.9826-7-chaitanya.kulkarni@wdc.com> X-Mailer: git-send-email 2.22.1 In-Reply-To: <20201202062227.9826-1-chaitanya.kulkarni@wdc.com> References: <20201202062227.9826-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 Wed Dec 2 06:22:25 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chaitanya Kulkarni X-Patchwork-Id: 11944785 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.5 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 529F8C64E7C for ; Wed, 2 Dec 2020 06:25:28 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id EABC222202 for ; Wed, 2 Dec 2020 06:25:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728439AbgLBGZ1 (ORCPT ); Wed, 2 Dec 2020 01:25:27 -0500 Received: from esa4.hgst.iphmx.com ([216.71.154.42]:64091 "EHLO esa4.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728419AbgLBGZ1 (ORCPT ); Wed, 2 Dec 2020 01:25:27 -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=1606890326; x=1638426326; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=hUhzJ651cVoNvniIQeg3wff/FCoz1DE77FDFCSJt0Zk=; b=rLEMdLap0W/Be1VwHL+UzTWsWSPnSLQodKLTA1kPpiWPtaCIsQbQY7Ka 3vvWHC0FyHMSfR29g/iOASRTMxFRT78pCQkMziW1AlUFg4FFAHW8eL1Tf kPs/MlWdUIdvr6UJ/temKnwwwmt5+iO5Bggjo+25+/AB2ZekGHBkr3Our KF00zWUYzM8ULvm6wqwWoJObdxC5qHNLGWR9kY7yAEGUQUNvLPQt0JlIO C026rgtFUr5Eff941Ybpbaj7GBfRWk5ig7wMk+wrqhegi7fVU+6nuV+Ze ApOKnKGG5bMpqov/i4OPkNSegzAIjAK7PebdA8rHfRU+bGQHKEONFm9Xc Q==; IronPort-SDR: tafnyYNOnsVE+vFkuQC3HpZTh8uOfONCn9mKmmyIwh5RwvIXOSa61xOqpDE0f4Li6gCDnahVDC LnpDHDC1Bh2HFdRRpRe/wDzXxx3c85vxpPjpwCvKvaiYDY6UrtF/7rhOFcDlarcIVlkHWFFT/5 lPhQVrxVrHeZ3ZuNvm5lm4Xn8SZRFSnMgZfDCWNgIdItcT/2IANgzL0gUcwAe99DRFTnludF/P 4xc9+MyTLNmR4pYiDsJ26P/N2wWYpXsPDCdf7owUtt9oe+jw6WK2dnPrZ7WkfGxs7jjfBrqbye BBI= X-IronPort-AV: E=Sophos;i="5.78,385,1599494400"; d="scan'208";a="153932893" 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; 02 Dec 2020 14:23:47 +0800 IronPort-SDR: i3pe/2HMEW0e5E6fk73A1r9l0PW+aMnS39VJm7R0hP7U52MAYVuD86N2wPyuVHsEJpZQ/66mAJ cM34BzK2avdkPZeJsfP5LE2SKgOyEhaFw= 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; 01 Dec 2020 22:07:59 -0800 IronPort-SDR: vZR7hBErOwRxhih13IvEpZq+gcAzgtYTdIRxvmOm7ikZiQAm+GML9an6SmLs58wrffQTxMazfu BFeyHTE0AVmQ== 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; 01 Dec 2020 22:23:47 -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, johannes.thumshirn@wdc.com, Chaitanya Kulkarni Subject: [PATCH V4 7/9] nvmet: add zns cmd effects to support zbdev Date: Tue, 1 Dec 2020 22:22:25 -0800 Message-Id: <20201202062227.9826-8-chaitanya.kulkarni@wdc.com> X-Mailer: git-send-email 2.22.1 In-Reply-To: <20201202062227.9826-1-chaitanya.kulkarni@wdc.com> References: <20201202062227.9826-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 Wed Dec 2 06:22:26 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chaitanya Kulkarni X-Patchwork-Id: 11944777 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.5 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 4A113C64E8A for ; Wed, 2 Dec 2020 06:24:40 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E6FE522202 for ; Wed, 2 Dec 2020 06:24:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728527AbgLBGYj (ORCPT ); Wed, 2 Dec 2020 01:24:39 -0500 Received: from esa5.hgst.iphmx.com ([216.71.153.144]:45258 "EHLO esa5.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728517AbgLBGYj (ORCPT ); Wed, 2 Dec 2020 01:24:39 -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=1606890278; x=1638426278; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=DGst3WtKZogqGUvuhSXY1Do01tQZeR4MGYSWqYweif8=; b=XNNBl7uIjE0J66yDCijjwNDdeXJfqdNN5O6f2J9jl8bEgDF3CAm6eEAn 668SxzHM9DsezdkGUjbvDB7o1PAnHhpQrv1Y8rPA1jeGztfvr6AbsjXde 5xwbx/sKNYIJFuuzr8k4Wrill3r/eBSGZWbWHB35ZpSaCRO8ko7VoPti6 kOEA5+FG4S7mO55+jBxOFuZHcUnrlyclX9qkCtNzDmeig7uoeMBxaHaoM ak4Lkbx8xysj2lma5YDicw8GuQlbn5h01rKV+N179tTfsrH40qscfZj24 ESfkUEBy+nAgybPVqw/h02vKf7M6kQDNyqGn1TcrZYPIwMj9kpZZJzqtF A==; IronPort-SDR: uoy2tXA22fDMsDp/Sn8oDPR2ydFl9p+4cG+DAV6S341MXNWO6ii0zZbBVV79RoQULEVm5/1Oim CcJ2xMlEtxi+AG4bCbW7b1SXCIsK35uQHfWqvpY/LcX0PXc3phccABN/FnHCjw2MrcqVTYf5YF eTQS6K8Pe5oVk3F/oV3ALZx+9HPTDFi+vI7MAU9zMKX/tIvhixmSYmV1pEE2gCmsYjCCRsaMbM HWRcOwdB+i9o/3N1cpVf+8l/qwiaj4J8+RhrGml+ROkKw2jgM3MP3mhLDrO1COyajYfvzDWfoy e/Y= X-IronPort-AV: E=Sophos;i="5.78,385,1599494400"; d="scan'208";a="154060516" 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; 02 Dec 2020 14:23:54 +0800 IronPort-SDR: gqOO1OhWPWyMC+WgqxCZgmGZ+QHqPjp0TibXzx5mFnZL1xgTo2NfHNOm9juEQTgDZl2i0R2md5 L0kO8EwlIQiOrly3fk69rFTOHtLSiwAAU= 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; 01 Dec 2020 22:09:29 -0800 IronPort-SDR: njVwyJp2xVsuqJqEziWlWXHeH9JfpNTAWREwm6IRzwIuh12ZmFU0s34CSNf0czw+//YGcXZNQp BD2YQhPZ8efg== 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; 01 Dec 2020 22:23: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, johannes.thumshirn@wdc.com, Chaitanya Kulkarni Subject: [PATCH V4 8/9] nvmet: add zns bdev config support Date: Tue, 1 Dec 2020 22:22:26 -0800 Message-Id: <20201202062227.9826-9-chaitanya.kulkarni@wdc.com> X-Mailer: git-send-email 2.22.1 In-Reply-To: <20201202062227.9826-1-chaitanya.kulkarni@wdc.com> References: <20201202062227.9826-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 Wed Dec 2 06:22:27 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chaitanya Kulkarni X-Patchwork-Id: 11944783 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D9487C64E8A for ; Wed, 2 Dec 2020 06:25:07 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 810F420637 for ; Wed, 2 Dec 2020 06:25:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728607AbgLBGZG (ORCPT ); Wed, 2 Dec 2020 01:25:06 -0500 Received: from esa2.hgst.iphmx.com ([68.232.143.124]:47445 "EHLO esa2.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728546AbgLBGZG (ORCPT ); Wed, 2 Dec 2020 01:25:06 -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=1606890976; x=1638426976; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=KZvesihZxqvpooUM98Q5I5u1Gk/h9BuWE3/slZ8Ndhs=; b=BHtLCuTgbXn3M/qX7KhFi/X9oK01y6nk0u6dLJRCk/VboQuPEeevb85y WOYuhzwfBdaiIHLfp063vt3mLFKA6B6HGNJN5n4UuIsg1RBjRHWmX/7tR D0xzDalBcTS4xCjUVmjxDExsNJsCdgrQw5BAfhPcgve1N36Y252FGeBcr KAkNg1xIKb+gZRVJQWx+Epkl3XAtVgEdl60BYBPyMBieuW6L+y1JwNAGO /Z8o5ra+nmco1M4Jzc5kxGri9R9zgLG0PXj/IjTM7IxzLFeZR/inzbMNT gpSBpK1KAj2gYeX3pHkrxdggFcAHGnt1qSGTfzwreqMTgehpcQcBaIR5I w==; IronPort-SDR: XnWDQPLWcZkN8q0wHx99a5uiPg+ISk30PleIeIslu+gFfRrvxgr4j6u+ApjHEaZ/FK20YiLfqK xvluwa+GNApvo+fGDGkUuLQEfLGibMW6jnineE2ZzSsBDmkcuMSWcT4SanSI9h2NVMmJUJ+XaM YlmjxOS+ReD4xQdUp0Ol68klYJmsq9FfwppHwJIr3ax/Rek4P6V+7LpTiKIubDkc+AXb0WyX73 6iLKO0dEFGdFSC8vIejyV5e71tFbU6p6nE7NrpZdLXS0+6M/kHeRNxxO9qj5To7exCu/v7Wv4H Rew= X-IronPort-AV: E=Sophos;i="5.78,385,1599494400"; d="scan'208";a="257684168" Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 02 Dec 2020 14:34:37 +0800 IronPort-SDR: WSRrg083iSMiNxwXypi2IZbyKTUlmN17M32dnlU7O/J42wvbLAdeIjHYJIvwcauM4e3IUv5Yvo gnnHQSOrlbWoWnWOP+fR+56IYta1kmTM4= 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; 01 Dec 2020 22:08:12 -0800 IronPort-SDR: pBQWN2G/rG01ZtfZmZxyR1JoaSnr0hctnDIfC2fg5Qi3qzSlOZAhl7P3HVUfMpjNGA0ULBA/K6 O7h4KZUNikNw== 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; 01 Dec 2020 22:24:01 -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, johannes.thumshirn@wdc.com, Chaitanya Kulkarni Subject: [PATCH V4 9/9] nvmet: add ZNS based I/O cmds handlers Date: Tue, 1 Dec 2020 22:22:27 -0800 Message-Id: <20201202062227.9826-10-chaitanya.kulkarni@wdc.com> X-Mailer: git-send-email 2.22.1 In-Reply-To: <20201202062227.9826-1-chaitanya.kulkarni@wdc.com> References: <20201202062227.9826-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);