master - lvmlockd: use flag to avoid blocking in sanlock_acquire
by David Teigland
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=df34fcdafd20ac...
Commit: df34fcdafd20ac195e588a06c8fc5a904fa71669
Parent: a6d1c8ac651ecdc6fbdfa20f892ba318c2dddeda
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Wed Oct 14 14:36:46 2015 -0500
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Wed Oct 14 14:39:29 2015 -0500
lvmlockd: use flag to avoid blocking in sanlock_acquire
If a host failed while holding a sanlock lease,
sanlock_acquire will by default block and wait
for the lease to expire before returning. We
want it to return with an error so we can retry
instead of blocking, which allows us to process
other lock operations.
(Enclose this in an ifdef until the new flag
appears in a sanlock release.)
---
daemons/lvmlockd/lvmlockd-sanlock.c | 29 +++++++++++++++++++++++++++++
1 files changed, 29 insertions(+), 0 deletions(-)
diff --git a/daemons/lvmlockd/lvmlockd-sanlock.c b/daemons/lvmlockd/lvmlockd-sanlock.c
index 1e691eb..e1a85b4 100644
--- a/daemons/lvmlockd/lvmlockd-sanlock.c
+++ b/daemons/lvmlockd/lvmlockd-sanlock.c
@@ -1392,6 +1392,15 @@ int lm_lock_sanlock(struct lockspace *ls, struct resource *r, int ld_mode,
if (adopt)
flags |= SANLK_ACQUIRE_ORPHAN_ONLY;
+#ifdef SANLOCK_HAS_ACQUIRE_OWNER_NOWAIT
+ /*
+ * Don't block waiting for a failed lease to expire since it causes
+ * sanlock_acquire to block for a long time, which would prevent this
+ * thread from processing other lock requests.
+ */
+ flags |= SANLK_ACQUIRE_OWNER_NOWAIT;
+#endif
+
rv = sanlock_acquire(lms->sock, -1, flags, 1, &rs, NULL);
if (rv == -EAGAIN) {
@@ -1462,6 +1471,26 @@ int lm_lock_sanlock(struct lockspace *ls, struct resource *r, int ld_mode,
return -EAGAIN;
}
+#ifdef SANLOCK_HAS_ACQUIRE_OWNER_NOWAIT
+ if (rv == SANLK_ACQUIRE_OWNED_RETRY) {
+ /*
+ * The lock is held by a failed host, and will eventually
+ * expire. If we retry we'll eventually acquire the lock
+ * (or find someone else has acquired it). The EAGAIN retry
+ * attempts for SH locks above would not be sufficient for
+ * the length of expiration time. We could add a longer
+ * retry time here to cover the full expiration time and block
+ * the activation command for that long. For now just return
+ * the standard error indicating that another host still owns
+ * the lease. FIXME: return a different error number so the
+ * command can print an different error indicating that the
+ * owner of the lease is in the process of expiring?
+ */
+ log_debug("S %s R %s lock_san acquire mode %d rv %d", ls->name, r->name, ld_mode, rv);
+ *retry = 0;
+ return -EAGAIN;
+ }
+#endif
if (rv < 0) {
log_error("S %s R %s lock_san acquire error %d",
ls->name, r->name, rv);
7 years, 11 months
master - dmeventd: use matching function
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=a6d1c8ac651ecd...
Commit: a6d1c8ac651ecdc6fbdfa20f892ba318c2dddeda
Parent: 7c36d7c90c77f8225432b451cb831711cea01883
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Wed Oct 14 14:19:47 2015 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Wed Oct 14 14:25:27 2015 +0200
dmeventd: use matching function
Respect lvm2_log_fn prototype. The idea of 'reusing' print_log with
plain cast is causing very strange crashes with some older 'gcc' compilers.
So just do it cleanly...
---
daemons/dmeventd/plugins/lvm2/dmeventd_lvm.c | 8 +++++++-
1 files changed, 7 insertions(+), 1 deletions(-)
diff --git a/daemons/dmeventd/plugins/lvm2/dmeventd_lvm.c b/daemons/dmeventd/plugins/lvm2/dmeventd_lvm.c
index e3d8321..49bfb56 100644
--- a/daemons/dmeventd/plugins/lvm2/dmeventd_lvm.c
+++ b/daemons/dmeventd/plugins/lvm2/dmeventd_lvm.c
@@ -34,6 +34,12 @@ static void *_lvm_handle = NULL;
DM_EVENT_LOG_FN("lvm")
+static void lvm2_print_log(int level, const char *file, int line,
+ int dm_errno_or_class, const char *msg)
+{
+ print_log(level, file, line, dm_errno_or_class, "%s", msg);
+}
+
/*
* Currently only one event can be processed at a time.
*/
@@ -56,7 +62,7 @@ int dmeventd_lvm2_init(void)
pthread_mutex_lock(&_register_mutex);
if (!_lvm_handle) {
- lvm2_log_fn((lvm2_log_fn_t)print_log);
+ lvm2_log_fn(lvm2_print_log);
if (!(_lvm_handle = lvm2_init()))
goto out;
7 years, 11 months
master - thin: enforce local activation when creation new thin
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=7c36d7c90c77f8...
Commit: 7c36d7c90c77f8225432b451cb831711cea01883
Parent: bbef4edd06097a71601b1470a713ded17deb7cba
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Wed Oct 14 01:00:35 2015 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Wed Oct 14 01:00:35 2015 +0200
thin: enforce local activation when creation new thin
As we need to check how full thin-pool is - require thin-pool is
locally active.
---
lib/metadata/lv_manip.c | 19 +++++++++++++------
1 files changed, 13 insertions(+), 6 deletions(-)
diff --git a/lib/metadata/lv_manip.c b/lib/metadata/lv_manip.c
index 8a0bbcd..7a3d9b9 100644
--- a/lib/metadata/lv_manip.c
+++ b/lib/metadata/lv_manip.c
@@ -7088,16 +7088,23 @@ static struct logical_volume *_lv_create_an_lv(struct volume_group *vg,
}
if (seg_is_thin_volume(lp)) {
+ thin_pool_was_active = lv_is_active(pool_lv);
if (lv_is_new_thin_pool(pool_lv)) {
- thin_pool_was_active = lv_is_active(pool_lv);
if (!check_new_thin_pool(pool_lv))
return_NULL;
/* New pool is now inactive */
- } else if (!pool_below_threshold(first_seg(pool_lv))) {
- log_error("Cannot create new thin volume, free space in "
- "thin pool %s reached threshold.",
- display_lvname(pool_lv));
- return NULL;
+ } else {
+ if (!activate_lv_excl_local(cmd, pool_lv)) {
+ log_error("Aborting. Failed to locally activate thin pool %s.",
+ display_lvname(pool_lv));
+ return 0;
+ }
+ if (!pool_below_threshold(first_seg(pool_lv))) {
+ log_error("Cannot create new thin volume, free space in "
+ "thin pool %s reached threshold.",
+ display_lvname(pool_lv));
+ return NULL;
+ }
}
}
7 years, 11 months
master - makefiles: switch to rpath-link
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=bbef4edd06097a...
Commit: bbef4edd06097a71601b1470a713ded17deb7cba
Parent: 3f1a3b7090d421d46f245454bc5c8ed299a9cc1d
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Wed Oct 14 00:51:55 2015 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Wed Oct 14 00:51:55 2015 +0200
makefiles: switch to rpath-link
Plain rpath is to invasive and gets into binary.
We only want to provide hint for linker.
---
scripts/Makefile.in | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/scripts/Makefile.in b/scripts/Makefile.in
index bfa0fad..af2b299 100644
--- a/scripts/Makefile.in
+++ b/scripts/Makefile.in
@@ -1,5 +1,5 @@
#
-# Copyright (C) 2006-2011 Red Hat, Inc. All rights reserved.
+# Copyright (C) 2006-2015 Red Hat, Inc. All rights reserved.
#
# This file is part of LVM2.
#
@@ -26,7 +26,7 @@ ifeq ("@APPLIB@", "yes")
DEPLIBS += $(top_builddir)/liblvm/liblvm2app.so $(top_builddir)/libdm/libdevmapper.so
LDFLAGS += -L$(top_builddir)/liblvm
ifeq ("@DMEVENTD@", "yes")
- LDFLAGS += -Wl,-rpath,$(top_builddir)/daemons/dmeventd
+ LDFLAGS += -Wl,-rpath-link,$(top_builddir)/daemons/dmeventd
endif
LVMLIBS = @LVM2APP_LIB@ -ldevmapper
endif
7 years, 11 months
master - dmeventd: fix missing '!'
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=3f1a3b7090d421...
Commit: 3f1a3b7090d421d46f245454bc5c8ed299a9cc1d
Parent: a91fbe9d27a79b4be7fad72fc7a1ba2a976ecd41
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Tue Oct 13 22:10:47 2015 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Tue Oct 13 22:10:47 2015 +0200
dmeventd: fix missing '!'
During recent code changes '!' was badly converted.
---
.../dmeventd/plugins/snapshot/dmeventd_snapshot.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/daemons/dmeventd/plugins/snapshot/dmeventd_snapshot.c b/daemons/dmeventd/plugins/snapshot/dmeventd_snapshot.c
index aebe5f9..d5575f3 100644
--- a/daemons/dmeventd/plugins/snapshot/dmeventd_snapshot.c
+++ b/daemons/dmeventd/plugins/snapshot/dmeventd_snapshot.c
@@ -201,7 +201,7 @@ int register_device(const char *device,
{
struct dso_state *state;
- if (dmeventd_lvm2_init_with_pool("snapshot_state", state))
+ if (!dmeventd_lvm2_init_with_pool("snapshot_state", state))
goto_bad;
if (!dmeventd_lvm2_command(state->mem, state->cmd_lvextend,
7 years, 11 months
master - makefiles: older gcc needs hint with rpath
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=a91fbe9d27a79b...
Commit: a91fbe9d27a79b4be7fad72fc7a1ba2a976ecd41
Parent: ccc39be053b9a186abc6a020f516ff5f425981d6
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Tue Oct 13 22:02:17 2015 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Tue Oct 13 22:02:17 2015 +0200
makefiles: older gcc needs hint with rpath
gcc 4.3 seems not to be able to find linked library without
specifying -rpath to linker (plain -L) is not enough.
---
scripts/Makefile.in | 3 +++
1 files changed, 3 insertions(+), 0 deletions(-)
diff --git a/scripts/Makefile.in b/scripts/Makefile.in
index f7f672d..bfa0fad 100644
--- a/scripts/Makefile.in
+++ b/scripts/Makefile.in
@@ -25,6 +25,9 @@ include $(top_builddir)/make.tmpl
ifeq ("@APPLIB@", "yes")
DEPLIBS += $(top_builddir)/liblvm/liblvm2app.so $(top_builddir)/libdm/libdevmapper.so
LDFLAGS += -L$(top_builddir)/liblvm
+ifeq ("@DMEVENTD@", "yes")
+ LDFLAGS += -Wl,-rpath,$(top_builddir)/daemons/dmeventd
+endif
LVMLIBS = @LVM2APP_LIB@ -ldevmapper
endif
7 years, 11 months
master - dmeventd: compilable without DEBUG CFLAG
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=ccc39be053b9a1...
Commit: ccc39be053b9a186abc6a020f516ff5f425981d6
Parent: 0cf787a377548394f4588b671c2890ee1a45098b
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Tue Oct 13 20:57:59 2015 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Tue Oct 13 20:59:35 2015 +0200
dmeventd: compilable without DEBUG CFLAG
Missed compilability without DEBUG.
---
daemons/dmeventd/dmeventd.c | 9 ++++++---
1 files changed, 6 insertions(+), 3 deletions(-)
diff --git a/daemons/dmeventd/dmeventd.c b/daemons/dmeventd/dmeventd.c
index ba7d01c..56c504a 100644
--- a/daemons/dmeventd/dmeventd.c
+++ b/daemons/dmeventd/dmeventd.c
@@ -112,8 +112,6 @@ static int _restart = 0;
static char **_initial_registrations = 0;
/* FIXME Make configurable at runtime */
-#ifdef DEBUG
-# define DEBUGLOG log_debug
__attribute__((format(printf, 4, 5)))
static void _dmeventd_log(int level, const char *file, int line,
const char *format, ...)
@@ -124,6 +122,8 @@ static void _dmeventd_log(int level, const char *file, int line,
va_end(ap);
}
+#ifdef DEBUG
+# define DEBUGLOG log_debug
static const char *decode_cmd(uint32_t cmd)
{
switch (cmd) {
@@ -1535,8 +1535,9 @@ static void _process_request(struct dm_event_fifos *fifos)
{
int die;
struct dm_event_daemon_message msg = { 0 };
+#ifdef DEBUG
int cmd;
-
+#endif
/*
* Read the request from the client (client_read, client_write
* give true on success and false on failure).
@@ -1544,7 +1545,9 @@ static void _process_request(struct dm_event_fifos *fifos)
if (!_client_read(fifos, &msg))
return;
+#ifdef DEBUG
cmd = msg.cmd;
+#endif
DEBUGLOG(">>> CMD:%s (0x%x) processing...", decode_cmd(cmd), cmd);
die = (msg.cmd == DM_EVENT_CMD_DIE) ? 1 : 0;
7 years, 11 months
master - Revert "log: no file for external logging"
by Alasdair Kergon
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=0cf787a3775483...
Commit: 0cf787a377548394f4588b671c2890ee1a45098b
Parent: acc70de43968961e9a71612cda04642e4fbfd71f
Author: Alasdair G Kergon <agk(a)redhat.com>
AuthorDate: Tue Oct 13 15:31:57 2015 +0100
Committer: Alasdair G Kergon <agk(a)redhat.com>
CommitterDate: Tue Oct 13 15:31:57 2015 +0100
Revert "log: no file for external logging"
This reverts commit 1b1c01a27b359f8e91c3c9e08684c435d8fd51c2.
This caused messages to get dropped instead of logged into the log file.
(The log file and log function are independent at the moment.)
---
WHATS_NEW | 1 -
lib/log/log.c | 4 ----
2 files changed, 0 insertions(+), 5 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index 7507b9c..c089228 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,6 +1,5 @@
Version 2.02.133 -
======================================
- Avoid creation of log file when logging function is set.
Do not change logging in lvm2 library when it's already set.
Check for enough space in thin-pool in command before creating new thin.
Make libblkid detect all copies of the same signature if use_blkid_wiping=1.
diff --git a/lib/log/log.c b/lib/log/log.c
index 2f1be72..c44c3d4 100644
--- a/lib/log/log.c
+++ b/lib/log/log.c
@@ -71,10 +71,6 @@ void init_log_file(const char *log_file, int append)
int i = 0;
_log_file_path[0] = '\0';
-
- if (_lvm2_log_fn)
- return; /* No log file, when log function is set */
-
if ((env = getenv("LVM_LOG_FILE_EPOCH"))) {
while (isalpha(env[i]) && i < 32) /* Up to 32 alphas */
i++;
7 years, 11 months
master - tests: more extend testing
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=acc70de4396896...
Commit: acc70de43968961e9a71612cda04642e4fbfd71f
Parent: cf1c2da836223de64daacd94f0fd40a96f6cd46f
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Tue Oct 13 14:33:24 2015 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Tue Oct 13 16:02:21 2015 +0200
tests: more extend testing
---
test/shell/lvextend-thin-metadata-dmeventd.sh | 51 +++++++++++++++++++++++--
1 files changed, 47 insertions(+), 4 deletions(-)
diff --git a/test/shell/lvextend-thin-metadata-dmeventd.sh b/test/shell/lvextend-thin-metadata-dmeventd.sh
index ea081a2..9ecd5ae 100644
--- a/test/shell/lvextend-thin-metadata-dmeventd.sh
+++ b/test/shell/lvextend-thin-metadata-dmeventd.sh
@@ -37,14 +37,20 @@ wait_for_change_() {
# Currently it expects 2MB thin metadata and 200MB data volume size
# Argument specifies how many devices should be created.
fake_metadata_() {
- echo '<superblock uuid="" time="1" transaction="'$2'" data_block_size="128" nr_data_blocks="3200">'
- for i in $(seq 1 $1)
+ echo '<superblock uuid="" time="0" transaction="'$2'" data_block_size="128" nr_data_blocks="3200">'
+ echo ' <device dev_id="1" mapped_blocks="0" transaction="0" creation_time="0" snap_time="0">'
+ echo ' </device>'
+ echo ' <device dev_id="2" mapped_blocks="0" transaction="0" creation_time="0" snap_time="0">'
+ echo ' </device>'
+ for i in $(seq 10 $1)
do
- echo ' <device dev_id="'$i'" mapped_blocks="37" transaction="0" creation_time="0" snap_time="1">'
- echo ' <range_mapping origin_begin="0" data_begin="0" length="37" time="0"/>'
+ echo ' <device dev_id="'$i'" mapped_blocks="30" transaction="0" creation_time="0" snap_time="0">'
+ echo ' <range_mapping origin_begin="0" data_begin="0" length="29" time="0"/>'
echo ' </device>'
+ set +x
done
echo "</superblock>"
+ set -x
}
test -n "$LVM_TEST_THIN_RESTORE_CMD" || LVM_TEST_THIN_RESTORE_CMD=$(which thin_restore) || skip
@@ -99,4 +105,41 @@ vgchange -ay $vg
pre=$(meta_percent_)
wait_for_change_ $pre
+lvchange -an $vg
+
+lvs -a $vg
+#
+fake_metadata_ 350 2 >data
+lvchange -ay $vg/$lv1
+"$LVM_TEST_THIN_RESTORE_CMD" -i data -o "$DM_DEV_DIR/mapper/$vg-$lv1"
+
+lvs -a $vg
+dmsetup table
+lvconvert -y --chunksize 64k --thinpool $vg/pool --poolmetadata $vg/$lv1
+lvchange -ay $vg/pool $vg/$lv1
+lvs -a $vg
+
+lvcreate -s -Ky -n $lv2 $vg/thin
+echo 2 >"$DM_DEV_DIR/mapper/$vg-$lv2"
+
+#lvchange -an $vg
+#lvconvert -y --chunksize 64k --thinpool $vg/pool --poolmetadata $vg/$lv1
+#lvchange -ay $vg/$lv1
+#thin_dump "$DM_DEV_DIR/mapper/$vg-$lv1"
+#exit
+
+# no more space for new thin LV
+#
+# TODO:
+# though maybe 'lvcreate' itself should initiate resize - if dmeventd is not 'fast' enough
+# deploying usage of threshold kernel module paramater would likely help as well
+# for now it stops here:
+not lvcreate -s -Ky -n $lv3 $vg/thin
+lvs -a $vg
+
+pre=$(meta_percent_)
+wait_for_change_ $pre
+
+lvs -a $vg
+
vgremove -f $vg
7 years, 11 months
master - tests: wait for initial sync
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=cf1c2da836223d...
Commit: cf1c2da836223de64daacd94f0fd40a96f6cd46f
Parent: c4cc5eabfe722daf88d19b60d58c616c31e57edd
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Tue Oct 13 11:21:40 2015 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Tue Oct 13 16:02:21 2015 +0200
tests: wait for initial sync
Raid should be in-sync ATM for any gaming.
---
test/shell/lvconvert-repair-raid-dmeventd.sh | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)
diff --git a/test/shell/lvconvert-repair-raid-dmeventd.sh b/test/shell/lvconvert-repair-raid-dmeventd.sh
index df55449..a5a7a53 100644
--- a/test/shell/lvconvert-repair-raid-dmeventd.sh
+++ b/test/shell/lvconvert-repair-raid-dmeventd.sh
@@ -23,6 +23,7 @@ lvcreate -aey --type raid1 -m 3 --ignoremonitoring -L 1 -n 4way $vg
lvchange --monitor y $vg/4way
lvs -a -o all,lv_modules $vg
lvdisplay --maps $vg
+aux wait_for_sync $vg 4way
aux disable_dev "$dev2" "$dev4"
mkfs.ext3 "$DM_DEV_DIR/$vg/4way"
sleep 10 # FIXME: need a "poll" utility, akin to "check"
7 years, 11 months