mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-29 11:11:45 -04:00
dm: improve block integrity support
The current block integrity (DIF/DIX) support in DM is verifying that all devices' integrity profiles match during DM device resume (which is past the point of no return). To some degree that is unavoidable (stacked DM devices force this late checking). But for most DM devices (which aren't stacking on other DM devices) the ideal time to verify all integrity profiles match is during table load. Introduce the notion of an "initialized" integrity profile: a profile that was blk_integrity_register()'d with a non-NULL 'blk_integrity' template. Add blk_integrity_is_initialized() to allow checking if a profile was initialized. Update DM integrity support to: - check all devices with _initialized_ integrity profiles match during table load; uninitialized profiles (e.g. for underlying DM device(s) of a stacked DM device) are ignored. - disallow a table load that would result in an integrity profile that conflicts with a DM device's existing (in-use) integrity profile - avoid clearing an existing integrity profile - validate all integrity profiles match during resume; but if they don't all we can do is report the mismatch (during resume we're past the point of no return) Signed-off-by: Mike Snitzer <[email protected]> Cc: Martin K. Petersen <[email protected]> Signed-off-by: Jens Axboe <[email protected]>
This commit is contained in:
parent
7dcda1c96d
commit
a63a5cf84d
3 changed files with 93 additions and 35 deletions
|
|
@ -30,6 +30,8 @@
|
|||
|
||||
static struct kmem_cache *integrity_cachep;
|
||||
|
||||
static const char *bi_unsupported_name = "unsupported";
|
||||
|
||||
/**
|
||||
* blk_rq_count_integrity_sg - Count number of integrity scatterlist elements
|
||||
* @q: request queue
|
||||
|
|
@ -358,6 +360,14 @@ static struct kobj_type integrity_ktype = {
|
|||
.release = blk_integrity_release,
|
||||
};
|
||||
|
||||
bool blk_integrity_is_initialized(struct gendisk *disk)
|
||||
{
|
||||
struct blk_integrity *bi = blk_get_integrity(disk);
|
||||
|
||||
return (bi && bi->name && strcmp(bi->name, bi_unsupported_name) != 0);
|
||||
}
|
||||
EXPORT_SYMBOL(blk_integrity_is_initialized);
|
||||
|
||||
/**
|
||||
* blk_integrity_register - Register a gendisk as being integrity-capable
|
||||
* @disk: struct gendisk pointer to make integrity-aware
|
||||
|
|
@ -407,7 +417,7 @@ int blk_integrity_register(struct gendisk *disk, struct blk_integrity *template)
|
|||
bi->get_tag_fn = template->get_tag_fn;
|
||||
bi->tag_size = template->tag_size;
|
||||
} else
|
||||
bi->name = "unsupported";
|
||||
bi->name = bi_unsupported_name;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue