From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-vs1-f98.google.com (mail-vs1-f98.google.com [209.85.217.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 B04D23A63F6 for ; Tue, 24 Feb 2026 17:15:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.217.98 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771953305; cv=none; b=V6HZ8abdSTyzzJNSgMwh6IbXPLxYUk0lJxF1naCkkqW1V3h1hUDp4l549dUp8+9n4/2UlDgmP2z2K7npqn09mMAWKqe1lsze6cC5UcN7s9hNjIlmkHcf5R5+7xMfUXIYzQpdqKMR1sf+SIf5Ca3N6Cfx1QxulF1GONa6EwN6nmA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771953305; c=relaxed/simple; bh=X+W+av2iPZp0WhzcXBoIuO+sar1KALyAE5oKfwqngOk=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=IYpJ54TK55Tp32GFAf3jsoXe5aiq0BN5gVNWy0+7/cRnQw0VxfzArNir1jOumT4JxxktGMwEdtocb3+J/MxJwFR5vN1CKb+kuhQe3RKqCIVBNVaiT0DBopRsFaOekLir+7Q9X4IatuuJKM7y8blpmxcgxGtQhYgn/rPubmKg3Ew= 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=Zsd84U3X; arc=none smtp.client-ip=209.85.217.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="Zsd84U3X" Received: by mail-vs1-f98.google.com with SMTP id ada2fe7eead31-5fe01ed3e3bso298424137.1 for ; Tue, 24 Feb 2026 09:15:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=purestorage.com; s=google2022; t=1771953301; x=1772558101; 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=QL2ryiCUVfF0yvlCDe2HZGFa6PV7tL4QK7zbVcKn8Kg=; b=Zsd84U3XReShUXD2U1Twn6CAbxIOeUkm+rdvk3G24IEuLiiqRKhXX/boPkft03tsMQ VQ/d/m4zkqWVGQ8WbBHEDhReYuEMWCG2KpnlpuMoX707b5pCGjjxPuWbGSnOI6aGix/9 TPf3MH2aQKa9QFsfgX2MzNFfEY/+1qP9TTZbIcA/Ek0M3TD43nwwR8m/uYB5nYjcp3p6 kTQQH+eXrkzpg55Few9UmVQazECXrXbYw6SLMJtRPxL+VkB+6I9wbVwBfQ/f08F6nQBP SDYoRlY8Ql8WmgI9CyoFZGLhQp3QocneVgJSgIkT64ElkbLeCrSkBhkCPGkiOLVPFL0G gROw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1771953301; x=1772558101; 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=QL2ryiCUVfF0yvlCDe2HZGFa6PV7tL4QK7zbVcKn8Kg=; b=vQ82OzIHxcfpVxpm7IA/YT2Q4VIU1HyqYV84Dpdf47x6GzMTX0p2tPSOt+B9fhX12l L+CfGhq9gk0Vm+mqTjQwIM7qi3GDpWTn2DaBQ9c0Bamrr+3Of49p+pXm07CS7PoB4chg Gq9nOkatKdhRGF2fDwvGTQm933QDRMrTkrlLQFq9XVE3c7O+4XP8MRFy63JhmbaCg9eD jBXMAos3arpV279GAWZyst0ZtPzZ0MK+zJD7kgiNrieFv0DWz7rgxs8/HPlZVTwwUirc jHK7qgokoTeDUwdiuxDL5jJx9US8NCHLuOlpjfLTELsE8aKavmbtg2apCaoXsSuM18g2 PJHA== X-Forwarded-Encrypted: i=1; AJvYcCVLE9lpsewypSw8eO46dpKlCqFKU8WtExAKcv/2FoG/BmUBJK/DVLoKsDEfy+OXZLQubHUJy5kH0KanL7U=@vger.kernel.org X-Gm-Message-State: AOJu0YzX/Z7jDxC9Zu6uUF66bH1uEkiq9ZcLmu2Gb0aw8oATu85uNWz1 9v77PVGHjDKCrTKLIJ/R+fmj/oFi0fVZfR0J8MXM4cuEe3HYdd5bulj4ExXWs5A+hogxdpBf0sc 5vaOqZQWuecwSB/Eag2WhVxoWoITfBMrqInSi/yzkmRmPLlktxAiH X-Gm-Gg: ATEYQzzRla0Wbj8ex4H5h1m793tvb7v4hIDpAgF5ozGy5lyD6yN8s4jArLjgVAFAKNr RY1+auuENbiSqPs/ySQzrFrQRJHWL8F8XwGIDlXJBewQb3JiRK4EjWe6X8FSKrnT+SSADVI154T g1eX28RuDbAwPMR7DfD2FV/ZHiLDo7BTmYZ8O2h8/xLoItDvU7RLJ9vd9eQLpVxbaxNU+XVTagJ R3yIo7HR4MarvtPWIrvJ+foFtHLTmjnN2NrU36ZEo4Dv27gUt1JsHQuni8LTA/7r/fECvVJYpr9 6RR5wZJp87f7tnaXiV8RKTnyJvC53eaAiU5v80+EJYprdk8j7jCxRgK+i3nmzUSf9WfwyQujlWJ npj7fGKayTV/Pk2I3rLc3JOcJKejKAo2rJfZa9p4= X-Received: by 2002:a05:6102:1606:b0:5ec:95a0:6aac with SMTP id ada2fe7eead31-5feb3012075mr2528095137.4.1771953301460; Tue, 24 Feb 2026 09:15:01 -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 a1e0cc1a2514c-94da8b19a3fsm872261241.8.2026.02.24.09.15.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Feb 2026 09:15:01 -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 C54C5340705; Tue, 24 Feb 2026 10:15:00 -0700 (MST) Received: by dev-csander.dev.purestorage.com (Postfix, from userid 1557716354) id B6404E41254; Tue, 24 Feb 2026 10:15:00 -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 v3 0/8] nvme: set discard_granularity from NPDG/NPDA Date: Tue, 24 Feb 2026 10:14:29 -0700 Message-ID: <20260224171437.3175993-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. 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 | 85 +++++++++++++++++++++---------- 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, 95 insertions(+), 34 deletions(-) -- 2.45.2