Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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: Christoph Hellwig <hch@lst.de>
Reviewed-by: Chaitanya Kulkarni <kch@nvidia.com>
Reviewed-by: Hannes Reinecke <hare@suse.de>
Reviewed-by: Martin K. Petersen <martin.petersen@oracle.com>
Link: https://lore.kernel.org/r/20240613084839.1044015-12-hch@lst.de
Signed-off-by: Jens Axboe <axboe@kernel.dk>

authored by

Christoph Hellwig and committed by
Jens Axboe
9f4aa46f 3c3e85dd

+13 -13
+2 -2
block/bio-integrity.c
··· 448 448 return true; 449 449 450 450 if (bio_data_dir(bio) == READ) { 451 - if (!(bi->flags & BLK_INTEGRITY_VERIFY)) 451 + if (bi->flags & BLK_INTEGRITY_NOVERIFY) 452 452 return true; 453 453 } else { 454 - if (!(bi->flags & BLK_INTEGRITY_GENERATE)) 454 + if (bi->flags & BLK_INTEGRITY_NOGENERATE) 455 455 return true; 456 456 457 457 /*
+9 -9
block/blk-integrity.c
··· 254 254 if (err) 255 255 return err; 256 256 257 + /* the flags are inverted vs the values in the sysfs files */ 257 258 if (val) 258 - bi->flags |= flag; 259 - else 260 259 bi->flags &= ~flag; 260 + else 261 + bi->flags |= flag; 261 262 return count; 262 263 } 263 264 ··· 267 266 { 268 267 struct blk_integrity *bi = dev_to_bi(dev); 269 268 270 - return sysfs_emit(page, "%d\n", !!(bi->flags & flag)); 269 + return sysfs_emit(page, "%d\n", !(bi->flags & flag)); 271 270 } 272 271 273 272 static ssize_t format_show(struct device *dev, struct device_attribute *attr, ··· 302 301 struct device_attribute *attr, 303 302 const char *page, size_t count) 304 303 { 305 - return flag_store(dev, attr, page, count, BLK_INTEGRITY_VERIFY); 304 + return flag_store(dev, attr, page, count, BLK_INTEGRITY_NOVERIFY); 306 305 } 307 306 308 307 static ssize_t read_verify_show(struct device *dev, 309 308 struct device_attribute *attr, char *page) 310 309 { 311 - return flag_show(dev, attr, page, BLK_INTEGRITY_VERIFY); 310 + return flag_show(dev, attr, page, BLK_INTEGRITY_NOVERIFY); 312 311 } 313 312 314 313 static ssize_t write_generate_store(struct device *dev, 315 314 struct device_attribute *attr, 316 315 const char *page, size_t count) 317 316 { 318 - return flag_store(dev, attr, page, count, BLK_INTEGRITY_GENERATE); 317 + return flag_store(dev, attr, page, count, BLK_INTEGRITY_NOGENERATE); 319 318 } 320 319 321 320 static ssize_t write_generate_show(struct device *dev, 322 321 struct device_attribute *attr, char *page) 323 322 { 324 - return flag_show(dev, attr, page, BLK_INTEGRITY_GENERATE); 323 + return flag_show(dev, attr, page, BLK_INTEGRITY_NOGENERATE); 325 324 } 326 325 327 326 static ssize_t device_is_integrity_capable_show(struct device *dev, ··· 372 371 struct blk_integrity *bi = &disk->queue->integrity; 373 372 374 373 bi->csum_type = template->csum_type; 375 - bi->flags = BLK_INTEGRITY_VERIFY | BLK_INTEGRITY_GENERATE | 376 - template->flags; 374 + bi->flags = template->flags; 377 375 bi->interval_exp = template->interval_exp ? : 378 376 ilog2(queue_logical_block_size(disk->queue)); 379 377 bi->tuple_size = template->tuple_size;
+2 -2
include/linux/blk-integrity.h
··· 7 7 struct request; 8 8 9 9 enum blk_integrity_flags { 10 - BLK_INTEGRITY_VERIFY = 1 << 0, 11 - BLK_INTEGRITY_GENERATE = 1 << 1, 10 + BLK_INTEGRITY_NOVERIFY = 1 << 0, 11 + BLK_INTEGRITY_NOGENERATE = 1 << 1, 12 12 BLK_INTEGRITY_DEVICE_CAPABLE = 1 << 2, 13 13 BLK_INTEGRITY_REF_TAG = 1 << 3, 14 14 };