From: Alasdair G Kergon <agk@redhat.com>

Add a target feature flag to indicate that a target does not work in
read-only mode.

Signed-off-by: Alasdair G Kergon <agk@redhat.com>
---
 drivers/md/dm-table.c         |    6 ++++++
 include/linux/device-mapper.h |    5 ++++-
 2 files changed, 10 insertions(+), 1 deletion(-)

Index: linux-3.0-rc7/drivers/md/dm-table.c
===================================================================
--- linux-3.0-rc7.orig/drivers/md/dm-table.c
+++ linux-3.0-rc7/drivers/md/dm-table.c
@@ -777,6 +777,12 @@ int dm_table_add_target(struct dm_table 
 		t->singleton = 1;
 	}
 
+	if (dm_target_always_writeable(tgt->type) && !(t->mode & FMODE_WRITE)) {
+		DMERR("%s: target type %s may not be included in read-only tables",
+		      dm_device_name(t->md), type);
+		return -EINVAL;
+	}
+
 	tgt->table = t;
 	tgt->begin = start;
 	tgt->len = len;
Index: linux-3.0-rc7/include/linux/device-mapper.h
===================================================================
--- linux-3.0-rc7.orig/include/linux/device-mapper.h
+++ linux-3.0-rc7/include/linux/device-mapper.h
@@ -162,9 +162,12 @@ struct target_type {
 /*
  * Any table that contains an instance of this target must have only one.
  */
-#define DM_TARGET_SINGLETON	0x00000001
+#define DM_TARGET_SINGLETON		0x00000001
 #define dm_target_needs_singleton(type)	((type)->features & DM_TARGET_SINGLETON)
 
+#define DM_TARGET_ALWAYS_WRITEABLE	0x00000002
+#define dm_target_always_writeable(type)	((type)->features & DM_TARGET_ALWAYS_WRITEABLE)
+
 struct dm_target {
 	struct dm_table *table;
 	struct target_type *type;
