return_0;
/* Replace the empty layer with error segment */
- segtype = get_segtype_from_string(lv->vg->cmd, "error");
+ if (!(segtype = get_segtype_from_string(lv->vg->cmd, "error")))
+ return_0;
if (!lv_add_virtual_segment(layer_lv, 0, parent->le_count, segtype, NULL))
return_0;
uint64_t status,
const char *layer_suffix)
{
- static char _suffixes[][8] = { "_tdata", "_cdata", "_corig" };
+ static const char _suffixes[][8] = { "_tdata", "_cdata", "_corig" };
int r;
char *name;
size_t len;
/* Remove the temporary tags */
dm_list_iterate_items(sl, &lv_where->tags)
str_list_del(&layer_lv->tags, sl->str);
-
}
log_very_verbose("Inserting layer %s for %s",
lv_names.old = lv_where->name;
lv_names.new = layer_lv->name;
if (!for_each_sub_lv(layer_lv, _rename_cb, (void *) &lv_names))
- return 0;
+ return_NULL;
break;
}
}
if (lp->stripe_size > vg->extent_size) {
- if (segtype_is_raid(lp->segtype) &&
- (vg->extent_size < STRIPE_SIZE_MIN)) {
+ if (seg_is_raid(lp) && (vg->extent_size < STRIPE_SIZE_MIN)) {
/*
* FIXME: RAID will simply fail to load the table if
* this is the case, but we should probably
if (seg_is_cache(lp)) {
if (!lp->pool_name) {
- log_error(INTERNAL_ERROR "Cannot create cached volume without cache pool.");
- return NULL;
+ log_error(INTERNAL_ERROR "Cannot create thin volume without thin pool.");
+ return NULL;
}
- /* We have the cache_pool, create the origin with cache */
if (!(pool_lv = find_lv(vg, lp->pool_name))) {
- log_error("Couldn't find cache pool volume %s in "
- "volume group %s.", lp->pool_name, vg->name);
+ log_error("Couldn't find volume %s in Volume group %s.",
+ lp->pool_name, vg->name);
return NULL;
}
return NULL;
}
if (lv_is_locked(origin_lv)) {
- log_error("Snapshots of locked devices are not "
- "supported yet");
+ log_error("Snapshots of locked devices are not supported.");
return NULL;
}
if (lv_is_merging_origin(origin_lv)) {
return_NULL;
if (lp->read_ahead != lv->read_ahead) {
- log_verbose("Setting read ahead sectors");
lv->read_ahead = lp->read_ahead;
+ log_debug_metadata("Setting read ahead sectors %u.", lv->read_ahead);
}
if (!seg_is_thin_pool(lp) && lp->minor >= 0) {
lv->major = lp->major;
lv->minor = lp->minor;
lv->status |= FIXED_MINOR;
- log_verbose("Setting device number to (%d, %d)", lv->major,
- lv->minor);
+ log_debug_metadata("Setting device number to (%d, %d).",
+ lv->major, lv->minor);
}
dm_list_splice(&lv->tags, &lp->tags);
* it just as if CHANGE_AY was used, CHANGE_AN otherwise.
*/
if (lp->activate == CHANGE_AAY)
- lp->activate = lv_passes_auto_activation_filter(cmd, lv) ?
- CHANGE_ALY : CHANGE_ALN;
+ lp->activate = lv_passes_auto_activation_filter(cmd, lv)
+ ? CHANGE_ALY : CHANGE_ALN;
if (lv_activation_skip(lv, lp->activate, lp->activation_skip & ACTIVATION_SKIP_IGNORE))
lp->activate = CHANGE_AN;
.yes = lp->yes,
.force = lp->force
})) {
- log_error("Aborting. Failed to wipe %s.",
- lp->snapshot ? "snapshot exception store" :
- "start of new LV");
+ log_error("Aborting. Failed to wipe %s.", lp->snapshot
+ ? "snapshot exception store" : "start of new LV");
goto deactivate_and_revert_new_lv;
}
}
if ((vg_is_clustered(vg) ||
(!lp->voriginsize && !lv_is_active(origin_lv))) &&
!deactivate_lv(cmd, lv)) {
- log_error("Aborting. Couldn't deactivate snapshot "
- "COW area. Manual intervention required.");
+ log_error("Aborting. Couldn't deactivate snapshot COW area. "
+ "Manual intervention required.");
return NULL;
}
/* store vg on disk(s) */
if (!lv_update_and_reload(origin_lv))
- return_0;
+ return_NULL;
}
-
out:
return lv;
extents = percent_of_extents(lp->extents, vg->extent_count, 0);
break;
case PERCENT_LV:
- log_error("Please express size as %s%%VG, %%PVS, "
- "or %%FREE.", (lp->snapshot) ? "%ORIGIN, " : "");
+ log_error("Please express size as %%FREE%s, %%PVS or %%VG.",
+ (lp->snapshot) ? ", %ORIGIN" : "");
return 0;
case PERCENT_ORIGIN:
if (lp->snapshot && lp->origin_name &&
/*
* RAID1 does not take a stripe arg
*/
- if ((lp->stripes > 1) &&
- segtype_is_mirrored(lp->segtype) &&
+ if ((lp->stripes > 1) && seg_is_mirrored(lp) &&
strcmp(lp->segtype->name, SEG_TYPE_NAME_RAID10)) {
log_error("Stripe argument cannot be used with segment type, %s",
lp->segtype->name);
{
const char *cachemode;
- if (!segtype_is_cache_pool(lp->segtype))
+ if (!seg_is_cache(lp) && !seg_is_cache_pool(lp))
return 1;
- cachemode = arg_str_value(cmd, cachemode_ARG, NULL);
- if (!cachemode)
+ if (!(cachemode = arg_str_value(cmd, cachemode_ARG, NULL)))
cachemode = find_config_tree_str(cmd, allocation_cache_pool_cachemode_CFG, NULL);
if (!get_cache_mode(cachemode, &lp->feature_flags))
lp->zero = 0;
}
- /*
- * Read ahead.
- */
+ /* Read ahead */
lp->read_ahead = arg_uint_value(cmd, readahead_ARG,
cmd->default_settings.read_ahead);
pagesize = lvm_getpagesize() >> SECTOR_SHIFT;
"of %uK page size.", lp->read_ahead, pagesize >> 1);
}
- /*
- * Permissions.
- */
+ /* Permissions */
lp->permission = arg_uint_value(cmd, permission_ARG,
LVM_READ | LVM_WRITE);
if (!get_and_validate_major_minor(cmd, vg->fid->fmt,
&lp->major, &lp->minor))
- return_0;
+ return_0;
} else if (arg_is_set(cmd, major_ARG) || arg_is_set(cmd, minor_ARG)) {
log_error("--major and --minor require -My.");
return 0;
* Allocation parameters
*/
contiguous = arg_int_value(cmd, contiguous_ARG, 0);
-
lp->alloc = contiguous ? ALLOC_CONTIGUOUS : ALLOC_INHERIT;
-
lp->alloc = (alloc_policy_t) arg_uint_value(cmd, alloc_ARG, lp->alloc);
if (contiguous && (lp->alloc != ALLOC_CONTIGUOUS)) {
- log_error("Conflicting contiguous and alloc arguments");
+ log_error("Conflicting contiguous and alloc arguments.");
return 0;
}
continue;
if (!(tag = grouped_arg_str_value(current_group->arg_values, addtag_ARG, NULL))) {
- log_error("Failed to get tag");
+ log_error("Failed to get tag.");
return 0;
}
if (!str_list_add(cmd->mem, &lp->tags, tag)) {
- log_error("Unable to allocate memory for tag %s", tag);
+ log_error("Unable to allocate memory for tag %s.", tag);
return 0;
}
}