diff options
author | Alasdair G Kergon <agk@redhat.com> | 2011-10-31 16:19:04 -0400 |
---|---|---|
committer | Alasdair G Kergon <agk@redhat.com> | 2011-10-31 16:19:04 -0400 |
commit | 36a0456fbf2d9680bf9af81b39daf4a8e22cb1b8 (patch) | |
tree | a19af18640d538e8357c195e6b4c77d0f6c92391 /drivers/md/dm-table.c | |
parent | cc6cbe141a20f6d876b161b60af38d93935bfa85 (diff) |
dm table: add immutable feature
Introduce DM_TARGET_IMMUTABLE to indicate that the target type cannot be mixed
with any other target type, and once loaded into a device, it cannot be
replaced with a table containing a different type.
The thin provisioning pool device will use this.
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 | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/drivers/md/dm-table.c b/drivers/md/dm-table.c index 9917141729ef..8e9132130142 100644 --- a/drivers/md/dm-table.c +++ b/drivers/md/dm-table.c | |||
@@ -54,6 +54,7 @@ struct dm_table { | |||
54 | sector_t *highs; | 54 | sector_t *highs; |
55 | struct dm_target *targets; | 55 | struct dm_target *targets; |
56 | 56 | ||
57 | struct target_type *immutable_target_type; | ||
57 | unsigned integrity_supported:1; | 58 | unsigned integrity_supported:1; |
58 | unsigned singleton:1; | 59 | unsigned singleton:1; |
59 | 60 | ||
@@ -780,6 +781,21 @@ int dm_table_add_target(struct dm_table *t, const char *type, | |||
780 | return -EINVAL; | 781 | return -EINVAL; |
781 | } | 782 | } |
782 | 783 | ||
784 | if (t->immutable_target_type) { | ||
785 | if (t->immutable_target_type != tgt->type) { | ||
786 | DMERR("%s: immutable target type %s cannot be mixed with other target types", | ||
787 | dm_device_name(t->md), t->immutable_target_type->name); | ||
788 | return -EINVAL; | ||
789 | } | ||
790 | } else if (dm_target_is_immutable(tgt->type)) { | ||
791 | if (t->num_targets) { | ||
792 | DMERR("%s: immutable target type %s cannot be mixed with other target types", | ||
793 | dm_device_name(t->md), tgt->type->name); | ||
794 | return -EINVAL; | ||
795 | } | ||
796 | t->immutable_target_type = tgt->type; | ||
797 | } | ||
798 | |||
783 | tgt->table = t; | 799 | tgt->table = t; |
784 | tgt->begin = start; | 800 | tgt->begin = start; |
785 | tgt->len = len; | 801 | tgt->len = len; |
@@ -937,6 +953,11 @@ unsigned dm_table_get_type(struct dm_table *t) | |||
937 | return t->type; | 953 | return t->type; |
938 | } | 954 | } |
939 | 955 | ||
956 | struct target_type *dm_table_get_immutable_target_type(struct dm_table *t) | ||
957 | { | ||
958 | return t->immutable_target_type; | ||
959 | } | ||
960 | |||
940 | bool dm_table_request_based(struct dm_table *t) | 961 | bool dm_table_request_based(struct dm_table *t) |
941 | { | 962 | { |
942 | return dm_table_get_type(t) == DM_TYPE_REQUEST_BASED; | 963 | return dm_table_get_type(t) == DM_TYPE_REQUEST_BASED; |