public inbox for linux-scsi@vger.kernel.org
 help / color / mirror / Atom feed
From: Anuj Gupta <anuj20.g@samsung.com>
To: axboe@kernel.dk, hch@lst.de, kbusch@kernel.org,
	martin.petersen@oracle.com
Cc: anuj1072538@gmail.com, nikh1092@linux.ibm.com,
	linux-nvme@lists.infradead.org, linux-block@vger.kernel.org,
	linux-scsi@vger.kernel.org, dm-devel@lists.linux.dev,
	Anuj Gupta <anuj20.g@samsung.com>,
	M Nikhil <nikhilm@linux.ibm.com>
Subject: [PATCH v1 1/3] block: Fix incorrect integrity sysfs reporting for DM devices
Date: Tue, 25 Feb 2025 10:16:51 +0530	[thread overview]
Message-ID: <20250225044653.6867-2-anuj20.g@samsung.com> (raw)
In-Reply-To: <20250225044653.6867-1-anuj20.g@samsung.com>

The integrity stacking logic in device-mapper currently does not
explicitly mark the device with BLK_INTEGRITY_NOGENERATE and
BLK_INTEGRITY_NOVERIFY when the underlying device(s) do not support
integrity. This can lead to incorrect sysfs reporting of integrity
attributes.

Additionally, queue_limits_stack_integrity() incorrectly sets
BLK_INTEGRITY_DEVICE_CAPABLE for a DM device even when none of its
underlying devices support integrity. This happens because the flag is
blindly inherited from the first base device, even if it lacks integrity
support.

This patch ensures:
1. BLK_INTEGRITY_NOGENERATE and BLK_INTEGRITY_NOVERIFY are set correctly:
   - When the underlying device does not support integrity.
   - When integrity stacking fails due to incompatible profiles.
2. device_is_integrity_capable is correctly propagated to reflect the
actual capability of the stacked device.

Reported-by: M Nikhil <nikhilm@linux.ibm.com>
Link: https://lore.kernel.org/linux-block/f6130475-3ccd-45d2-abde-3ccceada0f0a@linux.ibm.com/
Fixes: c6e56cf6b2e7 ("block: move integrity information into queue_limits")
Signed-off-by: Anuj Gupta <anuj20.g@samsung.com>
---
 block/blk-settings.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/block/blk-settings.c b/block/blk-settings.c
index c44dadc35e1e..c32517c8bc2e 100644
--- a/block/blk-settings.c
+++ b/block/blk-settings.c
@@ -861,7 +861,8 @@ bool queue_limits_stack_integrity(struct queue_limits *t,
 
 	if (!ti->tuple_size) {
 		/* inherit the settings from the first underlying device */
-		if (!(ti->flags & BLK_INTEGRITY_STACKED)) {
+		if (!(ti->flags & BLK_INTEGRITY_STACKED) &&
+		    (bi->flags & BLK_INTEGRITY_DEVICE_CAPABLE)) {
 			ti->flags = BLK_INTEGRITY_DEVICE_CAPABLE |
 				(bi->flags & BLK_INTEGRITY_REF_TAG);
 			ti->csum_type = bi->csum_type;
@@ -871,8 +872,11 @@ bool queue_limits_stack_integrity(struct queue_limits *t,
 			ti->tag_size = bi->tag_size;
 			goto done;
 		}
-		if (!bi->tuple_size)
+		if (!bi->tuple_size) {
+			ti->flags |= BLK_INTEGRITY_NOGENERATE |
+				     BLK_INTEGRITY_NOVERIFY;
 			goto done;
+		}
 	}
 
 	if (ti->tuple_size != bi->tuple_size)
@@ -893,6 +897,7 @@ bool queue_limits_stack_integrity(struct queue_limits *t,
 
 incompatible:
 	memset(ti, 0, sizeof(*ti));
+	ti->flags |= BLK_INTEGRITY_NOGENERATE | BLK_INTEGRITY_NOVERIFY;
 	return false;
 }
 EXPORT_SYMBOL_GPL(queue_limits_stack_integrity);
-- 
2.25.1


  reply	other threads:[~2025-02-25  5:12 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CGME20250225045511epcas5p2d89efcac39b6553317e93e8c7fea3f2b@epcas5p2.samsung.com>
2025-02-25  4:46 ` [PATCH v1 0/3] Fix integrity sysfs reporting inconsistencies across NVMe, SCSI, and DM Anuj Gupta
2025-02-25  4:46   ` Anuj Gupta [this message]
2025-02-25 15:06     ` [PATCH v1 1/3] block: Fix incorrect integrity sysfs reporting for DM devices Christoph Hellwig
2025-02-26 11:27       ` Anuj gupta
2025-02-25  4:46   ` [PATCH v1 2/3] nvme: Fix incorrect block integrity sysfs values for non-PI namespaces Anuj Gupta
2025-02-25 15:07     ` Christoph Hellwig
2025-02-25  4:46   ` [PATCH v1 3/3] scsi: Fix incorrect integrity sysfs values when HBA doesn't support DIX Anuj Gupta

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250225044653.6867-2-anuj20.g@samsung.com \
    --to=anuj20.g@samsung.com \
    --cc=anuj1072538@gmail.com \
    --cc=axboe@kernel.dk \
    --cc=dm-devel@lists.linux.dev \
    --cc=hch@lst.de \
    --cc=kbusch@kernel.org \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-nvme@lists.infradead.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=martin.petersen@oracle.com \
    --cc=nikh1092@linux.ibm.com \
    --cc=nikhilm@linux.ibm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox