summaryrefslogtreecommitdiff
path: root/drivers/md
diff options
context:
space:
mode:
authorAlasdair G Kergon <agk@redhat.com>2011-11-01 00:19:00 +0400
committerAlasdair G Kergon <agk@redhat.com>2011-11-01 00:19:00 +0400
commit3791e2fc0e4b40d4188e79b0a99bfa6bce714a10 (patch)
tree2dc67f0593e1cb1f3dc07ff9883a03fe9edb4b2a /drivers/md
parent7f06965390e4a10fb6906c886324bfd0a96961be (diff)
downloadlinux-3791e2fc0e4b40d4188e79b0a99bfa6bce714a10.tar.xz
dm table: add singleton feature
Introduce the concept of a singleton table which contains exactly one target. If a target type sets the DM_TARGET_SINGLETON feature bit device-mapper will ensure that any table that includes that target contains no others. The thin provisioning pool target uses this. Signed-off-by: Alasdair G Kergon <agk@redhat.com>
Diffstat (limited to 'drivers/md')
-rw-r--r--drivers/md/dm-table.c16
1 files changed, 16 insertions, 0 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 {
struct dm_target *targets;
unsigned integrity_supported:1;
+ unsigned singleton:1;
/*
* Indicates the rw permissions for the new logical
@@ -740,6 +741,12 @@ int dm_table_add_target(struct dm_table *t, const char *type,
char **argv;
struct dm_target *tgt;
+ if (t->singleton) {
+ DMERR("%s: target type %s must appear alone in table",
+ dm_device_name(t->md), t->targets->type->name);
+ return -EINVAL;
+ }
+
if ((r = check_space(t)))
return r;
@@ -758,6 +765,15 @@ int dm_table_add_target(struct dm_table *t, const char *type,
return -EINVAL;
}
+ if (dm_target_needs_singleton(tgt->type)) {
+ if (t->num_targets) {
+ DMERR("%s: target type %s must appear alone in table",
+ dm_device_name(t->md), type);
+ return -EINVAL;
+ }
+ t->singleton = 1;
+ }
+
tgt->table = t;
tgt->begin = start;
tgt->len = len;