1
0
mirror of git://sourceware.org/git/lvm2.git synced 2025-03-10 16:58:47 +03:00

thin: move alloc_pool_metadata

Move function from /tool to /lib to thin_manip.c
Since lvm2api will need to move many things into /lib anyway.
This commit is contained in:
Zdenek Kabelac 2013-07-04 11:04:05 +02:00
parent f884970797
commit f88f5a1ca3
5 changed files with 50 additions and 53 deletions

View File

@ -657,6 +657,11 @@ int update_pool_params(struct cmd_context *cmd, unsigned attr, int passed_args,
uint64_t *pool_metadata_size);
int get_pool_discards(const char *str, thin_discards_t *discards);
const char *get_pool_discards_name(thin_discards_t discards);
struct logical_volume *alloc_pool_metadata(struct logical_volume *pool_lv,
const char *name, uint32_t read_ahead,
uint32_t stripes, uint32_t stripe_size,
uint64_t size, alloc_policy_t alloc,
struct dm_list *pvh);
/*
* Activation options

View File

@ -681,3 +681,43 @@ const char *get_pool_discards_name(thin_discards_t discards)
return "unknown";
}
struct logical_volume *alloc_pool_metadata(struct logical_volume *pool_lv,
const char *name, uint32_t read_ahead,
uint32_t stripes, uint32_t stripe_size,
uint64_t size, alloc_policy_t alloc,
struct dm_list *pvh)
{
struct logical_volume *metadata_lv;
/* FIXME: Make lvm2api usable */
struct lvcreate_params lvc = {
.activate = CHANGE_ALY,
.alloc = alloc,
.lv_name = name,
.major = -1,
.minor = -1,
.permission = LVM_READ | LVM_WRITE,
.pvh = pvh,
.read_ahead = read_ahead,
.stripe_size = stripe_size,
.stripes = stripes,
.vg_name = pool_lv->vg->name,
.zero = 1,
};
dm_list_init(&lvc.tags);
if (!(lvc.extents = extents_from_size(pool_lv->vg->cmd, size,
pool_lv->vg->extent_size)))
return_0;
if (!(lvc.segtype = get_segtype_from_string(pool_lv->vg->cmd, "striped")))
return_0;
/* FIXME: allocate properly space for metadata_lv */
if (!(metadata_lv = lv_create_single(pool_lv->vg, &lvc)))
return_0;
return metadata_lv;
}

View File

@ -2145,10 +2145,11 @@ static int _lvconvert_thinpool(struct cmd_context *cmd,
if (!get_stripe_params(cmd, &lp->stripes, &lp->stripe_size))
return_0;
if (!(metadata_lv = alloc_pool_metadata(pool_lv, lp->alloc, metadata_name,
lp->pvh, lp->read_ahead,
lp->stripes, lp->stripe_size,
lp->poolmetadata_size)))
if (!(metadata_lv = alloc_pool_metadata(pool_lv, metadata_name,
lp->read_ahead, lp->stripes,
lp->stripe_size,
lp->poolmetadata_size,
lp->alloc, lp->pvh)))
return_0;
}

View File

@ -1601,50 +1601,6 @@ int get_pool_params(struct cmd_context *cmd,
return 1;
}
struct logical_volume *alloc_pool_metadata(struct logical_volume *pool_lv,
alloc_policy_t alloc,
const char *name,
struct dm_list *pvh,
uint32_t read_ahead,
uint32_t stripes,
uint32_t stripe_size,
uint64_t size)
{
struct logical_volume *metadata_lv;
struct lvcreate_params lvc;
/* FIXME: Make lvm2api usable */
memset(&lvc, 0, sizeof(lvc));
if (!(lvc.extents = extents_from_size(pool_lv->vg->cmd, size,
pool_lv->vg->extent_size)))
return_0;
if (!(lvc.segtype = get_segtype_from_string(pool_lv->vg->cmd, "striped")))
return_0;
dm_list_init(&lvc.tags);
/* FIXME: allocate properly space for metadata_lv */
lvc.activate = CHANGE_ALY;
lvc.alloc = alloc;
lvc.lv_name = name;
lvc.major = -1;
lvc.minor = -1;
lvc.permission = LVM_READ | LVM_WRITE;
lvc.pvh = pvh;
lvc.read_ahead = read_ahead;
lvc.stripe_size = stripe_size;
lvc.stripes = stripes;
lvc.vg_name = pool_lv->vg->name;
lvc.zero = 1;
if (!(metadata_lv = lv_create_single(pool_lv->vg, &lvc)))
return_0;
return metadata_lv;
}
/*
* Generic stripe parameter checks.
*/

View File

@ -122,11 +122,6 @@ int get_pool_params(struct cmd_context *cmd,
uint64_t *pool_metadata_size,
int *zero);
struct logical_volume *alloc_pool_metadata(struct logical_volume *pool_lv,
alloc_policy_t alloc, const char *name,
struct dm_list *pvh, uint32_t read_ahead,
uint32_t stripes, uint32_t stripe_size,
uint64_t size);
int get_stripe_params(struct cmd_context *cmd, uint32_t *stripes,
uint32_t *stripe_size);