Skip to content

Commit

Permalink
dm table: add always writeable feature
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
kergon committed Oct 31, 2011
1 parent 3791e2f commit cc6cbe1
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
6 changes: 6 additions & 0 deletions drivers/md/dm-table.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
7 changes: 7 additions & 0 deletions include/linux/device-mapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,13 @@ struct target_type {
#define DM_TARGET_SINGLETON 0x00000001
#define dm_target_needs_singleton(type) ((type)->features & DM_TARGET_SINGLETON)

/*
* Indicates that a target does not support read-only devices.
*/
#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;
Expand Down

0 comments on commit cc6cbe1

Please sign in to comment.