Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=84394c0219e4fcee…
Commit: 84394c0219e4fcee719663c710121f1bb731a538
Parent: d2d5c24a68285a2f056977f877ab1a19e61b992f
Author: Alasdair G Kergon <agk(a)redhat.com>
AuthorDate: Fri Nov 29 20:56:29 2013 +0000
Committer: Alasdair G Kergon <agk(a)redhat.com>
CommitterDate: Fri Nov 29 20:56:29 2013 +0000
lvmetad: extend socket/pid file handling
Make it easier to run a live lvmetad in debugging mode and
to avoid conflicts if multiple test instances need to be run
alongside a live one.
No longer require -s when -f is used: use built-in default.
Add -p to lvmetad to specify the pid file.
No longer disable pidfile if -f used to run in foreground.
If specified socket file appears to be genuine but stale, remove it
before use.
On error, only remove lvmetad socket file if created by the same
process. (Previous code removes socket even while a running instance
is using it!)
---
WHATS_NEW | 3 ++
daemons/lvmetad/lvmetad-core.c | 25 +++++++++++---------
libdaemon/server/daemon-server.c | 46 +++++++++++++++++++++++++++++++++++--
man/lvmetad.8.in | 36 +++++++++++++++++++++--------
test/lib/test.sh | 1 +
5 files changed, 87 insertions(+), 24 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index 0101b49..043b7ef 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,8 @@
Version 2.02.105 -
=====================================
+ Add -p and LVM_LVMETAD_PID env var to lvmetad to change pid file.
+ Allow lvmetad to reuse stale socket.
+ Only unlink lvmetad socket on error if created by the same process.
Append missing newline to lvmetad missing socket path error message.
Check for non-zero aligment in _text_pv_add_metadata_area() to not div by 0.
Add allocation/use_blkid_wiping to lvm.conf to enable blkid wiping.
diff --git a/daemons/lvmetad/lvmetad-core.c b/daemons/lvmetad/lvmetad-core.c
index 71254f4..2810faf 100644
--- a/daemons/lvmetad/lvmetad-core.c
+++ b/daemons/lvmetad/lvmetad-core.c
@@ -1189,6 +1189,7 @@ static void usage(char *prog, FILE *file)
" -h Show this help information\n"
" -f Don't fork, run in the foreground\n"
" -l Logging message level (-l {all|wire|debug})\n"
+ " -p Set path to the pidfile\n"
" -s Set path to the socket to listen on\n\n", prog);
}
@@ -1196,27 +1197,34 @@ int main(int argc, char *argv[])
{
signed char opt;
lvmetad_state ls;
+ int _pidfile_override = 1;
int _socket_override = 1;
daemon_state s = {
.daemon_fini = fini,
.daemon_init = init,
.handler = handler,
.name = "lvmetad",
- .pidfile = LVMETAD_PIDFILE,
+ .pidfile = getenv("LVM_LVMETAD_PIDFILE"),
.private = &ls,
.protocol = "lvmetad",
.protocol_version = 1,
.socket_path = getenv("LVM_LVMETAD_SOCKET"),
};
+ if (!s.pidfile) {
+ _pidfile_override = 0;
+ s.pidfile = LVMETAD_PIDFILE;
+ }
+
if (!s.socket_path) {
_socket_override = 0;
s.socket_path = LVMETAD_SOCKET;
}
+
ls.log_config = "";
// use getopt_long
- while ((opt = getopt(argc, argv, "?fhVl:s:")) != EOF) {
+ while ((opt = getopt(argc, argv, "?fhVl:p:s:")) != EOF) {
switch (opt) {
case 'h':
usage(argv[0], stdout);
@@ -1230,6 +1238,10 @@ int main(int argc, char *argv[])
case 'l':
ls.log_config = optarg;
break;
+ case 'p':
+ s.pidfile = optarg;
+ _pidfile_override = 1;
+ break;
case 's': // --socket
s.socket_path = optarg;
_socket_override = 1;
@@ -1240,15 +1252,6 @@ int main(int argc, char *argv[])
}
}
- if (s.foreground) {
- if (!_socket_override) {
- fprintf(stderr, "A socket path (-s) is required in foreground mode.\n");
- exit(2);
- }
-
- s.pidfile = NULL;
- }
-
daemon_start(s);
return 0;
}
diff --git a/libdaemon/server/daemon-server.c b/libdaemon/server/daemon-server.c
index 156925a..914b803 100644
--- a/libdaemon/server/daemon-server.c
+++ b/libdaemon/server/daemon-server.c
@@ -207,7 +207,9 @@ out:
static int _open_socket(daemon_state s)
{
int fd = -1;
+ int file_created = 0;
struct sockaddr_un sockaddr = { .sun_family = AF_UNIX };
+ struct stat buf;
mode_t old_mask;
(void) dm_prepare_selinux_context(s.socket_path, S_IFSOCK);
@@ -233,9 +235,47 @@ static int _open_socket(daemon_state s)
}
if (bind(fd, (struct sockaddr *) &sockaddr, sizeof(sockaddr))) {
- perror("can't bind local socket.");
- goto error;
+ if (errno != EADDRINUSE) {
+ perror("can't bind local socket");
+ goto error;
+ }
+
+ /* Socket already exists. If it's stale, remove it. */
+ if (stat(sockaddr.sun_path, &buf)) {
+ perror("stat failed");
+ goto error;
+ }
+
+ if (S_ISSOCK(buf.st_mode)) {
+ fprintf(stderr, "%s: not a socket\n", sockaddr.sun_path);
+ goto error;
+ }
+
+ if (buf.st_uid || (buf.st_mode & (S_IRWXG | S_IRWXO))) {
+ fprintf(stderr, "%s: unrecognised permissions\n", sockaddr.sun_path);
+ goto error;
+ }
+
+ if (!connect(fd, (struct sockaddr *) &sockaddr, sizeof(sockaddr))) {
+ fprintf(stderr, "Socket %s already in use\n", sockaddr.sun_path);
+ goto error;
+ }
+
+ fprintf(stderr, "removing stale socket %s\n", sockaddr.sun_path);
+
+ if (unlink(sockaddr.sun_path) && (errno != ENOENT)) {
+ perror("unlink failed");
+ goto error;
+ }
+
+ if (bind(fd, (struct sockaddr *) &sockaddr, sizeof(sockaddr))) {
+ perror("local socket bind failed after unlink");
+ goto error;
+ }
}
+
+ file_created = 1;
+
if (listen(fd, 1) != 0) {
perror("listen local");
goto error;
@@ -250,7 +290,7 @@ error:
if (fd >= 0) {
if (close(fd))
perror("close failed");
- if (unlink(s.socket_path))
+ if (file_created && unlink(s.socket_path))
perror("unlink failed");
fd = -1;
}
diff --git a/man/lvmetad.8.in b/man/lvmetad.8.in
index 7110877..4956a3f 100644
--- a/man/lvmetad.8.in
+++ b/man/lvmetad.8.in
@@ -6,8 +6,11 @@ lvmetad \- LVM metadata cache daemon
.RB [ \-l
.RI {all|wire|debug}
.RB ]
+.RB [ \-p
+.RI pidfile_path
+.RB ]
.RB [ \-s
-.RI path
+.RI socket_path
.RB ]
.RB [ \-f ]
.RB [ \-h ]
@@ -21,6 +24,15 @@ consistent image of the volume groups available in the system.
By default, lvmetad, even if running, is not used by LVM. See \fBlvm.conf\fP(5).
.SH OPTIONS
+
+To run the daemon in a test environment both the pidfile_path and the
+socket_path should be changed from the defaults.
+.TP
+.B \-f
+Don't fork, but run in the foreground.
+.TP
+.BR \-h ", " \-?
+Show help information.
.TP
.BR \-l " {" \fIall | \fIwire | \fIdebug }
Select the type of log messages to generate.
@@ -32,23 +44,27 @@ Selecting 'all' supplies both and is equivalent to a comma-separated list
Prior to release 2.02.98, repeating -d from 1 to 3 times, viz. -d, -dd, -ddd,
increased the detail of messages.
.TP
-.B \-f
-Don't fork, run in the foreground.
-.TP
-.BR \-h ", " \-?
-Show help information.
+.B \-p \fIpidfile_path
+Path to the pidfile. This overrides both the built-in default
+(#DEFAULT_PID_DIR#/lvmetad.pid) and the environment variable
+\fBLVM_LVMETAD_PIDFILE\fP. This file is used to prevent more
+than one instance of the daemon running simultaneously.
.TP
-.B \-s \fIpath
-Path to the socket file to use. The option overrides both the built-in default
+.B \-s \fIsocket_path
+Path to the socket file. This overrides both the built-in default
(#DEFAULT_RUN_DIR#/lvmetad.socket) and the environment variable
-\fBLVM_LVMETAD_SOCKET\fP.
+\fBLVM_LVMETAD_SOCKET\fP. To communicate successfully with lvmetad,
+all LVM2 processes should use the same socket path.
.TP
.B \-V
Display the version of lvmetad daemon.
.SH ENVIRONMENT VARIABLES
.TP
+.B LVM_LVMETAD_PIDFILE
+Path for the pid file.
+.TP
.B LVM_LVMETAD_SOCKET
-override path for socket file to use.
+Path for the socket file.
.SH SEE ALSO
.BR lvm (8),
diff --git a/test/lib/test.sh b/test/lib/test.sh
index 563ef59..265d61d 100644
--- a/test/lib/test.sh
+++ b/test/lib/test.sh
@@ -83,6 +83,7 @@ aux prepare_clvmd
test -n "$LVM_TEST_LVMETAD" && {
aux prepare_lvmetad
export LVM_LVMETAD_SOCKET="$TESTDIR/lvmetad.socket"
+ export LVM_LVMETAD_PIDFILE="$TESTDIR/lvmetad.pid"
}
echo "@TESTDIR=$TESTDIR"
echo "@PREFIX=$PREFIX"
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=75628f341ad38b68…
Commit: 75628f341ad38b68aae33eae0b5700be2a6e5769
Parent: b3074560eb36d0b1c8ec61f50e71b0b27dbda982
Author: Peter Rajnoha <prajnoha(a)redhat.com>
AuthorDate: Fri Nov 29 15:27:56 2013 +0100
Committer: Peter Rajnoha <prajnoha(a)redhat.com>
CommitterDate: Fri Nov 29 15:27:56 2013 +0100
configure: enable blkid_wiping by default if the blkid library is present
---
WHATS_NEW | 3 +-
configure | 53 ++++++++++++++++++++--------------------------
configure.in | 29 +++++++++++++++++--------
lib/misc/configure.h.in | 2 +-
4 files changed, 46 insertions(+), 41 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index 6aac94a..0101b49 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -3,7 +3,8 @@ Version 2.02.105 -
Append missing newline to lvmetad missing socket path error message.
Check for non-zero aligment in _text_pv_add_metadata_area() to not div by 0.
Add allocation/use_blkid_wiping to lvm.conf to enable blkid wiping.
- Add configure --enable-blkid_wiping to use libblkid to detect signatures.
+ Enable blkid_wiping by default if the blkid library is present.
+ Add configure --disable-blkid_wiping to disable libblkid signature detection.
Add -W/--wipesignatures lvcreate option to support wiping on new LVs.
Add allocation/wipe_signatures_on_new_logical_volumes_when_zeroing to lvm.conf.
Do not fail the whole autoactivation if the VG refresh done before fails.
diff --git a/configure b/configure
index 8247ddd..5d81dac 100755
--- a/configure
+++ b/configure
@@ -1563,7 +1563,8 @@ Optional Features:
--enable-valgrind-pool enable valgrind awareness of pools
--disable-devmapper disable LVM2 device-mapper interaction
--enable-lvmetad enable the LVM Metadata Daemon
- --enable-blkid_wiping use wiping functionality provided by libblkid
+ --disable-blkid_wiping disable libblkid detection of signatures when wiping
+ and use native code instead
--enable-udev-systemd-background-jobs
enable udev-systemd protocol to instantiate a
service for background job
@@ -9185,20 +9186,19 @@ _ACEOF
fi
################################################################################
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to use blkid wiping functionality" >&5
-$as_echo_n "checking whether to use blkid wiping functionality... " >&6; }
-# Check whether --enable-blkid-wiping was given.
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to enable libblkid detection of signatures when wiping" >&5
+$as_echo_n "checking whether to enable libblkid detection of signatures when wiping... " >&6; }
+# Check whether --enable-blkid_wiping was given.
if test "${enable_blkid_wiping+set}" = set; then :
enableval=$enable_blkid_wiping; BLKID_WIPING=$enableval
else
- BLKID_WIPING=no
+ BLKID_WIPING=maybe
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $BLKID_WIPING" >&5
$as_echo "$BLKID_WIPING" >&6; }
-
-if test x$BLKID_WIPING = xyes; then
+if test x$BLKID_WIPING != xno; then
if test x$PKGCONFIG_INIT != x1; then
pkg_config_init
fi
@@ -9259,43 +9259,36 @@ fi
# Put the nasty error message in config.log where it belongs
echo "$BLKID_PKG_ERRORS" >&5
- as_fn_error $? "Package requirements (blkid >= 2.22) were not met:
-
-$BLKID_PKG_ERRORS
-
-Consider adjusting the PKG_CONFIG_PATH environment variable if you
-installed software in a non-standard prefix.
-
-Alternatively, you may set the environment variables BLKID_CFLAGS
-and BLKID_LIBS to avoid the need to call pkg-config.
-See the pkg-config man page for more details." "$LINENO" 5
+ if test x$BLKID_WIPING = xmaybe; then
+ BLKID_WIPING=no
+ else
+ as_fn_error $? "bailing out... blkid library >= 2.22 is required" "$LINENO" 5
+ fi
elif test $pkg_failed = untried; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
- { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
-$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
-as_fn_error $? "The pkg-config script could not be found or is too old. Make sure it
-is in your PATH or set the PKG_CONFIG environment variable to the full
-path to pkg-config.
-
-Alternatively, you may set the environment variables BLKID_CFLAGS
-and BLKID_LIBS to avoid the need to call pkg-config.
-See the pkg-config man page for more details.
-
-To get pkg-config, see <http://pkg-config.freedesktop.org/>.
-See \`config.log' for more details" "$LINENO" 5; }
+ if test x$BLKID_WIPING = xmaybe; then
+ BLKID_WIPING=no
+ else
+ as_fn_error $? "bailing out... blkid library >= 2.22 is required" "$LINENO" 5
+ fi
else
BLKID_CFLAGS=$pkg_cv_BLKID_CFLAGS
BLKID_LIBS=$pkg_cv_BLKID_LIBS
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
$as_echo "yes" >&6; }
- BLKID_PC="blkid"
+ if test x$BLKID_WIPING = xmaybe; then
+ BLKID_WIPING=yes
+ fi
fi
+ if test x$BLKID_WIPING = xyes; then
+ BLKID_PC="blkid"
$as_echo "#define BLKID_WIPING_SUPPORT 1" >>confdefs.h
+ fi
fi
################################################################################
diff --git a/configure.in b/configure.in
index ff9bf81..b4a407a 100644
--- a/configure.in
+++ b/configure.in
@@ -947,21 +947,32 @@ fi
################################################################################
dnl -- Enable blkid wiping functionality
-AC_MSG_CHECKING(whether to use blkid wiping functionality)
-AC_ARG_ENABLE(blkid-wiping,
- AC_HELP_STRING([--enable-blkid_wiping],
- [use wiping functionality provided by libblkid]),
- BLKID_WIPING=$enableval, BLKID_WIPING=no)
+AC_MSG_CHECKING(whether to enable libblkid detection of signatures when wiping)
+AC_ARG_ENABLE(blkid_wiping,
+ AC_HELP_STRING([--disable-blkid_wiping],
+ [disable libblkid detection of signatures when wiping and use native code instead]),
+ BLKID_WIPING=$enableval, BLKID_WIPING=maybe)
AC_MSG_RESULT($BLKID_WIPING)
-
-if test x$BLKID_WIPING = xyes; then
+if test x$BLKID_WIPING != xno; then
dnl -- init pkgconfig if required
if test x$PKGCONFIG_INIT != x1; then
pkg_config_init
fi
- PKG_CHECK_MODULES(BLKID, blkid >= 2.22, [BLKID_PC="blkid"])
- AC_DEFINE([BLKID_WIPING_SUPPORT], 1, [Define to 1 to use wiping functionality provided by libblkid.])
+ PKG_CHECK_MODULES(BLKID, blkid >= 2.22,
+ [if test x$BLKID_WIPING = xmaybe; then
+ BLKID_WIPING=yes
+ fi],
+ [if test x$BLKID_WIPING = xmaybe; then
+ BLKID_WIPING=no
+ else
+ AC_MSG_ERROR([bailing out... blkid library >= 2.22 is required])
+ fi
+ ])
+ if test x$BLKID_WIPING = xyes; then
+ BLKID_PC="blkid"
+ AC_DEFINE([BLKID_WIPING_SUPPORT], 1, [Define to 1 to use libblkid detection of signatures when wiping.])
+ fi
fi
################################################################################
diff --git a/lib/misc/configure.h.in b/lib/misc/configure.h.in
index 51db42e..4e9ffd1 100644
--- a/lib/misc/configure.h.in
+++ b/lib/misc/configure.h.in
@@ -1,6 +1,6 @@
/* lib/misc/configure.h.in. Generated from configure.in by autoheader. */
-/* Define to 1 to use wiping functionality provided by libblkid. */
+/* Define to 1 to use libblkid detection of signatures when wiping. */
#undef BLKID_WIPING_SUPPORT
/* Define to 1 if the `closedir' function returns void instead of `int'. */
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=08bab406b5bcae92…
Commit: 08bab406b5bcae92df340209c1a0902e68aa1a28
Parent: c24b558c8c3e8f877e7cf216369e3415be8dbc6f
Author: Peter Rajnoha <prajnoha(a)redhat.com>
AuthorDate: Thu Nov 28 14:10:55 2013 +0100
Committer: Peter Rajnoha <prajnoha(a)redhat.com>
CommitterDate: Thu Nov 28 14:10:55 2013 +0100
tests: wipe fs signature manually in pvcreate-operation test
So that the next pvcreate that is called does not issue any
warnings/prompts about existing signature (when blkid wiping is used).
---
test/shell/pvcreate-operation.sh | 3 +++
1 files changed, 3 insertions(+), 0 deletions(-)
diff --git a/test/shell/pvcreate-operation.sh b/test/shell/pvcreate-operation.sh
index ddcf94c..b885ed2 100644
--- a/test/shell/pvcreate-operation.sh
+++ b/test/shell/pvcreate-operation.sh
@@ -23,6 +23,9 @@ do
not pvcreate -M$mdatype "$dev1" 2>err
grep "Can't open "$dev1" exclusively. Mounted filesystem?" err
umount "$dev1"
+ # wipe the filesystem signature for next
+ # pvcreate to not issue any prompts
+ dd if=/dev/zero of=$dev1 bs=1K count=2
fi
# pvcreate (lvm$mdatype) succeeds when run repeatedly (pv not in a vg) (bz178216)
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=c24b558c8c3e8f87…
Commit: c24b558c8c3e8f877e7cf216369e3415be8dbc6f
Parent: 6a1957badcb95a5f2815436e64798b48ed85ca0c
Author: Peter Rajnoha <prajnoha(a)redhat.com>
AuthorDate: Thu Nov 28 13:23:45 2013 +0100
Committer: Peter Rajnoha <prajnoha(a)redhat.com>
CommitterDate: Thu Nov 28 13:27:52 2013 +0100
tests: initialize signature wiping
Do not use signature wiping for newly created LVs in tests - we're
reusing the devs in tests and such detection could just interfere
inappropriately. We'd need to modify all tests to anwer the prompt
whether any signature found should be removed or not or we'd need
to use "-y" option for all lvcreates in tests. It's better to disable
this feature then and let's do a separate test to test this signature
wiping functionality.
---
test/lib/aux.sh | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)
diff --git a/test/lib/aux.sh b/test/lib/aux.sh
index 4ef1132..d1ae524 100644
--- a/test/lib/aux.sh
+++ b/test/lib/aux.sh
@@ -563,6 +563,7 @@ activation/polling_interval = 0
activation/snapshot_autoextend_percent = 50
activation/snapshot_autoextend_threshold = 50
activation/monitoring = 0
+allocation/wipe_signatures_on_new_logical_volumes_when_zeroing = 0
EOF
}
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=a1eda8ea245ec7af…
Commit: a1eda8ea245ec7af684fb50e7f0abf5229d9bcfb
Parent: 8724c0fcebcc35df980e6819e5c531f213fe2767
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Fri Nov 22 22:27:32 2013 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Thu Nov 28 12:45:52 2013 +0100
toollib: drop init of ret
Keep the ret uninitialized, so we get compiler warning, when tried
to use this value instead of ret_max as function return value.
---
tools/toollib.c | 10 +++++-----
1 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/tools/toollib.c b/tools/toollib.c
index 90a7cb8..654384d 100644
--- a/tools/toollib.c
+++ b/tools/toollib.c
@@ -190,7 +190,7 @@ int process_each_lv_in_vg(struct cmd_context *cmd,
process_single_lv_fn_t process_single_lv)
{
int ret_max = ECMD_PROCESSED;
- int ret = 0;
+ int ret;
unsigned process_all = 0;
unsigned process_lv = 0;
unsigned tags_supplied = 0;
@@ -302,7 +302,7 @@ int process_each_lv(struct cmd_context *cmd, int argc, char **argv,
{
int opt = 0;
int ret_max = ECMD_PROCESSED;
- int ret = 0;
+ int ret;
struct dm_list *tags_arg;
struct dm_list *vgnames; /* VGs to process */
@@ -724,7 +724,7 @@ int process_each_pv_in_vg(struct cmd_context *cmd, struct volume_group *vg,
process_single_pv_fn_t process_single_pv)
{
int ret_max = ECMD_PROCESSED;
- int ret = 0;
+ int ret;
struct pv_list *pvl;
dm_list_iterate_items(pvl, &vg->pvs) {
@@ -810,7 +810,7 @@ int process_each_pv(struct cmd_context *cmd, int argc, char **argv,
{
int opt = 0;
int ret_max = ECMD_PROCESSED;
- int ret = 0;
+ int ret;
int lock_global = !(flags & READ_WITHOUT_LOCK) && !(flags & READ_FOR_UPDATE) && !lvmetad_active();
struct pv_list *pvl;
@@ -1803,7 +1803,7 @@ int process_each_label(struct cmd_context *cmd, int argc, char **argv, void *han
struct device *dev;
int ret_max = ECMD_PROCESSED;
- int ret = 0;
+ int ret;
int opt = 0;
if (argc) {
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=fc9d4dd11f2331e0…
Commit: fc9d4dd11f2331e056f0b56274877c8a4b4b1570
Parent: 79991aa7699587b40946d029787b38ae67405336
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Mon Nov 25 13:44:46 2013 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Thu Nov 28 12:42:44 2013 +0100
config: use int for type
Since the type is used for 'or' operation of enumerated bit fields,
it doesn't not have type cfg_def_type_t - use proper int type for
bitmask.
---
lib/config/config.h | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/lib/config/config.h b/lib/config/config.h
index f57757b..0769c40 100644
--- a/lib/config/config.h
+++ b/lib/config/config.h
@@ -88,7 +88,7 @@ typedef struct cfg_def_item {
int id; /* ID of this item */
int parent; /* ID of parent item */
const char *name; /* name of the item in configuration tree */
- cfg_def_type_t type; /* configuration item type */
+ int type; /* configuration item type (bits of cfg_def_type_t) */
cfg_def_value_t default_value; /* default value (only for settings) */
uint16_t flags; /* configuration item definition flags */
uint16_t since_version; /* version this item appeared in */
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=01c438a96c82bf31…
Commit: 01c438a96c82bf31ccda0721707fc90afa01a07e
Parent: 5a4137c804b0ba579c5f368fe91942c465815f66
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Sun Nov 24 19:00:53 2013 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Thu Nov 28 12:42:39 2013 +0100
format-text: ensure aligment is not 0
Make sure this path of code is not used for alignment == 0,
to prevent division by 0.
---
WHATS_NEW | 1 +
lib/format_text/format-text.c | 2 +-
2 files changed, 2 insertions(+), 1 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index 55b17c0..cd63144 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.105 -
=====================================
+ Check for non-zero aligment in _text_pv_add_metadata_area() to not div by 0.
Add allocation/use_blkid_wiping to lvm.conf to enable blkid wiping.
Add configure --enable-blkid_wiping to use libblkid to detect signatures.
Add -W/--wipesignatures lvcreate option to support wiping on new LVs.
diff --git a/lib/format_text/format-text.c b/lib/format_text/format-text.c
index 275d16f..eb5c9e9 100644
--- a/lib/format_text/format-text.c
+++ b/lib/format_text/format-text.c
@@ -2083,7 +2083,7 @@ static int _text_pv_add_metadata_area(const struct format_type *fmt,
* alignment since it would be useless.
* Check first whether we can apply that!
*/
- if (!pe_start_locked &&
+ if (!pe_start_locked && alignment &&
((limit - mda_start) > alignment * 2)) {
mda_size = limit - mda_start - alignment * 2;
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=5968f07fd5ccb2b7…
Commit: 5968f07fd5ccb2b7d4e407cd8fec86b0b1f80f3a
Parent: eaa23d32732c9bc3dd4f948781b5764cf21d84ba
Author: Peter Rajnoha <prajnoha(a)redhat.com>
AuthorDate: Wed Nov 27 15:20:12 2013 +0100
Committer: Peter Rajnoha <prajnoha(a)redhat.com>
CommitterDate: Wed Nov 27 15:49:15 2013 +0100
man: lvcreate -W/--wipesignatures
---
man/lvcreate.8.in | 21 +++++++++++++++++++--
1 files changed, 19 insertions(+), 2 deletions(-)
diff --git a/man/lvcreate.8.in b/man/lvcreate.8.in
index 4a29720..a34c4ae 100644
--- a/man/lvcreate.8.in
+++ b/man/lvcreate.8.in
@@ -75,6 +75,7 @@ lvcreate \- create a logical volume in an existing volume group
.RB [ \-\-type
.IR SegmentType ]
.RB [ \-v | \-\-verbose ]
+.RB [ \-W | \-\-wipesignatures ]
.RB [ \-Z | \-\-zero
.RI { y | n }]
.IR VolumeGroup { Name | Path }[/ ThinPoolLogicalVolumeName ]
@@ -135,8 +136,9 @@ If autoactivation option is used (\fB\-a\fIay\fR), the logical volume is
activated only if it matches an item in the
.B activation/auto_activation_volume_list
set in \fBlvm.conf\fP(5).
-For autoactivated logical volumes, \fB\-\-zero\fP \fIn\fP is always assumed
-and it can't be overridden. If the clustered locking is enabled,
+For autoactivated logical volumes, \fB\-\-zero\fP \fIn\fP and
+\fB\-\-wipesignatures\fP \fIn\fP is always assumed and it can't
+be overridden. If the clustered locking is enabled,
\fB\-a\fIey\fR will activate exclusively on one node and
.IR \fB\-a { a | l } y
will activate only on the local node.
@@ -399,6 +401,21 @@ requested size using the zero target. A suffix of _vorigin is used for
this device. Note: using sparse snapshots is not efficient for larger
device sizes (GiB), thin provisioning should be used for this case.
.TP
+.BR \-W ", " \-\-wipesignatures " {" \fIy | \fIn }
+Controls wiping of detected signatures on newly created Logical Volume.
+If this option is not specified, then by default signature wiping is done
+each time the zeroing (\fB\-Z\fP/\fB\-\-zero\fP) is done. This default behaviour
+can be controlled by \fBallocation/wipe_signatures_on_new_logical_volumes_when_zeroing\fP
+setting found in \fBlvm.conf\fP(5).
+.br
+If blkid wiping is used (\fBallocation/use_blkid_wiping setting\fP in \fBlvm.conf\fP(5))
+and LVM2 is compiled with blkid wiping support, then \fBblkid\fP(8) library is used
+to detect the signatures (use \fBblkid -k\fP command to list the signatures that are recognized).
+Otherwise, native LVM2 code is used to detect signatures (MD RAID, swap and LUKS
+signatures are detected only in this case).
+.br
+Logical Volume is not wiped if the read only flag is set.
+.TP
.BR \-Z ", " \-\-zero " {" \fIy | \fIn }
Controls zeroing of the first KiB of data in the new logical volume.
.br
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=ab2f858af7a72448…
Commit: ab2f858af7a72448b6c015a5984c73f5cdaf3664
Parent: 9bfc0be493192958f5dbffea4eb7dda968062261
Author: Peter Rajnoha <prajnoha(a)redhat.com>
AuthorDate: Wed Nov 27 13:52:15 2013 +0100
Committer: Peter Rajnoha <prajnoha(a)redhat.com>
CommitterDate: Wed Nov 27 15:49:14 2013 +0100
conf: add allocation/use_blkid_wiping
Add allocation/use_blkid_wiping setting to lvm.conf to select between
LVM2 native code to detect signatures to wipe or blkid library code.
---
WHATS_NEW | 1 +
conf/example.conf.in | 15 +++++++++++++++
lib/config/config_settings.h | 1 +
3 files changed, 17 insertions(+), 0 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index 9823cd1..55b17c0 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.105 -
=====================================
+ Add allocation/use_blkid_wiping to lvm.conf to enable blkid wiping.
Add configure --enable-blkid_wiping to use libblkid to detect signatures.
Add -W/--wipesignatures lvcreate option to support wiping on new LVs.
Add allocation/wipe_signatures_on_new_logical_volumes_when_zeroing to lvm.conf.
diff --git a/conf/example.conf.in b/conf/example.conf.in
index 0ac53ef..b7ad3d1 100644
--- a/conf/example.conf.in
+++ b/conf/example.conf.in
@@ -272,6 +272,21 @@ allocation {
# algorithm.
maximise_cling = 1
+ # Whether to use blkid library instead of native LVM2 code to detect
+ # any existing signatures while creating new Physical Volumes and
+ # Logical Volumes. LVM2 needs to be compiled with blkid wiping support
+ # for this setting to take effect.
+ #
+ # LVM2 native detection code is currently able to recognize these signatures:
+ # - MD device signature
+ # - swap signature
+ # - LUKS signature
+ # To see the list of signatures recognized by blkid, check the output
+ # of 'blkid -k' command. The blkid can recognize more signatures than
+ # LVM2 native detection code, but due to this higher number of signatures
+ # to be recognized, it can take more time to complete the signature scan.
+ use_blkid_wiping = 1
+
# Whether do wipe any signatures found on newly created Logical Volumes
# automatically in addition to zeroing of the first KB on the LV
# (-Z/--zero y option) when running the LVM command without specifying
diff --git a/lib/config/config_settings.h b/lib/config/config_settings.h
index 7a7e8e5..929e907 100644
--- a/lib/config/config_settings.h
+++ b/lib/config/config_settings.h
@@ -104,6 +104,7 @@ cfg(devices_issue_discards_CFG, "issue_discards", devices_CFG_SECTION, 0, CFG_TY
cfg_array(allocation_cling_tag_list_CFG, "cling_tag_list", allocation_CFG_SECTION, 0, CFG_TYPE_STRING, NULL, vsn(2, 2, 77), NULL)
cfg(allocation_maximise_cling_CFG, "maximise_cling", allocation_CFG_SECTION, 0, CFG_TYPE_BOOL, DEFAULT_MAXIMISE_CLING, vsn(2, 2, 85), NULL)
+cfg(allocation_use_blkid_wiping_CFG, "use_blkid_wiping", allocation_CFG_SECTION, 0, CFG_TYPE_BOOL, 1, vsn(2, 2, 105), NULL)
cfg(allocation_wipe_signatures_on_new_logical_volumes_when_zeroing_CFG, "wipe_signatures_on_new_logical_volumes_when_zeroing", allocation_CFG_SECTION, 0, CFG_TYPE_BOOL, 1, vsn(2, 2, 105), NULL)
cfg(allocation_mirror_logs_require_separate_pvs_CFG, "mirror_logs_require_separate_pvs", allocation_CFG_SECTION, 0, CFG_TYPE_BOOL, DEFAULT_MIRROR_LOGS_REQUIRE_SEPARATE_PVS, vsn(2, 2, 85), NULL)
cfg(allocation_thin_pool_metadata_require_separate_pvs_CFG, "thin_pool_metadata_require_separate_pvs", allocation_CFG_SECTION, 0, CFG_TYPE_BOOL, DEFAULT_THIN_POOL_METADATA_REQUIRE_SEPARATE_PVS, vsn(2, 2, 89), NULL)
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=5b7e543cae5be52e…
Commit: 5b7e543cae5be52e1dcd79c7f6876acc89138cf1
Parent: 03c941a4caf411f21045670e205ccdd975be27c7
Author: Peter Rajnoha <prajnoha(a)redhat.com>
AuthorDate: Wed Nov 27 12:54:48 2013 +0100
Committer: Peter Rajnoha <prajnoha(a)redhat.com>
CommitterDate: Wed Nov 27 15:48:06 2013 +0100
conf: add allocation/wipe_signatures_on_new_logical_volumes_when_zeroing
This setting controls whether signature wiping on newly created logical
volumes will follow the state of zeroing (-Z/--zero option).
---
WHATS_NEW | 1 +
conf/default.profile.in | 1 +
conf/example.conf.in | 9 +++++++++
lib/config/config_settings.h | 1 +
4 files changed, 12 insertions(+), 0 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index 7718b6f..af489d6 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.105 -
=====================================
+ Add allocation/wipe_signatures_on_new_logical_volumes_when_zeroing to lvm.conf.
Do not fail the whole autoactivation if the VG refresh done before fails.
Do not connect to lvmetad on vg/lvchange --sysinit -aay and socket absent.
Use lv_check_not_in_use() when testing device in use before merging.
diff --git a/conf/default.profile.in b/conf/default.profile.in
index 29049ef..5a481de 100644
--- a/conf/default.profile.in
+++ b/conf/default.profile.in
@@ -9,6 +9,7 @@
# Refer to 'man lvm.conf' for further information about profiles and file layout.
allocation {
+ wipe_signatures_on_new_logical_volumes_when_zeroing = 1
thin_pool_chunk_size_policy = "generic"
thin_pool_chunk_size = 64
thin_pool_discards = "passdown"
diff --git a/conf/example.conf.in b/conf/example.conf.in
index 03e1c45..0ac53ef 100644
--- a/conf/example.conf.in
+++ b/conf/example.conf.in
@@ -272,6 +272,15 @@ allocation {
# algorithm.
maximise_cling = 1
+ # Whether do wipe any signatures found on newly created Logical Volumes
+ # automatically in addition to zeroing of the first KB on the LV
+ # (-Z/--zero y option) when running the LVM command without specifying
+ # the -W/--wipesignatures option. If -W/--wipesignatures command line
+ # option is specified, it always takes precedence over this setting.
+ # Default is to wipe signatures when zeroing.
+ #
+ wipe_signatures_on_new_logical_volumes_when_zeroing = 1
+
# Set to 1 to guarantee that mirror logs will always be placed on
# different PVs from the mirror images. This was the default
# until version 2.02.85.
diff --git a/lib/config/config_settings.h b/lib/config/config_settings.h
index 7fdf763..7a7e8e5 100644
--- a/lib/config/config_settings.h
+++ b/lib/config/config_settings.h
@@ -104,6 +104,7 @@ cfg(devices_issue_discards_CFG, "issue_discards", devices_CFG_SECTION, 0, CFG_TY
cfg_array(allocation_cling_tag_list_CFG, "cling_tag_list", allocation_CFG_SECTION, 0, CFG_TYPE_STRING, NULL, vsn(2, 2, 77), NULL)
cfg(allocation_maximise_cling_CFG, "maximise_cling", allocation_CFG_SECTION, 0, CFG_TYPE_BOOL, DEFAULT_MAXIMISE_CLING, vsn(2, 2, 85), NULL)
+cfg(allocation_wipe_signatures_on_new_logical_volumes_when_zeroing_CFG, "wipe_signatures_on_new_logical_volumes_when_zeroing", allocation_CFG_SECTION, 0, CFG_TYPE_BOOL, 1, vsn(2, 2, 105), NULL)
cfg(allocation_mirror_logs_require_separate_pvs_CFG, "mirror_logs_require_separate_pvs", allocation_CFG_SECTION, 0, CFG_TYPE_BOOL, DEFAULT_MIRROR_LOGS_REQUIRE_SEPARATE_PVS, vsn(2, 2, 85), NULL)
cfg(allocation_thin_pool_metadata_require_separate_pvs_CFG, "thin_pool_metadata_require_separate_pvs", allocation_CFG_SECTION, 0, CFG_TYPE_BOOL, DEFAULT_THIN_POOL_METADATA_REQUIRE_SEPARATE_PVS, vsn(2, 2, 89), NULL)
cfg(allocation_thin_pool_zero_CFG, "thin_pool_zero", allocation_CFG_SECTION, CFG_PROFILABLE, CFG_TYPE_BOOL, DEFAULT_THIN_POOL_ZERO, vsn(2, 2, 99), NULL)
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=d6e67b850365864b…
Commit: d6e67b850365864bba91619a40503ff0b0392e2c
Parent: 729b104413e11412866a549ef8a6702f56c4acd1
Author: Peter Rajnoha <prajnoha(a)redhat.com>
AuthorDate: Wed Nov 27 08:33:02 2013 +0100
Committer: Peter Rajnoha <prajnoha(a)redhat.com>
CommitterDate: Wed Nov 27 08:33:02 2013 +0100
WHATS_NEW: commit 729b104
---
WHATS_NEW | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index 4148754..7718b6f 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.105 -
=====================================
+ Do not fail the whole autoactivation if the VG refresh done before fails.
Do not connect to lvmetad on vg/lvchange --sysinit -aay and socket absent.
Use lv_check_not_in_use() when testing device in use before merging.
Move test for target present from init_snapshot_merge() to lvconvert.
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=729b104413e11412…
Commit: 729b104413e11412866a549ef8a6702f56c4acd1
Parent: 8d5cff5b9bb217942c009dca49d0bffb51e85004
Author: Peter Rajnoha <prajnoha(a)redhat.com>
AuthorDate: Wed Nov 27 08:20:02 2013 +0100
Committer: Peter Rajnoha <prajnoha(a)redhat.com>
CommitterDate: Wed Nov 27 08:20:02 2013 +0100
activation: continue with autoactivation if refresh fails
If the refresh fails for any reason before autoactivation, let's not
make this a stopper for autoactivation itself - just log the error
message if it appears.
The reason is that in some rare situations, we can still hit the
problem with the suspend call to fail (as already described in
commit d8085edf65006a50608edb821b3d30947abaa838, also
https://bugzilla.redhat.com/show_bug.cgi?id=1027314) The refresh
itself is done for only one reason - to refresh any dm tables
for LVs for which the underlying PVs got unplugged/disconnected
and then plugged/connected back (see also
https://bugzilla.redhat.com/show_bug.cgi?id=954061 for more info).
In this case, the major:minor pair is changed and we need to
update dm tables for LVs accordingly.
Now if refresh fails, the error is still logged, but autoactivation
continues.
---
tools/pvscan.c | 4 +---
1 files changed, 1 insertions(+), 3 deletions(-)
diff --git a/tools/pvscan.c b/tools/pvscan.c
index ce8c446..981a9c2 100644
--- a/tools/pvscan.c
+++ b/tools/pvscan.c
@@ -147,10 +147,8 @@ static int _auto_activation_handler(struct cmd_context *cmd,
usleep(REFRESH_BEFORE_AUTOACTIVATION_RETRY_USLEEP_DELAY);
}
- if (!refresh_done) {
+ if (!refresh_done)
log_error("%s: refresh before autoactivation failed.", vg->name);
- goto out;
- }
if (!vgchange_activate(vg->cmd, vg, activate)) {
log_error("%s: autoactivation failed.", vg->name);
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=8d5cff5b9bb21794…
Commit: 8d5cff5b9bb217942c009dca49d0bffb51e85004
Parent: 47110f7e27ce2a4bf329e860cf6eb339d107fde7
Author: Peter Rajnoha <prajnoha(a)redhat.com>
AuthorDate: Tue Nov 26 14:51:23 2013 +0100
Committer: Peter Rajnoha <prajnoha(a)redhat.com>
CommitterDate: Tue Nov 26 14:51:23 2013 +0100
lv/vgchange: do not try to connect to lvmetad if socket absent and --sysinit -aay used
If using lv/vgchange --sysinit -aay and lvmetad is enabled, we'd like to
avoid the direct activation and rely on autoactivation instead so
it fits system initialization scripts.
But if we're calling lv/vgchange --sysinit -aay too early when even
lvmetad service is not started yet, we just need to do the direct
activation instead without printing any error messages (while
trying to connect to lvmetad and not finding its socket).
This patch adds two helper functions - "lvmetad_socket_present" and
"lvmetad_used" which can be used to check for this condition properly
and avoid these lvmetad connections when the socket is not present
(and hence lvmetad is not yet running).
---
WHATS_NEW | 1 +
daemons/lvmetad/lvmetad-client.h | 4 +++-
daemons/lvmetad/lvmetad-core.c | 4 +++-
lib/cache/lvmetad.c | 16 ++++++++++++++++
lib/cache/lvmetad.h | 15 +++++++++++++++
tools/lvchange.c | 30 ++++++++++++++++++++++++++----
tools/vgchange.c | 30 ++++++++++++++++++++++++++----
7 files changed, 90 insertions(+), 10 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index 9b18ef0..4148754 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.105 -
=====================================
+ Do not connect to lvmetad on vg/lvchange --sysinit -aay and socket absent.
Use lv_check_not_in_use() when testing device in use before merging.
Move test for target present from init_snapshot_merge() to lvconvert.
Check for failure of lvmcache_add_mda() when writing pv.
diff --git a/daemons/lvmetad/lvmetad-client.h b/daemons/lvmetad/lvmetad-client.h
index fe8eedc..8d6ae0e 100644
--- a/daemons/lvmetad/lvmetad-client.h
+++ b/daemons/lvmetad/lvmetad-client.h
@@ -17,6 +17,8 @@
#include "daemon-client.h"
+#define LVMETAD_SOCKET DEFAULT_RUN_DIR "/lvmetad.socket"
+
struct volume_group;
/* Different types of replies we may get from lvmetad. */
@@ -64,7 +66,7 @@ static inline daemon_handle lvmetad_open(const char *socket)
{
daemon_info lvmetad_info = {
.path = "lvmetad",
- .socket = socket ?: DEFAULT_RUN_DIR "/lvmetad.socket",
+ .socket = socket ?: LVMETAD_SOCKET,
.protocol = "lvmetad",
.protocol_version = 1,
.autostart = 0
diff --git a/daemons/lvmetad/lvmetad-core.c b/daemons/lvmetad/lvmetad-core.c
index 03d89c9..87374e8 100644
--- a/daemons/lvmetad/lvmetad-core.c
+++ b/daemons/lvmetad/lvmetad-core.c
@@ -29,6 +29,8 @@
#include <math.h> /* fabs() */
#include <float.h> /* DBL_EPSILON */
+#define LVMETAD_SOCKET DEFAULT_RUN_DIR "/lvmetad.socket"
+
typedef struct {
log_state *log; /* convenience */
const char *log_config;
@@ -1209,7 +1211,7 @@ int main(int argc, char *argv[])
if (!s.socket_path) {
_socket_override = 0;
- s.socket_path = DEFAULT_RUN_DIR "/lvmetad.socket";
+ s.socket_path = LVMETAD_SOCKET;
}
ls.log_config = "";
diff --git a/lib/cache/lvmetad.c b/lib/cache/lvmetad.c
index 5119ab1..1ead9f8 100644
--- a/lib/cache/lvmetad.c
+++ b/lib/cache/lvmetad.c
@@ -72,6 +72,22 @@ void lvmetad_connect_or_warn(void)
strerror(_lvmetad.error));
}
+int lvmetad_used(void)
+{
+ return _lvmetad_use;
+}
+
+int lvmetad_socket_present(void)
+{
+ const char *socket = _lvmetad_socket ?: LVMETAD_SOCKET;
+ int r;
+
+ if ((r = access(socket, F_OK)) && errno != ENOENT)
+ log_sys_error("lvmetad_socket_present", "");
+
+ return !r;
+}
+
int lvmetad_active(void)
{
if (!_lvmetad_use)
diff --git a/lib/cache/lvmetad.h b/lib/cache/lvmetad.h
index ff4cd0a..85b71c2 100644
--- a/lib/cache/lvmetad.h
+++ b/lib/cache/lvmetad.h
@@ -44,6 +44,19 @@ void lvmetad_set_active(int);
void lvmetad_set_socket(const char *);
/*
+ * Check whether lvmetad is used.
+ */
+int lvmetad_used(void);
+
+/*
+ * Check if lvmetad socket is present (either the one set by lvmetad_set_socket
+ * or the default one if not set). For example, this may be used before calling
+ * lvmetad_active() check that does connect to the socket - this would produce
+ * various connection errors if the socket is not present.
+ */
+int lvmetad_socket_present(void);
+
+/*
* Check whether lvmetad is active (where active means both that it is running
* and that we have a working connection with it).
*/
@@ -149,6 +162,8 @@ int lvmetad_pvscan_all_devs(struct cmd_context *cmd, activation_handler handler)
# define lvmetad_disconnect() do { } while (0)
# define lvmetad_set_active(a) do { } while (0)
# define lvmetad_set_socket(a) do { } while (0)
+# define lvmetad_used() (0)
+# define lvmetad_socket_present() (0)
# define lvmetad_active() (0)
# define lvmetad_connect_or_warn() do { } while (0)
# define lvmetad_set_token(a) do { } while (0)
diff --git a/tools/lvchange.c b/tools/lvchange.c
index 1931c03..897ffb2 100644
--- a/tools/lvchange.c
+++ b/tools/lvchange.c
@@ -1235,11 +1235,33 @@ int lvchange(struct cmd_context *cmd, int argc, char **argv)
return EINVALID_CMD_LINE;
}
- if (arg_count(cmd, sysinit_ARG) && lvmetad_active() &&
+ /*
+ * If --sysinit -aay is used and at the same time lvmetad is used,
+ * we want to rely on autoactivation to take place. Also, we
+ * need to take special care here as lvmetad service does
+ * not neet to be running at this moment yet - it could be
+ * just too early during system initialization time.
+ */
+ if (arg_count(cmd, sysinit_ARG) && lvmetad_used() &&
arg_uint_value(cmd, activate_ARG, 0) == CHANGE_AAY) {
- log_warn("lvmetad is active while using --sysinit -a ay, "
- "skipping manual activation");
- return ECMD_PROCESSED;
+ if (!lvmetad_socket_present()) {
+ /*
+ * If lvmetad socket is not present yet,
+ * the service is just not started. It'll
+ * be started a bit later so we need to do
+ * the activation without lvmetad which means
+ * direct activation instead of autoactivation.
+ */
+ log_warn("lvmetad is not active yet, using direct activation during sysinit");
+ lvmetad_set_active(0);
+ } else if (lvmetad_active()) {
+ /*
+ * If lvmetad is active already, we want
+ * to make use of the autoactivation.
+ */
+ log_warn("lvmetad is active, skipping direct activation during sysinit");
+ return ECMD_PROCESSED;
+ }
}
return process_each_lv(cmd, argc, argv,
diff --git a/tools/vgchange.c b/tools/vgchange.c
index 4087fab..b50b444 100644
--- a/tools/vgchange.c
+++ b/tools/vgchange.c
@@ -616,11 +616,33 @@ int vgchange(struct cmd_context *cmd, int argc, char **argv)
return EINVALID_CMD_LINE;
}
- if (arg_count(cmd, sysinit_ARG) && lvmetad_active() &&
+ /*
+ * If --sysinit -aay is used and at the same time lvmetad is used,
+ * we want to rely on autoactivation to take place. Also, we
+ * need to take special care here as lvmetad service does
+ * not neet to be running at this moment yet - it could be
+ * just too early during system initialization time.
+ */
+ if (arg_count(cmd, sysinit_ARG) && lvmetad_used() &&
arg_uint_value(cmd, activate_ARG, 0) == CHANGE_AAY) {
- log_warn("lvmetad is active while using --sysinit -a ay, "
- "skipping manual activation");
- return ECMD_PROCESSED;
+ if (!lvmetad_socket_present()) {
+ /*
+ * If lvmetad socket is not present yet,
+ * the service is just not started. It'll
+ * be started a bit later so we need to do
+ * the activation without lvmetad which means
+ * direct activation instead of autoactivation.
+ */
+ log_warn("lvmetad is not active yet, using direct activation during sysinit");
+ lvmetad_set_active(0);
+ } else if (lvmetad_active()) {
+ /*
+ * If lvmetad is active already, we want
+ * to make use of the autoactivation.
+ */
+ log_warn("lvmetad is active, skipping direct activation during sysinit");
+ return ECMD_PROCESSED;
+ }
}
if (arg_count(cmd, clustered_ARG) && !argc && !arg_count(cmd, yes_ARG) &&
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=782a356e7cce8d0d…
Commit: 782a356e7cce8d0d32850677cdb5a9b28996471e
Parent: d079c81ab49648fc5506490e34e16244c20fa45f
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Fri Nov 22 13:12:35 2013 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Fri Nov 22 21:00:54 2013 +0100
archiver: add check for dm_pool_strdup
It will likely not fail to duplicate empty string, but
just keep the test of result of this function consistent.
Also on error path restore extent_size if in some
case someone would still use that variable.
---
lib/format_text/archiver.c | 6 +++++-
1 files changed, 5 insertions(+), 1 deletions(-)
diff --git a/lib/format_text/archiver.c b/lib/format_text/archiver.c
index f41bffc..c1fe3f5 100644
--- a/lib/format_text/archiver.c
+++ b/lib/format_text/archiver.c
@@ -334,13 +334,17 @@ int backup_restore_vg(struct cmd_context *cmd, struct volume_group *vg, int drop
* Setting vg->old_name to a blank value will explicitly
* disable any attempt to check VG name in existing metadata.
*/
- vg->old_name = dm_pool_strdup(vg->vgmem, "");
+ if (!(vg->old_name = dm_pool_strdup(vg->vgmem, ""))) {
+ log_error("Failed to duplicate empty name.");
+ return 0;
+ }
/* Add any metadata areas on the PVs */
dm_list_iterate_items(pvl, &vg->pvs) {
tmp = vg->extent_size;
vg->extent_size = 0;
if (!vg->fid->fmt->ops->pv_setup(vg->fid->fmt, pvl->pv, vg)) {
+ vg->extent_size = tmp;
log_error("Format-specific setup for %s failed",
pv_dev_name(pvl->pv));
return 0;
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=12d5e53953f1dacd…
Commit: 12d5e53953f1dacd911190cacc153dc2343878fe
Parent: fe5b538c14c47e2e206d13c17f0225e39470d720
Author: Tony Asleson <tasleson(a)redhat.com>
AuthorDate: Thu Oct 3 16:06:05 2013 -0500
Committer: Tony Asleson <tasleson(a)redhat.com>
CommitterDate: Tue Nov 19 14:40:44 2013 -0600
lvm2app: Remove forward declarations.
Remove the forward struct declaration. This isn't needed for
implementing opaque data pointers.
Signed-off-by: Tony Asleson <tasleson(a)redhat.com>
---
liblvm/lvm2app.h | 19 ++++++-------------
1 files changed, 6 insertions(+), 13 deletions(-)
diff --git a/liblvm/lvm2app.h b/liblvm/lvm2app.h
index 0940b6f..a91640a 100644
--- a/liblvm/lvm2app.h
+++ b/liblvm/lvm2app.h
@@ -84,20 +84,13 @@ const char *lvm_library_get_version(void);
/******************************** structures ********************************/
/**
- * Opaque structures - do not use directly. Internal structures may change
- * without notice between releases, whereas this API will be changed much less
- * frequently. Backwards compatibility will normally be preserved in future
- * releases. On any occasion when the developers do decide to break backwards
- * compatibility in any significant way, the LVM_LIBAPI number (included in
- * the library's soname) will be incremented.
- */
-struct lvm;
-struct physical_volume;
-struct volume_group;
-struct logical_volume;
-struct lv_segment;
-struct pv_segment;
-struct lvm_lv_create_params;
+ * Opaque C pointers - Internal structures may change without notice between
+ * releases, whereas this API will be changed much less frequently. Backwards
+ * compatibility will normally be preserved in future releases. On any occasion
+ * when the developers do decide to break backwards compatibility in any
+ * significant way, the LVM_LIBAPI number (included in the library's soname)
+ * will be incremented.
+ */
/**
* \class lvm_t
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=e54e70dc66a8be0d…
Commit: e54e70dc66a8be0dbc61e1dbc65310d86d35b086
Parent: 531d85a0ee3854e49f9b81658dd6d7c60bb4de86
Author: Tony Asleson <tasleson(a)redhat.com>
AuthorDate: Wed Sep 11 18:13:18 2013 -0500
Committer: Tony Asleson <tasleson(a)redhat.com>
CommitterDate: Tue Nov 19 14:40:37 2013 -0600
python-lvm: Update and enable unit test case
Added tests for lvm.pvCreate and enable the test suite.
Signed-off-by: Tony Asleson <tasleson(a)redhat.com>
---
test/api/pytest.sh | 4 --
test/api/python_lvm_unit.py | 99 +++++++++++++++++++++++++++++++++++++++++++
2 files changed, 99 insertions(+), 4 deletions(-)
diff --git a/test/api/pytest.sh b/test/api/pytest.sh
index 791c9dc..67e224c 100644
--- a/test/api/pytest.sh
+++ b/test/api/pytest.sh
@@ -27,8 +27,4 @@ export PYTHONPATH=`dirname $python_lib`:$PYTHONPATH
#Setup which devices the unit test can use.
export PY_UNIT_PVS=$(cat DEVICES)
-
-#We will skip until we can ensure it is correct.
-skip
-
python_lvm_unit.py -v -f
diff --git a/test/api/python_lvm_unit.py b/test/api/python_lvm_unit.py
index eab9575..6c13149 100755
--- a/test/api/python_lvm_unit.py
+++ b/test/api/python_lvm_unit.py
@@ -27,6 +27,17 @@ import os
# production system. Therefore it is strongly advised that this unit test
# not be run on a system that contains data of value.
+fh = None
+
+
+def l(txt):
+ if os.environ.get('PY_UNIT_LOG') is not None:
+ global fh
+ if fh is None:
+ fh = open('/tmp/lvm_py_unit_test_' + rs(10), "a")
+ fh.write(txt + "\n")
+ fh.flush()
+
def rs(l=10):
"""
@@ -693,5 +704,93 @@ class TestLvm(unittest.TestCase):
self._testTags(vg)
vg.close()
+ def testListing(self):
+
+ env = os.environ
+
+ for k, v in env.items():
+ l("%s:%s" % (k, v))
+
+ with lvm.listPvs() as pvs:
+ for p in pvs:
+ l('pv= %s' % p.getName())
+
+ l('Checking for VG')
+ for v in lvm.listVgNames():
+ l('vg= %s' % v)
+
+ def testPVemptylisting(self):
+ #We had a bug where we would seg. fault if we had no PVs.
+
+ l('testPVemptylisting entry')
+
+ device_names = self._get_pv_device_names()
+
+ for d in device_names:
+ l("Removing %s" % d)
+ lvm.pvRemove(d)
+
+ count = 0
+
+ with lvm.listPvs() as pvs:
+ for p in pvs:
+ count += 1
+ l('pv= %s' % p.getName())
+
+ self.assertTrue(count == 0)
+
+ for d in device_names:
+ lvm.pvCreate(d)
+
+ def testPVCreate(self):
+ size = [0, 1024*1024*4]
+ pvmeta_copies = [0, 1, 2]
+ pvmeta_size = [0, 255, 512, 1024]
+ data_alignment = [0, 2048, 4096]
+ data_alignment_offset = [1, 1, 1]
+ zero = [0, 1]
+
+ device_names = self._get_pv_device_names()
+
+ for d in device_names:
+ lvm.pvRemove(d)
+
+ d = device_names[0]
+
+ #Test some error cases
+ self.assertRaises(TypeError, lvm.pvCreate, None)
+ self.assertRaises(lvm.LibLVMError, lvm.pvCreate, '')
+ self.assertRaises(lvm.LibLVMError, lvm.pvCreate, d, 4)
+ self.assertRaises(lvm.LibLVMError, lvm.pvCreate, d, 0, 4)
+ self.assertRaises(lvm.LibLVMError, lvm.pvCreate, d, 0, 0, 0, 2**34)
+ self.assertRaises(lvm.LibLVMError, lvm.pvCreate, d, 0, 0, 0, 4096,
+ 2**34)
+
+ #Try a number of combinations and permutations
+ for s in size:
+ lvm.pvCreate(d, s)
+ lvm.pvRemove(d)
+ for copies in pvmeta_copies:
+ lvm.pvCreate(d, s, copies)
+ lvm.pvRemove(d)
+ for pv_size in pvmeta_size:
+ lvm.pvCreate(d, s, copies, pv_size)
+ lvm.pvRemove(d)
+ for align in data_alignment:
+ lvm.pvCreate(d, s, copies, pv_size, align)
+ lvm.pvRemove(d)
+ for align_offset in data_alignment_offset:
+ lvm.pvCreate(d, s, copies, pv_size, align,
+ align * align_offset)
+ lvm.pvRemove(d)
+ for z in zero:
+ lvm.pvCreate(d, s, copies, pv_size, align,
+ align * align_offset, z)
+ lvm.pvRemove(d)
+
+ #Restore
+ for d in device_names:
+ lvm.pvCreate(d)
+
if __name__ == "__main__":
unittest.main()
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=ec7f632ce08014ca…
Commit: ec7f632ce08014ca5ceb3ac6c92d834fb0b8c93e
Parent: 5074dcc896681494309c59830803b54a84429fd0
Author: Tony Asleson <tasleson(a)redhat.com>
AuthorDate: Tue Sep 10 17:59:45 2013 -0500
Committer: Tony Asleson <tasleson(a)redhat.com>
CommitterDate: Tue Nov 19 14:40:32 2013 -0600
python-lvm: Test case change for vg.reduce
Fix reduce as newly changed vg reduce fails when you
try to remove the last pv in the vg.
Signed-off-by: Tony Asleson <tasleson(a)redhat.com>
---
test/api/python_lvm_unit.py | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/test/api/python_lvm_unit.py b/test/api/python_lvm_unit.py
index bceb82c..eab9575 100755
--- a/test/api/python_lvm_unit.py
+++ b/test/api/python_lvm_unit.py
@@ -185,7 +185,7 @@ class TestLvm(unittest.TestCase):
for p in pvs:
pe_devices.append(p.getName())
- for pv in pe_devices:
+ for pv in pe_devices[:-1]:
vg.reduce(pv)
vg.remove()
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=ecc296311ff2a251…
Commit: ecc296311ff2a251aa254353b0a0fb3ee97be97c
Parent: a5bb1b48eea704c5970a719d2e77577dccd82bb9
Author: Petr Rockai <prockai(a)redhat.com>
AuthorDate: Sun Nov 17 22:35:16 2013 +0100
Committer: Petr Rockai <prockai(a)redhat.com>
CommitterDate: Sun Nov 17 22:35:16 2013 +0100
metadata: Do not throw an error in pv_label for missing PVs.
---
lib/metadata/pv.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/lib/metadata/pv.c b/lib/metadata/pv.c
index 1d608f2..349048e 100644
--- a/lib/metadata/pv.c
+++ b/lib/metadata/pv.c
@@ -355,7 +355,7 @@ struct label *pv_label(const struct physical_volume *pv)
struct lvmcache_info *info =
lvmcache_info_from_pvid((const char *)&pv->id.uuid, 0);
if (!info) {
- if (pv->vg) /* process_each_pv will create PVs that are dummy
+ if (pv->vg && pv->dev) /* process_each_pv will create PVs that are dummy
* and that have no label associated */
log_error(INTERNAL_ERROR "PV %s unexpectedly not in cache.",
dev_name(pv->dev));
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=bead8ef5f03f5630…
Commit: bead8ef5f03f563064276037eed5d9ca94b67ead
Parent: ba6d6f002837d0fa2f27ad3660cfde7887870401
Author: Petr Rockai <prockai(a)redhat.com>
AuthorDate: Tue Feb 19 10:57:45 2013 +0100
Committer: Petr Rockai <prockai(a)redhat.com>
CommitterDate: Sun Nov 17 21:41:27 2013 +0100
metadata: Nuke the exported "pv_read" function.
---
lib/metadata/metadata-exported.h | 3 ---
lib/metadata/metadata.c | 36 ------------------------------------
2 files changed, 0 insertions(+), 39 deletions(-)
diff --git a/lib/metadata/metadata-exported.h b/lib/metadata/metadata-exported.h
index c00e4e5..1bf5236 100644
--- a/lib/metadata/metadata-exported.h
+++ b/lib/metadata/metadata-exported.h
@@ -505,9 +505,6 @@ int vg_commit(struct volume_group *vg);
void vg_revert(struct volume_group *vg);
struct volume_group *vg_read_internal(struct cmd_context *cmd, const char *vg_name,
const char *vgid, int warnings, int *consistent);
-struct physical_volume *pv_read(struct cmd_context *cmd, const char *pv_name,
- int warnings,
- int scan_label_only);
#define get_pvs( cmd ) get_pvs_internal((cmd), NULL, NULL)
#define get_pvs_perserve_vg( cmd, pv_list, vg_list ) get_pvs_internal((cmd), (pv_list), (vg_list))
diff --git a/lib/metadata/metadata.c b/lib/metadata/metadata.c
index fa480c8..aa5f124 100644
--- a/lib/metadata/metadata.c
+++ b/lib/metadata/metadata.c
@@ -1339,20 +1339,6 @@ static int pvcreate_check(struct cmd_context *cmd, const char *name,
if (!(pv = find_pv_by_name(cmd, name, 1)))
stack;
- /*
- * If a PV has no MDAs it may appear to be an orphan until the
- * metadata is read off another PV in the same VG. Detecting
- * this means checking every VG by scanning every PV on the
- * system.
- */
- if (pv && is_orphan(pv) && dm_list_empty(&pv->fid->metadata_areas_in_use)) {
- free_pv_fid(pv);
- if (!scan_vgs_for_pvs(cmd, 0))
- return_0;
- if (!(pv = pv_read(cmd, name, 0, 0)))
- stack;
- }
-
/* Allow partial & exported VGs to be destroyed. */
/* We must have -ff to overwrite a non orphan */
if (pv && !is_orphan(pv) && pp->force != DONT_PROMPT_OVERRIDE) {
@@ -3652,28 +3638,6 @@ const char *find_vgname_from_pvname(struct cmd_context *cmd,
return find_vgname_from_pvid(cmd, pvid);
}
-/**
- * pv_read - read and return a handle to a physical volume
- * @cmd: LVM command initiating the pv_read
- * @pv_name: full device name of the PV, including the path
- * @mdas: list of metadata areas of the PV
- * @label_sector: sector number where the PV label is stored on @pv_name
- * @warnings:
- *
- * Returns:
- * PV handle - valid pv_name and successful read of the PV, or
- * NULL - invalid parameter or error in reading the PV
- *
- * Note:
- * FIXME - liblvm todo - make into function that returns handle
- */
-struct physical_volume *pv_read(struct cmd_context *cmd, const char *pv_name,
- int warnings,
- int scan_label_only)
-{
- return _pv_read(cmd, cmd->mem, pv_name, NULL, warnings, scan_label_only);
-}
-
/* FIXME Use label functions instead of PV functions */
static struct physical_volume *_pv_read(struct cmd_context *cmd,
struct dm_pool *pvmem,
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=0a59305c44e99283…
Commit: 0a59305c44e992831d66da50f5058f154a795d3a
Parent: 7e685e6c70e5b738e5740b920e6080b9a13c2556
Author: Petr Rockai <prockai(a)redhat.com>
AuthorDate: Tue Jun 11 09:13:39 2013 +0200
Committer: Petr Rockai <prockai(a)redhat.com>
CommitterDate: Sun Nov 17 21:41:26 2013 +0100
test: Add a test for the failing pv_read optimisation.
---
test/shell/mda-rollback.sh | 26 ++++++++++++++++++++++++++
1 files changed, 26 insertions(+), 0 deletions(-)
diff --git a/test/shell/mda-rollback.sh b/test/shell/mda-rollback.sh
new file mode 100644
index 0000000..d47eb8a
--- /dev/null
+++ b/test/shell/mda-rollback.sh
@@ -0,0 +1,26 @@
+#!/bin/sh
+# Copyright (C) 2013 Red Hat, Inc. All rights reserved.
+#
+# This copyrighted material is made available to anyone wishing to use,
+# modify, copy, or redistribute it subject to the terms and conditions
+# of the GNU General Public License v.2.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software Foundation,
+# Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+. lib/test
+
+aux prepare_devs 3
+
+vgcreate --metadatasize 128k $vg1 "$dev1" "$dev2" "$dev3"
+
+vgreduce $vg1 $dev1
+dd if="$dev1" of=badmda bs=256K count=1
+vgextend $vg1 $dev1
+
+dd if=badmda of="$dev1" bs=256K count=1
+
+# dev1 is part of vg1 (as witnessed by metadata on dev2 and dev3), but its mda
+# was corrupt (written over by a backup from time dev1 was an orphan)
+check pv_field $dev1 vg_name $vg1
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=77a1efeb8eb0fe73…
Commit: 77a1efeb8eb0fe73c858ade05b578c3cfe3ddd9f
Parent: 527db4645fdbf10361797c871b9cadf6c5e73405
Author: Alasdair G Kergon <agk(a)redhat.com>
AuthorDate: Wed Nov 13 14:02:34 2013 +0000
Committer: Alasdair G Kergon <agk(a)redhat.com>
CommitterDate: Wed Nov 13 14:02:34 2013 +0000
release 2.02.104
87 files changed, 1207 insertions(+), 294 deletions(-)
---
VERSION | 2 +-
VERSION_DM | 2 +-
WHATS_NEW | 7 +++----
WHATS_NEW_DM | 6 ++++--
4 files changed, 9 insertions(+), 8 deletions(-)
diff --git a/VERSION b/VERSION
index 8e798d0..576af30 100644
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-2.02.104(2)-git (2013-10-04)
+2.02.104(2)-git (2013-11-13)
diff --git a/VERSION_DM b/VERSION_DM
index 0e6eddb..89b02c3 100644
--- a/VERSION_DM
+++ b/VERSION_DM
@@ -1 +1 @@
-1.02.83-git (2013-10-04)
+1.02.83-git (2013-11-13)
diff --git a/WHATS_NEW b/WHATS_NEW
index ff6041d..475794e 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,5 @@
-Version 2.02.104 -
-===================================
+Version 2.02.104 - 13th November 2013
+=====================================
Workaround VG refresh race during autoactivation by retrying the refresh.
Handle failures in temporary mirror used when adding images to mirrors.
Fix and improve logic for implicitely exclusive activations.
@@ -28,7 +28,6 @@ Version 2.02.104 -
Move code to remove virtual snapshot from tools to lib for lvm2app.
Fix possible race during daemon worker thread creation (lvmetad).
Fix possible deadlock while clearing lvmetad cache for full rescan.
- Fix possible race while creating/destroying memory pools.
Recognise NVM Express devices in filter.
Fix failing metadata repair when lvmetad is used.
Fix incorrect memory handling when reading messages from lvmetad.
@@ -37,7 +36,7 @@ Version 2.02.104 -
Add support for flagging an LV to skip udev scanning during activation.
Improve message when unable to change discards setting on active thin pool.
Run full scan before vgrename operation to avoid any cache name collision.
- Fix lvconvert when converting to a thin pool and thin LV at once.
+ Fix lvconvert when converting to a thin pool and thin LV at once. (2.02.99)
Version 2.02.103 - 4th October 2013
===================================
diff --git a/WHATS_NEW_DM b/WHATS_NEW_DM
index 0f905fd..1e8bae7 100644
--- a/WHATS_NEW_DM
+++ b/WHATS_NEW_DM
@@ -1,9 +1,11 @@
-Version 1.02.83
-==================================
+Version 1.02.83 - 13th November 2013
+====================================
Consistently report on stderr when device is not found for dmsetup info.
Skip race errors when non-udev dmsetup build runs on udev-enabled system.
Skip error message when holders are not present in sysfs.
Use __linux__ instead of linux define to make libdevmapper.h C compliant.
+ Use mutex to avoid possible race while creating/destroying memory pools.
+ Require libpthread to build now.
Version 1.02.82 - 4th October 2013
==================================
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=d8085edf65006a50…
Commit: d8085edf65006a50608edb821b3d30947abaa838
Parent: 7de533ad12972f5a9c5bf2d2b477d8320f7e4a8e
Author: Peter Rajnoha <prajnoha(a)redhat.com>
AuthorDate: Tue Nov 12 10:55:34 2013 +0100
Committer: Peter Rajnoha <prajnoha(a)redhat.com>
CommitterDate: Tue Nov 12 11:09:45 2013 +0100
pvscan: retry VG refresh before autoactivation if it fails
There's a tiny race when suspending the device which is part
of the refresh because when suspend ioctl is performed, the
dm kernel driver executes (do_suspend and dm_suspend kernel fn):
step 1: a check whether the dev is already suspended and
if yes it returns success immediately as there's
nothing to do
step 2: it grabs the suspend lock
step 3: another check whether the dev is already suspended
and if found suspended, it exits with -EINVAL now
The race can occur in between step 1 and step 2. To prevent
premature autoactivation failure, we're using a simple retry
logic here before we fail completely. For a complete solution,
we need to fix the locking so there's no possibility for suspend
calls to interleave each other to cause this kind of race.
This is just a workaround. Remove it and replace it with proper
locking once we have that in!
---
WHATS_NEW | 1 +
tools/pvscan.c | 34 +++++++++++++++++++++++++++++++++-
2 files changed, 34 insertions(+), 1 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index 5eb4abe..af1a26a 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.104 -
===================================
+ Workaround VG refresh race during autoactivation by retrying the refresh.
Handle failures in temporary mirror used when adding images to mirrors.
Fix and improve logic for implicitely exclusive activations.
Return success when LV cannot be activated because of volume_list filter.
diff --git a/tools/pvscan.c b/tools/pvscan.c
index b6a07bd..ce8c446 100644
--- a/tools/pvscan.c
+++ b/tools/pvscan.c
@@ -91,10 +91,15 @@ static void _pvscan_display_single(struct cmd_context *cmd,
display_size(cmd, (uint64_t) (pv_pe_count(pv) - pv_pe_alloc_count(pv)) * pv_pe_size(pv)));
}
+#define REFRESH_BEFORE_AUTOACTIVATION_RETRIES 5
+#define REFRESH_BEFORE_AUTOACTIVATION_RETRY_USLEEP_DELAY 100000
+
static int _auto_activation_handler(struct cmd_context *cmd,
const char *vgid, int partial,
activation_change_t activate)
{
+ unsigned int refresh_retries = REFRESH_BEFORE_AUTOACTIVATION_RETRIES;
+ int refresh_done = 0;
struct volume_group *vg;
int consistent = 0;
struct id vgid_raw;
@@ -115,7 +120,34 @@ static int _auto_activation_handler(struct cmd_context *cmd,
r = 1; goto out;
}
- if (!vg_refresh_visible(vg->cmd, vg)) {
+ /* FIXME: There's a tiny race when suspending the device which is part
+ * of the refresh because when suspend ioctl is performed, the dm
+ * kernel driver executes (do_suspend and dm_suspend kernel fn):
+ *
+ * step 1: a check whether the dev is already suspended and
+ * if yes it returns success immediately as there's
+ * nothing to do
+ * step 2: it grabs the suspend lock
+ * step 3: another check whether the dev is already suspended
+ * and if found suspended, it exits with -EINVAL now
+ *
+ * The race can occur in between step 1 and step 2. To prevent premature
+ * autoactivation failure, we're using a simple retry logic here before
+ * we fail completely. For a complete solution, we need to fix the
+ * locking so there's no possibility for suspend calls to interleave
+ * each other to cause this kind of race.
+ *
+ * Remove this workaround with "refresh_retries" once we have proper locking in!
+ */
+ while (refresh_retries--) {
+ if (vg_refresh_visible(vg->cmd, vg)) {
+ refresh_done = 1;
+ break;
+ }
+ usleep(REFRESH_BEFORE_AUTOACTIVATION_RETRY_USLEEP_DELAY);
+ }
+
+ if (!refresh_done) {
log_error("%s: refresh before autoactivation failed.", vg->name);
goto out;
}
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=7de533ad12972f5a…
Commit: 7de533ad12972f5a9c5bf2d2b477d8320f7e4a8e
Parent: b6b5299d1e1f6bdddb9bda30c4f37aaccbe3df44
Author: Jonathan Brassow <jbrassow(a)redhat.com>
AuthorDate: Fri Nov 8 09:52:00 2013 -0600
Committer: Jonathan Brassow <jbrassow(a)redhat.com>
CommitterDate: Fri Nov 8 09:52:00 2013 -0600
mirror: Handle failures in tmp mirror used when up-converting.
Failures in the temporary mirror used when up-converting cause dmeventd
to issue 'lvconvert --repair' on the sub-LV, <lv_name>_mimagetmp_?. The
'lvconvert' command refuses to deal with this sub-LV outright - it
expects to be given the name of the top-level LV. So, just like we do
with mirrored logs, we strip-off the portion of the name that is not
the top-level LV and issue the command on the top-level LV instead.
---
WHATS_NEW | 1 +
daemons/dmeventd/plugins/lvm2/dmeventd_lvm.c | 4 ++--
2 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index f0a764b..5eb4abe 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.104 -
===================================
+ Handle failures in temporary mirror used when adding images to mirrors.
Fix and improve logic for implicitely exclusive activations.
Return success when LV cannot be activated because of volume_list filter.
Return proper error state for remote exclusive activation.
diff --git a/daemons/dmeventd/plugins/lvm2/dmeventd_lvm.c b/daemons/dmeventd/plugins/lvm2/dmeventd_lvm.c
index 5d5a46b..6d2c3de 100644
--- a/daemons/dmeventd/plugins/lvm2/dmeventd_lvm.c
+++ b/daemons/dmeventd/plugins/lvm2/dmeventd_lvm.c
@@ -159,8 +159,8 @@ int dmeventd_lvm2_command(struct dm_pool *mem, char *buffer, size_t size,
}
/* strip off the mirror component designations */
- layer = strstr(lv, "_mlog");
- if (layer)
+ if ((layer = strstr(lv, "_mimagetmp")) ||
+ (layer = strstr(lv, "_mlog")))
*layer = '\0';
r = dm_snprintf(buffer, size, "%s %s/%s", cmd, vg, lv);
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=52f41baedba31335…
Commit: 52f41baedba31335cd16d7767df26378f43c4626
Parent: 9f6209b878fb5b33dae5bc52a7ea47a9de9ff900
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Fri Nov 1 12:40:27 2013 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Fri Nov 1 13:05:03 2013 +0100
dmsetup: report error on stderr
Send error message on stdout, since after _display_info_long()
command return errors.
Patch makes consistent behavior for command:
dmsetup info -c non-existing-dev
&
dmsetup info non-existing-dev
Now both commands report error on stderr when they return error status
for non-existing device.
---
WHATS_NEW_DM | 1 +
tools/dmsetup.c | 2 +-
2 files changed, 2 insertions(+), 1 deletions(-)
diff --git a/WHATS_NEW_DM b/WHATS_NEW_DM
index 6742ad4..0f905fd 100644
--- a/WHATS_NEW_DM
+++ b/WHATS_NEW_DM
@@ -1,5 +1,6 @@
Version 1.02.83
==================================
+ Consistently report on stderr when device is not found for dmsetup info.
Skip race errors when non-udev dmsetup build runs on udev-enabled system.
Skip error message when holders are not present in sysfs.
Use __linux__ instead of linux define to make libdevmapper.h C compliant.
diff --git a/tools/dmsetup.c b/tools/dmsetup.c
index a0ee23e..e25d109 100644
--- a/tools/dmsetup.c
+++ b/tools/dmsetup.c
@@ -461,7 +461,7 @@ static void _display_info_long(struct dm_task *dmt, struct dm_info *info)
uint32_t read_ahead;
if (!info->exists) {
- printf("Device does not exist.\n");
+ fprintf(stderr, "Device does not exist.\n");
return;
}
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=c3e674ad3010d21d…
Commit: c3e674ad3010d21dc2cbde27b7634f7ea4fe67e3
Parent: 1bde9f68cea61c7ee085588f2595ed52277da084
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Fri Nov 1 10:28:42 2013 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Fri Nov 1 13:02:36 2013 +0100
activation: _lv_activate is ok when filtered.
If the volume_list filters out volume from activation,
it is still success result for this function.
Change the error message back to verbose level.
Detect if the volume is active localy before zeroing,
so we report error a bit later for cases, where volume
could not be activated because it doesn't pass through volume
list (but user still could create volume when he disables
zeroing)
---
WHATS_NEW | 1 +
lib/activate/activate.c | 5 +++--
lib/metadata/lv_manip.c | 6 ++++++
3 files changed, 10 insertions(+), 2 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index 2bf95d2..ff8da1d 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.104 -
===================================
+ Return success when LV cannot be activated because of volume_list filter.
Return proper error state for remote exclusive activation.
Fix missing lvmetad scan for PVs found on MD partitions.
Respect DM_UDEV_DISABLE_OTHER_RULES_FLAG in lvmetad udev rules.
diff --git a/lib/activate/activate.c b/lib/activate/activate.c
index 006681e..7e6a5ac 100644
--- a/lib/activate/activate.c
+++ b/lib/activate/activate.c
@@ -2029,8 +2029,9 @@ static int _lv_activate(struct cmd_context *cmd, const char *lvid_s,
goto out;
if (filter && !_passes_activation_filter(cmd, lv)) {
- log_error("Not activating %s/%s since it does not pass "
- "activation filter.", lv->vg->name, lv->name);
+ log_verbose("Not activating %s/%s since it does not pass "
+ "activation filter.", lv->vg->name, lv->name);
+ r = 1;
goto out;
}
diff --git a/lib/metadata/lv_manip.c b/lib/metadata/lv_manip.c
index 88fceb2..020b365 100644
--- a/lib/metadata/lv_manip.c
+++ b/lib/metadata/lv_manip.c
@@ -5381,6 +5381,12 @@ int set_lv(struct cmd_context *cmd, struct logical_volume *lv,
struct device *dev;
char *name;
+ if (!lv_is_active_locally(lv)) {
+ log_error("Volume \"%s/%s\" is not active locally.",
+ lv->vg->name, lv->name);
+ return 0;
+ }
+
/*
* FIXME:
* <clausen> also, more than 4k
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=1bde9f68cea61c7e…
Commit: 1bde9f68cea61c7ee085588f2595ed52277da084
Parent: de7531d384b1b505801ac232da45b9ffe58f061b
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Fri Nov 1 10:26:43 2013 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Fri Nov 1 13:02:13 2013 +0100
locking: activate_lv_excl return correct error code
Correct return code of activate_lv_excl().
Function is not supposed to return activation state of
activated volume, but return code of the operation.
Since i.e. when activation filter is allowing to activate
volume on current system, it is still success even though
no volume is activated.
---
WHATS_NEW | 1 +
lib/locking/locking.c | 6 +++---
2 files changed, 4 insertions(+), 3 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index b8a9bf7..2bf95d2 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.104 -
===================================
+ Return proper error state for remote exclusive activation.
Fix missing lvmetad scan for PVs found on MD partitions.
Respect DM_UDEV_DISABLE_OTHER_RULES_FLAG in lvmetad udev rules.
Fix clvmd message verification to not reject REMOTE flag. (2.02.100)
diff --git a/lib/locking/locking.c b/lib/locking/locking.c
index 9183ee6..9433e40 100644
--- a/lib/locking/locking.c
+++ b/lib/locking/locking.c
@@ -559,10 +559,10 @@ int activate_lv_excl(struct cmd_context *cmd, struct logical_volume *lv)
return 1;
/* FIXME Deal with error return codes. */
- if (activate_lv_excl_remote(cmd, lv))
- stack;
+ if (!activate_lv_excl_remote(cmd, lv))
+ return_0;
- return lv_is_active_exclusive(lv);
+ return 1;
}
/* Lock a list of LVs */