diff options
Diffstat (limited to 'drivers/md')
-rw-r--r-- | drivers/md/dm-table.c | 22 | ||||
-rw-r--r-- | drivers/md/dm-target.c | 9 | ||||
-rw-r--r-- | drivers/md/dm.h | 11 |
3 files changed, 39 insertions, 3 deletions
diff --git a/drivers/md/dm-table.c b/drivers/md/dm-table.c index f221812b7dbc..f309477d7efe 100644 --- a/drivers/md/dm-table.c +++ b/drivers/md/dm-table.c | |||
@@ -860,14 +860,17 @@ EXPORT_SYMBOL(dm_consume_args); | |||
860 | static int dm_table_set_type(struct dm_table *t) | 860 | static int dm_table_set_type(struct dm_table *t) |
861 | { | 861 | { |
862 | unsigned i; | 862 | unsigned i; |
863 | unsigned bio_based = 0, request_based = 0; | 863 | unsigned bio_based = 0, request_based = 0, hybrid = 0; |
864 | struct dm_target *tgt; | 864 | struct dm_target *tgt; |
865 | struct dm_dev_internal *dd; | 865 | struct dm_dev_internal *dd; |
866 | struct list_head *devices; | 866 | struct list_head *devices; |
867 | unsigned live_md_type; | ||
867 | 868 | ||
868 | for (i = 0; i < t->num_targets; i++) { | 869 | for (i = 0; i < t->num_targets; i++) { |
869 | tgt = t->targets + i; | 870 | tgt = t->targets + i; |
870 | if (dm_target_request_based(tgt)) | 871 | if (dm_target_hybrid(tgt)) |
872 | hybrid = 1; | ||
873 | else if (dm_target_request_based(tgt)) | ||
871 | request_based = 1; | 874 | request_based = 1; |
872 | else | 875 | else |
873 | bio_based = 1; | 876 | bio_based = 1; |
@@ -879,6 +882,21 @@ static int dm_table_set_type(struct dm_table *t) | |||
879 | } | 882 | } |
880 | } | 883 | } |
881 | 884 | ||
885 | if (hybrid && !bio_based && !request_based) { | ||
886 | /* | ||
887 | * The targets can work either way. | ||
888 | * Determine the type from the live device. | ||
889 | * Default to bio-based if device is new. | ||
890 | */ | ||
891 | dm_lock_md_type(t->md); | ||
892 | live_md_type = dm_get_md_type(t->md); | ||
893 | dm_unlock_md_type(t->md); | ||
894 | if (live_md_type == DM_TYPE_REQUEST_BASED) | ||
895 | request_based = 1; | ||
896 | else | ||
897 | bio_based = 1; | ||
898 | } | ||
899 | |||
882 | if (bio_based) { | 900 | if (bio_based) { |
883 | /* We must use this table as bio-based */ | 901 | /* We must use this table as bio-based */ |
884 | t->type = DM_TYPE_BIO_BASED; | 902 | t->type = DM_TYPE_BIO_BASED; |
diff --git a/drivers/md/dm-target.c b/drivers/md/dm-target.c index 37ba5db71cd9..242e3cec397a 100644 --- a/drivers/md/dm-target.c +++ b/drivers/md/dm-target.c | |||
@@ -131,12 +131,19 @@ static int io_err_map(struct dm_target *tt, struct bio *bio) | |||
131 | return -EIO; | 131 | return -EIO; |
132 | } | 132 | } |
133 | 133 | ||
134 | static int io_err_map_rq(struct dm_target *ti, struct request *clone, | ||
135 | union map_info *map_context) | ||
136 | { | ||
137 | return -EIO; | ||
138 | } | ||
139 | |||
134 | static struct target_type error_target = { | 140 | static struct target_type error_target = { |
135 | .name = "error", | 141 | .name = "error", |
136 | .version = {1, 1, 0}, | 142 | .version = {1, 2, 0}, |
137 | .ctr = io_err_ctr, | 143 | .ctr = io_err_ctr, |
138 | .dtr = io_err_dtr, | 144 | .dtr = io_err_dtr, |
139 | .map = io_err_map, | 145 | .map = io_err_map, |
146 | .map_rq = io_err_map_rq, | ||
140 | }; | 147 | }; |
141 | 148 | ||
142 | int __init dm_target_init(void) | 149 | int __init dm_target_init(void) |
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 | |||
@@ -89,10 +89,21 @@ int dm_setup_md_queue(struct mapped_device *md); | |||
89 | #define dm_target_is_valid(t) ((t)->table) | 89 | #define dm_target_is_valid(t) ((t)->table) |
90 | 90 | ||
91 | /* | 91 | /* |
92 | * To check whether the target type is bio-based or not (request-based). | ||
93 | */ | ||
94 | #define dm_target_bio_based(t) ((t)->type->map != NULL) | ||
95 | |||
96 | /* | ||
92 | * To check whether the target type is request-based or not (bio-based). | 97 | * To check whether the target type is request-based or not (bio-based). |
93 | */ | 98 | */ |
94 | #define dm_target_request_based(t) ((t)->type->map_rq != NULL) | 99 | #define dm_target_request_based(t) ((t)->type->map_rq != NULL) |
95 | 100 | ||
101 | /* | ||
102 | * To check whether the target type is a hybrid (capable of being | ||
103 | * either request-based or bio-based). | ||
104 | */ | ||
105 | #define dm_target_hybrid(t) (dm_target_bio_based(t) && dm_target_request_based(t)) | ||
106 | |||
96 | /*----------------------------------------------------------------- | 107 | /*----------------------------------------------------------------- |
97 | * A registry of target types. | 108 | * A registry of target types. |
98 | *---------------------------------------------------------------*/ | 109 | *---------------------------------------------------------------*/ |