1
0
mirror of git://sourceware.org/git/lvm2.git synced 2025-01-18 10:04:20 +03:00

cleanup: ignore vg_name in /lib

Since  vg_name inside /lib function has already been ignored mostly
except for a few debug prints - make it and official internal API
feature.

vg_name is used only in  /tools while the VG is not yet openned,
and when  lvresize/lvcreate /lib function is called with VG pointer
already being used, then vg_name becomes irrelevant (it's not been
validated anyway).

So any internal user of lvcreate_params and lvresize_params does not
need to set vg_name pointer and may leave it NULL.
This commit is contained in:
Zdenek Kabelac 2014-06-30 12:02:05 +02:00
parent 667f93b7d9
commit 13fb02ff1f
5 changed files with 17 additions and 24 deletions

View File

@ -3658,8 +3658,8 @@ static int _fsadm_cmd(struct cmd_context *cmd,
if (status) if (status)
*status = -1; *status = -1;
if (dm_snprintf(lv_path, PATH_MAX, "%s%s/%s", cmd->dev_dir, lp->vg_name, if (dm_snprintf(lv_path, sizeof(lv_path), "%s%s/%s", cmd->dev_dir,
lp->lv_name) < 0) { vg->name, lp->lv_name) < 0) {
log_error("Couldn't create LV path for %s", lp->lv_name); log_error("Couldn't create LV path for %s", lp->lv_name);
return 0; return 0;
} }
@ -3667,7 +3667,7 @@ static int _fsadm_cmd(struct cmd_context *cmd,
argv[i++] = lv_path; argv[i++] = lv_path;
if (fcmd == FSADM_CMD_RESIZE) { if (fcmd == FSADM_CMD_RESIZE) {
if (dm_snprintf(size_buf, SIZE_BUF, "%" PRIu64 "K", if (dm_snprintf(size_buf, sizeof(size_buf), "%" PRIu64 "K",
(uint64_t) lp->extents * (vg->extent_size / 2)) < 0) { (uint64_t) lp->extents * (vg->extent_size / 2)) < 0) {
log_error("Couldn't generate new LV size string"); log_error("Couldn't generate new LV size string");
return 0; return 0;
@ -3713,7 +3713,7 @@ static int _adjust_policy_params(struct cmd_context *cmd,
(percent > policy_threshold)) { (percent > policy_threshold)) {
if (!thin_pool_feature_supported(lv, THIN_FEATURE_METADATA_RESIZE)) { if (!thin_pool_feature_supported(lv, THIN_FEATURE_METADATA_RESIZE)) {
log_error_once("Online metadata resize for %s/%s is not supported.", log_error_once("Online metadata resize for %s/%s is not supported.",
lp->vg_name, lp->lv_name); lv->vg->name, lv->name);
return 0; return 0;
} }
lp->poolmetadatasize = (first_seg(lv)->metadata_lv->size * lp->poolmetadatasize = (first_seg(lv)->metadata_lv->size *
@ -6015,7 +6015,7 @@ static struct logical_volume *_lv_create_an_lv(struct volume_group *vg,
if (new_lv_name && find_lv_in_vg(vg, new_lv_name)) { if (new_lv_name && find_lv_in_vg(vg, new_lv_name)) {
log_error("Logical volume \"%s\" already exists in " log_error("Logical volume \"%s\" already exists in "
"volume group \"%s\"", new_lv_name, lp->vg_name); "volume group \"%s\"", new_lv_name, vg->name);
return NULL; return NULL;
} }

View File

@ -473,7 +473,7 @@ struct pvcreate_params {
}; };
struct lvresize_params { struct lvresize_params {
const char *vg_name; const char *vg_name; /* only-used when VG is not yet opened (in /tools) */
const char *lv_name; const char *lv_name;
uint32_t stripes; uint32_t stripes;
@ -782,7 +782,7 @@ struct lvcreate_params {
const char *origin; /* snap */ const char *origin; /* snap */
const char *pool; /* thin */ const char *pool; /* thin */
const char *vg_name; /* all */ const char *vg_name; /* only-used when VG is not yet opened (in /tools) */
const char *lv_name; /* all */ const char *lv_name; /* all */
/* Keep args given by the user on command line */ /* Keep args given by the user on command line */

View File

@ -559,7 +559,6 @@ struct logical_volume *alloc_pool_metadata(struct logical_volume *pool_lv,
.read_ahead = read_ahead, .read_ahead = read_ahead,
.stripe_size = stripe_size, .stripe_size = stripe_size,
.stripes = stripes, .stripes = stripes,
.vg_name = pool_lv->vg->name,
.zero = 1, .zero = 1,
}; };
@ -600,7 +599,6 @@ static struct logical_volume *_alloc_pool_metadata_spare(struct volume_group *vg
.pvh = pvh ? : &vg->pvs, .pvh = pvh ? : &vg->pvs,
.read_ahead = DM_READ_AHEAD_AUTO, .read_ahead = DM_READ_AHEAD_AUTO,
.stripes = 1, .stripes = 1,
.vg_name = vg->name,
.zero = 1, .zero = 1,
.temporary = 1, .temporary = 1,
}; };

View File

@ -194,7 +194,6 @@ static void _lv_set_default_params(struct lvcreate_params *lp,
lp->major = -1; lp->major = -1;
lp->minor = -1; lp->minor = -1;
lp->activate = CHANGE_AY; lp->activate = CHANGE_AY;
lp->vg_name = vg->name;
lp->lv_name = lvname; /* FIXME: check this for safety */ lp->lv_name = lvname; /* FIXME: check this for safety */
lp->pvh = &vg->pvs; lp->pvh = &vg->pvs;
@ -458,19 +457,16 @@ int lvm_lv_rename(lv_t lv, const char *new_name)
int lvm_lv_resize(const lv_t lv, uint64_t new_size) int lvm_lv_resize(const lv_t lv, uint64_t new_size)
{ {
int rc = 0; int rc = 0;
struct lvresize_params lp = { 0 }; struct lvresize_params lp = {
struct saved_env e = { 0 }; .lv_name = lv->name,
.sign = SIGN_NONE,
lp.vg_name = lv->vg->name; .percent = PERCENT_NONE,
lp.lv_name = lv->name; .resize = LV_ANY,
lp.sign = SIGN_NONE; .size = new_size >> SECTOR_SHIFT,
lp.percent = PERCENT_NONE; .ac_force = 1, /* Assume the user has a good backup? */
lp.resize = LV_ANY; .sizeargs = 1,
lp.size = new_size >> SECTOR_SHIFT; };
lp.ac_force = 1; /* Assume the user has a good backup? */ struct saved_env e = store_user_env(lv->vg->cmd);
lp.sizeargs = 1;
e = store_user_env(lv->vg->cmd);
if (!lv_resize_prepare(lv->vg->cmd, lv, &lp, &lv->vg->pvs) || if (!lv_resize_prepare(lv->vg->cmd, lv, &lp, &lv->vg->pvs) ||
!lv_resize(lv->vg->cmd, lv, &lp, &lv->vg->pvs)) { !lv_resize(lv->vg->cmd, lv, &lp, &lv->vg->pvs)) {

View File

@ -2522,7 +2522,6 @@ static int _lvconvert_thinpool_external(struct cmd_context *cmd,
.pvh = &vg->pvs, .pvh = &vg->pvs,
.read_ahead = DM_READ_AHEAD_AUTO, .read_ahead = DM_READ_AHEAD_AUTO,
.stripes = 1, .stripes = 1,
.vg_name = vg->name,
.voriginextents = external_lv->le_count, .voriginextents = external_lv->le_count,
.voriginsize = external_lv->size, .voriginsize = external_lv->size,
}; };