diff options
author | Mike Snitzer <snitzer@redhat.com> | 2013-08-22 18:21:38 -0400 |
---|---|---|
committer | Mike Snitzer <snitzer@redhat.com> | 2013-09-05 20:46:05 -0400 |
commit | 169e2cc279c443085f7e423561eb1fe6158ade44 (patch) | |
tree | 109acfea689865bb69e1c12a3ad36d34b8293429 /drivers/md/dm-table.c | |
parent | eb18cba78c2b9250663021e17e1e9cc34630e92a (diff) |
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 <snitzer@redhat.com>
Signed-off-by: Joe Jin <joe.jin@oracle.com>
Signed-off-by: Jun'ichi Nomura <j-nomura@ce.jp.nec.com>
Acked-by: Mikulas Patocka <mpatocka@redhat.com>
Signed-off-by: Alasdair G Kergon <agk@redhat.com>
Diffstat (limited to 'drivers/md/dm-table.c')
-rw-r--r-- | drivers/md/dm-table.c | 22 |
1 files changed, 20 insertions, 2 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; |