master - lvmetad: warn about making changes while not using lvmetad
by David Teigland
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=1134ab63240de6...
Commit: 1134ab63240de66850c30fe1576bbb8b4f3e7052
Parent: 6e6f8025ff6ad8b3909a4631f71f310821ea7d4b
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Thu Apr 21 10:28:01 2016 -0500
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Thu Apr 21 10:28:01 2016 -0500
lvmetad: warn about making changes while not using lvmetad
If lvmetad is running, and a command opts to not use it
(--config global/use_lvmetad=0), and the command changes
metadata, then the metadata change is not visible to
lvmetad. Subsequent commands using lvmetad to change
metadata may cause corruption based on the invalid
lvmetad state.
Eventually we can set the disabled state in lvmetad
to prevent this problem, but for now print a warning
about the possibility.
---
lib/commands/toolcontext.c | 4 +++-
1 files changed, 3 insertions(+), 1 deletions(-)
diff --git a/lib/commands/toolcontext.c b/lib/commands/toolcontext.c
index 67d4f99..31f3a50 100644
--- a/lib/commands/toolcontext.c
+++ b/lib/commands/toolcontext.c
@@ -1720,8 +1720,10 @@ static int _init_lvmetad(struct cmd_context *cmd)
}
if (!find_config_tree_bool(cmd, global_use_lvmetad_CFG, NULL)) {
- if (lvmetad_pidfile_present())
+ if (lvmetad_pidfile_present()) {
log_warn("WARNING: Not using lvmetad because config setting use_lvmetad=0.");
+ log_warn("WARNING: To avoid corruption, rescan devices to make changes visible (pvscan --cache).");
+ }
return 1;
}
6 years, 11 months
master - lvmetad: fix compile without lvmetad
by David Teigland
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=6e6f8025ff6ad8...
Commit: 6e6f8025ff6ad8b3909a4631f71f310821ea7d4b
Parent: e44c4806db2424c6e375ac06391f0bcd475e6ce7
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Thu Apr 21 10:06:47 2016 -0500
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Thu Apr 21 10:06:47 2016 -0500
lvmetad: fix compile without lvmetad
Last commit was missing stub function.
---
lib/cache/lvmetad.h | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)
diff --git a/lib/cache/lvmetad.h b/lib/cache/lvmetad.h
index 240610b..0985a54 100644
--- a/lib/cache/lvmetad.h
+++ b/lib/cache/lvmetad.h
@@ -165,6 +165,7 @@ void lvmetad_clear_disabled(struct cmd_context *cmd);
# define lvmetad_used() (0)
# define lvmetad_set_socket(a) do { } while (0)
# define lvmetad_socket_present() (0)
+# define lvmetad_pidfile_present() (0)
# define lvmetad_set_token(a) do { } while (0)
# define lvmetad_release_token() do { } while (0)
# define lvmetad_vg_update(vg) (1)
6 years, 11 months
master - lvmetad: check pid for warning case
by David Teigland
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=e44c4806db2424...
Commit: e44c4806db2424c6e375ac06391f0bcd475e6ce7
Parent: d00b70c789cca1ca73b3d1311db9981d9ca5056b
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Thu Apr 21 09:50:59 2016 -0500
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Thu Apr 21 09:50:59 2016 -0500
lvmetad: check pid for warning case
When command is not using lvmetad because
use_lvmetad=0 in the config, but the lvmetad
pidfile exists, print a warning (previously
this checked for the socket existing instead
of the pidfile existing.)
---
lib/cache/lvmetad.c | 7 +++++++
lib/cache/lvmetad.h | 6 ++++++
lib/commands/toolcontext.c | 2 +-
3 files changed, 14 insertions(+), 1 deletions(-)
diff --git a/lib/cache/lvmetad.c b/lib/cache/lvmetad.c
index e50234a..8d13a59 100644
--- a/lib/cache/lvmetad.c
+++ b/lib/cache/lvmetad.c
@@ -165,6 +165,13 @@ void lvmetad_make_unused(struct cmd_context *cmd)
stack;
}
+int lvmetad_pidfile_present(void)
+{
+ const char *pidfile = getenv("LVM_LVMETAD_PIDFILE") ?: LVMETAD_PIDFILE;
+
+ return !access(pidfile, F_OK);
+}
+
int lvmetad_socket_present(void)
{
const char *socket = _lvmetad_socket ?: LVMETAD_SOCKET;
diff --git a/lib/cache/lvmetad.h b/lib/cache/lvmetad.h
index 699c9a4..240610b 100644
--- a/lib/cache/lvmetad.h
+++ b/lib/cache/lvmetad.h
@@ -53,6 +53,12 @@ void lvmetad_set_socket(const char *);
int lvmetad_socket_present(void);
/*
+ * Check if lvmetad pidfile is present, indicating that the lvmetad
+ * process is running or not.
+ */
+int lvmetad_pidfile_present(void);
+
+/*
* Set the "lvmetad validity token" (currently only consists of the lvmetad
* filter. See lvm.conf.
*/
diff --git a/lib/commands/toolcontext.c b/lib/commands/toolcontext.c
index 1f8ac4c..67d4f99 100644
--- a/lib/commands/toolcontext.c
+++ b/lib/commands/toolcontext.c
@@ -1720,7 +1720,7 @@ static int _init_lvmetad(struct cmd_context *cmd)
}
if (!find_config_tree_bool(cmd, global_use_lvmetad_CFG, NULL)) {
- if (lvmetad_socket_present())
+ if (lvmetad_pidfile_present())
log_warn("WARNING: Not using lvmetad because config setting use_lvmetad=0.");
return 1;
}
6 years, 11 months
master - lvmetad: check for socket in connect
by David Teigland
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=d00b70c789cca1...
Commit: d00b70c789cca1ca73b3d1311db9981d9ca5056b
Parent: 0778d2e9857966e2d7e8f44c7f769fbdebb03a73
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Thu Apr 21 09:27:20 2016 -0500
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Thu Apr 21 09:27:20 2016 -0500
lvmetad: check for socket in connect
We can connect if the socket is present, even
though the pidfile may not exist, since systemd
may start the process when the socket is opened.
---
lib/cache/lvmetad.c | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/lib/cache/lvmetad.c b/lib/cache/lvmetad.c
index bbf3550..e50234a 100644
--- a/lib/cache/lvmetad.c
+++ b/lib/cache/lvmetad.c
@@ -126,8 +126,8 @@ void lvmetad_disconnect(void)
int lvmetad_connect(struct cmd_context *cmd)
{
- if (access(getenv("LVM_LVMETAD_PIDFILE") ? : LVMETAD_PIDFILE, F_OK)) {
- log_debug_lvmetad("Failed to connect to lvmetad: not running.");
+ if (!lvmetad_socket_present()) {
+ log_debug_lvmetad("Failed to connect to lvmetad: socket not present.");
_lvmetad_connected = 0;
_lvmetad_use = 0;
_lvmetad_cmd = NULL;
6 years, 11 months
master - display: Avoid internal snapshot LV names in msgs.
by Alasdair Kergon
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=0778d2e9857966...
Commit: 0778d2e9857966e2d7e8f44c7f769fbdebb03a73
Parent: 2763b928de9b79ed9e144950446e59c0cac36a03
Author: Alasdair G Kergon <agk(a)redhat.com>
AuthorDate: Thu Apr 21 00:30:17 2016 +0100
Committer: Alasdair G Kergon <agk(a)redhat.com>
CommitterDate: Thu Apr 21 00:30:17 2016 +0100
display: Avoid internal snapshot LV names in msgs.
vg/snapshotN should not appear anywhere.
No code should be showing this, but it was noticed in some logs last
week and we can deal with it in display_lvname().
---
WHATS_NEW | 1 +
lib/display/display.c | 14 ++++++++++++--
lib/metadata/metadata-exported.h | 3 +++
lib/metadata/snapshot_manip.c | 5 +++++
4 files changed, 21 insertions(+), 2 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index 10f688d..65fefa1 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.151 -
=================================
+ Avoid internal snapshot LV names in messages.
Autodetect and use /run/lock dir when available instead of /var/lock.
lvchange --refresh for merging thin origin will retry to deactivate snapshot.
Recognize in-progress snapshot merge for thin volumes from dm table.
diff --git a/lib/display/display.c b/lib/display/display.c
index a6387c6..0151d01 100644
--- a/lib/display/display.c
+++ b/lib/display/display.c
@@ -121,19 +121,29 @@ const char *get_percent_string(percent_type_t def)
return _percent_types[def];
}
+static const char *_lv_name(const struct logical_volume *lv)
+{
+ /* Never try to display names of the internal snapshot structures. */
+ if (lv_is_snapshot(lv))
+ return find_cow(lv)->name;
+
+ return lv->name;
+}
+
const char *display_lvname(const struct logical_volume *lv)
{
char *name;
+ const char *lv_name = _lv_name(lv);
int r;
if ((lv->vg->cmd->display_lvname_idx + NAME_LEN) >= sizeof((lv->vg->cmd->display_buffer)))
lv->vg->cmd->display_lvname_idx = 0;
name = lv->vg->cmd->display_buffer + lv->vg->cmd->display_lvname_idx;
- r = dm_snprintf(name, NAME_LEN, "%s/%s", lv->vg->name, lv->name);
+ r = dm_snprintf(name, NAME_LEN, "%s/%s", lv->vg->name, lv_name);
if (r < 0) {
- log_error("Full LV name \"%s/%s\" is too long.", lv->vg->name, lv->name);
+ log_error("Full LV name \"%s/%s\" is too long.", lv->vg->name, lv_name);
return NULL;
}
diff --git a/lib/metadata/metadata-exported.h b/lib/metadata/metadata-exported.h
index fb2ffa3..039708e 100644
--- a/lib/metadata/metadata-exported.h
+++ b/lib/metadata/metadata-exported.h
@@ -1082,6 +1082,9 @@ struct lv_segment *find_snapshot(const struct logical_volume *lv);
/* Given a cow LV, return its origin */
struct logical_volume *origin_from_cow(const struct logical_volume *lv);
+/* Given an internal snapshot LV, return its cow */
+struct logical_volume *find_cow(const struct logical_volume *snap);
+
void init_snapshot_seg(struct lv_segment *seg, struct logical_volume *origin,
struct logical_volume *cow, uint32_t chunk_size, int merge);
diff --git a/lib/metadata/snapshot_manip.c b/lib/metadata/snapshot_manip.c
index d28d7c1..29b851f 100644
--- a/lib/metadata/snapshot_manip.c
+++ b/lib/metadata/snapshot_manip.c
@@ -34,6 +34,11 @@ int lv_is_cow(const struct logical_volume *lv)
return (!lv_is_thin_volume(lv) && !lv_is_origin(lv) && lv->snapshot) ? 1 : 0;
}
+struct logical_volume *find_cow(const struct logical_volume *snap)
+{
+ return first_seg(snap)->cow;
+}
+
/*
* Some kernels have a bug that they may leak space in the snapshot on crash.
* If the kernel is buggy, we add some extra space.
6 years, 11 months
master - lvmetad: fix compilation without lvmetad#
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=2763b928de9b79...
Commit: 2763b928de9b79ed9e144950446e59c0cac36a03
Parent: 7ce486e881a96db24a1f46a99110b0eb7009b0de
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Thu Apr 21 00:16:17 2016 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Thu Apr 21 00:34:01 2016 +0200
lvmetad: fix compilation without lvmetad#
---
lib/cache/lvmetad.h | 6 +++---
1 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/lib/cache/lvmetad.h b/lib/cache/lvmetad.h
index 82371d9..699c9a4 100644
--- a/lib/cache/lvmetad.h
+++ b/lib/cache/lvmetad.h
@@ -154,8 +154,8 @@ void lvmetad_clear_disabled(struct cmd_context *cmd);
# else /* LVMETAD_SUPPORT */
# define lvmetad_disconnect() do { } while (0)
-# define lvmetad_connect(cmd) do { } while (0)
-# define lvmetad_make_unused() do { } while (0)
+# define lvmetad_connect(cmd) (0)
+# define lvmetad_make_unused(cmd) do { } while (0)
# define lvmetad_used() (0)
# define lvmetad_set_socket(a) do { } while (0)
# define lvmetad_socket_present() (0)
@@ -175,7 +175,7 @@ void lvmetad_clear_disabled(struct cmd_context *cmd);
# define lvmetad_pvscan_single(cmd, dev, handler, ignore_obsolete) (0)
# define lvmetad_pvscan_all_devs(cmd, handler, do_wait) (0)
# define lvmetad_pvscan_foreign_vgs(cmd, handler) (0)
-# define lvmetad_vg_clear_outdated_pvs(vg) (1)
+# define lvmetad_vg_clear_outdated_pvs(vg) do { } while (0)
# define lvmetad_validate_global_cache(cmd, force) do { } while (0)
# define lvmetad_vg_is_foreign(cmd, vgname, vgid) (0)
# define lvmetad_token_matches(cmd) (1)
6 years, 11 months
master - tests: minor update
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=7ce486e881a96d...
Commit: 7ce486e881a96db24a1f46a99110b0eb7009b0de
Parent: 545b58542cec657af5125d16125732b424274982
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Wed Apr 20 23:21:03 2016 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Thu Apr 21 00:34:01 2016 +0200
tests: minor update
---
test/shell/pvmove-background.sh | 10 +++++++---
1 files changed, 7 insertions(+), 3 deletions(-)
diff --git a/test/shell/pvmove-background.sh b/test/shell/pvmove-background.sh
index 000de1c..26970d4 100644
--- a/test/shell/pvmove-background.sh
+++ b/test/shell/pvmove-background.sh
@@ -21,11 +21,15 @@ for mode in "--atomic" ""
do
lvcreate -aey -l1 -n $lv1 $vg "$dev1"
-lvs -o +devices | grep "$dev1"
+lvs -o +devices | tee out
+grep "$dev1" out
+
LVM_TEST_TAG="kill_me_$PREFIX" pvmove $mode -i 1 -b "$dev1" "$dev2"
sleep 5 # arbitrary...
-lvs -o +devices | not grep "pvmove"
-lvs -o +devices | grep "$dev2"
+lvs -o +devices | tee out
+not grep "pvmove" out
+lvs -o +devices | tee out
+grep "$dev2" out
lvremove -ff $vg
done
6 years, 11 months
master - tests: still show systems stas when command has not produced debug.log file
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=545b58542cec65...
Commit: 545b58542cec657af5125d16125732b424274982
Parent: 22a71e1119823be5ec76abff151f852ee366a00c
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Wed Apr 20 23:19:33 2016 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Thu Apr 21 00:34:01 2016 +0200
tests: still show systems stas when command has not produced debug.log file
When no debug.log* file is present whole stacktracking was skipped.
Add extra test the file exists to catch this case.
---
test/lib/utils.sh | 3 ++-
1 files changed, 2 insertions(+), 1 deletions(-)
diff --git a/test/lib/utils.sh b/test/lib/utils.sh
index 861c931..a3b5e2e 100644
--- a/test/lib/utils.sh
+++ b/test/lib/utils.sh
@@ -147,11 +147,12 @@ STACKTRACE() {
local name
local idx
for i in debug.log* ; do
+ test -f "$i" || break # nothing is found (expands to debug.log*)
name=${i##debug.log_}
name=${name%%_*}
test "$name" = "DEBUG" && { name="$name$idx" ; idx=$(($idx + 1)) ; }
echo "<======== Debug log $i ========>"
- sed -e "s,^,## $name: ," $i
+ sed -e "s,^,## $name: ," "$i"
done
if test -e strace.log ; then
echo "<======== Strace debug log ========>"
6 years, 11 months
master - tests: document make parametr for tracing aux scripts
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=22a71e1119823b...
Commit: 22a71e1119823be5ec76abff151f852ee366a00c
Parent: 509b2e524795d28f68be06b862794f7f0c5c9991
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Wed Apr 20 23:18:51 2016 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Thu Apr 21 00:34:01 2016 +0200
tests: document make parametr for tracing aux scripts
---
test/Makefile.in | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)
diff --git a/test/Makefile.in b/test/Makefile.in
index d4c6b95..0903b90 100644
--- a/test/Makefile.in
+++ b/test/Makefile.in
@@ -83,6 +83,7 @@ help:
@echo " clean Clean dir."
@echo " help Display callable targets."
@echo -e "\nSupported variables:"
+ @echo " LVM_TEST_AUX_TRACE Set for verbose messages for aux scripts []."
@echo " LVM_TEST_BACKING_DEVICE Set device used for testing (see also LVM_TEST_DIR)."
@echo " LVM_TEST_CAN_CLOBBER_DMESG Allow to clobber dmesg buffer without /dev/kmsg. (1)"
@echo " LVM_TEST_DEVDIR Set to '/dev' to run on real /dev."
6 years, 11 months
master - debug: move misplaced log_debug
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=509b2e524795d2...
Commit: 509b2e524795d28f68be06b862794f7f0c5c9991
Parent: 57f468a53ed8ec425d1087ce06c90862caa19ff1
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Wed Apr 20 12:45:15 2016 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Thu Apr 21 00:34:01 2016 +0200
debug: move misplaced log_debug
It should log action before taking it instead of only in error path.
---
lib/format_text/format-text.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/lib/format_text/format-text.c b/lib/format_text/format-text.c
index 43ebd27..095ae97 100644
--- a/lib/format_text/format-text.c
+++ b/lib/format_text/format-text.c
@@ -985,8 +985,8 @@ static int _vg_write_file(struct format_instance *fid __attribute__((unused)),
if (lvm_fclose(fp, tc->path_edit))
return_0;
+ log_debug_metadata("Renaming %s to %s", temp_file, tc->path_edit);
if (rename(temp_file, tc->path_edit)) {
- log_debug_metadata("Renaming %s to %s", temp_file, tc->path_edit);
log_error("%s: rename to %s failed: %s", temp_file,
tc->path_edit, strerror(errno));
return 0;
6 years, 11 months