master - lv_refresh: move the bulk of the function into lib
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=e043e03cd853f9dbeb653ecdd63957d39c7136cc Commit: e043e03cd853f9dbeb653ecdd63957d39c7136cc Parent: 3d9957e3dd82666a360481b3a18baa9f23c75300 Author: David Teigland <[email protected]> AuthorDate: Tue Jun 16 13:38:40 2015 -0500 Committer: David Teigland <[email protected]> CommitterDate: Tue Jun 16 13:38:40 2015 -0500
lv_refresh: move the bulk of the function into lib
So that it can be used from other lib code.
--- lib/metadata/lv_manip.c | 22 ++++++++++++++++++++++ lib/metadata/metadata-exported.h | 2 ++ tools/toollib.c | 18 ++---------------- 3 files changed, 26 insertions(+), 16 deletions(-)
lib/metadata/lv_manip.c +22 -0
@@ -1395,6 +1395,28 @@ int replace_lv_with_error_segment(struct logical_volume *lv)return 1 ; } +int lv_refresh_suspend_resume (struct cmd_context *cmd,struct logical_volume *lv) +{ +if (!cmd->partial_activation && (lv->status &PARTIAL_LV )) { +log_error ("Refusing refresh of partial LV %s." +" Use '--activationmode partial' to override." , +display_lvname (lv)); +return 0 ; + } + +if (!suspend_lv (cmd, lv)) { +log_error ("Failed to suspend %s." ,display_lvname (lv)); +return 0 ; + } + +if (!resume_lv (cmd, lv)) { +log_error ("Failed to reactivate %s." ,display_lvname (lv)); +return 0 ; + } + +return 1 ; +} +/* * Remove given number of extents from LV. */
lib/metadata/metadata-exported.h +2 -0
@@ -738,6 +738,8 @@ int lv_empty(struct logical_volume *lv);/* Empty an LV and add error segment */ int replace_lv_with_error_segment (struct logical_volume *lv); +int lv_refresh_suspend_resume (struct cmd_context *cmd,struct logical_volume *lv); +/* Entry point for all LV extent allocations */ int lv_extend(struct logical_volume *lv, const struct segment_type *segtype,
tools/toollib.c +2 -16
@@ -850,22 +850,8 @@ int lv_change_activate(struct cmd_context *cmd, struct logical_volume *lv,int lv_refresh (struct cmd_context *cmd,struct logical_volume *lv) { -if (!cmd->partial_activation && (lv->status &PARTIAL_LV )) { -log_error ("Refusing refresh of partial LV %s." -" Use '--activationmode partial' to override." , - lv->name); -return 0 ; - } - -if (!suspend_lv (cmd, lv)) { -log_error ("Failed to suspend %s." , lv->name); -return 0 ; - } - -if (!resume_lv (cmd, lv)) { -log_error ("Failed to reactivate %s." , lv->name); -return 0 ; - } +if (!lv_refresh_suspend_resume (cmd, lv)) + return_0;/* * check if snapshot merge should be polled