Commit 9f4aa46f authored by Christoph Hellwig's avatar Christoph Hellwig Committed by Jens Axboe

block: invert the BLK_INTEGRITY_{GENERATE,VERIFY} flags

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: default avatarChristoph Hellwig <hch@lst.de>
Reviewed-by: default avatarChaitanya Kulkarni <kch@nvidia.com>
Reviewed-by: default avatarHannes Reinecke <hare@suse.de>
Reviewed-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
Link: https://lore.kernel.org/r/20240613084839.1044015-12-hch@lst.deSigned-off-by: default avatarJens Axboe <axboe@kernel.dk>
parent 3c3e85dd
...@@ -448,10 +448,10 @@ bool bio_integrity_prep(struct bio *bio) ...@@ -448,10 +448,10 @@ bool bio_integrity_prep(struct bio *bio)
return true; return true;
if (bio_data_dir(bio) == READ) { if (bio_data_dir(bio) == READ) {
if (!(bi->flags & BLK_INTEGRITY_VERIFY)) if (bi->flags & BLK_INTEGRITY_NOVERIFY)
return true; return true;
} else { } else {
if (!(bi->flags & BLK_INTEGRITY_GENERATE)) if (bi->flags & BLK_INTEGRITY_NOGENERATE)
return true; return true;
/* /*
......
...@@ -254,10 +254,11 @@ static ssize_t flag_store(struct device *dev, struct device_attribute *attr, ...@@ -254,10 +254,11 @@ static ssize_t flag_store(struct device *dev, struct device_attribute *attr,
if (err) if (err)
return err; return err;
/* the flags are inverted vs the values in the sysfs files */
if (val) if (val)
bi->flags |= flag;
else
bi->flags &= ~flag; bi->flags &= ~flag;
else
bi->flags |= flag;
return count; return count;
} }
...@@ -266,7 +267,7 @@ static ssize_t flag_show(struct device *dev, struct device_attribute *attr, ...@@ -266,7 +267,7 @@ static ssize_t flag_show(struct device *dev, struct device_attribute *attr,
{ {
struct blk_integrity *bi = dev_to_bi(dev); 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, 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, ...@@ -301,26 +302,26 @@ static ssize_t read_verify_store(struct device *dev,
struct device_attribute *attr, struct device_attribute *attr,
const char *page, size_t count) 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, static ssize_t read_verify_show(struct device *dev,
struct device_attribute *attr, char *page) 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, static ssize_t write_generate_store(struct device *dev,
struct device_attribute *attr, struct device_attribute *attr,
const char *page, size_t count) 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, static ssize_t write_generate_show(struct device *dev,
struct device_attribute *attr, char *page) 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, 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 ...@@ -371,8 +372,7 @@ void blk_integrity_register(struct gendisk *disk, struct blk_integrity *template
struct blk_integrity *bi = &disk->queue->integrity; struct blk_integrity *bi = &disk->queue->integrity;
bi->csum_type = template->csum_type; bi->csum_type = template->csum_type;
bi->flags = BLK_INTEGRITY_VERIFY | BLK_INTEGRITY_GENERATE | bi->flags = template->flags;
template->flags;
bi->interval_exp = template->interval_exp ? : bi->interval_exp = template->interval_exp ? :
ilog2(queue_logical_block_size(disk->queue)); ilog2(queue_logical_block_size(disk->queue));
bi->tuple_size = template->tuple_size; bi->tuple_size = template->tuple_size;
......
...@@ -7,8 +7,8 @@ ...@@ -7,8 +7,8 @@
struct request; struct request;
enum blk_integrity_flags { enum blk_integrity_flags {
BLK_INTEGRITY_VERIFY = 1 << 0, BLK_INTEGRITY_NOVERIFY = 1 << 0,
BLK_INTEGRITY_GENERATE = 1 << 1, BLK_INTEGRITY_NOGENERATE = 1 << 1,
BLK_INTEGRITY_DEVICE_CAPABLE = 1 << 2, BLK_INTEGRITY_DEVICE_CAPABLE = 1 << 2,
BLK_INTEGRITY_REF_TAG = 1 << 3, BLK_INTEGRITY_REF_TAG = 1 << 3,
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment