linux-raid.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Christoph Hellwig <hch@lst.de>
To: Jens Axboe <axboe@kernel.dk>,
	"Martin K. Petersen" <martin.petersen@oracle.com>
Cc: Mike Snitzer <snitzer@kernel.org>,
	Mikulas Patocka <mpatocka@redhat.com>, Song Liu <song@kernel.org>,
	Yu Kuai <yukuai3@huawei.com>,
	Dan Williams <dan.j.williams@intel.com>,
	Vishal Verma <vishal.l.verma@intel.com>,
	Dave Jiang <dave.jiang@intel.com>,
	Ira Weiny <ira.weiny@intel.com>, Keith Busch <kbusch@kernel.org>,
	Sagi Grimberg <sagi@grimberg.me>,
	Chaitanya Kulkarni <kch@nvidia.com>,
	linux-block@vger.kernel.org, dm-devel@lists.linux.dev,
	linux-raid@vger.kernel.org, nvdimm@lists.linux.dev,
	linux-nvme@lists.infradead.org, linux-scsi@vger.kernel.org,
	Hannes Reinecke <hare@suse.de>
Subject: [PATCH 11/12] block: invert the BLK_INTEGRITY_{GENERATE,VERIFY} flags
Date: Thu, 13 Jun 2024 10:48:21 +0200	[thread overview]
Message-ID: <20240613084839.1044015-12-hch@lst.de> (raw)
In-Reply-To: <20240613084839.1044015-1-hch@lst.de>

Invert the flags so that user set values will be able to persist
revalidating the integrity information once we switch the integrity
information to queue_limits.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Chaitanya Kulkarni <kch@nvidia.com>
Reviewed-by: Hannes Reinecke <hare@suse.de>
---
 block/bio-integrity.c         |  4 ++--
 block/blk-integrity.c         | 18 +++++++++---------
 include/linux/blk-integrity.h |  4 ++--
 3 files changed, 13 insertions(+), 13 deletions(-)

diff --git a/block/bio-integrity.c b/block/bio-integrity.c
index 31dbc2853f92e3..173ffd4d623788 100644
--- a/block/bio-integrity.c
+++ b/block/bio-integrity.c
@@ -448,10 +448,10 @@ bool bio_integrity_prep(struct bio *bio)
 		return true;
 
 	if (bio_data_dir(bio) == READ) {
-		if (!(bi->flags & BLK_INTEGRITY_VERIFY))
+		if (bi->flags & BLK_INTEGRITY_NOVERIFY)
 			return true;
 	} else {
-		if (!(bi->flags & BLK_INTEGRITY_GENERATE))
+		if (bi->flags & BLK_INTEGRITY_NOGENERATE)
 			return true;
 
 		/*
diff --git a/block/blk-integrity.c b/block/blk-integrity.c
index bec0d1df387ce9..b37b8855eed147 100644
--- a/block/blk-integrity.c
+++ b/block/blk-integrity.c
@@ -254,10 +254,11 @@ static ssize_t flag_store(struct device *dev, struct device_attribute *attr,
 	if (err)
 		return err;
 
+	/* the flags are inverted vs the values in the sysfs files */
 	if (val)
-		bi->flags |= flag;
-	else
 		bi->flags &= ~flag;
+	else
+		bi->flags |= flag;
 	return count;
 }
 
