master - tests: more places where missing should not appear
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=ce83162d7c7eae00893...
Commit: ce83162d7c7eae008935989a26dbf23dfb08d0f9
Parent: 7eae2647c0ad4458b90b7bcc85e42668b9f49607
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Tue Nov 21 17:34:41 2017 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Fri Nov 24 16:09:59 2017 +0100
tests: more places where missing should not appear
---
test/shell/lvconvert-repair-cache.sh | 2 ++
1 files changed, 2 insertions(+), 0 deletions(-)
diff --git a/test/shell/lvconvert-repair-cache.sh b/test/shell/lvconvert-repair-cache.sh
index b7925e2..4b9d8b8 100644
--- a/test/shell/lvconvert-repair-cache.sh
+++ b/test/shell/lvconvert-repair-cache.sh
@@ -50,6 +50,8 @@ aux disable_dev "$dev1"
not lvconvert --uncache $vg/$lv1
# --yes to drop when Check its prompting
lvconvert --yes --uncache $vg/$lv1
+should not dmsetup remove ${vg}-cpool_cmeta-missing_0_0
+should not dmsetup remove ${vg}-cpool_cdata-missing_0_0
"$FSCK" -n "$DM_DEV_DIR/$vg/$lv1"
6 years, 5 months
master - tests: typo
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=7eae2647c0ad4458b90...
Commit: 7eae2647c0ad4458b90b7bcc85e42668b9f49607
Parent: 7bffbe0e2f7f43acf9cdb93f9d24cfb8638c7e7b
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Tue Nov 21 15:34:02 2017 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Fri Nov 24 16:09:59 2017 +0100
tests: typo
---
test/shell/lvconvert-repair-cache.sh | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/test/shell/lvconvert-repair-cache.sh b/test/shell/lvconvert-repair-cache.sh
index 5470e3f..b7925e2 100644
--- a/test/shell/lvconvert-repair-cache.sh
+++ b/test/shell/lvconvert-repair-cache.sh
@@ -46,7 +46,7 @@ aux disable_dev "$dev1"
#lvchange -an $vg
-# Check it is prompting fro confirmation
+# Check it is prompting for confirmation
not lvconvert --uncache $vg/$lv1
# --yes to drop when Check its prompting
lvconvert --yes --uncache $vg/$lv1
6 years, 5 months
master - cleanup: update error messages
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=7bffbe0e2f7f43acf9c...
Commit: 7bffbe0e2f7f43acf9cdb93f9d24cfb8638c7e7b
Parent: b0398f42ad125ca084e2b6942e23cacaafabd98e
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Tue Nov 21 15:33:29 2017 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Fri Nov 24 16:09:59 2017 +0100
cleanup: update error messages
Correct printed lv names in error messages
and add missing trace for return.
---
tools/lvconvert.c | 18 +++++++++---------
tools/pvmove_poll.c | 2 +-
2 files changed, 10 insertions(+), 10 deletions(-)
diff --git a/tools/lvconvert.c b/tools/lvconvert.c
index d5491a7..deb7cc9 100644
--- a/tools/lvconvert.c
+++ b/tools/lvconvert.c
@@ -2328,15 +2328,15 @@ static int _lvconvert_thin_pool_repair(struct cmd_context *cmd,
deactivate_mlv:
if (!deactivate_lv(cmd, mlv)) {
log_error("Cannot deactivate thin pool metadata volume %s.",
- mlv->name);
- return 0;
+ display_lvname(mlv));
+ ret = 0;
}
deactivate_pmslv:
if (!deactivate_lv(cmd, pmslv)) {
- log_error("Cannot deactivate thin pool metadata volume %s.",
- mlv->name);
- return 0;
+ log_error("Cannot deactivate pool metadata spare volume %s.",
+ display_lvname(pmslv));
+ ret = 0;
}
if (!ret)
@@ -2500,15 +2500,15 @@ static int _lvconvert_cache_repair(struct cmd_context *cmd,
deactivate_mlv:
if (!deactivate_lv(cmd, mlv)) {
log_error("Cannot deactivate pool metadata volume %s.",
- mlv->name);
- return 0;
+ display_lvname(mlv));
+ ret = 0;
}
deactivate_pmslv:
if (!deactivate_lv(cmd, pmslv)) {
log_error("Cannot deactivate pool metadata spare volume %s.",
- mlv->name);
- return 0;
+ display_lvname(pmslv));
+ ret = 0;
}
if (!ret)
diff --git a/tools/pvmove_poll.c b/tools/pvmove_poll.c
index 982bf96..f573eb9 100644
--- a/tools/pvmove_poll.c
+++ b/tools/pvmove_poll.c
@@ -64,7 +64,7 @@ static int _detach_pvmove_mirror(struct cmd_context *cmd,
if (!lv_remove_mirrors(cmd, lv_mirr, 1, 0, _is_pvmove_image_removable, &mimage_to_remove, PVMOVE) ||
!remove_layers_for_segments_all(cmd, lv_mirr, PVMOVE,
&lvs_completed)) {
- return 0;
+ return_0;
}
dm_list_iterate_items(lvl, &lvs_completed)
6 years, 5 months
master - cleanup: using max args consistently
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=b0398f42ad125ca084e...
Commit: b0398f42ad125ca084e2b6942e23cacaafabd98e
Parent: 54741aeac5e45abbad26343776a6205dab85b0fb
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Tue Nov 21 17:36:09 2017 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Fri Nov 24 16:09:59 2017 +0100
cleanup: using max args consistently
Define and use MAX_PDATA_ARGS for thin_repair and cache_repair consistently.
---
tools/lvconvert.c | 14 ++++++++------
1 files changed, 8 insertions(+), 6 deletions(-)
diff --git a/tools/lvconvert.c b/tools/lvconvert.c
index ed1a130..d5491a7 100644
--- a/tools/lvconvert.c
+++ b/tools/lvconvert.c
@@ -18,6 +18,8 @@
#include "lv_alloc.h"
#include "lvconvert_poll.h"
+#define MAX_PDATA_ARGS 10 /* Max number of accepted args for d-m-p-d tools */
+
typedef enum {
/* Split:
* For a mirrored or raid LV, split mirror into two mirrors, optionally tracking
@@ -2204,7 +2206,7 @@ static int _lvconvert_thin_pool_repair(struct cmd_context *cmd,
const struct dm_config_value *cv;
int ret = 0, status;
int args = 0;
- const char *argv[19]; /* Max supported 10 args */
+ const char *argv[MAX_PDATA_ARGS + 7]; /* Max supported args */
char *dm_name, *trans_id_str;
char meta_path[PATH_MAX];
char pms_path[PATH_MAX];
@@ -2250,7 +2252,7 @@ static int _lvconvert_thin_pool_repair(struct cmd_context *cmd,
return 0;
}
- for (cv = cn->v; cv && args < 16; cv = cv->next) {
+ for (cv = cn->v; cv && args < MAX_PDATA_ARGS; cv = cv->next) {
if (cv->type != DM_CFG_STRING) {
log_error("Invalid string in config file: "
"global/thin_repair_options");
@@ -2259,7 +2261,7 @@ static int _lvconvert_thin_pool_repair(struct cmd_context *cmd,
argv[++args] = cv->v.str;
}
- if (args == 10) {
+ if (args >= MAX_PDATA_ARGS) {
log_error("Too many options for thin repair command.");
return 0;
}
@@ -2401,7 +2403,7 @@ static int _lvconvert_cache_repair(struct cmd_context *cmd,
const struct dm_config_value *cv;
int ret = 0, status;
int args = 0;
- const char *argv[19]; /* Max supported 10 args */
+ const char *argv[MAX_PDATA_ARGS + 7]; /* Max supported args */
char *dm_name;
char meta_path[PATH_MAX];
char pms_path[PATH_MAX];
@@ -2448,7 +2450,7 @@ static int _lvconvert_cache_repair(struct cmd_context *cmd,
return 0;
}
- for (cv = cn->v; cv && args < 16; cv = cv->next) {
+ for (cv = cn->v; cv && args < MAX_PDATA_ARGS; cv = cv->next) {
if (cv->type != DM_CFG_STRING) {
log_error("Invalid string in config file: "
"global/cache_repair_options");
@@ -2457,7 +2459,7 @@ static int _lvconvert_cache_repair(struct cmd_context *cmd,
argv[++args] = cv->v.str;
}
- if (args == 10) {
+ if (args >= MAX_PDATA_ARGS) {
log_error("Too many options for cache repair command.");
return 0;
}
6 years, 5 months
master - cleanup: reduce couple debug lines
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=54741aeac5e45abbad2...
Commit: 54741aeac5e45abbad26343776a6205dab85b0fb
Parent: 5e88d3a89b353ad4d286d453dcc24042b09efaf9
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Fri Nov 17 00:01:45 2017 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Fri Nov 24 16:09:59 2017 +0100
cleanup: reduce couple debug lines
---
lib/cache/lvmetad.c | 29 +++++++++++++++++------------
1 files changed, 17 insertions(+), 12 deletions(-)
diff --git a/lib/cache/lvmetad.c b/lib/cache/lvmetad.c
index 1fd9091..6755ed6 100644
--- a/lib/cache/lvmetad.c
+++ b/lib/cache/lvmetad.c
@@ -551,6 +551,7 @@ static int _token_update(int *replaced_update)
daemon_reply reply;
const char *token_expected;
const char *prev_token;
+ const char *reply_str;
int update_pid;
int ending_our_update;
@@ -567,13 +568,14 @@ static int _token_update(int *replaced_update)
}
update_pid = (int)daemon_reply_int(reply, "update_pid", 0);
+ reply_str = daemon_reply_str(reply, "response", "");
/*
* A mismatch can only happen when this command attempts to set the
* token to filter:<hash> at the end of its update, but the update has
* been preempted in lvmetad by a new one (from update_pid).
*/
- if (!strcmp(daemon_reply_str(reply, "response", ""), "token_mismatch")) {
+ if (!strcmp(reply_str, "token_mismatch")) {
token_expected = daemon_reply_str(reply, "expected", "");
ending_our_update = strcmp(_lvmetad_token, LVMETAD_TOKEN_UPDATE_IN_PROGRESS);
@@ -599,7 +601,7 @@ static int _token_update(int *replaced_update)
return 0;
}
- if (strcmp(daemon_reply_str(reply, "response", ""), "OK")) {
+ if (strcmp(reply_str, "OK")) {
log_error("Failed response from lvmetad for token update.");
daemon_reply_destroy(reply);
return 0;
@@ -626,6 +628,7 @@ static int _lvmetad_handle_reply(daemon_reply reply, const char *id, const char
{
const char *token_expected;
const char *action;
+ const char *reply_str;
int action_modifies = 0;
int daemon_in_update;
int we_are_in_update;
@@ -670,8 +673,8 @@ static int _lvmetad_handle_reply(daemon_reply reply, const char *id, const char
/*
* Errors related to token mismatch.
*/
-
- if (!strcmp(daemon_reply_str(reply, "response", ""), "token_mismatch")) {
+ reply_str = daemon_reply_str(reply, "response", "");
+ if (!strcmp(reply_str, "token_mismatch")) {
token_expected = daemon_reply_str(reply, "expected", "");
update_pid = (int)daemon_reply_int(reply, "update_pid", 0);
@@ -769,14 +772,14 @@ static int _lvmetad_handle_reply(daemon_reply reply, const char *id, const char
*/
/* All OK? */
- if (!strcmp(daemon_reply_str(reply, "response", ""), "OK")) {
+ if (!strcmp(reply_str, "OK")) {
if (found)
*found = 1;
return 1;
}
/* Unknown device permitted? */
- if (found && !strcmp(daemon_reply_str(reply, "response", ""), "unknown")) {
+ if (found && !strcmp(reply_str, "unknown")) {
log_very_verbose("Request to %s %s%sin lvmetad did not find any matching object.",
action, object, *object ? " " : "");
*found = 0;
@@ -784,7 +787,7 @@ static int _lvmetad_handle_reply(daemon_reply reply, const char *id, const char
}
/* Multiple VGs with the same name were found. */
- if (found && !strcmp(daemon_reply_str(reply, "response", ""), "multiple")) {
+ if (found && !strcmp(reply_str, "multiple")) {
log_very_verbose("Request to %s %s%sin lvmetad found multiple matching objects.",
action, object, *object ? " " : "");
if (found)
@@ -1607,7 +1610,7 @@ int lvmetad_pv_found(struct cmd_context *cmd, const struct id *pvid, struct devi
struct dm_config_tree *pvmeta, *vgmeta;
const char *status = NULL, *vgname = NULL;
int64_t changed = 0;
- int result;
+ int result, seqno_after;
if (!lvmetad_used() || test_mode())
return 1;
@@ -1672,10 +1675,12 @@ int lvmetad_pv_found(struct cmd_context *cmd, const struct id *pvid, struct devi
result = _lvmetad_handle_reply(reply, "pv_found", uuid, NULL);
- if (vg && result &&
- (daemon_reply_int(reply, "seqno_after", -1) != vg->seqno ||
- daemon_reply_int(reply, "seqno_after", -1) != daemon_reply_int(reply, "seqno_before", -1)))
- log_warn("WARNING: Inconsistent metadata found for VG %s", vg->name);
+ if (vg && result) {
+ seqno_after = daemon_reply_int(reply, "seqno_after", -1);
+ if ((seqno_after != vg->seqno) ||
+ (seqno_after != daemon_reply_int(reply, "seqno_before", -1)))
+ log_warn("WARNING: Inconsistent metadata found for VG %s", vg->name);
+ }
if (result && found_vgnames) {
status = daemon_reply_str(reply, "status", NULL);
6 years, 5 months
master - cache: use conditional in warning message
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=5e88d3a89b353ad4d28...
Commit: 5e88d3a89b353ad4d286d453dcc24042b09efaf9
Parent: 5b5c5cc618bbfaa2945d6fe2211443b28588764a
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Mon Nov 20 16:33:43 2017 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Fri Nov 24 16:09:59 2017 +0100
cache: use conditional in warning message
In some cases the message could be slightly misleading so use
here rather conditional.
TODO:
In future we may possibly further tune the message in case we are
certain the level of redundancy protection has not been reduced.
---
lib/metadata/cache_manip.c | 2 +-
test/shell/lvconvert-cache-raid.sh | 4 ++--
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/lib/metadata/cache_manip.c b/lib/metadata/cache_manip.c
index 5e0e5c4..55ed724 100644
--- a/lib/metadata/cache_manip.c
+++ b/lib/metadata/cache_manip.c
@@ -129,7 +129,7 @@ void cache_check_for_warns(const struct lv_segment *seg)
if (lv_is_raid(origin_lv) &&
first_seg(seg->pool_lv)->cache_mode == CACHE_MODE_WRITEBACK)
- log_warn("WARNING: Data redundancy is lost with writeback "
+ log_warn("WARNING: Data redundancy could be lost with writeback "
"caching of raid logical volume!");
if (lv_is_thin_pool_data(seg->lv))
diff --git a/test/shell/lvconvert-cache-raid.sh b/test/shell/lvconvert-cache-raid.sh
index 9e4f55c..ec9b1e4 100644
--- a/test/shell/lvconvert-cache-raid.sh
+++ b/test/shell/lvconvert-cache-raid.sh
@@ -39,7 +39,7 @@ lvcreate --type raid1 -m 1 --nosync -l 2 -n $lv1 $vg
lvcreate --type raid1 -m 1 --nosync -l 2 -n ${lv1}_cachepool $vg
#should lvs -a $vg/${lv1}_cdata_rimage_0 # ensure images are properly renamed
lvconvert --yes --type cache --cachemode writeback --cachepool $vg/${lv1}_cachepool $vg/$lv1 2>&1 | tee out
-grep "WARNING: Data redundancy is lost" out
+grep "WARNING: Data redundancy could be lost" out
check lv_exists $vg/${lv1}_corig_rimage_0 # ensure images are properly renamed
dmsetup table ${vg}-$lv1 | grep cache # ensure it is loaded in kernel
lvremove -f $vg
@@ -47,7 +47,7 @@ lvremove -f $vg
lvcreate -n corigin -m 1 --type raid1 --nosync -l 10 $vg
lvcreate -n cpool --type cache $vg/corigin --cachemode writeback -l 10 2>&1 | tee out
-grep "WARNING: Data redundancy is lost" out
+grep "WARNING: Data redundancy could be lost" out
not lvconvert --splitmirrors 1 --name split $vg/corigin "$dev1"
lvconvert --yes --splitmirrors 1 --name split $vg/corigin "$dev1"
6 years, 5 months
master - toollib: avoid printing default stripe size
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=5b5c5cc618bbfaa2945...
Commit: 5b5c5cc618bbfaa2945d6fe2211443b28588764a
Parent: 16ef133be2a6aaa0d16078326e739d19eaf5f66b
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Fri Nov 17 23:02:44 2017 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Fri Nov 24 16:09:59 2017 +0100
toollib: avoid printing default stripe size
When user is not creating striped LV, do not print
rather confusing info about default stripe size.
---
WHATS_NEW | 1 +
tools/toollib.c | 2 +-
2 files changed, 2 insertions(+), 1 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index c27db7c..f78b6c2 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.177 -
====================================
+ Fix printing of default stripe size when user is not using stripes.
Activation code for pvmove automatically discovers holding LVs for resume.
Make a pvmove LV locking holder.
Do not change critical section counter on resume path without real resume.
diff --git a/tools/toollib.c b/tools/toollib.c
index 9b88341..ffd9a4d 100644
--- a/tools/toollib.c
+++ b/tools/toollib.c
@@ -1271,7 +1271,7 @@ static int _validate_stripe_params(struct cmd_context *cmd, const struct segment
if (!stripe_size_required && *stripe_size) {
log_print_unless_silent("Ignoring stripesize argument for %s devices.", segtype->name);
*stripe_size = 0;
- } else if (*stripes == 1 && (segtype_is_striped_target(segtype) || segtype_is_mirror(segtype))) {
+ } else if (*stripes == 1 && stripe_size_required) {
stripe_size_required = 0;
if (*stripe_size) {
log_print_unless_silent("Ignoring stripesize argument with single stripe.");
6 years, 5 months
master - pvmove: finish no longer needs explicit resumed
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=16ef133be2a6aaa0d16...
Commit: 16ef133be2a6aaa0d16078326e739d19eaf5f66b
Parent: 2a6981a6976368f633942a13cf007b141b2ece0a
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Fri Nov 24 14:00:22 2017 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Fri Nov 24 16:09:59 2017 +0100
pvmove: finish no longer needs explicit resumed
Activation code can see from holders needed LVs for resume.
---
tools/pvmove_poll.c | 17 -----------------
1 files changed, 0 insertions(+), 17 deletions(-)
diff --git a/tools/pvmove_poll.c b/tools/pvmove_poll.c
index 36c2d0c..982bf96 100644
--- a/tools/pvmove_poll.c
+++ b/tools/pvmove_poll.c
@@ -92,10 +92,6 @@ int pvmove_update_metadata(struct cmd_context *cmd, struct volume_group *vg,
int pvmove_finish(struct cmd_context *cmd, struct volume_group *vg,
struct logical_volume *lv_mirr, struct dm_list *lvs_changed)
{
- struct lv_list *lvl;
- struct logical_volume *holder;
- int r = 1;
-
if (!dm_list_empty(lvs_changed) &&
(!_detach_pvmove_mirror(cmd, lv_mirr) ||
!replace_lv_with_error_segment(lv_mirr))) {
@@ -106,19 +102,6 @@ int pvmove_finish(struct cmd_context *cmd, struct volume_group *vg,
if (!lv_update_and_reload(lv_mirr))
return_0;
- /* Takes locks and resumed volumes (should be still suspended, but preloaded) */
- dm_list_iterate_items(lvl, lvs_changed) {
- holder = (struct logical_volume *) lv_lock_holder(lvl->lv);
- if (!resume_lv(cmd, holder)) {
- log_error("Failed to reactivate logical volume %s.",
- display_lvname(holder));
- r = 0; /* But try to resume as much as we can */
- }
- }
-
- if (!r)
- return 0;
-
/* Deactivate mirror LV */
if (!deactivate_lv(cmd, lv_mirr)) {
log_error("ABORTING: Unable to deactivate temporary logical "
6 years, 5 months
master - activation: automaticaly discover pvmove holders
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=2a6981a6976368f6339...
Commit: 2a6981a6976368f633942a13cf007b141b2ece0a
Parent: ddbe763eb81c5f9608ca9ff192bd33d9d37acd77
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Fri Nov 24 13:55:42 2017 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Fri Nov 24 16:09:59 2017 +0100
activation: automaticaly discover pvmove holders
When pvmove is finished and does 'suspend/resume' on PVMOVE LV,
on resume path committed metadata are already showing 'standalone'
pvmove LV prepared just for removal.
However code should be able to 'resume' preloaded LV there were
participating in pvmove operation.
Previously this was all done in the 'tools' part of lvm2 code.
So the lvconvert upon pvmove finish had to explicitely call 'resume' on every such LV.
Now 'smarted' activation code is able to deduce and combine all information from
the active dm table and committed metadata so single call resolves
it all in one go.
Internally holders are detected by reading sysfs directory to capture
all needed UUID which are then looked in lvm2 metadata and all such
LVs are automatically collected into dmtree.
---
WHATS_NEW | 1 +
lib/activate/dev_manager.c | 108 ++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 109 insertions(+), 0 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index f29a498..c27db7c 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.177 -
====================================
+ Activation code for pvmove automatically discovers holding LVs for resume.
Make a pvmove LV locking holder.
Do not change critical section counter on resume path without real resume.
Enhance activation code to automatically suspend pvmove participants.
diff --git a/lib/activate/dev_manager.c b/lib/activate/dev_manager.c
index 1ca3baa..76fc546 100644
--- a/lib/activate/dev_manager.c
+++ b/lib/activate/dev_manager.c
@@ -26,6 +26,7 @@
#include "activate.h"
#include "lvm-exec.h"
#include "str_list.h"
+#include "dm-ioctl.h" /* for DM_UUID_LEN */
#include <limits.h>
#include <dirent.h>
@@ -1717,6 +1718,104 @@ static uint16_t _get_udev_flags(struct dev_manager *dm, const struct logical_vol
return udev_flags;
}
+static int _add_lv_to_dtree(struct dev_manager *dm, struct dm_tree *dtree,
+ const struct logical_volume *lv, int origin_only);
+/*
+ * Add exiting devices which holds given LV device open.
+ * This is used in case when metadata already do not contain information
+ * i.e. PVMOVE is being finished and final table is going to be resumed.
+ */
+static int _add_holders_to_dtree(struct dev_manager *dm, struct dm_tree *dtree,
+ const struct logical_volume *lv, struct dm_info *info)
+{
+ const char *default_uuid_prefix = dm_uuid_prefix();
+ const size_t default_uuid_prefix_len = strlen(default_uuid_prefix);
+ const char *sysfs_dir = dm_sysfs_dir();
+ char sysfs_path[PATH_MAX];
+ char uuid_path[PATH_MAX];
+ char uuid_buf[DM_UUID_LEN + 1];
+ char *uuid;
+ struct dirent *dirent;
+ DIR *d;
+ FILE *fp;
+ struct logical_volume *lv_det;
+ int r = 0;
+
+ /* Sysfs path of holders */
+ if (dm_snprintf(sysfs_path, sizeof(sysfs_path), "%sdev/block/" FMTu32
+ ":" FMTu32 "/holders", sysfs_dir, info->major, info->minor) < 0) {
+ log_error("sysfs_path dm_snprintf failed.");
+ return 0;
+ }
+
+ if (!(d = opendir(sysfs_path))) {
+ if (errno != ENOENT)
+ log_sys_error("opendir", sysfs_path);
+ return 0;
+ }
+
+ while ((dirent = readdir(d))) {
+ if (!strcmp(dirent->d_name, ".") || !strcmp(dirent->d_name, ".."))
+ continue;
+
+ /* Determine path where sysfs holds UUID for holding dm device */
+ if (dm_snprintf(uuid_path, sizeof(uuid_path), "%s/%s/dm/uuid",
+ sysfs_path, dirent->d_name) < 0) {
+ log_error("uuid_path dm_snprintf failed.");
+ goto out;
+ }
+
+ if (!(fp = fopen(uuid_path, "r"))) {
+ log_sys_error("fopen", uuid_path);
+ goto out;
+ }
+
+ if (!fgets(uuid_buf, sizeof(uuid_buf), fp)) {
+ log_sys_error("fgets", uuid_path);
+ fclose(fp);
+ goto out;
+ }
+
+ if (fclose(fp))
+ log_sys_debug("fclose", uuid_path);
+
+ uuid = uuid_buf;
+ log_debug_activation("Checking holder of LV %s with uuid %s.",
+ display_lvname(lv), uuid);
+
+ /* Skip common uuid LVM prefix */
+ if (!strncmp(default_uuid_prefix, uuid, default_uuid_prefix_len))
+ uuid += default_uuid_prefix_len;
+
+ /* Check holder comes from processed VG and is not yet in dmtree */
+ if (!strncmp(uuid, (char*)&lv->vg->id, sizeof(lv->vg->id)) &&
+ !dm_tree_find_node_by_uuid(dtree, uuid)) {
+ uuid[2 * sizeof(struct id)] = 0; /* Cut any suffix */
+ /* If UUID is not yet in dtree, look for matching LV */
+ if (!(lv_det = find_lv_in_vg_by_lvid(lv->vg, (union lvid*)uuid))) {
+ log_error("Cannot find holding uuid %s in VG %s.",
+ uuid, lv->vg->name);
+ goto out;
+ }
+
+ if (lv_is_cow(lv_det))
+ lv_det = origin_from_cow(lv_det);
+ log_debug_activation("Found holder %s of %s.",
+ display_lvname(lv_det),
+ display_lvname(lv));
+ if (!_add_lv_to_dtree(dm, dtree, lv_det, 0))
+ goto_out;
+ }
+ }
+
+ r = 1;
+out:
+ if (closedir(d))
+ log_sys_error("closedir", "holders");
+
+ return r;
+}
+
static int _add_dev_to_dtree(struct dev_manager *dm, struct dm_tree *dtree,
const struct logical_volume *lv, const char *layer)
{
@@ -1771,6 +1870,15 @@ static int _add_dev_to_dtree(struct dev_manager *dm, struct dm_tree *dtree,
return_0;
}
+ /*
+ * Find holders of existing active LV where name starts with 'pvmove',
+ * but it's not anymore PVMOVE LV and also it's not PVMOVE _mimage
+ */
+ if (info.exists && !lv_is_pvmove(lv) &&
+ !strchr(lv->name, '_') && !strncmp(lv->name, "pvmove", 6))
+ if (!_add_holders_to_dtree(dm, dtree, lv, &info))
+ return_0;
+
return 1;
}
6 years, 5 months
master - mirror: use lv_update_and_reload_origin
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=ddbe763eb81c5f9608c...
Commit: ddbe763eb81c5f9608ca9ff192bd33d9d37acd77
Parent: aa68b898ff9c51dcbd87c6be34632e33f0299a18
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Fri Nov 24 13:58:23 2017 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Fri Nov 24 16:05:21 2017 +0100
mirror: use lv_update_and_reload_origin
Replace complex code with standard lv_update_and_reload_origin().
Extra suspend should not be necessary.
(If they would be - dependency tree would have bug for fixing).
---
lib/metadata/mirror.c | 44 +-------------------------------------------
1 files changed, 1 insertions(+), 43 deletions(-)
diff --git a/lib/metadata/mirror.c b/lib/metadata/mirror.c
index c89408c..327ce99 100644
--- a/lib/metadata/mirror.c
+++ b/lib/metadata/mirror.c
@@ -1038,50 +1038,8 @@ static int _remove_mirror_images(struct logical_volume *lv,
* remove the LVs from the mirror set, commit that metadata
* then deactivate and remove them fully.
*/
- if (!vg_write(mirrored_seg->lv->vg)) {
- log_error("intermediate VG write failed.");
- return 0;
- }
-
- if (!suspend_lv_origin(mirrored_seg->lv->vg->cmd, mirrored_seg->lv)) {
- log_error("Failed to lock %s.", display_lvname(mirrored_seg->lv));
- vg_revert(mirrored_seg->lv->vg);
- return 0;
- }
-
- /* FIXME: second suspend should not be needed
- * Explicitly suspend temporary LV.
- * This balances critical_section_inc() calls with critical_section_dec()
- * in resume (both local and cluster) and also properly propagates precommitted
- * metadata into dm table on other nodes.
- * FIXME: check propagation of suspend with visible flag
- */
- if (temp_layer_lv && !suspend_lv(temp_layer_lv->vg->cmd, temp_layer_lv))
- log_error("Problem suspending temporary LV %s.", display_lvname(temp_layer_lv));
-
- if (!vg_commit(mirrored_seg->lv->vg)) {
- if (!resume_lv(mirrored_seg->lv->vg->cmd, mirrored_seg->lv))
- stack;
+ if (!lv_update_and_reload_origin(mirrored_seg->lv))
return_0;
- }
-
- log_very_verbose("Updating %s in kernel.", display_lvname(mirrored_seg->lv));
-
- /*
- * Avoid having same mirror target loaded twice simultaneously by first
- * resuming the removed LV which now contains an error segment.
- * As it's now detached from mirrored_seg->lv we must resume it
- * explicitly.
- */
- if (temp_layer_lv && !resume_lv(temp_layer_lv->vg->cmd, temp_layer_lv)) {
- log_error("Problem resuming temporary LV %s.", display_lvname(temp_layer_lv));
- return 0;
- }
-
- if (!resume_lv_origin(mirrored_seg->lv->vg->cmd, mirrored_seg->lv)) {
- log_error("Problem reactivating %s.", display_lvname(mirrored_seg->lv));
- return 0;
- }
/* Save or delete the 'orphan' LVs */
reactivate = lv_is_active(lv_lock_holder(lv));
6 years, 5 months