]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
Add a target feature flag to indicate that a target does not work in
authorAlasdair G Kergon <agk@redhat.com>
Mon, 25 Jul 2011 00:50:00 +0000 (10:50 +1000)
committerStephen Rothwell <sfr@canb.auug.org.au>
Mon, 25 Jul 2011 00:50:00 +0000 (10:50 +1000)
read-only mode.

The thin provisioning target will use this.

Signed-off-by: Alasdair G Kergon <agk@redhat.com>
drivers/md/dm-table.c
include/linux/device-mapper.h

index 43ae635409ca7099dffd79366a5314974d24c8f8..5e8e2f3af9cdf077d4b91d1706db962ce7d06acd 100644 (file)
@@ -774,6 +774,12 @@ int dm_table_add_target(struct dm_table *t, const char *type,
                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 310d0a65d12e29c489fb5fa3d2737a10427bfcc8..ade1e695ad7970f41efba4cb9f022ce3f2c0ac7b 100644 (file)
@@ -165,6 +165,10 @@ struct target_type {
 #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;