@@ -266,7 +267,7 @@ static ssize_t flag_show(struct device *dev, struct device_attribute *attr,
 {
 	struct blk_integrity *bi = dev_to_bi(dev);
 
-	return sysfs_emit(page, "%d\n", !!(bi->flags & flag));
+	return sysfs_emit(page, "%d\n", !(bi->flags & flag));
 }
 
 static ssize_t format_show(struct device *dev, struct device_attribute *attr,
@@ -301,26 +302,26 @@ static ssize_t read_verify_store(struct device *dev,
 				 struct device_attribute *attr,
 				 const char *page, size_t count)
 {
-	return flag_store(dev, attr, page, count, BLK_INTEGRITY_VERIFY);
+	return flag_store(dev, attr, page, count, BLK_INTEGRITY_NOVERIFY);
 }
 
 static ssize_t read_verify_show(struct device *dev,
 				struct device_attribute *attr, char *page)
 {
-	return flag_show(dev, attr, page, BLK_INTEGRITY_VERIFY);
+	return flag_show(dev, attr, page, BLK_INTEGRITY_NOVERIFY);
 }
 
 static ssize_t write_generate_store(struct device *dev,
 				    struct device_attribute *attr,
 				    const char *page, size_t count)
 {
-	return flag_store(dev, attr, page, count, BLK_INTEGRITY_GENERATE);
+	return flag_store(dev, attr, page, count, BLK_INTEGRITY_NOGENERATE);
 }
 
 static ssize_t write_generate_show(struct device *dev,
 				   struct device_attribute *attr, char *page)
 {
-	return flag_show(dev, attr, page, BLK_INTEGRITY_GENERATE);
+	return flag_show(dev, attr, page, BLK_INTEGRITY_NOGENERATE);
 }
 
 static ssize_t device_is_integrity_capable_show(struct device *dev,
@@ -371,8 +372,7 @@ void blk_integrity_register(struct gendisk *disk, struct blk_integrity *template
 	struct blk_integrity *bi = &disk->queue->integrity;
 
 	bi->csum_type = template->csum_type;
-	bi->flags = BLK_INTEGRITY_VERIFY | BLK_INTEGRITY_GENERATE |
-		template->flags;
+	bi->flags = template->flags;
 	bi->interval_exp = template->interval_exp ? :
 		ilog2(queue_logical_block_size(disk->queue));
 	bi->tuple_size = template->tuple_size;
diff --git a/include/linux/blk-integrity.h b/include/linux/blk-integrity.h
index 56ce1ae355805d..bafa01d4e7f95b 100644
--- a/include/linux/blk-integrity.h
+++ b/include/linux/blk-integrity.h
@@ -7,8 +7,8 @@
 struct request;
 
 enum blk_integrity_flags {
-	BLK_INTEGRITY_VERIFY		= 1 << 0,
-	BLK_INTEGRITY_GENERATE		= 1 << 1,
+	BLK_INTEGRITY_NOVERIFY		= 1 << 0,
+	BLK_INTEGRITY_NOGENERATE	= 1 << 1,
 	BLK_INTEGRITY_DEVICE_CAPABLE	= 1 << 2,
 	BLK_INTEGRITY_REF_TAG		= 1 << 3,
 };
-- 
2.43.0


  parent reply	other threads:[~2024-06-13  8:49 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-06-13  8:48 move integrity settings to queue_limits v3 Christoph Hellwig
2024-06-13  8:48 ` [PATCH 01/12] block: initialize integrity buffer to zero before writing it to media Christoph Hellwig
2024-06-14  2:02   ` Martin K. Petersen
2024-06-14 12:45   ` Kanchan Joshi
2024-06-13  8:48 ` [PATCH 02/12] md/raid0: don't free conf on raid0_run failure Christoph Hellwig
2024-06-14  2:03   ` Martin K. Petersen
2024-06-13  8:48 ` [PATCH 03/12] md/raid1: " Christoph Hellwig
2024-06-14  2:04   ` Martin K. Petersen
2024-06-13  8:48 ` [PATCH 04/12] dm-integrity: use the nop integrity profile Christoph Hellwig
2024-06-14  2:04   ` Martin K. Petersen
2024-06-13  8:48 ` [PATCH 05/12] block: remove the blk_integrity_profile structure Christoph Hellwig
2024-06-14  2:11   ` Martin K. Petersen
2024-06-13  8:48 ` [PATCH 06/12] block: remove the blk_flush_integrity call in blk_integrity_unregister Christoph Hellwig
2024-06-13  8:48 ` [PATCH 07/12] block: factor out flag_{store,show} helper for integrity Christoph Hellwig
2024-06-13  8:48 ` [PATCH 08/12] block: use kstrtoul in flag_store Christoph Hellwig
2024-06-14 12:46   ` Kanchan Joshi
2024-06-13  8:48 ` [PATCH 09/12] block: don't require stable pages for non-PI metadata Christoph Hellwig
2024-06-13  8:48 ` [PATCH 10/12] block: bypass the STABLE_WRITES flag for protection information Christoph Hellwig
2024-06-13  8:48 ` Christoph Hellwig [this message]
2024-06-14  2:11   ` [PATCH 11/12] block: invert the BLK_INTEGRITY_{GENERATE,VERIFY} flags Martin K. Petersen
2024-06-13  8:48 ` [PATCH 12/12] block: move integrity information into queue_limits Christoph Hellwig
2024-06-13 13:40   ` Hannes Reinecke
2024-06-14  2:18   ` Martin K. Petersen
2024-06-14 12:33 ` move integrity settings to queue_limits v3 Jens Axboe
2024-06-14 16:03   ` Christoph Hellwig
2024-06-14 16:04     ` Jens Axboe
2024-06-14 16:07       ` Christoph Hellwig
2024-06-14 16:16         ` Jens Axboe
2024-06-14 16:23           ` Jens Axboe
2024-06-15  5:01             ` Christoph Hellwig
2024-06-14 16:23 ` Jens Axboe
  -- strict thread matches above, loose matches on Subject: below --
2024-06-05  6:28 move integrity settings to queue_limits Christoph Hellwig
2024-06-05  6:28 ` [PATCH 11/12] block: invert the BLK_INTEGRITY_{GENERATE,VERIFY} flags Christoph Hellwig
2024-06-06  0:20   ` Chaitanya Kulkarni

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=20240613084839.1044015-12-hch@lst.de \
    --to=hch@lst.de \
    --cc=axboe@kernel.dk \
    --cc=dan.j.williams@intel.com \
    --cc=dave.jiang@intel.com \
    --cc=dm-devel@lists.linux.dev \
    --cc=hare@suse.de \
    --cc=ira.weiny@intel.com \
    --cc=kbusch@kernel.org \
    --cc=kch@nvidia.com \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-nvme@lists.infradead.org \
    --cc=linux-raid@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=martin.petersen@oracle.com \
    --cc=mpatocka@redhat.com \
    --cc=nvdimm@lists.linux.dev \
    --cc=sagi@grimberg.me \
    --cc=snitzer@kernel.org \
    --cc=song@kernel.org \
    --cc=vishal.l.verma@intel.com \
    --cc=yukuai3@huawei.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;
as well as URLs for NNTP newsgroup(s).