From bbcd37e4b8962ddbc9f6827cde7eb9b925e472a5 Mon Sep 17 00:00:00 2001 From: Zdenek Kabelac Date: Sun, 30 Oct 2011 22:04:57 +0000 Subject: [PATCH] Thin segment transaction_id moved Add a new node flag send_messages that is used to simplify test when to call _node_send_messages(). Add call to _node_send_messages when pool is deeper in the tree. --- libdm/libdm-deptree.c | 40 +++++++++++++++++++++++++++------------- 1 file changed, 27 insertions(+), 13 deletions(-) diff --git a/libdm/libdm-deptree.c b/libdm/libdm-deptree.c index 53ce550b0..6b3a543b1 100644 --- a/libdm/libdm-deptree.c +++ b/libdm/libdm-deptree.c @@ -170,6 +170,7 @@ struct load_segment { struct dm_tree_node *metadata; /* Thin_pool */ struct dm_tree_node *pool; /* Thin_pool, Thin */ struct dm_list thin_messages; /* Thin_pool */ + uint64_t transaction_id; /* Thin_pool */ uint64_t low_water_mark; /* Thin_pool */ uint32_t data_block_size; /* Thin_pool */ unsigned skip_block_zeroing; /* Thin_pool */ @@ -186,8 +187,6 @@ struct load_properties { uint32_t read_ahead; uint32_t read_ahead_flags; - uint64_t thin_pool_transaction_id; /* Thin_pool */ - unsigned segment_count; unsigned size_changed; struct dm_list segs; @@ -209,6 +208,9 @@ struct load_properties { * avoid starting the mirror resync operation too early. */ unsigned delay_resume_if_new; + + /* Send messages for this node in preload */ + unsigned send_messages; }; /* Two of these used to join two nodes with uses and used_by. */ @@ -1335,8 +1337,7 @@ static int _node_send_messages(struct dm_tree_node *dnode, uint64_t trans_id; const char *uuid; - if ((dnode == &dnode->dtree->root) || /* root has props.segs uninitialized */ - !dnode->info.exists || (dm_list_size(&dnode->props.segs) != 1)) + if (!dnode->info.exists || (dm_list_size(&dnode->props.segs) != 1)) return 1; seg = dm_list_item(dm_list_last(&dnode->props.segs), struct load_segment); @@ -1352,22 +1353,28 @@ static int _node_send_messages(struct dm_tree_node *dnode, } if (!_thin_pool_status_transaction_id(dnode, &trans_id)) - return_0; + goto_bad; - if (trans_id == dnode->props.thin_pool_transaction_id) + if (trans_id == seg->transaction_id) return 1; /* In sync - skip messages */ - if (trans_id != (dnode->props.thin_pool_transaction_id - 1)) { + if (trans_id != (seg->transaction_id - 1)) { log_error("Thin pool transaction_id=%" PRIu64 ", while expected: %" PRIu64 ".", - trans_id, dnode->props.thin_pool_transaction_id - 1); - return 0; /* Nothing to send */ + trans_id, seg->transaction_id - 1); + goto bad; /* Nothing to send */ } dm_list_iterate_items(tmsg, &seg->thin_messages) if (!(_thin_pool_node_message(dnode, tmsg))) - return_0; + goto_bad; return 1; +bad: + /* Try to deactivate */ + if (!(dm_tree_deactivate_children(dnode, uuid_prefix, uuid_prefix_len))) + log_error("Failed to deactivate %s", dnode->name); + + return 0; } /* @@ -2315,7 +2322,11 @@ int dm_tree_preload_children(struct dm_tree_node *dnode, /* Update cached info */ child->info = newinfo; - + if (child->props.send_messages && + !(r = _node_send_messages(child, uuid_prefix, uuid_prefix_len))) { + stack; + continue; + } /* * Prepare for immediate synchronization with udev and flush all stacked * dev node operations if requested by immediate_dev_node property. But @@ -2325,7 +2336,9 @@ int dm_tree_preload_children(struct dm_tree_node *dnode, update_devs_flag = 1; } - handle = NULL; + if (r && dnode->props.send_messages && + !(r = _node_send_messages(dnode, uuid_prefix, uuid_prefix_len))) + stack; if (update_devs_flag) { if (!dm_udev_wait(dm_tree_get_cookie(dnode))) @@ -2875,7 +2888,8 @@ int dm_tree_node_add_thin_pool_target(struct dm_tree_node *node, if (!_link_tree_nodes(node, seg->pool)) return_0; - node->props.thin_pool_transaction_id = transaction_id; // compare on resume + node->props.send_messages = 1; + seg->transaction_id = transaction_id; seg->low_water_mark = low_water_mark; seg->data_block_size = data_block_size; seg->skip_block_zeroing = skip_block_zeroing; -- 2.43.5