diff options
author | Vishal Verma <vishal.l.verma@intel.com> | 2015-06-25 04:21:52 -0400 |
---|---|---|
committer | Dan Williams <dan.j.williams@intel.com> | 2015-06-26 11:23:38 -0400 |
commit | 41cd8b70c37ace40077c8d6ec0b74b983178c192 (patch) | |
tree | e4d99ee384708f35e4d44549a16b2165a77209ef /drivers/nvdimm/core.c | |
parent | f68eb1e71a92765ffd8eb68466a41b48f2fbba04 (diff) |
libnvdimm, btt: add support for blk integrity
Support multiple block sizes (sector + metadata) using the blk integrity
framework. This registers a new integrity template that defines the
protection information tuple size based on the configured metadata size,
and simply acts as a passthrough for protection information generated by
another layer. The metadata is written to the storage as-is, and read back
with each sector.
Signed-off-by: Vishal Verma <vishal.l.verma@linux.intel.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
Diffstat (limited to 'drivers/nvdimm/core.c')
-rw-r--r-- | drivers/nvdimm/core.c | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/drivers/nvdimm/core.c b/drivers/nvdimm/core.c index dd824d7c2669..1d96b9a6e4cc 100644 --- a/drivers/nvdimm/core.c +++ b/drivers/nvdimm/core.c @@ -13,6 +13,7 @@ #include <linux/libnvdimm.h> #include <linux/export.h> #include <linux/module.h> +#include <linux/blkdev.h> #include <linux/device.h> #include <linux/ctype.h> #include <linux/ndctl.h> @@ -361,6 +362,42 @@ void nvdimm_bus_unregister(struct nvdimm_bus *nvdimm_bus) } EXPORT_SYMBOL_GPL(nvdimm_bus_unregister); +#ifdef CONFIG_BLK_DEV_INTEGRITY +static int nd_pi_nop_generate_verify(struct blk_integrity_iter *iter) +{ + return 0; +} + +int nd_integrity_init(struct gendisk *disk, unsigned long meta_size) +{ + struct blk_integrity integrity = { + .name = "ND-PI-NOP", + .generate_fn = nd_pi_nop_generate_verify, + .verify_fn = nd_pi_nop_generate_verify, + .tuple_size = meta_size, + .tag_size = meta_size, + }; + int ret; + + ret = blk_integrity_register(disk, &integrity); + if (ret) + return ret; + + blk_queue_max_integrity_segments(disk->queue, 1); + + return 0; +} +EXPORT_SYMBOL(nd_integrity_init); + +#else /* CONFIG_BLK_DEV_INTEGRITY */ +int nd_integrity_init(struct gendisk *disk, unsigned long meta_size) +{ + return 0; +} +EXPORT_SYMBOL(nd_integrity_init); + +#endif + static __init int libnvdimm_init(void) { int rc; |