Block Layer Data Integrity Fixes
Subsystems (2)
PATCH 1/1 Block Layer Data Integrity Fixes
Block integrity updates for 2.6.29.
3 files changed, 29 insertions(+), 23 deletions(-) block/blk-integrity.c | 25 ++++++++++++++----------- fs/bio-integrity.c | 26 +++++++++++++++----------- include/linux/bio.h | 1 -
PATCH 1/1 block: Allow empty integrity profile
Allow a block device to allocate and register an integrity profile without providing a template. This allows DM to preallocate a profile to avoid deadlocks during table reconfiguration.
---
1 file changed, 14 insertions(+), 11 deletions(-)
block/blk-integrity.c | 25 ++++++++++++++-----------
block/blk-integrity.c +14 -11
@@ -309,24 +309,24 @@ static struct kobj_type integrity_ktype/** * blk_integrity_register - Register a gendisk as being integrity-capable * @disk: struct gendisk pointer to make integrity-aware -* @template: integrity profile +* @template: optional integrity profile to register * * Description: When a device needs to advertise itself as being able * to send/receive integrity metadata it must use this function to * register the capability with the block layer. The template is a * blk_integrity struct with values appropriate for the underlying -* hardware. See Documentation/block/data-integrity.txt. +* hardware. If template is NULL the new profile is allocated but +* not filled out. See Documentation/block/data-integrity.txt. */ int blk_integrity_register (struct gendisk *disk,struct blk_integrity *template) {struct blk_integrity *bi;BUG_ON (disk ==NULL ); -BUG_ON (template ==NULL );if (disk->integrity ==NULL ) { bi =kmem_cache_alloc (integrity_cachep, -GFP_KERNEL | __GFP_ZERO); +GFP_KERNEL | __GFP_ZERO);if (!bi)return -1 ;
@@ -346,13 +346,16 @@ int blk_integrity_register(struct gendis bi = disk->integrity;/* Use the provided profile as template */ - bi->name = template->name; - bi->generate_fn = template->generate_fn; - bi->verify_fn = template->verify_fn; - bi->tuple_size = template->tuple_size; - bi->set_tag_fn = template->set_tag_fn; - bi->get_tag_fn = template->get_tag_fn; - bi->tag_size = template->tag_size; +if (template !=NULL ) { + bi->name = template->name; + bi->generate_fn = template->generate_fn; + bi->verify_fn = template->verify_fn; + bi->tuple_size = template->tuple_size; + bi->set_tag_fn = template->set_tag_fn; + bi->get_tag_fn = template->get_tag_fn; + bi->tag_size = template->tag_size; + }else + bi->name ="unsupported" ;return 0 ; }
PATCH 1/1 block: Remove obsolete BUG_ON
In reply to Martin K. PetersenNow that bio_vecs are no longer cleared in bvec_alloc_bs() the following BUG_ON must go.
---
1 file changed, 1 deletion(-)
fs/bio-integrity.c | 1 -
fs/bio-integrity.c +0 -1
@@ -140,7 +140,6 @@ int bio_integrity_add_page(struct bio *b iv =bip_vec_idx (bip, bip->bip_vcnt);BUG_ON (iv ==NULL ); -BUG_ON (iv->bv_page !=NULL ); iv->bv_page = page; iv->bv_len = len;
PATCH 1/1 block: Don't verify integrity metadata on read error
In reply to Martin K. PetersenIf we get an I/O error on a read request there is no point in doing a verify pass on the integrity buffer. Adjust the completion path accordingly.
---
2 files changed, 15 insertions(+), 11 deletions(-)
fs/bio-integrity.c | 25 +++++++++++++++----------include/linux/bio.h | 1 -
fs/bio-integrity.c +15 -10
@@ -465,7 +465,7 @@ static int bio_integrity_verify(struct bif (ret) {kunmap_atomic (kaddr,KM_USER0 ); -break ; +return ret; } sectors = bv->bv_len / bi->sector_size;
@@ -493,18 +493,13 @@ static void bio_integrity_verify_fn(strustruct bio_integrity_payload *bip = container_of(work, struct bio_integrity_payload, bip_work);struct bio *bio = bip->bip_bio; -int error = bip->bip_error; +int error; -if (bio_integrity_verify (bio)) { -clear_bit (BIO_UPTODATE , &bio->bi_flags); - error = -EIO ; - } + error =bio_integrity_verify (bio);/* Restore original bio completion handler */ bio->bi_end_io = bip->bip_end_io; - -if (bio->bi_end_io) - bio->bi_end_io (bio, error); +bio_endio (bio, error); }/**
@@ -525,7 +520,17 @@ void bio_integrity_endio(struct bio *bioBUG_ON (bip->bip_bio != bio); - bip->bip_error = error; +/* In case of an I/O error there is no point in verifying the +* integrity metadata. Restore original bio end_io handler +* and run it. +*/ +if (error) { + bio->bi_end_io = bip->bip_end_io; +bio_endio (bio, error); + +return ; + } +INIT_WORK (&bip->bip_work, bio_integrity_verify_fn);queue_work (kintegrityd_wq, &bip->bip_work); }
include/linux/bio.h +0 -1
@@ -312,7 +312,6 @@ struct bio_integrity_payload {void *bip_buf;/* generated integrity data */ bio_end_io_t *bip_end_io;/* saved I/O completion fn */ -int bip_error;/* saved I/O error */ unsigned int bip_size;unsigned short bip_pool;/* pool the ivec came from */
Quoted 7 lines · Martin K. Petersen
Block integrity updates for 2.6.29.
3 files changed, 29 insertions(+), 23 deletions(-) block/blk-integrity.c | 25 ++++++++++++++----------- fs/bio-integrity.c | 26 +++++++++++++++----------- include/linux/bio.h | 1 -
Applied 1-3 for 2.6.29
Signature · 1 line
Jens Axboe