mirror of
git://sourceware.org/git/lvm2.git
synced 2024-12-21 13:34:40 +03:00
dev_manager: implement _cached_dm_tree_node
This commit is contained in:
parent
a985d5c63d
commit
363e8888ae
@ -991,31 +991,43 @@ out:
|
|||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static struct dm_tree_node *_cached_dm_tree_node(struct dm_pool *mem,
|
||||||
|
struct dm_tree *dtree,
|
||||||
|
const struct logical_volume *lv,
|
||||||
|
const char *layer)
|
||||||
|
{
|
||||||
|
struct dm_tree_node *dnode;
|
||||||
|
char *dlid;
|
||||||
|
|
||||||
|
if (!(dlid = build_dm_uuid(mem, lv, layer)))
|
||||||
|
return_NULL;
|
||||||
|
|
||||||
|
dnode = dm_tree_find_node_by_uuid(dtree, dlid);
|
||||||
|
|
||||||
|
dm_pool_free(mem, dlid);
|
||||||
|
|
||||||
|
return dnode;
|
||||||
|
}
|
||||||
|
|
||||||
static const struct dm_info *_cached_dm_info(struct dm_pool *mem,
|
static const struct dm_info *_cached_dm_info(struct dm_pool *mem,
|
||||||
struct dm_tree *dtree,
|
struct dm_tree *dtree,
|
||||||
const struct logical_volume *lv,
|
const struct logical_volume *lv,
|
||||||
const char *layer)
|
const char *layer)
|
||||||
{
|
{
|
||||||
char *dlid;
|
|
||||||
const struct dm_tree_node *dnode;
|
const struct dm_tree_node *dnode;
|
||||||
const struct dm_info *dinfo = NULL;
|
const struct dm_info *dinfo = NULL;
|
||||||
|
|
||||||
if (!(dlid = build_dm_uuid(mem, lv, layer)))
|
if (!(dnode = _cached_dm_tree_node(mem, dtree, lv, layer)))
|
||||||
return_NULL;
|
return NULL;
|
||||||
|
|
||||||
if (!(dnode = dm_tree_find_node_by_uuid(dtree, dlid)))
|
|
||||||
goto out;
|
|
||||||
|
|
||||||
if (!(dinfo = dm_tree_node_get_info(dnode))) {
|
if (!(dinfo = dm_tree_node_get_info(dnode))) {
|
||||||
log_warn("WARNING: Cannot get info from tree node for %s.",
|
log_warn("WARNING: Cannot get info from tree node for %s.",
|
||||||
display_lvname(lv));
|
display_lvname(lv));
|
||||||
goto out;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!dinfo->exists)
|
if (!dinfo->exists)
|
||||||
dinfo = NULL;
|
dinfo = NULL;
|
||||||
out:
|
|
||||||
dm_pool_free(mem, dlid);
|
|
||||||
|
|
||||||
return dinfo;
|
return dinfo;
|
||||||
}
|
}
|
||||||
@ -2726,7 +2738,6 @@ static int _add_lv_to_dtree(struct dev_manager *dm, struct dm_tree *dtree,
|
|||||||
struct dm_list *snh;
|
struct dm_list *snh;
|
||||||
struct lv_segment *seg;
|
struct lv_segment *seg;
|
||||||
struct dm_tree_node *node;
|
struct dm_tree_node *node;
|
||||||
const char *uuid;
|
|
||||||
const struct logical_volume *plv;
|
const struct logical_volume *plv;
|
||||||
|
|
||||||
if (lv_is_pvmove(lv) && (dm->track_pvmove_deps == 2))
|
if (lv_is_pvmove(lv) && (dm->track_pvmove_deps == 2))
|
||||||
@ -2789,9 +2800,7 @@ static int _add_lv_to_dtree(struct dev_manager *dm, struct dm_tree *dtree,
|
|||||||
* and base this according to info.exists ?
|
* and base this according to info.exists ?
|
||||||
*/
|
*/
|
||||||
if (!dm->activation) {
|
if (!dm->activation) {
|
||||||
if (!(uuid = build_dm_uuid(dm->mem, lv, lv_layer(lv))))
|
if ((node = _cached_dm_tree_node(dm->mem, dtree, lv, lv_layer(lv)))) {
|
||||||
return_0;
|
|
||||||
if ((node = dm_tree_find_node_by_uuid(dtree, uuid))) {
|
|
||||||
if (origin_only) {
|
if (origin_only) {
|
||||||
struct lv_activate_opts laopts = {
|
struct lv_activate_opts laopts = {
|
||||||
.origin_only = 1,
|
.origin_only = 1,
|
||||||
@ -2835,10 +2844,7 @@ static int _add_lv_to_dtree(struct dev_manager *dm, struct dm_tree *dtree,
|
|||||||
if (!origin_only && !dm->activation && !dm->track_pending_delete) {
|
if (!origin_only && !dm->activation && !dm->track_pending_delete) {
|
||||||
/* Setup callback for non-activation partial tree */
|
/* Setup callback for non-activation partial tree */
|
||||||
/* Activation gets own callback when needed */
|
/* Activation gets own callback when needed */
|
||||||
/* TODO: extend _cached_dm_info() to return dnode */
|
if ((node = _cached_dm_tree_node(dm->mem, dtree, lv, lv_layer(lv))) &&
|
||||||
if (!(uuid = build_dm_uuid(dm->mem, lv, lv_layer(lv))))
|
|
||||||
return_0;
|
|
||||||
if ((node = dm_tree_find_node_by_uuid(dtree, uuid)) &&
|
|
||||||
!_pool_register_callback(dm, node, lv))
|
!_pool_register_callback(dm, node, lv))
|
||||||
return_0;
|
return_0;
|
||||||
}
|
}
|
||||||
@ -3287,14 +3293,10 @@ static int _add_new_external_lv_to_dtree(struct dev_manager *dm,
|
|||||||
struct lv_activate_opts *laopts)
|
struct lv_activate_opts *laopts)
|
||||||
{
|
{
|
||||||
struct seg_list *sl;
|
struct seg_list *sl;
|
||||||
char *dlid;
|
|
||||||
struct dm_tree_node *dnode;
|
struct dm_tree_node *dnode;
|
||||||
|
|
||||||
if (!(dlid = build_dm_uuid(dm->mem, external_lv, lv_layer(external_lv))))
|
|
||||||
return_0;
|
|
||||||
|
|
||||||
/* We've already processed this node if it already has a context ptr */
|
/* We've already processed this node if it already has a context ptr */
|
||||||
if ((dnode = dm_tree_find_node_by_uuid(dtree, dlid)) &&
|
if ((dnode = _cached_dm_tree_node(dm->mem, dtree, external_lv, lv_layer(external_lv))) &&
|
||||||
dm_tree_node_get_context(dnode)) {
|
dm_tree_node_get_context(dnode)) {
|
||||||
/* Skip repeated invocation of external lv processing */
|
/* Skip repeated invocation of external lv processing */
|
||||||
log_debug_activation("Skipping users for already added external origin LV %s.",
|
log_debug_activation("Skipping users for already added external origin LV %s.",
|
||||||
|
Loading…
Reference in New Issue
Block a user