From nobody Thu Apr 9 20:26:46 2026 Received: from mail-dl1-f74.google.com (mail-dl1-f74.google.com [74.125.82.74]) (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 529B3339B2D for ; Thu, 5 Mar 2026 20:28:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.82.74 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772742503; cv=none; b=tJYcqXn6fLMGA4v8pXxQTUVgMKbCjzfyQGfCNOuDBH1JnWvYCV5XqiXAzmb9zKoEpRw2kVMn/z9vqDz7A13VtTR9U8ErW8tiDOv6aQsnBqL7z3k7QNKHHZEQEY/GV7e8hZ/dln/jDBCTAQNM5EiN4pfkMm/Y7Yg9KExrYJL5OdE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772742503; c=relaxed/simple; bh=8vNLxhCegBtFXuA7Z4U4BUbcqasJ2AKCXd/UQh0e9JU=; h=Date:Mime-Version:Message-ID:Subject:From:To:Cc:Content-Type; b=obhJFoPTPcLVIgLJAYkUxp8NefHAZcyBIGq1ScH5KAJOLP1NfNg1lob5kJYqYDhEkFRwxF1lg8MC7lQaXK1Q6U4HM+ny0xnsG/hlqCi9USOxy1pPEWlOPG/Izpz8dmRBK6WUISiqoKcGE02goQU9k7i1vDpE0k+YY8pnKO7KWvA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--robertpang.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=Om4PCaxQ; arc=none smtp.client-ip=74.125.82.74 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--robertpang.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="Om4PCaxQ" Received: by mail-dl1-f74.google.com with SMTP id a92af1059eb24-128babbc373so13397503c88.0 for ; Thu, 05 Mar 2026 12:28:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1772742500; x=1773347300; darn=vger.kernel.org; h=cc:to:from:subject:message-id:mime-version:date:from:to:cc:subject :date:message-id:reply-to; bh=HQMoFpZFPnY9iExqsKENry4ZRR79ZPh5u7A7J7oYrH8=; b=Om4PCaxQE7JnMAMg6t9zLHtCzEBUdEAaQor7dcYNt9+rmkqIyBmso4+1euhIgR/Eo0 cVJmIY2Wa8VBfh7IS2TSGzpc69kuJBsKzW6Cc6/vCnpDfzbcu3KQdBuvCfSdSXfOlGjW uP8RSi+ZD7/h1a/Z+f2c3RbxZhJlNwoHfE+eWCW2YjcYtAaShiLThy4ps35O6NiVlsYS +s8krDD2jRdef+bY0t3iVweHvtlNt7wyiEvX1lTV6niG9uP6lrUVUYuAA9huXqoa24RG PCiiocG76FC69zdFK4LDbXHzH7k/546DAZU31HMmN0+urGZfPCPoMqB2cTUfhYhTRKxc oIgA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1772742500; x=1773347300; h=cc:to:from:subject:message-id:mime-version:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=HQMoFpZFPnY9iExqsKENry4ZRR79ZPh5u7A7J7oYrH8=; b=lY2zF7jfwKtpa1ytP/ED0wYzr6WxLcjfghCdB9G9JEjc6JoOhoNBrqcU3H30xaaSkN mSQkQBwI2B2Rz8WwzTcVyeJEeIFsV1Pv/UDJbm3VtSKRH0VH9oIOXk9lo4hzVbCsgv82 j6dWlHqZbgciXKcgjoFZV7QgqsKBLhO+uLPzNlqX50AC9rED9aS2hBesrUMRY+IYKHzW CqvspAHE8g7XpvttPaFJ+OqtOa8q9EX6VrjEB66UPdIQhRaSAKXbsJZN2tidZyPwxoOD oGd0sko5XQs7q4hCGcxx9bIJCFhzOhuXvMuabyW/W8SzCJsWURVTL7/3yYNQKUjj2F3p EIIA== X-Forwarded-Encrypted: i=1; AJvYcCU0Nv9PA5uLupzaAIE6ceZ35rhAwq+ovPAsP2LBJrefNfecEfsvu30kG+8ROBO9SqYeHJxSjHy5EImk2ZY=@vger.kernel.org X-Gm-Message-State: AOJu0YxpKylSAUOCAKs159mKm4ookKXrWh5FlOMFVU9uYnXZN2AiqeZG n1IjAe6G6Y2/mfXPhWLnlbhDcp5YrmyYlrTbYixmFeSAyJT2Bl0a2z1zvmG1g18ypPogx+xklKM p/uH24NUjeFXU2vpKxq0lqw== X-Received: from dlam21-n1.prod.google.com ([2002:a05:701b:2095:10b0:127:89b6:8d2a]) (user=robertpang job=prod-delivery.src-stubby-dispatcher) by 2002:a05:7022:ba4:b0:11b:7824:5c97 with SMTP id a92af1059eb24-128b70ebd92mr3414667c88.40.1772742499786; Thu, 05 Mar 2026 12:28:19 -0800 (PST) Date: Thu, 5 Mar 2026 12:27:32 -0800 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 X-Mailer: git-send-email 2.53.0.473.g4a7958ca14-goog Message-ID: <20260305202735.1773922-1-robertpang@google.com> Subject: [PATCH] nvme: honor NVME_QUIRK_DEALLOCATE_ZEROES for unmap Write Zeroes From: Robert Pang To: Keith Busch , Jens Axboe , Christoph Hellwig , Sagi Grimberg , Zhang Yi Cc: bmarzins@redhat.com, brauner@kernel.org, chaitanyak@nvidia.com, chengzhihao1@huawei.com, djwong@kernel.org, john.g.garry@oracle.com, martin.petersen@oracle.com, shinichiro.kawasaki@wdc.com, tytso@mit.edu, yangerkun@huawei.com, yi.zhang@huawei.com, yukuai3@huawei.com, robertpang@google.com, linux-nvme@lists.infradead.org, linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Currently, the NVMe driver sets max_hw_wzeroes_unmap_sectors to indicate the support for unmap Write Zeroes based strictly on the Deallocate Logical Blo= ck Features (dlfeat) in the Identify Namespace data (commit 545fb46e5bc6 "nvme= : set max_hw_wzeroes_unmap_sectors if device supports DEAC bit"). However, certain devices already use the NVME_QUIRK_DEALLOCATE_ZEROES quirk= to indicate that they deterministically return zeroes after a deallocate/disca= rd operation to support the Write Zeroes operation in nvme_setup_write_zeroes(= ). For these devices, it is appropriate to treat them as supporting the unmap = Write Zeroes operation. Update nvme_update_disk_info() to allow the presence of the DEALLOCATE_ZERO= ES quirk (combined with DSM support) to set max_hw_wzeroes_unmap_sectors to en= able the support for unmap Write Zeroes. This ensures consistency with how these devices are handled elsewhere in the driver. Signed-off-by: Robert Pang Link: https://lore.kernel.org/linux-ext4/20260225000531.3658802-1-robertpan= g@google.com/T/#m5e776f78ecb7631372d82a5cb3d11f8f1f8afe06 --- drivers/nvme/host/core.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c index f5ebcaa2f859..3f5dd3f867e9 100644 --- a/drivers/nvme/host/core.c +++ b/drivers/nvme/host/core.c @@ -2120,9 +2120,10 @@ static bool nvme_update_disk_info(struct nvme_ns *ns= , struct nvme_id_ns *id, lim->io_min =3D phys_bs; lim->io_opt =3D io_opt; if ((ns->ctrl->quirks & NVME_QUIRK_DEALLOCATE_ZEROES) && - (ns->ctrl->oncs & NVME_CTRL_ONCS_DSM)) + (ns->ctrl->oncs & NVME_CTRL_ONCS_DSM)) { lim->max_write_zeroes_sectors =3D UINT_MAX; - else + lim->max_hw_wzeroes_unmap_sectors =3D UINT_MAX; + } else lim->max_write_zeroes_sectors =3D ns->ctrl->max_zeroes_sectors; return valid; } --=20 2.53.0.473.g4a7958ca14-goog