diff options
author | Alasdair G Kergon <agk@redhat.com> | 2011-10-31 16:19:00 -0400 |
---|---|---|
committer | Alasdair G Kergon <agk@redhat.com> | 2011-10-31 16:19:00 -0400 |
commit | 3791e2fc0e4b40d4188e79b0a99bfa6bce714a10 (patch) | |
tree | 2dc67f0593e1cb1f3dc07ff9883a03fe9edb4b2a /drivers/md | |
parent | 7f06965390e4a10fb6906c886324bfd0a96961be (diff) |
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.c | 16 |
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 { | |||
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; |