mirror of
git://sourceware.org/git/lvm2.git
synced 2024-10-27 18:55:19 +03:00
Add vg_set_alloc_policy() liblvm function and move vgchange logic inside.
NOTE: vg_set_alloc_policy() returns success if you try to set a value that is already stored. The behavior of vgchange is the same though - it fails. There is a fixme noted in the code about this inconsistency, which should be resolved if possible. Signed-off-by: Dave Wysochanski <dwysocha@redhat.com>
This commit is contained in:
parent
dba458ae9a
commit
5d623bde94
@ -437,6 +437,7 @@ int vg_extend(struct volume_group *vg, int pv_count, char **pv_names);
|
||||
int vg_set_extent_size(vg_t *vg, uint32_t new_extent_size);
|
||||
int vg_set_max_lv(vg_t *vg, uint32_t max_lv);
|
||||
int vg_set_max_pv(vg_t *vg, uint32_t max_pv);
|
||||
int vg_set_alloc_policy(vg_t *vg, alloc_policy_t alloc);
|
||||
int vg_split_mdas(struct cmd_context *cmd, struct volume_group *vg_from,
|
||||
struct volume_group *vg_to);
|
||||
|
||||
|
@ -829,6 +829,24 @@ int vg_set_max_pv(vg_t *vg, uint32_t max_pv)
|
||||
return 1;
|
||||
}
|
||||
|
||||
int vg_set_alloc_policy(vg_t *vg, alloc_policy_t alloc)
|
||||
{
|
||||
if (alloc == ALLOC_INHERIT) {
|
||||
log_error("Volume Group allocation policy cannot inherit "
|
||||
"from anything");
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (alloc == vg->alloc) {
|
||||
log_print("Volume group allocation policy is already %s",
|
||||
get_alloc_string(vg->alloc));
|
||||
return 1;
|
||||
}
|
||||
vg->alloc = alloc;
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Separate metadata areas after splitting a VG.
|
||||
* Also accepts orphan VG as destination (for vgreduce).
|
||||
|
@ -179,23 +179,18 @@ static int _vgchange_alloc(struct cmd_context *cmd, struct volume_group *vg)
|
||||
|
||||
alloc = arg_uint_value(cmd, alloc_ARG, ALLOC_NORMAL);
|
||||
|
||||
if (alloc == ALLOC_INHERIT) {
|
||||
log_error("Volume Group allocation policy cannot inherit "
|
||||
"from anything");
|
||||
return EINVALID_CMD_LINE;
|
||||
}
|
||||
if (!archive(vg))
|
||||
return ECMD_FAILED;
|
||||
|
||||
/* FIXME: make consistent with vg_set_alloc_policy() */
|
||||
if (alloc == vg->alloc) {
|
||||
log_error("Volume group allocation policy is already %s",
|
||||
get_alloc_string(vg->alloc));
|
||||
return ECMD_FAILED;
|
||||
}
|
||||
|
||||
if (!archive(vg))
|
||||
if (!vg_set_alloc_policy(vg, alloc))
|
||||
return ECMD_FAILED;
|
||||
|
||||
vg->alloc = alloc;
|
||||
|
||||
if (!vg_write(vg) || !vg_commit(vg))
|
||||
return ECMD_FAILED;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user