From nobody Tue Mar 14 13:58:55 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 4PbZrH2gM5z3yJpM; Tue, 14 Mar 2023 13:58:55 +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 4PbZrH2872z44Pj; Tue, 14 Mar 2023 13:58:55 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1678802335; 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=Mm7vUlYAvfHWzIncQyk+AlJJV4+1ctfRRjhLO4AbjCs=; b=jxlRXXAoq/xK6hRwOWQZvVCIHgeWw+xDazDABNsSfYvHEtBxnyWIWxD6/sGR3Z5iDuu3y3 OpbYjgwPJX/CAsI02dlRyFLW4vWWzSts/ud5kIWFDbgwNrUqcXrYwgzGB9YNthR6RBGnkg G+HSZ/uiWfZRqybyA9m4hl6UR5WTT0NBiyT33/2nLFK6vhVmekRJ1PLcVhkMV4w8Ob1xe/ bC6HqAXaEt4/42GDl6N+xhIyO8S0rhQmAsktBMF/EwikUaepHw16PW9FMiOFA6tA8lQN+d AZDyxXi6/KqV5X0jLA0s9jZJOLghapZ1ZfdsO1upCUnkL5SLCIyeGvd/VNvcKg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1678802335; 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=Mm7vUlYAvfHWzIncQyk+AlJJV4+1ctfRRjhLO4AbjCs=; b=ty+pgC0rvvfvmBhwvhu/k4gTNDN1fMatFtOBS89+OneP5pZlo9VC8YRyNWgy5dbQs+0eCt 6p58EdwPR95N7CApyZc9upyid1kLjk6MUzKTMOgY713VyYYdePLie9sj2w1UQfpnNsktSX 7gS9NvOydm0/syBaXDNJ+R/XAwXaWl3SO8RB69YyOUQrh6M1a/LKPmDw8aACjQBZBRjvaU x1X49moK1gyI2i+jrT7T6SDGHKnMe/QWlL2ekBUfJr8Y2JJfILIqOnU4SDRKGOyg6mrPPB UbWukgfH+gPxy89FQrRARBT8sAMjb881U5dm7TSHQ9x5rabwRXG0mOebkNsnmQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1678802335; a=rsa-sha256; cv=none; b=uSp7pgHNeYRJ6s75kK0DSzRsmCvqFCHDMLn06ipchSAfB4v75g09Elx1Z6MARr9gQ+ECN0 QhRq5jXzWTWOtuxGhG0xJmNkSN1RJWvrbanRh0HYTM9rtaZxvWy/Ut6Ip2bfs7ENR/SXHH zQKXfyKIha8wLX1lM0922v9yRTNe1Ka/Ujo6cRPmEj00FzHAz8eQuxEkINEiksUMEAGLK+ vEeR2QpKdlnEl8+VbADXmimItFhlKUkqHif5jF7lwicNt4OnTY0pq3boVut9fIUYyHFcEl emvmV0d4J9Za5/cEiOG24fycWsDSu3ojK6O+tfsL/GVoOiZ7mobeLWtRGyw0RA== 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 4PbZrH1BtdzdVc; Tue, 14 Mar 2023 13:58:55 +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 32EDwtof011073; Tue, 14 Mar 2023 13:58:55 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 32EDwtEK011072; Tue, 14 Mar 2023 13:58:55 GMT (envelope-from git) Date: Tue, 14 Mar 2023 13:58:55 GMT Message-Id: <202303141358.32EDwtEK011072@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Alexander Motin Subject: git: 069fb41af5bc - releng/13.2 - 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/releng/13.2 X-Git-Reftype: branch X-Git-Commit: 069fb41af5bca224caf6f96b50fed55fa7755c5b Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch releng/13.2 has been updated by mav: URL: https://cgit.FreeBSD.org/src/commit/?id=069fb41af5bca224caf6f96b50fed55fa7755c5b commit 069fb41af5bca224caf6f96b50fed55fa7755c5b Author: Alexander Motin AuthorDate: 2023-03-09 15:19:00 +0000 Commit: Alexander Motin CommitDate: 2023-03-14 13:58:02 +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. PR: 269912 Approved by: re (cperciva) (cherry picked from commit 20dc2c4d11ddaa980c491116b65c51ab522028e9) (cherry picked from commit de0b02cb7b112947191af96dd34e7a95b760019c) --- 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 763c12aa11af..040918caf9c5 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));