From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-ot1-f100.google.com (mail-ot1-f100.google.com [209.85.210.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 CF9CE33261C for ; Thu, 26 Feb 2026 19:04:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.100 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772132671; cv=none; b=HpapAPvKnU8BYMZxcbrJwVmzNUgL8j5xTXGF8VZ/hUGO+xER437qehkKOi0RuvzCdlQ2frWJUbjUML5u4EbWc87MGHA7+x95gNeFioYEzj5ly/hLTMnaMJtORI4zVmjNggVEOZkqZQtLT3vTvTrr1pzCUNFupcsr50T/QSBEGvg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772132671; c=relaxed/simple; bh=+nKifTsTDYH6kzS82cf2dfmHcUDmr5lzIryK7KgZkqU=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=dsB+ZCTfFEIZZzm57b3s0UeCA8RLyHNU6GouFbp8qmjcj1rwtwP2yp1vlaKJOdyJguWgSdiZJr5EtTNyKI77sN/Mu2/DnXv6Ar+zlGZ3lRbMuDSyS8ZYR6IZmOioZyIhJtORQCLSdgWyE8ak1yF/bim9hnKAO0qyVaE5zmVAPZI= 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=S4aZxHrp; arc=none smtp.client-ip=209.85.210.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="S4aZxHrp" Received: by mail-ot1-f100.google.com with SMTP id 46e09a7af769-7d18e44b0afso126288a34.3 for ; Thu, 26 Feb 2026 11:04:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=purestorage.com; s=google2022; t=1772132660; x=1772737460; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=P8Pf2k79HwheJjr29+InaR2lhFNdapyckaF87dy9zn0=; b=S4aZxHrpz3bWTieiSfvCsXBU6hrwlZZa5mecpz8uWWsWfrIPWVUIwo3wTxqHr5YCqc Mqq0pv89AxGvEQBYjxUpOSzw02FNUD2VfaeZHxFyYMtuZndHm0fEMNk3CCtVX69eehj0 B55r/14vSBYcohQRn5npE8fpZO3H/uQZoAOjhHsEK5QWxycG3qBEHNPCdS7jf7+0dtJL RW9o+VF9w5SRRUzQ/lW14OVDhyfJMPtrgTSZnHjzZJ1w3H036AMsstLzKMmF6tk05kuz QLvPBUBBihj6x4kNTjVSZErWpRb//8CanSjGoiOM/bZqVDBS6u8BvmL7JSXO/9OdaNq/ FcFQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1772132660; x=1772737460; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=P8Pf2k79HwheJjr29+InaR2lhFNdapyckaF87dy9zn0=; b=rp1XO5t58DPLpyhTPsDWBYYCfsl2ud1s322Z/QXcIWTt5wURqmDfj7Cx78L2+SDxTy xeE9f4/KGT3+9HHqFEU3niWQKnH5SS3322yyMd9xTv3MKBye+dRj2DiDA+Nvo5D21bVb 5588RmrQG8A27eFd9JbRxuHegV2inia4PzsBnK8vHxL+ujwHCl4/GtMGphXyTgXAnK9N /z99jOrPqie+K+1RdB1BDDusTPUHVyYUBUEO4jfrNhHA2aNCksuNYCq4bYWUCtrxCjcW qiHLpkFbgj+0msZjuItCq2ngNbpK5rnqBxeYlzqkReiWDBNmPvAKyHkxpy05K7Oqtrsk 3nsw== X-Forwarded-Encrypted: i=1; AJvYcCVRKBWwt0HsIS9VsUzc3Q9HyHXjVsaraNH71aA70bD7DissGRMZjt36Ab28LQOh+YJZKz4YTRYoFNDZu3U=@vger.kernel.org X-Gm-Message-State: AOJu0Yz87dW7CcxxxJitKPoiccdkT3nL7UQ6FZdlfWlt2lXt1C5g5/iZ q5LqCACfZlA6FLCt3FdK8deiYissAQ+9/a5MOIW/O1mYXQ5YvQA3wWPPt7Eg7I2agH+X/uS2xl+ im24I2nY8tyvhV4ybWZOWm6TLIpMsO0lLMFJu X-Gm-Gg: ATEYQzwMPBjmnBJs3mGDfRwfSxAxzX+R8rw3do5+4RawVC3DEqwUcIBks+kuGFON+O0 s4QuHfta/cRC5lvQmIAi7/bSknwL1jnXA0SNrONXi+ezJn4WkMSytQc8GEVNASKWqEC0rG4D3As 1TNSCpwt8qwTG5FOFajLn7LWl2lShqN+xNXbIc5De7FgmiANVitu56udccs7IgEQHyFE+6fPOdH qknJ442DXvjN32uN6K0++p0sCoMG1Atz7i3wBMRHAW3EicTAdUFd+NhHfGJtxqJoBnuDWFrpqM3 i7dk2HMJZWLuQUTv55luF/Al39a952wacnRrF3Ph8nU/641Hxv4eXuh0hQuCJHMO+R8ZI+pJ1GR tPxR+mgLsXFmD6JjetrHvhmXYwiU8VX+Cy0YbQyWJ3NPWah8N1iXm7A== X-Received: by 2002:a05:6830:7189:b0:7cf:e4a1:8b64 with SMTP id 46e09a7af769-7d591affc02mr205140a34.2.1772132660441; Thu, 26 Feb 2026 11:04:20 -0800 (PST) Received: from c7-smtp-2023.dev.purestorage.com ([208.88.159.129]) by smtp-relay.gmail.com with ESMTPS id 46e09a7af769-7d5865024ffsm329727a34.4.2026.02.26.11.04.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Feb 2026 11:04:20 -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 A3C87340245; Thu, 26 Feb 2026 12:04:19 -0700 (MST) Received: by dev-csander.dev.purestorage.com (Postfix, from userid 1557716354) id 8BBE4E41254; Thu, 26 Feb 2026 12:04:19 -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 v4 0/8] nvme: set discard_granularity from NPDG/NPDA Date: Thu, 26 Feb 2026 12:04:07 -0700 Message-ID: <20260226190416.297725-1-csander@purestorage.com> X-Mailer: git-send-email 2.45.2 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit NVMe block devices always report the logical block size for the discard_granularity queue limit. However, more accurate values may be available in the NPDG/NPDA fields of the Identify Namespace structure or the NPDGL/NPDAL fields of the NVM Command Set Specific Identify Namespace structure. So use these values to compute discard_granularity. Also fix the use of the OPTPERF field to better comply with version 2.1 of the NVMe spec. Update the target side to report NPDGL and NPDAL as well, in case the discard granularity doesn't fit in the 16-bit NPDG and NPDA fields. v4: - Issue NVM Command Set Specific Identify Namespace regardless of controller version (Keith) v3: - Introduce from0based() (Christoph) - Fix merge conflict resolution (Keith) - Add more comments (Christoph) - Add Reviewed-by tags (Christoph) v2: - Only use low bit of OPTPERF on pre-2.1 controllers (Christoph) - Add Reviewed-by tags (Christoph) Caleb Sander Mateos (8): nvme: add preferred I/O size fields to struct nvme_id_ns_nvm nvme: fold nvme_config_discard() into nvme_update_disk_info() nvme: update nvme_id_ns OPTPERF constants nvme: always issue I/O Command Set specific Identify Namespace nvme: add from0based() helper nvme: set discard_granularity from NPDG/NPDA nvmet: use NVME_NS_FEAT_OPTPERF_SHIFT nvmet: report NPDGL and NPDAL drivers/nvme/host/core.c | 90 ++++++++++++++++++++----------- drivers/nvme/host/nvme.h | 6 +++ drivers/nvme/target/admin-cmd.c | 2 + drivers/nvme/target/io-cmd-bdev.c | 19 +++++-- drivers/nvme/target/nvmet.h | 2 + include/linux/nvme.h | 15 +++++- 6 files changed, 96 insertions(+), 38 deletions(-) -- 2.45.2