master - gcc: replace #ifdef linux with __linux__
by Alasdair Kergon
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=527db4645fdbf1...
Commit: 527db4645fdbf10361797c871b9cadf6c5e73405
Parent: d8085edf65006a50608edb821b3d30947abaa838
Author: Alasdair G Kergon <agk(a)redhat.com>
AuthorDate: Wed Nov 13 13:56:29 2013 +0000
Committer: Alasdair G Kergon <agk(a)redhat.com>
CommitterDate: Wed Nov 13 13:56:29 2013 +0000
gcc: replace #ifdef linux with __linux__
---
WHATS_NEW | 1 +
daemons/dmeventd/dmeventd.c | 10 +++++-----
daemons/dmeventd/plugins/thin/dmeventd_thin.c | 2 +-
lib/activate/activate.c | 4 ++--
lib/commands/toolcontext.c | 2 +-
lib/device/dev-io.c | 2 +-
lib/device/dev-md.c | 2 +-
lib/device/dev-swap.c | 2 +-
lib/device/dev-type.c | 2 +-
lib/device/dev-type.h | 2 +-
lib/filters/filter-md.c | 2 +-
lib/filters/filter-mpath.c | 2 +-
lib/filters/filter-sysfs.c | 2 +-
lib/mm/xlate.h | 2 +-
libdaemon/server/daemon-server.c | 8 ++++----
libdm/ioctl/libdm-iface.c | 2 +-
libdm/libdm-common.c | 4 ++--
libdm/misc/dm-ioctl.h | 2 +-
tools/dmsetup.c | 2 +-
19 files changed, 28 insertions(+), 27 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index af1a26a..ff6041d 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -18,6 +18,7 @@ Version 2.02.104 -
Remove 2>/dev/null from three lvm commands executed by vgimportclone.
Add configure --enable-udev-systemd-background-jobs.
Add lvm2-pvscan@.service to run pvscan as a service for lvmetad/autoactivation.
+ Use #ifdef __linux__ instead of linux throughout.
Fix lvconvert swap of poolmetadata volume for active thin pool.
Check for open count with a timeout before removal/deactivation of an LV.
Report RAID images split with tracking as out-of-sync ("I").
diff --git a/daemons/dmeventd/dmeventd.c b/daemons/dmeventd/dmeventd.c
index 3754714..bdaf552 100644
--- a/daemons/dmeventd/dmeventd.c
+++ b/daemons/dmeventd/dmeventd.c
@@ -39,7 +39,7 @@
#include <arpa/inet.h> /* for htonl, ntohl */
#include <fcntl.h> /* for musl libc */
-#ifdef linux
+#ifdef __linux__
/*
* Kernel version 2.6.36 and higher has
* new OOM killer adjustment interface.
@@ -1619,7 +1619,7 @@ static void _exit_handler(int sig __attribute__((unused)))
_exit_now = 1;
}
-#ifdef linux
+#ifdef __linux__
static int _set_oom_adj(const char *oom_adj_path, int val)
{
FILE *fp;
@@ -1810,7 +1810,7 @@ static void _daemonize(void)
fd = rlim.rlim_cur;
for (--fd; fd >= 0; fd--) {
-#ifdef linux
+#ifdef __linux__
/* Do not close fds preloaded by systemd! */
if (_systemd_activation &&
(fd == SD_FD_FIFO_SERVER || fd == SD_FD_FIFO_CLIENT))
@@ -1963,7 +1963,7 @@ int main(int argc, char *argv[])
if (_restart)
restart();
-#ifdef linux
+#ifdef __linux__
_systemd_activation = _systemd_handover(&fifos);
#endif
@@ -1985,7 +1985,7 @@ int main(int argc, char *argv[])
signal(SIGHUP, &_exit_handler);
signal(SIGQUIT, &_exit_handler);
-#ifdef linux
+#ifdef __linux__
/* Systemd has adjusted oom killer for us already */
if (!_systemd_activation && !_protect_against_oom_killer())
syslog(LOG_ERR, "Failed to protect against OOM killer");
diff --git a/daemons/dmeventd/plugins/thin/dmeventd_thin.c b/daemons/dmeventd/plugins/thin/dmeventd_thin.c
index 8b173f1..3126bfa 100644
--- a/daemons/dmeventd/plugins/thin/dmeventd_thin.c
+++ b/daemons/dmeventd/plugins/thin/dmeventd_thin.c
@@ -44,7 +44,7 @@ struct dso_state {
/* TODO - move this mountinfo code into library to be reusable */
-#ifdef linux
+#ifdef __linux__
# include "kdev_t.h"
#else
# define MAJOR(x) major((x))
diff --git a/lib/activate/activate.c b/lib/activate/activate.c
index 7e6a5ac..0597409 100644
--- a/lib/activate/activate.c
+++ b/lib/activate/activate.c
@@ -910,8 +910,8 @@ int lv_raid_message(const struct logical_volume *lv, const char *msg)
if (lv_is_thin_pool(lv) &&
(lv_is_raid(seg_lv(first_seg(lv), 0)) ||
lv_is_raid(first_seg(lv)->metadata_lv))) {
- log_error("Thinpool data or metadata volume"
- " must be specified. (e.g. \"%s/%s_tdata\")",
+ log_error("Thin pool data or metadata volume "
+ "must be specified. (E.g. \"%s/%s_tdata\")",
lv->vg->name, lv->name);
return 0;
}
diff --git a/lib/commands/toolcontext.c b/lib/commands/toolcontext.c
index 3ed359d..d13d8d5 100644
--- a/lib/commands/toolcontext.c
+++ b/lib/commands/toolcontext.c
@@ -49,7 +49,7 @@
#include <syslog.h>
#include <time.h>
-#ifdef linux
+#ifdef __linux__
# include <malloc.h>
#endif
diff --git a/lib/device/dev-io.c b/lib/device/dev-io.c
index 34e3064..6c8613c 100644
--- a/lib/device/dev-io.c
+++ b/lib/device/dev-io.c
@@ -27,7 +27,7 @@
#include <unistd.h>
#include <sys/ioctl.h>
-#ifdef linux
+#ifdef __linux__
# define u64 uint64_t /* Missing without __KERNEL__ */
# undef WNOHANG /* Avoid redefinition */
# undef WUNTRACED /* Avoid redefinition */
diff --git a/lib/device/dev-md.c b/lib/device/dev-md.c
index a8bbe81..9af8074 100644
--- a/lib/device/dev-md.c
+++ b/lib/device/dev-md.c
@@ -18,7 +18,7 @@
#include "metadata.h"
#include "xlate.h"
-#ifdef linux
+#ifdef __linux__
/* Lifted from <linux/raid/md_p.h> because of difficulty including it */
diff --git a/lib/device/dev-swap.c b/lib/device/dev-swap.c
index 6faa810..cc44008 100644
--- a/lib/device/dev-swap.c
+++ b/lib/device/dev-swap.c
@@ -15,7 +15,7 @@
#include "lib.h"
#include "dev-type.h"
-#ifdef linux
+#ifdef __linux__
#define MAX_PAGESIZE (64 * 1024)
#define SIGNATURE_SIZE 10
diff --git a/lib/device/dev-type.c b/lib/device/dev-type.c
index 11f0407..a98cf45 100644
--- a/lib/device/dev-type.c
+++ b/lib/device/dev-type.c
@@ -443,7 +443,7 @@ out:
return ret;
}
-#ifdef linux
+#ifdef __linux__
static unsigned long _dev_topology_attribute(struct dev_types *dt,
const char *attribute,
diff --git a/lib/device/dev-type.h b/lib/device/dev-type.h
index 1227ab0..2fa32db 100644
--- a/lib/device/dev-type.h
+++ b/lib/device/dev-type.h
@@ -19,7 +19,7 @@
#define NUMBER_OF_MAJORS 4096
-#ifdef linux
+#ifdef __linux__
# define MAJOR(dev) ((dev & 0xfff00) >> 8)
# define MINOR(dev) ((dev & 0xff) | ((dev >> 12) & 0xfff00))
# define MKDEV(ma,mi) ((mi & 0xff) | (ma << 8) | ((mi & ~0xff) << 12))
diff --git a/lib/filters/filter-md.c b/lib/filters/filter-md.c
index 0089f93..fe79f3d 100644
--- a/lib/filters/filter-md.c
+++ b/lib/filters/filter-md.c
@@ -16,7 +16,7 @@
#include "lib.h"
#include "filter.h"
-#ifdef linux
+#ifdef __linux__
static int _ignore_md(struct dev_filter *f __attribute__((unused)),
struct device *dev)
diff --git a/lib/filters/filter-mpath.c b/lib/filters/filter-mpath.c
index a9881fd..10106f0 100644
--- a/lib/filters/filter-mpath.c
+++ b/lib/filters/filter-mpath.c
@@ -16,7 +16,7 @@
#include "filter.h"
#include "activate.h"
-#ifdef linux
+#ifdef __linux__
#include <dirent.h>
diff --git a/lib/filters/filter-sysfs.c b/lib/filters/filter-sysfs.c
index e03beca..af3ed07 100644
--- a/lib/filters/filter-sysfs.c
+++ b/lib/filters/filter-sysfs.c
@@ -15,7 +15,7 @@
#include "lib.h"
#include "filter.h"
-#ifdef linux
+#ifdef __linux__
#include <dirent.h>
diff --git a/lib/mm/xlate.h b/lib/mm/xlate.h
index 57d7241..0d243c4 100644
--- a/lib/mm/xlate.h
+++ b/lib/mm/xlate.h
@@ -16,7 +16,7 @@
#ifndef _LVM_XLATE_H
#define _LVM_XLATE_H
-#ifdef linux
+#ifdef __linux__
# include <endian.h>
# include <byteswap.h>
#else
diff --git a/libdaemon/server/daemon-server.c b/libdaemon/server/daemon-server.c
index b114b9f..156925a 100644
--- a/libdaemon/server/daemon-server.c
+++ b/libdaemon/server/daemon-server.c
@@ -54,7 +54,7 @@ static void _exit_handler(int sig __attribute__((unused)))
#define EXIT_ALREADYRUNNING 13
-#ifdef linux
+#ifdef __linux__
#include <stddef.h>
@@ -318,7 +318,7 @@ static void _daemonise(daemon_state s)
fd = rlim.rlim_cur;
for (--fd; fd >= 0; fd--) {
-#ifdef linux
+#ifdef __linux__
/* Do not close fds preloaded by systemd! */
if (_systemd_activation && fd == SD_FD_SOCKET_SERVER)
continue;
@@ -469,7 +469,7 @@ void daemon_start(daemon_state s)
if (setenv("LC_ALL", "C", 1))
perror("Cannot set LC_ALL to C");
-#ifdef linux
+#ifdef __linux__
_systemd_activation = _systemd_handover(&s);
#endif
@@ -504,7 +504,7 @@ void daemon_start(daemon_state s)
signal(SIGALRM, &_exit_handler);
signal(SIGPIPE, SIG_IGN);
-#ifdef linux
+#ifdef __linux__
/* Systemd has adjusted oom killer for us already */
if (s.avoid_oom && !_systemd_activation && !_protect_against_oom_killer())
ERROR(&s, "Failed to protect against OOM killer");
diff --git a/libdm/ioctl/libdm-iface.c b/libdm/ioctl/libdm-iface.c
index c530bb7..7b1fead 100644
--- a/libdm/ioctl/libdm-iface.c
+++ b/libdm/ioctl/libdm-iface.c
@@ -23,7 +23,7 @@
#include <sys/utsname.h>
#include <limits.h>
-#ifdef linux
+#ifdef __linux__
# include "kdev_t.h"
# include <linux/limits.h>
#else
diff --git a/libdm/libdm-common.c b/libdm/libdm-common.c
index 9a52f2e..febcd0e 100644
--- a/libdm/libdm-common.c
+++ b/libdm/libdm-common.c
@@ -32,7 +32,7 @@
# include <libudev.h>
#endif
-#ifdef linux
+#ifdef __linux__
# include <linux/fs.h>
#endif
@@ -1069,7 +1069,7 @@ static int _rename_dev_node(const char *old_name, const char *new_name,
return 1;
}
-#ifdef linux
+#ifdef __linux__
static int _open_dev_node(const char *dev_name)
{
int fd = -1;
diff --git a/libdm/misc/dm-ioctl.h b/libdm/misc/dm-ioctl.h
index dae2bcb..76316b0 100644
--- a/libdm/misc/dm-ioctl.h
+++ b/libdm/misc/dm-ioctl.h
@@ -8,7 +8,7 @@
#ifndef _LINUX_DM_IOCTL_V4_H
#define _LINUX_DM_IOCTL_V4_H
-#ifdef linux
+#ifdef __linux__
# include <linux/types.h>
#endif
diff --git a/tools/dmsetup.c b/tools/dmsetup.c
index e25d109..4433571 100644
--- a/tools/dmsetup.c
+++ b/tools/dmsetup.c
@@ -84,7 +84,7 @@ extern char *optarg;
__result; }))
#endif
-#ifdef linux
+#ifdef __linux__
# include "kdev_t.h"
#else
# define MAJOR(x) major((x))
10 years
master - pvscan: retry VG refresh before autoactivation if it fails
by Peter Rajnoha
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=d8085edf65006a...
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;
}
10 years
master - mirror: Handle failures in tmp mirror used when up-converting.
by Jonathan Brassow
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=7de533ad12972f...
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);
10 years
master - corosync: fix some gcc warnings
by Peter Rajnoha
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=b6b5299d1e1f6b...
Commit: b6b5299d1e1f6bdddb9bda30c4f37aaccbe3df44
Parent: fc144a3fc5389db11c3c34c9c240a763cc850cc7
Author: Peter Rajnoha <prajnoha(a)redhat.com>
AuthorDate: Wed Nov 6 14:55:18 2013 +0100
Committer: Peter Rajnoha <prajnoha(a)redhat.com>
CommitterDate: Wed Nov 6 14:55:18 2013 +0100
corosync: fix some gcc warnings
warning: function declaration isn't a prototype [-Wstrict-prototypes]
warning: old-style function definition [-Wold-style-definition]
---
daemons/clvmd/clvmd-corosync.c | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/daemons/clvmd/clvmd-corosync.c b/daemons/clvmd/clvmd-corosync.c
index 9092c8a..e68cb73 100644
--- a/daemons/clvmd/clvmd-corosync.c
+++ b/daemons/clvmd/clvmd-corosync.c
@@ -388,7 +388,7 @@ static int _name_from_csid(const char *csid, char *name)
return 0;
}
-static int _get_num_nodes()
+static int _get_num_nodes(void)
{
DEBUGLOG("num_nodes = %d\n", num_nodes);
return num_nodes;
@@ -505,7 +505,7 @@ static int _unlock_resource(const char *resource, int lockid)
return 0;
}
-static int _is_quorate()
+static int _is_quorate(void)
{
int quorate;
if (quorum_getquorate(quorum_handle, &quorate) == CS_OK)
10 years, 1 month
master - profile: add thin_pool_chunk_size_policy to default.profile
by Peter Rajnoha
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=fc144a3fc5389d...
Commit: fc144a3fc5389db11c3c34c9c240a763cc850cc7
Parent: 14b852609b20e57c3b2dede0641d31155232b946
Author: Peter Rajnoha <prajnoha(a)redhat.com>
AuthorDate: Wed Nov 6 13:29:25 2013 +0100
Committer: Peter Rajnoha <prajnoha(a)redhat.com>
CommitterDate: Wed Nov 6 13:29:25 2013 +0100
profile: add thin_pool_chunk_size_policy to default.profile
By default, thin_pool_chunk_size_policy is set to "generic".
---
conf/default.profile.in | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)
diff --git a/conf/default.profile.in b/conf/default.profile.in
index 6a0b8f1..29049ef 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 {
+ thin_pool_chunk_size_policy = "generic"
thin_pool_chunk_size = 64
thin_pool_discards = "passdown"
thin_pool_zero = 1
10 years, 1 month
master - tests: testing thin lvchange
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=14b852609b20e5...
Commit: 14b852609b20e57c3b2dede0641d31155232b946
Parent: 52f41baedba31335cd16d7767df26378f43c4626
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Fri Nov 1 12:55:41 2013 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Fri Nov 1 13:05:05 2013 +0100
tests: testing thin lvchange
Test various thin change operation,
including activation logic - which is somewhat
limited with singlenode emulation.
More tests needs to be added.
---
test/shell/lvchange-thin.sh | 131 +++++++++++++++++++++++++++++++++++++++++++
1 files changed, 131 insertions(+), 0 deletions(-)
diff --git a/test/shell/lvchange-thin.sh b/test/shell/lvchange-thin.sh
new file mode 100644
index 0000000..0b4c15d
--- /dev/null
+++ b/test/shell/lvchange-thin.sh
@@ -0,0 +1,131 @@
+#!/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 have_thin 1 0 0 || skip
+
+aux prepare_pvs 3
+
+vgcreate -s 128k $vg "$dev1" "$dev2"
+vgcreate -s 128k $vg2 "$dev3"
+
+lvcreate -V10M -L10M -T $vg/pool -n $lv1
+lvcreate -L10M -n $lv2 $vg
+
+lvchange -an $vg/$lv1
+
+# Test activation
+lvchange -aly $vg/$lv1
+check active $vg $lv1
+
+lvchange -aln $vg/$lv1
+check inactive $vg $lv1
+
+# Test for allowable changes
+#
+# contiguous_ARG
+lvchange -C y $vg/$lv1
+lvchange -C n $vg/$lv1
+
+# permission_ARG
+lvchange -p r $vg/$lv1
+lvchange -p rw $vg/$lv1
+
+# FIXME
+#should lvchange -p r $vg/pool
+#should lvchange -p rw $vg/pool
+
+# readahead_ARG
+lvchange -r none $vg/$lv1
+lvchange -r auto $vg/$lv1
+# FIXME
+# Think about more support
+
+# minor_ARG
+lvchange --yes -M y --minor 234 --major 253 $vg/$lv1
+lvchange -M n $vg/$lv1
+
+lvchange --yes -M y --minor 235 --major 253 $vg/pool
+lvchange -M n $vg/pool
+
+# addtag_ARG
+lvchange --addtag foo $vg/$lv1
+lvchange --addtag foo $vg/pool
+
+# deltag_ARG
+lvchange --deltag foo $vg/$lv1
+lvchange --deltag foo $vg/pool
+
+# discards_ARG
+lvchange --discards nopassdown $vg/pool
+lvchange --discards passdown $vg/pool
+
+# zero_ARG
+lvchange --zero n $vg/pool
+lvchange --zero y $vg/pool
+
+#
+# Test for disallowed metadata changes
+#
+# resync_ARG
+not lvchange --resync $vg/$lv1
+
+# alloc_ARG
+#not lvchange --alloc anywhere $vg/$lv1
+
+# discards_ARG
+not lvchange --discards ignore $vg/$lv1
+
+# zero_ARG
+not lvchange --zero y $vg/$lv1
+
+
+#
+# Ensure that allowed args don't cause disallowed args to get through
+#
+not lvchange --resync -ay $vg/$lv1
+not lvchange --resync --addtag foo $vg/$lv1
+
+#
+# Play with tags and activation
+#
+TAG=$(hostname)
+aux lvmconf 'activation/volume_list = [ "$vg/$lv2", "@mytag", "$vg2" ]'
+
+lvchange -ay $vg/$lv1
+check inactive $vg $lv1
+
+lvchange --addtag mytag $vg/$lv1
+
+lvchange -ay @mytag_fake
+check inactive $vg $lv1
+
+lvchange -ay $vg/$lv1
+# Volume has matching tag
+check active $vg $lv1
+lvchange -an $vg/$lv1
+
+lvchange -ay @mytag
+check active $vg $lv1
+
+# Fails here since it cannot clear device header
+not lvcreate -Zy -L10 -n $lv3 $vg2
+# OK when zeroing is disabled
+lvcreate -Zn -L10 -n $lv3 $vg2
+check inactive $vg2 $lv3
+
+aux lvmconf 'activation/volume_list = [ "$vg2" ]'
+vgchange -an $vg
+vgchange -ay $vg $vg2
+lvs -a -o+lv_active $vg $vg2
+
+vgremove -ff $vg $vg2
10 years, 1 month
master - dmsetup: report error on stderr
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=52f41baedba313...
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;
}
10 years, 1 month
master - activation: improve activation
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=9f6209b878fb5b...
Commit: 9f6209b878fb5b33dae5bc52a7ea47a9de9ff900
Parent: c3e674ad3010d21dc2cbde27b7634f7ea4fe67e3
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Fri Nov 1 10:31:31 2013 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Fri Nov 1 13:03:50 2013 +0100
activation: improve activation
This patch fixes mostly cluster behavior but also updates
non-cluster reaction where calls like 'lvchange -aln'
lead to incorrect errors for some segment types.
Fix the implicit activation rules where some segment types could
be activated only in exclusive mode in cluster.
lvm2 command was not preserver 'local' property and incorrectly
converted local activations in to plain exclusive, so the local
activation could have activate volumes exclusively, but remotely.
---
WHATS_NEW | 1 +
lib/metadata/lv.c | 63 ++++++++++++++++++++++++++++++++---------------
lib/metadata/lv_manip.c | 10 +++----
3 files changed, 48 insertions(+), 26 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index ff8da1d..f0a764b 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.104 -
===================================
+ 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.
Fix missing lvmetad scan for PVs found on MD partitions.
diff --git a/lib/metadata/lv.c b/lib/metadata/lv.c
index e59bd8e..c1f6271 100644
--- a/lib/metadata/lv.c
+++ b/lib/metadata/lv.c
@@ -735,39 +735,62 @@ char *lv_host_dup(struct dm_pool *mem, const struct logical_volume *lv)
return dm_pool_strdup(mem, lv->hostname ? : "");
}
+static int _lv_is_exclusive(struct logical_volume *lv)
+{
+ /* Some devices require exlusivness */
+ return seg_is_raid(first_seg(lv)) ||
+ lv_is_origin(lv) ||
+ lv_is_thin_type(lv);
+}
+
int lv_active_change(struct cmd_context *cmd, struct logical_volume *lv,
enum activation_change activate)
{
- if (activate == CHANGE_AN) {
+ switch (activate) {
+ case CHANGE_AN:
+deactivate:
log_verbose("Deactivating logical volume \"%s\"", lv->name);
if (!deactivate_lv(cmd, lv))
return_0;
- } else if ((activate == CHANGE_AE) ||
- seg_is_raid(first_seg(lv)) ||
- lv_is_origin(lv) ||
- lv_is_thin_type(lv)) {
- if (activate == CHANGE_ALN) {
- /* origin, thin or RAID - all others have _AE */
- /* other types of activation are implicitly exclusive */
- /* Note: the order of tests is mandatory */
- log_error("Cannot deactivate \"%s\" locally.", lv->name);
- return 0;
+ break;
+ case CHANGE_ALN:
+ if (_lv_is_exclusive(lv)) {
+ if (!lv_is_active_locally(lv)) {
+ log_error("Cannot deactivate remotely exclusive device locally.");
+ return 0;
+ }
+ /* Unlock whole exclusive activation */
+ goto deactivate;
}
- log_verbose("Activating logical volume \"%s\" exclusively.",
- lv->name);
- if (!activate_lv_excl(cmd, lv))
- return_0;
- } else if (activate == CHANGE_ALN) {
log_verbose("Deactivating logical volume \"%s\" locally.",
lv->name);
if (!deactivate_lv_local(cmd, lv))
return_0;
- } else if ((activate == CHANGE_ALY) || (activate == CHANGE_AAY)) {
- log_verbose("Activating logical volume \"%s\" locally.",
+ break;
+ case CHANGE_ALY:
+ case CHANGE_AAY:
+ if (_lv_is_exclusive(lv)) {
+ log_verbose("Activating logical volume \"%s\" exclusively locally.",
+ lv->name);
+ if (!activate_lv_excl_local(cmd, lv))
+ return_0;
+ } else {
+ log_verbose("Activating logical volume \"%s\" locally.",
+ lv->name);
+ if (!activate_lv_local(cmd, lv))
+ return_0;
+ }
+ break;
+ case CHANGE_AE:
+exclusive:
+ log_verbose("Activating logical volume \"%s\" exclusively.",
lv->name);
- if (!activate_lv_local(cmd, lv))
+ if (!activate_lv_excl(cmd, lv))
return_0;
- } else { /* CHANGE_AY */
+ break;
+ default: /* CHANGE_AY */
+ if (_lv_is_exclusive(lv))
+ goto exclusive;
log_verbose("Activating logical volume \"%s\".", lv->name);
if (!activate_lv(cmd, lv))
return_0;
diff --git a/lib/metadata/lv_manip.c b/lib/metadata/lv_manip.c
index 020b365..4a224e4 100644
--- a/lib/metadata/lv_manip.c
+++ b/lib/metadata/lv_manip.c
@@ -2892,8 +2892,8 @@ static int _lv_extend_layered_lv(struct alloc_handle *ah,
continue;
}
- /* For clearing, simply activate exclusive locally */
- if (!activate_lv_excl_local(meta_lv->vg->cmd, meta_lv)) {
+ /* For clearing, simply activate locally */
+ if (!activate_lv_local(meta_lv->vg->cmd, meta_lv)) {
log_error("Failed to activate %s/%s for clearing",
meta_lv->vg->name, meta_lv->name);
return 0;
@@ -6046,7 +6046,7 @@ static struct logical_volume *_lv_create_an_lv(struct volume_group *vg,
stack;
goto revert_new_lv;
}
- if (!activate_lv_excl(cmd, lv)) {
+ if (!lv_active_change(cmd, lv, lp->activate)) {
log_error("Failed to activate thin %s.", lv->name);
goto deactivate_and_revert_new_lv;
}
@@ -6057,9 +6057,7 @@ static struct logical_volume *_lv_create_an_lv(struct volume_group *vg,
"exception store.");
goto revert_new_lv;
}
- } else if ((lp->activate == CHANGE_AY && !activate_lv(cmd, lv)) ||
- (lp->activate == CHANGE_AE && !activate_lv_excl(cmd, lv)) ||
- (lp->activate == CHANGE_ALY && !activate_lv_local(cmd, lv))) {
+ } else if (!lv_active_change(cmd, lv, lp->activate)) {
log_error("Failed to activate new LV.");
if (lp->zero)
goto deactivate_and_revert_new_lv;
10 years, 1 month
master - activation: _lv_activate is ok when filtered.
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=c3e674ad3010d2...
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
10 years, 1 month
master - locking: activate_lv_excl return correct error code
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=1bde9f68cea61c...
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 */
10 years, 1 month