From 169e2cc279c443085f7e423561eb1fe6158ade44 Mon Sep 17 00:00:00 2001 From: Mike Snitzer Date: Thu, 22 Aug 2013 18:21:38 -0400 Subject: dm: allow error target to replace bio-based and request-based targets It may be useful to switch a request-based table to the "error" target. Enhance the DM core to allow a hybrid target_type which is capable of handling either bios (via .map) or requests (via .map_rq). Add a request-based map function (.map_rq) to the "error" target_type; making it DM's first hybrid target. Train dm_table_set_type() to prefer the mapped device's established type (request-based or bio-based). If the mapped device doesn't have an established type default to making the table with the hybrid target(s) bio-based. Tested 'dmsetup wipe_table' to work on both bio-based and request-based devices. Signed-off-by: Mike Snitzer Signed-off-by: Joe Jin Signed-off-by: Jun'ichi Nomura Acked-by: Mikulas Patocka Signed-off-by: Alasdair G Kergon --- drivers/md/dm.h | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'drivers/md/dm.h') diff --git a/drivers/md/dm.h b/drivers/md/dm.h index 45b97da1bd06..8b4c075d9a2f 100644 --- a/drivers/md/dm.h +++ b/drivers/md/dm.h @@ -88,11 +88,22 @@ int dm_setup_md_queue(struct mapped_device *md); */ #define dm_target_is_valid(t) ((t)->table) +/* + * To check whether the target type is bio-based or not (request-based). + */ +#define dm_target_bio_based(t) ((t)->type->map != NULL) + /* * To check whether the target type is request-based or not (bio-based). */ #define dm_target_request_based(t) ((t)->type->map_rq != NULL) +/* + * To check whether the target type is a hybrid (capable of being + * either request-based or bio-based). + */ +#define dm_target_hybrid(t) (dm_target_bio_based(t) && dm_target_request_based(t)) + /*----------------------------------------------------------------- * A registry of target types. *---------------------------------------------------------------*/ -- cgit v1.2.2