From ad6b0ebb737de14d9d841edba7108fc39943abff Mon Sep 17 00:00:00 2001 From: Alasdair Kergon Date: Wed, 9 Nov 2005 13:08:41 +0000 Subject: [PATCH] rename deptree --- WHATS_NEW | 6 ++++ lib/activate/dev_manager.c | 62 +++++++++++++++++++------------------- lib/activate/targets.h | 2 +- lib/error/errseg.c | 4 +-- lib/metadata/segtype.h | 2 +- lib/mirror/mirrored.c | 10 +++--- lib/striped/striped.c | 6 ++-- lib/zero/zero.c | 4 +-- 8 files changed, 51 insertions(+), 45 deletions(-) diff --git a/WHATS_NEW b/WHATS_NEW index db3514dc5..402aa357e 100644 --- a/WHATS_NEW +++ b/WHATS_NEW @@ -1,5 +1,11 @@ Version 2.02.00 - =================================== + Stop lvcreate attempting to wipe zero or error segments. + Added new lvs table attributes. + Separated out activation preload. + Moved activation functions into libdevmapper. + Fixed build_dm_name. + Add return macros. Added xen xvd devices. Clear up precommitted metadata better. A pvresize implementation. diff --git a/lib/activate/dev_manager.c b/lib/activate/dev_manager.c index 73f0955c0..acc6a67b4 100644 --- a/lib/activate/dev_manager.c +++ b/lib/activate/dev_manager.c @@ -573,7 +573,7 @@ int dev_manager_lv_rmnodes(const struct logical_volume *lv) return fs_del_lv(lv); } -static int _add_dev_to_deptree(struct dev_manager *dm, struct dm_tree *dtree, +static int _add_dev_to_dtree(struct dev_manager *dm, struct dm_tree *dtree, struct logical_volume *lv, const char *layer) { char *dlid, *name; @@ -592,7 +592,7 @@ static int _add_dev_to_deptree(struct dev_manager *dm, struct dm_tree *dtree, } if (info.exists && !dm_tree_add_dev(dtree, info.major, info.minor)) { - log_error("Failed to add device (%" PRIu32 ":%" PRIu32") to deptree", + log_error("Failed to add device (%" PRIu32 ":%" PRIu32") to dtree", info.major, info.minor); return 0; } @@ -603,39 +603,39 @@ static int _add_dev_to_deptree(struct dev_manager *dm, struct dm_tree *dtree, /* * Add LV and any known dependencies */ -static int _add_lv_to_deptree(struct dev_manager *dm, struct dm_tree *dtree, struct logical_volume *lv) +static int _add_lv_to_dtree(struct dev_manager *dm, struct dm_tree *dtree, struct logical_volume *lv) { - if (!_add_dev_to_deptree(dm, dtree, lv, NULL)) + if (!_add_dev_to_dtree(dm, dtree, lv, NULL)) return_0; /* FIXME Can we avoid doing this every time? */ - if (!_add_dev_to_deptree(dm, dtree, lv, "real")) + if (!_add_dev_to_dtree(dm, dtree, lv, "real")) return_0; - if (!_add_dev_to_deptree(dm, dtree, lv, "cow")) + if (!_add_dev_to_dtree(dm, dtree, lv, "cow")) return_0; return 1; } -static struct dm_tree *_create_partial_deptree(struct dev_manager *dm, struct logical_volume *lv) +static struct dm_tree *_create_partial_dtree(struct dev_manager *dm, struct logical_volume *lv) { struct dm_tree *dtree; struct list *snh, *snht; if (!(dtree = dm_tree_create())) { - log_error("Partial deptree creation failed for %s.", lv->name); + log_error("Partial dtree creation failed for %s.", lv->name); return NULL; } - if (!_add_lv_to_deptree(dm, dtree, lv)) { + if (!_add_lv_to_dtree(dm, dtree, lv)) { stack; goto fail; } /* Add any snapshots of this LV */ list_iterate_safe(snh, snht, &lv->snapshot_segs) - if (!_add_lv_to_deptree(dm, dtree, list_struct_base(snh, struct lv_segment, origin_list)->cow)) { + if (!_add_lv_to_dtree(dm, dtree, list_struct_base(snh, struct lv_segment, origin_list)->cow)) { stack; goto fail; } @@ -686,7 +686,7 @@ int add_areas_line(struct dev_manager *dm, struct lv_segment *seg, return 1; } -static int _add_origin_target_to_deptree(struct dev_manager *dm, +static int _add_origin_target_to_dtree(struct dev_manager *dm, struct dm_tree *dtree, struct dm_tree_node *dnode, struct logical_volume *lv) @@ -702,7 +702,7 @@ static int _add_origin_target_to_deptree(struct dev_manager *dm, return 1; } -static int _add_snapshot_target_to_deptree(struct dev_manager *dm, +static int _add_snapshot_target_to_dtree(struct dev_manager *dm, struct dm_tree *dtree, struct dm_tree_node *dnode, struct logical_volume *lv) @@ -731,7 +731,7 @@ static int _add_snapshot_target_to_deptree(struct dev_manager *dm, return 1; } -static int _add_target_to_deptree(struct dev_manager *dm, +static int _add_target_to_dtree(struct dev_manager *dm, struct dm_tree *dtree, struct dm_tree_node *dnode, struct lv_segment *seg) @@ -751,10 +751,10 @@ static int _add_target_to_deptree(struct dev_manager *dm, &dm-> pvmove_mirror_count); } -static int _add_new_lv_to_deptree(struct dev_manager *dm, struct dm_tree *dtree, +static int _add_new_lv_to_dtree(struct dev_manager *dm, struct dm_tree *dtree, struct logical_volume *lv, const char *layer); -static int _add_segment_to_deptree(struct dev_manager *dm, +static int _add_segment_to_dtree(struct dev_manager *dm, struct dm_tree *dtree, struct dm_tree_node *dnode, struct lv_segment *seg, @@ -773,7 +773,7 @@ static int _add_segment_to_deptree(struct dev_manager *dm, /* Add mirror log */ if (seg->log_lv && - !_add_new_lv_to_deptree(dm, dtree, seg->log_lv, NULL)) + !_add_new_lv_to_dtree(dm, dtree, seg->log_lv, NULL)) return_0; /* If this is a snapshot origin, add real LV */ @@ -782,39 +782,39 @@ static int _add_segment_to_deptree(struct dev_manager *dm, log_error("Clustered snapshots are not yet supported"); return 0; } - if (!_add_new_lv_to_deptree(dm, dtree, seg->lv, "real")) + if (!_add_new_lv_to_dtree(dm, dtree, seg->lv, "real")) return_0; } else if (lv_is_cow(seg->lv) && !layer) { - if (!_add_new_lv_to_deptree(dm, dtree, seg->lv, "cow")) + if (!_add_new_lv_to_dtree(dm, dtree, seg->lv, "cow")) return_0; } else { /* Add any LVs used by this segment */ for (s = 0; s < seg->area_count; s++) if ((seg_type(seg, s) == AREA_LV) && - (!_add_new_lv_to_deptree(dm, dtree, seg_lv(seg, s), NULL))) + (!_add_new_lv_to_dtree(dm, dtree, seg_lv(seg, s), NULL))) return_0; } /* Now we've added its dependencies, we can add the target itself */ if (lv_is_origin(seg->lv) && !layer) { - if (!_add_origin_target_to_deptree(dm, dtree, dnode, seg->lv)) + if (!_add_origin_target_to_dtree(dm, dtree, dnode, seg->lv)) return_0; } else if (lv_is_cow(seg->lv) && !layer) { - if (!_add_snapshot_target_to_deptree(dm, dtree, dnode, seg->lv)) + if (!_add_snapshot_target_to_dtree(dm, dtree, dnode, seg->lv)) return_0; - } else if (!_add_target_to_deptree(dm, dtree, dnode, seg)) + } else if (!_add_target_to_dtree(dm, dtree, dnode, seg)) return_0; if (lv_is_origin(seg->lv) && !layer) /* Add any snapshots of this LV */ list_iterate(snh, &seg->lv->snapshot_segs) - if (!_add_new_lv_to_deptree(dm, dtree, list_struct_base(snh, struct lv_segment, origin_list)->cow, NULL)) + if (!_add_new_lv_to_dtree(dm, dtree, list_struct_base(snh, struct lv_segment, origin_list)->cow, NULL)) return_0; return 1; } -static int _add_new_lv_to_deptree(struct dev_manager *dm, struct dm_tree *dtree, +static int _add_new_lv_to_dtree(struct dev_manager *dm, struct dm_tree *dtree, struct logical_volume *lv, const char *layer) { struct lv_segment *seg; @@ -835,14 +835,14 @@ static int _add_new_lv_to_deptree(struct dev_manager *dm, struct dm_tree *dtree, /* FIXME How do we determine whether a pre-existing node need reloading or not? */ if (!(lvlayer = dm_pool_alloc(dm->mem, sizeof(*lvlayer)))) { - log_error("_add_new_lv_to_deptree: pool alloc failed for %s %s.", lv->name, layer); + log_error("_add_new_lv_to_dtree: pool alloc failed for %s %s.", lv->name, layer); return 0; } lvlayer->lv = lv; /* - * Add LV to deptree. + * Add LV to dtree. * If we're working with precommitted metadata, clear any * existing inactive table left behind. * Major/minor settings only apply to the visible layer. @@ -861,7 +861,7 @@ static int _add_new_lv_to_deptree(struct dev_manager *dm, struct dm_tree *dtree, /* Create table */ dm->pvmove_mirror_count = 0u; list_iterate_items(seg, &lv->segments) { - if (!_add_segment_to_deptree(dm, dtree, dnode, seg, layer)) + if (!_add_segment_to_dtree(dm, dtree, dnode, seg, layer)) return_0; /* These aren't real segments in the LVM2 metadata */ if (lv_is_origin(lv) && !layer) @@ -942,7 +942,7 @@ static int _tree_action(struct dev_manager *dm, struct logical_volume *lv, actio char *dlid; int r = 0; - if (!(dtree = _create_partial_deptree(dm, lv))) + if (!(dtree = _create_partial_dtree(dm, lv))) return_0; if (!(root = dm_tree_find_node(dtree, 0, 0))) { @@ -972,7 +972,7 @@ static int _tree_action(struct dev_manager *dm, struct logical_volume *lv, actio case PRELOAD: case ACTIVATE: /* Add all required new devices to tree */ - if (!_add_new_lv_to_deptree(dm, dtree, lv, NULL)) + if (!_add_new_lv_to_dtree(dm, dtree, lv, NULL)) goto_out; /* Preload any devices required before any suspensions */ @@ -1043,12 +1043,12 @@ int dev_manager_device_uses_vg(struct dev_manager *dm, struct device *dev, int r = 1; if (!(dtree = dm_tree_create())) { - log_error("partial deptree creation failed"); + log_error("partial dtree creation failed"); return r; } if (!dm_tree_add_dev(dtree, MAJOR(dev->dev), MINOR(dev->dev))) { - log_error("Failed to add device %s (%" PRIu32 ":%" PRIu32") to deptree", + log_error("Failed to add device %s (%" PRIu32 ":%" PRIu32") to dtree", dev_name(dev), (uint32_t) MAJOR(dev->dev), (uint32_t) MINOR(dev->dev)); goto out; } diff --git a/lib/activate/targets.h b/lib/activate/targets.h index 8a8b8ac7e..ac5413e88 100644 --- a/lib/activate/targets.h +++ b/lib/activate/targets.h @@ -24,7 +24,7 @@ int compose_areas_line(struct dev_manager *dm, struct lv_segment *seg, int start_area, int areas); int add_areas_line(struct dev_manager *dm, struct lv_segment *seg, - struct deptree_node *node, int start_area, int areas); + struct dm_tree_node *node, int start_area, int areas); int build_dev_string(struct dev_manager *dm, char *dlid, char *devbuf, size_t bufsize, const char *desc); diff --git a/lib/error/errseg.c b/lib/error/errseg.c index a41619af9..54f1d9194 100644 --- a/lib/error/errseg.c +++ b/lib/error/errseg.c @@ -41,10 +41,10 @@ static int _merge_segments(struct lv_segment *seg1, struct lv_segment *seg2) static int _add_target_line(struct dev_manager *dm, struct dm_pool *mem, struct config_tree *cft, void **target_state, struct lv_segment *seg, - struct deptree_node *node, uint64_t len, + struct dm_tree_node *node, uint64_t len, uint32_t *pvmove_mirror_count) { - return dm_deptree_node_add_error_target(node, len); + return dm_tree_node_add_error_target(node, len); } static int _target_present(void) diff --git a/lib/metadata/segtype.h b/lib/metadata/segtype.h index 415feb0b7..e64b85d21 100644 --- a/lib/metadata/segtype.h +++ b/lib/metadata/segtype.h @@ -69,7 +69,7 @@ struct segtype_handler { int (*add_target_line) (struct dev_manager *dm, struct dm_pool *mem, struct config_tree *cft, void **target_state, struct lv_segment *seg, - struct deptree_node *node, uint64_t len, + struct dm_tree_node *node, uint64_t len, uint32_t *pvmove_mirror_count); int (*target_percent) (void **target_state, struct dm_pool * mem, struct config_tree * cft, diff --git a/lib/mirror/mirrored.c b/lib/mirror/mirrored.c index e3a7e2623..c8c4d0b40 100644 --- a/lib/mirror/mirrored.c +++ b/lib/mirror/mirrored.c @@ -217,7 +217,7 @@ static int _target_percent(void **target_state, struct dm_pool *mem, } static int _add_log(struct dev_manager *dm, struct lv_segment *seg, - struct deptree_node *node, uint32_t area_count, uint32_t region_size) + struct dm_tree_node *node, uint32_t area_count, uint32_t region_size) { unsigned clustered = 0; char *log_dlid = NULL; @@ -238,13 +238,13 @@ static int _add_log(struct dev_manager *dm, struct lv_segment *seg, } /* FIXME Add sync parm? */ - return dm_deptree_node_add_mirror_target_log(node, region_size, clustered, log_dlid, area_count); + return dm_tree_node_add_mirror_target_log(node, region_size, clustered, log_dlid, area_count); } static int _add_target_line(struct dev_manager *dm, struct dm_pool *mem, struct config_tree *cft, void **target_state, struct lv_segment *seg, - struct deptree_node *node, uint64_t len, + struct dm_tree_node *node, uint64_t len, uint32_t *pvmove_mirror_count) { struct mirror_state *mirr_state; @@ -276,7 +276,7 @@ static int _add_target_line(struct dev_manager *dm, struct dm_pool *mem, } if (mirror_status != MIRR_RUNNING) { - if (!dm_deptree_node_add_linear_target(node, len)) + if (!dm_tree_node_add_linear_target(node, len)) return_0; goto done; } @@ -300,7 +300,7 @@ static int _add_target_line(struct dev_manager *dm, struct dm_pool *mem, } } - if (!dm_deptree_node_add_mirror_target(node, len)) + if (!dm_tree_node_add_mirror_target(node, len)) return_0; if ((r = _add_log(dm, seg, node, area_count, region_size)) <= 0) { diff --git a/lib/striped/striped.c b/lib/striped/striped.c index e23da877b..eadd3426f 100644 --- a/lib/striped/striped.c +++ b/lib/striped/striped.c @@ -154,7 +154,7 @@ static int _merge_segments(struct lv_segment *seg1, struct lv_segment *seg2) static int _add_target_line(struct dev_manager *dm, struct dm_pool *mem, struct config_tree *cft, void **target_state, struct lv_segment *seg, - struct deptree_node *node, uint64_t len, + struct dm_tree_node *node, uint64_t len, uint32_t *pvmove_mirror_count) { if (!seg->area_count) { @@ -163,9 +163,9 @@ static int _add_target_line(struct dev_manager *dm, struct dm_pool *mem, return 0; } if (seg->area_count == 1) { - if (!dm_deptree_node_add_linear_target(node, len)) + if (!dm_tree_node_add_linear_target(node, len)) return_0; - } else if (!dm_deptree_node_add_striped_target(node, len, + } else if (!dm_tree_node_add_striped_target(node, len, seg->stripe_size)) return_0; diff --git a/lib/zero/zero.c b/lib/zero/zero.c index 6c3ccf064..1cc1bdc85 100644 --- a/lib/zero/zero.c +++ b/lib/zero/zero.c @@ -41,10 +41,10 @@ static int _merge_segments(struct lv_segment *seg1, struct lv_segment *seg2) static int _add_target_line(struct dev_manager *dm, struct dm_pool *mem, struct config_tree *cft, void **target_state, struct lv_segment *seg, - struct deptree_node *node, uint64_t len, + struct dm_tree_node *node, uint64_t len, uint32_t *pvmove_mirror_count) { - return dm_deptree_node_add_zero_target(node, len); + return dm_tree_node_add_zero_target(node, len); } static int _target_present(void)