From: Alasdair G Kergon Date: Thu, 4 Aug 2011 00:24:36 +0000 (+1000) Subject: Add a target feature flag to indicate that a target does not work in X-Git-Tag: next-20110804~24^2~3 X-Git-Url: https://git.karo-electronics.de/?a=commitdiff_plain;h=3348a38759322af14d5c4a4ed8ccaa11c552c3e8;p=karo-tx-linux.git Add a target feature flag to indicate that a target does not work in read-only mode. The thin provisioning target uses this. Signed-off-by: Alasdair G Kergon --- diff --git a/drivers/md/dm-table.c b/drivers/md/dm-table.c index 26aef82a88d8..443d31a1f196 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, 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; diff --git a/include/linux/device-mapper.h b/include/linux/device-mapper.h index 310d0a65d12e..ade1e695ad79 100644 --- a/include/linux/device-mapper.h +++ b/include/linux/device-mapper.h @@ -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;