aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/md/dm-table.c16
-rw-r--r--include/linux/device-mapper.h14
2 files changed, 26 insertions, 4 deletions
diff --git a/drivers/md/dm-table.c b/drivers/md/dm-table.c
index 81cbbf375bd7..2ec3482e942a 100644
--- a/drivers/md/dm-table.c
+++ b/drivers/md/dm-table.c
@@ -55,6 +55,7 @@ struct dm_table {
55 struct dm_target *targets; 55 struct dm_target *targets;
56 56
57 unsigned integrity_supported:1; 57 unsigned integrity_supported:1;
58 unsigned singleton:1;
58 59
59 /* 60 /*
60 * Indicates the rw permissions for the new logical 61 * Indicates the rw permissions for the new logical
@@ -740,6 +741,12 @@ int dm_table_add_target(struct dm_table *t, const char *type,
740 char **argv; 741 char **argv;
741 struct dm_target *tgt; 742 struct dm_target *tgt;
742 743
744 if (t->singleton) {
745 DMERR("%s: target type %s must appear alone in table",
746 dm_device_name(t->md), t->targets->type->name);
747 return -EINVAL;
748 }
749
743 if ((r = check_space(t))) 750 if ((r = check_space(t)))
744 return r; 751 return r;
745 752
@@ -758,6 +765,15 @@ int dm_table_add_target(struct dm_table *t, const char *type,
758 return -EINVAL; 765 return -EINVAL;
759 } 766 }
760 767
768 if (dm_target_needs_singleton(tgt->type)) {
769 if (t->num_targets) {
770 DMERR("%s: target type %s must appear alone in table",
771 dm_device_name(t->md), type);
772 return -EINVAL;
773 }
774 t->singleton = 1;
775 }
776
761 tgt->table = t; 777 tgt->table = t;
762 tgt->begin = start; 778 tgt->begin = start;
763 tgt->len = len; 779 tgt->len = len;
diff --git a/include/linux/device-mapper.h b/include/linux/device-mapper.h
index 622678ccb5e0..294e78a7fccd 100644
--- a/include/linux/device-mapper.h
+++ b/include/linux/device-mapper.h
@@ -128,10 +128,6 @@ void dm_put_device(struct dm_target *ti, struct dm_dev *d);
128 * Information about a target type 128 * Information about a target type
129 */ 129 */
130 130
131/*
132 * Target features
133 */
134
135struct target_type { 131struct target_type {
136 uint64_t features; 132 uint64_t features;
137 const char *name; 133 const char *name;
@@ -160,6 +156,16 @@ struct target_type {
160 struct list_head list; 156 struct list_head list;
161}; 157};
162 158
159/*
160 * Target features
161 */
162
163/*
164 * Any table that contains an instance of this target must have only one.
165 */
166#define DM_TARGET_SINGLETON 0x00000001
167#define dm_target_needs_singleton(type) ((type)->features & DM_TARGET_SINGLETON)
168
163struct dm_target { 169struct dm_target {
164 struct dm_table *table; 170 struct dm_table *table;
165 struct target_type *type; 171 struct target_type *type;