master - thin: move pool messaging from resume to suspend
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=a900d150e4658a5d72c39acdd4fefd069b8f00b8 Commit: a900d150e4658a5d72c39acdd4fefd069b8f00b8 Parent: 5bef18f2eb1071a29b682f6f456a13a73493868e Author: Zdenek Kabelac <[email protected]> AuthorDate: Wed Jul 1 13:31:37 2015 +0200 Committer: Zdenek Kabelac <[email protected]> CommitterDate: Fri Jul 3 16:13:14 2015 +0200
thin: move pool messaging from resume to suspend
Existing messaging intarface for thin-pool has a few 'weak' points:
* Message were posted with each 'resume' operation, thus not allowing activation of thin-pool with the existing state.
* Acceleration skipped suspend step has not worked in cluster, since clvmd resumes only nodes which are suspended (have proper lock state).
* Resume may fail and code is not really designed to 'fail' in this phase (generic rule here is resume DOES NOT fail unless something serious is wrong and lvm2 tool usually doesn't handle recovery path in this case.)
* Full thin-pool suspend happened, when taken a thin-volume snapshot.
With this patch the new method relocates message passing into suspend state.
This has a few drawbacks with current API, but overal it performs better and gives are more posibilities to deal with errors.
Patch introduces a new logic for 'origin-only' suspend of thin-pool and this also relates to thin-volume when taking snapshot.
When suspend_origin_only operation is invoked on a pool with queued messages then only those messages are posted to thin-pool and actual suspend of thin pool and data and metadata volume is skipped.
This makes taking a snapshot of thin-volume lighter operation and avoids blocking of other unrelated active thin volumes.
Also fail now happens in 'suspend' state where the 'Fail' is more expected and it is better handled through error paths.
Activation of thin-pool is now not sending any message and leaves upto a tool to decided later how to finish unfinished double-commit transaction.
Problem which needs some API improvements relates to the lvm2 tree construction. For the suspend tree we do not add target table line into the tree, but only a device is inserted into a tree. Current mechanism to attach messages for thin-pool requires the libdm to know about thin-pool target, so lvm2 currently takes assumption, node is really a thin-pool and fills in the table line for this node (which should be ensured by the PRELOAD phase, but it's a misuse of internal API) we would possibly need to be able to attach message to 'any' node.
Other thing to notice - current messaging interface in thin-pool target requires to suspend thin volume origin first and then send a create message, but this could not have any 'nice' solution on lvm2 side and IMHO we should introduce something like 'create_after_resume' message.
Patch also changes the moment, where lvm2 transaction id is increased. Now it happens only after successful finish of kernel transaction id change. This change was needed to handle properly activation of pool, which is in the middle of unfinished transaction, and also this corrects usage of thin-pool by external apps like Docker.
--- WHATS_NEW | 1 + lib/activate/activate.c | 12 ++++----- lib/activate/dev_manager.c | 56 ++++++++++++++++++++++++++++++++++++-------- lib/metadata/lv_manip.c | 32 +++++++++++-------------- lib/metadata/thin_manip.c | 44 ++++++++++++++++++---------------- lib/thin/thin.c | 9 ++++--- libdm/libdm-deptree.c | 10 ++++++- 7 files changed, 102 insertions(+), 62 deletions(-)
WHATS_NEW +1 -0
@@ -1,5 +1,6 @@ Version 2.02.124 - ================================= + Move sending thin pool messages from resume to suspend phase. Report warning when pool is overprovisioned and not auto resized. Recognize free-form date/time values for lv_time field in selection criteria. Fix regression in select to match string fields if using synonyms (2.02.123).
lib/activate/activate.c +5 -7
@@ -1813,7 +1813,9 @@ static int _lv_suspend(struct cmd_context *cmd, const char *lvid_s, goto_out;/* Ignore origin_only unless LV is origin in both old and new metadata */ -if (!lv_is_thin_volume (ondisk_lv) && !(lv_is_origin (ondisk_lv) &&lv_is_origin (incore_lv))) +/* or LV is thin or thin pool volume */ +if (!lv_is_thin_volume (ondisk_lv) && !lv_is_thin_pool (ondisk_lv) && + !(lv_is_origin (ondisk_lv) &&lv_is_origin (incore_lv))) laopts->origin_only =0 ;if (test_mode ()) {
@@ -1987,7 +1989,6 @@ static int _lv_resume(struct cmd_context *cmd, const char *lvid_s,const struct logical_volume *lv_to_free =NULL ;struct lvinfo info;int r =0 ; -int messages_only =0 ;if (!activation ())return 1 ;
@@ -1995,10 +1996,7 @@ static int _lv_resume(struct cmd_context *cmd, const char *lvid_s,if (!lv && !(lv_to_free = lv =lv_from_lvid (cmd, lvid_s,0 ))) goto_out; -if (lv_is_thin_pool (lv) && laopts->origin_only) - messages_only =1 ; - -if (!lv_is_origin (lv) && !lv_is_thin_volume (lv)) +if (!lv_is_origin (lv) && !lv_is_thin_volume (lv) && !lv_is_thin_pool (lv)) laopts->origin_only =0 ;if (test_mode ()) {
@@ -2018,7 +2016,7 @@ static int _lv_resume(struct cmd_context *cmd, const char *lvid_s,if (!lv_info (cmd, lv, laopts->origin_only, &info,0 ,0 )) goto_out; -if (!info.exists || !(info.suspended || messages_only)) { +if (!info.exists || !info.suspended) {if (error_if_not_active) goto_out; r =1 ;
lib/activate/dev_manager.c +46 -10
107 lines not on this page · raw message
lib/metadata/lv_manip.c +14 -18
@@ -7372,11 +7372,8 @@ static struct logical_volume *_lv_create_an_lv(struct volume_group *vg, stack; goto revert_new_lv; } -/* When change is activating, don't duplicate backup call */ -if (!is_change_activating (lp->activate)) -backup (vg); } -if (is_change_activating (lp->activate)) { +if (!dm_list_empty (&first_seg (pool_lv)->thin_messages)) {/* Send message so that table preload knows new thin */ if (!lv_is_active (pool_lv)) {/* Avoid multiple thin-pool activations in this case */
@@ -7394,25 +7391,24 @@ static struct logical_volume *_lv_create_an_lv(struct volume_group *vg, } }/* Keep thin pool active until thin volume is activated */ -if (!update_pool_lv (pool_lv, (thin_pool_was_active <0 ) ?1 :0 )) { +if (!update_pool_lv (pool_lv,1 )) { stack; goto revert_new_lv; } + } +backup (vg); -backup (vg); - -if (!lv_active_change (cmd, lv, lp->activate,0 )) { -log_error ("Failed to activate thin %s." , lv->name); - goto deactivate_and_revert_new_lv; - } +if (!lv_active_change (cmd, lv, lp->activate,0 )) { +log_error ("Failed to activate thin %s." , lv->name); + goto deactivate_and_revert_new_lv; + } -/* Restore inactive state if needed */ -if (!thin_pool_was_active && - !deactivate_lv (cmd, pool_lv)) { -log_error ("Failed to deactivate thin pool %s." , -display_lvname (pool_lv)); -return NULL ; - } +/* Restore inactive state if needed */ +if (!thin_pool_was_active && + !deactivate_lv (cmd, pool_lv)) { +log_error ("Failed to deactivate thin pool %s." , +display_lvname (pool_lv)); +return NULL ; } }else if (lp->snapshot) { lv->status |=LV_TEMPORARY ;
lib/metadata/thin_manip.c +23 -21
78 lines not on this page · raw message
lib/thin/thin.c +5 -4
@@ -294,7 +294,8 @@ static int _thin_pool_add_target_line(struct dev_manager *dm,return 0 ; } -if (!dm_tree_node_add_thin_pool_target (node, len, seg->transaction_id, +if (!dm_tree_node_add_thin_pool_target (node, len, + seg->transaction_id + (laopts->send_messages ?1 :0 ), metadata_dlid, pool_dlid, seg->chunk_size, seg->low_water_mark, seg->zero_new_blocks ?0 :1 ))
@@ -372,11 +373,11 @@ static int _thin_pool_add_target_line(struct dev_manager *dm,if (!dm_list_empty (&seg->thin_messages)) {/* Messages were passed, modify transaction_id as the last one */ -log_debug_activation ("Thin pool set transaction id %" PRIu64"." , seg->transaction_id); +log_debug_activation ("Thin pool set transaction id %" PRIu64"." , seg->transaction_id +1 );if (!dm_tree_node_add_thin_pool_message (node,DM_THIN_MESSAGE_SET_TRANSACTION_ID , - seg->transaction_id -1 , - seg->transaction_id)) + seg->transaction_id, + seg->transaction_id +1 )) return_0; }
libdm/libdm-deptree.c +8 -2
@@ -241,7 +241,12 @@ struct load_properties {*/ unsigned delay_resume_if_new; -/* Send messages for this node in preload */ +/* +* Call node_send_messages(), set to 2 if there are messages +* When != 0, it validates matching transaction id, thus thin-pools +* where transation_id is passed as 0 are never validated, this +* allows external managment of thin-pool TID. +*/ unsigned send_messages;/* Skip suspending node's children, used when sending messages to thin-pool */ int skip_suspend;
@@ -3871,7 +3876,8 @@ int dm_tree_node_add_thin_pool_message(struct dm_tree_node *node, tm->message.type = type;dm_list_add (&seg->thin_messages, &tm->list); - node->props.send_messages =1 ; +/* Higher value >1 identifies there are really some messages */ + node->props.send_messages =2 ;return 1 ; }