1
0
mirror of git://sourceware.org/git/lvm2.git synced 2024-12-21 13:34:40 +03:00

segtype: add SEG_ONLY_EXCLUSIVE flag

Mark segtypes which do require exclusive activation in cluster.r
This commit is contained in:
Zdenek Kabelac 2014-11-10 18:44:37 +01:00
parent 0dc73f7dbd
commit e2c4a3ef67
6 changed files with 18 additions and 11 deletions

View File

@ -390,7 +390,7 @@ int init_cache_segtypes(struct cmd_context *cmd,
} }
segtype->name = "cache-pool"; segtype->name = "cache-pool";
segtype->flags = SEG_CACHE_POOL | SEG_CANNOT_BE_ZEROED; segtype->flags = SEG_CACHE_POOL | SEG_CANNOT_BE_ZEROED | SEG_ONLY_EXCLUSIVE;
segtype->ops = &_cache_pool_ops; segtype->ops = &_cache_pool_ops;
if (!lvm_register_segtype(seglib, segtype)) if (!lvm_register_segtype(seglib, segtype))
@ -404,7 +404,7 @@ int init_cache_segtypes(struct cmd_context *cmd,
} }
segtype->name = "cache"; segtype->name = "cache";
segtype->flags = SEG_CACHE; segtype->flags = SEG_CACHE | SEG_ONLY_EXCLUSIVE;
segtype->ops = &_cache_ops; segtype->ops = &_cache_ops;
if (!lvm_register_segtype(seglib, segtype)) if (!lvm_register_segtype(seglib, segtype))

View File

@ -858,11 +858,16 @@ char *lv_host_dup(struct dm_pool *mem, const struct logical_volume *lv)
static int _lv_is_exclusive(struct logical_volume *lv) static int _lv_is_exclusive(struct logical_volume *lv)
{ {
/* Some devices require exlusiveness */ struct lv_segment *seg;
return lv_is_raid(lv) ||
lv_is_origin(lv) || /* Some seg types require exclusive activation */
lv_is_thin_type(lv) || /* TODO: deep-scan of every segtype in use */
lv_is_cache_type(lv); dm_list_iterate_items(seg, &lv->segments)
if (seg_only_exclusive(seg))
return 1;
/* Origin has no seg type require exlusiveness */
return lv_is_origin(lv);
} }
int lv_active_change(struct cmd_context *cmd, struct logical_volume *lv, int lv_active_change(struct cmd_context *cmd, struct logical_volume *lv,

View File

@ -44,6 +44,7 @@ struct dev_manager;
#define SEG_CACHE 0x00002000U #define SEG_CACHE 0x00002000U
#define SEG_CACHE_POOL 0x00004000U #define SEG_CACHE_POOL 0x00004000U
#define SEG_MIRROR 0x00008000U #define SEG_MIRROR 0x00008000U
#define SEG_ONLY_EXCLUSIVE 0x00010000U /* In cluster only exlusive activation */
#define SEG_UNKNOWN 0x80000000U #define SEG_UNKNOWN 0x80000000U
#define segtype_is_cache(segtype) ((segtype)->flags & SEG_CACHE ? 1 : 0) #define segtype_is_cache(segtype) ((segtype)->flags & SEG_CACHE ? 1 : 0)
@ -78,6 +79,7 @@ struct dev_manager;
#define seg_can_split(seg) ((seg)->segtype->flags & SEG_CAN_SPLIT ? 1 : 0) #define seg_can_split(seg) ((seg)->segtype->flags & SEG_CAN_SPLIT ? 1 : 0)
#define seg_cannot_be_zeroed(seg) ((seg)->segtype->flags & SEG_CANNOT_BE_ZEROED ? 1 : 0) #define seg_cannot_be_zeroed(seg) ((seg)->segtype->flags & SEG_CANNOT_BE_ZEROED ? 1 : 0)
#define seg_monitored(seg) ((seg)->segtype->flags & SEG_MONITORED ? 1 : 0) #define seg_monitored(seg) ((seg)->segtype->flags & SEG_MONITORED ? 1 : 0)
#define seg_only_exclusive(seg) ((seg)->segtype->flags & SEG_ONLY_EXCLUSIVE ? 1 : 0)
struct segment_type { struct segment_type {
struct dm_list list; /* Internal */ struct dm_list list; /* Internal */

View File

@ -465,7 +465,7 @@ static struct segment_type *_init_raid_segtype(struct cmd_context *cmd,
segtype->ops = &_raid_ops; segtype->ops = &_raid_ops;
segtype->name = rt->name; segtype->name = rt->name;
segtype->flags = SEG_RAID | rt->extra_flags | monitored; segtype->flags = SEG_RAID | SEG_ONLY_EXCLUSIVE | rt->extra_flags | monitored;
segtype->parity_devs = rt->parity; segtype->parity_devs = rt->parity;
log_very_verbose("Initialised segtype: %s", segtype->name); log_very_verbose("Initialised segtype: %s", segtype->name);

View File

@ -260,7 +260,7 @@ struct segment_type *init_segtype(struct cmd_context *cmd)
segtype->ops = &_snapshot_ops; segtype->ops = &_snapshot_ops;
segtype->name = "snapshot"; segtype->name = "snapshot";
segtype->flags = SEG_SNAPSHOT | SEG_CANNOT_BE_ZEROED; segtype->flags = SEG_SNAPSHOT | SEG_CANNOT_BE_ZEROED | SEG_ONLY_EXCLUSIVE;
#ifdef DEVMAPPER_SUPPORT #ifdef DEVMAPPER_SUPPORT
# ifdef DMEVENTD # ifdef DMEVENTD

View File

@ -753,9 +753,9 @@ int init_multiple_segtypes(struct cmd_context *cmd, struct segtype_library *segl
const char name[16]; const char name[16];
uint32_t flags; uint32_t flags;
} reg_segtypes[] = { } reg_segtypes[] = {
{ &_thin_pool_ops, "thin-pool", SEG_THIN_POOL | SEG_CANNOT_BE_ZEROED }, { &_thin_pool_ops, "thin-pool", SEG_THIN_POOL | SEG_CANNOT_BE_ZEROED | SEG_ONLY_EXCLUSIVE },
/* FIXME Maybe use SEG_THIN_VOLUME instead of SEG_VIRTUAL */ /* FIXME Maybe use SEG_THIN_VOLUME instead of SEG_VIRTUAL */
{ &_thin_ops, "thin", SEG_THIN_VOLUME | SEG_VIRTUAL } { &_thin_ops, "thin", SEG_THIN_VOLUME | SEG_VIRTUAL | SEG_ONLY_EXCLUSIVE }
}; };
struct segment_type *segtype; struct segment_type *segtype;