Skip to content

Commit 9f4aa46

Browse files
Christoph Hellwigaxboe
authored andcommitted
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 <[email protected]> Reviewed-by: Chaitanya Kulkarni <[email protected]> Reviewed-by: Hannes Reinecke <[email protected]> Reviewed-by: Martin K. Petersen <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jens Axboe <[email protected]>
1 parent 3c3e85d commit 9f4aa46

File tree

3 files changed

+13
-13
lines changed

3 files changed

+13
-13
lines changed

block/bio-integrity.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -448,10 +448,10 @@ bool bio_integrity_prep(struct bio *bio)
448448
return true;
449449

450450
if (bio_data_dir(bio) == READ) {
451-
if (!(bi->flags & BLK_INTEGRITY_VERIFY))
451+
if (bi->flags & BLK_INTEGRITY_NOVERIFY)
452452
return true;
453453
} else {
454-
if (!(bi->flags & BLK_INTEGRITY_GENERATE))
454+
if (bi->flags & BLK_INTEGRITY_NOGENERATE)
455455
return true;
456456

457457
/*

block/blk-integrity.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -254,10 +254,11 @@ static ssize_t flag_store(struct device *dev, struct device_attribute *attr,
254254
if (err)
255255
return err;
256256

257+
/* the flags are inverted vs the values in the sysfs files */
257258
if (val)
258-
bi->flags |= flag;
259-
else
260259
bi->flags &= ~flag;
260+
else
261+
bi->flags |= flag;
261262
return count;
262263
}
263264

@@ -266,7 +267,7 @@ static ssize_t flag_show(struct device *dev, struct device_attribute *attr,
266267
{
267268
struct blk_integrity *bi = dev_to_bi(dev);
268269

269-
return sysfs_emit(page, "%d\n", !!(bi->flags & flag));
270+
return sysfs_emit(page, "%d\n", !(bi->flags & flag));
270271
}
271272

272273
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,
301302
struct device_attribute *attr,
302303
const char *page, size_t count)
303304
{
304-
return flag_store(dev, attr, page, count, BLK_INTEGRITY_VERIFY);
305+
return flag_store(dev, attr, page, count, BLK_INTEGRITY_NOVERIFY);
305306
}
306307

307308
static ssize_t read_verify_show(struct device *dev,
308309
struct device_attribute *attr, char *page)
309310
{
310-
return flag_show(dev, attr, page, BLK_INTEGRITY_VERIFY);
311+
return flag_show(dev, attr, page, BLK_INTEGRITY_NOVERIFY);
311312
}
312313

313314
static ssize_t write_generate_store(struct device *dev,
314315
struct device_attribute *attr,
315316
const char *page, size_t count)
316317
{
317-
return flag_store(dev, attr, page, count, BLK_INTEGRITY_GENERATE);
318+
return flag_store(dev, attr, page, count, BLK_INTEGRITY_NOGENERATE);
318319
}
319320

320321
static ssize_t write_generate_show(struct device *dev,
321322
struct device_attribute *attr, char *page)
322323
{
323-
return flag_show(dev, attr, page, BLK_INTEGRITY_GENERATE);
324+
return flag_show(dev, attr, page, BLK_INTEGRITY_NOGENERATE);
324325
}
325326

326327
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
371372
struct blk_integrity *bi = &disk->queue->integrity;
372373

373374
bi->csum_type = template->csum_type;
374-
bi->flags = BLK_INTEGRITY_VERIFY | BLK_INTEGRITY_GENERATE |
375-
template->flags;
375+
bi->flags = template->flags;
376376
bi->interval_exp = template->interval_exp ? :
377377
ilog2(queue_logical_block_size(disk->queue));
378378
bi->tuple_size = template->tuple_size;

include/linux/blk-integrity.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
struct request;
88

99
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,
1212
BLK_INTEGRITY_DEVICE_CAPABLE = 1 << 2,
1313
BLK_INTEGRITY_REF_TAG = 1 << 3,
1414
};

0 commit comments

Comments
 (0)