1
0
mirror of git://sourceware.org/git/lvm2.git synced 2024-12-04 08:17:12 +03:00

segtype: add linear

Add linear segtype addressing FIXME in preparation
for linear <-> striped convenience conversion support
This commit is contained in:
Heinz Mauelshagen 2018-05-30 12:44:24 +02:00
parent 2eda683a20
commit de66704253
4 changed files with 18 additions and 10 deletions

View File

@ -1462,6 +1462,7 @@ static int _init_segtypes(struct cmd_context *cmd)
struct segment_type *segtype;
struct segtype_library seglib = { .cmd = cmd, .lib = NULL };
struct segment_type *(*init_segtype_array[])(struct cmd_context *cmd) = {
init_linear_segtype,
init_striped_segtype,
init_zero_segtype,
init_error_segtype,

View File

@ -22,10 +22,6 @@ struct segment_type *get_segtype_from_string(struct cmd_context *cmd,
{
struct segment_type *segtype;
/* FIXME Register this properly within striped.c */
if (!strcmp(str, SEG_TYPE_NAME_LINEAR))
str = SEG_TYPE_NAME_STRIPED;
dm_list_iterate_items(segtype, &cmd->segtypes)
if (!strcmp(segtype->name, str))
return segtype;

View File

@ -68,6 +68,7 @@ struct dev_manager;
#define SEG_RAID6 SEG_RAID6_ZR
#define SEG_STRIPED_TARGET (1ULL << 39)
#define SEG_LINEAR_TARGET (1ULL << 40)
#define SEG_UNKNOWN (1ULL << 63)
@ -105,7 +106,7 @@ struct dev_manager;
#define SEG_TYPE_NAME_RAID6_RS_6 "raid6_rs_6"
#define SEG_TYPE_NAME_RAID6_N_6 "raid6_n_6"
#define segtype_is_linear(segtype) (!strcmp(segtype->name, SEG_TYPE_NAME_LINEAR))
#define segtype_is_linear(segtype) (!strcmp((segtype)->name, SEG_TYPE_NAME_LINEAR))
#define segtype_is_striped_target(segtype) ((segtype)->flags & SEG_STRIPED_TARGET ? 1 : 0)
#define segtype_is_cache(segtype) ((segtype)->flags & SEG_CACHE ? 1 : 0)
#define segtype_is_cache_pool(segtype) ((segtype)->flags & SEG_CACHE_POOL ? 1 : 0)
@ -274,6 +275,7 @@ struct segtype_library;
int lvm_register_segtype(struct segtype_library *seglib,
struct segment_type *segtype);
struct segment_type *init_linear_segtype(struct cmd_context *cmd);
struct segment_type *init_striped_segtype(struct cmd_context *cmd);
struct segment_type *init_zero_segtype(struct cmd_context *cmd);
struct segment_type *init_error_segtype(struct cmd_context *cmd);

View File

@ -230,7 +230,7 @@ static struct segtype_handler _striped_ops = {
.destroy = _striped_destroy,
};
struct segment_type *init_striped_segtype(struct cmd_context *cmd)
static struct segment_type *_init_segtype(struct cmd_context *cmd, const char *name, uint64_t target)
{
struct segment_type *segtype = dm_zalloc(sizeof(*segtype));
@ -238,11 +238,20 @@ struct segment_type *init_striped_segtype(struct cmd_context *cmd)
return_NULL;
segtype->ops = &_striped_ops;
segtype->name = SEG_TYPE_NAME_STRIPED;
segtype->flags = SEG_STRIPED_TARGET |
SEG_CAN_SPLIT | SEG_AREAS_STRIPED;
segtype->name = name;
segtype->flags = target | SEG_CAN_SPLIT | SEG_AREAS_STRIPED;
log_very_verbose("Initialised segtype: %s", segtype->name);
return segtype;
}
struct segment_type *init_striped_segtype(struct cmd_context *cmd)
{
return _init_segtype(cmd, SEG_TYPE_NAME_STRIPED, SEG_STRIPED_TARGET);
}
struct segment_type *init_linear_segtype(struct cmd_context *cmd)
{
return _init_segtype(cmd, SEG_TYPE_NAME_LINEAR, SEG_LINEAR_TARGET);
}