summaryrefslogtreecommitdiffstats
path: root/drivers/md/dm-verity.h
diff options
context:
space:
mode:
authorSami Tolvanen <samitolvanen@google.com>2015-12-03 15:26:30 +0100
committerMike Snitzer <snitzer@redhat.com>2015-12-10 16:39:03 +0100
commita739ff3f543afbb4a041c16cd0182c8e8d366e70 (patch)
tree2613a382283548a1b88e6f2ba589252312d05fff /drivers/md/dm-verity.h
parentdm verity: factor out verity_for_bv_block() (diff)
downloadlinux-a739ff3f543afbb4a041c16cd0182c8e8d366e70.tar.xz
linux-a739ff3f543afbb4a041c16cd0182c8e8d366e70.zip
dm verity: add support for forward error correction
Add support for correcting corrupted blocks using Reed-Solomon. This code uses RS(255, N) interleaved across data and hash blocks. Each error-correcting block covers N bytes evenly distributed across the combined total data, so that each byte is a maximum distance away from the others. This makes it possible to recover from several consecutive corrupted blocks with relatively small space overhead. In addition, using verity hashes to locate erasures nearly doubles the effectiveness of error correction. Being able to detect corrupted blocks also improves performance, because only corrupted blocks need to corrected. For a 2 GiB partition, RS(255, 253) (two parity bytes for each 253-byte block) can correct up to 16 MiB of consecutive corrupted blocks if erasures can be located, and 8 MiB if they cannot, with 16 MiB space overhead. Signed-off-by: Sami Tolvanen <samitolvanen@google.com> Signed-off-by: Mike Snitzer <snitzer@redhat.com>
Diffstat (limited to 'drivers/md/dm-verity.h')
-rw-r--r--drivers/md/dm-verity.h10
1 files changed, 10 insertions, 0 deletions
diff --git a/drivers/md/dm-verity.h b/drivers/md/dm-verity.h
index f5af52df8e38..8e853722f6c6 100644
--- a/drivers/md/dm-verity.h
+++ b/drivers/md/dm-verity.h
@@ -29,6 +29,8 @@ enum verity_block_type {
DM_VERITY_BLOCK_TYPE_METADATA
};
+struct dm_verity_fec;
+
struct dm_verity {
struct dm_dev *data_dev;
struct dm_dev *hash_dev;
@@ -58,6 +60,8 @@ struct dm_verity {
/* starting blocks for each tree level. 0 is the lowest level. */
sector_t hash_level_block[DM_VERITY_MAX_LEVELS];
+
+ struct dm_verity_fec *fec; /* forward error correction */
};
struct dm_verity_io {
@@ -103,6 +107,12 @@ static inline u8 *verity_io_want_digest(struct dm_verity *v,
return (u8 *)(io + 1) + v->shash_descsize + v->digest_size;
}
+static inline u8 *verity_io_digest_end(struct dm_verity *v,
+ struct dm_verity_io *io)
+{
+ return verity_io_want_digest(v, io) + v->digest_size;
+}
+
extern int verity_for_bv_block(struct dm_verity *v, struct dm_verity_io *io,
struct bvec_iter *iter,
int (*process)(struct dm_verity *v,