diff options
author | David Teigland <teigland@redhat.com> | 2015-06-16 13:38:40 -0500 |
---|---|---|
committer | David Teigland <teigland@redhat.com> | 2015-06-16 13:38:40 -0500 |
commit | e043e03cd853f9dbeb653ecdd63957d39c7136cc (patch) | |
tree | b623863785aba13baf4b3db5ff40ddc7ae7ec942 | |
parent | 3d9957e3dd82666a360481b3a18baa9f23c75300 (diff) | |
download | lvm2-dev-dct-next.tar.gz |
lv_refresh: move the bulk of the function into libdev-dct-next
So that it can be used from other lib code.
-rw-r--r-- | lib/metadata/lv_manip.c | 22 | ||||
-rw-r--r-- | lib/metadata/metadata-exported.h | 2 | ||||
-rw-r--r-- | tools/toollib.c | 18 |
3 files changed, 26 insertions, 16 deletions
diff --git a/lib/metadata/lv_manip.c b/lib/metadata/lv_manip.c index 1251a5d90..998379381 100644 --- a/lib/metadata/lv_manip.c +++ b/lib/metadata/lv_manip.c @@ -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. */ diff --git a/lib/metadata/metadata-exported.h b/lib/metadata/metadata-exported.h index b673af3d3..ff10a98b9 100644 --- a/lib/metadata/metadata-exported.h +++ b/lib/metadata/metadata-exported.h @@ -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, diff --git a/tools/toollib.c b/tools/toollib.c index ca198dceb..bfd378985 100644 --- a/tools/toollib.c +++ b/tools/toollib.c @@ -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 |