mirror of
git://sourceware.org/git/lvm2.git
synced 2024-12-21 13:34:40 +03:00
Use stack return macros throughout.
This commit is contained in:
parent
962b2a559d
commit
c51b9fff19
@ -1,5 +1,6 @@
|
||||
Version 2.02.33 -
|
||||
===================================
|
||||
Use stack return macros throughout.
|
||||
Rely upon internally-cached PV labels while corresponding VG lock is held.
|
||||
|
||||
Version 2.02.32 - 29th January 2008
|
||||
|
@ -100,10 +100,8 @@ static struct dm_task *_setup_task(const char *name, const char *uuid,
|
||||
{
|
||||
struct dm_task *dmt;
|
||||
|
||||
if (!(dmt = dm_task_create(task))) {
|
||||
stack;
|
||||
return NULL;
|
||||
}
|
||||
if (!(dmt = dm_task_create(task)))
|
||||
return_NULL;
|
||||
|
||||
if (name)
|
||||
dm_task_set_name(dmt, name);
|
||||
@ -127,10 +125,8 @@ static int _info_run(const char *name, const char *dlid, struct dm_info *info,
|
||||
|
||||
dmtask = mknodes ? DM_DEVICE_MKNODES : DM_DEVICE_INFO;
|
||||
|
||||
if (!(dmt = _setup_task(name, dlid, 0, dmtask))) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
if (!(dmt = _setup_task(name, dlid, 0, dmtask)))
|
||||
return_0;
|
||||
|
||||
if (!with_open_count)
|
||||
if (!dm_task_no_open_count(dmt))
|
||||
@ -259,10 +255,8 @@ static int _status_run(const char *name, const char *uuid,
|
||||
char *type = NULL;
|
||||
char *params = NULL;
|
||||
|
||||
if (!(dmt = _setup_task(name, uuid, 0, DM_DEVICE_STATUS))) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
if (!(dmt = _setup_task(name, uuid, 0, DM_DEVICE_STATUS)))
|
||||
return_0;
|
||||
|
||||
if (!dm_task_no_open_count(dmt))
|
||||
log_error("Failed to disable open_count");
|
||||
@ -348,10 +342,8 @@ static int _percent_run(struct dev_manager *dm, const char *name,
|
||||
*percent = -1;
|
||||
|
||||
if (!(dmt = _setup_task(name, dlid, event_nr,
|
||||
wait ? DM_DEVICE_WAITEVENT : DM_DEVICE_STATUS))) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
wait ? DM_DEVICE_WAITEVENT : DM_DEVICE_STATUS)))
|
||||
return_0;
|
||||
|
||||
if (!dm_task_no_open_count(dmt))
|
||||
log_error("Failed to disable open_count");
|
||||
@ -443,10 +435,8 @@ struct dev_manager *dev_manager_create(struct cmd_context *cmd,
|
||||
struct dm_pool *mem;
|
||||
struct dev_manager *dm;
|
||||
|
||||
if (!(mem = dm_pool_create("dev_manager", 16 * 1024))) {
|
||||
stack;
|
||||
return NULL;
|
||||
}
|
||||
if (!(mem = dm_pool_create("dev_manager", 16 * 1024)))
|
||||
return_NULL;
|
||||
|
||||
if (!(dm = dm_pool_alloc(mem, sizeof(*dm))))
|
||||
goto_bad;
|
||||
@ -509,10 +499,8 @@ int dev_manager_snapshot_percent(struct dev_manager *dm,
|
||||
*/
|
||||
log_debug("Getting device status percentage for %s", name);
|
||||
if (!(_percent(dm, name, dlid, "snapshot", 0, NULL, percent,
|
||||
NULL))) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
NULL)))
|
||||
return_0;
|
||||
|
||||
/* FIXME dm_pool_free ? */
|
||||
|
||||
@ -544,10 +532,8 @@ int dev_manager_mirror_percent(struct dev_manager *dm,
|
||||
|
||||
log_debug("Getting device mirror status percentage for %s", name);
|
||||
if (!(_percent(dm, name, dlid, "mirror", wait, lv, percent,
|
||||
event_nr))) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
event_nr)))
|
||||
return_0;
|
||||
|
||||
return 1;
|
||||
}
|
||||
@ -691,31 +677,25 @@ static struct dm_tree *_create_partial_dtree(struct dev_manager *dm, struct logi
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (!_add_lv_to_dtree(dm, dtree, lv)) {
|
||||
stack;
|
||||
goto fail;
|
||||
}
|
||||
if (!_add_lv_to_dtree(dm, dtree, lv))
|
||||
goto_bad;
|
||||
|
||||
/* Add any snapshots of this LV */
|
||||
list_iterate_safe(snh, snht, &lv->snapshot_segs)
|
||||
if (!_add_lv_to_dtree(dm, dtree, list_struct_base(snh, struct lv_segment, origin_list)->cow)) {
|
||||
stack;
|
||||
goto fail;
|
||||
}
|
||||
if (!_add_lv_to_dtree(dm, dtree, list_struct_base(snh, struct lv_segment, origin_list)->cow))
|
||||
goto_bad;
|
||||
|
||||
/* Add any LVs used by segments in this LV */
|
||||
list_iterate_items(seg, &lv->segments)
|
||||
for (s = 0; s < seg->area_count; s++)
|
||||
if (seg_type(seg, s) == AREA_LV && seg_lv(seg, s)) {
|
||||
if (!_add_lv_to_dtree(dm, dtree, seg_lv(seg, s))) {
|
||||
stack;
|
||||
goto fail;
|
||||
}
|
||||
if (!_add_lv_to_dtree(dm, dtree, seg_lv(seg, s)))
|
||||
goto_bad;
|
||||
}
|
||||
|
||||
return dtree;
|
||||
|
||||
fail:
|
||||
bad:
|
||||
dm_tree_free(dtree);
|
||||
return NULL;
|
||||
}
|
||||
|
@ -175,10 +175,8 @@ static int _mk_link(const char *dev_dir, const char *vg_name,
|
||||
}
|
||||
|
||||
#ifdef HAVE_SELINUX
|
||||
if (!dm_set_selinux_context(lv_path, S_IFLNK)) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
if (!dm_set_selinux_context(lv_path, S_IFLNK))
|
||||
return_0;
|
||||
#endif
|
||||
|
||||
return 1;
|
||||
@ -225,17 +223,13 @@ static int _do_fs_op(fs_op_t type, const char *dev_dir, const char *vg_name,
|
||||
switch (type) {
|
||||
case FS_ADD:
|
||||
if (!_mk_dir(dev_dir, vg_name) ||
|
||||
!_mk_link(dev_dir, vg_name, lv_name, dev)) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
!_mk_link(dev_dir, vg_name, lv_name, dev))
|
||||
return_0;
|
||||
break;
|
||||
case FS_DEL:
|
||||
if (!_rm_link(dev_dir, vg_name, lv_name) ||
|
||||
!_rm_dir(dev_dir, vg_name)) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
!_rm_dir(dev_dir, vg_name))
|
||||
return_0;
|
||||
break;
|
||||
/* FIXME Use rename() */
|
||||
case FS_RENAME:
|
||||
@ -316,10 +310,8 @@ static int _fs_op(fs_op_t type, const char *dev_dir, const char *vg_name,
|
||||
{
|
||||
if (memlock()) {
|
||||
if (!_stack_fs_op(type, dev_dir, vg_name, lv_name, dev,
|
||||
old_lv_name)) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
old_lv_name))
|
||||
return_0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
12
lib/cache/lvmcache.c
vendored
12
lib/cache/lvmcache.c
vendored
@ -803,10 +803,8 @@ struct lvmcache_info *lvmcache_add(struct labeller *labeller, const char *pvid,
|
||||
|
||||
if (!(existing = info_from_pvid(pvid_s, 0)) &&
|
||||
!(existing = info_from_pvid(dev->pvid, 0))) {
|
||||
if (!(label = label_create(labeller))) {
|
||||
stack;
|
||||
return NULL;
|
||||
}
|
||||
if (!(label = label_create(labeller)))
|
||||
return_NULL;
|
||||
if (!(info = dm_malloc(sizeof(*info)))) {
|
||||
log_error("lvmcache_info allocation failed");
|
||||
label_destroy(label);
|
||||
@ -862,11 +860,9 @@ struct lvmcache_info *lvmcache_add(struct labeller *labeller, const char *pvid,
|
||||
/* Has labeller changed? */
|
||||
if (info->label->labeller != labeller) {
|
||||
label_destroy(info->label);
|
||||
if (!(info->label = label_create(labeller))) {
|
||||
if (!(info->label = label_create(labeller)))
|
||||
/* FIXME leaves info without label! */
|
||||
stack;
|
||||
return NULL;
|
||||
}
|
||||
return_NULL;
|
||||
info->label->info = info;
|
||||
}
|
||||
label = info->label;
|
||||
|
@ -282,10 +282,8 @@ static int _init_tags(struct cmd_context *cmd, struct config_tree *cft)
|
||||
if (!cmd->hosttags && find_config_int(cft->root, "tags/hosttags",
|
||||
DEFAULT_HOSTTAGS)) {
|
||||
/* FIXME Strip out invalid chars: only A-Za-z0-9_+.- */
|
||||
if (!_set_tag(cmd, cmd->hostname)) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
if (!_set_tag(cmd, cmd->hostname))
|
||||
return_0;
|
||||
cmd->hosttags = 1;
|
||||
}
|
||||
|
||||
@ -301,17 +299,13 @@ static int _init_tags(struct cmd_context *cmd, struct config_tree *cft)
|
||||
}
|
||||
if (cn->child) {
|
||||
passes = 0;
|
||||
if (!_check_host_filters(cmd, cn->child, &passes)) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
if (!_check_host_filters(cmd, cn->child, &passes))
|
||||
return_0;
|
||||
if (!passes)
|
||||
continue;
|
||||
}
|
||||
if (!_set_tag(cmd, tag)) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
if (!_set_tag(cmd, tag))
|
||||
return_0;
|
||||
}
|
||||
|
||||
return 1;
|
||||
@ -385,10 +379,8 @@ static int _init_lvm_conf(struct cmd_context *cmd)
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (!_load_config_file(cmd, "")) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
if (!_load_config_file(cmd, ""))
|
||||
return_0;
|
||||
|
||||
return 1;
|
||||
}
|
||||
@ -400,11 +392,8 @@ static int _init_tag_configs(struct cmd_context *cmd)
|
||||
|
||||
/* Tag list may grow while inside this loop */
|
||||
list_iterate_items(sl, &cmd->tags) {
|
||||
if (!_load_config_file(cmd, sl->str)) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!_load_config_file(cmd, sl->str))
|
||||
return_0;
|
||||
}
|
||||
|
||||
return 1;
|
||||
@ -424,10 +413,8 @@ static int _merge_config_files(struct cmd_context *cmd)
|
||||
|
||||
list_iterate_items(cfl, &cmd->config_files) {
|
||||
/* Merge all config trees into cmd->cft using merge/tag rules */
|
||||
if (!merge_config_tree(cmd, cmd->cft, cfl->cft)) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
if (!merge_config_tree(cmd, cmd->cft, cfl->cft))
|
||||
return_0;
|
||||
}
|
||||
|
||||
return 1;
|
||||
@ -694,10 +681,8 @@ static int _init_formats(struct cmd_context *cmd)
|
||||
return 0;
|
||||
}
|
||||
if (!(lib = load_shared_library(cmd, cv->v.str,
|
||||
"format", 0))) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
"format", 0)))
|
||||
return_0;
|
||||
|
||||
if (!(init_format_fn = dlsym(lib, "init_format"))) {
|
||||
log_error("Shared library %s does not contain "
|
||||
@ -790,10 +775,8 @@ static int _init_segtypes(struct cmd_context *cmd)
|
||||
return 0;
|
||||
}
|
||||
if (!(lib = load_shared_library(cmd, cv->v.str,
|
||||
"segment type", 0))) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
"segment type", 0)))
|
||||
return_0;
|
||||
|
||||
if (!(init_segtype_fn = dlsym(lib, "init_segtype"))) {
|
||||
log_error("Shared library %s does not contain "
|
||||
|
@ -196,10 +196,8 @@ int read_config_fd(struct config_tree *cft, struct device *dev,
|
||||
off_t mmap_offset = 0;
|
||||
char *buf = NULL;
|
||||
|
||||
if (!(p = dm_pool_alloc(c->mem, sizeof(*p)))) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
if (!(p = dm_pool_alloc(c->mem, sizeof(*p))))
|
||||
return_0;
|
||||
p->mem = c->mem;
|
||||
|
||||
/* Only use mmap with regular files */
|
||||
@ -217,10 +215,8 @@ int read_config_fd(struct config_tree *cft, struct device *dev,
|
||||
}
|
||||
p->fb = p->fb + mmap_offset;
|
||||
} else {
|
||||
if (!(buf = dm_malloc(size + size2))) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
if (!(buf = dm_malloc(size + size2)))
|
||||
return_0;
|
||||
if (!dev_read_circular(dev, (uint64_t) offset, size,
|
||||
(uint64_t) offset2, size2, buf)) {
|
||||
goto out;
|
||||
@ -237,10 +233,8 @@ int read_config_fd(struct config_tree *cft, struct device *dev,
|
||||
|
||||
p->fe = p->fb + size + size2;
|
||||
|
||||
if (!_parse_config_file(p, cft)) {
|
||||
stack;
|
||||
goto out;
|
||||
}
|
||||
if (!_parse_config_file(p, cft))
|
||||
goto_out;
|
||||
|
||||
r = 1;
|
||||
|
||||
@ -537,10 +531,8 @@ static struct config_node *_file(struct parser *p)
|
||||
{
|
||||
struct config_node *root = NULL, *n, *l = NULL;
|
||||
while (p->t != TOK_EOF) {
|
||||
if (!(n = _section(p))) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
if (!(n = _section(p)))
|
||||
return_0;
|
||||
|
||||
if (!root)
|
||||
root = n;
|
||||
@ -555,25 +547,19 @@ static struct config_node *_section(struct parser *p)
|
||||
{
|
||||
/* IDENTIFIER SECTION_B_CHAR VALUE* SECTION_E_CHAR */
|
||||
struct config_node *root, *n, *l = NULL;
|
||||
if (!(root = _create_node(p))) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
if (!(root = _create_node(p)))
|
||||
return_0;
|
||||
|
||||
if (!(root->key = _dup_tok(p))) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
if (!(root->key = _dup_tok(p)))
|
||||
return_0;
|
||||
|
||||
match(TOK_IDENTIFIER);
|
||||
|
||||
if (p->t == TOK_SECTION_B) {
|
||||
match(TOK_SECTION_B);
|
||||
while (p->t != TOK_SECTION_E) {
|
||||
if (!(n = _section(p))) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
if (!(n = _section(p)))
|
||||
return_0;
|
||||
|
||||
if (!root->child)
|
||||
root->child = n;
|
||||
@ -584,10 +570,8 @@ static struct config_node *_section(struct parser *p)
|
||||
match(TOK_SECTION_E);
|
||||
} else {
|
||||
match(TOK_EQ);
|
||||
if (!(root->v = _value(p))) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
if (!(root->v = _value(p)))
|
||||
return_0;
|
||||
}
|
||||
|
||||
return root;
|
||||
@ -600,10 +584,8 @@ static struct config_value *_value(struct parser *p)
|
||||
if (p->t == TOK_ARRAY_B) {
|
||||
match(TOK_ARRAY_B);
|
||||
while (p->t != TOK_ARRAY_E) {
|
||||
if (!(l = _type(p))) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
if (!(l = _type(p)))
|
||||
return_0;
|
||||
|
||||
if (!h)
|
||||
h = l;
|
||||
@ -656,10 +638,8 @@ static struct config_value *_type(struct parser *p)
|
||||
v->type = CFG_STRING;
|
||||
|
||||
p->tb++, p->te--; /* strip "'s */
|
||||
if (!(v->v.str = _dup_tok(p))) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
if (!(v->v.str = _dup_tok(p)))
|
||||
return_0;
|
||||
p->te++;
|
||||
match(TOK_STRING);
|
||||
break;
|
||||
@ -847,10 +827,8 @@ static char *_dup_tok(struct parser *p)
|
||||
{
|
||||
size_t len = p->te - p->tb;
|
||||
char *str = dm_pool_alloc(p->mem, len + 1);
|
||||
if (!str) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
if (!str)
|
||||
return_0;
|
||||
strncpy(str, p->tb, len);
|
||||
str[len] = '\0';
|
||||
return str;
|
||||
|
@ -87,10 +87,8 @@ int btree_insert(struct btree *t, uint32_t k, void *data)
|
||||
struct node *p, **c = _lookup(&t->root, key, &p), *n;
|
||||
|
||||
if (!*c) {
|
||||
if (!(n = dm_pool_alloc(t->mem, sizeof(*n)))) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
if (!(n = dm_pool_alloc(t->mem, sizeof(*n))))
|
||||
return_0;
|
||||
|
||||
n->key = key;
|
||||
n->data = data;
|
||||
|
@ -20,10 +20,8 @@ struct list *str_list_create(struct dm_pool *mem)
|
||||
{
|
||||
struct list *sl;
|
||||
|
||||
if (!(sl = dm_pool_alloc(mem, sizeof(struct list)))) {
|
||||
stack;
|
||||
return NULL;
|
||||
}
|
||||
if (!(sl = dm_pool_alloc(mem, sizeof(struct list))))
|
||||
return_NULL;
|
||||
|
||||
list_init(sl);
|
||||
|
||||
@ -34,19 +32,15 @@ int str_list_add(struct dm_pool *mem, struct list *sll, const char *str)
|
||||
{
|
||||
struct str_list *sln;
|
||||
|
||||
if (!str) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
if (!str)
|
||||
return_0;
|
||||
|
||||
/* Already in list? */
|
||||
if (str_list_match_item(sll, str))
|
||||
return 1;
|
||||
|
||||
if (!(sln = dm_pool_alloc(mem, sizeof(*sln)))) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
if (!(sln = dm_pool_alloc(mem, sizeof(*sln))))
|
||||
return_0;
|
||||
|
||||
sln->str = str;
|
||||
list_add(sll, &sln->list);
|
||||
@ -74,10 +68,8 @@ int str_list_dup(struct dm_pool *mem, struct list *sllnew,
|
||||
list_init(sllnew);
|
||||
|
||||
list_iterate_items(sl, sllold) {
|
||||
if (!str_list_add(mem, sllnew, dm_pool_strdup(mem, sl->str))) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
if (!str_list_add(mem, sllnew, dm_pool_strdup(mem, sl->str)))
|
||||
return_0;
|
||||
}
|
||||
|
||||
return 1;
|
||||
|
@ -236,10 +236,8 @@ static int _add_alias(struct device *dev, const char *path)
|
||||
const char *oldpath;
|
||||
int prefer_old = 1;
|
||||
|
||||
if (!sl) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
if (!sl)
|
||||
return_0;
|
||||
|
||||
/* Is name already there? */
|
||||
list_iterate_items(strl, &dev->aliases) {
|
||||
@ -249,10 +247,8 @@ static int _add_alias(struct device *dev, const char *path)
|
||||
}
|
||||
}
|
||||
|
||||
if (!(sl->str = dm_pool_strdup(_cache.mem, path))) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
if (!(sl->str = dm_pool_strdup(_cache.mem, path)))
|
||||
return_0;
|
||||
|
||||
if (!list_empty(&dev->aliases)) {
|
||||
oldpath = list_item(dev->aliases.n, struct str_list)->str;
|
||||
@ -294,14 +290,10 @@ static int _insert_dev(const char *path, dev_t d)
|
||||
(uint32_t) d))) {
|
||||
/* create new device */
|
||||
if (loopfile) {
|
||||
if (!(dev = dev_create_file(path, NULL, NULL, 0))) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
} else if (!(dev = _dev_create(d))) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
if (!(dev = dev_create_file(path, NULL, NULL, 0)))
|
||||
return_0;
|
||||
} else if (!(dev = _dev_create(d)))
|
||||
return_0;
|
||||
|
||||
if (!(btree_insert(_cache.devices, (uint32_t) d, dev))) {
|
||||
log_err("Couldn't insert device into binary tree.");
|
||||
@ -369,10 +361,8 @@ static int _insert_dir(const char *dir)
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!(path = _join(dir, dirent[n]->d_name))) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
if (!(path = _join(dir, dirent[n]->d_name)))
|
||||
return_0;
|
||||
|
||||
_collapse_slashes(path);
|
||||
r &= _insert(path, 1);
|
||||
@ -400,10 +390,8 @@ static int _insert_file(const char *path)
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!_insert_dev(path, 0)) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
if (!_insert_dev(path, 0))
|
||||
return_0;
|
||||
|
||||
return 1;
|
||||
}
|
||||
@ -439,10 +427,8 @@ static int _insert(const char *path, int rec)
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!_insert_dev(path, info.st_rdev)) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
if (!_insert_dev(path, info.st_rdev))
|
||||
return_0;
|
||||
|
||||
r = 1;
|
||||
}
|
||||
@ -543,16 +529,13 @@ int dev_cache_init(struct cmd_context *cmd)
|
||||
_cache.names = NULL;
|
||||
_cache.has_scanned = 0;
|
||||
|
||||
if (!(_cache.mem = dm_pool_create("dev_cache", 10 * 1024))) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
if (!(_cache.mem = dm_pool_create("dev_cache", 10 * 1024)))
|
||||
return_0;
|
||||
|
||||
if (!(_cache.names = dm_hash_create(128))) {
|
||||
stack;
|
||||
dm_pool_destroy(_cache.mem);
|
||||
_cache.mem = 0;
|
||||
return 0;
|
||||
return_0;
|
||||
}
|
||||
|
||||
if (!(_cache.devices = btree_create(_cache.mem))) {
|
||||
|
@ -170,10 +170,8 @@ static int _aligned_io(struct device_area *where, void *buffer,
|
||||
struct device_area widened;
|
||||
|
||||
if (!(where->dev->flags & DEV_REGULAR) &&
|
||||
!_get_block_size(where->dev, &block_size)) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
!_get_block_size(where->dev, &block_size))
|
||||
return_0;
|
||||
|
||||
if (!block_size)
|
||||
block_size = lvm_getpagesize();
|
||||
@ -200,10 +198,8 @@ static int _aligned_io(struct device_area *where, void *buffer,
|
||||
|
||||
/* channel the io through the bounce buffer */
|
||||
if (!_io(&widened, bounce, 0)) {
|
||||
if (!should_write) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
if (!should_write)
|
||||
return_0;
|
||||
/* FIXME pre-extend the file */
|
||||
memset(bounce, '\n', widened.size);
|
||||
}
|
||||
@ -354,10 +350,8 @@ int dev_open_flags(struct device *dev, int flags, int direct, int quiet)
|
||||
|
||||
if (dev->flags & DEV_REGULAR)
|
||||
name = dev_name(dev);
|
||||
else if (!(name = dev_name_confirmed(dev, quiet))) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
else if (!(name = dev_name_confirmed(dev, quiet)))
|
||||
return_0;
|
||||
|
||||
if (!(dev->flags & DEV_REGULAR)) {
|
||||
if (stat(name, &buf) < 0) {
|
||||
@ -557,10 +551,8 @@ int dev_read(struct device *dev, uint64_t offset, size_t len, void *buffer)
|
||||
{
|
||||
struct device_area where;
|
||||
|
||||
if (!dev->open_count) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
if (!dev->open_count)
|
||||
return_0;
|
||||
|
||||
where.dev = dev;
|
||||
where.start = offset;
|
||||
@ -607,10 +599,8 @@ int dev_append(struct device *dev, size_t len, void *buffer)
|
||||
{
|
||||
int r;
|
||||
|
||||
if (!dev->open_count) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
if (!dev->open_count)
|
||||
return_0;
|
||||
|
||||
r = dev_write(dev, dev->end, len, buffer);
|
||||
dev->end += (uint64_t) len;
|
||||
@ -625,10 +615,8 @@ int dev_write(struct device *dev, uint64_t offset, size_t len, void *buffer)
|
||||
{
|
||||
struct device_area where;
|
||||
|
||||
if (!dev->open_count) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
if (!dev->open_count)
|
||||
return_0;
|
||||
|
||||
where.dev = dev;
|
||||
where.start = offset;
|
||||
@ -644,10 +632,8 @@ int dev_set(struct device *dev, uint64_t offset, size_t len, int value)
|
||||
size_t s;
|
||||
char buffer[4096] __attribute((aligned(8)));
|
||||
|
||||
if (!dev_open(dev)) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
if (!dev_open(dev))
|
||||
return_0;
|
||||
|
||||
if ((offset % SECTOR_SIZE) || (len % SECTOR_SIZE))
|
||||
log_debug("Wiping %s at %" PRIu64 " length %" PRIsize_t,
|
||||
|
@ -62,10 +62,8 @@ static int _has_partition_table(struct device *dev)
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (!dev_read(dev, UINT64_C(0), sizeof(buf), &buf)) {
|
||||
stack;
|
||||
goto out;
|
||||
}
|
||||
if (!dev_read(dev, UINT64_C(0), sizeof(buf), &buf))
|
||||
goto_out;
|
||||
|
||||
/* FIXME Check for other types of partition table too */
|
||||
|
||||
|
@ -360,10 +360,8 @@ int pvdisplay_short(const struct cmd_context *cmd __attribute((unused)),
|
||||
if (!pv)
|
||||
return 0;
|
||||
|
||||
if (!id_write_format(&pv->id, uuid, sizeof(uuid))) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
if (!id_write_format(&pv->id, uuid, sizeof(uuid)))
|
||||
return_0;
|
||||
|
||||
log_print("PV Name %s ", pv_dev_name(pv));
|
||||
/* FIXME pv->pv_number); */
|
||||
@ -407,10 +405,8 @@ int lvdisplay_full(struct cmd_context *cmd,
|
||||
struct lv_segment *snap_seg = NULL;
|
||||
float snap_percent; /* fused, fsize; */
|
||||
|
||||
if (!id_write_format(&lv->lvid.id[1], uuid, sizeof(uuid))) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
if (!id_write_format(&lv->lvid.id[1], uuid, sizeof(uuid)))
|
||||
return_0;
|
||||
|
||||
inkernel = lv_info(cmd, lv, &info, 1, 1) && info.exists;
|
||||
|
||||
|
@ -50,10 +50,8 @@ struct dev_filter *composite_filter_create(int n, struct dev_filter **filters)
|
||||
{
|
||||
struct dev_filter **filters_copy, *cft;
|
||||
|
||||
if (!filters) {
|
||||
stack;
|
||||
return NULL;
|
||||
}
|
||||
if (!filters)
|
||||
return_NULL;
|
||||
|
||||
if (!(filters_copy = dm_malloc(sizeof(*filters) * (n + 1)))) {
|
||||
log_error("composite filters allocation failed");
|
||||
|
@ -42,10 +42,8 @@ static int _init_hash(struct pfilter *pf)
|
||||
if (pf->devices)
|
||||
dm_hash_destroy(pf->devices);
|
||||
|
||||
if (!(pf->devices = dm_hash_create(128))) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
if (!(pf->devices = dm_hash_create(128)))
|
||||
return_0;
|
||||
|
||||
return 1;
|
||||
}
|
||||
@ -293,10 +291,8 @@ struct dev_filter *persistent_filter_create(struct dev_filter *real,
|
||||
struct pfilter *pf;
|
||||
struct dev_filter *f = NULL;
|
||||
|
||||
if (!(pf = dm_malloc(sizeof(*pf)))) {
|
||||
stack;
|
||||
return NULL;
|
||||
}
|
||||
if (!(pf = dm_malloc(sizeof(*pf))))
|
||||
return_NULL;
|
||||
memset(pf, 0, sizeof(*pf));
|
||||
|
||||
if (!(pf->file = dm_malloc(strlen(file) + 1)))
|
||||
|
@ -70,10 +70,8 @@ static int _extract_pattern(struct dm_pool *mem, const char *pat,
|
||||
/*
|
||||
* copy the regex
|
||||
*/
|
||||
if (!(r = dm_pool_strdup(mem, pat))) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
if (!(r = dm_pool_strdup(mem, pat)))
|
||||
return_0;
|
||||
|
||||
/*
|
||||
* trim the trailing character, having checked it's sep.
|
||||
@ -192,10 +190,8 @@ struct dev_filter *regex_filter_create(struct config_value *patterns)
|
||||
struct rfilter *rf;
|
||||
struct dev_filter *f;
|
||||
|
||||
if (!mem) {
|
||||
stack;
|
||||
return NULL;
|
||||
}
|
||||
if (!mem)
|
||||
return_NULL;
|
||||
|
||||
if (!(rf = dm_pool_alloc(mem, sizeof(*rf))))
|
||||
goto_bad;
|
||||
|
@ -277,9 +277,8 @@ struct dev_filter *lvm_type_filter_create(const char *proc,
|
||||
f->private = NULL;
|
||||
|
||||
if (!_scan_proc_dev(proc, cn)) {
|
||||
stack;
|
||||
dm_free(f);
|
||||
return NULL;
|
||||
return_NULL;
|
||||
}
|
||||
|
||||
return f;
|
||||
|
@ -21,7 +21,6 @@
|
||||
|
||||
#include <fcntl.h>
|
||||
|
||||
#define fail do {stack; return 0;} while(0)
|
||||
#define xx16(v) disk->v = xlate16(disk->v)
|
||||
#define xx32(v) disk->v = xlate32(disk->v)
|
||||
#define xx64(v) disk->v = xlate64(disk->v)
|
||||
@ -218,7 +217,7 @@ static int _read_pvd(struct device *dev, struct pv_disk *pvd)
|
||||
static int _read_lvd(struct device *dev, uint64_t pos, struct lv_disk *disk)
|
||||
{
|
||||
if (!dev_read(dev, pos, sizeof(*disk), disk))
|
||||
fail;
|
||||
return_0;
|
||||
|
||||
_xlate_lvd(disk);
|
||||
|
||||
@ -230,12 +229,12 @@ int read_vgd(struct device *dev, struct vg_disk *vgd, struct pv_disk *pvd)
|
||||
uint64_t pos = pvd->vg_on_disk.base;
|
||||
|
||||
if (!dev_read(dev, pos, sizeof(*vgd), vgd))
|
||||
fail;
|
||||
return_0;
|
||||
|
||||
_xlate_vgd(vgd);
|
||||
|
||||
if ((vgd->lv_max > MAX_LV) || (vgd->pv_max > MAX_PV))
|
||||
fail;
|
||||
return_0;
|
||||
|
||||
/* If UUID is missing, create one */
|
||||
if (vgd->vg_uuid[0] == '\0')
|
||||
@ -254,10 +253,10 @@ static int _read_uuids(struct disk_list *data)
|
||||
|
||||
while (pos < end && num_read < data->vgd.pv_cur) {
|
||||
if (!dev_read(data->dev, pos, sizeof(buffer), buffer))
|
||||
fail;
|
||||
return_0;
|
||||
|
||||
if (!(ul = dm_pool_alloc(data->mem, sizeof(*ul))))
|
||||
fail;
|
||||
return_0;
|
||||
|
||||
memcpy(ul->uuid, buffer, NAME_LEN);
|
||||
ul->uuid[NAME_LEN - 1] = '\0';
|
||||
@ -288,10 +287,10 @@ static int _read_lvs(struct disk_list *data)
|
||||
ll = dm_pool_alloc(data->mem, sizeof(*ll));
|
||||
|
||||
if (!ll)
|
||||
fail;
|
||||
return_0;
|
||||
|
||||
if (!_read_lvd(data->dev, pos, &ll->lvd))
|
||||
fail;
|
||||
return_0;
|
||||
|
||||
if (!_check_lvd(&ll->lvd))
|
||||
continue;
|
||||
@ -310,10 +309,10 @@ static int _read_extents(struct disk_list *data)
|
||||
uint64_t pos = data->pvd.pe_on_disk.base;
|
||||
|
||||
if (!extents)
|
||||
fail;
|
||||
return_0;
|
||||
|
||||
if (!dev_read(data->dev, pos, len, extents))
|
||||
fail;
|
||||
return_0;
|
||||
|
||||
_xlate_extents(extents, data->pvd.pe_total);
|
||||
data->extents = extents;
|
||||
@ -347,10 +346,8 @@ static struct disk_list *__read_disk(const struct format_type *fmt,
|
||||
struct disk_list *dl = dm_pool_zalloc(mem, sizeof(*dl));
|
||||
const char *name = dev_name(dev);
|
||||
|
||||
if (!dl) {
|
||||
stack;
|
||||
return NULL;
|
||||
}
|
||||
if (!dl)
|
||||
return_NULL;
|
||||
|
||||
dl->dev = dev;
|
||||
dl->mem = mem;
|
||||
@ -417,10 +414,8 @@ struct disk_list *read_disk(const struct format_type *fmt, struct device *dev,
|
||||
{
|
||||
struct disk_list *dl;
|
||||
|
||||
if (!dev_open(dev)) {
|
||||
stack;
|
||||
return NULL;
|
||||
}
|
||||
if (!dev_open(dev))
|
||||
return_NULL;
|
||||
|
||||
dl = __read_disk(fmt, dev, mem, vg_name);
|
||||
|
||||
@ -519,7 +514,7 @@ static int _write_vgd(struct disk_list *data)
|
||||
|
||||
_xlate_vgd(vgd);
|
||||
if (!dev_write(data->dev, pos, sizeof(*vgd), vgd))
|
||||
fail;
|
||||
return_0;
|
||||
|
||||
_xlate_vgd(vgd);
|
||||
|
||||
@ -544,7 +539,7 @@ static int _write_uuids(struct disk_list *data)
|
||||
pos, NAME_LEN);
|
||||
|
||||
if (!dev_write(data->dev, pos, NAME_LEN, ul->uuid))
|
||||
fail;
|
||||
return_0;
|
||||
|
||||
pos += NAME_LEN;
|
||||
}
|
||||
@ -560,7 +555,7 @@ static int _write_lvd(struct device *dev, uint64_t pos, struct lv_disk *disk)
|
||||
|
||||
_xlate_lvd(disk);
|
||||
if (!dev_write(dev, pos, sizeof(*disk), disk))
|
||||
fail;
|
||||
return_0;
|
||||
|
||||
_xlate_lvd(disk);
|
||||
|
||||
@ -588,7 +583,7 @@ static int _write_lvs(struct disk_list *data)
|
||||
}
|
||||
|
||||
if (!_write_lvd(data->dev, pos + offset, &ll->lvd))
|
||||
fail;
|
||||
return_0;
|
||||
}
|
||||
|
||||
return 1;
|
||||
@ -606,7 +601,7 @@ static int _write_extents(struct disk_list *data)
|
||||
|
||||
_xlate_extents(extents, data->pvd.pe_total);
|
||||
if (!dev_write(data->dev, pos, len, extents))
|
||||
fail;
|
||||
return_0;
|
||||
|
||||
_xlate_extents(extents, data->pvd.pe_total);
|
||||
|
||||
@ -643,7 +638,7 @@ static int _write_pvd(struct disk_list *data)
|
||||
_xlate_pvd((struct pv_disk *) buf);
|
||||
if (!dev_write(data->dev, pos, size, buf)) {
|
||||
dm_free(buf);
|
||||
fail;
|
||||
return_0;
|
||||
}
|
||||
|
||||
dm_free(buf);
|
||||
@ -707,10 +702,8 @@ static int _write_all_pvd(const struct format_type *fmt, struct disk_list *data)
|
||||
{
|
||||
int r;
|
||||
|
||||
if (!dev_open(data->dev)) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
if (!dev_open(data->dev))
|
||||
return_0;
|
||||
|
||||
r = __write_all_pvd(fmt, data);
|
||||
|
||||
@ -731,7 +724,7 @@ int write_disks(const struct format_type *fmt, struct list *pvs)
|
||||
|
||||
list_iterate_items(dl, pvs) {
|
||||
if (!(_write_all_pvd(fmt, dl)))
|
||||
fail;
|
||||
return_0;
|
||||
|
||||
log_very_verbose("Successfully wrote data to %s",
|
||||
dev_name(dl->dev));
|
||||
|
@ -168,7 +168,6 @@ static struct volume_group *_build_vg(struct format_instance *fid,
|
||||
return vg;
|
||||
|
||||
bad:
|
||||
stack;
|
||||
dm_pool_free(mem, vg);
|
||||
return NULL;
|
||||
}
|
||||
@ -182,10 +181,8 @@ static struct volume_group *_format1_vg_read(struct format_instance *fid,
|
||||
struct volume_group *vg = NULL;
|
||||
list_init(&pvs);
|
||||
|
||||
if (!mem) {
|
||||
stack;
|
||||
return NULL;
|
||||
}
|
||||
if (!mem)
|
||||
return_NULL;
|
||||
|
||||
/* Strip dev_dir if present */
|
||||
vg_name = strip_dir(vg_name, fid->fmt->cmd->dev_dir);
|
||||
@ -209,10 +206,8 @@ static struct disk_list *_flatten_pv(struct format_instance *fid,
|
||||
{
|
||||
struct disk_list *dl = dm_pool_alloc(mem, sizeof(*dl));
|
||||
|
||||
if (!dl) {
|
||||
stack;
|
||||
return NULL;
|
||||
}
|
||||
if (!dl)
|
||||
return_NULL;
|
||||
|
||||
dl->mem = mem;
|
||||
dl->dev = pv->dev;
|
||||
@ -224,9 +219,8 @@ static struct disk_list *_flatten_pv(struct format_instance *fid,
|
||||
!export_vg(&dl->vgd, vg) ||
|
||||
!export_uuids(dl, vg) ||
|
||||
!export_lvs(dl, vg, pv, dev_dir) || !calculate_layout(dl)) {
|
||||
stack;
|
||||
dm_pool_free(mem, dl);
|
||||
return NULL;
|
||||
return_NULL;
|
||||
}
|
||||
|
||||
return dl;
|
||||
@ -241,10 +235,8 @@ static int _flatten_vg(struct format_instance *fid, struct dm_pool *mem,
|
||||
struct disk_list *data;
|
||||
|
||||
list_iterate_items(pvl, &vg->pvs) {
|
||||
if (!(data = _flatten_pv(fid, mem, vg, pvl->pv, dev_dir))) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
if (!(data = _flatten_pv(fid, mem, vg, pvl->pv, dev_dir)))
|
||||
return_0;
|
||||
|
||||
list_add(pvds, &data->list);
|
||||
}
|
||||
@ -252,10 +244,8 @@ static int _flatten_vg(struct format_instance *fid, struct dm_pool *mem,
|
||||
export_numbers(pvds, vg);
|
||||
export_pv_act(pvds);
|
||||
|
||||
if (!export_vg_number(fid, pvds, vg->name, filter)) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
if (!export_vg_number(fid, pvds, vg->name, filter))
|
||||
return_0;
|
||||
|
||||
return 1;
|
||||
}
|
||||
@ -267,10 +257,8 @@ static int _format1_vg_write(struct format_instance *fid, struct volume_group *v
|
||||
struct list pvds;
|
||||
int r = 0;
|
||||
|
||||
if (!mem) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
if (!mem)
|
||||
return_0;
|
||||
|
||||
list_init(&pvds);
|
||||
|
||||
@ -293,25 +281,17 @@ static int _format1_pv_read(const struct format_type *fmt, const char *pv_name,
|
||||
|
||||
log_very_verbose("Reading physical volume data %s from disk", pv_name);
|
||||
|
||||
if (!mem) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
if (!mem)
|
||||
return_0;
|
||||
|
||||
if (!(dev = dev_cache_get(pv_name, fmt->cmd->filter))) {
|
||||
stack;
|
||||
goto out;
|
||||
}
|
||||
if (!(dev = dev_cache_get(pv_name, fmt->cmd->filter)))
|
||||
goto_out;
|
||||
|
||||
if (!(dl = read_disk(fmt, dev, mem, NULL))) {
|
||||
stack;
|
||||
goto out;
|
||||
}
|
||||
if (!(dl = read_disk(fmt, dev, mem, NULL)))
|
||||
goto_out;
|
||||
|
||||
if (!import_pv(fmt, fmt->cmd->mem, dl->dev, NULL, pv, &dl->pvd, &dl->vgd)) {
|
||||
stack;
|
||||
goto out;
|
||||
}
|
||||
if (!import_pv(fmt, fmt->cmd->mem, dl->dev, NULL, pv, &dl->pvd, &dl->vgd))
|
||||
goto_out;
|
||||
|
||||
pv->fmt = fmt;
|
||||
|
||||
@ -344,10 +324,8 @@ static int _format1_pv_setup(const struct format_type *fmt,
|
||||
/*
|
||||
* This works out pe_start and pe_count.
|
||||
*/
|
||||
if (!calculate_extent_count(pv, extent_size, extent_count, pe_start)) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
if (!calculate_extent_count(pv, extent_size, extent_count, pe_start))
|
||||
return_0;
|
||||
|
||||
/* Retain existing extent locations exactly */
|
||||
if (((pe_start || extent_count) && (pe_start != pv->pe_start)) ||
|
||||
@ -390,10 +368,8 @@ static int _format1_pv_write(const struct format_type *fmt, struct physical_volu
|
||||
struct lvmcache_info *info;
|
||||
|
||||
if (!(info = lvmcache_add(fmt->labeller, (char *) &pv->id, pv->dev,
|
||||
pv->vg_name, NULL, 0))) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
pv->vg_name, NULL, 0)))
|
||||
return_0;
|
||||
label = info->label;
|
||||
info->device_size = pv->size << SECTOR_SHIFT;
|
||||
info->fmt = fmt;
|
||||
@ -406,10 +382,8 @@ static int _format1_pv_write(const struct format_type *fmt, struct physical_volu
|
||||
pv->pe_size = pv->pe_count = 0;
|
||||
pv->pe_start = LVM1_PE_ALIGN;
|
||||
|
||||
if (!(mem = dm_pool_create("lvm1 pv_write", 1024))) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
if (!(mem = dm_pool_create("lvm1 pv_write", 1024)))
|
||||
return_0;
|
||||
|
||||
if (!(dl = dm_pool_alloc(mem, sizeof(*dl))))
|
||||
goto_bad;
|
||||
@ -473,10 +447,8 @@ static int _format1_vg_setup(struct format_instance *fid, struct volume_group *v
|
||||
static int _format1_segtype_supported(struct format_instance *fid __attribute((unused)),
|
||||
const struct segment_type *segtype)
|
||||
{
|
||||
if (!(segtype->flags & SEG_FORMAT1_SUPPORT)) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
if (!(segtype->flags & SEG_FORMAT1_SUPPORT))
|
||||
return_0;
|
||||
|
||||
return 1;
|
||||
}
|
||||
@ -494,19 +466,16 @@ static struct format_instance *_format1_create_instance(const struct format_type
|
||||
struct format_instance *fid;
|
||||
struct metadata_area *mda;
|
||||
|
||||
if (!(fid = dm_pool_alloc(fmt->cmd->mem, sizeof(*fid)))) {
|
||||
stack;
|
||||
return NULL;
|
||||
}
|
||||
if (!(fid = dm_pool_alloc(fmt->cmd->mem, sizeof(*fid))))
|
||||
return_NULL;
|
||||
|
||||
fid->fmt = fmt;
|
||||
list_init(&fid->metadata_areas);
|
||||
|
||||
/* Define a NULL metadata area */
|
||||
if (!(mda = dm_pool_alloc(fmt->cmd->mem, sizeof(*mda)))) {
|
||||
stack;
|
||||
dm_pool_free(fmt->cmd->mem, fid);
|
||||
return NULL;
|
||||
return_NULL;
|
||||
}
|
||||
|
||||
mda->ops = &_metadata_format1_ops;
|
||||
@ -547,10 +516,8 @@ struct format_type *init_format(struct cmd_context *cmd)
|
||||
{
|
||||
struct format_type *fmt = dm_malloc(sizeof(*fmt));
|
||||
|
||||
if (!fmt) {
|
||||
stack;
|
||||
return NULL;
|
||||
}
|
||||
if (!fmt)
|
||||
return_NULL;
|
||||
|
||||
fmt->cmd = cmd;
|
||||
fmt->ops = &_format1_ops;
|
||||
|
@ -117,10 +117,8 @@ int import_pv(const struct format_type *fmt, struct dm_pool *mem,
|
||||
list_init(&pv->tags);
|
||||
list_init(&pv->segments);
|
||||
|
||||
if (!alloc_pv_segment_whole_pv(mem, pv)) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
if (!alloc_pv_segment_whole_pv(mem, pv))
|
||||
return_0;
|
||||
|
||||
return 1;
|
||||
}
|
||||
@ -150,10 +148,8 @@ int export_pv(struct cmd_context *cmd, struct dm_pool *mem __attribute((unused))
|
||||
memcpy(pvd->pv_uuid, pv->id.uuid, ID_LEN);
|
||||
|
||||
if (pv->vg_name) {
|
||||
if (!_check_vg_name(pv->vg_name)) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
if (!_check_vg_name(pv->vg_name))
|
||||
return_0;
|
||||
strncpy((char *)pvd->vg_name, pv->vg_name, sizeof(pvd->vg_name));
|
||||
}
|
||||
|
||||
@ -167,10 +163,8 @@ int export_pv(struct cmd_context *cmd, struct dm_pool *mem __attribute((unused))
|
||||
if (!*vg->system_id ||
|
||||
strncmp(vg->system_id, EXPORTED_TAG,
|
||||
sizeof(EXPORTED_TAG) - 1)) {
|
||||
if (!_system_id(cmd, (char *)pvd->system_id, EXPORTED_TAG)) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
if (!_system_id(cmd, (char *)pvd->system_id, EXPORTED_TAG))
|
||||
return_0;
|
||||
}
|
||||
if (strlen((char *)pvd->vg_name) + sizeof(EXPORTED_TAG) >
|
||||
sizeof(pvd->vg_name)) {
|
||||
@ -184,18 +178,14 @@ int export_pv(struct cmd_context *cmd, struct dm_pool *mem __attribute((unused))
|
||||
/* Is VG being imported? */
|
||||
if (vg && !(vg->status & EXPORTED_VG) && *vg->system_id &&
|
||||
!strncmp(vg->system_id, EXPORTED_TAG, sizeof(EXPORTED_TAG) - 1)) {
|
||||
if (!_system_id(cmd, (char *)pvd->system_id, IMPORTED_TAG)) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
if (!_system_id(cmd, (char *)pvd->system_id, IMPORTED_TAG))
|
||||
return_0;
|
||||
}
|
||||
|
||||
/* Generate system_id if PV is in VG */
|
||||
if (!pvd->system_id || !*pvd->system_id)
|
||||
if (!_system_id(cmd, (char *)pvd->system_id, "")) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
if (!_system_id(cmd, (char *)pvd->system_id, ""))
|
||||
return_0;
|
||||
|
||||
/* Update internal system_id if we changed it */
|
||||
if (vg &&
|
||||
@ -227,20 +217,14 @@ int import_vg(struct dm_pool *mem,
|
||||
struct vg_disk *vgd = &dl->vgd;
|
||||
memcpy(vg->id.uuid, vgd->vg_uuid, ID_LEN);
|
||||
|
||||
if (!_check_vg_name((char *)dl->pvd.vg_name)) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
if (!_check_vg_name((char *)dl->pvd.vg_name))
|
||||
return_0;
|
||||
|
||||
if (!(vg->name = dm_pool_strdup(mem, (char *)dl->pvd.vg_name))) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
if (!(vg->name = dm_pool_strdup(mem, (char *)dl->pvd.vg_name)))
|
||||
return_0;
|
||||
|
||||
if (!(vg->system_id = dm_pool_alloc(mem, NAME_LEN))) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
if (!(vg->system_id = dm_pool_alloc(mem, NAME_LEN)))
|
||||
return_0;
|
||||
|
||||
*vg->system_id = '\0';
|
||||
|
||||
@ -315,10 +299,8 @@ int import_lv(struct dm_pool *mem, struct logical_volume *lv, struct lv_disk *lv
|
||||
{
|
||||
lvid_from_lvnum(&lv->lvid, &lv->vg->id, lvd->lv_number);
|
||||
|
||||
if (!(lv->name = _create_lv_name(mem, (char *)lvd->lv_name))) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
if (!(lv->name = _create_lv_name(mem, (char *)lvd->lv_name)))
|
||||
return_0;
|
||||
|
||||
lv->status |= VISIBLE_LV;
|
||||
|
||||
@ -457,15 +439,11 @@ int import_pvs(const struct format_type *fmt, struct dm_pool *mem,
|
||||
*count = 0;
|
||||
list_iterate_items(dl, pvds) {
|
||||
if (!(pvl = dm_pool_zalloc(mem, sizeof(*pvl))) ||
|
||||
!(pvl->pv = dm_pool_alloc(mem, sizeof(*pvl->pv)))) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
!(pvl->pv = dm_pool_alloc(mem, sizeof(*pvl->pv))))
|
||||
return_0;
|
||||
|
||||
if (!import_pv(fmt, mem, dl->dev, vg, pvl->pv, &dl->pvd, &dl->vgd)) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
if (!import_pv(fmt, mem, dl->dev, vg, pvl->pv, &dl->pvd, &dl->vgd))
|
||||
return_0;
|
||||
|
||||
pvl->pv->fmt = fmt;
|
||||
list_add(results, &pvl->list);
|
||||
@ -483,17 +461,13 @@ static struct logical_volume *_add_lv(struct dm_pool *mem,
|
||||
struct logical_volume *lv;
|
||||
|
||||
if (!(ll = dm_pool_zalloc(mem, sizeof(*ll))) ||
|
||||
!(ll->lv = dm_pool_zalloc(mem, sizeof(*ll->lv)))) {
|
||||
stack;
|
||||
return NULL;
|
||||
}
|
||||
!(ll->lv = dm_pool_zalloc(mem, sizeof(*ll->lv))))
|
||||
return_NULL;
|
||||
lv = ll->lv;
|
||||
lv->vg = vg;
|
||||
|
||||
if (!import_lv(mem, lv, lvd)) {
|
||||
stack;
|
||||
return NULL;
|
||||
}
|
||||
if (!import_lv(mem, lv, lvd))
|
||||
return_NULL;
|
||||
|
||||
list_add(&vg->lvs, &ll->list);
|
||||
vg->lv_count++;
|
||||
@ -512,10 +486,8 @@ int import_lvs(struct dm_pool *mem, struct volume_group *vg, struct list *pvds)
|
||||
lvd = &ll->lvd;
|
||||
|
||||
if (!find_lv(vg, (char *)lvd->lv_name) &&
|
||||
!_add_lv(mem, vg, lvd)) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
!_add_lv(mem, vg, lvd))
|
||||
return_0;
|
||||
}
|
||||
}
|
||||
|
||||
@ -533,49 +505,37 @@ int export_lvs(struct disk_list *dl, struct volume_group *vg,
|
||||
uint32_t lv_num;
|
||||
struct dm_hash_table *lvd_hash;
|
||||
|
||||
if (!_check_vg_name(vg->name)) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
if (!_check_vg_name(vg->name))
|
||||
return_0;
|
||||
|
||||
if (!(lvd_hash = dm_hash_create(32))) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
if (!(lvd_hash = dm_hash_create(32)))
|
||||
return_0;
|
||||
|
||||
/*
|
||||
* setup the pv's extents array
|
||||
*/
|
||||
len = sizeof(struct pe_disk) * dl->pvd.pe_total;
|
||||
if (!(dl->extents = dm_pool_alloc(dl->mem, len))) {
|
||||
stack;
|
||||
goto out;
|
||||
}
|
||||
if (!(dl->extents = dm_pool_alloc(dl->mem, len)))
|
||||
goto_out;
|
||||
memset(dl->extents, 0, len);
|
||||
|
||||
list_iterate_items(ll, &vg->lvs) {
|
||||
if (ll->lv->status & SNAPSHOT)
|
||||
continue;
|
||||
|
||||
if (!(lvdl = dm_pool_alloc(dl->mem, sizeof(*lvdl)))) {
|
||||
stack;
|
||||
goto out;
|
||||
}
|
||||
if (!(lvdl = dm_pool_alloc(dl->mem, sizeof(*lvdl))))
|
||||
goto_out;
|
||||
|
||||
_export_lv(&lvdl->lvd, vg, ll->lv, dev_dir);
|
||||
|
||||
lv_num = lvnum_from_lvid(&ll->lv->lvid);
|
||||
lvdl->lvd.lv_number = lv_num;
|
||||
|
||||
if (!dm_hash_insert(lvd_hash, ll->lv->name, &lvdl->lvd)) {
|
||||
stack;
|
||||
goto out;
|
||||
}
|
||||
if (!dm_hash_insert(lvd_hash, ll->lv->name, &lvdl->lvd))
|
||||
goto_out;
|
||||
|
||||
if (!export_extents(dl, lv_num + 1, ll->lv, pv)) {
|
||||
stack;
|
||||
goto out;
|
||||
}
|
||||
if (!export_extents(dl, lv_num + 1, ll->lv, pv))
|
||||
goto_out;
|
||||
|
||||
if (lv_is_origin(ll->lv))
|
||||
lvdl->lvd.lv_access |= LV_SNAPSHOT_ORG;
|
||||
@ -675,10 +635,8 @@ int export_uuids(struct disk_list *dl, struct volume_group *vg)
|
||||
struct pv_list *pvl;
|
||||
|
||||
list_iterate_items(pvl, &vg->pvs) {
|
||||
if (!(ul = dm_pool_alloc(dl->mem, sizeof(*ul)))) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
if (!(ul = dm_pool_alloc(dl->mem, sizeof(*ul))))
|
||||
return_0;
|
||||
|
||||
memset(ul->uuid, 0, sizeof(ul->uuid));
|
||||
memcpy(ul->uuid, pvl->pv->id.uuid, ID_LEN);
|
||||
@ -723,10 +681,8 @@ int export_vg_number(struct format_instance *fid, struct list *pvds,
|
||||
struct disk_list *dl;
|
||||
int vg_num;
|
||||
|
||||
if (!get_free_vg_number(fid, filter, vg_name, &vg_num)) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
if (!get_free_vg_number(fid, filter, vg_name, &vg_num))
|
||||
return_0;
|
||||
|
||||
list_iterate_items(dl, pvds)
|
||||
dl->vgd.vg_number = vg_num;
|
||||
|
@ -118,10 +118,8 @@ static int _fill_maps(struct dm_hash_table *maps, struct volume_group *vg,
|
||||
e = dl->extents;
|
||||
|
||||
/* build an array of lv's for this pv */
|
||||
if (!_fill_lv_array(lvms, maps, dl)) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
if (!_fill_lv_array(lvms, maps, dl))
|
||||
return_0;
|
||||
|
||||
for (i = 0; i < dl->pvd.pe_total; i++) {
|
||||
lv_num = e[i].lv_num;
|
||||
@ -189,10 +187,8 @@ static int _check_maps_are_complete(struct dm_hash_table *maps)
|
||||
for (n = dm_hash_get_first(maps); n; n = dm_hash_get_next(maps, n)) {
|
||||
lvm = (struct lv_map *) dm_hash_get_data(maps, n);
|
||||
|
||||
if (!_check_single_map(lvm)) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
if (!_check_single_map(lvm))
|
||||
return_0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
@ -216,10 +212,8 @@ static int _read_linear(struct cmd_context *cmd, struct lv_map *lvm)
|
||||
struct lv_segment *seg;
|
||||
struct segment_type *segtype;
|
||||
|
||||
if (!(segtype = get_segtype_from_string(cmd, "striped"))) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
if (!(segtype = get_segtype_from_string(cmd, "striped")))
|
||||
return_0;
|
||||
|
||||
while (le < lvm->lv->le_count) {
|
||||
len = _area_length(lvm, le);
|
||||
@ -334,10 +328,8 @@ static int _build_all_segments(struct cmd_context *cmd, struct dm_hash_table *ma
|
||||
|
||||
for (n = dm_hash_get_first(maps); n; n = dm_hash_get_next(maps, n)) {
|
||||
lvm = (struct lv_map *) dm_hash_get_data(maps, n);
|
||||
if (!_build_segments(cmd, lvm)) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
if (!_build_segments(cmd, lvm))
|
||||
return_0;
|
||||
}
|
||||
|
||||
return 1;
|
||||
@ -350,10 +342,8 @@ int import_extents(struct cmd_context *cmd, struct volume_group *vg,
|
||||
struct dm_pool *scratch = dm_pool_create("lvm1 import_extents", 10 * 1024);
|
||||
struct dm_hash_table *maps;
|
||||
|
||||
if (!scratch) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
if (!scratch)
|
||||
return_0;
|
||||
|
||||
if (!(maps = _create_lv_maps(scratch, vg))) {
|
||||
log_err("Couldn't allocate logical volume maps.");
|
||||
@ -365,10 +355,8 @@ int import_extents(struct cmd_context *cmd, struct volume_group *vg,
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (!_check_maps_are_complete(maps) && !(vg->status & PARTIAL_VG)) {
|
||||
stack;
|
||||
goto out;
|
||||
}
|
||||
if (!_check_maps_are_complete(maps) && !(vg->status & PARTIAL_VG))
|
||||
goto_out;
|
||||
|
||||
if (!_build_all_segments(cmd, maps)) {
|
||||
log_err("Couldn't build extent segments.");
|
||||
|
@ -122,10 +122,8 @@ int calculate_extent_count(struct physical_volume *pv, uint32_t extent_size,
|
||||
struct pv_disk *pvd = dm_malloc(sizeof(*pvd));
|
||||
uint32_t end;
|
||||
|
||||
if (!pvd) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
if (!pvd)
|
||||
return_0;
|
||||
|
||||
/*
|
||||
* Guess how many extents will fit, bearing in mind that
|
||||
|
@ -71,10 +71,8 @@ static int _lvm1_read(struct labeller *l, struct device *dev, void *buf,
|
||||
}
|
||||
|
||||
if (!(info = lvmcache_add(l, (char *)pvd->pv_uuid, dev, (char *)pvd->vg_name, vgid,
|
||||
exported))) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
exported)))
|
||||
return_0;
|
||||
*label = info->label;
|
||||
|
||||
info->device_size = xlate32(pvd->pv_size) << SECTOR_SHIFT;
|
||||
|
@ -33,15 +33,11 @@ int get_free_vg_number(struct format_instance *fid, struct dev_filter *filter,
|
||||
|
||||
list_init(&all_pvs);
|
||||
|
||||
if (!mem) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
if (!mem)
|
||||
return_0;
|
||||
|
||||
if (!read_pvs_in_vg(fid->fmt, NULL, filter, mem, &all_pvs)) {
|
||||
stack;
|
||||
goto out;
|
||||
}
|
||||
if (!read_pvs_in_vg(fid->fmt, NULL, filter, mem, &all_pvs))
|
||||
goto_out;
|
||||
|
||||
memset(numbers, 0, sizeof(numbers));
|
||||
|
||||
|
@ -45,10 +45,8 @@ static int __read_pool_disk(const struct format_type *fmt, struct device *dev,
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!read_pool_label(pl, fmt->labeller, dev, buf, NULL)) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
if (!read_pool_label(pl, fmt->labeller, dev, buf, NULL))
|
||||
return_0;
|
||||
|
||||
return 1;
|
||||
}
|
||||
@ -98,10 +96,8 @@ int read_pool_label(struct pool_list *pl, struct labeller *l,
|
||||
log_debug("Calculated uuid %s for %s", uuid, pd->pl_pool_name);
|
||||
|
||||
if (!(info = lvmcache_add(l, (char *) &pvid, dev, pd->pl_pool_name,
|
||||
(char *) &vgid, 0))) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
(char *) &vgid, 0)))
|
||||
return_0;
|
||||
if (label)
|
||||
*label = info->label;
|
||||
|
||||
@ -252,10 +248,8 @@ static int _read_vg_pds(const struct format_type *fmt, struct dm_pool *mem,
|
||||
|
||||
/* FIXME: maybe should return a different error in memory
|
||||
* allocation failure */
|
||||
if (!(tmpmem = dm_pool_create("pool read_vg", 512))) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
if (!(tmpmem = dm_pool_create("pool read_vg", 512)))
|
||||
return_0;
|
||||
|
||||
list_iterate_items(info, &vginfo->infos) {
|
||||
if (info->dev &&
|
||||
@ -354,20 +348,16 @@ struct pool_list *read_pool_disk(const struct format_type *fmt,
|
||||
{
|
||||
struct pool_list *pl;
|
||||
|
||||
if (!dev_open(dev)) {
|
||||
stack;
|
||||
return NULL;
|
||||
}
|
||||
if (!dev_open(dev))
|
||||
return_NULL;
|
||||
|
||||
if (!(pl = dm_pool_zalloc(mem, sizeof(*pl)))) {
|
||||
log_error("Unable to allocate pool list structure");
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!__read_pool_disk(fmt, dev, mem, pl, vg_name)) {
|
||||
stack;
|
||||
return NULL;
|
||||
}
|
||||
if (!__read_pool_disk(fmt, dev, mem, pl, vg_name))
|
||||
return_NULL;
|
||||
|
||||
if (!dev_close(dev))
|
||||
stack;
|
||||
|
@ -128,44 +128,32 @@ static struct volume_group *_build_vg_from_pds(struct format_instance
|
||||
list_init(&vg->lvs);
|
||||
list_init(&vg->tags);
|
||||
|
||||
if (!import_pool_vg(vg, smem, pds)) {
|
||||
stack;
|
||||
return NULL;
|
||||
}
|
||||
if (!import_pool_vg(vg, smem, pds))
|
||||
return_NULL;
|
||||
|
||||
if (!import_pool_pvs(fid->fmt, vg, &vg->pvs, smem, pds)) {
|
||||
stack;
|
||||
return NULL;
|
||||
}
|
||||
if (!import_pool_pvs(fid->fmt, vg, &vg->pvs, smem, pds))
|
||||
return_NULL;
|
||||
|
||||
if (!import_pool_lvs(vg, smem, pds)) {
|
||||
stack;
|
||||
return NULL;
|
||||
}
|
||||
if (!import_pool_lvs(vg, smem, pds))
|
||||
return_NULL;
|
||||
|
||||
/*
|
||||
* I need an intermediate subpool structure that contains all the
|
||||
* relevant info for this. Then i can iterate through the subpool
|
||||
* structures for checking, and create the segments
|
||||
*/
|
||||
if (!(usp = _build_usp(pds, mem, &sp_count))) {
|
||||
stack;
|
||||
return NULL;
|
||||
}
|
||||
if (!(usp = _build_usp(pds, mem, &sp_count)))
|
||||
return_NULL;
|
||||
|
||||
/*
|
||||
* check the subpool structures - we can't handle partial VGs in
|
||||
* the pool format, so this will error out if we're missing PVs
|
||||
*/
|
||||
if (!_check_usp(vg->name, usp, sp_count)) {
|
||||
stack;
|
||||
return NULL;
|
||||
}
|
||||
if (!_check_usp(vg->name, usp, sp_count))
|
||||
return_NULL;
|
||||
|
||||
if (!import_pool_segments(&vg->lvs, smem, usp, sp_count)) {
|
||||
stack;
|
||||
return NULL;
|
||||
}
|
||||
if (!import_pool_segments(&vg->lvs, smem, usp, sp_count))
|
||||
return_NULL;
|
||||
|
||||
return vg;
|
||||
}
|
||||
@ -182,25 +170,19 @@ static struct volume_group *_pool_vg_read(struct format_instance *fid,
|
||||
|
||||
/* We can safely ignore the mda passed in */
|
||||
|
||||
if (!mem) {
|
||||
stack;
|
||||
return NULL;
|
||||
}
|
||||
if (!mem)
|
||||
return_NULL;
|
||||
|
||||
/* Strip dev_dir if present */
|
||||
vg_name = strip_dir(vg_name, fid->fmt->cmd->dev_dir);
|
||||
|
||||
/* Read all the pvs in the vg */
|
||||
if (!read_pool_pds(fid->fmt, vg_name, mem, &pds)) {
|
||||
stack;
|
||||
goto out;
|
||||
}
|
||||
if (!read_pool_pds(fid->fmt, vg_name, mem, &pds))
|
||||
goto_out;
|
||||
|
||||
/* Do the rest of the vg stuff */
|
||||
if (!(vg = _build_vg_from_pds(fid, mem, &pds))) {
|
||||
stack;
|
||||
goto out;
|
||||
}
|
||||
if (!(vg = _build_vg_from_pds(fid, mem, &pds)))
|
||||
goto_out;
|
||||
|
||||
out:
|
||||
dm_pool_destroy(mem);
|
||||
@ -231,30 +213,22 @@ static int _pool_pv_read(const struct format_type *fmt, const char *pv_name,
|
||||
|
||||
log_very_verbose("Reading physical volume data %s from disk", pv_name);
|
||||
|
||||
if (!mem) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
if (!mem)
|
||||
return_0;
|
||||
|
||||
if (!(dev = dev_cache_get(pv_name, fmt->cmd->filter))) {
|
||||
stack;
|
||||
goto out;
|
||||
}
|
||||
if (!(dev = dev_cache_get(pv_name, fmt->cmd->filter)))
|
||||
goto_out;
|
||||
|
||||
/*
|
||||
* I need to read the disk and populate a pv structure here
|
||||
* I'll probably need to abstract some of this later for the
|
||||
* vg_read code
|
||||
*/
|
||||
if (!(pl = read_pool_disk(fmt, dev, mem, NULL))) {
|
||||
stack;
|
||||
goto out;
|
||||
}
|
||||
if (!(pl = read_pool_disk(fmt, dev, mem, NULL)))
|
||||
goto_out;
|
||||
|
||||
if (!import_pool_pv(fmt, fmt->cmd->mem, NULL, pv, pl)) {
|
||||
stack;
|
||||
goto out;
|
||||
}
|
||||
if (!import_pool_pv(fmt, fmt->cmd->mem, NULL, pv, pl))
|
||||
goto_out;
|
||||
|
||||
pv->fmt = fmt;
|
||||
|
||||
|
@ -91,10 +91,8 @@ int import_pool_lvs(struct volume_group *vg, struct dm_pool *mem, struct list *p
|
||||
if (lv->name)
|
||||
continue;
|
||||
|
||||
if (!(lv->name = dm_pool_strdup(mem, pl->pd.pl_pool_name))) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
if (!(lv->name = dm_pool_strdup(mem, pl->pd.pl_pool_name)))
|
||||
return_0;
|
||||
|
||||
get_pool_lv_uuid(lv->lvid.id, &pl->pd);
|
||||
log_debug("Calculated lv uuid for lv %s: %s", lv->name,
|
||||
@ -178,10 +176,8 @@ int import_pool_pv(const struct format_type *fmt, struct dm_pool *mem,
|
||||
list_init(&pv->tags);
|
||||
list_init(&pv->segments);
|
||||
|
||||
if (!alloc_pv_segment_whole_pv(mem, pv)) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
if (!alloc_pv_segment_whole_pv(mem, pv))
|
||||
return_0;
|
||||
|
||||
return 1;
|
||||
}
|
||||
@ -216,10 +212,8 @@ static int _add_stripe_seg(struct dm_pool *mem,
|
||||
area_len = (usp->devs[0].blocks) / POOL_PE_SIZE;
|
||||
|
||||
if (!(segtype = get_segtype_from_string(lv->vg->cmd,
|
||||
"striped"))) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
"striped")))
|
||||
return_0;
|
||||
|
||||
if (!(seg = alloc_lv_segment(mem, segtype, lv, *le_cur,
|
||||
area_len * usp->num_devs, 0,
|
||||
@ -230,10 +224,8 @@ static int _add_stripe_seg(struct dm_pool *mem,
|
||||
}
|
||||
|
||||
for (j = 0; j < usp->num_devs; j++)
|
||||
if (!set_lv_segment_area_pv(seg, j, usp->devs[j].pv, 0)) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
if (!set_lv_segment_area_pv(seg, j, usp->devs[j].pv, 0))
|
||||
return_0;
|
||||
|
||||
/* add the subpool type to the segment tag list */
|
||||
str_list_add(mem, &seg->tags, _cvt_sptype(usp->type));
|
||||
@ -254,10 +246,8 @@ static int _add_linear_seg(struct dm_pool *mem,
|
||||
unsigned j;
|
||||
uint32_t area_len;
|
||||
|
||||
if (!(segtype = get_segtype_from_string(lv->vg->cmd, "striped"))) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
if (!(segtype = get_segtype_from_string(lv->vg->cmd, "striped")))
|
||||
return_0;
|
||||
|
||||
for (j = 0; j < usp->num_devs; j++) {
|
||||
area_len = (usp->devs[j].blocks) / POOL_PE_SIZE;
|
||||
@ -274,10 +264,8 @@ static int _add_linear_seg(struct dm_pool *mem,
|
||||
/* add the subpool type to the segment tag list */
|
||||
str_list_add(mem, &seg->tags, _cvt_sptype(usp->type));
|
||||
|
||||
if (!set_lv_segment_area_pv(seg, 0, usp->devs[j].pv, 0)) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
if (!set_lv_segment_area_pv(seg, 0, usp->devs[j].pv, 0))
|
||||
return_0;
|
||||
list_add(&lv->segments, &seg->list);
|
||||
|
||||
*le_cur += seg->len;
|
||||
@ -302,15 +290,11 @@ int import_pool_segments(struct list *lvs, struct dm_pool *mem,
|
||||
|
||||
for (i = 0; i < subpools; i++) {
|
||||
if (usp[i].striping) {
|
||||
if (!_add_stripe_seg(mem, &usp[i], lv, &le_cur)) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
if (!_add_stripe_seg(mem, &usp[i], lv, &le_cur))
|
||||
return_0;
|
||||
} else {
|
||||
if (!_add_linear_seg(mem, &usp[i], lv, &le_cur)) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
if (!_add_linear_seg(mem, &usp[i], lv, &le_cur))
|
||||
return_0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -113,10 +113,8 @@ static char *_join_file_to_dir(struct dm_pool *mem, const char *dir, const char
|
||||
!dm_pool_grow_object(mem, dir, strlen(dir)) ||
|
||||
!dm_pool_grow_object(mem, "/", 1) ||
|
||||
!dm_pool_grow_object(mem, name, strlen(name)) ||
|
||||
!dm_pool_grow_object(mem, "\0", 1)) {
|
||||
stack;
|
||||
return NULL;
|
||||
}
|
||||
!dm_pool_grow_object(mem, "\0", 1))
|
||||
return_NULL;
|
||||
|
||||
return dm_pool_end_object(mem);
|
||||
}
|
||||
@ -134,10 +132,8 @@ static struct list *_scan_archive(struct dm_pool *mem,
|
||||
struct archive_file *af;
|
||||
struct list *results;
|
||||
|
||||
if (!(results = dm_pool_alloc(mem, sizeof(*results)))) {
|
||||
stack;
|
||||
return NULL;
|
||||
}
|
||||
if (!(results = dm_pool_alloc(mem, sizeof(*results))))
|
||||
return_NULL;
|
||||
|
||||
list_init(results);
|
||||
|
||||
@ -161,10 +157,8 @@ static struct list *_scan_archive(struct dm_pool *mem,
|
||||
if (strcmp(vgname, vgname_found))
|
||||
continue;
|
||||
|
||||
if (!(path = _join_file_to_dir(mem, dir, dirent[i]->d_name))) {
|
||||
stack;
|
||||
goto out;
|
||||
}
|
||||
if (!(path = _join_file_to_dir(mem, dir, dirent[i]->d_name)))
|
||||
goto_out;
|
||||
|
||||
/*
|
||||
* Create a new archive_file.
|
||||
@ -255,10 +249,9 @@ int archive_vg(struct volume_group *vg,
|
||||
}
|
||||
|
||||
if (!text_vg_export_file(vg, desc, fp)) {
|
||||
stack;
|
||||
if (fclose(fp))
|
||||
log_sys_error("fclose", temp_file);
|
||||
return 0;
|
||||
return_0;
|
||||
}
|
||||
|
||||
if (lvm_fclose(fp, temp_file))
|
||||
@ -267,10 +260,8 @@ int archive_vg(struct volume_group *vg,
|
||||
/*
|
||||
* Now we want to rename this file to <vg>_index.vg.
|
||||
*/
|
||||
if (!(archives = _scan_archive(vg->cmd->mem, vg->name, dir))) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
if (!(archives = _scan_archive(vg->cmd->mem, vg->name, dir)))
|
||||
return_0;
|
||||
|
||||
if (list_empty(archives))
|
||||
ix = 0;
|
||||
@ -343,10 +334,8 @@ int archive_list(struct cmd_context *cmd, const char *dir, const char *vgname)
|
||||
struct list *archives;
|
||||
struct archive_file *af;
|
||||
|
||||
if (!(archives = _scan_archive(cmd->mem, vgname, dir))) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
if (!(archives = _scan_archive(cmd->mem, vgname, dir)))
|
||||
return_0;
|
||||
|
||||
if (list_empty(archives))
|
||||
log_print("No archives found in %s.", dir);
|
||||
@ -379,10 +368,8 @@ int backup_list(struct cmd_context *cmd, const char *dir, const char *vgname)
|
||||
{
|
||||
struct archive_file af;
|
||||
|
||||
if (!(af.path = _join_file_to_dir(cmd->mem, dir, vgname))) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
if (!(af.path = _join_file_to_dir(cmd->mem, dir, vgname)))
|
||||
return_0;
|
||||
|
||||
if (path_exists(af.path))
|
||||
_display_archive(cmd, &af);
|
||||
|
@ -78,17 +78,13 @@ static char *_build_desc(struct dm_pool *mem, const char *line, int before)
|
||||
size_t len = strlen(line) + 32;
|
||||
char *buffer;
|
||||
|
||||
if (!(buffer = dm_pool_zalloc(mem, strlen(line) + 32))) {
|
||||
stack;
|
||||
return NULL;
|
||||
}
|
||||
if (!(buffer = dm_pool_zalloc(mem, strlen(line) + 32)))
|
||||
return_NULL;
|
||||
|
||||
if (snprintf(buffer, len,
|
||||
"Created %s executing '%s'",
|
||||
before ? "*before*" : "*after*", line) < 0) {
|
||||
stack;
|
||||
return NULL;
|
||||
}
|
||||
before ? "*before*" : "*after*", line) < 0)
|
||||
return_NULL;
|
||||
|
||||
return buffer;
|
||||
}
|
||||
@ -97,10 +93,8 @@ static int __archive(struct volume_group *vg)
|
||||
{
|
||||
char *desc;
|
||||
|
||||
if (!(desc = _build_desc(vg->cmd->mem, vg->cmd->cmd_line, 1))) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
if (!(desc = _build_desc(vg->cmd->mem, vg->cmd->cmd_line, 1)))
|
||||
return_0;
|
||||
|
||||
return archive_vg(vg, vg->cmd->archive_params->dir, desc,
|
||||
vg->cmd->archive_params->keep_days,
|
||||
@ -196,10 +190,8 @@ static int __backup(struct volume_group *vg)
|
||||
char name[PATH_MAX];
|
||||
char *desc;
|
||||
|
||||
if (!(desc = _build_desc(vg->cmd->mem, vg->cmd->cmd_line, 0))) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
if (!(desc = _build_desc(vg->cmd->mem, vg->cmd->cmd_line, 0)))
|
||||
return_0;
|
||||
|
||||
if (dm_snprintf(name, sizeof(name), "%s/%s",
|
||||
vg->cmd->backup_params->dir, vg->name) < 0) {
|
||||
@ -324,10 +316,8 @@ int backup_restore_vg(struct cmd_context *cmd, struct volume_group *vg)
|
||||
}
|
||||
}
|
||||
|
||||
if (!vg_write(vg) || !vg_commit(vg)) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
if (!vg_write(vg) || !vg_commit(vg))
|
||||
return_0;
|
||||
|
||||
return 1;
|
||||
}
|
||||
@ -341,10 +331,8 @@ int backup_restore_from_file(struct cmd_context *cmd, const char *vg_name,
|
||||
/*
|
||||
* Read in the volume group from the text file.
|
||||
*/
|
||||
if (!(vg = backup_read_vg(cmd, vg_name, file))) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
if (!(vg = backup_read_vg(cmd, vg_name, file)))
|
||||
return_0;
|
||||
|
||||
return backup_restore_vg(cmd, vg);
|
||||
}
|
||||
|
@ -135,10 +135,8 @@ static int _nl_raw(struct formatter *f)
|
||||
{
|
||||
/* If metadata doesn't fit, extend buffer */
|
||||
if ((f->data.buf.used + 2 > f->data.buf.size) &&
|
||||
(!_extend_buffer(f))) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
(!_extend_buffer(f)))
|
||||
return_0;
|
||||
|
||||
*(f->data.buf.start + f->data.buf.used) = '\n';
|
||||
f->data.buf.used += 1;
|
||||
@ -195,10 +193,8 @@ static int _out_with_comment_raw(struct formatter *f,
|
||||
|
||||
/* If metadata doesn't fit, extend buffer */
|
||||
if (n < 0 || (n + f->data.buf.used + 2 > f->data.buf.size)) {
|
||||
if (!_extend_buffer(f)) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
if (!_extend_buffer(f))
|
||||
return_0;
|
||||
return -1; /* Retry */
|
||||
}
|
||||
|
||||
@ -323,26 +319,20 @@ static int _print_vg(struct formatter *f, struct volume_group *vg)
|
||||
{
|
||||
char buffer[4096];
|
||||
|
||||
if (!id_write_format(&vg->id, buffer, sizeof(buffer))) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
if (!id_write_format(&vg->id, buffer, sizeof(buffer)))
|
||||
return_0;
|
||||
|
||||
outf(f, "id = \"%s\"", buffer);
|
||||
|
||||
outf(f, "seqno = %u", vg->seqno);
|
||||
|
||||
if (!print_flags(vg->status, VG_FLAGS, buffer, sizeof(buffer))) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
if (!print_flags(vg->status, VG_FLAGS, buffer, sizeof(buffer)))
|
||||
return_0;
|
||||
outf(f, "status = %s", buffer);
|
||||
|
||||
if (!list_empty(&vg->tags)) {
|
||||
if (!print_tags(&vg->tags, buffer, sizeof(buffer))) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
if (!print_tags(&vg->tags, buffer, sizeof(buffer)))
|
||||
return_0;
|
||||
outf(f, "tags = %s", buffer);
|
||||
}
|
||||
|
||||
@ -350,10 +340,8 @@ static int _print_vg(struct formatter *f, struct volume_group *vg)
|
||||
outf(f, "system_id = \"%s\"", vg->system_id);
|
||||
|
||||
if (!out_size(f, (uint64_t) vg->extent_size, "extent_size = %u",
|
||||
vg->extent_size)) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
vg->extent_size))
|
||||
return_0;
|
||||
outf(f, "max_lv = %u", vg->max_lv);
|
||||
outf(f, "max_pv = %u", vg->max_pv);
|
||||
|
||||
@ -390,52 +378,38 @@ static int _print_pvs(struct formatter *f, struct volume_group *vg)
|
||||
list_iterate_items(pvl, &vg->pvs) {
|
||||
pv = pvl->pv;
|
||||
|
||||
if (!(name = _get_pv_name(f, pv))) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
if (!(name = _get_pv_name(f, pv)))
|
||||
return_0;
|
||||
|
||||
outnl(f);
|
||||
outf(f, "%s {", name);
|
||||
_inc_indent(f);
|
||||
|
||||
if (!id_write_format(&pv->id, buffer, sizeof(buffer))) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
if (!id_write_format(&pv->id, buffer, sizeof(buffer)))
|
||||
return_0;
|
||||
|
||||
outf(f, "id = \"%s\"", buffer);
|
||||
if (!out_hint(f, "device = \"%s\"", pv_dev_name(pv))) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
if (!out_hint(f, "device = \"%s\"", pv_dev_name(pv)))
|
||||
return_0;
|
||||
outnl(f);
|
||||
|
||||
if (!print_flags(pv->status, PV_FLAGS, buffer, sizeof(buffer))) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
if (!print_flags(pv->status, PV_FLAGS, buffer, sizeof(buffer)))
|
||||
return_0;
|
||||
outf(f, "status = %s", buffer);
|
||||
|
||||
if (!list_empty(&pv->tags)) {
|
||||
if (!print_tags(&pv->tags, buffer, sizeof(buffer))) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
if (!print_tags(&pv->tags, buffer, sizeof(buffer)))
|
||||
return_0;
|
||||
outf(f, "tags = %s", buffer);
|
||||
}
|
||||
|
||||
if (!out_size(f, pv->size, "dev_size = %" PRIu64, pv->size)) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
if (!out_size(f, pv->size, "dev_size = %" PRIu64, pv->size))
|
||||
return_0;
|
||||
|
||||
outf(f, "pe_start = %" PRIu64, pv->pe_start);
|
||||
if (!out_size(f, vg->extent_size * (uint64_t) pv->pe_count,
|
||||
"pe_count = %u", pv->pe_count)) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
"pe_count = %u", pv->pe_count))
|
||||
return_0;
|
||||
|
||||
_dec_indent(f);
|
||||
outf(f, "}");
|
||||
@ -456,27 +430,21 @@ static int _print_segment(struct formatter *f, struct volume_group *vg,
|
||||
|
||||
outf(f, "start_extent = %u", seg->le);
|
||||
if (!out_size(f, (uint64_t) seg->len * vg->extent_size,
|
||||
"extent_count = %u", seg->len)) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
"extent_count = %u", seg->len))
|
||||
return_0;
|
||||
|
||||
outnl(f);
|
||||
outf(f, "type = \"%s\"", seg->segtype->name);
|
||||
|
||||
if (!list_empty(&seg->tags)) {
|
||||
if (!print_tags(&seg->tags, buffer, sizeof(buffer))) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
if (!print_tags(&seg->tags, buffer, sizeof(buffer)))
|
||||
return_0;
|
||||
outf(f, "tags = %s", buffer);
|
||||
}
|
||||
|
||||
if (seg->segtype->ops->text_export &&
|
||||
!seg->segtype->ops->text_export(seg, f)) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
!seg->segtype->ops->text_export(seg, f))
|
||||
return_0;
|
||||
|
||||
_dec_indent(f);
|
||||
outf(f, "}");
|
||||
@ -498,10 +466,8 @@ int out_areas(struct formatter *f, const struct lv_segment *seg,
|
||||
for (s = 0; s < seg->area_count; s++) {
|
||||
switch (seg_type(seg, s)) {
|
||||
case AREA_PV:
|
||||
if (!(name = _get_pv_name(f, seg_pv(seg, s)))) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
if (!(name = _get_pv_name(f, seg_pv(seg, s))))
|
||||
return_0;
|
||||
|
||||
outf(f, "\"%s\", %u%s", name,
|
||||
seg_pe(seg, s),
|
||||
@ -534,24 +500,18 @@ static int _print_lv(struct formatter *f, struct logical_volume *lv)
|
||||
_inc_indent(f);
|
||||
|
||||
/* FIXME: Write full lvid */
|
||||
if (!id_write_format(&lv->lvid.id[1], buffer, sizeof(buffer))) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
if (!id_write_format(&lv->lvid.id[1], buffer, sizeof(buffer)))
|
||||
return_0;
|
||||
|
||||
outf(f, "id = \"%s\"", buffer);
|
||||
|
||||
if (!print_flags(lv->status, LV_FLAGS, buffer, sizeof(buffer))) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
if (!print_flags(lv->status, LV_FLAGS, buffer, sizeof(buffer)))
|
||||
return_0;
|
||||
outf(f, "status = %s", buffer);
|
||||
|
||||
if (!list_empty(&lv->tags)) {
|
||||
if (!print_tags(&lv->tags, buffer, sizeof(buffer))) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
if (!print_tags(&lv->tags, buffer, sizeof(buffer)))
|
||||
return_0;
|
||||
outf(f, "tags = %s", buffer);
|
||||
}
|
||||
|
||||
@ -579,10 +539,8 @@ static int _print_lv(struct formatter *f, struct logical_volume *lv)
|
||||
|
||||
seg_count = 1;
|
||||
list_iterate_items(seg, &lv->segments) {
|
||||
if (!_print_segment(f, lv->vg, seg_count++, seg)) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
if (!_print_segment(f, lv->vg, seg_count++, seg))
|
||||
return_0;
|
||||
}
|
||||
|
||||
_dec_indent(f);
|
||||
@ -610,19 +568,15 @@ static int _print_lvs(struct formatter *f, struct volume_group *vg)
|
||||
list_iterate_items(lvl, &vg->lvs) {
|
||||
if (!(lvl->lv->status & VISIBLE_LV))
|
||||
continue;
|
||||
if (!_print_lv(f, lvl->lv)) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
if (!_print_lv(f, lvl->lv))
|
||||
return_0;
|
||||
}
|
||||
|
||||
list_iterate_items(lvl, &vg->lvs) {
|
||||
if ((lvl->lv->status & VISIBLE_LV))
|
||||
continue;
|
||||
if (!_print_lv(f, lvl->lv)) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
if (!_print_lv(f, lvl->lv))
|
||||
return_0;
|
||||
}
|
||||
|
||||
_dec_indent(f);
|
||||
@ -671,10 +625,8 @@ static int _text_vg_export(struct formatter *f,
|
||||
{
|
||||
int r = 0;
|
||||
|
||||
if (!_build_pv_names(f, vg)) {
|
||||
stack;
|
||||
goto out;
|
||||
}
|
||||
if (!_build_pv_names(f, vg))
|
||||
goto_out;
|
||||
|
||||
if (f->header && !_print_header(f, desc))
|
||||
goto_out;
|
||||
@ -721,10 +673,8 @@ int text_vg_export_file(struct volume_group *vg, const char *desc, FILE *fp)
|
||||
|
||||
_init();
|
||||
|
||||
if (!(f = dm_malloc(sizeof(*f)))) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
if (!(f = dm_malloc(sizeof(*f))))
|
||||
return_0;
|
||||
|
||||
memset(f, 0, sizeof(*f));
|
||||
f->data.fp = fp;
|
||||
@ -748,10 +698,8 @@ int text_vg_export_raw(struct volume_group *vg, const char *desc, char **buf)
|
||||
|
||||
_init();
|
||||
|
||||
if (!(f = dm_malloc(sizeof(*f)))) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
if (!(f = dm_malloc(sizeof(*f))))
|
||||
return_0;
|
||||
|
||||
memset(f, 0, sizeof(*f));
|
||||
|
||||
@ -767,9 +715,8 @@ int text_vg_export_raw(struct volume_group *vg, const char *desc, char **buf)
|
||||
f->nl = &_nl_raw;
|
||||
|
||||
if (!_text_vg_export(f, vg, desc)) {
|
||||
stack;
|
||||
dm_free(f->data.buf.start);
|
||||
goto out;
|
||||
goto_out;
|
||||
}
|
||||
|
||||
r = f->data.buf.used + 1;
|
||||
|
@ -91,10 +91,8 @@ int print_flags(uint32_t status, int type, char *buffer, size_t size)
|
||||
int f, first = 1;
|
||||
struct flag *flags;
|
||||
|
||||
if (!(flags = _get_flags(type))) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
if (!(flags = _get_flags(type)))
|
||||
return_0;
|
||||
|
||||
if (!emit_to_buffer(&buffer, &size, "["))
|
||||
return 0;
|
||||
@ -135,10 +133,8 @@ int read_flags(uint32_t *status, int type, struct config_value *cv)
|
||||
uint32_t s = 0;
|
||||
struct flag *flags;
|
||||
|
||||
if (!(flags = _get_flags(type))) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
if (!(flags = _get_flags(type)))
|
||||
return_0;
|
||||
|
||||
if (cv->type == CFG_EMPTY_ARRAY)
|
||||
goto out;
|
||||
|
@ -297,40 +297,38 @@ static struct mda_header *_raw_read_mda_header(const struct format_type *fmt,
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (!dev_read(dev_area->dev, dev_area->start, MDA_HEADER_SIZE, mdah)) {
|
||||
stack;
|
||||
goto error;
|
||||
}
|
||||
if (!dev_read(dev_area->dev, dev_area->start, MDA_HEADER_SIZE, mdah))
|
||||
goto_bad;
|
||||
|
||||
if (mdah->checksum_xl != xlate32(calc_crc(INITIAL_CRC, mdah->magic,
|
||||
MDA_HEADER_SIZE -
|
||||
sizeof(mdah->checksum_xl)))) {
|
||||
log_error("Incorrect metadata area header checksum");
|
||||
goto error;
|
||||
goto bad;
|
||||
}
|
||||
|
||||
_xlate_mdah(mdah);
|
||||
|
||||
if (strncmp((char *)mdah->magic, FMTT_MAGIC, sizeof(mdah->magic))) {
|
||||
log_error("Wrong magic number in metadata area header");
|
||||
goto error;
|
||||
goto bad;
|
||||
}
|
||||
|
||||
if (mdah->version != FMTT_VERSION) {
|
||||
log_error("Incompatible metadata area header version: %d",
|
||||
mdah->version);
|
||||
goto error;
|
||||
goto bad;
|
||||
}
|
||||
|
||||
if (mdah->start != dev_area->start) {
|
||||
log_error("Incorrect start sector in metadata area header: %"
|
||||
PRIu64, mdah->start);
|
||||
goto error;
|
||||
goto bad;
|
||||
}
|
||||
|
||||
return mdah;
|
||||
|
||||
error:
|
||||
bad:
|
||||
dm_pool_free(fmt->cmd->mem, mdah);
|
||||
return NULL;
|
||||
}
|
||||
@ -349,9 +347,8 @@ static int _raw_write_mda_header(const struct format_type *fmt,
|
||||
sizeof(mdah->checksum_xl)));
|
||||
|
||||
if (!dev_write(dev, start_byte, MDA_HEADER_SIZE, mdah)) {
|
||||
stack;
|
||||
dm_pool_free(fmt->cmd->mem, mdah);
|
||||
return 0;
|
||||
return_0;
|
||||
}
|
||||
|
||||
return 1;
|
||||
@ -380,17 +377,15 @@ static struct raw_locn *_find_vg_rlocn(struct device_area *dev_area,
|
||||
/* FIXME Loop through rlocns two-at-a-time. List null-terminated. */
|
||||
/* FIXME Ignore if checksum incorrect!!! */
|
||||
if (!dev_read(dev_area->dev, dev_area->start + rlocn->offset,
|
||||
sizeof(vgnamebuf), vgnamebuf)) {
|
||||
stack;
|
||||
goto error;
|
||||
}
|
||||
sizeof(vgnamebuf), vgnamebuf))
|
||||
goto_bad;
|
||||
|
||||
if (!strncmp(vgnamebuf, vgname, len = strlen(vgname)) &&
|
||||
(isspace(vgnamebuf[len]) || vgnamebuf[len] == '{')) {
|
||||
return rlocn;
|
||||
}
|
||||
|
||||
error:
|
||||
bad:
|
||||
if ((info = info_from_pvid(dev_area->dev->pvid, 0)))
|
||||
lvmcache_update_vgname_and_id(info, ORPHAN, ORPHAN, 0, NULL);
|
||||
|
||||
@ -422,15 +417,11 @@ static int _raw_holds_vgname(struct format_instance *fid,
|
||||
int noprecommit = 0;
|
||||
struct mda_header *mdah;
|
||||
|
||||
if (!dev_open(dev_area->dev)) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
if (!dev_open(dev_area->dev))
|
||||
return_0;
|
||||
|
||||
if (!(mdah = _raw_read_mda_header(fid->fmt, dev_area))) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
if (!(mdah = _raw_read_mda_header(fid->fmt, dev_area)))
|
||||
return_0;
|
||||
|
||||
if (_find_vg_rlocn(dev_area, mdah, vgname, &noprecommit))
|
||||
r = 1;
|
||||
@ -453,15 +444,11 @@ static struct volume_group *_vg_read_raw_area(struct format_instance *fid,
|
||||
char *desc;
|
||||
uint32_t wrap = 0;
|
||||
|
||||
if (!dev_open(area->dev)) {
|
||||
stack;
|
||||
return NULL;
|
||||
}
|
||||
if (!dev_open(area->dev))
|
||||
return_NULL;
|
||||
|
||||
if (!(mdah = _raw_read_mda_header(fid->fmt, area))) {
|
||||
stack;
|
||||
goto out;
|
||||
}
|
||||
if (!(mdah = _raw_read_mda_header(fid->fmt, area)))
|
||||
goto_out;
|
||||
|
||||
if (!(rlocn = _find_vg_rlocn(area, mdah, vgname, &precommitted))) {
|
||||
log_debug("VG %s not found on %s", vgname, dev_name(area->dev));
|
||||
@ -483,10 +470,8 @@ static struct volume_group *_vg_read_raw_area(struct format_instance *fid,
|
||||
(uint32_t) (rlocn->size - wrap),
|
||||
(off_t) (area->start + MDA_HEADER_SIZE),
|
||||
wrap, calc_crc, rlocn->checksum, &when,
|
||||
&desc))) {
|
||||
stack;
|
||||
goto out;
|
||||
}
|
||||
&desc)))
|
||||
goto_out;
|
||||
log_debug("Read %s %smetadata (%u) from %s at %" PRIu64 " size %"
|
||||
PRIu64, vg->name, precommitted ? "pre-commit " : "",
|
||||
vg->seqno, dev_name(area->dev),
|
||||
@ -544,15 +529,11 @@ static int _vg_write_raw(struct format_instance *fid, struct volume_group *vg,
|
||||
if (!found)
|
||||
return 1;
|
||||
|
||||
if (!dev_open(mdac->area.dev)) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
if (!dev_open(mdac->area.dev))
|
||||
return_0;
|
||||
|
||||
if (!(mdah = _raw_read_mda_header(fid->fmt, &mdac->area))) {
|
||||
stack;
|
||||
goto out;
|
||||
}
|
||||
if (!(mdah = _raw_read_mda_header(fid->fmt, &mdac->area)))
|
||||
goto_out;
|
||||
|
||||
rlocn = _find_vg_rlocn(&mdac->area, mdah, vg->name, &noprecommit);
|
||||
mdac->rlocn.offset = _next_rlocn_offset(rlocn, mdah);
|
||||
@ -589,10 +570,8 @@ static int _vg_write_raw(struct format_instance *fid, struct volume_group *vg,
|
||||
/* Write text out, circularly */
|
||||
if (!dev_write(mdac->area.dev, mdac->area.start + mdac->rlocn.offset,
|
||||
(size_t) (mdac->rlocn.size - new_wrap),
|
||||
fidtc->raw_metadata_buf)) {
|
||||
stack;
|
||||
goto out;
|
||||
}
|
||||
fidtc->raw_metadata_buf))
|
||||
goto_out;
|
||||
|
||||
if (new_wrap) {
|
||||
log_debug("Writing metadata to %s at %" PRIu64 " len %" PRIu32,
|
||||
@ -603,10 +582,8 @@ static int _vg_write_raw(struct format_instance *fid, struct volume_group *vg,
|
||||
mdac->area.start + MDA_HEADER_SIZE,
|
||||
(size_t) new_wrap,
|
||||
fidtc->raw_metadata_buf +
|
||||
mdac->rlocn.size - new_wrap)) {
|
||||
stack;
|
||||
goto out;
|
||||
}
|
||||
mdac->rlocn.size - new_wrap))
|
||||
goto_out;
|
||||
}
|
||||
|
||||
mdac->rlocn.checksum = calc_crc(INITIAL_CRC, fidtc->raw_metadata_buf,
|
||||
@ -652,10 +629,8 @@ static int _vg_commit_raw_rlocn(struct format_instance *fid,
|
||||
if (!found)
|
||||
return 1;
|
||||
|
||||
if (!(mdah = _raw_read_mda_header(fid->fmt, &mdac->area))) {
|
||||
stack;
|
||||
goto out;
|
||||
}
|
||||
if (!(mdah = _raw_read_mda_header(fid->fmt, &mdac->area)))
|
||||
goto_out;
|
||||
|
||||
if (!(rlocn = _find_vg_rlocn(&mdac->area, mdah, vg->name, &noprecommit))) {
|
||||
mdah->raw_locns[0].offset = 0;
|
||||
@ -759,15 +734,11 @@ static int _vg_remove_raw(struct format_instance *fid, struct volume_group *vg,
|
||||
int r = 0;
|
||||
int noprecommit = 0;
|
||||
|
||||
if (!dev_open(mdac->area.dev)) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
if (!dev_open(mdac->area.dev))
|
||||
return_0;
|
||||
|
||||
if (!(mdah = _raw_read_mda_header(fid->fmt, &mdac->area))) {
|
||||
stack;
|
||||
goto out;
|
||||
}
|
||||
if (!(mdah = _raw_read_mda_header(fid->fmt, &mdac->area)))
|
||||
goto_out;
|
||||
|
||||
if (!(rlocn = _find_vg_rlocn(&mdac->area, mdah, vg->name, &noprecommit))) {
|
||||
rlocn = &mdah->raw_locns[0];
|
||||
@ -801,10 +772,8 @@ static struct volume_group *_vg_read_file_name(struct format_instance *fid,
|
||||
time_t when;
|
||||
char *desc;
|
||||
|
||||
if (!(vg = text_vg_import_file(fid, read_path, &when, &desc))) {
|
||||
stack;
|
||||
return NULL;
|
||||
}
|
||||
if (!(vg = text_vg_import_file(fid, read_path, &when, &desc)))
|
||||
return_NULL;
|
||||
|
||||
/*
|
||||
* Currently you can only have a single volume group per
|
||||
@ -1065,10 +1034,8 @@ const char *vgname_from_mda(const struct format_type *fmt,
|
||||
if (mda_free_sectors)
|
||||
*mda_free_sectors = ((dev_area->size - MDA_HEADER_SIZE) / 2) >> SECTOR_SHIFT;
|
||||
|
||||
if (!dev_open(dev_area->dev)) {
|
||||
stack;
|
||||
return NULL;
|
||||
}
|
||||
if (!dev_open(dev_area->dev))
|
||||
return_NULL;
|
||||
|
||||
if (!(mdah = _raw_read_mda_header(fmt, dev_area)))
|
||||
goto_out;
|
||||
@ -1114,15 +1081,13 @@ const char *vgname_from_mda(const struct format_type *fmt,
|
||||
|
||||
/* Ignore this entry if the characters aren't permissible */
|
||||
if (!validate_name(vgname)) {
|
||||
stack;
|
||||
vgname = NULL;
|
||||
goto out;
|
||||
goto_out;
|
||||
}
|
||||
|
||||
if (!id_write_format(vgid, uuid, sizeof(uuid))) {
|
||||
stack;
|
||||
vgname = NULL;
|
||||
goto out;
|
||||
goto_out;
|
||||
}
|
||||
|
||||
log_debug("%s: Found metadata at %" PRIu64 " size %" PRIu64
|
||||
@ -1328,10 +1293,8 @@ static int _text_pv_write(const struct format_type *fmt, struct physical_volume
|
||||
/* FIXME Test mode don't update cache? */
|
||||
|
||||
if (!(info = lvmcache_add(fmt->labeller, (char *) &pv->id, pv->dev,
|
||||
ORPHAN, NULL, 0))) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
ORPHAN, NULL, 0)))
|
||||
return_0;
|
||||
label = info->label;
|
||||
|
||||
if (label_sector != -1)
|
||||
@ -1384,15 +1347,11 @@ static int _text_pv_write(const struct format_type *fmt, struct physical_volume
|
||||
}
|
||||
}
|
||||
if (!add_da
|
||||
(NULL, &info->das, pv->pe_start << SECTOR_SHIFT, UINT64_C(0))) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
(NULL, &info->das, pv->pe_start << SECTOR_SHIFT, UINT64_C(0)))
|
||||
return_0;
|
||||
|
||||
if (!dev_open(pv->dev)) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
if (!dev_open(pv->dev))
|
||||
return_0;
|
||||
|
||||
list_iterate_items(mda, &info->mdas) {
|
||||
mdac = mda->metadata_locn;
|
||||
@ -1400,19 +1359,16 @@ static int _text_pv_write(const struct format_type *fmt, struct physical_volume
|
||||
mdah->size = mdac->area.size;
|
||||
if (!_raw_write_mda_header(fmt, mdac->area.dev,
|
||||
mdac->area.start, mdah)) {
|
||||
stack;
|
||||
if (!dev_close(pv->dev))
|
||||
stack;
|
||||
return 0;
|
||||
return_0;
|
||||
}
|
||||
}
|
||||
|
||||
label_write(pv->dev, label);
|
||||
|
||||
if (!dev_close(pv->dev)) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
if (!dev_close(pv->dev))
|
||||
return_0;
|
||||
|
||||
return 1;
|
||||
}
|
||||
@ -1449,16 +1405,12 @@ static int _text_pv_read(const struct format_type *fmt, const char *pv_name,
|
||||
struct mda_context *mdac, *mdac_new;
|
||||
struct data_area_list *da;
|
||||
|
||||
if (!(dev = dev_cache_get(pv_name, fmt->cmd->filter))) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
if (!(dev = dev_cache_get(pv_name, fmt->cmd->filter)))
|
||||
return_0;
|
||||
|
||||
/* FIXME Optimise out repeated reading when cache lock held */
|
||||
if (!(label_read(dev, &label, UINT64_C(0)))) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
if (!(label_read(dev, &label, UINT64_C(0))))
|
||||
return_0;
|
||||
info = (struct lvmcache_info *) label->info;
|
||||
|
||||
/* Have we already cached vgname? */
|
||||
@ -1642,16 +1594,12 @@ static int _text_pv_setup(const struct format_type *fmt,
|
||||
continue;
|
||||
|
||||
if (!(mda_new = dm_pool_alloc(fmt->cmd->mem,
|
||||
sizeof(*mda_new)))) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
sizeof(*mda_new))))
|
||||
return_0;
|
||||
|
||||
if (!(mdac_new = dm_pool_alloc(fmt->cmd->mem,
|
||||
sizeof(*mdac_new)))) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
sizeof(*mdac_new))))
|
||||
return_0;
|
||||
/* FIXME multiple dev_areas inside area */
|
||||
memcpy(mda_new, mda, sizeof(*mda));
|
||||
memcpy(mdac_new, mdac, sizeof(*mdac));
|
||||
@ -1687,11 +1635,8 @@ static int _text_pv_setup(const struct format_type *fmt,
|
||||
if (extent_count)
|
||||
pe_end = pe_start + extent_count * extent_size - 1;
|
||||
if (!_mda_setup(fmt, pe_start, pe_end, pvmetadatacopies,
|
||||
pvmetadatasize, mdas, pv, vg)) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
|
||||
pvmetadatasize, mdas, pv, vg))
|
||||
return_0;
|
||||
}
|
||||
|
||||
return 1;
|
||||
@ -1732,10 +1677,8 @@ static struct format_instance *_text_create_text_instance(const struct format_ty
|
||||
list_init(&fid->metadata_areas);
|
||||
|
||||
if (!vgname) {
|
||||
if (!(mda = dm_pool_alloc(fmt->cmd->mem, sizeof(*mda)))) {
|
||||
stack;
|
||||
return NULL;
|
||||
}
|
||||
if (!(mda = dm_pool_alloc(fmt->cmd->mem, sizeof(*mda))))
|
||||
return_NULL;
|
||||
mda->ops = &_metadata_text_file_backup_ops;
|
||||
mda->metadata_locn = context;
|
||||
list_add(&fid->metadata_areas, &mda->list);
|
||||
@ -1751,10 +1694,8 @@ static struct format_instance *_text_create_text_instance(const struct format_ty
|
||||
}
|
||||
|
||||
context = create_text_context(fmt->cmd, path, NULL);
|
||||
if (!(mda = dm_pool_alloc(fmt->cmd->mem, sizeof(*mda)))) {
|
||||
stack;
|
||||
return NULL;
|
||||
}
|
||||
if (!(mda = dm_pool_alloc(fmt->cmd->mem, sizeof(*mda))))
|
||||
return_NULL;
|
||||
mda->ops = &_metadata_text_file_ops;
|
||||
mda->metadata_locn = context;
|
||||
list_add(&fid->metadata_areas, &mda->list);
|
||||
@ -1767,15 +1708,11 @@ static struct format_instance *_text_create_text_instance(const struct format_ty
|
||||
if (!_raw_holds_vgname(fid, &rl->dev_area, vgname))
|
||||
continue;
|
||||
|
||||
if (!(mda = dm_pool_alloc(fmt->cmd->mem, sizeof(*mda)))) {
|
||||
stack;
|
||||
return NULL;
|
||||
}
|
||||
if (!(mda = dm_pool_alloc(fmt->cmd->mem, sizeof(*mda))))
|
||||
return_NULL;
|
||||
|
||||
if (!(mdac = dm_pool_alloc(fmt->cmd->mem, sizeof(*mdac)))) {
|
||||
stack;
|
||||
return NULL;
|
||||
}
|
||||
if (!(mdac = dm_pool_alloc(fmt->cmd->mem, sizeof(*mdac))))
|
||||
return_NULL;
|
||||
mda->metadata_locn = mdac;
|
||||
/* FIXME Allow multiple dev_areas inside area */
|
||||
memcpy(&mdac->area, &rl->dev_area, sizeof(mdac->area));
|
||||
@ -1786,10 +1723,8 @@ static struct format_instance *_text_create_text_instance(const struct format_ty
|
||||
|
||||
/* Scan PVs in VG for any further MDAs */
|
||||
lvmcache_label_scan(fmt->cmd, 0);
|
||||
if (!(vginfo = vginfo_from_vgname(vgname, vgid))) {
|
||||
stack;
|
||||
goto out;
|
||||
}
|
||||
if (!(vginfo = vginfo_from_vgname(vgname, vgid)))
|
||||
goto_out;
|
||||
list_iterate_items(info, &vginfo->infos) {
|
||||
mdas = &info->mdas;
|
||||
list_iterate_items(mda, mdas) {
|
||||
@ -1798,16 +1733,12 @@ static struct format_instance *_text_create_text_instance(const struct format_ty
|
||||
|
||||
/* FIXME Check it holds this VG */
|
||||
if (!(mda_new = dm_pool_alloc(fmt->cmd->mem,
|
||||
sizeof(*mda_new)))) {
|
||||
stack;
|
||||
return NULL;
|
||||
}
|
||||
sizeof(*mda_new))))
|
||||
return_NULL;
|
||||
|
||||
if (!(mdac_new = dm_pool_alloc(fmt->cmd->mem,
|
||||
sizeof(*mdac_new)))) {
|
||||
stack;
|
||||
return NULL;
|
||||
}
|
||||
sizeof(*mdac_new))))
|
||||
return_NULL;
|
||||
/* FIXME multiple dev_areas inside area */
|
||||
memcpy(mda_new, mda, sizeof(*mda));
|
||||
memcpy(mdac_new, mdac, sizeof(*mdac));
|
||||
@ -1834,33 +1765,26 @@ void *create_text_context(struct cmd_context *cmd, const char *path,
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (!(tc = dm_pool_alloc(cmd->mem, sizeof(*tc)))) {
|
||||
stack;
|
||||
return NULL;
|
||||
}
|
||||
if (!(tc = dm_pool_alloc(cmd->mem, sizeof(*tc))))
|
||||
return_NULL;
|
||||
|
||||
if (!(tc->path_live = dm_pool_strdup(cmd->mem, path))) {
|
||||
stack;
|
||||
goto no_mem;
|
||||
}
|
||||
if (!(tc->path_live = dm_pool_strdup(cmd->mem, path)))
|
||||
goto_bad;
|
||||
|
||||
if (!(tc->path_edit = dm_pool_alloc(cmd->mem, strlen(path) + 5)))
|
||||
goto_bad;
|
||||
|
||||
if (!(tc->path_edit = dm_pool_alloc(cmd->mem, strlen(path) + 5))) {
|
||||
stack;
|
||||
goto no_mem;
|
||||
}
|
||||
sprintf(tc->path_edit, "%s.tmp", path);
|
||||
|
||||
if (!desc)
|
||||
desc = "";
|
||||
|
||||
if (!(tc->desc = dm_pool_strdup(cmd->mem, desc))) {
|
||||
stack;
|
||||
goto no_mem;
|
||||
}
|
||||
if (!(tc->desc = dm_pool_strdup(cmd->mem, desc)))
|
||||
goto_bad;
|
||||
|
||||
return (void *) tc;
|
||||
|
||||
no_mem:
|
||||
bad:
|
||||
dm_pool_free(cmd->mem, tc);
|
||||
|
||||
log_err("Couldn't allocate text format context object.");
|
||||
@ -1956,10 +1880,8 @@ struct format_type *create_text_format(struct cmd_context *cmd)
|
||||
struct config_value *cv;
|
||||
struct mda_lists *mda_lists;
|
||||
|
||||
if (!(fmt = dm_malloc(sizeof(*fmt)))) {
|
||||
stack;
|
||||
return NULL;
|
||||
}
|
||||
if (!(fmt = dm_malloc(sizeof(*fmt))))
|
||||
return_NULL;
|
||||
|
||||
fmt->cmd = cmd;
|
||||
fmt->ops = &_text_handler;
|
||||
|
@ -111,10 +111,8 @@ struct volume_group *text_vg_import_fd(struct format_instance *fid,
|
||||
if (!(*vsn)->check_version(cft))
|
||||
continue;
|
||||
|
||||
if (!(vg = (*vsn)->read_vg(fid, cft))) {
|
||||
stack;
|
||||
goto out;
|
||||
}
|
||||
if (!(vg = (*vsn)->read_vg(fid, cft)))
|
||||
goto_out;
|
||||
|
||||
(*vsn)->read_desc(fid->fmt->cmd->mem, cft, when, desc);
|
||||
break;
|
||||
|
@ -136,10 +136,8 @@ static int _read_pv(struct format_instance *fid, struct dm_pool *mem,
|
||||
uint64_t size;
|
||||
|
||||
if (!(pvl = dm_pool_zalloc(mem, sizeof(*pvl))) ||
|
||||
!(pvl->pv = dm_pool_zalloc(mem, sizeof(*pvl->pv)))) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
!(pvl->pv = dm_pool_zalloc(mem, sizeof(*pvl->pv))))
|
||||
return_0;
|
||||
|
||||
pv = pvl->pv;
|
||||
|
||||
@ -147,10 +145,8 @@ static int _read_pv(struct format_instance *fid, struct dm_pool *mem,
|
||||
* Add the pv to the pv hash for quick lookup when we read
|
||||
* the lv segments.
|
||||
*/
|
||||
if (!dm_hash_insert(pv_hash, pvn->key, pv)) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
if (!dm_hash_insert(pv_hash, pvn->key, pv))
|
||||
return_0;
|
||||
|
||||
if (!(pvn = pvn->child)) {
|
||||
log_error("Empty pv section.");
|
||||
@ -180,10 +176,8 @@ static int _read_pv(struct format_instance *fid, struct dm_pool *mem,
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!(pv->vg_name = dm_pool_strdup(mem, vg->name))) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
if (!(pv->vg_name = dm_pool_strdup(mem, vg->name)))
|
||||
return_0;
|
||||
|
||||
memcpy(&pv->vgid, &vg->id, sizeof(vg->id));
|
||||
|
||||
@ -250,10 +244,8 @@ static int _read_pv(struct format_instance *fid, struct dm_pool *mem,
|
||||
}
|
||||
}
|
||||
|
||||
if (!alloc_pv_segment_whole_pv(mem, pv)) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
if (!alloc_pv_segment_whole_pv(mem, pv))
|
||||
return_0;
|
||||
|
||||
vg->pv_count++;
|
||||
list_add(&vg->pvs, &pvl->list);
|
||||
@ -316,16 +308,12 @@ static int _read_segment(struct dm_pool *mem, struct volume_group *vg,
|
||||
segtype_str = cv->v.str;
|
||||
}
|
||||
|
||||
if (!(segtype = get_segtype_from_string(vg->cmd, segtype_str))) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
if (!(segtype = get_segtype_from_string(vg->cmd, segtype_str)))
|
||||
return_0;
|
||||
|
||||
if (segtype->ops->text_import_area_count &&
|
||||
!segtype->ops->text_import_area_count(sn, &area_count)) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
!segtype->ops->text_import_area_count(sn, &area_count))
|
||||
return_0;
|
||||
|
||||
if (!(seg = alloc_lv_segment(mem, segtype, lv, start_extent,
|
||||
extent_count, 0, 0, NULL, area_count,
|
||||
@ -335,10 +323,8 @@ static int _read_segment(struct dm_pool *mem, struct volume_group *vg,
|
||||
}
|
||||
|
||||
if (seg->segtype->ops->text_import &&
|
||||
!seg->segtype->ops->text_import(seg, sn, pv_hash)) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
!seg->segtype->ops->text_import(seg, sn, pv_hash))
|
||||
return_0;
|
||||
|
||||
/* Optional tags */
|
||||
if ((cn = find_config_node(sn, "tags")) &&
|
||||
@ -403,10 +389,8 @@ int text_import_areas(struct lv_segment *seg, const struct config_node *sn,
|
||||
|
||||
/* FIXME Cope if LV not yet read in */
|
||||
if ((pv = dm_hash_lookup(pv_hash, cv->v.str))) {
|
||||
if (!set_lv_segment_area_pv(seg, s, pv, (uint32_t) cv->next->v.i)) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
if (!set_lv_segment_area_pv(seg, s, pv, (uint32_t) cv->next->v.i))
|
||||
return_0;
|
||||
} else if ((lv1 = find_lv(seg->lv->vg, cv->v.str))) {
|
||||
if (!set_lv_segment_area_lv(seg, s, lv1,
|
||||
(uint32_t) cv->next->v.i,
|
||||
@ -447,10 +431,8 @@ static int _read_segments(struct dm_pool *mem, struct volume_group *vg,
|
||||
* All sub-sections are assumed to be segments.
|
||||
*/
|
||||
if (!sn->v) {
|
||||
if (!_read_segment(mem, vg, lv, sn, pv_hash)) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
if (!_read_segment(mem, vg, lv, sn, pv_hash))
|
||||
return_0;
|
||||
|
||||
count++;
|
||||
}
|
||||
@ -475,18 +457,14 @@ static int _read_segments(struct dm_pool *mem, struct volume_group *vg,
|
||||
/*
|
||||
* Check there are no gaps or overlaps in the lv.
|
||||
*/
|
||||
if (!check_lv_segments(lv, 0)) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
if (!check_lv_segments(lv, 0))
|
||||
return_0;
|
||||
|
||||
/*
|
||||
* Merge segments in case someones been editing things by hand.
|
||||
*/
|
||||
if (!lv_merge_segments(lv)) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
if (!lv_merge_segments(lv))
|
||||
return_0;
|
||||
|
||||
return 1;
|
||||
}
|
||||
@ -502,17 +480,13 @@ static int _read_lvnames(struct format_instance *fid __attribute((unused)),
|
||||
struct config_node *cn;
|
||||
|
||||
if (!(lvl = dm_pool_zalloc(mem, sizeof(*lvl))) ||
|
||||
!(lvl->lv = dm_pool_zalloc(mem, sizeof(*lvl->lv)))) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
!(lvl->lv = dm_pool_zalloc(mem, sizeof(*lvl->lv))))
|
||||
return_0;
|
||||
|
||||
lv = lvl->lv;
|
||||
|
||||
if (!(lv->name = dm_pool_strdup(mem, lvn->key))) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
if (!(lv->name = dm_pool_strdup(mem, lvn->key)))
|
||||
return_0;
|
||||
|
||||
if (!(lvn = lvn->child)) {
|
||||
log_error("Empty logical volume section.");
|
||||
@ -538,10 +512,8 @@ static int _read_lvnames(struct format_instance *fid __attribute((unused)),
|
||||
}
|
||||
|
||||
lv->alloc = get_alloc_from_string(cv->v.str);
|
||||
if (lv->alloc == ALLOC_INVALID) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
if (lv->alloc == ALLOC_INVALID)
|
||||
return_0;
|
||||
}
|
||||
|
||||
if (!_read_int32(lvn, "read_ahead", &lv->read_ahead))
|
||||
@ -611,10 +583,8 @@ static int _read_lvsegs(struct format_instance *fid __attribute((unused)),
|
||||
|
||||
memcpy(&lv->lvid.id[0], &lv->vg->id, sizeof(lv->lvid.id[0]));
|
||||
|
||||
if (!_read_segments(mem, vg, lv, lvn, pv_hash)) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
if (!_read_segments(mem, vg, lv, lvn, pv_hash))
|
||||
return_0;
|
||||
|
||||
lv->size = (uint64_t) lv->le_count * (uint64_t) vg->extent_size;
|
||||
|
||||
@ -664,10 +634,8 @@ static int _read_sections(struct format_instance *fid,
|
||||
}
|
||||
|
||||
for (n = n->child; n; n = n->sib) {
|
||||
if (!fn(fid, mem, vg, n, vgn, pv_hash)) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
if (!fn(fid, mem, vg, n, vgn, pv_hash))
|
||||
return_0;
|
||||
}
|
||||
|
||||
return 1;
|
||||
@ -689,10 +657,8 @@ static struct volume_group *_read_vg(struct format_instance *fid,
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (!(vg = dm_pool_zalloc(mem, sizeof(*vg)))) {
|
||||
stack;
|
||||
return NULL;
|
||||
}
|
||||
if (!(vg = dm_pool_zalloc(mem, sizeof(*vg))))
|
||||
return_NULL;
|
||||
vg->cmd = fid->fmt->cmd;
|
||||
|
||||
/* FIXME Determine format type from file contents */
|
||||
@ -770,10 +736,8 @@ static struct volume_group *_read_vg(struct format_instance *fid,
|
||||
}
|
||||
|
||||
vg->alloc = get_alloc_from_string(cv->v.str);
|
||||
if (vg->alloc == ALLOC_INVALID) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
if (vg->alloc == ALLOC_INVALID)
|
||||
return_0;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -24,30 +24,22 @@ int print_tags(struct list *tags, char *buffer, size_t size)
|
||||
struct str_list *sl;
|
||||
int first = 1;
|
||||
|
||||
if (!emit_to_buffer(&buffer, &size, "[")) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
if (!emit_to_buffer(&buffer, &size, "["))
|
||||
return_0;
|
||||
|
||||
list_iterate_items(sl, tags) {
|
||||
if (!first) {
|
||||
if (!emit_to_buffer(&buffer, &size, ", ")) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
if (!emit_to_buffer(&buffer, &size, ", "))
|
||||
return_0;
|
||||
} else
|
||||
first = 0;
|
||||
|
||||
if (!emit_to_buffer(&buffer, &size, "\"%s\"", sl->str)) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
if (!emit_to_buffer(&buffer, &size, "\"%s\"", sl->str))
|
||||
return_0;
|
||||
}
|
||||
|
||||
if (!emit_to_buffer(&buffer, &size, "]")) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
if (!emit_to_buffer(&buffer, &size, "]"))
|
||||
return_0;
|
||||
|
||||
return 1;
|
||||
}
|
||||
@ -63,10 +55,8 @@ int read_tags(struct dm_pool *mem, struct list *tags, struct config_value *cv)
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!str_list_add(mem, tags, dm_pool_strdup(mem, cv->v.str))) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
if (!str_list_add(mem, tags, dm_pool_strdup(mem, cv->v.str)))
|
||||
return_0;
|
||||
|
||||
cv = cv->next;
|
||||
}
|
||||
|
@ -86,10 +86,8 @@ int label_register_handler(const char *name, struct labeller *handler)
|
||||
{
|
||||
struct labeller_i *li;
|
||||
|
||||
if (!(li = _alloc_li(name, handler))) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
if (!(li = _alloc_li(name, handler)))
|
||||
return_0;
|
||||
|
||||
list_add(&_labellers, &li->list);
|
||||
return 1;
|
||||
@ -203,10 +201,8 @@ int label_remove(struct device *dev)
|
||||
|
||||
log_very_verbose("Scanning for labels to wipe from %s", dev_name(dev));
|
||||
|
||||
if (!dev_open(dev)) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
if (!dev_open(dev))
|
||||
return_0;
|
||||
|
||||
/*
|
||||
* We flush the device just in case someone is stupid
|
||||
@ -322,18 +318,14 @@ int label_write(struct device *dev, struct label *label)
|
||||
lh->sector_xl = xlate64(label->sector);
|
||||
lh->offset_xl = xlate32(sizeof(*lh));
|
||||
|
||||
if (!(label->labeller->ops->write)(label, buf)) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
if (!(label->labeller->ops->write)(label, buf))
|
||||
return_0;
|
||||
|
||||
lh->crc_xl = xlate32(calc_crc(INITIAL_CRC, &lh->offset_xl, LABEL_SIZE -
|
||||
((void *) &lh->offset_xl - (void *) lh)));
|
||||
|
||||
if (!dev_open(dev)) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
if (!dev_open(dev))
|
||||
return_0;
|
||||
|
||||
log_info("%s: Writing label to sector %" PRIu64, dev_name(dev),
|
||||
label->sector);
|
||||
|
@ -73,10 +73,8 @@ int init_external_locking(struct locking_type *locking, struct cmd_context *cmd)
|
||||
libname = find_config_tree_str(cmd, "global/locking_library",
|
||||
DEFAULT_LOCKING_LIB);
|
||||
|
||||
if (!(_locking_lib = load_shared_library(cmd, libname, "locking", 1))) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
if (!(_locking_lib = load_shared_library(cmd, libname, "locking", 1)))
|
||||
return_0;
|
||||
|
||||
/* Get the functions we need */
|
||||
if (!(_init_fn = dlsym(_locking_lib, "locking_init")) ||
|
||||
|
@ -178,15 +178,12 @@ struct lv_segment *alloc_lv_segment(struct dm_pool *mem,
|
||||
struct lv_segment *seg;
|
||||
uint32_t areas_sz = area_count * sizeof(*seg->areas);
|
||||
|
||||
if (!(seg = dm_pool_zalloc(mem, sizeof(*seg)))) {
|
||||
stack;
|
||||
return NULL;
|
||||
}
|
||||
if (!(seg = dm_pool_zalloc(mem, sizeof(*seg))))
|
||||
return_NULL;
|
||||
|
||||
if (!(seg->areas = dm_pool_zalloc(mem, areas_sz))) {
|
||||
dm_pool_free(mem, seg);
|
||||
stack;
|
||||
return NULL;
|
||||
return_NULL;
|
||||
}
|
||||
|
||||
if (!segtype) {
|
||||
@ -290,10 +287,8 @@ int move_lv_segment_area(struct lv_segment *seg_to, uint32_t area_to,
|
||||
seg_from->area_len);
|
||||
release_lv_segment_area(seg_to, area_to, seg_to->area_len);
|
||||
|
||||
if (!set_lv_segment_area_pv(seg_to, area_to, pv, pe)) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
if (!set_lv_segment_area_pv(seg_to, area_to, pv, pe))
|
||||
return_0;
|
||||
|
||||
break;
|
||||
|
||||
@ -326,10 +321,8 @@ int set_lv_segment_area_pv(struct lv_segment *seg, uint32_t area_num,
|
||||
seg->areas[area_num].type = AREA_PV;
|
||||
|
||||
if (!(seg_pvseg(seg, area_num) =
|
||||
assign_peg_to_lvseg(pv, pe, seg->area_len, seg, area_num))) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
assign_peg_to_lvseg(pv, pe, seg->area_len, seg, area_num)))
|
||||
return_0;
|
||||
|
||||
return 1;
|
||||
}
|
||||
@ -365,10 +358,8 @@ static int _lv_segment_add_areas(struct logical_volume *lv,
|
||||
struct lv_segment_area *newareas;
|
||||
uint32_t areas_sz = new_area_count * sizeof(*newareas);
|
||||
|
||||
if (!(newareas = dm_pool_zalloc(lv->vg->cmd->mem, areas_sz))) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
if (!(newareas = dm_pool_zalloc(lv->vg->cmd->mem, areas_sz)))
|
||||
return_0;
|
||||
|
||||
memcpy(newareas, seg->areas, seg->area_count * sizeof(*seg->areas));
|
||||
|
||||
@ -423,19 +414,15 @@ static int _lv_reduce(struct logical_volume *lv, uint32_t extents, int delete)
|
||||
if (seg->len <= count) {
|
||||
/* remove this segment completely */
|
||||
/* FIXME Check this is safe */
|
||||
if (seg->log_lv && !lv_remove(seg->log_lv)) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
if (seg->log_lv && !lv_remove(seg->log_lv))
|
||||
return_0;
|
||||
list_del(&seg->list);
|
||||
reduction = seg->len;
|
||||
} else
|
||||
reduction = count;
|
||||
|
||||
if (!_lv_segment_reduce(seg, reduction)) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
if (!_lv_segment_reduce(seg, reduction))
|
||||
return_0;
|
||||
count -= reduction;
|
||||
}
|
||||
|
||||
@ -447,19 +434,15 @@ static int _lv_reduce(struct logical_volume *lv, uint32_t extents, int delete)
|
||||
|
||||
/* Remove the LV if it is now empty */
|
||||
if (!lv->le_count) {
|
||||
if (!(lvl = find_lv_in_vg(lv->vg, lv->name))) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
if (!(lvl = find_lv_in_vg(lv->vg, lv->name)))
|
||||
return_0;
|
||||
|
||||
list_del(&lvl->list);
|
||||
|
||||
lv->vg->lv_count--;
|
||||
} else if (lv->vg->fid->fmt->ops->lv_setup &&
|
||||
!lv->vg->fid->fmt->ops->lv_setup(lv->vg->fid, lv)) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
!lv->vg->fid->fmt->ops->lv_setup(lv->vg->fid, lv))
|
||||
return_0;
|
||||
|
||||
return 1;
|
||||
}
|
||||
@ -504,10 +487,8 @@ int lv_reduce(struct logical_volume *lv, uint32_t extents)
|
||||
int lv_remove(struct logical_volume *lv)
|
||||
{
|
||||
|
||||
if (!lv_reduce(lv, lv->le_count)) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
if (!lv_reduce(lv, lv->le_count))
|
||||
return_0;
|
||||
|
||||
return 1;
|
||||
}
|
||||
@ -684,12 +665,9 @@ static int _setup_alloced_segment(struct logical_volume *lv, uint32_t status,
|
||||
return 0;
|
||||
}
|
||||
|
||||
for (s = 0; s < area_count; s++) {
|
||||
if (!set_lv_segment_area_pv(seg, s, aa[s].pv, aa[s].pe)) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
for (s = 0; s < area_count; s++)
|
||||
if (!set_lv_segment_area_pv(seg, s, aa[s].pv, aa[s].pe))
|
||||
return_0;
|
||||
|
||||
list_add(&lv->segments, &seg->list);
|
||||
|
||||
@ -717,10 +695,8 @@ static int _setup_alloced_segments(struct logical_volume *lv,
|
||||
list_iterate_items(aa, &alloced_areas[0]) {
|
||||
if (!_setup_alloced_segment(lv, status, area_count,
|
||||
stripe_size, segtype, aa,
|
||||
region_size, log_lv)) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
region_size, log_lv))
|
||||
return_0;
|
||||
}
|
||||
|
||||
return 1;
|
||||
@ -1142,10 +1118,8 @@ static int _find_parallel_space(struct alloc_handle *ah, alloc_policy_t alloc,
|
||||
allocated,
|
||||
(ah->log_count && !ah->log_area.len) ?
|
||||
*(areas + ix_offset + ix - 1) :
|
||||
NULL)) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
NULL))
|
||||
return_0;
|
||||
|
||||
} while (!contiguous && *allocated != needed && can_split);
|
||||
|
||||
@ -1187,10 +1161,8 @@ static int _allocate(struct alloc_handle *ah,
|
||||
/*
|
||||
* Build the sets of available areas on the pv's.
|
||||
*/
|
||||
if (!(pvms = create_pv_maps(ah->mem, vg, allocatable_pvs))) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
if (!(pvms = create_pv_maps(ah->mem, vg, allocatable_pvs)))
|
||||
return_0;
|
||||
|
||||
if (!_log_parallel_areas(ah->mem, ah->parallel_areas))
|
||||
stack;
|
||||
@ -1315,9 +1287,8 @@ struct alloc_handle *allocate_extents(struct volume_group *vg,
|
||||
if (!segtype_is_virtual(segtype) &&
|
||||
!_allocate(ah, vg, lv, (lv ? lv->le_count : 0) + extents,
|
||||
1, allocatable_pvs)) {
|
||||
stack;
|
||||
alloc_destroy(ah);
|
||||
return NULL;
|
||||
return_NULL;
|
||||
}
|
||||
|
||||
return ah;
|
||||
@ -1348,10 +1319,8 @@ int lv_add_segment(struct alloc_handle *ah,
|
||||
if (!_setup_alloced_segments(lv, &ah->alloced_areas[first_area],
|
||||
num_areas, status,
|
||||
stripe_size, segtype,
|
||||
region_size, log_lv)) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
region_size, log_lv))
|
||||
return_0;
|
||||
|
||||
if ((segtype->flags & SEG_CAN_SPLIT) && !lv_merge_segments(lv)) {
|
||||
log_err("Couldn't merge segments after extending "
|
||||
@ -1360,10 +1329,8 @@ int lv_add_segment(struct alloc_handle *ah,
|
||||
}
|
||||
|
||||
if (lv->vg->fid->fmt->ops->lv_setup &&
|
||||
!lv->vg->fid->fmt->ops->lv_setup(lv->vg->fid, lv)) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
!lv->vg->fid->fmt->ops->lv_setup(lv->vg->fid, lv))
|
||||
return_0;
|
||||
|
||||
return 1;
|
||||
}
|
||||
@ -1615,10 +1582,8 @@ int lv_extend(struct logical_volume *lv,
|
||||
|
||||
if (mirrors < 2) {
|
||||
if (!lv_add_segment(ah, 0, ah->area_count, lv, segtype, stripe_size,
|
||||
status, 0, NULL)) {
|
||||
stack;
|
||||
goto out;
|
||||
}
|
||||
status, 0, NULL))
|
||||
goto_out;
|
||||
} else {
|
||||
if (!_lv_extend_mirror(ah, lv, extents, 0))
|
||||
return_0;
|
||||
@ -1787,15 +1752,13 @@ int lv_rename(struct cmd_context *cmd, struct logical_volume *lv,
|
||||
backup(vg);
|
||||
|
||||
if (!suspend_lv(cmd, lv)) {
|
||||
stack;
|
||||
vg_revert(vg);
|
||||
return 0;
|
||||
return_0;
|
||||
}
|
||||
|
||||
if (!vg_commit(vg)) {
|
||||
stack;
|
||||
resume_lv(cmd, lv);
|
||||
return 0;
|
||||
return_0;
|
||||
}
|
||||
|
||||
resume_lv(cmd, lv);
|
||||
@ -1890,10 +1853,9 @@ struct logical_volume *lv_create_empty(const char *name,
|
||||
lv->lvid = *lvid;
|
||||
|
||||
if (fi->fmt->ops->lv_setup && !fi->fmt->ops->lv_setup(fi, lv)) {
|
||||
stack;
|
||||
if (ll)
|
||||
dm_pool_free(cmd->mem, ll);
|
||||
return NULL;
|
||||
return_NULL;
|
||||
}
|
||||
|
||||
if (!import)
|
||||
@ -1960,10 +1922,8 @@ struct list *build_parallel_areas_from_lv(struct cmd_context *cmd,
|
||||
/* Find next segment end */
|
||||
/* FIXME Unnecessary nesting! */
|
||||
if (!_for_each_pv(cmd, lv, current_le, spvs->len, &spvs->len,
|
||||
0, 0, -1, 0, _add_pvs, (void *) spvs)) {
|
||||
stack;
|
||||
return NULL;
|
||||
}
|
||||
0, 0, -1, 0, _add_pvs, (void *) spvs))
|
||||
return_NULL;
|
||||
|
||||
current_le = spvs->le + spvs->len;
|
||||
} while (current_le < lv->le_count);
|
||||
@ -2055,10 +2015,8 @@ int lv_remove_single(struct cmd_context *cmd, struct logical_volume *lv,
|
||||
if (lv_is_cow(lv)) {
|
||||
origin = origin_from_cow(lv);
|
||||
log_verbose("Removing snapshot %s", lv->name);
|
||||
if (!vg_remove_snapshot(lv)) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
if (!vg_remove_snapshot(lv))
|
||||
return_0;
|
||||
}
|
||||
|
||||
log_verbose("Releasing logical volume \"%s\"", lv->name);
|
||||
|
@ -305,10 +305,8 @@ static int _lv_split_segment(struct logical_volume *lv, struct lv_segment *seg,
|
||||
seg->area_len,
|
||||
seg_pvseg(seg, s)->len -
|
||||
seg->area_len,
|
||||
split_seg, s))) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
split_seg, s)))
|
||||
return_0;
|
||||
log_debug("Split %s:%u[%u] at %u: %s PE %u", lv->name,
|
||||
seg->le, s, le,
|
||||
dev_name(seg_dev(seg, s)),
|
||||
@ -344,15 +342,11 @@ int lv_split_segment(struct logical_volume *lv, uint32_t le)
|
||||
if (le == seg->le)
|
||||
return 1;
|
||||
|
||||
if (!_lv_split_segment(lv, seg, le)) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
if (!_lv_split_segment(lv, seg, le))
|
||||
return_0;
|
||||
|
||||
if (!vg_validate(lv->vg)) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
if (!vg_validate(lv->vg))
|
||||
return_0;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
@ -154,10 +154,8 @@ int add_pv_to_vg(struct volume_group *vg, const char *pv_name,
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!alloc_pv_segment_whole_pv(mem, pv)) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
if (!alloc_pv_segment_whole_pv(mem, pv))
|
||||
return_0;
|
||||
|
||||
pvl->pv = pv;
|
||||
list_add(&vg->pvs, &pvl->list);
|
||||
@ -189,10 +187,8 @@ static int _copy_pv(struct physical_volume *pv_to,
|
||||
}
|
||||
|
||||
if (!peg_dup(pv_to->fmt->cmd->mem, &pv_to->segments,
|
||||
&pv_from->segments)) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
&pv_from->segments))
|
||||
return_0;
|
||||
|
||||
return 1;
|
||||
}
|
||||
@ -217,10 +213,8 @@ int get_pv_from_vg_by_id(const struct format_type *fmt, const char *vg_name,
|
||||
|
||||
list_iterate_items(pvl, &vg->pvs) {
|
||||
if (id_equal(&pvl->pv->id, (const struct id *) pvid)) {
|
||||
if (!_copy_pv(pv, pvl->pv)) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
if (!_copy_pv(pv, pvl->pv))
|
||||
return_0;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
@ -475,10 +469,8 @@ struct volume_group *vg_create(struct cmd_context *cmd, const char *vg_name,
|
||||
int consistent = 0;
|
||||
int old_partial;
|
||||
|
||||
if (!(vg = dm_pool_zalloc(mem, sizeof(*vg)))) {
|
||||
stack;
|
||||
return NULL;
|
||||
}
|
||||
if (!(vg = dm_pool_zalloc(mem, sizeof(*vg))))
|
||||
return_NULL;
|
||||
|
||||
/* is this vg name already in use ? */
|
||||
old_partial = partial_mode();
|
||||
@ -499,10 +491,8 @@ struct volume_group *vg_create(struct cmd_context *cmd, const char *vg_name,
|
||||
|
||||
vg->cmd = cmd;
|
||||
|
||||
if (!(vg->name = dm_pool_strdup(mem, vg_name))) {
|
||||
stack;
|
||||
goto bad;
|
||||
}
|
||||
if (!(vg->name = dm_pool_strdup(mem, vg_name)))
|
||||
goto_bad;
|
||||
|
||||
vg->seqno = 0;
|
||||
|
||||
@ -595,22 +585,16 @@ int vg_change_pesize(struct cmd_context *cmd __attribute((unused)),
|
||||
vg->extent_size = new_size;
|
||||
|
||||
if (vg->fid->fmt->ops->vg_setup &&
|
||||
!vg->fid->fmt->ops->vg_setup(vg->fid, vg)) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
!vg->fid->fmt->ops->vg_setup(vg->fid, vg))
|
||||
return_0;
|
||||
|
||||
if (!_recalc_extents(&vg->extent_count, vg->name, "", old_size,
|
||||
new_size)) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
new_size))
|
||||
return_0;
|
||||
|
||||
if (!_recalc_extents(&vg->free_count, vg->name, " free space",
|
||||
old_size, new_size)) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
old_size, new_size))
|
||||
return_0;
|
||||
|
||||
/* foreach PV */
|
||||
list_iterate_items(pvl, &vg->pvs) {
|
||||
@ -618,16 +602,12 @@ int vg_change_pesize(struct cmd_context *cmd __attribute((unused)),
|
||||
|
||||
pv->pe_size = new_size;
|
||||
if (!_recalc_extents(&pv->pe_count, pv_dev_name(pv), "",
|
||||
old_size, new_size)) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
old_size, new_size))
|
||||
return_0;
|
||||
|
||||
if (!_recalc_extents(&pv->pe_alloc_count, pv_dev_name(pv),
|
||||
" allocated space", old_size, new_size)) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
" allocated space", old_size, new_size))
|
||||
return_0;
|
||||
|
||||
/* foreach free PV Segment */
|
||||
list_iterate_items(pvseg, &pv->segments) {
|
||||
@ -636,16 +616,12 @@ int vg_change_pesize(struct cmd_context *cmd __attribute((unused)),
|
||||
|
||||
if (!_recalc_extents(&pvseg->pe, pv_dev_name(pv),
|
||||
" PV segment start", old_size,
|
||||
new_size)) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
new_size))
|
||||
return_0;
|
||||
if (!_recalc_extents(&pvseg->len, pv_dev_name(pv),
|
||||
" PV segment length", old_size,
|
||||
new_size)) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
new_size))
|
||||
return_0;
|
||||
}
|
||||
}
|
||||
|
||||
@ -654,39 +630,29 @@ int vg_change_pesize(struct cmd_context *cmd __attribute((unused)),
|
||||
lv = lvl->lv;
|
||||
|
||||
if (!_recalc_extents(&lv->le_count, lv->name, "", old_size,
|
||||
new_size)) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
new_size))
|
||||
return_0;
|
||||
|
||||
list_iterate_items(seg, &lv->segments) {
|
||||
if (!_recalc_extents(&seg->le, lv->name,
|
||||
" segment start", old_size,
|
||||
new_size)) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
new_size))
|
||||
return_0;
|
||||
|
||||
if (!_recalc_extents(&seg->len, lv->name,
|
||||
" segment length", old_size,
|
||||
new_size)) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
new_size))
|
||||
return_0;
|
||||
|
||||
if (!_recalc_extents(&seg->area_len, lv->name,
|
||||
" area length", old_size,
|
||||
new_size)) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
new_size))
|
||||
return_0;
|
||||
|
||||
if (!_recalc_extents(&seg->extents_copied, lv->name,
|
||||
" extents moved", old_size,
|
||||
new_size)) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
new_size))
|
||||
return_0;
|
||||
|
||||
/* foreach area */
|
||||
for (s = 0; s < seg->area_count; s++) {
|
||||
@ -696,27 +662,21 @@ int vg_change_pesize(struct cmd_context *cmd __attribute((unused)),
|
||||
(&seg_pe(seg, s),
|
||||
lv->name,
|
||||
" pvseg start", old_size,
|
||||
new_size)) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
new_size))
|
||||
return_0;
|
||||
if (!_recalc_extents
|
||||
(&seg_pvseg(seg, s)->len,
|
||||
lv->name,
|
||||
" pvseg length", old_size,
|
||||
new_size)) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
new_size))
|
||||
return_0;
|
||||
break;
|
||||
case AREA_LV:
|
||||
if (!_recalc_extents
|
||||
(&seg_le(seg, s), lv->name,
|
||||
" area start", old_size,
|
||||
new_size)) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
new_size))
|
||||
return_0;
|
||||
break;
|
||||
case AREA_UNASSIGNED:
|
||||
log_error("Unassigned area %u found in "
|
||||
@ -804,10 +764,8 @@ static struct physical_volume *_alloc_pv(struct dm_pool *mem)
|
||||
{
|
||||
struct physical_volume *pv = dm_pool_zalloc(mem, sizeof(*pv));
|
||||
|
||||
if (!pv) {
|
||||
stack;
|
||||
return NULL;
|
||||
}
|
||||
if (!pv)
|
||||
return_NULL;
|
||||
|
||||
if (!(pv->vg_name = dm_pool_zalloc(mem, NAME_LEN))) {
|
||||
dm_pool_free(mem, pv);
|
||||
@ -1074,10 +1032,8 @@ int vg_remove(struct volume_group *vg)
|
||||
/* Remove each copy of the metadata */
|
||||
list_iterate_items(mda, &vg->fid->metadata_areas) {
|
||||
if (mda->ops->vg_remove &&
|
||||
!mda->ops->vg_remove(vg->fid, vg, mda)) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
!mda->ops->vg_remove(vg->fid, vg, mda))
|
||||
return_0;
|
||||
}
|
||||
|
||||
return 1;
|
||||
@ -1260,10 +1216,8 @@ int vg_write(struct volume_group *vg)
|
||||
struct list *mdah;
|
||||
struct metadata_area *mda;
|
||||
|
||||
if (!vg_validate(vg)) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
if (!vg_validate(vg))
|
||||
return_0;
|
||||
|
||||
if (vg->status & PARTIAL_VG) {
|
||||
log_error("Cannot change metadata for partial volume group %s",
|
||||
@ -1378,10 +1332,8 @@ static struct volume_group *_vg_read_orphans(struct cmd_context *cmd)
|
||||
struct volume_group *vg;
|
||||
struct physical_volume *pv;
|
||||
|
||||
if (!(vginfo = vginfo_from_vgname(ORPHAN, NULL))) {
|
||||
stack;
|
||||
return NULL;
|
||||
}
|
||||
if (!(vginfo = vginfo_from_vgname(ORPHAN, NULL)))
|
||||
return_NULL;
|
||||
|
||||
if (!(vg = dm_pool_zalloc(cmd->mem, sizeof(*vg)))) {
|
||||
log_error("vg allocation failed");
|
||||
@ -1477,15 +1429,11 @@ static struct volume_group *_vg_read(struct cmd_context *cmd,
|
||||
if (!(fmt = fmt_from_vgname(vgname, vgid))) {
|
||||
lvmcache_label_scan(cmd, 0);
|
||||
if (!(fmt = fmt_from_vgname(vgname, vgid))) {
|
||||
if (memlock()) {
|
||||
stack;
|
||||
return NULL;
|
||||
}
|
||||
if (memlock())
|
||||
return_NULL;
|
||||
lvmcache_label_scan(cmd, 2);
|
||||
if (!(fmt = fmt_from_vgname(vgname, vgid))) {
|
||||
stack;
|
||||
return NULL;
|
||||
}
|
||||
if (!(fmt = fmt_from_vgname(vgname, vgid)))
|
||||
return_NULL;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1493,10 +1441,8 @@ static struct volume_group *_vg_read(struct cmd_context *cmd,
|
||||
use_precommitted = 0;
|
||||
|
||||
/* Store pvids for later so we can check if any are missing */
|
||||
if (!(pvids = lvmcache_get_pvids(cmd, vgname, vgid))) {
|
||||
stack;
|
||||
return NULL;
|
||||
}
|
||||
if (!(pvids = lvmcache_get_pvids(cmd, vgname, vgid)))
|
||||
return_NULL;
|
||||
|
||||
/* create format instance with appropriate metadata area */
|
||||
if (!(fid = fmt->ops->create_instance(fmt, vgname, vgid, NULL))) {
|
||||
@ -1551,15 +1497,11 @@ static struct volume_group *_vg_read(struct cmd_context *cmd,
|
||||
if (!correct_vg) {
|
||||
inconsistent = 0;
|
||||
|
||||
if (memlock()) {
|
||||
stack;
|
||||
return NULL;
|
||||
}
|
||||
if (memlock())
|
||||
return_NULL;
|
||||
lvmcache_label_scan(cmd, 2);
|
||||
if (!(fmt = fmt_from_vgname(vgname, vgid))) {
|
||||
stack;
|
||||
return NULL;
|
||||
}
|
||||
if (!(fmt = fmt_from_vgname(vgname, vgid)))
|
||||
return_NULL;
|
||||
|
||||
if (precommitted && !(fmt->features & FMT_PRECOMMIT))
|
||||
use_precommitted = 0;
|
||||
@ -1605,10 +1547,8 @@ static struct volume_group *_vg_read(struct cmd_context *cmd,
|
||||
}
|
||||
|
||||
/* Give up looking */
|
||||
if (!correct_vg) {
|
||||
stack;
|
||||
return NULL;
|
||||
}
|
||||
if (!correct_vg)
|
||||
return_NULL;
|
||||
}
|
||||
|
||||
lvmcache_update_vg(correct_vg);
|
||||
@ -1837,10 +1777,8 @@ static struct physical_volume *_pv_read(struct cmd_context *cmd,
|
||||
struct lvmcache_info *info;
|
||||
struct device *dev;
|
||||
|
||||
if (!(dev = dev_cache_get(pv_name, cmd->filter))) {
|
||||
stack;
|
||||
return NULL;
|
||||
}
|
||||
if (!(dev = dev_cache_get(pv_name, cmd->filter)))
|
||||
return_NULL;
|
||||
|
||||
if (!(label_read(dev, &label, UINT64_C(0)))) {
|
||||
if (warnings)
|
||||
@ -1871,10 +1809,8 @@ static struct physical_volume *_pv_read(struct cmd_context *cmd,
|
||||
if (!pv->size)
|
||||
return NULL;
|
||||
|
||||
if (!alloc_pv_segment_whole_pv(cmd->mem, pv)) {
|
||||
stack;
|
||||
return NULL;
|
||||
}
|
||||
if (!alloc_pv_segment_whole_pv(cmd->mem, pv))
|
||||
return_NULL;
|
||||
|
||||
return pv;
|
||||
}
|
||||
@ -1996,10 +1932,8 @@ static int _pv_write(struct cmd_context *cmd __attribute((unused)),
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!pv->fmt->ops->pv_write(pv->fmt, pv, mdas, label_sector)) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
if (!pv->fmt->ops->pv_write(pv->fmt, pv, mdas, label_sector))
|
||||
return_0;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
@ -1002,10 +1002,8 @@ struct logical_volume *find_pvmove_lv_from_pvname(struct cmd_context *cmd,
|
||||
{
|
||||
struct physical_volume *pv;
|
||||
|
||||
if (!(pv = find_pv_by_name(cmd, name))) {
|
||||
stack;
|
||||
return NULL;
|
||||
}
|
||||
if (!(pv = find_pv_by_name(cmd, name)))
|
||||
return_NULL;
|
||||
|
||||
return find_pvmove_lv(vg, pv->dev, lv_type);
|
||||
}
|
||||
|
@ -53,10 +53,8 @@ int alloc_pv_segment_whole_pv(struct dm_pool *mem, struct physical_volume *pv)
|
||||
return 1;
|
||||
|
||||
/* FIXME Cope with holes in PVs */
|
||||
if (!(peg = _alloc_pv_segment(mem, pv, 0, pv->pe_count, NULL, 0))) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
if (!(peg = _alloc_pv_segment(mem, pv, 0, pv->pe_count, NULL, 0)))
|
||||
return_0;
|
||||
|
||||
list_add(&pv->segments, &peg->list);
|
||||
|
||||
@ -72,10 +70,8 @@ int peg_dup(struct dm_pool *mem, struct list *peg_new, struct list *peg_old)
|
||||
list_iterate_items(pego, peg_old) {
|
||||
if (!(peg = _alloc_pv_segment(mem, pego->pv, pego->pe,
|
||||
pego->len, pego->lvseg,
|
||||
pego->lv_area))) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
pego->lv_area)))
|
||||
return_0;
|
||||
list_add(peg_new, &peg->list);
|
||||
}
|
||||
|
||||
@ -93,10 +89,8 @@ static int _pv_split_segment(struct physical_volume *pv, struct pv_segment *peg,
|
||||
|
||||
if (!(peg_new = _alloc_pv_segment(pv->fmt->cmd->mem, peg->pv, pe,
|
||||
peg->len + peg->pe - pe,
|
||||
NULL, 0))) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
NULL, 0)))
|
||||
return_0;
|
||||
|
||||
peg->len = peg->len - peg_new->len;
|
||||
|
||||
@ -130,10 +124,8 @@ int pv_split_segment(struct physical_volume *pv, uint32_t pe)
|
||||
if (pe == peg->pe)
|
||||
return 1;
|
||||
|
||||
if (!_pv_split_segment(pv, peg, pe)) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
if (!_pv_split_segment(pv, peg, pe))
|
||||
return_0;
|
||||
|
||||
return 1;
|
||||
}
|
||||
@ -155,10 +147,8 @@ struct pv_segment *assign_peg_to_lvseg(struct physical_volume *pv,
|
||||
return &null_pv_segment;
|
||||
|
||||
if (!pv_split_segment(pv, pe) ||
|
||||
!pv_split_segment(pv, pe + area_len)) {
|
||||
stack;
|
||||
return NULL;
|
||||
}
|
||||
!pv_split_segment(pv, pe + area_len))
|
||||
return_NULL;
|
||||
|
||||
if (!(peg = find_peg_by_pe(pv, pe))) {
|
||||
log_error("Missing PV segment on %s at %u.",
|
||||
@ -196,10 +186,8 @@ int release_pv_segment(struct pv_segment *peg, uint32_t area_reduction)
|
||||
}
|
||||
|
||||
if (!pv_split_segment(peg->pv, peg->pe + peg->lvseg->area_len -
|
||||
area_reduction)) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
area_reduction))
|
||||
return_0;
|
||||
|
||||
return 1;
|
||||
}
|
||||
@ -371,10 +359,8 @@ static int _reduce_pv(struct physical_volume *pv, struct volume_group *vg, uint3
|
||||
}
|
||||
}
|
||||
|
||||
if (!pv_split_segment(pv, new_pe_count)) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
if (!pv_split_segment(pv, new_pe_count))
|
||||
return_0;
|
||||
|
||||
list_iterate_items_safe(peg, pegt, &pv->segments) {
|
||||
if (peg->pe + peg->len > new_pe_count)
|
||||
|
@ -40,10 +40,8 @@ static int _create_single_area(struct dm_pool *mem, struct pv_map *pvm,
|
||||
{
|
||||
struct pv_area *pva;
|
||||
|
||||
if (!(pva = dm_pool_zalloc(mem, sizeof(*pva)))) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
if (!(pva = dm_pool_zalloc(mem, sizeof(*pva))))
|
||||
return_0;
|
||||
|
||||
log_debug("Allowing allocation on %s start PE %" PRIu32 " length %"
|
||||
PRIu32, pv_dev_name(pvm->pv), start, length);
|
||||
@ -88,10 +86,8 @@ static int _create_alloc_areas_for_pv(struct dm_pool *mem, struct pv_map *pvm,
|
||||
area_len = (end >= peg->pe + peg->len - 1) ?
|
||||
peg->len - (pe - peg->pe) : end - pe + 1;
|
||||
|
||||
if (!_create_single_area(mem, pvm, pe, area_len)) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
if (!_create_single_area(mem, pvm, pe, area_len))
|
||||
return_0;
|
||||
|
||||
next:
|
||||
pe = peg->pe + peg->len;
|
||||
@ -108,20 +104,16 @@ static int _create_all_areas_for_pv(struct dm_pool *mem, struct pv_map *pvm,
|
||||
if (!pe_ranges) {
|
||||
/* Use whole PV */
|
||||
if (!_create_alloc_areas_for_pv(mem, pvm, UINT32_C(0),
|
||||
pvm->pv->pe_count)) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
pvm->pv->pe_count))
|
||||
return_0;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
list_iterate_items(aa, pe_ranges) {
|
||||
if (!_create_alloc_areas_for_pv(mem, pvm, aa->start,
|
||||
aa->count)) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
aa->count))
|
||||
return_0;
|
||||
}
|
||||
|
||||
return 1;
|
||||
@ -145,20 +137,16 @@ static int _create_maps(struct dm_pool *mem, struct list *pvs, struct list *pvms
|
||||
}
|
||||
|
||||
if (!pvm) {
|
||||
if (!(pvm = dm_pool_zalloc(mem, sizeof(*pvm)))) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
if (!(pvm = dm_pool_zalloc(mem, sizeof(*pvm))))
|
||||
return_0;
|
||||
|
||||
pvm->pv = pvl->pv;
|
||||
list_init(&pvm->areas);
|
||||
list_add(pvms, &pvm->list);
|
||||
}
|
||||
|
||||
if (!_create_all_areas_for_pv(mem, pvm, pvl->pe_ranges)) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
if (!_create_all_areas_for_pv(mem, pvm, pvl->pe_ranges))
|
||||
return_0;
|
||||
}
|
||||
|
||||
return 1;
|
||||
|
@ -70,17 +70,13 @@ int vg_add_snapshot(const char *name, struct logical_volume *origin,
|
||||
|
||||
if (!(snap = lv_create_empty(name ? name : "snapshot%d",
|
||||
lvid, LVM_READ | LVM_WRITE | VISIBLE_LV,
|
||||
ALLOC_INHERIT, 1, origin->vg))) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
ALLOC_INHERIT, 1, origin->vg)))
|
||||
return_0;
|
||||
|
||||
snap->le_count = extent_count;
|
||||
|
||||
if (!(seg = alloc_snapshot_seg(snap, 0, 0))) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
if (!(seg = alloc_snapshot_seg(snap, 0, 0)))
|
||||
return_0;
|
||||
|
||||
seg->chunk_size = chunk_size;
|
||||
seg->origin = origin;
|
||||
|
@ -555,10 +555,8 @@ struct segment_type *init_segtype(struct cmd_context *cmd)
|
||||
{
|
||||
struct segment_type *segtype = dm_malloc(sizeof(*segtype));
|
||||
|
||||
if (!segtype) {
|
||||
stack;
|
||||
return NULL;
|
||||
}
|
||||
if (!segtype)
|
||||
return_NULL;
|
||||
|
||||
segtype->cmd = cmd;
|
||||
segtype->ops = &_mirrored_ops;
|
||||
|
@ -583,10 +583,8 @@ static int _size32_disp(struct dm_report *rh __attribute((unused)), struct dm_po
|
||||
const char *disp, *repstr;
|
||||
uint64_t *sortval;
|
||||
|
||||
if (!*(disp = display_size_units(private, (uint64_t) size))) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
if (!*(disp = display_size_units(private, (uint64_t) size)))
|
||||
return_0;
|
||||
|
||||
if (!(repstr = dm_pool_strdup(mem, disp))) {
|
||||
log_error("dm_pool_strdup failed");
|
||||
@ -614,10 +612,8 @@ static int _size64_disp(struct dm_report *rh __attribute((unused)),
|
||||
const char *disp, *repstr;
|
||||
uint64_t *sortval;
|
||||
|
||||
if (!*(disp = display_size_units(private, size))) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
if (!*(disp = display_size_units(private, size)))
|
||||
return_0;
|
||||
|
||||
if (!(repstr = dm_pool_strdup(mem, disp))) {
|
||||
log_error("dm_pool_strdup failed");
|
||||
@ -809,10 +805,8 @@ static int _uuid_disp(struct dm_report *rh __attribute((unused)), struct dm_pool
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!id_write_format((const struct id *) data, repstr, 40)) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
if (!id_write_format((const struct id *) data, repstr, 40))
|
||||
return_0;
|
||||
|
||||
dm_report_field_set_value(field, repstr, NULL);
|
||||
return 1;
|
||||
|
@ -74,10 +74,8 @@ static int _snap_text_import(struct lv_segment *seg, const struct config_node *s
|
||||
}
|
||||
|
||||
if (!vg_add_snapshot(seg->lv->name, org, cow,
|
||||
&seg->lv->lvid, seg->len, chunk_size)) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
&seg->lv->lvid, seg->len, chunk_size))
|
||||
return_0;
|
||||
|
||||
return 1;
|
||||
}
|
||||
@ -304,10 +302,8 @@ struct segment_type *init_segtype(struct cmd_context *cmd)
|
||||
char *dso;
|
||||
#endif
|
||||
|
||||
if (!segtype) {
|
||||
stack;
|
||||
return NULL;
|
||||
}
|
||||
if (!segtype)
|
||||
return_NULL;
|
||||
|
||||
segtype->cmd = cmd;
|
||||
segtype->ops = &_snapshot_ops;
|
||||
|
@ -213,10 +213,8 @@ struct segment_type *init_striped_segtype(struct cmd_context *cmd)
|
||||
{
|
||||
struct segment_type *segtype = dm_malloc(sizeof(*segtype));
|
||||
|
||||
if (!segtype) {
|
||||
stack;
|
||||
return NULL;
|
||||
}
|
||||
if (!segtype)
|
||||
return_NULL;
|
||||
|
||||
segtype->cmd = cmd;
|
||||
segtype->ops = &_striped_ops;
|
||||
|
@ -96,10 +96,8 @@ struct segment_type *init_zero_segtype(struct cmd_context *cmd)
|
||||
{
|
||||
struct segment_type *segtype = dm_malloc(sizeof(*segtype));
|
||||
|
||||
if (!segtype) {
|
||||
stack;
|
||||
return NULL;
|
||||
}
|
||||
if (!segtype)
|
||||
return_NULL;
|
||||
|
||||
segtype->cmd = cmd;
|
||||
segtype->ops = &_zero_ops;
|
||||
|
@ -53,10 +53,8 @@ static int lvchange_permission(struct cmd_context *cmd,
|
||||
}
|
||||
|
||||
log_very_verbose("Updating logical volume \"%s\" on disk(s)", lv->name);
|
||||
if (!vg_write(lv->vg)) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
if (!vg_write(lv->vg))
|
||||
return_0;
|
||||
|
||||
backup(lv->vg);
|
||||
|
||||
@ -114,16 +112,12 @@ static int lvchange_availability(struct cmd_context *cmd,
|
||||
if (activate == CHANGE_ALN) {
|
||||
log_verbose("Deactivating logical volume \"%s\" locally",
|
||||
lv->name);
|
||||
if (!deactivate_lv_local(cmd, lv)) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
if (!deactivate_lv_local(cmd, lv))
|
||||
return_0;
|
||||
} else if (activate == CHANGE_AN) {
|
||||
log_verbose("Deactivating logical volume \"%s\"", lv->name);
|
||||
if (!deactivate_lv(cmd, lv)) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
if (!deactivate_lv(cmd, lv))
|
||||
return_0;
|
||||
} else {
|
||||
if (lockingfailed() && (lv->vg->status & CLUSTERED)) {
|
||||
log_verbose("Locking failed: ignoring clustered "
|
||||
@ -134,24 +128,18 @@ static int lvchange_availability(struct cmd_context *cmd,
|
||||
if (lv_is_origin(lv) || (activate == CHANGE_AE)) {
|
||||
log_verbose("Activating logical volume \"%s\" "
|
||||
"exclusively", lv->name);
|
||||
if (!activate_lv_excl(cmd, lv)) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
if (!activate_lv_excl(cmd, lv))
|
||||
return_0;
|
||||
} else if (activate == CHANGE_ALY) {
|
||||
log_verbose("Activating logical volume \"%s\" locally",
|
||||
lv->name);
|
||||
if (!activate_lv_local(cmd, lv)) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
if (!activate_lv_local(cmd, lv))
|
||||
return_0;
|
||||
} else {
|
||||
log_verbose("Activating logical volume \"%s\"",
|
||||
lv->name);
|
||||
if (!activate_lv(cmd, lv)) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
if (!activate_lv(cmd, lv))
|
||||
return_0;
|
||||
}
|
||||
|
||||
if ((lv->status & LOCKED) &&
|
||||
@ -357,18 +345,14 @@ static int lvchange_alloc(struct cmd_context *cmd, struct logical_volume *lv)
|
||||
|
||||
log_very_verbose("Updating logical volume \"%s\" on disk(s)", lv->name);
|
||||
|
||||
if (!vg_write(lv->vg)) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
if (!vg_write(lv->vg))
|
||||
return_0;
|
||||
|
||||
backup(lv->vg);
|
||||
|
||||
/* No need to suspend LV for this change */
|
||||
if (!vg_commit(lv->vg)) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
if (!vg_commit(lv->vg))
|
||||
return_0;
|
||||
|
||||
return 1;
|
||||
}
|
||||
@ -407,10 +391,8 @@ static int lvchange_readahead(struct cmd_context *cmd,
|
||||
lv->name);
|
||||
|
||||
log_very_verbose("Updating logical volume \"%s\" on disk(s)", lv->name);
|
||||
if (!vg_write(lv->vg)) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
if (!vg_write(lv->vg))
|
||||
return_0;
|
||||
|
||||
backup(lv->vg);
|
||||
|
||||
@ -488,17 +470,13 @@ static int lvchange_persistent(struct cmd_context *cmd,
|
||||
}
|
||||
|
||||
log_very_verbose("Updating logical volume \"%s\" on disk(s)", lv->name);
|
||||
if (!vg_write(lv->vg)) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
if (!vg_write(lv->vg))
|
||||
return_0;
|
||||
|
||||
backup(lv->vg);
|
||||
|
||||
if (!vg_commit(lv->vg)) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
if (!vg_commit(lv->vg))
|
||||
return_0;
|
||||
|
||||
if (active) {
|
||||
log_verbose("Re-activating logical volume \"%s\"", lv->name);
|
||||
@ -542,18 +520,14 @@ static int lvchange_tag(struct cmd_context *cmd, struct logical_volume *lv,
|
||||
}
|
||||
|
||||
log_very_verbose("Updating logical volume \"%s\" on disk(s)", lv->name);
|
||||
if (!vg_write(lv->vg)) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
if (!vg_write(lv->vg))
|
||||
return_0;
|
||||
|
||||
backup(lv->vg);
|
||||
|
||||
/* No need to suspend LV for this change */
|
||||
if (!vg_commit(lv->vg)) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
if (!vg_commit(lv->vg))
|
||||
return_0;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
@ -743,21 +743,19 @@ int lvconvert(struct cmd_context * cmd, int argc, char **argv)
|
||||
if (!(lvl = find_lv_in_vg(vg, lp.lv_name))) {
|
||||
log_error("Logical volume \"%s\" not found in "
|
||||
"volume group \"%s\"", lp.lv_name, lp.vg_name);
|
||||
goto error;
|
||||
goto bad;
|
||||
}
|
||||
|
||||
if (lp.pv_count) {
|
||||
if (!(lp.pvh = create_pv_list(cmd->mem, vg, lp.pv_count,
|
||||
lp.pvs, 1))) {
|
||||
stack;
|
||||
goto error;
|
||||
}
|
||||
lp.pvs, 1)))
|
||||
goto_bad;
|
||||
} else
|
||||
lp.pvh = &vg->pvs;
|
||||
|
||||
ret = lvconvert_single(cmd, lvl->lv, &lp);
|
||||
|
||||
error:
|
||||
bad:
|
||||
unlock_vg(cmd, lp.vg_name);
|
||||
|
||||
if (ret == ECMD_PROCESSED && lp.need_polling) {
|
||||
|
@ -135,10 +135,8 @@ static int _lvcreate_name_params(struct lvcreate_params *lp,
|
||||
if ((ptr = strrchr(lp->lv_name, '/')))
|
||||
lp->lv_name = ptr + 1;
|
||||
|
||||
if (!apply_lvname_restrictions(lp->lv_name)) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
if (!apply_lvname_restrictions(lp->lv_name))
|
||||
return_0;
|
||||
|
||||
if (!validate_name(lp->lv_name)) {
|
||||
log_error("Logical volume name \"%s\" is invalid",
|
||||
@ -385,10 +383,8 @@ static int _lvcreate_params(struct lvcreate_params *lp, struct cmd_context *cmd,
|
||||
}
|
||||
log_verbose("Setting chunksize to %d sectors.", lp->chunk_size);
|
||||
|
||||
if (!(lp->segtype = get_segtype_from_string(cmd, "snapshot"))) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
if (!(lp->segtype = get_segtype_from_string(cmd, "snapshot")))
|
||||
return_0;
|
||||
} else {
|
||||
if (arg_count(cmd, chunksize_ARG)) {
|
||||
log_error("-c is only available with snapshots");
|
||||
@ -409,10 +405,8 @@ static int _lvcreate_params(struct lvcreate_params *lp, struct cmd_context *cmd,
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!(lp->segtype = get_segtype_from_string(cmd, "striped"))) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
if (!(lp->segtype = get_segtype_from_string(cmd, "striped")))
|
||||
return_0;
|
||||
} else {
|
||||
if (arg_count(cmd, corelog_ARG)) {
|
||||
log_error("--corelog is only available with mirrors");
|
||||
@ -435,10 +429,8 @@ static int _lvcreate_params(struct lvcreate_params *lp, struct cmd_context *cmd,
|
||||
if (!_lvcreate_name_params(lp, cmd, &argc, &argv) ||
|
||||
!_read_size_params(lp, cmd) ||
|
||||
!_read_stripe_params(lp, cmd) ||
|
||||
!_read_mirror_params(lp, cmd)) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
!_read_mirror_params(lp, cmd))
|
||||
return_0;
|
||||
|
||||
/*
|
||||
* Should we zero the lv.
|
||||
@ -557,10 +549,8 @@ static int _lvcreate(struct cmd_context *cmd, struct volume_group *vg,
|
||||
*/
|
||||
if (lp->pv_count) {
|
||||
if (!(pvh = create_pv_list(cmd->mem, vg,
|
||||
lp->pv_count, lp->pvs, 1))) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
lp->pv_count, lp->pvs, 1)))
|
||||
return_0;
|
||||
} else
|
||||
pvh = &vg->pvs;
|
||||
|
||||
@ -712,10 +702,8 @@ static int _lvcreate(struct cmd_context *cmd, struct volume_group *vg,
|
||||
|
||||
/* The snapshot segment gets created later */
|
||||
if (lp->snapshot &&
|
||||
!(lp->segtype = get_segtype_from_string(cmd, "striped"))) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
!(lp->segtype = get_segtype_from_string(cmd, "striped")))
|
||||
return_0;
|
||||
|
||||
if (!archive(vg))
|
||||
return 0;
|
||||
@ -754,10 +742,8 @@ static int _lvcreate(struct cmd_context *cmd, struct volume_group *vg,
|
||||
}
|
||||
|
||||
if (!(lv = lv_create_empty(lv_name ? lv_name : "lvol%d", NULL,
|
||||
status, lp->alloc, 0, vg))) {
|
||||
stack;
|
||||
goto error;
|
||||
}
|
||||
status, lp->alloc, 0, vg)))
|
||||
return_0;
|
||||
|
||||
if (lp->read_ahead) {
|
||||
log_verbose("Setting read ahead sectors");
|
||||
@ -775,7 +761,7 @@ static int _lvcreate(struct cmd_context *cmd, struct volume_group *vg,
|
||||
if (tag && !str_list_add(cmd->mem, &lv->tags, tag)) {
|
||||
log_error("Failed to add tag %s to %s/%s",
|
||||
tag, lv->vg->name, lv->name);
|
||||
goto error;
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!lv_extend(lv, lp->segtype, lp->stripes, lp->stripe_size,
|
||||
@ -880,9 +866,6 @@ static int _lvcreate(struct cmd_context *cmd, struct volume_group *vg,
|
||||
|
||||
return 1;
|
||||
|
||||
error:
|
||||
return 0;
|
||||
|
||||
deactivate_and_revert_new_lv:
|
||||
if (!deactivate_lv(cmd, lv)) {
|
||||
log_error("Unable to deactivate failed new LV. "
|
||||
|
@ -1028,10 +1028,8 @@ struct cmd_context *init_lvm(unsigned is_static)
|
||||
|
||||
_cmdline.the_args = &_the_args[0];
|
||||
|
||||
if (!(cmd = create_toolcontext(_cmdline.the_args, is_static, 0))) {
|
||||
stack;
|
||||
return NULL;
|
||||
}
|
||||
if (!(cmd = create_toolcontext(_cmdline.the_args, is_static, 0)))
|
||||
return_NULL;
|
||||
|
||||
_init_rand();
|
||||
|
||||
|
@ -150,19 +150,13 @@ static int do_resizefs_reduce(const struct cmd_context *cmd,
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!lp->nofsck) {
|
||||
if (!exec_cmd("fsadm", "check", lv_path, NULL)) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
if (!lp->nofsck)
|
||||
if (!exec_cmd("fsadm", "check", lv_path, NULL))
|
||||
return_0;
|
||||
|
||||
if (lp->resize == LV_REDUCE) {
|
||||
if (!exec_cmd("fsadm", "resize", lv_path, size_buf)) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
if (lp->resize == LV_REDUCE)
|
||||
if (!exec_cmd("fsadm", "resize", lv_path, size_buf))
|
||||
return_0;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
@ -164,9 +164,8 @@ static int _pvchange_single(struct cmd_context *cmd, struct physical_volume *pv,
|
||||
return 0;
|
||||
}
|
||||
if (!id_write_format(&pv->id, uuid, sizeof(uuid))) {
|
||||
stack;
|
||||
unlock_vg(cmd, vg_name);
|
||||
return 0;
|
||||
return_0;
|
||||
}
|
||||
log_verbose("Changing uuid of %s to %s.", pv_name, uuid);
|
||||
if (!is_orphan(pv)) {
|
||||
|
@ -71,18 +71,13 @@ static struct list *_get_allocatable_pvs(struct cmd_context *cmd, int argc,
|
||||
struct list *allocatable_pvs, *pvht, *pvh;
|
||||
struct pv_list *pvl;
|
||||
|
||||
if (argc) {
|
||||
if (!(allocatable_pvs = create_pv_list(cmd->mem, vg, argc,
|
||||
argv, 1))) {
|
||||
stack;
|
||||
return NULL;
|
||||
}
|
||||
} else {
|
||||
if (!(allocatable_pvs = clone_pv_list(cmd->mem, &vg->pvs))) {
|
||||
stack;
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
if (argc)
|
||||
allocatable_pvs = create_pv_list(cmd->mem, vg, argc, argv, 1);
|
||||
else
|
||||
allocatable_pvs = clone_pv_list(cmd->mem, &vg->pvs);
|
||||
|
||||
if (!allocatable_pvs)
|
||||
return_NULL;
|
||||
|
||||
list_iterate_safe(pvh, pvht, allocatable_pvs) {
|
||||
pvl = list_item(pvh, struct pv_list);
|
||||
@ -197,10 +192,8 @@ static struct logical_volume *_set_up_pvmove_lv(struct cmd_context *cmd,
|
||||
continue;
|
||||
}
|
||||
if (!_insert_pvmove_mirrors(cmd, lv_mirr, source_pvl, lv,
|
||||
*lvs_changed)) {
|
||||
stack;
|
||||
return NULL;
|
||||
}
|
||||
*lvs_changed))
|
||||
return_NULL;
|
||||
}
|
||||
|
||||
/* Is temporary mirror empty? */
|
||||
@ -236,10 +229,8 @@ static int _update_metadata(struct cmd_context *cmd, struct volume_group *vg,
|
||||
backup(vg);
|
||||
|
||||
/* Suspend lvs_changed */
|
||||
if (!suspend_lvs(cmd, lvs_changed)) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
if (!suspend_lvs(cmd, lvs_changed))
|
||||
return_0;
|
||||
|
||||
/* Suspend mirrors on subsequent calls */
|
||||
if (!first_time) {
|
||||
|
@ -144,9 +144,8 @@ static int _pv_resize_single(struct cmd_context *cmd,
|
||||
}
|
||||
|
||||
if (!pv_resize(pv, vg, new_pe_count)) {
|
||||
stack;
|
||||
unlock_vg(cmd, vg_name);
|
||||
return 0;
|
||||
return_0;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -978,10 +978,8 @@ static int _parse_pes(struct dm_pool *mem, char *c, struct list *pe_ranges,
|
||||
|
||||
/* Default to whole PV */
|
||||
if (!c) {
|
||||
if (!_add_pe_range(mem, pvname, pe_ranges, UINT32_C(0), size)) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
if (!_add_pe_range(mem, pvname, pe_ranges, UINT32_C(0), size))
|
||||
return_0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -1026,10 +1024,8 @@ static int _parse_pes(struct dm_pool *mem, char *c, struct list *pe_ranges,
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!_add_pe_range(mem, pvname, pe_ranges, start, end - start + 1)) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
if (!_add_pe_range(mem, pvname, pe_ranges, start, end - start + 1))
|
||||
return_0;
|
||||
|
||||
}
|
||||
|
||||
@ -1084,10 +1080,8 @@ static int _create_pv_entry(struct dm_pool *mem, struct pv_list *pvl,
|
||||
|
||||
/* Determine selected physical extents */
|
||||
if (!_parse_pes(mem, colon, new_pvl->pe_ranges, pv_dev_name(pvl->pv),
|
||||
pvl->pv->pe_count)) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
pvl->pv->pe_count))
|
||||
return_0;
|
||||
|
||||
return 1;
|
||||
}
|
||||
@ -1124,10 +1118,8 @@ struct list *create_pv_list(struct dm_pool *mem, struct volume_group *vg, int ar
|
||||
tagname)) {
|
||||
if (!_create_pv_entry(mem, pvl, NULL,
|
||||
allocatable_only,
|
||||
r)) {
|
||||
stack;
|
||||
return NULL;
|
||||
}
|
||||
r))
|
||||
return_NULL;
|
||||
}
|
||||
}
|
||||
continue;
|
||||
@ -1149,10 +1141,8 @@ struct list *create_pv_list(struct dm_pool *mem, struct volume_group *vg, int ar
|
||||
"Volume Group \"%s\"", pvname, vg->name);
|
||||
return NULL;
|
||||
}
|
||||
if (!_create_pv_entry(mem, pvl, colon, allocatable_only, r)) {
|
||||
stack;
|
||||
return NULL;
|
||||
}
|
||||
if (!_create_pv_entry(mem, pvl, colon, allocatable_only, r))
|
||||
return_NULL;
|
||||
}
|
||||
|
||||
if (list_empty(r))
|
||||
|
@ -42,12 +42,12 @@ static int _vgmerge_single(struct cmd_context *cmd, const char *vg_name_to,
|
||||
}
|
||||
|
||||
if (!vgs_are_compatible(cmd, vg_from, vg_to))
|
||||
goto error;
|
||||
goto_bad;
|
||||
|
||||
/* FIXME List arg: vg_show_with_pv_and_lv(vg_to); */
|
||||
|
||||
if (!archive(vg_from) || !archive(vg_to))
|
||||
goto error;
|
||||
goto_bad;
|
||||
|
||||
/* Merge volume groups */
|
||||
while (!list_empty(&vg_from->pvs)) {
|
||||
@ -75,13 +75,11 @@ static int _vgmerge_single(struct cmd_context *cmd, const char *vg_name_to,
|
||||
log_error("Failed to generate new "
|
||||
"random LVID for %s",
|
||||
lvl2->lv->name);
|
||||
goto error;
|
||||
goto bad;
|
||||
}
|
||||
if (!id_write_format(&lvid2->id[1], uuid,
|
||||
sizeof(uuid))) {
|
||||
stack;
|
||||
goto error;
|
||||
}
|
||||
sizeof(uuid)))
|
||||
goto_bad;
|
||||
|
||||
log_verbose("Changed LVID for %s to %s",
|
||||
lvl2->lv->name, uuid);
|
||||
@ -110,9 +108,8 @@ static int _vgmerge_single(struct cmd_context *cmd, const char *vg_name_to,
|
||||
|
||||
/* store it on disks */
|
||||
log_verbose("Writing out updated volume group");
|
||||
if (!vg_write(vg_to) || !vg_commit(vg_to)) {
|
||||
goto error;
|
||||
}
|
||||
if (!vg_write(vg_to) || !vg_commit(vg_to))
|
||||
goto_bad;
|
||||
|
||||
/* FIXME Remove /dev/vgfrom */
|
||||
|
||||
@ -125,7 +122,7 @@ static int _vgmerge_single(struct cmd_context *cmd, const char *vg_name_to,
|
||||
vg_from->name, vg_to->name);
|
||||
return ECMD_PROCESSED;
|
||||
|
||||
error:
|
||||
bad:
|
||||
unlock_vg(cmd, vg_name_from);
|
||||
unlock_vg(cmd, vg_name_to);
|
||||
return ECMD_FAILED;
|
||||
|
@ -25,10 +25,8 @@ static int _remove_pv(struct volume_group *vg, struct pv_list *pvl)
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!id_write_format(&pvl->pv->id, uuid, sizeof(uuid))) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
if (!id_write_format(&pvl->pv->id, uuid, sizeof(uuid)))
|
||||
return_0;
|
||||
|
||||
log_verbose("Removing PV with UUID %s from VG %s", uuid, vg->name);
|
||||
|
||||
@ -91,16 +89,12 @@ static int _remove_lv(struct cmd_context *cmd, struct logical_volume *lv,
|
||||
}
|
||||
|
||||
*list_unsafe = 1; /* May remove caller's lvht! */
|
||||
if (!vg_remove_snapshot(cow)) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
if (!vg_remove_snapshot(cow))
|
||||
return_0;
|
||||
log_verbose("Removing LV %s from VG %s", cow->name,
|
||||
lv->vg->name);
|
||||
if (!lv_remove(cow)) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
if (!lv_remove(cow))
|
||||
return_0;
|
||||
|
||||
first = 0;
|
||||
}
|
||||
@ -129,10 +123,8 @@ static int _remove_lv(struct cmd_context *cmd, struct logical_volume *lv,
|
||||
} else {
|
||||
/* Remove LV immediately. */
|
||||
log_verbose("Removing LV %s from VG %s", lv->name, lv->vg->name);
|
||||
if (!lv_remove(lv)) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
if (!lv_remove(lv))
|
||||
return_0;
|
||||
}
|
||||
|
||||
return 1;
|
||||
@ -177,10 +169,8 @@ static int _make_vg_consistent(struct cmd_context *cmd, struct volume_group *vg)
|
||||
only_mirror_images_found = 0;
|
||||
continue;
|
||||
}
|
||||
if (!_remove_lv(cmd, lv, &list_unsafe, &lvs_changed)) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
if (!_remove_lv(cmd, lv, &list_unsafe, &lvs_changed))
|
||||
return_0;
|
||||
if (list_unsafe)
|
||||
goto restart_loop;
|
||||
}
|
||||
@ -198,10 +188,8 @@ static int _make_vg_consistent(struct cmd_context *cmd, struct volume_group *vg)
|
||||
pvl = list_item(pvh, struct pv_list);
|
||||
if (pvl->pv->dev)
|
||||
continue;
|
||||
if (!_remove_pv(vg, pvl)) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
if (!_remove_pv(vg, pvl))
|
||||
return_0;
|
||||
}
|
||||
|
||||
/* VG is now consistent */
|
||||
@ -223,10 +211,9 @@ static int _make_vg_consistent(struct cmd_context *cmd, struct volume_group *vg)
|
||||
/* Suspend lvs_changed */
|
||||
init_partial(1);
|
||||
if (!suspend_lvs(cmd, &lvs_changed)) {
|
||||
stack;
|
||||
init_partial(0);
|
||||
vg_revert(vg);
|
||||
return 0;
|
||||
return_0;
|
||||
}
|
||||
init_partial(0);
|
||||
}
|
||||
@ -290,10 +277,8 @@ static int _make_vg_consistent(struct cmd_context *cmd, struct volume_group *vg)
|
||||
|
||||
if ((mimages != mirrored_seg->area_count) || remove_log){
|
||||
if (!reconfigure_mirror_images(mirrored_seg, mimages,
|
||||
NULL, remove_log)) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
NULL, remove_log))
|
||||
return_0;
|
||||
|
||||
if (!vg_write(vg)) {
|
||||
log_error("Failed to write out updated "
|
||||
@ -353,10 +338,8 @@ static int _make_vg_consistent(struct cmd_context *cmd, struct volume_group *vg)
|
||||
lvl->lv->vg->name);
|
||||
/* Skip LVs already removed by mirror code */
|
||||
if (find_lv_in_vg(vg, lvl->lv->name) &&
|
||||
!lv_remove(lvl->lv)) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
!lv_remove(lvl->lv))
|
||||
return_0;
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user