linux-raid.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Anuj Gupta <anuj20.g@samsung.com>
To: Anuj gupta <anuj1072538@gmail.com>
Cc: "Martin K. Petersen" <martin.petersen@oracle.com>,
	Christoph Hellwig <hch@lst.de>, M Nikhil <nikh1092@linux.ibm.com>,
	linux-block@vger.kernel.org, dm-devel@lists.linux.dev,
	linux-raid@vger.kernel.org, nvdimm@lists.linux.dev,
	linux-scsi@vger.kernel.org, hare@suse.de,
	steffen Maier <maier@linux.ibm.com>,
	Benjamin Block <bblock@linux.ibm.com>,
	Nihar Panda <niharp@linux.ibm.com>
Subject: Re: Change in reported values of some block integrity sysfs attributes
Date: Fri, 21 Feb 2025 16:05:54 +0530	[thread overview]
Message-ID: <20250221103554.GA28830@green245> (raw)
In-Reply-To: <CACzX3AvbM4qG+ZOWJoCTNMMgSz8gMjoRcQ10_HJbMyi0Nv9qvQ@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 2886 bytes --]

On Fri, Feb 21, 2025 at 04:07:55PM +0530, Anuj gupta wrote:
> > I don't see any change in what's reported with block/for-next in a
> > regular SCSI HBA/disk setup. Will have to look at whether there is a
> > stacking issue wrt. multipathing.
> 
> Hi Martin, Christoph,
> 
> It seems this change in behaviour is not limited to SCSI only. As Nikhil
> mentioned an earlier commit
> [9f4aa46f2a74 ("block: invert the BLK_INTEGRITY_{GENERATE,VERIFY} flags")]
> causes this change in behaviour. On my setup with a NVMe drive not formatted
> with PI, I see that:
> 
> Without this commit:
> Value reported by read_verify and write_generate sysfs entries is 0.
> 
> With this commit:
> Value reported by read_verify and write_generate sysfs entries is 1.
> 
> Diving a bit deeper, both these flags got inverted due to this commit.
> But during init (in nvme_init_integrity) these values get initialized to 0,
> inturn setting the sysfs entries to 1. In order to fix this, the driver has to
> initialize both these flags to 1 in nvme_init_integrity if PI is not supported.
> That way, the value in sysfs for these entries would become 0 again. Tried this
> approach in my setup, and I am able to see the right values now. Then something
> like this would also need to be done for SCSI too.

This is the patch that I used:

diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
index 818d4e49aab5..6cd9f57131cc 100644
--- a/drivers/nvme/host/core.c
+++ b/drivers/nvme/host/core.c
@@ -1799,6 +1799,7 @@ static bool nvme_init_integrity(struct nvme_ns_head *head,
 
 	memset(bi, 0, sizeof(*bi));
 
+	bi->flags |= BLK_INTEGRITY_NOGENERATE | BLK_INTEGRITY_NOVERIFY;
 	if (!head->ms)
 		return true;
 
@@ -1817,11 +1818,15 @@ static bool nvme_init_integrity(struct nvme_ns_head *head,
 			bi->csum_type = BLK_INTEGRITY_CSUM_CRC;
 			bi->tag_size = sizeof(u16) + sizeof(u32);
 			bi->flags |= BLK_INTEGRITY_DEVICE_CAPABLE;
+			bi->flags &= ~(BLK_INTEGRITY_NOGENERATE |
+				       BLK_INTEGRITY_NOVERIFY);
 			break;
 		case NVME_NVM_NS_64B_GUARD:
 			bi->csum_type = BLK_INTEGRITY_CSUM_CRC64;
 			bi->tag_size = sizeof(u16) + 6;
 			bi->flags |= BLK_INTEGRITY_DEVICE_CAPABLE;
+			bi->flags &= ~(BLK_INTEGRITY_NOGENERATE |
+				       BLK_INTEGRITY_NOVERIFY);
 			break;
 		default:
 			break;
@@ -1835,12 +1840,16 @@ static bool nvme_init_integrity(struct nvme_ns_head *head,
 			bi->tag_size = sizeof(u16);
 			bi->flags |= BLK_INTEGRITY_DEVICE_CAPABLE |
 				     BLK_INTEGRITY_REF_TAG;
+			bi->flags &= ~(BLK_INTEGRITY_NOGENERATE |
+				       BLK_INTEGRITY_NOVERIFY);
 			break;
 		case NVME_NVM_NS_64B_GUARD:
 			bi->csum_type = BLK_INTEGRITY_CSUM_CRC64;
 			bi->tag_size = sizeof(u16);
 			bi->flags |= BLK_INTEGRITY_DEVICE_CAPABLE |
 				     BLK_INTEGRITY_REF_TAG;
+			bi->flags &= ~(BLK_INTEGRITY_NOGENERATE |
+				       BLK_INTEGRITY_NOVERIFY);
 			break;
 		default:
 			break;


[-- Attachment #2: Type: text/plain, Size: 0 bytes --]



  reply	other threads:[~2025-02-21 10:44 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-12-13  7:16 Change in reported values of some block integrity sysfs attributes M Nikhil
2024-12-13 14:33 ` Christoph Hellwig
2024-12-17 12:46   ` M Nikhil
2024-12-13 22:30 ` Martin K. Petersen
2024-12-17 12:39   ` M Nikhil
2025-02-21  6:01     ` M Nikhil
2025-02-21 10:37   ` Anuj gupta
2025-02-21 10:35     ` Anuj Gupta [this message]
2025-02-21 12:07     ` Anuj Gupta
2025-02-25  1:07       ` Martin K. Petersen

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=20250221103554.GA28830@green245 \
    --to=anuj20.g@samsung.com \
    --cc=anuj1072538@gmail.com \
    --cc=bblock@linux.ibm.com \
    --cc=dm-devel@lists.linux.dev \
    --cc=hare@suse.de \
    --cc=hch@lst.de \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-raid@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=maier@linux.ibm.com \
    --cc=martin.petersen@oracle.com \
    --cc=niharp@linux.ibm.com \
    --cc=nikh1092@linux.ibm.com \
    --cc=nvdimm@lists.linux.dev \
    /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;
as well as URLs for NNTP newsgroup(s).