summaryrefslogtreecommitdiffstats
path: root/block
diff options
context:
space:
mode:
authorDan Williams <dan.j.williams@intel.com>2015-10-21 13:20:29 -0400
committerJens Axboe <axboe@fb.com>2015-10-21 14:43:45 -0600
commit4125a09b0a0d579ebace17f0e62b03ab9d5ab2f4 (patch)
treed2e073b3985850b1ea2a8e7ba9a414a6427f463f /block
parent5a48fc147d7f2718a5c7e73bc8c4067235791fc1 (diff)
downloadlinux-4125a09b0a0d579ebace17f0e62b03ab9d5ab2f4.tar.gz
linux-4125a09b0a0d579ebace17f0e62b03ab9d5ab2f4.tar.bz2
linux-4125a09b0a0d579ebace17f0e62b03ab9d5ab2f4.zip
block, libnvdimm, nvme: provide a built-in blk_integrity nop profile
The libnvidmm-btt and nvme drivers use blk_integrity to reserve space for per-sector metadata, but sometimes without protection checksums. This property is generically useful, so teach the block core to internally specify a nop profile if one is not provided at registration time. Cc: Keith Busch <keith.busch@intel.com> Cc: Matthew Wilcox <willy@linux.intel.com> Suggested-by: Christoph Hellwig <hch@lst.de> [hch: kill the local nvme nop profile as well] Acked-by: Martin K. Petersen <martin.petersen@oracle.com> Signed-off-by: Dan Williams <dan.j.williams@intel.com> Signed-off-by: Jens Axboe <axboe@fb.com>
Diffstat (limited to 'block')
-rw-r--r--block/blk-integrity.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/block/blk-integrity.c b/block/blk-integrity.c
index 5d339ae64d56..d69c5c79f98e 100644
--- a/block/blk-integrity.c
+++ b/block/blk-integrity.c
@@ -384,6 +384,17 @@ static struct kobj_type integrity_ktype = {
.sysfs_ops = &integrity_ops,
};
+static int blk_integrity_nop_fn(struct blk_integrity_iter *iter)
+{
+ return 0;
+}
+
+static struct blk_integrity_profile nop_profile = {
+ .name = "nop",
+ .generate_fn = blk_integrity_nop_fn,
+ .verify_fn = blk_integrity_nop_fn,
+};
+
/**
* blk_integrity_register - Register a gendisk as being integrity-capable
* @disk: struct gendisk pointer to make integrity-aware
@@ -402,7 +413,7 @@ void blk_integrity_register(struct gendisk *disk, struct blk_integrity *template
bi->flags = BLK_INTEGRITY_VERIFY | BLK_INTEGRITY_GENERATE |
template->flags;
bi->interval_exp = ilog2(queue_logical_block_size(disk->queue));
- bi->profile = template->profile;
+ bi->profile = template->profile ? template->profile : &nop_profile;
bi->tuple_size = template->tuple_size;
bi->tag_size = template->tag_size;