Skip to content

Commit

Permalink
block: Block layer data integrity support
Browse files Browse the repository at this point in the history
Some block devices support verifying the integrity of requests by way
of checksums or other protection information that is submitted along
with the I/O.

This patch implements support for generating and verifying integrity
metadata, as well as correctly merging, splitting and cloning bios and
requests that have this extra information attached.

See Documentation/block/data-integrity.txt for more information.

Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
  • Loading branch information
martinkpetersen authored and Jens Axboe committed Jul 3, 2008
1 parent 51d654e commit 7ba1ba1
Show file tree
Hide file tree
Showing 13 changed files with 1,355 additions and 7 deletions.
12 changes: 12 additions & 0 deletions block/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,18 @@ config BLK_DEV_BSG

If unsure, say N.

config BLK_DEV_INTEGRITY
bool "Block layer data integrity support"
---help---
Some storage devices allow extra information to be
stored/retrieved to help protect the data. The block layer
data integrity option provides hooks which can be used by
filesystems to ensure better data integrity.

Say yes here if you have a storage device that provides the
T10/SCSI Data Integrity Field or the T13/ATA External Path
Protection. If in doubt, say N.

endif # BLOCK

config BLOCK_COMPAT
Expand Down
1 change: 1 addition & 0 deletions block/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,4 @@ obj-$(CONFIG_IOSCHED_CFQ) += cfq-iosched.o

obj-$(CONFIG_BLK_DEV_IO_TRACE) += blktrace.o
obj-$(CONFIG_BLOCK_COMPAT) += compat_ioctl.o
obj-$(CONFIG_BLK_DEV_INTEGRITY) += blk-integrity.o
7 changes: 7 additions & 0 deletions block/blk-core.c
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,10 @@ static void req_bio_endio(struct request *rq, struct bio *bio,

bio->bi_size -= nbytes;
bio->bi_sector += (nbytes >> 9);

if (bio_integrity(bio))
bio_integrity_advance(bio, nbytes);

if (bio->bi_size == 0)
bio_endio(bio, error);
} else {
Expand Down Expand Up @@ -1381,6 +1385,9 @@ static inline void __generic_make_request(struct bio *bio)
*/
blk_partition_remap(bio);

if (bio_integrity_enabled(bio) && bio_integrity_prep(bio))
goto end_io;

if (old_sector != -1)
blk_add_trace_remap(q, bio, old_dev, bio->bi_sector,
old_sector);
Expand Down
Loading

0 comments on commit 7ba1ba1

Please sign in to comment.