aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlasdair G Kergon <agk@redhat.com>2011-10-31 16:19:02 -0400
committerAlasdair G Kergon <agk@redhat.com>2011-10-31 16:19:02 -0400
commitcc6cbe141a20f6d876b161b60af38d93935bfa85 (patch)
tree82fbbc48815503683b434c74b7eb18c15960f4f9
parent3791e2fc0e4b40d4188e79b0a99bfa6bce714a10 (diff)
dm table: add always writeable feature
Add a target feature flag DM_TARGET_ALWAYS_WRITEABLE to indicate that a target does not support read-only mode. The initial implementation of the thin provisioning target uses this. Signed-off-by: Alasdair G Kergon <agk@redhat.com>
-rw-r--r--drivers/md/dm-table.c6
-rw-r--r--include/linux/device-mapper.h7
2 files changed, 13 insertions, 0 deletions
diff --git a/drivers/md/dm-table.c b/drivers/md/dm-table.c
index 2ec3482e942a..9917141729ef 100644
--- a/drivers/md/dm-table.c
+++ b/drivers/md/dm-table.c
@@ -774,6 +774,12 @@ int dm_table_add_target(struct dm_table *t, const char *type,
774 t->singleton = 1; 774 t->singleton = 1;
775 } 775 }
776 776
777 if (dm_target_always_writeable(tgt->type) && !(t->mode & FMODE_WRITE)) {
778 DMERR("%s: target type %s may not be included in read-only tables",
779 dm_device_name(t->md), type);
780 return -EINVAL;
781 }
782
777 tgt->table = t; 783 tgt->table = t;
778 tgt->begin = start; 784 tgt->begin = start;
779 tgt->len = len; 785 tgt->len = len;
diff --git a/include/linux/device-mapper.h b/include/linux/device-mapper.h
index 294e78a7fccd..cc58e2d7c032 100644
--- a/include/linux/device-mapper.h
+++ b/include/linux/device-mapper.h
@@ -166,6 +166,13 @@ struct target_type {
166#define DM_TARGET_SINGLETON 0x00000001 166#define DM_TARGET_SINGLETON 0x00000001
167#define dm_target_needs_singleton(type) ((type)->features & DM_TARGET_SINGLETON) 167#define dm_target_needs_singleton(type) ((type)->features & DM_TARGET_SINGLETON)
168 168
169/*
170 * Indicates that a target does not support read-only devices.
171 */
172#define DM_TARGET_ALWAYS_WRITEABLE 0x00000002
173#define dm_target_always_writeable(type) \
174 ((type)->features & DM_TARGET_ALWAYS_WRITEABLE)
175
169struct dm_target { 176struct dm_target {
170 struct dm_table *table; 177 struct dm_table *table;
171 struct target_type *type; 178 struct target_type *type;