From nobody Sun Apr 5 13:31:02 2026 Received: from mail-ot1-f99.google.com (mail-ot1-f99.google.com [209.85.210.99]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 736B12236EE for ; Fri, 20 Feb 2026 03:28:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.99 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771558099; cv=none; b=gy/fKsZDuhwD3YUIRjB9mooToKQ+hT/0vS6eNg4SNaktZ49R72L8MGTLLJ7m5/V4wxhovbPAtmZYWw1ebrjk057spIb7vf4lNMov1dGlLGmSsIateKrLwqN6FWkbIjL0jZo7lb8KOalAC+Xpmjl0NYbfNwAmlvGKmwa073wm0BA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771558099; c=relaxed/simple; bh=mZHSIDVaGLMYG9Ti22BiSRZ0ysWggu+FnM1Bucmt1fM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=OgjQrpFe9zl/oK06AOVljikJFhe5U1bW8sBmVR6jb8QEVyOZErkV4mR/8GDMOjjlWu69fo6TMW2dIUWVge3vRTORCICoWX20s4WKHKUxbT0bihZw+lOnKzN80pSz8Jg6vrW5+Lz4Ufbk66dtJHsXqFS+EWLLpBCmXbwOFV1OqUU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=purestorage.com; spf=fail smtp.mailfrom=purestorage.com; dkim=pass (2048-bit key) header.d=purestorage.com header.i=@purestorage.com header.b=YBp/SqkW; arc=none smtp.client-ip=209.85.210.99 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=purestorage.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=purestorage.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=purestorage.com header.i=@purestorage.com header.b="YBp/SqkW" Received: by mail-ot1-f99.google.com with SMTP id 46e09a7af769-7d18d72c034so271714a34.3 for ; Thu, 19 Feb 2026 19:28:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=purestorage.com; s=google2022; t=1771558096; x=1772162896; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=ROLPQj1JsknI7CLw0SSjV12TwHbOBrfd3E+ueRGmUuo=; b=YBp/SqkWeEDrpQfEYSyvBF8ENEpvK6yd6RhUf/Wrbcr32qopF10cZnVjs/sErCNyfs /LEdicyQ1GerH1KHGjsHks8pgcyoqFEQxMnDfsMfOTSCgzmnCqwoLnyt1+Du3IJ7M2ws Jc+bYxFLzr6ftN5DLnxENeYV2rHkwtE+jSmUhEnPJ/OYlxTfZVBktSAteYuea+mic8gp QQPAk1gSnTGxAHqMGRFnT+rKAR61jYMDbQ80mq6d4QWLzDEd0RkSpyJ4O6EaseGwDZmT YdkhpiNJytiUBWR34nF0tUdBqYHnElCxn2g0rIGwrUzZoND0Y1ZUDHvmtSKLKYJ1cb1+ Jk0w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1771558096; x=1772162896; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=ROLPQj1JsknI7CLw0SSjV12TwHbOBrfd3E+ueRGmUuo=; b=qSy5E+cOCiSFoGJZyl1bAvp2V+oJsz3y2m4nxFsoiBqf5C1nvbRs2+yz3Dob/WEqJj /rIIkU5eYu8LHUWeyeqQZtzemmKY8JUiuojC8XwC6efb2ierXvv8uHVwUounWTTTWexn r2IoO07WHxXLE6F+mYh53aSq7Wz4HGkwVjawpQtK0ldyZ1UGR8R1OWk48lh2ndEfbg11 jj0lcGcN55/5IccpcKlLkY/e2Vs1oHxw8Q8eLl+jAVdIaYOO8lBhDWobx1I3rl976ucy 9zAs0fz91qfsoRPw23AgEflR2zYS6lNTO7u2/gzQKM3gDk736Cjsjgo614gnHl4tolxz Rzfw== X-Forwarded-Encrypted: i=1; AJvYcCX6j5oLnmgq9iy9JVkeVL19j/bgGy8J+TUFqxTTeONQ8/EVLNaAwEfYUH441f/aQfU0xMfVrRmCtsZitB4=@vger.kernel.org X-Gm-Message-State: AOJu0Yyv0lxnquEzJZdRIzhHLEmpcL0ho3hXy+DoF87cZUhRDqAb5IwP dPhp0kvOPVGtgy3r8AuXvbr2RaHF+B6Q9X0rbbSjlxu6I3ZsV99mKCur9nTQPd685DuK6CWda0A zCAfqOW4oJQCxZ5Tdro/maVfvHoKwcJPlRyzf X-Gm-Gg: AZuq6aLh+m+O8eP8kcyfHlB9BedxDeyKHS+R//d4JdZuV9jUNNcudJ1IGCMKc7FsbF3 L+KFLAYw47wnNX3aDx5GMsYRTdHqoWNWpAi/dIWkaC5tWzENhdcHzRIv/8StXxkweo23UGzkpy9 IYAZb7J/kNYOvqSxlfk/uMi1OZ/3M6EbzMSsmrt7xJ83wOQ2+Z5xVML9fHSRf7T5ICQ4JtDViyc e6zzDQC0alg4HmaRl2P8hqBFs2IIsHrFNEoRICerC8X+uHoGPV58yvOs0hH8I6qKKevxZLzrs+t Nq5JHQKXvP4UOCNogy5MFeSJA03SCawRAeh69nezQVRjHu1Pw1zUSgz0DRA1k2GXx2wLAkr1FYI SL+jUH4i4qo4xriSom0CTF1ZT/Hih+GLy+1/EXgljMUtzf8yZZfjlqg== X-Received: by 2002:a4a:de01:0:b0:672:bc17:221 with SMTP id 006d021491bc7-679ae7dc8a7mr1836862eaf.1.1771558096335; Thu, 19 Feb 2026 19:28:16 -0800 (PST) Received: from c7-smtp-2023.dev.purestorage.com ([208.88.159.129]) by smtp-relay.gmail.com with ESMTPS id 006d021491bc7-67817ccdbe7sm1973163eaf.2.2026.02.19.19.28.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Feb 2026 19:28:16 -0800 (PST) X-Relaying-Domain: purestorage.com Received: from dev-csander.dev.purestorage.com (dev-csander.dev.purestorage.com [10.112.29.101]) by c7-smtp-2023.dev.purestorage.com (Postfix) with ESMTP id D13AC340705; Thu, 19 Feb 2026 20:28:15 -0700 (MST) Received: by dev-csander.dev.purestorage.com (Postfix, from userid 1557716354) id D034DE420F8; Thu, 19 Feb 2026 20:28:15 -0700 (MST) From: Caleb Sander Mateos To: Keith Busch , Jens Axboe , Christoph Hellwig , Sagi Grimberg , Chaitanya Kulkarni Cc: linux-nvme@lists.infradead.org, linux-kernel@vger.kernel.org, Caleb Sander Mateos Subject: [PATCH 1/6] nvme: add preferred I/O size fields to struct nvme_id_ns_nvm Date: Thu, 19 Feb 2026 20:28:04 -0700 Message-ID: <20260220032809.758089-2-csander@purestorage.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20260220032809.758089-1-csander@purestorage.com> References: <20260220032809.758089-1-csander@purestorage.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" A subsequent change will use the NPDGL and NPDAL fields of the NVM Command Set Specific Identify Namespace structure, so add them (and the handful of intervening fields) to struct nvme_id_ns_nvm. Signed-off-by: Caleb Sander Mateos --- include/linux/nvme.h | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/include/linux/nvme.h b/include/linux/nvme.h index 655d194f8e72..bc991d4ae89d 100644 --- a/include/linux/nvme.h +++ b/include/linux/nvme.h @@ -511,11 +511,16 @@ struct nvme_id_ctrl_zns { struct nvme_id_ns_nvm { __le64 lbstm; __u8 pic; __u8 rsvd9[3]; __le32 elbaf[64]; - __u8 rsvd268[3828]; + __le32 npdgl; + __le32 nprg; + __le32 npra; + __le32 nors; + __le32 npdal; + __u8 rsvd288[3808]; }; =20 enum { NVME_ID_NS_NVM_STS_MASK =3D 0x7f, NVME_ID_NS_NVM_GUARD_SHIFT =3D 7, --=20 2.45.2 From nobody Sun Apr 5 13:31:02 2026 Received: from mail-qv1-f99.google.com (mail-qv1-f99.google.com [209.85.219.99]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DC42227FB2D for ; Fri, 20 Feb 2026 03:28:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.99 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771558100; cv=none; b=uaX55sMQ3pTpoqUbLhb1QIA+1CfM6FX8bgfnsuu5bxmOU2KJ1BynqAwmeXUpxEXmE0A/TtHufkBAo+PkKUUBx/XRYLJdunQCOBHfO1ccmHHdPLdnp0hpVef0lHya7LaUdnREYQxVzTN0+Asam3+VHE7W2HreLJzpx0VrvjmJyPo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771558100; c=relaxed/simple; bh=Rcw/Fsp67BuWmYt4ZmR1agIyycWBJoEV5piBgRUp98I=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=pPXJJnKq3ySG/CBE1oFRw2GxgjvSIQ3UL1ff1FUYnja8+m5rpGzU2A+3H5sMuDwgczHX36l9/DyfKhS8zQkg0KyZMny6Uvso2y/SOg0dtCCkn//InnkCMXrEhJ5jSod7P+3fliygotqxrY2I23XjZxoa4aagiU35KF1oOWauIY8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=purestorage.com; spf=fail smtp.mailfrom=purestorage.com; dkim=pass (2048-bit key) header.d=purestorage.com header.i=@purestorage.com header.b=Af8LoFFx; arc=none smtp.client-ip=209.85.219.99 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=purestorage.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=purestorage.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=purestorage.com header.i=@purestorage.com header.b="Af8LoFFx" Received: by mail-qv1-f99.google.com with SMTP id 6a1803df08f44-895498f3819so2539546d6.3 for ; Thu, 19 Feb 2026 19:28:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=purestorage.com; s=google2022; t=1771558097; x=1772162897; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=ptMOCF8NjnbTdAq6XG34n7GRmdz+Z/rsqtMtW/eBnI0=; b=Af8LoFFxmP2YRT5F4E6HBOwVlriGOdOgA0Wn7AkFC5+xs+f9XGMqAlw+eZ/IvFgJgD iCERZ83AOrJ4h0GkdEi1nFFAWtvZxqDqVc5k8AmNbAYnBgMPR786H5/j5KPdBjINIB02 Dmn35OntXu2Poewx7138PPOaAnQQCs7nIgcjvP2EN0hUU/n1kRWycXYV9FKXAkbw83fj FblDbMkAQ3aGlIO5rhoBIqZAu/Linhez0jMq9cYDuVACfgQuh7tf4bYd6TmF9aHmt+ky EiQP9r3NX+VG753RdpEnohTUDI1Q8ZU9WyuLueSBImf1YpsqDBDxUY2QOhjKwYn2kEhz 1Ruw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1771558097; x=1772162897; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=ptMOCF8NjnbTdAq6XG34n7GRmdz+Z/rsqtMtW/eBnI0=; b=rwPWSpbTM5R5UlMYO3mfmRSgI95dSlSe8dKH4HwZk8Xd7LabpSFxq2YJL1GehSQMOM EiGSc2jrsFms5c2199OOaUaBYHjXQ99zNqYearPPhM5Dnuq8/DFs+NVY73l6oa9/K8ks 71nY6ChhDlVvJCq9OlQjPtBJmn4q3Do1lla4LTkKndZfXMmdm0Sfhv1sIsJMbbiZe86w XFmrzN3jQdM2j+0jNkVBdAROk4GPyAiRE76X9JBUmf7z1FMx+GSOXhpdIpCVnaMnYvbC JPNUKjB2R2AZWP9a1vqui9dQn4EpvZvuIo7zci+VAOEJgDgCiEA/AQYcnYZEsXFy8kWA nHdw== X-Forwarded-Encrypted: i=1; AJvYcCVBjTXLJR7HL7VsMLv9ArTIzEmL1j+pI+d+g8EQ8+W2gRqOlKDAXckvSwh3fCFIurffIN4FrYqNapJ5x6c=@vger.kernel.org X-Gm-Message-State: AOJu0YyW2ZRZ/my+dM4wnfpm3prFiB5tjQXgnFVTOf7qBIFeZwQhfgab Y/jrKUdnNWhv2ObW8j94c8FcKQ5LV5wTeSS1mrxNJmR+x8XQjTsn+SUCzAZz7/Wz+r+azBSLVQN lu9Tjz8eLlXkiaEg4WgGHl/M81+QLXyJaFryn3M+t5G9UAO2QCejT X-Gm-Gg: AZuq6aLs9AFzuE9TgwdvtcHn+cUugXRMvQHyeCCe7rkIvCj3TnIhdpxlQ0NBysrHGIX NrT4PPQh/ku+Ioz1zLlJDs9WD4wYq/kenHi3as/5rYv9oO0yKKLjhR743XarFFstPc93YQcWmtg XCryGO+n35ltl/h76FA3SOVbLj7MrMvloKKGifCGitOmNfMJsXTNrG+exLVgkKT8Ix7caZ0VLnE enJsQ/1CdExrNuAsJxcGO9a8zgUu9HO0vubFLURf3ftJonne7f6esZYvJyqy1sGK4L8FUH7sPYT ifLk2tG07aJKy/Lzr/eifbFX0H7owNcZqY2CfOusHuz1DTeun2AEc/kIMFOo1pNKBm/87+t/1Ch /tu2VGER07snS2bYY/o74UC5+eLIn/ZbAUHjRbDo= X-Received: by 2002:ac8:5e53:0:b0:4ee:1db1:a61d with SMTP id d75a77b69052e-506a6831f24mr237407291cf.3.1771558096686; Thu, 19 Feb 2026 19:28:16 -0800 (PST) Received: from c7-smtp-2023.dev.purestorage.com ([2620:125:9017:12:36:3:5:0]) by smtp-relay.gmail.com with ESMTPS id d75a77b69052e-50684a3e737sm27357291cf.2.2026.02.19.19.28.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Feb 2026 19:28:16 -0800 (PST) X-Relaying-Domain: purestorage.com Received: from dev-csander.dev.purestorage.com (dev-csander.dev.purestorage.com [10.112.29.101]) by c7-smtp-2023.dev.purestorage.com (Postfix) with ESMTP id 0B2FF3408B8; Thu, 19 Feb 2026 20:28:16 -0700 (MST) Received: by dev-csander.dev.purestorage.com (Postfix, from userid 1557716354) id 0814AE420F8; Thu, 19 Feb 2026 20:28:16 -0700 (MST) From: Caleb Sander Mateos To: Keith Busch , Jens Axboe , Christoph Hellwig , Sagi Grimberg , Chaitanya Kulkarni Cc: linux-nvme@lists.infradead.org, linux-kernel@vger.kernel.org, Caleb Sander Mateos Subject: [PATCH 2/6] nvme: update nvme_id_ns OPTPERF constants Date: Thu, 19 Feb 2026 20:28:05 -0700 Message-ID: <20260220032809.758089-3-csander@purestorage.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20260220032809.758089-1-csander@purestorage.com> References: <20260220032809.758089-1-csander@purestorage.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Since NVM Command Spec 1.1, OPTPERF comprises both bits 4 and 5 of NSFEAT in the Identify Namespace structure. Replace NVME_NS_FEAT_IO_OPT, which represented only bit 4, with NVME_NS_FEAT_OPTPERF_SHIFT and NVME_NS_FEAT_OPTPERF_MASK. Update nvme_update_disk_info() to check both OPTPERF bits, as NPWG and NOWS are supported even if only bit 5 is set. Signed-off-by: Caleb Sander Mateos --- drivers/nvme/host/core.c | 3 ++- include/linux/nvme.h | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c index 3a2126584a23..674dd823b209 100644 --- a/drivers/nvme/host/core.c +++ b/drivers/nvme/host/core.c @@ -2095,11 +2095,12 @@ static bool nvme_update_disk_info(struct nvme_ns *n= s, struct nvme_id_ns *id, } =20 phys_bs =3D bs; atomic_bs =3D nvme_configure_atomic_write(ns, id, lim, bs); =20 - if (id->nsfeat & NVME_NS_FEAT_IO_OPT) { + if (id->nsfeat >> NVME_NS_FEAT_OPTPERF_SHIFT & + NVME_NS_FEAT_OPTPERF_MASK) { /* NPWG =3D Namespace Preferred Write Granularity */ phys_bs =3D bs * (1 + le16_to_cpu(id->npwg)); /* NOWS =3D Namespace Optimal Write Size */ if (id->nows) io_opt =3D bs * (1 + le16_to_cpu(id->nows)); diff --git a/include/linux/nvme.h b/include/linux/nvme.h index bc991d4ae89d..f279e5d72e2d 100644 --- a/include/linux/nvme.h +++ b/include/linux/nvme.h @@ -593,11 +593,12 @@ enum { }; =20 enum { NVME_NS_FEAT_THIN =3D 1 << 0, NVME_NS_FEAT_ATOMICS =3D 1 << 1, - NVME_NS_FEAT_IO_OPT =3D 1 << 4, + NVME_NS_FEAT_OPTPERF_SHIFT =3D 4, + NVME_NS_FEAT_OPTPERF_MASK =3D 0x3, NVME_NS_ATTR_RO =3D 1 << 0, NVME_NS_FLBAS_LBA_MASK =3D 0xf, NVME_NS_FLBAS_LBA_UMASK =3D 0x60, NVME_NS_FLBAS_LBA_SHIFT =3D 1, NVME_NS_FLBAS_META_EXT =3D 0x10, --=20 2.45.2 From nobody Sun Apr 5 13:31:02 2026 Received: from mail-pl1-f227.google.com (mail-pl1-f227.google.com [209.85.214.227]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 06320283FE5 for ; Fri, 20 Feb 2026 03:28:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.227 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771558099; cv=none; b=jijUjFbQ3ZOaspXb/WV2M3NRmxjrq69+fMdgRRBVf1IGnw+qgTgcsd6VpU7WpYw7jTnfU0ZFFwZpZRGrM8/yUERVf/pxnyHpMlTUJZ64hg/NbI+2B/QDQrBBhYR5sjQf5wIQzoK9Vnas+7mBD7algIfqRPSomAF0wNcW74aTR24= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771558099; c=relaxed/simple; bh=bIAp2X9ovbr07d2sa5XIRpO5C9thT7Y5hErLWfChn/s=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=KiaWkoVQpS6HdEL+tE8yd8yale95cHbKDA0Buoenzwm7hm8Nc8HLWfW+UqkVfAF+7A0Z/NKz23RRHHTzzx22RkFzFmF9CBR0cAgoZkkZlyrO8RLr1NaUbHIVlz89wfs/PIsWOVdF2pVpeII9PdZTP1+58kFU7hXemm8QrG9tVwM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=purestorage.com; spf=fail smtp.mailfrom=purestorage.com; dkim=pass (2048-bit key) header.d=purestorage.com header.i=@purestorage.com header.b=ZSlcuNgI; arc=none smtp.client-ip=209.85.214.227 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=purestorage.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=purestorage.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=purestorage.com header.i=@purestorage.com header.b="ZSlcuNgI" Received: by mail-pl1-f227.google.com with SMTP id d9443c01a7336-2a3e79fe2b8so1854355ad.1 for ; Thu, 19 Feb 2026 19:28:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=purestorage.com; s=google2022; t=1771558097; x=1772162897; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=rnvrwXKPD1mz6+9mov3GXHuRhTeAw5K2AjQa0fuRQNA=; b=ZSlcuNgIZMb2b+mLcR4RMechhcuhkuvtCA21XRI+sRSb4Nr5n/7KpsXdpQFwE4QQC5 kWzfUy0p5pOK1oIfhgdAVROUA/PxmAevGAF3YHRvZGe1ISzCcCSVvkjqZoKZI9TD61ir vtaxN0kyWjc+CfFJop/pIC03TuuyOx8ByDia/gLj3Wx2LbmyJ9Yi+RL75VV2SzFoP0sX 4QBT1ymyI1sfPwIN9VnzeWsLCJKQ8JoA8V0vQdUls/3IFLOcIxcdEIoTEnjvIjrY5w3t Af0NdvBtePLWwrUfKgm1LBxpY5FJSXaCtbsXpmJ8vNtCf0UVzqBa7xT3cTJNEnh1lxKj vP4A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1771558097; x=1772162897; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=rnvrwXKPD1mz6+9mov3GXHuRhTeAw5K2AjQa0fuRQNA=; b=ERam3p+C9AgJ7kgLEtTYl+JfQOC3kjw4yvCizsJoe9HkHxl6fJckf99iIkh9Z96MLL jN01nd7Wc/qc0qfkDe7lO9uOrPGjSqfXz7EFOgKfICxQaXI5C/Zg8HFdcabsvPMCdKzR qD9OJf0R6NgEhtoH6ebWg4CIDLdp2k8aqR6mTjlaqymdpSVzE8jIff8Zh3HjpNpZ0ZWB YtarfJEOur88PWZ8/QJX/y5PUZF93zSxYdV+3gkdvh2bENXi+h7uxgMVNlaps00ImuvI P6n3asWsJnWaI0lgA+RDufBHv+gVoeudsOOnHViMbvC0rfyTbBUpmwZh6txnJsigj//z cv0Q== X-Forwarded-Encrypted: i=1; AJvYcCWzr7rT6bCH4ToEupleBAUp3KjmnARsI/OwYfpyDOddhd95z3c+J7GHTf7PyypNOjnFeOooojrLoXmFuQg=@vger.kernel.org X-Gm-Message-State: AOJu0YzLu7UuBza6opIe3TvoFVEfFrhXDquGT0Rlk8VzDOCpqNjz0Mqc xpbup1IN8EqIptGlH8euQdN2W7BmJoQUmnOFaoVNGZFLSH0UjSuVC3qrlg4kQ9k1PTjiizT3XiP qMMRUm7YuBIqkVbgKQgCzCpxMKeNT8Vi2VSDD4tt0fLxo2RlQRSve X-Gm-Gg: AZuq6aI0Z+mhKtYwguHO5ItgPqP1+M7YMcQfgEcQkVgUYgz4TnyTwVY29lvUVSZe0wO 5Y8gL5PsjPLQjWJ3pc6118UaxRGRIJHmoMW2fQL+0Qs0OJxvDRvK5xLeKDlZOdzs6mQ9Gw3c2Qo zPCHQv0yP+e2woQvcTQ220tughhAXy5xTEV/swslAMoFTigwFc6XI0AgYcmokRNvgzflN3yaS17 fJxiWLU9k3BLoyrUOYkVV2fDKj541sKmJM+q9hEBU8vgacCEREwRfhibhYiu1Y8R+sSRN4feM/2 2Zu2Nu04oZKWYARU0JEwQyU5IP2RFslqFQJWblMNDTTWD7PC+xz++nDAil96zhivTO7esIRmgWL F+9984ei2cKeXioEb0UY0y4q1KW2gOvtMfijSJTw= X-Received: by 2002:a17:903:1983:b0:2aa:d5fe:f193 with SMTP id d9443c01a7336-2ab4d001292mr157822975ad.4.1771558096920; Thu, 19 Feb 2026 19:28:16 -0800 (PST) Received: from c7-smtp-2023.dev.purestorage.com ([2620:125:9017:12:36:3:5:0]) by smtp-relay.gmail.com with ESMTPS id d9443c01a7336-2ad1a79387csm23110195ad.27.2026.02.19.19.28.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Feb 2026 19:28:16 -0800 (PST) X-Relaying-Domain: purestorage.com Received: from dev-csander.dev.purestorage.com (dev-csander.dev.purestorage.com [10.112.29.101]) by c7-smtp-2023.dev.purestorage.com (Postfix) with ESMTP id 2CA6F341568; Thu, 19 Feb 2026 20:28:16 -0700 (MST) Received: by dev-csander.dev.purestorage.com (Postfix, from userid 1557716354) id 2AAFAE420F8; Thu, 19 Feb 2026 20:28:16 -0700 (MST) From: Caleb Sander Mateos To: Keith Busch , Jens Axboe , Christoph Hellwig , Sagi Grimberg , Chaitanya Kulkarni Cc: linux-nvme@lists.infradead.org, linux-kernel@vger.kernel.org, Caleb Sander Mateos Subject: [PATCH 3/6] nvme: always issue I/O Command Set specific Identify Namespace Date: Thu, 19 Feb 2026 20:28:06 -0700 Message-ID: <20260220032809.758089-4-csander@purestorage.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20260220032809.758089-1-csander@purestorage.com> References: <20260220032809.758089-1-csander@purestorage.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Currently, the I/O Command Set specific Identify Namespace structure is only fetched for controllers that support extended LBA formats. This is because struct nvme_id_ns_nvm is only used by nvme_configure_pi_elbas(), which is only called when the ELBAS bit is set in the CTRATT field of the Identify Controller structure. However, the I/O Command Set specific Identify Namespace structure will soon be used in nvme_config_discard(), so always try to obtain it in nvme_update_ns_info_block() if the controller supports NVMe version 2.0 or later. Signed-off-by: Caleb Sander Mateos Reviewed-by: Christoph Hellwig --- drivers/nvme/host/core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c index 674dd823b209..70ff14a56a01 100644 --- a/drivers/nvme/host/core.c +++ b/drivers/nvme/host/core.c @@ -2351,11 +2351,11 @@ static int nvme_update_ns_info_block(struct nvme_ns= *ns, ret =3D -ENXIO; goto out; } lbaf =3D nvme_lbaf_index(id->flbas); =20 - if (ns->ctrl->ctratt & NVME_CTRL_ATTR_ELBAS) { + if (ns->ctrl->vs >=3D NVME_VS(2, 0, 0)) { ret =3D nvme_identify_ns_nvm(ns->ctrl, info->nsid, &nvm); if (ret < 0) goto out; } =20 --=20 2.45.2 From nobody Sun Apr 5 13:31:02 2026 Received: from mail-dl1-f100.google.com (mail-dl1-f100.google.com [74.125.82.100]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6459E2D6E70 for ; Fri, 20 Feb 2026 03:28:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.82.100 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771558100; cv=none; b=WGVsdIPl5kC1IARu9bR5GASL9MwUUCaTdPsIPOvir4t1yCsA15gAKu5DmMD/Ec8f8OQDxGDm+RxJYkVdhKwiifcSmZ06xPAPxzuBcBA2s7epx2pEXrLD5a0l+wPJU+pSY+BgQnHlkAXgmoN83NcEVGHsDE4m/Tt43UG+K479Bmc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771558100; c=relaxed/simple; bh=rUjAk7r3nBxei+ldkNCZMmNRL6U8Wd2/FZIoomQCes8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=GaDqdVTEgIgIYMz0MaFLtMvh1Eeu5JSqaX3+nDgcVGTf9zwuVxnDQP3O3TGWJ8pPRr7ParOoJiJtR2Jon8b3VuFntdGkhJYH9FZf8YaASOaHPzNllWYfxIcZQIGZyIIffyeb4EV0mtVx040morHyqEUZnQbjPN9cSG497PPeFfc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=purestorage.com; spf=fail smtp.mailfrom=purestorage.com; dkim=pass (2048-bit key) header.d=purestorage.com header.i=@purestorage.com header.b=c+3azNkm; arc=none smtp.client-ip=74.125.82.100 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=purestorage.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=purestorage.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=purestorage.com header.i=@purestorage.com header.b="c+3azNkm" Received: by mail-dl1-f100.google.com with SMTP id a92af1059eb24-124a7216c9cso166659c88.0 for ; Thu, 19 Feb 2026 19:28:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=purestorage.com; s=google2022; t=1771558098; x=1772162898; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=D7v4Jlt69J0HoetHkHttpCb1bOrq9W3em9yk/dBmRx4=; b=c+3azNkmH33hNrwFJTY5oMTPRVBVQbkuMZ3qBy2/VKn2O8py5v/bz1EA1fmZdK+63d M6TjLU8griJWflDvpXxpb1jNK0tMe3AV6kN6M2gH0p/3oEZnlZ6uY11TcI4Q0wJw129v pAjW9pjFPshqjTFhsbqOvpdplmWW589o0h/Taz43BgRaumS/PX+8axtyMHNeIOrI3mxE eXzLCfdj7IYno6MWg0YsAaRGvzcqL45nOOUOg1Qq+rOzxvHv7LarS4p133AIdaOhW9yF lB6P44h5JwVx9ErhzOtjsTxUow+UYT1ax3nFPaKedq20eVSLbxWW3zaTRPmkuf03UKch 145A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1771558098; x=1772162898; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=D7v4Jlt69J0HoetHkHttpCb1bOrq9W3em9yk/dBmRx4=; b=d3YcwyMyqbZ0D5A0aKrvQrPGos0voHq6pDUuahLiad8QtSuGGYT56Bfzu1WC64RPk5 daCKIBVXMDL9cIojiGkdonm80lRB4BRJCyujt1Bg4ooO8Z4Tq6s2fkQM8TkXiYbxYDSD 3J5cDyPp10Hq+81kEDQpzPu/aFxJIDJcfFpBlXtFhyhhikUkh3G30AMrg+tSSC4FB2Ep yS05xSdWr7939m/lnDzkZNdSVR4sJaWLu9llte7TkyIRIgA7MhLGcDouNWbhXyCxSuqo wCkjzTWFLZsb4pDUrDSQwGesXys2Q70Mc9tLV3s7ndssZOktw4daeutTl6H5QLhkxNZW rrkA== X-Forwarded-Encrypted: i=1; AJvYcCUM4mP2kbrNKTS8/aIoizX8GrBoMf4ZYXqIfnrTgNr55fZXzmFERbIqqG+Dw2wo+eaf20dhBsihDjGdpEI=@vger.kernel.org X-Gm-Message-State: AOJu0YzvPCabPdpJdPpC/tR0ThUaL6Z0h1uZbJAYnoXm0o1m7aglObme Qb4rWM55e2OJZLYDQ8csEdlNiIuoO1yvdD6HIhZGBrg0tJBeS463AMz8dHI6rKutovE4OL53+U6 RrIw3d8GJsfXi4P/uunDCCw5UW1FWmN/BtwufX2uHAU5jpOJLLi/W X-Gm-Gg: AZuq6aISppHY7QRaAkBCWwI9EHkP5KzHWJOKMEnR1JpRas5hmeHDaqzffwRHyQihLQG wJ1gZFzjWwaDL+OgVfqU2uGqvHmrR9FxEJYaLTwJVriyxXE7OqatpvMMtbwrHsR4sYgPoFJzuoU mm7heV5Q+rs7Jh1AbRRghXFDiQjETBNsdg7kKPSgOjyeUncS0O+NBDdqNjYLKZ4JXmQ5yQuME5N t/Q/WojvEkVZ8I1VHzYxs+tiX3ptu4NeegfugdZkvCJoawO41oNoZEbAaVZk4bqA1aXR/uzUWdw /7+uvSrGD1lgio26Qnp0cAq5/yt47b6p3Zd7ffBRM+n+WAixUuDNW+rAfSdP0ojp2kcDwOvfsD1 oQOulEu0e+EJ0bmiVJ5+/oQm5Zn8wN1Tku9qID44= X-Received: by 2002:a05:7022:920:b0:119:e55a:95a1 with SMTP id a92af1059eb24-1273985ace2mr4639274c88.3.1771558098352; Thu, 19 Feb 2026 19:28:18 -0800 (PST) Received: from c7-smtp-2023.dev.purestorage.com ([2620:125:9017:12:36:3:5:0]) by smtp-relay.gmail.com with ESMTPS id 5a478bee46e88-2bacb62d781sm2279296eec.6.2026.02.19.19.28.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Feb 2026 19:28:18 -0800 (PST) X-Relaying-Domain: purestorage.com Received: from dev-csander.dev.purestorage.com (dev-csander.dev.purestorage.com [10.112.29.101]) by c7-smtp-2023.dev.purestorage.com (Postfix) with ESMTP id 55861341BBA; Thu, 19 Feb 2026 20:28:16 -0700 (MST) Received: by dev-csander.dev.purestorage.com (Postfix, from userid 1557716354) id 534BFE420F8; Thu, 19 Feb 2026 20:28:16 -0700 (MST) From: Caleb Sander Mateos To: Keith Busch , Jens Axboe , Christoph Hellwig , Sagi Grimberg , Chaitanya Kulkarni Cc: linux-nvme@lists.infradead.org, linux-kernel@vger.kernel.org, Caleb Sander Mateos Subject: [PATCH 4/6] nvme: set discard_granularity from NPDG/NPDA Date: Thu, 19 Feb 2026 20:28:07 -0700 Message-ID: <20260220032809.758089-5-csander@purestorage.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20260220032809.758089-1-csander@purestorage.com> References: <20260220032809.758089-1-csander@purestorage.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Currently, nvme_config_discard() always sets the discard_granularity queue limit to the logical block size. However, NVMe namespaces can advertise a larger preferred discard granularity in the NPDG or NPDA field of the Identify Namespace structure or the NPDGL or NPDAL fields of the I/O Command Set Specific Identify Namespace structure. Use these fields to compute the discard_granularity limit. The logic is somewhat involved. First, the fields are optional. NPDG is only reported if the low bit of OPTPERF is set in NSFEAT. NPDA is reported if any bit of OPTPERF is set. And NPDGL and NPDAL are reported if the high bit of OPTPERF is set. NPDGL and NPDAL can also each be set to 0 to opt out of reporting a limit. I/O Command Set Specific Identify Namespace may also not be supported by older NVMe controllers. Another complication is that multiple values may be reported among NPDG, NPDGL, NPDA, and NPDAL. The spec says to prefer the values reported in the L variants. The spec says NPDG should be a multiple of NPDA and NPDGL should be a multiple of NPDAL, but it doesn't specify a relationship between NPDG and NPDAL or NPDGL and NPDA. So use the maximum of the reported NPDG(L) and NPDA(L) values as the discard_granularity. Signed-off-by: Caleb Sander Mateos --- drivers/nvme/host/core.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c index 70ff14a56a01..7ac11c40ca9f 100644 --- a/drivers/nvme/host/core.c +++ b/drivers/nvme/host/core.c @@ -1880,23 +1880,33 @@ static bool nvme_init_integrity(struct nvme_ns_head= *head, bi->pi_offset =3D info->pi_offset; } return true; } =20 -static void nvme_config_discard(struct nvme_ns *ns, struct queue_limits *l= im) +static void nvme_config_discard(struct nvme_ns *ns, struct nvme_id_ns *id, + struct nvme_id_ns_nvm *nvm, + struct queue_limits *lim) { struct nvme_ctrl *ctrl =3D ns->ctrl; + u32 npdg, npda; + u8 optperf; =20 if (ctrl->dmrsl && ctrl->dmrsl <=3D nvme_sect_to_lba(ns->head, UINT_MAX)) lim->max_hw_discard_sectors =3D nvme_lba_to_sect(ns->head, ctrl->dmrsl); else if (ctrl->oncs & NVME_CTRL_ONCS_DSM) lim->max_hw_discard_sectors =3D UINT_MAX; else lim->max_hw_discard_sectors =3D 0; =20 - lim->discard_granularity =3D lim->logical_block_size; + optperf =3D id->nsfeat >> NVME_NS_FEAT_OPTPERF_SHIFT & + NVME_NS_FEAT_OPTPERF_MASK; + npdg =3D optperf & 0x2 && nvm && nvm->npdgl ? le32_to_cpu(nvm->npdgl) : + optperf & 0x1 ? le16_to_cpu(id->npdg) + 1 : 1; + npda =3D optperf & 0x2 && nvm && nvm->npdal ? le32_to_cpu(nvm->npdal) : + optperf ? le16_to_cpu(id->npda) + 1 : 1; + lim->discard_granularity =3D max(npdg, npda) * lim->logical_block_size; =20 if (ctrl->dmrl) lim->max_discard_segments =3D ctrl->dmrl; else lim->max_discard_segments =3D NVME_DSM_MAX_RANGES; @@ -2382,11 +2392,11 @@ static int nvme_update_ns_info_block(struct nvme_ns= *ns, nvme_configure_metadata(ns->ctrl, ns->head, id, nvm, info); nvme_set_chunk_sectors(ns, id, &lim); if (!nvme_update_disk_info(ns, id, &lim)) capacity =3D 0; =20 - nvme_config_discard(ns, &lim); + nvme_config_discard(ns, id, nvm, &lim); if (IS_ENABLED(CONFIG_BLK_DEV_ZONED) && ns->head->ids.csi =3D=3D NVME_CSI_ZNS) nvme_update_zone_info(ns, &lim, &zi); =20 if ((ns->ctrl->vwc & NVME_CTRL_VWC_PRESENT) && !info->no_vwc) --=20 2.45.2 From nobody Sun Apr 5 13:31:02 2026 Received: from mail-dl1-f97.google.com (mail-dl1-f97.google.com [74.125.82.97]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6A9E02D7D47 for ; Fri, 20 Feb 2026 03:28:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.82.97 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771558100; cv=none; b=sEvZ+sLBd+PYcDqKvBcPaO3pw3UZk6ZSw2ULtb4tWAv2hzS45l20IpTYg4b2MrJcmOnoZFs1sbhb7ZUpx/V6KtfaTKrg2JGbrRQOTuxYDT0aM4XD4D5K+WQf0ebH56a058/0fVAzqSXVVLLkVdcWI77fuboWDrhF7tSzHHnwYPY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771558100; c=relaxed/simple; bh=zUFAUVdTh72rKbrvljdX0A6hoTRSWJwJzaFgdY0Zch8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=dizWcoovc3ce/yb3MXT8E7JAlnGMSLFAMSeo45JYr9uxcSdgc/mjXFEub3qgKDIDnPbdcSSkOA1BTjyencD7UI1MYY0/pmz4CUmAJLC1YLmbQ7iLUuhtXP8M4XQiDFkGOy/o4eZpCWFrNutYEvnrlKHWwGhTdKBrmnRiG20p5ps= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=purestorage.com; spf=fail smtp.mailfrom=purestorage.com; dkim=pass (2048-bit key) header.d=purestorage.com header.i=@purestorage.com header.b=ZythDX3m; arc=none smtp.client-ip=74.125.82.97 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=purestorage.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=purestorage.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=purestorage.com header.i=@purestorage.com header.b="ZythDX3m" Received: by mail-dl1-f97.google.com with SMTP id a92af1059eb24-124a7216c9cso166661c88.0 for ; Thu, 19 Feb 2026 19:28:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=purestorage.com; s=google2022; t=1771558099; x=1772162899; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=A00Y3pDN9iUYHER17pm03ZbljFG3KevPDkg+zFu7U1Y=; b=ZythDX3mVb2mDctZ5IKAmgaBNtPGzT5ftPTaDmomsop0AiWCDWGTwwcyA1I6pj2KH1 7gSuqIUV+Q1SB9T5ADNhX1z9RQPIv7oQ3FdO0wkGIiz9MVNeDmboCi4B8oHjqQVYbeOn riOjxux2N8pZ7tjgAgut0IT37Dc6mh4Hd0T/aQ8iQwUVEfAfvIWOyyWxDzG9PYaSx0ni W/LWqyhMC/lQDT2E+kRFAQewk0Iq04qcuPoWlriHbcchlzLRUpxHa8FNgSrD8F/8HTx6 U17SdGPwSgYfhG79/+i5SIu35mWwPyzaCpl39gHjN2ar8dKjOgt0C3HKf1pjCc2fnH9W CGIQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1771558099; x=1772162899; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=A00Y3pDN9iUYHER17pm03ZbljFG3KevPDkg+zFu7U1Y=; b=LG0vl7o3bxyzD92AX7hSOimny90o9k2NmAqDQvtt9Kk116yYM3G0zed28PoNd1icJ3 hnfl6DtI8uiob1CoZEw74CWb/eJwc6k+hq2ociiTCNgFFnIE89H575zETKKCpqvTH1Ru IgUFjl9I/n8UV5AItgYRuOL5zHdsjHAMnQcv2hFtorpTCj/33HRTr1J62dmJ0P42wAhX qw4c7kZ9JCLqRh/RTWMHs2DSn6NnrLvOwqEKvOs1ta7uDpVwB5WUcRnu21XGARC0d/ii aJEbq8991Yx9WC55hC72/ZjdfQO2NA7hBGH9SgiE4jo0MXXj+Bf4CeTtVB7n87frfNOX QE3w== X-Forwarded-Encrypted: i=1; AJvYcCWItuRN4M/inC0qCc5MMwRvOx6Qput3J68wiOfAtcCRUQ0HhB0onRi8hB+anIbhH3M65xR5uIkYWwj9f1Y=@vger.kernel.org X-Gm-Message-State: AOJu0YwMWe/pEVcFrM7x622OsNtCEmPCR2lq596VU5QzDQ70P26kxpAp KidvdIqTkq6G1Sx/+d88xBs+kgKavHh2VrSj4Ccs5CtC0zZS1kPLp5i1TLm5gQ+9l/7MzGg4aoZ Bpmdh6le5tm19odfsnm2q4AbYrUJezmdXQYA5 X-Gm-Gg: AZuq6aIHgVPPdACkpF3v7l1M5ZPceH6rXr2Kim+7mJh1sHMaww2UiI+YJF2Aspg3A71 VGSHupGSnJ9/fbvfOgmUb7tSR4PGYVYHjv34EvPJgy6zN4U1kvtDzU566wiTSvAFfOnTM2SyklY ReDFl7svnTXxxuR9qDS/FPiVjZi7VBLbBgSjKOIDAjYdByrQUcifd8nkckaJvu7L5abm7OsWgn1 WYBUweGwhtiHwusPUP56vJ0t0pnlZZB3QvIM0XTH9oqjUV40oiHU6XzjPfPmGGOeSfH81buXNZP 6m3T3u1Dek60pySyVzR+I0QXqw6uBzDQbb3j+dtGqRDAhjJPDNXIbp5qeEoWCLJyPC/3hSOSndx dtsREayYhGRFxS8662z89yUV/nkVp3nYrlaOkSAF2bmu1IIT+c5E+tg== X-Received: by 2002:a05:7022:7e03:b0:127:3480:7ca5 with SMTP id a92af1059eb24-127397d8408mr4869659c88.2.1771558098534; Thu, 19 Feb 2026 19:28:18 -0800 (PST) Received: from c7-smtp-2023.dev.purestorage.com ([208.88.159.129]) by smtp-relay.gmail.com with ESMTPS id a92af1059eb24-12742b60d29sm3074231c88.1.2026.02.19.19.28.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Feb 2026 19:28:18 -0800 (PST) X-Relaying-Domain: purestorage.com Received: from dev-csander.dev.purestorage.com (dev-csander.dev.purestorage.com [10.112.29.101]) by c7-smtp-2023.dev.purestorage.com (Postfix) with ESMTP id 7CF1F341CC1; Thu, 19 Feb 2026 20:28:16 -0700 (MST) Received: by dev-csander.dev.purestorage.com (Postfix, from userid 1557716354) id 7A67BE420F8; Thu, 19 Feb 2026 20:28:16 -0700 (MST) From: Caleb Sander Mateos To: Keith Busch , Jens Axboe , Christoph Hellwig , Sagi Grimberg , Chaitanya Kulkarni Cc: linux-nvme@lists.infradead.org, linux-kernel@vger.kernel.org, Caleb Sander Mateos Subject: [PATCH 5/6] nvmet: use NVME_NS_FEAT_OPTPERF_SHIFT Date: Thu, 19 Feb 2026 20:28:08 -0700 Message-ID: <20260220032809.758089-6-csander@purestorage.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20260220032809.758089-1-csander@purestorage.com> References: <20260220032809.758089-1-csander@purestorage.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Use the NVME_NS_FEAT_OPTPERF_SHIFT constant in nvmet_bdev_set_limits() to set the OPTPERF bits of the nvme_id_ns NSFEAT field instead of the magic number 4. Signed-off-by: Caleb Sander Mateos Reviewed-by: Christoph Hellwig --- drivers/nvme/target/io-cmd-bdev.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/nvme/target/io-cmd-bdev.c b/drivers/nvme/target/io-cmd= -bdev.c index 8d246b8ca604..d94f885a56d9 100644 --- a/drivers/nvme/target/io-cmd-bdev.c +++ b/drivers/nvme/target/io-cmd-bdev.c @@ -28,15 +28,15 @@ void nvmet_bdev_set_limits(struct block_device *bdev, s= truct nvme_id_ns *id) id->nawun =3D lpp0b; id->nawupf =3D lpp0b; id->nacwu =3D lpp0b; =20 /* - * Bit 4 indicates that the fields NPWG, NPWA, NPDG, NPDA, and + * OPTPERF =3D 01b indicates that the fields NPWG, NPWA, NPDG, NPDA, and * NOWS are defined for this namespace and should be used by * the host for I/O optimization. */ - id->nsfeat |=3D 1 << 4; + id->nsfeat |=3D 0x1 << NVME_NS_FEAT_OPTPERF_SHIFT; /* NPWG =3D Namespace Preferred Write Granularity. 0's based */ id->npwg =3D to0based(bdev_io_min(bdev) / bdev_logical_block_size(bdev)); /* NPWA =3D Namespace Preferred Write Alignment. 0's based */ id->npwa =3D id->npwg; /* NPDG =3D Namespace Preferred Deallocate Granularity. 0's based */ --=20 2.45.2 From nobody Sun Apr 5 13:31:02 2026 Received: from mail-oa1-f98.google.com (mail-oa1-f98.google.com [209.85.160.98]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 55B902BEC4A for ; Fri, 20 Feb 2026 03:28:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.98 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771558099; cv=none; b=UgTpYJvr0mQa3+Q/1DMA4OOwKoUF7HJ13AGqeAhiW9rdZWqzjyDrTRo7FCW0VgwJLg2YYf/oXjRL0VcMZq6/Z+js/l/rP+mEojzNIjQrRUJkl3jasxsnt8/sQZaZ7dvfQWipfjjkBl39EqPHvXKtrWRjIXZLmXC/iZRYD+YL0Pg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771558099; c=relaxed/simple; bh=LV5733WF2Amrq7TZbrAkujCFMKLuo+5jXT+GVMP94K0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=YmYvA98Z1NfROxX4nmYZaSv7gjGmhf1XoFXkqU6Xe8Jh7ypkNiIWKGKFqyCrfbGql4iWPnUlXq3p8rhHXIjEhMLKJ+eKGNCBJ9xeV/8nIHtLJn8xnTybAUaXVFj06yw0yYxXg0ldoLfozbvsJMJ2PHlhHgFamwbf2xPhfnfFTkY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=purestorage.com; spf=fail smtp.mailfrom=purestorage.com; dkim=pass (2048-bit key) header.d=purestorage.com header.i=@purestorage.com header.b=EFqfsL0C; arc=none smtp.client-ip=209.85.160.98 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=purestorage.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=purestorage.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=purestorage.com header.i=@purestorage.com header.b="EFqfsL0C" Received: by mail-oa1-f98.google.com with SMTP id 586e51a60fabf-41392f596ceso128155fac.1 for ; Thu, 19 Feb 2026 19:28:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=purestorage.com; s=google2022; t=1771558097; x=1772162897; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=0AEEfE6xiusQnEvNeZM84fhKgvDhfLyCCrKC1bZTQl0=; b=EFqfsL0C9MVVvBbhjZKBsOFHowWb9ng/t4B9UHS/LIwhfa6PYcJb/qdmQyyvqYNino tNbviuyR+b4fx4EtIhU8jhfIVpEea4CHQQJiG+M+8pU9IeBp/I+idK9mb85M6l5LUZok NiAqGV2bkLMybxGL3v1gaUHsVMngAYGZrh2tPXzuk2la2Fdtt2/ieRDBEOWRWO/BQfql T1RjZkMSQiMB7ewMLfF353/zu9cGp/TeEnHiVbINgOZ2msxBsw8la6ZZ+QgcvmNUpyiI C2cZ4BlsHaIJf2fMzpOmTehVUoCX0mW9zIlLkxvc0a1ESIXad++n8zdv8HVdGId9RjTZ TljA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1771558097; x=1772162897; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=0AEEfE6xiusQnEvNeZM84fhKgvDhfLyCCrKC1bZTQl0=; b=N7axRCZoYxxlxnpOIkbfAgEogXBfpdLiozddwf9NBk01n3dR3Sgfcqog1SnhXjnxbF 3gTqFvLoJX2OpArk7VPzEj06P/ZigIBz09vcHwazmUx7FxCOw6wSgYza/1LcCHsm5cgu LhSkYYpoL2+TMXarMYLRJ9mK9bJPKXaj87YBvR3nKAHoguVLlB2au9EVIgbL8g2yeDjN bUzA5TtaUZXu8ysEXmc0u11vENaSI2/jDb2F4YMy/3JGchjLXKf4gbuWiEIlrRtIwQ6Y HQOi1+4StI4Dy85rbPgAa0eTso6Nf/TyoMxuu/LoDoWU7d2VlnD+PqTGVNtSYl2l4gCN YV0Q== X-Forwarded-Encrypted: i=1; AJvYcCWJoSewlZru067mY3KLo+gYLDDvcBXXSDMESRf/D93hLEbAHeUQ/Drl0evVasRnLCdAFM27yVUnGSqiPWo=@vger.kernel.org X-Gm-Message-State: AOJu0YzrJcUtWJkrF+ndgAsqV434RcYAIBN2c1bMIZTn8vdvk25SUrTb SEGRR2HxTb8D35LbJwgr+IpDp0pXS/ks/LgvIFzCjtYU+ISTrjy4vMXW4ldn10JFtKzALrXI19T dwgTXGINzIuvdZpmQB9F2wtoqtfsCAbKeavyE X-Gm-Gg: AZuq6aJMOPsQVPN1tH5EiL1AI6W8vojeC+6HNAQ66zPD7PBgmHMPDp6mot+zz7rJpJO Z8Wm+ZHs+M+X2dJQMDoSMwCVfaVcmEYD64G+fvXITZaPPSW7yxYaciLsk3sxbxkq8QIxg6HNOlx k78MMTK6QeQTD5uOo6MeIRmdJ2btFi2ZNknZsiEk82qFxdHgBdC6kABiQUUgVTBWW1H0pLGygC7 r9Qm86LIx8BwkzXUFC0oUxdup2v5vtir7XVn2CGT6HL0gWR7fHurp1Gzt6E4Sm3Xav5n2fe9p/l gB9aiYdpSCKkJXkyeMBxTW+aen3C7x0JdjbyujalC6WzP8irm8t1Y5HIY1SimP1liitm7r5IoQk CQC7c77tTUkUq1kRqC49HgXYy3KuGC7DHC2l1mmEMinySMIK4ApRCoQ== X-Received: by 2002:a05:6870:14cb:b0:3fd:c70c:3f0b with SMTP id 586e51a60fabf-40eee7fc0fbmr11112425fac.1.1771558097095; Thu, 19 Feb 2026 19:28:17 -0800 (PST) Received: from c7-smtp-2023.dev.purestorage.com ([208.88.159.128]) by smtp-relay.gmail.com with ESMTPS id 586e51a60fabf-40f18d151c8sm3221341fac.8.2026.02.19.19.28.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Feb 2026 19:28:17 -0800 (PST) X-Relaying-Domain: purestorage.com Received: from dev-csander.dev.purestorage.com (dev-csander.dev.purestorage.com [10.112.29.101]) by c7-smtp-2023.dev.purestorage.com (Postfix) with ESMTP id 9ACF1341D32; Thu, 19 Feb 2026 20:28:16 -0700 (MST) Received: by dev-csander.dev.purestorage.com (Postfix, from userid 1557716354) id 977F0E420F8; Thu, 19 Feb 2026 20:28:16 -0700 (MST) From: Caleb Sander Mateos To: Keith Busch , Jens Axboe , Christoph Hellwig , Sagi Grimberg , Chaitanya Kulkarni Cc: linux-nvme@lists.infradead.org, linux-kernel@vger.kernel.org, Caleb Sander Mateos Subject: [PATCH 6/6] nvmet: report NPDGL and NPDAL Date: Thu, 19 Feb 2026 20:28:09 -0700 Message-ID: <20260220032809.758089-7-csander@purestorage.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20260220032809.758089-1-csander@purestorage.com> References: <20260220032809.758089-1-csander@purestorage.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" A block device with a very large discard_granularity queue limit may not be able to report it in the 16-bit NPDG and NPDA fields in the Identify Namespace data structure. For this reason, version 2.1 of the NVMe specs added 32-bit fields NPDGL and NPDAL to the NVM Command Set Specific Identify Namespace structure. So report the discard_granularity there too and set OPTPERF to 11b to indicate those fields are supported. Signed-off-by: Caleb Sander Mateos --- drivers/nvme/target/admin-cmd.c | 2 ++ drivers/nvme/target/io-cmd-bdev.c | 19 +++++++++++++++---- drivers/nvme/target/nvmet.h | 2 ++ 3 files changed, 19 insertions(+), 4 deletions(-) diff --git a/drivers/nvme/target/admin-cmd.c b/drivers/nvme/target/admin-cm= d.c index 3da31bb1183e..72e733b62a2c 100644 --- a/drivers/nvme/target/admin-cmd.c +++ b/drivers/nvme/target/admin-cmd.c @@ -1056,10 +1056,12 @@ static void nvme_execute_identify_ns_nvm(struct nvm= et_req *req) id =3D kzalloc(sizeof(*id), GFP_KERNEL); if (!id) { status =3D NVME_SC_INTERNAL; goto out; } + if (req->ns->bdev) + nvmet_bdev_set_nvm_limits(req->ns->bdev, id); status =3D nvmet_copy_to_sgl(req, 0, id, sizeof(*id)); kfree(id); out: nvmet_req_complete(req, status); } diff --git a/drivers/nvme/target/io-cmd-bdev.c b/drivers/nvme/target/io-cmd= -bdev.c index d94f885a56d9..485b5cd42e4f 100644 --- a/drivers/nvme/target/io-cmd-bdev.c +++ b/drivers/nvme/target/io-cmd-bdev.c @@ -28,15 +28,15 @@ void nvmet_bdev_set_limits(struct block_device *bdev, s= truct nvme_id_ns *id) id->nawun =3D lpp0b; id->nawupf =3D lpp0b; id->nacwu =3D lpp0b; =20 /* - * OPTPERF =3D 01b indicates that the fields NPWG, NPWA, NPDG, NPDA, and - * NOWS are defined for this namespace and should be used by - * the host for I/O optimization. + * OPTPERF =3D 11b indicates that the fields NPWG, NPWA, NPDG, NPDA, + * NPDGL, NPDAL, and NOWS are defined for this namespace and should be + * used by the host for I/O optimization. */ - id->nsfeat |=3D 0x1 << NVME_NS_FEAT_OPTPERF_SHIFT; + id->nsfeat |=3D 0x3 << NVME_NS_FEAT_OPTPERF_SHIFT; /* NPWG =3D Namespace Preferred Write Granularity. 0's based */ id->npwg =3D to0based(bdev_io_min(bdev) / bdev_logical_block_size(bdev)); /* NPWA =3D Namespace Preferred Write Alignment. 0's based */ id->npwa =3D id->npwg; /* NPDG =3D Namespace Preferred Deallocate Granularity. 0's based */ @@ -50,10 +50,21 @@ void nvmet_bdev_set_limits(struct block_device *bdev, s= truct nvme_id_ns *id) /* Set WZDS and DRB if device supports unmapped write zeroes */ if (bdev_write_zeroes_unmap_sectors(bdev)) id->dlfeat =3D (1 << 3) | 0x1; } =20 +void nvmet_bdev_set_nvm_limits(struct block_device *bdev, + struct nvme_id_ns_nvm *id) +{ + /* + * NPDGL =3D Namespace Preferred Deallocate Granularity Large + * NPDAL =3D Namespace Preferred Deallocate Alignment Large + */ + id->npdgl =3D id->npdal =3D cpu_to_le32(bdev_discard_granularity(bdev) / + bdev_logical_block_size(bdev)); +} + void nvmet_bdev_ns_disable(struct nvmet_ns *ns) { if (ns->bdev_file) { fput(ns->bdev_file); ns->bdev =3D NULL; diff --git a/drivers/nvme/target/nvmet.h b/drivers/nvme/target/nvmet.h index b664b584fdc8..3a7efd9cb81a 100644 --- a/drivers/nvme/target/nvmet.h +++ b/drivers/nvme/target/nvmet.h @@ -547,10 +547,12 @@ void nvmet_start_keep_alive_timer(struct nvmet_ctrl *= ctrl); void nvmet_stop_keep_alive_timer(struct nvmet_ctrl *ctrl); =20 u16 nvmet_parse_connect_cmd(struct nvmet_req *req); u32 nvmet_connect_cmd_data_len(struct nvmet_req *req); void nvmet_bdev_set_limits(struct block_device *bdev, struct nvme_id_ns *i= d); +void nvmet_bdev_set_nvm_limits(struct block_device *bdev, + struct nvme_id_ns_nvm *id); u16 nvmet_bdev_parse_io_cmd(struct nvmet_req *req); u16 nvmet_file_parse_io_cmd(struct nvmet_req *req); u16 nvmet_bdev_zns_parse_io_cmd(struct nvmet_req *req); u32 nvmet_admin_cmd_data_len(struct nvmet_req *req); u16 nvmet_parse_admin_cmd(struct nvmet_req *req); --=20 2.45.2