From nobody Thu Mar 09 15:20:58 2023 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4PXXvH1DCJz3x2qY; Thu, 9 Mar 2023 15:20:59 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4PXXvH0dB7z3vPJ; Thu, 9 Mar 2023 15:20:59 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1678375259; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=gZRk5W1pR8uyNtmU84I/f82A7oouwxAGgWhH21rfuvM=; b=mAm96L167yEKrLKQBPlpqhgA+KrfFTnjectfk63lu//SMjuYhlwOtmuP3c2BsrTBBmRYX3 /gzpJLJ0kkIquj/0ildKqPnhF5aAjLaIeVoYY+MGHdi0E9CyHHmwKO6HpvPC7Rv0XUFSPs nFmHNnZp4iaPuX8c2z9xZdO6IK+OSJhPZcFFdxsEdhc3N4ez3elO9NS0gzICUX4//1a46s C/ZqMkt92+DtV0q/gaZTK3NNuCG1vXgNKX8aMUzQ8l/jDRoyycD6Qrp+FuVDMzrvMwZGcU g3u03xnX/eJraoVojN6GcCmrksIU1Rx4SSx1FJzDexjWbv24mmtqOhjbv8PnOw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1678375259; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=gZRk5W1pR8uyNtmU84I/f82A7oouwxAGgWhH21rfuvM=; b=XXg5JyAtBEAz2/4YJMkFBG55l0bKXkZ7eoc6Ypi8JZGPFbSwM+xYX7Vjrt/Sxq0BY5CnJW htRhgzS3rE0lUC6XiKb70IPVWd/VFf7tdzLPY8atgq0hY6B9WPzNOdGP4ztUZqEI6HPhUe 7yyEpvDwdZFuqbu7HHRSrwyGTGrY318pFRw4nNWVywxse+kAfQAdVywhQnpudgmDGfsOZd liS0u8LiuiHkyMx5SytVhUBQfSFdyNTblWxFJsPCGDhlpB2liPoD4Ct2Zx1TqaArK4ZHkh 248xnKpkrw/ddihloloIYIhpwzg56ZTFG9UeR8R3eKTuJ8c/pvuhzqbwAsAIDQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1678375259; a=rsa-sha256; cv=none; b=MU8qVtL+Z3wdBF6W/29asm0q9uGOL4mpdKN2VKdw1O2FERuxYQs2IGwt+fOZJSgqxzR10Q eqcaHEdXpulnaOGsryWF8V3usCW9+S7pV7M2sl7yvkd9j/cp1Q5PaOo7xU6Al0BJwSg6w2 RfCNzFYO0Cql8xe/+LY2Ul2wc+N3S5sxdBsz76kBCmhuUCqTJ935D/Q5L8sMwSOsdzMOI+ Y8eIHKG55dYOSwmtghRfBbFrNMHCV6hhJewvPacHHQLcD9VYRlgK1n1nA5mgwMXgF2ckfe +esMmUOmqV/yNSZWns5V0NLr9CLa+L11v3f64Tq85zIo2IBIITuPSxNCzf79Eg== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4PXXvG6Qslz1Bjh; Thu, 9 Mar 2023 15:20:58 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 329FKwfV011216; Thu, 9 Mar 2023 15:20:58 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 329FKwwR011215; Thu, 9 Mar 2023 15:20:58 GMT (envelope-from git) Date: Thu, 9 Mar 2023 15:20:58 GMT Message-Id: <202303091520.329FKwwR011215@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Alexander Motin Subject: git: 20dc2c4d11dd - main - nvmecontrol: Fix default ns create parameters. List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mav X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 20dc2c4d11ddaa980c491116b65c51ab522028e9 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by mav: URL: https://cgit.FreeBSD.org/src/commit/?id=20dc2c4d11ddaa980c491116b65c51ab522028e9 commit 20dc2c4d11ddaa980c491116b65c51ab522028e9 Author: Alexander Motin AuthorDate: 2023-03-09 15:19:00 +0000 Commit: Alexander Motin CommitDate: 2023-03-09 15:19:00 +0000 nvmecontrol: Fix default ns create parameters. Instead of passing 0xff's for all unset parameters, prefer reasonable defaults. It is much easier to use it this was without specs in hand. MFC after: 1 week --- sbin/nvmecontrol/ns.c | 56 ++++++++++++++++++++++++++++++++++----------------- 1 file changed, 37 insertions(+), 19 deletions(-) diff --git a/sbin/nvmecontrol/ns.c b/sbin/nvmecontrol/ns.c index 5c537e920dc3..25b90e896982 100644 --- a/sbin/nvmecontrol/ns.c +++ b/sbin/nvmecontrol/ns.c @@ -577,30 +577,48 @@ nscreate(const struct cmd *f, int argc, char *argv[]) NVME_CTRLR_DATA_OACS_NSMGMT_MASK) == 0) errx(EX_UNAVAILABLE, "controller does not support namespace management"); - /* Allow namespaces sharing if Multi-Path I/O is supported. */ - if (create_opt.nmic == NONE) { - create_opt.nmic = cd.mic ? (NVME_NS_DATA_NMIC_MAY_BE_SHARED_MASK << - NVME_NS_DATA_NMIC_MAY_BE_SHARED_SHIFT) : 0; - } - memset(&nsdata, 0, sizeof(nsdata)); nsdata.nsze = create_opt.nsze; nsdata.ncap = create_opt.cap; - if (create_opt.flbas == NONE) - nsdata.flbas = ((create_opt.lbaf & NVME_NS_DATA_FLBAS_FORMAT_MASK) - << NVME_NS_DATA_FLBAS_FORMAT_SHIFT) | - ((create_opt.mset & NVME_NS_DATA_FLBAS_EXTENDED_MASK) - << NVME_NS_DATA_FLBAS_EXTENDED_SHIFT); - else + if (create_opt.flbas != NONE) { nsdata.flbas = create_opt.flbas; - if (create_opt.dps == NONE) - nsdata.dps = ((create_opt.pi & NVME_NS_DATA_DPS_MD_START_MASK) - << NVME_NS_DATA_DPS_MD_START_SHIFT) | - ((create_opt.pil & NVME_NS_DATA_DPS_PIT_MASK) - << NVME_NS_DATA_DPS_PIT_SHIFT); - else + } else { + /* Default to the first format, whatever it is. */ + nsdata.flbas = 0; + if (create_opt.lbaf != NONE) { + nsdata.flbas |= (create_opt.lbaf & + NVME_NS_DATA_FLBAS_FORMAT_MASK) + << NVME_NS_DATA_FLBAS_FORMAT_SHIFT; + } + if (create_opt.mset != NONE) { + nsdata.flbas |= (create_opt.mset & + NVME_NS_DATA_FLBAS_EXTENDED_MASK) + << NVME_NS_DATA_FLBAS_EXTENDED_SHIFT; + } + } + if (create_opt.dps != NONE) { nsdata.dps = create_opt.dps; - nsdata.nmic = create_opt.nmic; + } else { + /* Default to protection disabled. */ + nsdata.dps = 0; + if (create_opt.pi != NONE) { + nsdata.dps |= (create_opt.pi & + NVME_NS_DATA_DPS_MD_START_MASK) + << NVME_NS_DATA_DPS_MD_START_SHIFT; + } + if (create_opt.pil != NONE) { + nsdata.dps |= (create_opt.pil & + NVME_NS_DATA_DPS_PIT_MASK) + << NVME_NS_DATA_DPS_PIT_SHIFT; + } + } + if (create_opt.nmic != NONE) { + nsdata.nmic = create_opt.nmic; + } else { + /* Allow namespaces sharing if Multi-Path I/O is supported. */ + nsdata.nmic = cd.mic ? (NVME_NS_DATA_NMIC_MAY_BE_SHARED_MASK << + NVME_NS_DATA_NMIC_MAY_BE_SHARED_SHIFT) : 0; + } nvme_namespace_data_swapbytes(&nsdata); memset(&pt, 0, sizeof(pt));