lvm2: update to 2.02.99.

This commit is contained in:
Juan RP 2013-08-13 08:51:24 +02:00
parent 96c41bd0a2
commit c612d662c9
31 changed files with 4 additions and 5425 deletions

View File

@ -1,252 +0,0 @@
commit 03ed86585e1bfbaf5df1e3488b6268b8887ca427
Author: Peter Rajnoha <prajnoha@redhat.com>
Date: Tue May 14 11:17:52 2013 +0200
lvm2-2_02_99-add-dm-disable-udev-env-var-and-fix-noudevsync-arg.patch
---
WHATS_NEW | 2 ++
WHATS_NEW_DM | 1 +
lib/commands/toolcontext.c | 62 ++++++++++++++++++++++++++++++++++------------
libdm/libdm-common.c | 43 ++++++++++++++++++++++++++------
tools/lvmcmdline.c | 4 +--
5 files changed, 86 insertions(+), 26 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index 1bdfeb0..8516f40 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,7 @@
Version 2.02.99 -
===================================
+ Recognize DM_DISABLE_UDEV environment variable for a complete fallback.
+ Do not verify udev operations if --noudevsync command option is used.
Fix blkdeactivate to handle nested mountpoints and mangled mount paths.
Fix a crash-inducing race condition in lvmetad while updating metadata.
Fix possible race while removing metadata from lvmetad.
diff --git a/WHATS_NEW_DM b/WHATS_NEW_DM
index e0b8d51..9574fdf 100644
--- a/WHATS_NEW_DM
+++ b/WHATS_NEW_DM
@@ -1,5 +1,6 @@
Version 1.02.78 -
===================================
+ Add DM_DISABLE_UDEV environment variable to manage dev nodes by libdm only.
Automatically deactivate failed preloaded dm tree node.
Fix dm_task_set_cookie to properly process udev flags if udev_sync disabled.
diff --git a/lib/commands/toolcontext.c b/lib/commands/toolcontext.c
index eb1a90b..80d0f3e 100644
--- a/lib/commands/toolcontext.c
+++ b/lib/commands/toolcontext.c
@@ -211,6 +211,21 @@ static void _init_logging(struct cmd_context *cmd)
reset_lvm_errno(1);
}
+static int _check_disable_udev(const char *msg) {
+ if (getenv("DM_DISABLE_UDEV")) {
+ log_very_verbose("DM_DISABLE_UDEV environment variable set. "
+ "Overriding configuration to use "
+ "udev_rules=0, udev_sync=0, verify_udev_operations=1.");
+ if (udev_is_running())
+ log_warn("Udev is running and DM_DISABLE_UDEV environment variable is set. "
+ "Bypassing udev, LVM will %s.", msg);
+
+ return 1;
+ }
+
+ return 0;
+}
+
#ifdef UDEV_SYNC_SUPPORT
/*
* Until the DM_UEVENT_GENERATED_FLAG was introduced in kernel patch
@@ -237,6 +252,7 @@ static int _process_config(struct cmd_context *cmd)
const struct dm_config_value *cv;
int64_t pv_min_kb;
const char *lvmetad_socket;
+ int udev_disabled = 0;
/* umask */
cmd->default_settings.umask = find_config_tree_int(cmd,
@@ -310,13 +326,20 @@ static int _process_config(struct cmd_context *cmd)
return 0;
}
- cmd->default_settings.udev_rules = find_config_tree_int(cmd,
- "activation/udev_rules",
- DEFAULT_UDEV_RULES);
+ /*
+ * If udev is disabled using DM_DISABLE_UDEV environment
+ * variable, override existing config and hardcode these:
+ * - udev_rules = 0
+ * - udev_sync = 0
+ * - udev_fallback = 1
+ */
+ udev_disabled = _check_disable_udev("manage logical volume symlinks in device directory");
- cmd->default_settings.udev_sync = find_config_tree_int(cmd,
- "activation/udev_sync",
- DEFAULT_UDEV_SYNC);
+ cmd->default_settings.udev_rules = udev_disabled ? 0 :
+ find_config_tree_int(cmd, "activation/udev_rules", DEFAULT_UDEV_RULES);
+
+ cmd->default_settings.udev_sync = udev_disabled ? 0 :
+ find_config_tree_int(cmd, "activation/udev_sync", DEFAULT_UDEV_SYNC);
init_retry_deactivation(find_config_tree_int(cmd, "activation/retry_deactivation",
DEFAULT_RETRY_DEACTIVATION));
@@ -326,14 +349,12 @@ static int _process_config(struct cmd_context *cmd)
#ifdef UDEV_SYNC_SUPPORT
/*
- * We need udev rules to be applied, otherwise we would end up with no
- * nodes and symlinks! However, we can disable the synchronization itself
- * in runtime and still have only udev to create the nodes and symlinks
- * without any fallback.
+ * Use udev fallback automatically in case udev
+ * is disabled via DM_DISABLE_UDEV environment
+ * variable or udev rules are switched off.
*/
- cmd->default_settings.udev_fallback = cmd->default_settings.udev_rules ?
- find_config_tree_int(cmd, "activation/verify_udev_operations",
- DEFAULT_VERIFY_UDEV_OPERATIONS) : 1;
+ cmd->default_settings.udev_fallback = !cmd->default_settings.udev_rules || udev_disabled ? 1 :
+ find_config_tree_int(cmd, "activation/verify_udev_operations", DEFAULT_VERIFY_UDEV_OPERATIONS);
/* Do not rely fully on udev if the udev support is known to be incomplete. */
if (!cmd->default_settings.udev_fallback && !_dm_driver_has_stable_udev_support()) {
@@ -693,9 +714,18 @@ static int _init_dev_cache(struct cmd_context *cmd)
if (!dev_cache_init(cmd))
return_0;
- device_list_from_udev = udev_is_running() ?
- find_config_tree_bool(cmd, "devices/obtain_device_list_from_udev",
- DEFAULT_OBTAIN_DEVICE_LIST_FROM_UDEV) : 0;
+ /*
+ * Override existing config and hardcode device_list_from_udev = 0 if:
+ * - udev is not running
+ * - udev is disabled using DM_DISABLE_UDEV environment variable
+ */
+ if (_check_disable_udev("obtain device list by scanning device directory"))
+ device_list_from_udev = 0;
+ else
+ device_list_from_udev = udev_is_running() ?
+ find_config_tree_bool(cmd, "devices/obtain_device_list_from_udev",
+ DEFAULT_OBTAIN_DEVICE_LIST_FROM_UDEV) : 0;
+
init_obtain_device_list_from_udev(device_list_from_udev);
if (!(cn = find_config_tree_node(cmd, "devices/scan"))) {
diff --git a/libdm/libdm-common.c b/libdm/libdm-common.c
index afdac89..075fba8 100644
--- a/libdm/libdm-common.c
+++ b/libdm/libdm-common.c
@@ -74,6 +74,8 @@ static dm_string_mangling_t _name_mangling_mode = DEFAULT_DM_NAME_MANGLING;
static struct selabel_handle *_selabel_handle = NULL;
#endif
+static int _udev_disabled = 0;
+
#ifdef UDEV_SYNC_SUPPORT
static int _semaphore_supported = -1;
static int _udev_running = -1;
@@ -85,6 +87,9 @@ void dm_lib_init(void)
{
const char *env;
+ if ((env = getenv("DM_DISABLE_UDEV")))
+ _udev_disabled = 1;
+
env = getenv(DM_DEFAULT_NAME_MANGLING_MODE_ENV_VAR_NAME);
if (env && *env) {
if (!strcasecmp(env, "none"))
@@ -1814,6 +1819,26 @@ out:
return r;
}
+static void _set_cookie_flags(struct dm_task *dmt, uint16_t flags)
+{
+ if (!dm_cookie_supported())
+ return;
+
+ if (_udev_disabled) {
+ /*
+ * If udev is disabled, hardcode this functionality:
+ * - we want libdm to create the nodes
+ * - we don't want the /dev/mapper and any subsystem
+ * related content to be created by udev if udev
+ * rules are installed
+ */
+ flags &= ~DM_UDEV_DISABLE_LIBRARY_FALLBACK;
+ flags |= DM_UDEV_DISABLE_DM_RULES_FLAG | DM_UDEV_DISABLE_SUBSYSTEM_RULES_FLAG;
+ }
+
+ dmt->event_nr = flags << DM_UDEV_FLAGS_SHIFT;
+}
+
#ifndef UDEV_SYNC_SUPPORT
void dm_udev_set_sync_support(int sync_with_udev)
{
@@ -1835,8 +1860,8 @@ int dm_udev_get_checking(void)
int dm_task_set_cookie(struct dm_task *dmt, uint32_t *cookie, uint16_t flags)
{
- if (dm_cookie_supported())
- dmt->event_nr = flags << DM_UDEV_FLAGS_SHIFT;
+ _set_cookie_flags(dmt, flags);
+
*cookie = 0;
dmt->cookie_set = 1;
@@ -1908,8 +1933,13 @@ static void _check_udev_sync_requirements_once(void)
if (_semaphore_supported < 0)
_semaphore_supported = _check_semaphore_is_supported();
- if (_udev_running < 0)
+ if (_udev_running < 0) {
_udev_running = _check_udev_is_running();
+ if (_udev_disabled && _udev_running)
+ log_warn("Udev is running and DM_DISABLE_UDEV environment variable is set. "
+ "Bypassing udev, device-mapper library will manage device "
+ "nodes in device directory.");
+ }
}
void dm_udev_set_sync_support(int sync_with_udev)
@@ -1922,8 +1952,8 @@ int dm_udev_get_sync_support(void)
{
_check_udev_sync_requirements_once();
- return _semaphore_supported && dm_cookie_supported() &&
- _udev_running && _sync_with_udev;
+ return !_udev_disabled && _semaphore_supported &&
+ dm_cookie_supported() &&_udev_running && _sync_with_udev;
}
void dm_udev_set_checking(int checking)
@@ -2203,8 +2233,7 @@ int dm_task_set_cookie(struct dm_task *dmt, uint32_t *cookie, uint16_t flags)
{
int semid;
- if (dm_cookie_supported())
- dmt->event_nr = flags << DM_UDEV_FLAGS_SHIFT;
+ _set_cookie_flags(dmt, flags);
if (!dm_udev_get_sync_support()) {
*cookie = 0;
diff --git a/tools/lvmcmdline.c b/tools/lvmcmdline.c
index 39a8c58..652d57e 100644
--- a/tools/lvmcmdline.c
+++ b/tools/lvmcmdline.c
@@ -901,10 +901,8 @@ static int _get_settings(struct cmd_context *cmd)
} else
init_trust_cache(0);
- if (arg_count(cmd, noudevsync_ARG)) {
+ if (arg_count(cmd, noudevsync_ARG))
cmd->current_settings.udev_sync = 0;
- cmd->current_settings.udev_fallback = 1;
- }
/* Handle synonyms */
if (!_merge_synonym(cmd, resizable_ARG, resizeable_ARG) ||

View File

@ -1,73 +0,0 @@
commit 764195207d4773cf6f1674a2fb16e9a0acda304a
Author: Peter Rajnoha <prajnoha@redhat.com>
Date: Fri Apr 19 12:17:53 2013 +0200
udev: also autoactivate on coldplug
Commit 756bcabbfe297688ba240a880bc2b55265ad33f0 fixed autoactivation
to not trigger on each uevent for a PV that appeared in the system
most notably the events that are triggered artificially (udevadm
trigger or as the result of the WATCH udev rule being applied that
consequently generates CHANGE uevents). This fixed a situation in
which VGs/LVs were activated when they should not.
BUT we still need to care about the coldplug used at boot to
retrigger the ADD events - the "udevadm trigger --action=add"!
For non-DM-based PVs, this is already covered as for these we
run the autoactivation on ADD event only.
However, for DM-based PVs, we still need to run the
autoactivation even for the artificial ADD event, reusing
the udev DB content from previous proper CHANGE event that
came with the DM device activation.
Simply, this patch fixes a situation in which we run extra
"udevadm trigger --action=add" (or echo add > /sys/block/<dev>/uevent)
for DM-based PVs (cryptsetup devices, multipath devices, any
other DM devices...).
Without this patch, while using lvmetad + autoactivation,
any VG/LV that has a DM-based PV and for which we do not
call the activation directly, the VG/LV is not activated.
For example a VG with an LV with root FS on it which is directly
activated in initrd and then missing activation of the rest
of the LVs in the VG because of unhandled uevent retrigger on
boot after switching to root FS (the "coldplug").
(No WHATS_NEW here as this fixes the commit mentioned
above and which was not released yet.)
---
udev/10-dm.rules.in | 5 ++++-
udev/69-dm-lvm-metad.rules.in | 1 +
2 files changed, 5 insertions(+), 1 deletion(-)
diff --git a/udev/10-dm.rules.in b/udev/10-dm.rules.in
index cfee145..512d156 100644
--- a/udev/10-dm.rules.in
+++ b/udev/10-dm.rules.in
@@ -77,7 +77,10 @@ LABEL="dm_flags_done"
# before (e.g. in initrd). If udev is used in initrd, we require the udev init
# script to not remove the existing udev database so we can reuse the information
# stored at the time of device activation in the initrd.
-ACTION=="add", ENV{DM_UDEV_RULES_VSN}!="1", ENV{DM_UDEV_PRIMARY_SOURCE_FLAG}!="1", GOTO="dm_disable"
+ACTION!="add", GOTO="dm_no_coldplug"
+ENV{DM_UDEV_RULES_VSN}!="1", ENV{DM_UDEV_PRIMARY_SOURCE_FLAG}!="1", GOTO="dm_disable"
+ENV{DM_ACTIVATION}="1"
+LABEL="dm_no_coldplug"
# "dm" sysfs subdirectory is available in newer versions of DM
# only (kernels >= 2.6.29). We have to check for its existence
diff --git a/udev/69-dm-lvm-metad.rules.in b/udev/69-dm-lvm-metad.rules.in
index b16a27a..66c58b3 100644
--- a/udev/69-dm-lvm-metad.rules.in
+++ b/udev/69-dm-lvm-metad.rules.in
@@ -26,6 +26,7 @@ ACTION=="remove", GOTO="lvm_scan"
KERNEL!="dm-[0-9]*", ACTION!="add", GOTO="lvm_end"
# If the PV is a dm device, scan only after proper mapping activation (CHANGE event + DM_ACTIVATION=1)
+# or after a coldplug (event retrigger) with "add" event (ADD event + DM_ACTIVATION=1)
KERNEL=="dm-[0-9]*", ENV{DM_ACTIVATION}!="1", GOTO="lvm_end"
LABEL="lvm_scan"

View File

@ -1,34 +0,0 @@
commit 9cff3357bd69f15497af8c03774df07081d361dd
Author: Peter Rajnoha <prajnoha@redhat.com>
Date: Tue May 14 11:04:08 2013 +0200
lvm2-2_02_99-avoid-global-lock-in-pvs-when-lvmetad-is-in-use.patch
---
WHATS_NEW | 1 +
tools/toollib.c | 2 +-
2 files changed, 2 insertions(+), 1 deletion(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index 62efb53..25e07ee 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.99 -
===================================
+ Avoid a global lock in pvs when lvmetad is in use.
Fix crash in pvscan --cache -aay triggered by non-mda PV.
Fix lvm2app to return all property sizes in bytes.
Add lvm.conf option global/thin_disabled_features.
diff --git a/tools/toollib.c b/tools/toollib.c
index 5fe94e0..dce42f4 100644
--- a/tools/toollib.c
+++ b/tools/toollib.c
@@ -701,7 +701,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 lock_global = !(flags & READ_WITHOUT_LOCK) && !(flags & READ_FOR_UPDATE);
+ int lock_global = !(flags & READ_WITHOUT_LOCK) && !(flags & READ_FOR_UPDATE) && !lvmetad_active();
struct pv_list *pvl;
struct physical_volume *pv;

View File

@ -1,109 +0,0 @@
commit b7e453f3821c4a896e00a29800351687d3365f64
Author: Peter Rajnoha <prajnoha@redhat.com>
Date: Tue May 14 11:26:40 2013 +0200
lvm2-2_02_99-close-dmeventd-fifo-fds-on-exec.patch
---
WHATS_NEW_DM | 1 +
daemons/dmeventd/dmeventd.c | 37 ++++++++++++++++++++++++++++---------
2 files changed, 29 insertions(+), 9 deletions(-)
diff --git a/WHATS_NEW_DM b/WHATS_NEW_DM
index 9574fdf..30d01f9 100644
--- a/WHATS_NEW_DM
+++ b/WHATS_NEW_DM
@@ -1,5 +1,6 @@
Version 1.02.78 -
===================================
+ Close open dmeventd FIFO file descriptors on exec (FD_CLOEXEC).
Add DM_DISABLE_UDEV environment variable to manage dev nodes by libdm only.
Automatically deactivate failed preloaded dm tree node.
Fix dm_task_set_cookie to properly process udev flags if udev_sync disabled.
diff --git a/daemons/dmeventd/dmeventd.c b/daemons/dmeventd/dmeventd.c
index 13148c3..5f2339f 100644
--- a/daemons/dmeventd/dmeventd.c
+++ b/daemons/dmeventd/dmeventd.c
@@ -1237,7 +1237,8 @@ static int _get_timeout(struct message_data *message_data)
/* Initialize a fifos structure with path names. */
static void _init_fifos(struct dm_event_fifos *fifos)
{
- memset(fifos, 0, sizeof(*fifos));
+ fifos->client = -1;
+ fifos->server = -1;
fifos->client_path = DM_EVENT_FIFO_CLIENT;
fifos->server_path = DM_EVENT_FIFO_SERVER;
@@ -1254,7 +1255,7 @@ static int _open_fifos(struct dm_event_fifos *fifos)
syslog(LOG_ERR, "%s: Failed to create client fifo %s: %m.\n",
__func__, fifos->client_path);
(void) dm_prepare_selinux_context(NULL, 0);
- return 0;
+ goto fail;
}
/* Create server fifo. */
@@ -1263,7 +1264,7 @@ static int _open_fifos(struct dm_event_fifos *fifos)
syslog(LOG_ERR, "%s: Failed to create server fifo %s: %m.\n",
__func__, fifos->server_path);
(void) dm_prepare_selinux_context(NULL, 0);
- return 0;
+ goto fail;
}
(void) dm_prepare_selinux_context(NULL, 0);
@@ -1281,31 +1282,49 @@ static int _open_fifos(struct dm_event_fifos *fifos)
if (chmod(fifos->client_path, 0600)) {
syslog(LOG_ERR, "Unable to set correct file permissions on %s: %m.\n",
fifos->client_path);
- return 0;
+ goto fail;
}
if (chmod(fifos->server_path, 0600)) {
syslog(LOG_ERR, "Unable to set correct file permissions on %s: %m.\n",
fifos->server_path);
- return 0;
+ goto fail;
}
/* Need to open read+write or we will block or fail */
if ((fifos->server = open(fifos->server_path, O_RDWR)) < 0) {
syslog(LOG_ERR, "Failed to open fifo server %s: %m.\n",
fifos->server_path);
- return 0;
+ goto fail;
+ }
+
+ if (fcntl(fifos->server, F_SETFD, FD_CLOEXEC) < 0) {
+ syslog(LOG_ERR, "Failed to set FD_CLOEXEC for fifo server %s: %m.\n",
+ fifos->server_path);
+ goto fail;
}
/* Need to open read+write for select() to work. */
if ((fifos->client = open(fifos->client_path, O_RDWR)) < 0) {
syslog(LOG_ERR, "Failed to open fifo client %s: %m", fifos->client_path);
- if (close(fifos->server))
- syslog(LOG_ERR, "Failed to close fifo server %s: %m", fifos->server_path);
- return 0;
+ goto fail;
+ }
+
+ if (fcntl(fifos->client, F_SETFD, FD_CLOEXEC) < 0) {
+ syslog(LOG_ERR, "Failed to set FD_CLOEXEC for fifo client %s: %m.\n",
+ fifos->client_path);
+ goto fail;
}
return 1;
+fail:
+ if (fifos->server >= 0 && close(fifos->server))
+ syslog(LOG_ERR, "Failed to close fifo server %s: %m", fifos->server_path);
+
+ if (fifos->client >= 0 && close(fifos->client))
+ syslog(LOG_ERR, "Failed to close fifo client %s: %m", fifos->client_path);
+
+ return 0;
}
/*

View File

@ -1,41 +0,0 @@
WHATS_NEW | 1 +
tools/pvscan.c | 15 +++++++++++++++
2 files changed, 16 insertions(+)
diff --git a/WHATS_NEW b/WHATS_NEW
index 12307ed..e247391 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.99 -
===================================
+ Exit pvscan --cache immediately if cluster locking used or lvmetad not used.
Don't use lvmetad in lvm2-monitor.service ExecStop to avoid a systemd issue.
Remove dependency on fedora-storage-init.service in lvm2 systemd units.
Depend on lvm2-lvmetad.socket in lvm2-monitor.service systemd unit.
diff --git a/tools/pvscan.c b/tools/pvscan.c
index 3d5ddef..34ab792 100644
--- a/tools/pvscan.c
+++ b/tools/pvscan.c
@@ -119,6 +119,21 @@ static int _pvscan_lvmetad(struct cmd_context *cmd, int argc, char **argv)
char *buf;
activation_handler handler = NULL;
+ /*
+ * Return here immediately if lvmetad is not used.
+ * Also return if locking_type=3 (clustered) as we
+ * dont't support cluster + lvmetad yet.
+ *
+ * This is to avoid taking the global lock uselessly
+ * and to prevent hangs in clustered environment.
+ */
+ /* TODO: Remove this once lvmetad + cluster supported! */
+ if (find_config_tree_int(cmd, "global/locking_type", 1) == 3 ||
+ !find_config_tree_int(cmd, "global/use_lvmetad", 0)) {
+ log_debug("_pvscan_lvmetad: immediate return");
+ return ret;
+ }
+
if (arg_count(cmd, activate_ARG)) {
if (arg_uint_value(cmd, activate_ARG, CHANGE_AAY) != CHANGE_AAY) {
log_error("Only --activate ay allowed with pvscan.");

View File

@ -1,50 +0,0 @@
commit 2ac217d408470dcecb69b83d9cbf7a254747fa5b
Author: Peter Rajnoha <prajnoha@redhat.com>
Date: Fri May 3 13:20:07 2013 +0200
udev: fire pvscan --cache properly on CHANGE event for MD devices
Commit 756bcabbfe297688ba240a880bc2b55265ad33f0 restricted the
situations at which the LVM autoactivation fires - only on ADD
event for devices other than DM. However, this caused a problem
for MD devices...
MD devices are activated in a very similar way as DM devices:
the MD dev is created on first appeareance of MD array member
(ADD event) and stays *inactive* until the array is complete.
Just then the MD dev turns to active state and this is reported
to userspace by CHANGE event.
Unfortunately, we can't differentiate between the CHANGE event
coming from udev trigger/WATCH rule and CHANGE event coming from
the transition to active state - MD would need to add similar logic
we already use to detect this in DM world. For now, we just have
to enable pvscan --cache on *all* CHANGE events for MD so the
autoactivation of the LVM volumes on top of MD works.
A downside of this is that a spurious CHANGE event for MD dev
can cause the LVM volumes on top of it to be automatically activated.
However, one should not open/change the device underneath until
the device above in the stack is removed! So this situation should
only happen if one opens the MD dev for read-write by mistake
(and hence firing the CHANGE event because of the WATCH udev rule),
or if calling udev trigger manually for the MD dev.
(No WHATS_NEW here as this fixes the commit mentioned
above and which has not been released yet.)
---
udev/69-dm-lvm-metad.rules.in | 1 +
1 file changed, 1 insertion(+)
diff --git a/udev/69-dm-lvm-metad.rules.in b/udev/69-dm-lvm-metad.rules.in
index 66c58b3..a0e48a1 100644
--- a/udev/69-dm-lvm-metad.rules.in
+++ b/udev/69-dm-lvm-metad.rules.in
@@ -21,6 +21,7 @@ SUBSYSTEM!="block", GOTO="lvm_end"
ENV{ID_FS_TYPE}!="LVM2_member|LVM1_member", GOTO="lvm_end"
ACTION=="remove", GOTO="lvm_scan"
+ACTION=="change", KERNEL=="md[0-9]*", GOTO="lvm_scan"
# If the PV is not a dm device, scan only after device addition (ADD event)
KERNEL!="dm-[0-9]*", ACTION!="add", GOTO="lvm_end"

View File

@ -1,62 +0,0 @@
commit 0bf7bdf5216eae93cff7abb47a76b39270d71413
Author: Peter Rajnoha <prajnoha@redhat.com>
Date: Tue Apr 9 10:07:15 2013 +0200
0
---
WHATS_NEW | 1 +
udev/10-dm.rules.in | 2 +-
udev/69-dm-lvm-metad.rules.in | 16 ++++++++++++----
3 files changed, 14 insertions(+), 5 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index 67a24c7..c481e68 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.99 -
===================================
+ Fix autoactivation to not autoactivate VG/LV on each change of the PVs used.
Skip mlocking [vectors] on arm architecture.
Exit pvscan --cache immediately if cluster locking used or lvmetad not used.
Don't use lvmetad in lvm2-monitor.service ExecStop to avoid a systemd issue.
diff --git a/udev/10-dm.rules.in b/udev/10-dm.rules.in
index 29af467..cfee145 100644
--- a/udev/10-dm.rules.in
+++ b/udev/10-dm.rules.in
@@ -45,7 +45,7 @@ ENV{DISK_RO}=="1", GOTO="dm_disable"
# in libdevmapper so we need to detect this and try to behave correctly.
# For such spurious events, regenerate all flags from current udev database content
# (this information would normally be inaccessible for spurious ADD and CHANGE events).
-ENV{DM_UDEV_PRIMARY_SOURCE_FLAG}=="1", GOTO="dm_flags_done"
+ENV{DM_UDEV_PRIMARY_SOURCE_FLAG}=="1", ENV{DM_ACTIVATION}="1", GOTO="dm_flags_done"
IMPORT{db}="DM_UDEV_DISABLE_DM_RULES_FLAG"
IMPORT{db}="DM_UDEV_DISABLE_SUBSYSTEM_RULES_FLAG"
IMPORT{db}="DM_UDEV_DISABLE_DISK_RULES_FLAG"
diff --git a/udev/69-dm-lvm-metad.rules.in b/udev/69-dm-lvm-metad.rules.in
index 706c03b..b16a27a 100644
--- a/udev/69-dm-lvm-metad.rules.in
+++ b/udev/69-dm-lvm-metad.rules.in
@@ -17,10 +17,18 @@
SUBSYSTEM!="block", GOTO="lvm_end"
(LVM_EXEC_RULE)
-# Device-mapper devices are processed only on change event or on supported synthesized event.
-KERNEL=="dm-[0-9]*", ENV{DM_UDEV_RULES_VSN}!="?*", GOTO="lvm_end"
-
# Only process devices already marked as a PV - this requires blkid to be called before.
-ENV{ID_FS_TYPE}=="LVM2_member|LVM1_member", RUN+="(LVM_EXEC)/lvm pvscan --cache --activate ay --major $major --minor $minor"
+ENV{ID_FS_TYPE}!="LVM2_member|LVM1_member", GOTO="lvm_end"
+
+ACTION=="remove", GOTO="lvm_scan"
+
+# If the PV is not a dm device, scan only after device addition (ADD event)
+KERNEL!="dm-[0-9]*", ACTION!="add", GOTO="lvm_end"
+
+# If the PV is a dm device, scan only after proper mapping activation (CHANGE event + DM_ACTIVATION=1)
+KERNEL=="dm-[0-9]*", ENV{DM_ACTIVATION}!="1", GOTO="lvm_end"
+
+LABEL="lvm_scan"
+RUN+="(LVM_EXEC)/lvm pvscan --cache --activate ay --major $major --minor $minor"
LABEL="lvm_end"

View File

@ -1,93 +0,0 @@
commit 5025178f95b122c6862dc7d925a7c089f5fb61a8
Author: Peter Rajnoha <prajnoha@redhat.com>
Date: Tue May 14 11:05:50 2013 +0200
lvm2-2_02_99-fix-blkdeactivate-handling-of-nested-mountpoints-and-mangled-mount-paths.patch
---
WHATS_NEW | 1 +
scripts/blkdeactivate.sh.in | 30 ++++++++++++++++++++++++------
2 files changed, 25 insertions(+), 6 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index 35c5e43..1bdfeb0 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.99 -
===================================
+ Fix blkdeactivate to handle nested mountpoints and mangled mount paths.
Fix a crash-inducing race condition in lvmetad while updating metadata.
Fix possible race while removing metadata from lvmetad.
Fix possible deadlock when querying and updating lvmetad at the same time.
diff --git a/scripts/blkdeactivate.sh.in b/scripts/blkdeactivate.sh.in
index 740bac5..be00c24 100644
--- a/scripts/blkdeactivate.sh.in
+++ b/scripts/blkdeactivate.sh.in
@@ -39,6 +39,7 @@ LVM="@sbindir@/lvm"
LSBLK="/bin/lsblk -r --noheadings -o TYPE,KNAME,NAME,MOUNTPOINT"
LSBLK_VARS="local devtype local kname local name local mnt"
LSBLK_READ="read -r devtype kname name mnt"
+SORT_MNT="/bin/sort -r -u -k 4"
# Do not unmount mounted devices by default.
DO_UMOUNT=0
@@ -122,9 +123,11 @@ is_top_level_device() {
device_umount () {
test -z "$mnt" && return 0;
+ test "$devtype" != "lvm" && test "${kname:0:3}" != "dm-" && return 0
+
if test -z "${SKIP_UMOUNT_LIST["$mnt"]}" -a "$DO_UMOUNT" -eq "1"; then
echo " UMOUNT: unmounting $name ($kname) mounted on $mnt"
- $UMOUNT "$mnt" || add_device_to_skip_list
+ $UMOUNT "$(printf $mnt)" || add_device_to_skip_list
else
echo " [SKIP]: unmount of $name ($kname) mounted on $mnt"
add_device_to_skip_list
@@ -142,9 +145,6 @@ deactivate_holders () {
# check if the device not on the skip list already
test -z ${SKIP_DEVICE_LIST["$kname"]} || return 1
- # try to unmount it if mounted
- device_umount || return 1
-
# try to deactivate the holder
test $skip -eq 1 && skip=0 && continue
deactivate || return 1
@@ -226,7 +226,16 @@ deactivate_all() {
echo "Deactivating block devices:"
if test $# -eq 0; then
- # Deactivate all devices
+ #######################
+ # Process all devices #
+ #######################
+
+ # Unmount all relevant mountpoints first
+ while $LSBLK_READ; do
+ device_umount
+ done <<< "`$LSBLK | $SORT_MNT`"
+
+ # Do deactivate
while $LSBLK_READ; do
# 'disk' is at the bottom already and it's a real device
test "$devtype" = "disk" && continue
@@ -249,8 +258,17 @@ deactivate_all() {
deactivate || skip=1
done <<< "`$LSBLK -s`"
else
- # Deactivate only specified devices
+ ##################################
+ # Process only specified devices #
+ ##################################
+
while test $# -ne 0; do
+ # Unmount all relevant mountpoints first
+ while $LSBLK_READ; do
+ device_umount
+ done <<< "`$LSBLK $1 | $SORT_MNT`"
+
+ # Do deactivate
# Single dm device tree deactivation.
if test -b "$1"; then
$LSBLK_READ <<< "`$LSBLK --nodeps $1`"

View File

@ -1,175 +0,0 @@
commit 5e247adf415942fcc0a5b888567f51a148619b65
Author: Peter Rajnoha <prajnoha@redhat.com>
Date: Tue May 14 11:03:46 2013 +0200
lvm2-2_02_99-fix-crash-in-pvscan-cache-aay-triggered-by-non-mda-pv.patch
---
WHATS_NEW | 1 +
lib/cache/lvmetad.c | 12 ++++------
lib/cache/lvmetad.h | 3 ++-
test/shell/lvmetad-pvscan-nomda.sh | 49 ++++++++++++++++++++++++++++++++++++++
tools/pvscan.c | 22 +++++++++++++++--
5 files changed, 76 insertions(+), 11 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index 5231745..62efb53 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.99 -
===================================
+ Fix crash in pvscan --cache -aay triggered by non-mda PV.
Fix lvm2app to return all property sizes in bytes.
Add lvm.conf option global/thin_disabled_features.
Add lvconvert support to swap thin pool metadata volume.
diff --git a/lib/cache/lvmetad.c b/lib/cache/lvmetad.c
index 72e07fd..a636f43 100644
--- a/lib/cache/lvmetad.c
+++ b/lib/cache/lvmetad.c
@@ -675,7 +675,7 @@ int lvmetad_pv_found(const struct id *pvid, struct device *device, const struct
daemon_reply reply;
struct lvmcache_info *info;
struct dm_config_tree *pvmeta, *vgmeta;
- const char *status;
+ const char *status, *vgid;
int result;
if (!lvmetad_active() || test_mode())
@@ -724,11 +724,6 @@ int lvmetad_pv_found(const struct id *pvid, struct device *device, const struct
NULL);
dm_config_destroy(vgmeta);
} else {
- if (handler) {
- log_error(INTERNAL_ERROR "Handler needs existing VG.");
- dm_free(pvmeta);
- return 0;
- }
/* There are no MDAs on this PV. */
reply = _lvmetad_send("pv_found", "pvmeta = %t", pvmeta, NULL);
}
@@ -744,10 +739,11 @@ int lvmetad_pv_found(const struct id *pvid, struct device *device, const struct
if (result && handler) {
status = daemon_reply_str(reply, "status", "<missing>");
+ vgid = daemon_reply_str(reply, "vgid", "<missing>");
if (!strcmp(status, "partial"))
- handler(vg, 1, CHANGE_AAY);
+ handler(_lvmetad_cmd, vgid, 1, CHANGE_AAY);
else if (!strcmp(status, "complete"))
- handler(vg, 0, CHANGE_AAY);
+ handler(_lvmetad_cmd, vgid, 0, CHANGE_AAY);
else if (!strcmp(status, "orphan"))
;
else
diff --git a/lib/cache/lvmetad.h b/lib/cache/lvmetad.h
index 5f0f552..c644069 100644
--- a/lib/cache/lvmetad.h
+++ b/lib/cache/lvmetad.h
@@ -22,7 +22,8 @@ struct cmd_context;
struct dm_config_tree;
enum activation_change;
-typedef int (*activation_handler) (struct volume_group *vg, int partial,
+typedef int (*activation_handler) (struct cmd_context *cmd,
+ const char *vgid, int partial,
enum activation_change activate);
#ifdef LVMETAD_SUPPORT
diff --git a/test/shell/lvmetad-pvscan-nomda.sh b/test/shell/lvmetad-pvscan-nomda.sh
new file mode 100644
index 0000000..c04a275
--- /dev/null
+++ b/test/shell/lvmetad-pvscan-nomda.sh
@@ -0,0 +1,49 @@
+#!/bin/sh
+# Copyright (C) 2012 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
+
+test -e LOCAL_LVMETAD || skip
+kill $(cat LOCAL_LVMETAD)
+rm LOCAL_LVMETAD
+
+aux prepare_devs 2
+
+pvcreate --metadatacopies 0 $dev1
+pvcreate --metadatacopies 1 $dev2
+vgcreate $vg1 $dev1 $dev2
+lvcreate -n foo -l 1 -an --zero n $vg1
+
+# start lvmetad but make sure it doesn't know about $dev1 or $dev2
+aux disable_dev $dev1
+aux disable_dev $dev2
+aux prepare_lvmetad
+lvs
+mv LOCAL_LVMETAD XXX
+aux enable_dev $dev2
+aux enable_dev $dev1
+mv XXX LOCAL_LVMETAD
+
+aux lvmconf 'global/use_lvmetad = 0'
+check inactive $vg1 foo
+aux lvmconf 'global/use_lvmetad = 1'
+
+pvscan --cache $dev2 -aay
+
+aux lvmconf 'global/use_lvmetad = 0'
+check inactive $vg1 foo
+aux lvmconf 'global/use_lvmetad = 1'
+
+pvscan --cache $dev1 -aay
+
+aux lvmconf 'global/use_lvmetad = 0'
+check active $vg1 foo
+aux lvmconf 'global/use_lvmetad = 1'
diff --git a/tools/pvscan.c b/tools/pvscan.c
index fbd524b..1e844c5 100644
--- a/tools/pvscan.c
+++ b/tools/pvscan.c
@@ -91,18 +91,36 @@ 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)));
}
-static int _auto_activation_handler(struct volume_group *vg, int partial,
+static int _auto_activation_handler(struct cmd_context *cmd,
+ const char *vgid, int partial,
activation_change_t activate)
{
+ struct volume_group *vg;
+ int consistent = 0;
+ struct id vgid_raw;
+
/* TODO: add support for partial and clustered VGs */
- if (partial || vg_is_clustered(vg))
+ if (partial)
return 1;
+ id_read_format(&vgid_raw, vgid);
+ /* NB. This is safe because we know lvmetad is running and we won't hit
+ * disk. */
+ if (!(vg = vg_read_internal(cmd, NULL, (const char *) &vgid_raw, 0, &consistent)))
+ return 1;
+
+ if (vg_is_clustered(vg)) {
+ release_vg(vg);
+ return 1;
+ }
+
if (!vgchange_activate(vg->cmd, vg, activate)) {
log_error("%s: autoactivation failed.", vg->name);
+ release_vg(vg);
return 0;
}
+ release_vg(vg);
return 1;
}

View File

@ -1,47 +0,0 @@
commit f03877ecb56f32d91dd98e8e3331164f472f8b77
Author: Peter Rajnoha <prajnoha@redhat.com>
Date: Tue May 14 11:48:51 2013 +0200
lvm2-2_02_99-fix-dmsetup-splitname-to-not-fail-if-used-without-c-switch.patch
---
WHATS_NEW_DM | 1 +
tools/dmsetup.c | 8 +++++---
2 files changed, 6 insertions(+), 3 deletions(-)
diff --git a/WHATS_NEW_DM b/WHATS_NEW_DM
index 30d01f9..34a0f70 100644
--- a/WHATS_NEW_DM
+++ b/WHATS_NEW_DM
@@ -1,5 +1,6 @@
Version 1.02.78 -
===================================
+ Fix 'dmsetup splitname -o' to not fail if used without '-c' switch (1.02.68).
Close open dmeventd FIFO file descriptors on exec (FD_CLOEXEC).
Add DM_DISABLE_UDEV environment variable to manage dev nodes by libdm only.
Automatically deactivate failed preloaded dm tree node.
diff --git a/tools/dmsetup.c b/tools/dmsetup.c
index 196c170..2dc3abd 100644
--- a/tools/dmsetup.c
+++ b/tools/dmsetup.c
@@ -3749,9 +3749,6 @@ static int _process_switches(int *argc, char ***argv, const char *dev_dir)
return 0;
}
- if (!_process_options(_string_args[OPTIONS_ARG]))
- return 0;
-
if (_switches[TABLE_ARG] && _switches[NOTABLE_ARG]) {
fprintf(stderr, "--table and --notable are incompatible.\n");
return 0;
@@ -3824,6 +3821,11 @@ int main(int argc, char **argv)
if (!strcmp(cmd->name, "mangle"))
dm_set_name_mangling_mode(DM_STRING_MANGLING_NONE);
+ if (!_process_options(_string_args[OPTIONS_ARG])) {
+ fprintf(stderr, "Couldn't process command line.\n");
+ goto out;
+ }
+
if (_switches[COLS_ARG]) {
if (!_report_init(cmd))
goto out;

View File

@ -1,64 +0,0 @@
commit 5bad6200b66259dde0c1cf3bd6295e65a5ade3c9
Author: Peter Rajnoha <prajnoha@redhat.com>
Date: Tue May 14 12:57:54 2013 +0200
lvm2-2_02_99-fix-handling-of-reappeared-and-missing-pvs-in-lvmetad.patch
---
lib/cache/lvmetad.c | 8 +++++++-
lib/metadata/metadata.c | 4 ++--
lib/metadata/metadata.h | 3 +++
3 files changed, 12 insertions(+), 3 deletions(-)
diff --git a/lib/cache/lvmetad.c b/lib/cache/lvmetad.c
index a636f43..d8ad4dd 100644
--- a/lib/cache/lvmetad.c
+++ b/lib/cache/lvmetad.c
@@ -354,14 +354,20 @@ struct volume_group *lvmetad_vg_lookup(struct cmd_context *cmd, const char *vgna
if ((info = lvmcache_info_from_pvid((const char *)&pvl->pv->id, 0))) {
pvl->pv->label_sector = lvmcache_get_label(info)->sector;
pvl->pv->dev = lvmcache_device(info);
+ if (!pvl->pv->dev)
+ pvl->pv->status |= MISSING_PV;
+ else
+ check_reappeared_pv(vg, pvl->pv);
if (!lvmcache_fid_add_mdas_pv(info, fid)) {
vg = NULL;
goto_out; /* FIXME error path */
}
- } /* else probably missing */
+ } else
+ pvl->pv->status |= MISSING_PV; /* probably missing */
}
lvmcache_update_vg(vg, 0);
+ vg_mark_partial_lvs(vg, 1);
}
out:
diff --git a/lib/metadata/metadata.c b/lib/metadata/metadata.c
index c210a63..2cca93c 100644
--- a/lib/metadata/metadata.c
+++ b/lib/metadata/metadata.c
@@ -2870,8 +2870,8 @@ int vg_missing_pv_count(const struct volume_group *vg)
return ret;
}
-static void check_reappeared_pv(struct volume_group *correct_vg,
- struct physical_volume *pv)
+void check_reappeared_pv(struct volume_group *correct_vg,
+ struct physical_volume *pv)
{
struct pv_list *pvl;
diff --git a/lib/metadata/metadata.h b/lib/metadata/metadata.h
index 19bf742..630c4ca 100644
--- a/lib/metadata/metadata.h
+++ b/lib/metadata/metadata.h
@@ -492,4 +492,7 @@ int is_mirror_image_removable(struct logical_volume *mimage_lv, void *baton);
uint64_t find_min_mda_size(struct dm_list *mdas);
char *tags_format_and_copy(struct dm_pool *mem, const struct dm_list *tags);
+void check_reappeared_pv(struct volume_group *correct_vg,
+ struct physical_volume *pv);
+
#endif

View File

@ -1,44 +0,0 @@
commit 191de7c40463b04ef80b424982221784df0a99ed
Author: Peter Rajnoha <prajnoha@redhat.com>
Date: Tue May 14 11:02:39 2013 +0200
lvm2-2_02_99-fix-lv_is_active-in-lvcreate.patch
---
lib/metadata/lv_manip.c | 10 ++--------
test/shell/lvcreate-usage.sh | 2 ++
2 files changed, 4 insertions(+), 8 deletions(-)
diff --git a/lib/metadata/lv_manip.c b/lib/metadata/lv_manip.c
index a59e03f..557df58 100644
--- a/lib/metadata/lv_manip.c
+++ b/lib/metadata/lv_manip.c
@@ -4348,14 +4348,8 @@ static struct logical_volume *_lv_create_an_lv(struct volume_group *vg, struct l
log_warn("WARNING: See global/mirror_segtype_default in lvm.conf.");
}
- if (!lv_is_active(org)) {
- log_error("Check for existence of active snapshot "
- "origin '%s' failed.", org->name);
- return NULL;
- }
- origin_active = 1;
-
- if (vg_is_clustered(vg) &&
+ if ((origin_active = lv_is_active(org)) &&
+ vg_is_clustered(vg) &&
!lv_is_active_exclusive_locally(org)) {
log_error("%s must be active exclusively to"
" create snapshot", org->name);
diff --git a/test/shell/lvcreate-usage.sh b/test/shell/lvcreate-usage.sh
index ddde401..c9c906a 100644
--- a/test/shell/lvcreate-usage.sh
+++ b/test/shell/lvcreate-usage.sh
@@ -64,6 +64,8 @@ lvcreate -l1 -n $lv3 $vg
not lvcreate -l1 -n $lv4 $vg
lvremove -ff $vg/$lv3
+# check snapshot of inactive origin
+lvchange -an $vg/$lv1
lvcreate -l1 -s -n $lv3 $vg/$lv1
not lvcreate -l1 -n $lv4 $vg
not lvcreate -l1 -m1 -n $lv4 $vg

View File

@ -1,35 +0,0 @@
commit 509ba58eaa537a8db2e0bd41d8c56c52a68e8512
Author: Peter Rajnoha <prajnoha@redhat.com>
Date: Tue May 14 11:04:30 2013 +0200
lvm2-2_02_99-fix-possible-deadlock-in-lvmetad-for-parallel-update-and-query.patch
---
WHATS_NEW | 1 +
daemons/lvmetad/lvmetad-core.c | 2 +-
2 files changed, 2 insertions(+), 1 deletion(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index 25e07ee..4728466 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.99 -
===================================
+ Fix possible deadlock when querying and updating lvmetad at the same time.
Avoid a global lock in pvs when lvmetad is in use.
Fix crash in pvscan --cache -aay triggered by non-mda PV.
Fix lvm2app to return all property sizes in bytes.
diff --git a/daemons/lvmetad/lvmetad-core.c b/daemons/lvmetad/lvmetad-core.c
index 0a1c884..3f417da 100644
--- a/daemons/lvmetad/lvmetad-core.c
+++ b/daemons/lvmetad/lvmetad-core.c
@@ -675,8 +675,8 @@ static int update_metadata(lvmetad_state *s, const char *name, const char *_vgid
lock_vgid_to_metadata(s);
old = dm_hash_lookup(s->vgid_to_metadata, _vgid);
- lock_vg(s, _vgid);
unlock_vgid_to_metadata(s);
+ lock_vg(s, _vgid);
seq = dm_config_find_int(metadata, "metadata/seqno", -1);

View File

@ -1,54 +0,0 @@
commit 8f17dc8027f1d9fd188468c26eb8c0a9957cc9cb
Author: Peter Rajnoha <prajnoha@redhat.com>
Date: Tue May 14 11:04:52 2013 +0200
lvm2-2_02_99-fix-possible-race-in-lvmetad-remove_metadata.patch
---
WHATS_NEW | 1 +
daemons/lvmetad/lvmetad-core.c | 14 +++++++++-----
2 files changed, 10 insertions(+), 5 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index 4728466..20a8125 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.99 -
===================================
+ Fix possible race while removing metadata from lvmetad.
Fix possible deadlock when querying and updating lvmetad at the same time.
Avoid a global lock in pvs when lvmetad is in use.
Fix crash in pvscan --cache -aay triggered by non-mda PV.
diff --git a/daemons/lvmetad/lvmetad-core.c b/daemons/lvmetad/lvmetad-core.c
index 3f417da..fed9296 100644
--- a/daemons/lvmetad/lvmetad-core.c
+++ b/daemons/lvmetad/lvmetad-core.c
@@ -605,19 +605,23 @@ static int remove_metadata(lvmetad_state *s, const char *vgid, int update_pvids)
lock_vgid_to_metadata(s);
old = dm_hash_lookup(s->vgid_to_metadata, vgid);
oldname = dm_hash_lookup(s->vgid_to_vgname, vgid);
- unlock_vgid_to_metadata(s);
- if (!old)
+ if (!old) {
+ unlock_vgid_to_metadata(s);
return 0;
+ }
+
assert(oldname);
- if (update_pvids)
- /* FIXME: What should happen when update fails */
- update_pvid_to_vgid(s, old, "#orphan", 0);
/* need to update what we have since we found a newer version */
dm_hash_remove(s->vgid_to_metadata, vgid);
dm_hash_remove(s->vgid_to_vgname, vgid);
dm_hash_remove(s->vgname_to_vgid, oldname);
+ unlock_vgid_to_metadata(s);
+
+ if (update_pvids)
+ /* FIXME: What should happen when update fails */
+ update_pvid_to_vgid(s, old, "#orphan", 0);
dm_config_destroy(old);
return 1;
}

View File

@ -1,182 +0,0 @@
commit 811db05e50b042c7ce3dc3ca9cfd3eccac464caa
Author: Peter Rajnoha <prajnoha@redhat.com>
Date: Tue May 14 11:22:58 2013 +0200
lvm2-2_02_99-fix-premature-dm-version-checking-which-caused-useless-mapper-control-access.patch
---
WHATS_NEW | 1 +
lib/activate/dev_manager.c | 58 +++++++++++++++++++++++++++++++++++++++++++---
lib/commands/toolcontext.c | 46 +++++++-----------------------------
3 files changed, 64 insertions(+), 41 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index 8516f40..eb7897d 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.99 -
===================================
+ Fix premature DM version checking which caused useless mapper/control access.
Recognize DM_DISABLE_UDEV environment variable for a complete fallback.
Do not verify udev operations if --noudevsync command option is used.
Fix blkdeactivate to handle nested mountpoints and mangled mount paths.
diff --git a/lib/activate/dev_manager.c b/lib/activate/dev_manager.c
index 31c1c27..7abd43b 100644
--- a/lib/activate/dev_manager.c
+++ b/lib/activate/dev_manager.c
@@ -1016,6 +1016,58 @@ int dev_manager_mknodes(const struct logical_volume *lv)
return r;
}
+#ifdef UDEV_SYNC_SUPPORT
+/*
+ * Until the DM_UEVENT_GENERATED_FLAG was introduced in kernel patch
+ * 856a6f1dbd8940e72755af145ebcd806408ecedd
+ * some operations could not be performed by udev, requiring our fallback code.
+ */
+static int _dm_driver_has_stable_udev_support(void)
+{
+ char vsn[80];
+ unsigned maj, min, patchlevel;
+
+ return driver_version(vsn, sizeof(vsn)) &&
+ (sscanf(vsn, "%u.%u.%u", &maj, &min, &patchlevel) == 3) &&
+ (maj == 4 ? min >= 18 : maj > 4);
+}
+
+static int _check_udev_fallback(struct cmd_context *cmd)
+{
+ struct config_info *settings = &cmd->current_settings;
+
+ if (settings->udev_fallback != -1)
+ goto out;
+
+ /*
+ * Use udev fallback automatically in case udev
+ * is disabled via DM_DISABLE_UDEV environment
+ * variable or udev rules are switched off.
+ */
+ settings->udev_fallback = !settings->udev_rules ? 1 :
+ find_config_tree_bool(cmd, "activation/verify_udev_operations",
+ DEFAULT_VERIFY_UDEV_OPERATIONS);
+
+ /* Do not rely fully on udev if the udev support is known to be incomplete. */
+ if (!settings->udev_fallback && !_dm_driver_has_stable_udev_support()) {
+ log_very_verbose("Kernel driver has incomplete udev support so "
+ "LVM will check and perform some operations itself.");
+ settings->udev_fallback = 1;
+ }
+out:
+ return settings->udev_fallback;
+}
+
+#else /* UDEV_SYNC_SUPPORT */
+
+static int _check_udev_fallback(struct cmd_context *cmd)
+{
+ /* We must use old node/symlink creation code if not compiled with udev support at all! */
+ return cmd->current_settings.udev_fallback = 1;
+}
+
+#endif /* UDEV_SYNC_SUPPORT */
+
static uint16_t _get_udev_flags(struct dev_manager *dm, struct logical_volume *lv,
const char *layer)
{
@@ -1025,7 +1077,7 @@ static uint16_t _get_udev_flags(struct dev_manager *dm, struct logical_volume *l
* Instruct also libdevmapper to disable udev
* fallback in accordance to LVM2 settings.
*/
- if (!dm->cmd->current_settings.udev_fallback)
+ if (!_check_udev_fallback(dm->cmd))
udev_flags |= DM_UDEV_DISABLE_LIBRARY_FALLBACK;
/*
@@ -2036,7 +2088,7 @@ static int _create_lv_symlinks(struct dev_manager *dm, struct dm_tree_node *root
int r = 1;
/* Nothing to do if udev fallback is disabled. */
- if (!dm->cmd->current_settings.udev_fallback) {
+ if (!_check_udev_fallback(dm->cmd)) {
fs_set_create();
return 1;
}
@@ -2084,7 +2136,7 @@ static int _remove_lv_symlinks(struct dev_manager *dm, struct dm_tree_node *root
int r = 1;
/* Nothing to do if udev fallback is disabled. */
- if (!dm->cmd->current_settings.udev_fallback)
+ if (!_check_udev_fallback(dm->cmd))
return 1;
while ((child = dm_tree_next_child(&handle, root, 0))) {
diff --git a/lib/commands/toolcontext.c b/lib/commands/toolcontext.c
index 80d0f3e..61d5c26 100644
--- a/lib/commands/toolcontext.c
+++ b/lib/commands/toolcontext.c
@@ -226,23 +226,6 @@ static int _check_disable_udev(const char *msg) {
return 0;
}
-#ifdef UDEV_SYNC_SUPPORT
-/*
- * Until the DM_UEVENT_GENERATED_FLAG was introduced in kernel patch
- * 856a6f1dbd8940e72755af145ebcd806408ecedd
- * some operations could not be performed by udev, requiring our fallback code.
- */
-static int _dm_driver_has_stable_udev_support(void)
-{
- char vsn[80];
- unsigned maj, min, patchlevel;
-
- return driver_version(vsn, sizeof(vsn)) &&
- (sscanf(vsn, "%u.%u.%u", &maj, &min, &patchlevel) == 3) &&
- (maj == 4 ? min >= 18 : maj > 4);
-}
-#endif
-
static int _process_config(struct cmd_context *cmd)
{
mode_t old_umask;
@@ -341,33 +324,20 @@ static int _process_config(struct cmd_context *cmd)
cmd->default_settings.udev_sync = udev_disabled ? 0 :
find_config_tree_int(cmd, "activation/udev_sync", DEFAULT_UDEV_SYNC);
+ /*
+ * Set udev_fallback lazily on first use since it requires
+ * checking DM driver version which is an extra ioctl!
+ * This also prevents unnecessary use of mapper/control.
+ * If udev is disabled globally, set fallback mode immediately.
+ */
+ cmd->default_settings.udev_fallback = udev_disabled ? 1 : -1;
+
init_retry_deactivation(find_config_tree_int(cmd, "activation/retry_deactivation",
DEFAULT_RETRY_DEACTIVATION));
init_activation_checks(find_config_tree_int(cmd, "activation/checks",
DEFAULT_ACTIVATION_CHECKS));
-#ifdef UDEV_SYNC_SUPPORT
- /*
- * Use udev fallback automatically in case udev
- * is disabled via DM_DISABLE_UDEV environment
- * variable or udev rules are switched off.
- */
- cmd->default_settings.udev_fallback = !cmd->default_settings.udev_rules || udev_disabled ? 1 :
- find_config_tree_int(cmd, "activation/verify_udev_operations", DEFAULT_VERIFY_UDEV_OPERATIONS);
-
- /* Do not rely fully on udev if the udev support is known to be incomplete. */
- if (!cmd->default_settings.udev_fallback && !_dm_driver_has_stable_udev_support()) {
- log_very_verbose("Kernel driver has incomplete udev support so "
- "LVM will check and perform some operations itself.");
- cmd->default_settings.udev_fallback = 1;
- }
-
-#else
- /* We must use old node/symlink creation code if not compiled with udev support at all! */
- cmd->default_settings.udev_fallback = 1;
-#endif
-
cmd->use_linear_target = find_config_tree_int(cmd,
"activation/use_linear_target",
DEFAULT_USE_LINEAR_TARGET);

View File

@ -1,58 +0,0 @@
diff --git a/WHATS_NEW b/WHATS_NEW
index c0ae3df..5887ec7 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,3 +1,7 @@
+Version 2.02.99 -
+===================================
+ Hardcode use_lvmetad=0 if cluster locking used and issue a warning msg.
+
Version 2.02.98 - 15th October 2012
===================================
Switch from DEBUG() to DEBUGLOG() in lvmetad as -DDEBUG is already used.
diff --git a/lib/commands/toolcontext.c b/lib/commands/toolcontext.c
index d7f8ece..eb1a90b 100644
--- a/lib/commands/toolcontext.c
+++ b/lib/commands/toolcontext.c
@@ -413,7 +413,15 @@ static int _process_config(struct cmd_context *cmd)
lvmetad_set_socket(lvmetad_socket);
cn = find_config_tree_node(cmd, "devices/global_filter");
lvmetad_set_token(cn ? cn->v : NULL);
- lvmetad_set_active(find_config_tree_int(cmd, "global/use_lvmetad", 1));
+
+ if (find_config_tree_int(cmd, "global/locking_type", 1) == 3 &&
+ find_config_tree_int(cmd, "global/use_lvmetad", 1)) {
+ log_warn("WARNING: configuration setting use_lvmetad overriden to 0 due to locking_type 3. "
+ "Clustered environment not supported by lvmetad yet.");
+ lvmetad_set_active(0);
+ } else
+ lvmetad_set_active(find_config_tree_int(cmd, "global/use_lvmetad", 1));
+
lvmetad_init(cmd);
return 1;
diff --git a/test/shell/lvmetad-no-cluster.sh b/test/shell/lvmetad-no-cluster.sh
new file mode 100644
index 0000000..db68e77
--- /dev/null
+++ b/test/shell/lvmetad-no-cluster.sh
@@ -0,0 +1,19 @@
+#!/bin/sh
+# Copyright (C) 2012 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
+
+test -e LOCAL_CLVMD || skip
+aux prepare_vg 2
+aux prepare_lvmetad
+vgs -vv 2> errs
+cat errs
+grep 'use_lvmetad' errs

View File

@ -1,111 +0,0 @@
diff --git a/WHATS_NEW b/WHATS_NEW
index 5887ec7..d0e0cd4 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.99 -
===================================
+ Initialize lvmetad lazily to avoid early socket access on config overrides.
Hardcode use_lvmetad=0 if cluster locking used and issue a warning msg.
Version 2.02.98 - 15th October 2012
diff --git a/lib/cache/lvmetad.c b/lib/cache/lvmetad.c
index 6a374ac..72e07fd 100644
--- a/lib/cache/lvmetad.c
+++ b/lib/cache/lvmetad.c
@@ -33,7 +33,8 @@ static struct cmd_context *_lvmetad_cmd = NULL;
void lvmetad_disconnect(void)
{
- daemon_close(_lvmetad);
+ if (_lvmetad_connected)
+ daemon_close(_lvmetad);
_lvmetad_connected = 0;
_lvmetad_cmd = NULL;
}
@@ -41,19 +42,25 @@ void lvmetad_disconnect(void)
void lvmetad_init(struct cmd_context *cmd)
{
if (!_lvmetad_use && !access(LVMETAD_PIDFILE, F_OK))
- log_warn("WARNING: lvmetad is running but disabled. Restart lvmetad before enabling it!");
+ log_warn("WARNING: lvmetad is running but disabled."
+ " Restart lvmetad before enabling it!");
+ _lvmetad_cmd = cmd;
+}
+
+static void _lvmetad_connect()
+{
if (_lvmetad_use && _lvmetad_socket && !_lvmetad_connected) {
assert(_lvmetad_socket);
_lvmetad = lvmetad_open(_lvmetad_socket);
- if (_lvmetad.socket_fd >= 0 && !_lvmetad.error) {
+ if (_lvmetad.socket_fd >= 0 && !_lvmetad.error)
_lvmetad_connected = 1;
- _lvmetad_cmd = cmd;
- }
}
}
void lvmetad_warning(void)
{
+ if (!_lvmetad_connected)
+ _lvmetad_connect();
if (_lvmetad_use && (_lvmetad.socket_fd < 0 || _lvmetad.error))
log_warn("WARNING: Failed to connect to lvmetad: %s. Falling back to internal scanning.",
strerror(_lvmetad.error));
@@ -61,7 +68,11 @@ void lvmetad_warning(void)
int lvmetad_active(void)
{
- return _lvmetad_use && _lvmetad_connected;
+ if (!_lvmetad_use)
+ return 0;
+ if (!_lvmetad_connected)
+ _lvmetad_connect();
+ return _lvmetad_connected;
}
void lvmetad_set_active(int active)
@@ -873,6 +884,11 @@ int lvmetad_pvscan_all_devs(struct cmd_context *cmd, activation_handler handler)
char *future_token;
int was_silent;
+ if (!lvmetad_active()) {
+ log_error("Cannot proceed since lvmetad is not active.");
+ return 0;
+ }
+
if (!(iter = dev_iter_create(cmd->lvmetad_filter, 1))) {
log_error("dev_iter creation failed");
return 0;
diff --git a/test/shell/lvmetad-override.sh b/test/shell/lvmetad-override.sh
new file mode 100644
index 0000000..3fb281a
--- /dev/null
+++ b/test/shell/lvmetad-override.sh
@@ -0,0 +1,25 @@
+#!/bin/sh
+# Copyright (C) 2012 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
+
+test -e LOCAL_LVMETAD || skip
+aux prepare_pvs 2
+
+vgcreate $vg1 $dev1 $dev2
+lvchange -ay $vg1 2>&1 | not grep "Failed to connect"
+kill $(cat LOCAL_LVMETAD)
+lvchange -ay $vg1 2>&1 | grep "Failed to connect"
+lvchange -ay $vg1 --sysinit 2>&1 | not grep "Failed to connect"
+lvchange -ay $vg1 --config 'global { use_lvmetad = 0 }' 2>&1 | not grep "Failed to connect"
+aux lvmconf "global/use_lvmetad = 0"
+lvchange -ay $vg1 --config 'global { use_lvmetad = 1 }' 2>&1 | grep "Failed to connect"
+

View File

@ -1,86 +0,0 @@
commit 98c5eb308690d990b957012db9d48b6722ea93cb
Author: Peter Rajnoha <prajnoha@redhat.com>
Date: Tue May 14 12:47:24 2013 +0200
lvm2-2_02_99-lvmetad-fix-a-race-in-metadata-update.patch
---
WHATS_NEW | 1 +
daemons/lvmetad/lvmetad-core.c | 21 +++++++++++++--------
2 files changed, 14 insertions(+), 8 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index 20a8125..35c5e43 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.99 -
===================================
+ Fix a crash-inducing race condition in lvmetad while updating metadata.
Fix possible race while removing metadata from lvmetad.
Fix possible deadlock when querying and updating lvmetad at the same time.
Avoid a global lock in pvs when lvmetad is in use.
diff --git a/daemons/lvmetad/lvmetad-core.c b/daemons/lvmetad/lvmetad-core.c
index fed9296..1f855a7 100644
--- a/daemons/lvmetad/lvmetad-core.c
+++ b/daemons/lvmetad/lvmetad-core.c
@@ -450,7 +450,8 @@ static response vg_lookup(lvmetad_state *s, request r)
DEBUGLOG(s, "vg_lookup: updated uuid = %s, name = %s", uuid, name);
- if (!uuid)
+ /* Check the name here. */
+ if (!uuid || !name)
return reply_unknown("VG not found");
cft = lock_vg(s, uuid);
@@ -679,16 +680,14 @@ static int update_metadata(lvmetad_state *s, const char *name, const char *_vgid
lock_vgid_to_metadata(s);
old = dm_hash_lookup(s->vgid_to_metadata, _vgid);
+ oldname = dm_hash_lookup(s->vgid_to_vgname, _vgid);
unlock_vgid_to_metadata(s);
lock_vg(s, _vgid);
seq = dm_config_find_int(metadata, "metadata/seqno", -1);
- if (old) {
+ if (old)
haveseq = dm_config_find_int(old->root, "metadata/seqno", -1);
- oldname = dm_hash_lookup(s->vgid_to_vgname, _vgid);
- assert(oldname);
- }
if (seq < 0)
goto out;
@@ -740,7 +739,7 @@ static int update_metadata(lvmetad_state *s, const char *name, const char *_vgid
if (haveseq >= 0 && haveseq < seq) {
INFO(s, "Updating metadata for %s at %d to %d", _vgid, haveseq, seq);
/* temporarily orphan all of our PVs */
- remove_metadata(s, vgid, 1);
+ update_pvid_to_vgid(s, old, "#orphan", 0);
}
lock_vgid_to_metadata(s);
@@ -750,14 +749,20 @@ static int update_metadata(lvmetad_state *s, const char *name, const char *_vgid
dm_hash_insert(s->vgid_to_metadata, vgid, cft) &&
dm_hash_insert(s->vgid_to_vgname, vgid, cfgname) &&
dm_hash_insert(s->vgname_to_vgid, name, (void*) vgid)) ? 1 : 0;
+
+ if (retval && oldname && strcmp(name, oldname))
+ dm_hash_remove(s->vgname_to_vgid, oldname);
+
+ if (haveseq >= 0 && haveseq < seq)
+ dm_config_destroy(old);
+
unlock_vgid_to_metadata(s);
if (retval)
- /* FIXME: What should happen when update fails */
retval = update_pvid_to_vgid(s, cft, vgid, 1);
unlock_pvid_to_vgid(s);
-out:
+out: /* FIXME: We should probably abort() on partial failures. */
if (!retval && cft)
dm_config_destroy(cft);
unlock_vg(s, _vgid);

View File

@ -1,32 +0,0 @@
diff --git a/WHATS_NEW_DM b/WHATS_NEW_DM
index 2d0b05c..3f8d9c9 100644
--- a/WHATS_NEW_DM
+++ b/WHATS_NEW_DM
@@ -1,3 +1,7 @@
+Version 1.02.78 -
+===================================
+ Fix dm_task_set_cookie to properly process udev flags if udev_sync disabled.
+
Version 1.02.77 - 15th October 2012
===================================
Support unmount of thin volumes from pool above thin pool threshold.
diff --git a/libdm/libdm-common.c b/libdm/libdm-common.c
index b8533ed..afdac89 100644
--- a/libdm/libdm-common.c
+++ b/libdm/libdm-common.c
@@ -1838,6 +1838,7 @@ int dm_task_set_cookie(struct dm_task *dmt, uint32_t *cookie, uint16_t flags)
if (dm_cookie_supported())
dmt->event_nr = flags << DM_UDEV_FLAGS_SHIFT;
*cookie = 0;
+ dmt->cookie_set = 1;
return 1;
}
@@ -2207,6 +2208,7 @@ int dm_task_set_cookie(struct dm_task *dmt, uint32_t *cookie, uint16_t flags)
if (!dm_udev_get_sync_support()) {
*cookie = 0;
+ dmt->cookie_set = 1;
return 1;
}

View File

@ -1,470 +0,0 @@
commit 0e47639a44e1630250ea10643f5a440281edfdce
Author: Andy Grover <agrover@redhat.com>
Date: Wed Oct 17 12:55:25 2012 -0700
python-lvm: Implement proper refcounting for parent objects
Our object nesting:
lib -> VG -> LV -> lvseg
-> PV -> pvseg
Implement refcounting and checks to ensure parent objects are not
dealloced before their children. Also ensure calls to self or child's
methods are handled cleanly for objects that have been closed or removed.
Ensure all functions that are object methods have a first parameter named
'self', for consistency
Rename local vars that reference a Python object to '*obj', in order to
differentiate from liblvm handles
Fix a misspelled pv method name
Signed-off-by: Andy Grover <agrover@redhat.com>
---
python/liblvm.c | 152 +++++++++++++++++++++++++++++++++++++++-----------------
1 file changed, 106 insertions(+), 46 deletions(-)
diff --git a/python/liblvm.c b/python/liblvm.c
index 8a73ced..024d769 100644
--- a/python/liblvm.c
+++ b/python/liblvm.c
@@ -35,21 +35,25 @@ typedef struct {
typedef struct {
PyObject_HEAD
lv_t lv; /* lv handle */
+ vgobject *parent_vgobj;
} lvobject;
typedef struct {
PyObject_HEAD
pv_t pv; /* pv handle */
+ vgobject *parent_vgobj;
} pvobject;
typedef struct {
PyObject_HEAD
lvseg_t lv_seg; /* lv segment handle */
+ lvobject *parent_lvobj;
} lvsegobject;
typedef struct {
PyObject_HEAD
pvseg_t pv_seg; /* pv segment handle */
+ pvobject *parent_pvobj;
} pvsegobject;
static PyTypeObject LibLVMvgType;
@@ -347,6 +351,7 @@ liblvm_vg_dealloc(vgobject *self)
#define VG_VALID(vgobject) \
do { \
+ LVM_VALID(); \
if (!vgobject->vg) { \
PyErr_SetString(PyExc_UnboundLocalError, "VG object invalid"); \
return NULL; \
@@ -785,18 +790,18 @@ liblvm_lvm_vg_set_extent_size(vgobject *self, PyObject *args)
}
static PyObject *
-liblvm_lvm_vg_list_lvs(vgobject *vg)
+liblvm_lvm_vg_list_lvs(vgobject *self)
{
struct dm_list *lvs;
struct lvm_lv_list *lvl;
PyObject * pytuple;
- lvobject * self;
+ lvobject * lvobj;
int i = 0;
- VG_VALID(vg);
+ VG_VALID(self);
/* unlike other LVM api calls, if there are no results, we get NULL */
- lvs = lvm_vg_list_lvs(vg->vg);
+ lvs = lvm_vg_list_lvs(self->vg);
if (!lvs)
return Py_BuildValue("()");
@@ -806,14 +811,17 @@ liblvm_lvm_vg_list_lvs(vgobject *vg)
dm_list_iterate_items(lvl, lvs) {
/* Create and initialize the object */
- self = PyObject_New(lvobject, &LibLVMlvType);
- if (!self) {
+ lvobj = PyObject_New(lvobject, &LibLVMlvType);
+ if (!lvobj) {
Py_DECREF(pytuple);
return NULL;
}
- self->lv = lvl->lv;
- PyTuple_SET_ITEM(pytuple, i, (PyObject *) self);
+ lvobj->parent_vgobj = self;
+ Py_INCREF(lvobj->parent_vgobj);
+
+ lvobj->lv = lvl->lv;
+ PyTuple_SET_ITEM(pytuple, i, (PyObject *) lvobj);
i++;
}
@@ -849,49 +857,53 @@ liblvm_lvm_vg_get_tags(vgobject *self)
}
static PyObject *
-liblvm_lvm_vg_create_lv_linear(vgobject *vg, PyObject *args)
+liblvm_lvm_vg_create_lv_linear(vgobject *self, PyObject *args)
{
const char *vgname;
uint64_t size;
- lvobject *self;
+ lvobject *lvobj;
- VG_VALID(vg);
+ VG_VALID(self);
if (!PyArg_ParseTuple(args, "sl", &vgname, &size)) {
return NULL;
}
- if ((self = PyObject_New(lvobject, &LibLVMlvType)) == NULL)
+ if ((lvobj = PyObject_New(lvobject, &LibLVMlvType)) == NULL)
return NULL;
- if ((self->lv = lvm_vg_create_lv_linear(vg->vg, vgname, size))== NULL) {
+ if ((lvobj->lv = lvm_vg_create_lv_linear(self->vg, vgname, size)) == NULL) {
PyErr_SetObject(LibLVMError, liblvm_get_last_error());
- Py_DECREF(self);
+ Py_DECREF(lvobj);
return NULL;
}
- return (PyObject *)self;
+ lvobj->parent_vgobj = self;
+ Py_INCREF(lvobj->parent_vgobj);
+
+ return (PyObject *)lvobj;
}
static void
liblvm_lv_dealloc(lvobject *self)
{
+ Py_DECREF(self->parent_vgobj);
PyObject_Del(self);
}
static PyObject *
-liblvm_lvm_vg_list_pvs(vgobject *vg)
+liblvm_lvm_vg_list_pvs(vgobject *self)
{
struct dm_list *pvs;
struct lvm_pv_list *pvl;
PyObject * pytuple;
- pvobject * self;
+ pvobject * pvobj;
int i = 0;
- VG_VALID(vg);
+ VG_VALID(self);
/* unlike other LVM api calls, if there are no results, we get NULL */
- pvs = lvm_vg_list_pvs(vg->vg);
+ pvs = lvm_vg_list_pvs(self->vg);
if (!pvs)
return Py_BuildValue("()");
@@ -901,14 +913,17 @@ liblvm_lvm_vg_list_pvs(vgobject *vg)
dm_list_iterate_items(pvl, pvs) {
/* Create and initialize the object */
- self = PyObject_New(pvobject, &LibLVMpvType);
- if (!self) {
+ pvobj = PyObject_New(pvobject, &LibLVMpvType);
+ if (!pvobj) {
Py_DECREF(pytuple);
return NULL;
}
- self->pv = pvl->pv;
- PyTuple_SET_ITEM(pytuple, i, (PyObject *) self);
+ pvobj->parent_vgobj = self;
+ Py_INCREF(pvobj->parent_vgobj);
+
+ pvobj->pv = pvl->pv;
+ PyTuple_SET_ITEM(pytuple, i, (PyObject *) pvobj);
i++;
}
@@ -922,7 +937,7 @@ static PyObject *
liblvm_lvm_lv_from_N(vgobject *self, PyObject *arg, lv_fetch_by_N method)
{
const char *id;
- lvobject *rc;
+ lvobject *lvobj;
lv_t lv = NULL;
VG_VALID(self);
@@ -936,13 +951,16 @@ liblvm_lvm_lv_from_N(vgobject *self, PyObject *arg, lv_fetch_by_N method)
return NULL;
}
- rc = PyObject_New(lvobject, &LibLVMlvType);
- if (!rc) {
+ lvobj = PyObject_New(lvobject, &LibLVMlvType);
+ if (!lvobj) {
return NULL;
}
- rc->lv = lv;
- return (PyObject *)rc;
+ lvobj->parent_vgobj = self;
+ Py_INCREF(lvobj->parent_vgobj);
+
+ lvobj->lv = lv;
+ return (PyObject *)lvobj;
}
static PyObject *
@@ -980,6 +998,7 @@ liblvm_lvm_pv_from_N(vgobject *self, PyObject *arg, pv_fetch_by_N method)
return NULL;
}
+ Py_INCREF(self);
rc->pv = pv;
return (PyObject *)rc;
}
@@ -999,6 +1018,7 @@ liblvm_lvm_pv_from_uuid(vgobject *self, PyObject *arg)
static void
liblvm_pv_dealloc(pvobject *self)
{
+ Py_DECREF(self->parent_vgobj);
PyObject_Del(self);
}
@@ -1006,6 +1026,7 @@ liblvm_pv_dealloc(pvobject *self)
#define LV_VALID(lvobject) \
do { \
+ VG_VALID(lvobject->parent_vgobj); \
if (!lvobject->lv) { \
PyErr_SetString(PyExc_UnboundLocalError, "LV object invalid"); \
return NULL; \
@@ -1242,17 +1263,17 @@ liblvm_lvm_lv_resize(lvobject *self, PyObject *args)
}
static PyObject *
-liblvm_lvm_lv_list_lvsegs(lvobject *lv)
+liblvm_lvm_lv_list_lvsegs(lvobject *self)
{
struct dm_list *lvsegs;
lvseg_list_t *lvsegl;
PyObject * pytuple;
- lvsegobject *self;
+ lvsegobject *lvsegobj;
int i = 0;
- LV_VALID(lv);
+ LV_VALID(self);
- lvsegs = lvm_lv_list_lvsegs(lv->lv);
+ lvsegs = lvm_lv_list_lvsegs(self->lv);
if (!lvsegs) {
return Py_BuildValue("()");
}
@@ -1263,14 +1284,17 @@ liblvm_lvm_lv_list_lvsegs(lvobject *lv)
dm_list_iterate_items(lvsegl, lvsegs) {
/* Create and initialize the object */
- self = PyObject_New(lvsegobject, &LibLVMlvsegType);
- if (!self) {
+ lvsegobj = PyObject_New(lvsegobject, &LibLVMlvsegType);
+ if (!lvsegobj) {
Py_DECREF(pytuple);
return NULL;
}
- self->lv_seg = lvsegl->lvseg;
- PyTuple_SET_ITEM(pytuple, i, (PyObject *) self);
+ lvsegobj->parent_lvobj = self;
+ Py_INCREF(lvsegobj->parent_lvobj);
+
+ lvsegobj->lv_seg = lvsegl->lvseg;
+ PyTuple_SET_ITEM(pytuple, i, (PyObject *) lvsegobj);
i++;
}
@@ -1281,7 +1305,8 @@ liblvm_lvm_lv_list_lvsegs(lvobject *lv)
#define PV_VALID(pvobject) \
do { \
- if (!pvobject->pv || !libh) { \
+ VG_VALID(pvobject->parent_vgobj); \
+ if (!pvobject->pv) { \
PyErr_SetString(PyExc_UnboundLocalError, "PV object invalid"); \
return NULL; \
} \
@@ -1290,18 +1315,24 @@ liblvm_lvm_lv_list_lvsegs(lvobject *lv)
static PyObject *
liblvm_lvm_pv_get_name(pvobject *self)
{
+ PV_VALID(self);
+
return Py_BuildValue("s", lvm_pv_get_name(self->pv));
}
static PyObject *
liblvm_lvm_pv_get_uuid(pvobject *self)
{
+ PV_VALID(self);
+
return Py_BuildValue("s", lvm_pv_get_uuid(self->pv));
}
static PyObject *
liblvm_lvm_pv_get_mda_count(pvobject *self)
{
+ PV_VALID(self);
+
return Py_BuildValue("l", lvm_pv_get_mda_count(self->pv));
}
@@ -1323,18 +1354,24 @@ liblvm_lvm_pv_get_property(pvobject *self, PyObject *args)
static PyObject *
liblvm_lvm_pv_get_dev_size(pvobject *self)
{
+ PV_VALID(self);
+
return Py_BuildValue("l", lvm_pv_get_dev_size(self->pv));
}
static PyObject *
liblvm_lvm_pv_get_size(pvobject *self)
{
+ PV_VALID(self);
+
return Py_BuildValue("l", lvm_pv_get_size(self->pv));
}
static PyObject *
liblvm_lvm_pv_get_free(pvobject *self)
{
+ PV_VALID(self);
+
return Py_BuildValue("l", lvm_pv_get_free(self->pv));
}
@@ -1344,6 +1381,8 @@ liblvm_lvm_pv_resize(pvobject *self, PyObject *args)
uint64_t new_size;
int rval;
+ PV_VALID(self);
+
if (!PyArg_ParseTuple(args, "l", &new_size)) {
return NULL;
}
@@ -1358,17 +1397,17 @@ liblvm_lvm_pv_resize(pvobject *self, PyObject *args)
}
static PyObject *
-liblvm_lvm_lv_list_pvsegs(pvobject *pv)
+liblvm_lvm_pv_list_pvsegs(pvobject *self)
{
struct dm_list *pvsegs;
pvseg_list_t *pvsegl;
PyObject *pytuple;
- pvsegobject *self;
+ pvsegobject *pvsegobj;
int i = 0;
- PV_VALID(pv);
+ PV_VALID(self);
- pvsegs = lvm_pv_list_pvsegs(pv->pv);
+ pvsegs = lvm_pv_list_pvsegs(self->pv);
if (!pvsegs) {
return Py_BuildValue("()");
}
@@ -1379,14 +1418,17 @@ liblvm_lvm_lv_list_pvsegs(pvobject *pv)
dm_list_iterate_items(pvsegl, pvsegs) {
/* Create and initialize the object */
- self = PyObject_New(pvsegobject, &LibLVMpvsegType);
- if (!self) {
+ pvsegobj = PyObject_New(pvsegobject, &LibLVMpvsegType);
+ if (!pvsegobj) {
Py_DECREF(pytuple);
return NULL;
}
- self->pv_seg = pvsegl->pvseg;
- PyTuple_SET_ITEM(pytuple, i, (PyObject *) self);
+ pvsegobj->parent_pvobj = self;
+ Py_INCREF(pvsegobj->parent_pvobj);
+
+ pvsegobj->pv_seg = pvsegl->pvseg;
+ PyTuple_SET_ITEM(pytuple, i, (PyObject *) pvsegobj);
i++;
}
@@ -1395,9 +1437,16 @@ liblvm_lvm_lv_list_pvsegs(pvobject *pv)
/* LV seg methods */
+/*
+ * No way to close/destroy an lvseg, just need to make sure parents are
+ * still good
+ */
+#define LVSEG_VALID(lvsegobject) LV_VALID(lvsegobject->parent_lvobj)
+
static void
liblvm_lvseg_dealloc(lvsegobject *self)
{
+ Py_DECREF(self->parent_lvobj);
PyObject_Del(self);
}
@@ -1407,6 +1456,8 @@ liblvm_lvm_lvseg_get_property(lvsegobject *self, PyObject *args)
const char *name;
struct lvm_property_value prop_value;
+ LVSEG_VALID(self);
+
if (!PyArg_ParseTuple(args, "s", &name))
return NULL;
@@ -1416,9 +1467,16 @@ liblvm_lvm_lvseg_get_property(lvsegobject *self, PyObject *args)
/* PV seg methods */
+/*
+ * No way to close/destroy a pvseg, just need to make sure parents are
+ * still good
+ */
+#define PVSEG_VALID(pvsegobject) PV_VALID(pvsegobject->parent_pvobj)
+
static void
liblvm_pvseg_dealloc(pvsegobject *self)
{
+ Py_DECREF(self->parent_pvobj);
PyObject_Del(self);
}
@@ -1428,6 +1486,8 @@ liblvm_lvm_pvseg_get_property(pvsegobject *self, PyObject *args)
const char *name;
struct lvm_property_value prop_value;
+ PVSEG_VALID(self);
+
if (!PyArg_ParseTuple(args, "s", &name))
return NULL;
@@ -1522,7 +1582,7 @@ static PyMethodDef liblvm_pv_methods[] = {
{ "getDevSize", (PyCFunction)liblvm_lvm_pv_get_dev_size, METH_NOARGS },
{ "getFree", (PyCFunction)liblvm_lvm_pv_get_free, METH_NOARGS },
{ "resize", (PyCFunction)liblvm_lvm_pv_resize, METH_VARARGS },
- { "listPVsegs", (PyCFunction)liblvm_lvm_lv_list_pvsegs, METH_NOARGS },
+ { "listPVsegs", (PyCFunction)liblvm_lvm_pv_list_pvsegs, METH_NOARGS },
{ NULL, NULL} /* sentinel */
};

View File

@ -1,793 +0,0 @@
commit 84a4d4b970bb9aaf540ad5fa82276b1caf5aa9bd
Author: Andy Grover <agrover@redhat.com>
Date: Mon Oct 15 13:26:01 2012 -0700
python-lvm: Remove liblvm object
Instead of requiring users to create a liblvm object, and then calling
methods on it, the module acquires a liblvm handle as part of
initialization. This makes it impossible to instantiate a liblvm object
with a different systemdir, but there is an alternate envvar method for
that obscure use case.
Signed-off-by: Andy Grover <agrover@redhat.com>
---
python/liblvm.c | 269 ++++++++++++++++++++------------------------------------
1 file changed, 97 insertions(+), 172 deletions(-)
diff --git a/python/liblvm.c b/python/liblvm.c
index cbfa170..4518cf4 100644
--- a/python/liblvm.c
+++ b/python/liblvm.c
@@ -24,39 +24,32 @@
#include <Python.h>
#include "lvm2app.h"
-typedef struct {
- PyObject_HEAD
- lvm_t libh; /* lvm lib handle */
-} lvmobject;
+static lvm_t libh;
+
typedef struct {
PyObject_HEAD
vg_t vg; /* vg handle */
- lvmobject *lvm_obj;
} vgobject;
typedef struct {
PyObject_HEAD
lv_t lv; /* lv handle */
- lvmobject *lvm_obj;
} lvobject;
typedef struct {
PyObject_HEAD
pv_t pv; /* pv handle */
- lvmobject *lvm_obj;
} pvobject;
typedef struct {
PyObject_HEAD
lvseg_t lv_seg; /* lv segment handle */
- lvmobject *lvm_obj;
} lvsegobject;
typedef struct {
PyObject_HEAD
pvseg_t pv_seg; /* pv segment handle */
- lvmobject *lvm_obj;
} pvsegobject;
static PyTypeObject LibLVMvgType;
@@ -67,100 +60,51 @@ static PyTypeObject LibLVMpvsegType;
static PyObject *LibLVMError;
-
-/* ----------------------------------------------------------------------
- * LVM object initialization/deallocation
- */
-
-static int
-liblvm_init(lvmobject *self, PyObject *arg)
-{
- char *systemdir = NULL;
-
- if (!PyArg_ParseTuple(arg, "|s", &systemdir))
- return -1;
-
- self->libh = lvm_init(systemdir);
- if (lvm_errno(self->libh)) {
- PyErr_SetFromErrno(PyExc_OSError);
- return -1;
- }
-
- return 0;
-}
-
-static void
-liblvm_dealloc(lvmobject *self)
-{
- /* if already closed, don't reclose it */
- if (self->libh != NULL){
- lvm_quit(self->libh);
- }
-
- PyObject_Del(self);
-}
-
-#define LVM_VALID(lvmobject) \
+#define LVM_VALID() \
do { \
- if (!lvmobject->libh) { \
- PyErr_SetString(PyExc_UnboundLocalError, "LVM object invalid"); \
+ if (!libh) { \
+ PyErr_SetString(PyExc_UnboundLocalError, "LVM handle invalid"); \
return NULL; \
} \
} while (0)
static PyObject *
-liblvm_get_last_error(lvmobject *self)
+liblvm_get_last_error(void)
{
PyObject *info;
- LVM_VALID(self);
+ LVM_VALID();
if((info = PyTuple_New(2)) == NULL)
return NULL;
- PyTuple_SetItem(info, 0, PyInt_FromLong((long) lvm_errno(self->libh)));
- PyTuple_SetItem(info, 1, PyString_FromString(lvm_errmsg(self->libh)));
+ PyTuple_SetItem(info, 0, PyInt_FromLong((long) lvm_errno(libh)));
+ PyTuple_SetItem(info, 1, PyString_FromString(lvm_errmsg(libh)));
return info;
}
static PyObject *
-liblvm_library_get_version(lvmobject *self)
+liblvm_library_get_version(void)
{
- LVM_VALID(self);
+ LVM_VALID();
return Py_BuildValue("s", lvm_library_get_version());
}
-
-static PyObject *
-liblvm_close(lvmobject *self)
-{
- LVM_VALID(self);
-
- /* if already closed, don't reclose it */
- if (self->libh != NULL)
- lvm_quit(self->libh);
-
- self->libh = NULL;
-
- Py_INCREF(Py_None);
- return Py_None;
-}
-
static PyObject *
-liblvm_lvm_list_vg_names(lvmobject *self)
+liblvm_lvm_list_vg_names(void)
{
struct dm_list *vgnames;
struct lvm_str_list *strl;
PyObject * pytuple;
int i = 0;
- LVM_VALID(self);
+ LVM_VALID();
- vgnames = lvm_list_vg_names(self->libh);
+ vgnames = lvm_list_vg_names(libh);
if (!vgnames) {
- PyErr_SetObject(LibLVMError, liblvm_get_last_error(self));
+ PyErr_SetObject(LibLVMError, liblvm_get_last_error());
return NULL;
}
@@ -177,18 +121,18 @@ liblvm_lvm_list_vg_names(lvmobject *self)
}
static PyObject *
-liblvm_lvm_list_vg_uuids(lvmobject *self)
+liblvm_lvm_list_vg_uuids(void)
{
struct dm_list *uuids;
struct lvm_str_list *strl;
PyObject * pytuple;
int i = 0;
- LVM_VALID(self);
+ LVM_VALID();
- uuids = lvm_list_vg_uuids(self->libh);
+ uuids = lvm_list_vg_uuids(libh);
if (!uuids) {
- PyErr_SetObject(LibLVMError, liblvm_get_last_error(self));
+ PyErr_SetObject(LibLVMError, liblvm_get_last_error());
return NULL;
}
@@ -205,12 +149,12 @@ liblvm_lvm_list_vg_uuids(lvmobject *self)
}
static PyObject *
-liblvm_lvm_percent_to_float(lvmobject *self, PyObject *arg)
+liblvm_lvm_percent_to_float(PyObject *arg)
{
double converted;
int percent;
- LVM_VALID(self);
+ LVM_VALID();
if (!PyArg_ParseTuple(arg, "i", &percent))
return NULL;
@@ -220,18 +164,18 @@ liblvm_lvm_percent_to_float(lvmobject *self, PyObject *arg)
}
static PyObject *
-liblvm_lvm_vgname_from_pvid(lvmobject *self, PyObject *arg)
+liblvm_lvm_vgname_from_pvid(PyObject *self, PyObject *arg)
{
const char *pvid;
const char *vgname;
- LVM_VALID(self);
+ LVM_VALID();
if (!PyArg_ParseTuple(arg, "s", &pvid))
return NULL;
- if((vgname = lvm_vgname_from_pvid(self->libh, pvid)) == NULL) {
- PyErr_SetObject(LibLVMError, liblvm_get_last_error(self));
+ if((vgname = lvm_vgname_from_pvid(libh, pvid)) == NULL) {
+ PyErr_SetObject(LibLVMError, liblvm_get_last_error());
return NULL;
}
@@ -239,18 +183,18 @@ liblvm_lvm_vgname_from_pvid(lvmobject *self, PyObject *arg)
}
static PyObject *
-liblvm_lvm_vgname_from_device(lvmobject *self, PyObject *arg)
+liblvm_lvm_vgname_from_device(PyObject *self, PyObject *arg)
{
const char *device;
const char *vgname;
- LVM_VALID(self);
+ LVM_VALID();
if (!PyArg_ParseTuple(arg, "s", &device))
return NULL;
- if((vgname = lvm_vgname_from_device(self->libh, device)) == NULL) {
- PyErr_SetObject(LibLVMError, liblvm_get_last_error(self));
+ if((vgname = lvm_vgname_from_device(libh, device)) == NULL) {
+ PyErr_SetObject(LibLVMError, liblvm_get_last_error());
return NULL;
}
@@ -259,18 +203,18 @@ liblvm_lvm_vgname_from_device(lvmobject *self, PyObject *arg)
static PyObject *
-liblvm_lvm_config_find_bool(lvmobject *self, PyObject *arg)
+liblvm_lvm_config_find_bool(PyObject *self, PyObject *arg)
{
const char *config;
int rval;
PyObject *rc;
- LVM_VALID(self);
+ LVM_VALID();
if (!PyArg_ParseTuple(arg, "s", &config))
return NULL;
- if ((rval = lvm_config_find_bool(self->libh, config, -10)) == -10) {
+ if ((rval = lvm_config_find_bool(libh, config, -10)) == -10) {
/* Retrieving error information yields no error in this case */
PyErr_Format(PyExc_ValueError, "config path not found");
return NULL;
@@ -283,14 +227,14 @@ liblvm_lvm_config_find_bool(lvmobject *self, PyObject *arg)
}
static PyObject *
-liblvm_lvm_config_reload(lvmobject *self)
+liblvm_lvm_config_reload(void)
{
int rval;
- LVM_VALID(self);
+ LVM_VALID();
- if((rval = lvm_config_reload(self->libh)) == -1) {
- PyErr_SetObject(LibLVMError, liblvm_get_last_error(self));
+ if((rval = lvm_config_reload(libh)) == -1) {
+ PyErr_SetObject(LibLVMError, liblvm_get_last_error());
return NULL;
}
@@ -300,14 +244,14 @@ liblvm_lvm_config_reload(lvmobject *self)
static PyObject *
-liblvm_lvm_scan(lvmobject *self)
+liblvm_lvm_scan(void)
{
int rval;
- LVM_VALID(self);
+ LVM_VALID();
- if((rval = lvm_scan(self->libh)) == -1) {
- PyErr_SetObject(LibLVMError, liblvm_get_last_error(self));
+ if((rval = lvm_scan(libh)) == -1) {
+ PyErr_SetObject(LibLVMError, liblvm_get_last_error());
return NULL;
}
@@ -316,18 +260,18 @@ liblvm_lvm_scan(lvmobject *self)
}
static PyObject *
-liblvm_lvm_config_override(lvmobject *self, PyObject *arg)
+liblvm_lvm_config_override(PyObject *self, PyObject *arg)
{
const char *config;
int rval;
- LVM_VALID(self);
+ LVM_VALID();
if (!PyArg_ParseTuple(arg, "s", &config))
return NULL;
- if ((rval = lvm_config_override(self->libh, config)) == -1) {
- PyErr_SetObject(LibLVMError, liblvm_get_last_error(self));
+ if ((rval = lvm_config_override(libh, config)) == -1) {
+ PyErr_SetObject(LibLVMError, liblvm_get_last_error());
return NULL;
}
@@ -340,14 +284,14 @@ liblvm_lvm_config_override(lvmobject *self, PyObject *arg)
static PyObject *
-liblvm_lvm_vg_open(lvmobject *lvm, PyObject *args)
+liblvm_lvm_vg_open(PyObject *self, PyObject *args)
{
const char *vgname;
const char *mode = NULL;
- vgobject *self;
+ vgobject *vgobj;
- LVM_VALID(lvm);
+ LVM_VALID();
if (!PyArg_ParseTuple(args, "s|s", &vgname, &mode)) {
return NULL;
@@ -356,42 +300,38 @@ liblvm_lvm_vg_open(lvmobject *lvm, PyObject *args)
if (mode == NULL)
mode = "r";
- if ((self = PyObject_New(vgobject, &LibLVMvgType)) == NULL)
+ if ((vgobj = PyObject_New(vgobject, &LibLVMvgType)) == NULL)
return NULL;
- if ((self->vg = lvm_vg_open(lvm->libh, vgname, mode, 0))== NULL) {
- PyErr_SetObject(LibLVMError, liblvm_get_last_error(lvm));
- Py_DECREF(self);
+ if ((vgobj->vg = lvm_vg_open(libh, vgname, mode, 0))== NULL) {
+ PyErr_SetObject(LibLVMError, liblvm_get_last_error());
return NULL;
}
- self->lvm_obj = lvm;
- return (PyObject *)self;
+ return (PyObject *)vgobj;
}
static PyObject *
-liblvm_lvm_vg_create(lvmobject *lvm, PyObject *args)
+liblvm_lvm_vg_create(PyObject *self, PyObject *args)
{
const char *vgname;
- vgobject *self;
+ vgobject *vgobj;
- LVM_VALID(lvm);
+ LVM_VALID();
if (!PyArg_ParseTuple(args, "s", &vgname)) {
return NULL;
}
- if ((self = PyObject_New(vgobject, &LibLVMvgType)) == NULL)
+ if ((vgobj = PyObject_New(vgobject, &LibLVMvgType)) == NULL)
return NULL;
- if ((self->vg = lvm_vg_create(lvm->libh, vgname))== NULL) {
- PyErr_SetObject(LibLVMError, liblvm_get_last_error(lvm));
- Py_DECREF(self);
+ if ((vgobj->vg = lvm_vg_create(libh, vgname))== NULL) {
+ PyErr_SetObject(LibLVMError, liblvm_get_last_error());
return NULL;
}
- self->lvm_obj = lvm;
- return (PyObject *)self;
+ return (PyObject *)vgobj;
}
static void
@@ -462,7 +402,7 @@ liblvm_lvm_vg_remove(vgobject *self)
return Py_None;
error:
- PyErr_SetObject(LibLVMError, liblvm_get_last_error(self->lvm_obj));
+ PyErr_SetObject(LibLVMError, liblvm_get_last_error());
return NULL;
}
@@ -488,7 +428,7 @@ liblvm_lvm_vg_extend(vgobject *self, PyObject *args)
return Py_None;
error:
- PyErr_SetObject(LibLVMError, liblvm_get_last_error(self->lvm_obj));
+ PyErr_SetObject(LibLVMError, liblvm_get_last_error());
return NULL;
}
@@ -514,7 +454,7 @@ liblvm_lvm_vg_reduce(vgobject *self, PyObject *args)
return Py_None;
error:
- PyErr_SetObject(LibLVMError, liblvm_get_last_error(self->lvm_obj));
+ PyErr_SetObject(LibLVMError, liblvm_get_last_error());
return NULL;
}
@@ -538,7 +478,7 @@ liblvm_lvm_vg_add_tag(vgobject *self, PyObject *args)
return Py_BuildValue("i", rval);
error:
- PyErr_SetObject(LibLVMError, liblvm_get_last_error(self->lvm_obj));
+ PyErr_SetObject(LibLVMError, liblvm_get_last_error());
return NULL;
}
@@ -564,7 +504,7 @@ liblvm_lvm_vg_remove_tag(vgobject *self, PyObject *args)
return Py_None;
error:
- PyErr_SetObject(LibLVMError, liblvm_get_last_error(self->lvm_obj));
+ PyErr_SetObject(LibLVMError, liblvm_get_last_error());
return NULL;
}
@@ -658,13 +598,13 @@ liblvm_lvm_vg_get_free_extent_count(vgobject *self)
/* Builds a python tuple ([string|number], bool) from a struct lvm_property_value */
static PyObject *
-get_property(lvmobject *h, struct lvm_property_value *prop)
+get_property(struct lvm_property_value *prop)
{
PyObject *pytuple;
PyObject *setable;
if( !prop->is_valid ) {
- PyErr_SetObject(LibLVMError, liblvm_get_last_error(h));
+ PyErr_SetObject(LibLVMError, liblvm_get_last_error());
return NULL;
}
@@ -703,7 +643,7 @@ liblvm_lvm_vg_get_property(vgobject *self, PyObject *args)
return NULL;
prop_value = lvm_vg_get_property(self->vg, name);
- return get_property(self->lvm_obj, &prop_value);
+ return get_property(&prop_value);
}
static PyObject *
@@ -791,7 +731,7 @@ liblvm_lvm_vg_set_property(vgobject *self, PyObject *args)
return Py_None;
lvmerror:
- PyErr_SetObject(LibLVMError, liblvm_get_last_error(self->lvm_obj));
+ PyErr_SetObject(LibLVMError, liblvm_get_last_error());
bail:
free(string_value);
if( variant_type_arg ) {
@@ -838,7 +778,7 @@ liblvm_lvm_vg_set_extent_size(vgobject *self, PyObject *args)
}
if ((rval = lvm_vg_set_extent_size(self->vg, new_size)) == -1) {
- PyErr_SetObject(LibLVMError, liblvm_get_last_error(self->lvm_obj));
+ PyErr_SetObject(LibLVMError, liblvm_get_last_error());
return NULL;
}
@@ -875,7 +815,6 @@ liblvm_lvm_vg_list_lvs(vgobject *vg)
}
self->lv = lvl->lv;
- self->lvm_obj = vg->lvm_obj;
PyTuple_SET_ITEM(pytuple, i, (PyObject *) self);
i++;
}
@@ -895,7 +834,7 @@ liblvm_lvm_vg_get_tags(vgobject *self)
tags = lvm_vg_get_tags(self->vg);
if (!tags) {
- PyErr_SetObject(LibLVMError, liblvm_get_last_error(self->lvm_obj));
+ PyErr_SetObject(LibLVMError, liblvm_get_last_error());
return NULL;
}
@@ -928,11 +867,10 @@ liblvm_lvm_vg_create_lv_linear(vgobject *vg, PyObject *args)
return NULL;
if ((self->lv = lvm_vg_create_lv_linear(vg->vg, vgname, size))== NULL) {
- PyErr_SetObject(LibLVMError, liblvm_get_last_error(vg->lvm_obj));
+ PyErr_SetObject(LibLVMError, liblvm_get_last_error());
Py_DECREF(self);
return NULL;
}
- self->lvm_obj = vg->lvm_obj;
return (PyObject *)self;
}
@@ -972,7 +910,6 @@ liblvm_lvm_vg_list_pvs(vgobject *vg)
}
self->pv = pvl->pv;
- self->lvm_obj = vg->lvm_obj;
PyTuple_SET_ITEM(pytuple, i, (PyObject *) self);
i++;
}
@@ -997,7 +934,7 @@ liblvm_lvm_lv_from_N(vgobject *self, PyObject *arg, lv_fetch_by_N method)
lv = method(self->vg, id);
if( !lv ) {
- PyErr_SetObject(LibLVMError, liblvm_get_last_error(self->lvm_obj));
+ PyErr_SetObject(LibLVMError, liblvm_get_last_error());
return NULL;
}
@@ -1007,7 +944,6 @@ liblvm_lvm_lv_from_N(vgobject *self, PyObject *arg, lv_fetch_by_N method)
}
rc->lv = lv;
- rc->lvm_obj = self->lvm_obj;
return (PyObject *)rc;
}
@@ -1037,7 +973,7 @@ liblvm_lvm_pv_from_N(vgobject *self, PyObject *arg, pv_fetch_by_N method)
pv = method(self->vg, id);
if( !pv ) {
- PyErr_SetObject(LibLVMError, liblvm_get_last_error(self->lvm_obj));
+ PyErr_SetObject(LibLVMError, liblvm_get_last_error());
return NULL;
}
@@ -1047,7 +983,6 @@ liblvm_lvm_pv_from_N(vgobject *self, PyObject *arg, pv_fetch_by_N method)
}
rc->pv = pv;
- rc->lvm_obj = self->lvm_obj;
return (PyObject *)rc;
}
@@ -1104,7 +1039,7 @@ liblvm_lvm_lv_activate(lvobject *self)
LV_VALID(self);
if ((rval = lvm_lv_activate(self->lv)) == -1) {
- PyErr_SetObject(LibLVMError, liblvm_get_last_error(self->lvm_obj));
+ PyErr_SetObject(LibLVMError, liblvm_get_last_error());
return NULL;
}
@@ -1120,7 +1055,7 @@ liblvm_lvm_lv_deactivate(lvobject *self)
LV_VALID(self);
if ((rval = lvm_lv_deactivate(self->lv)) == -1) {
- PyErr_SetObject(LibLVMError, liblvm_get_last_error(self->lvm_obj));
+ PyErr_SetObject(LibLVMError, liblvm_get_last_error());
return NULL;
}
@@ -1136,7 +1071,7 @@ liblvm_lvm_vg_remove_lv(lvobject *self)
LV_VALID(self);
if ((rval = lvm_vg_remove_lv(self->lv)) == -1) {
- PyErr_SetObject(LibLVMError, liblvm_get_last_error(self->lvm_obj));
+ PyErr_SetObject(LibLVMError, liblvm_get_last_error());
return NULL;
}
@@ -1149,7 +1084,7 @@ liblvm_lvm_vg_remove_lv(lvobject *self)
/* This will return a tuple of (value, bool) with the value being a string or
integer and bool indicating if property is settable */
static PyObject *
-liblvm_lvm_lv_get_property(lvobject *self, PyObject *args)
+liblvm_lvm_lv_get_property(lvobject *self, PyObject *args)
{
const char *name;
struct lvm_property_value prop_value;
@@ -1160,7 +1095,7 @@ liblvm_lvm_lv_get_property(lvobject *self, PyObject *args)
return NULL;
prop_value = lvm_lv_get_property(self->lv, name);
- return get_property(self->lvm_obj, &prop_value);
+ return get_property(&prop_value);
}
static PyObject *
@@ -1210,7 +1145,7 @@ liblvm_lvm_lv_add_tag(lvobject *self, PyObject *args)
}
if ((rval = lvm_lv_add_tag(self->lv, tag)) == -1) {
- PyErr_SetObject(LibLVMError, liblvm_get_last_error(self->lvm_obj));
+ PyErr_SetObject(LibLVMError, liblvm_get_last_error());
return NULL;
}
@@ -1231,7 +1166,7 @@ liblvm_lvm_lv_remove_tag(lvobject *self, PyObject *args)
}
if ((rval = lvm_lv_remove_tag(self->lv, tag)) == -1) {
- PyErr_SetObject(LibLVMError, liblvm_get_last_error(self->lvm_obj));
+ PyErr_SetObject(LibLVMError, liblvm_get_last_error());
return NULL;
}
@@ -1251,7 +1186,7 @@ liblvm_lvm_lv_get_tags(lvobject *self)
tags = lvm_lv_get_tags(self->lv);
if (!tags) {
- PyErr_SetObject(LibLVMError, liblvm_get_last_error(self->lvm_obj));
+ PyErr_SetObject(LibLVMError, liblvm_get_last_error());
return NULL;
}
@@ -1279,7 +1214,7 @@ liblvm_lvm_lv_rename(lvobject *self, PyObject *args)
return NULL;
if ((rval = lvm_lv_rename(self->lv, new_name)) == -1) {
- PyErr_SetObject(LibLVMError, liblvm_get_last_error(self->lvm_obj));
+ PyErr_SetObject(LibLVMError, liblvm_get_last_error());
return NULL;
}
@@ -1300,7 +1235,7 @@ liblvm_lvm_lv_resize(lvobject *self, PyObject *args)
}
if ((rval = lvm_lv_resize(self->lv, new_size)) == -1) {
- PyErr_SetObject(LibLVMError, liblvm_get_last_error(self->lvm_obj));
+ PyErr_SetObject(LibLVMError, liblvm_get_last_error());
return NULL;
}
@@ -1337,7 +1272,6 @@ liblvm_lvm_lv_list_lvsegs(lvobject *lv)
}
self->lv_seg = lvsegl->lvseg;
- self->lvm_obj = lv->lvm_obj;
PyTuple_SET_ITEM(pytuple, i, (PyObject *) self);
i++;
}
@@ -1349,7 +1283,7 @@ liblvm_lvm_lv_list_lvsegs(lvobject *lv)
#define PV_VALID(pvobject) \
do { \
- if (!pvobject->pv || !pvobject->lvm_obj) { \
+ if (!pvobject->pv || !libh) { \
PyErr_SetString(PyExc_UnboundLocalError, "PV object invalid"); \
return NULL; \
} \
@@ -1385,7 +1319,7 @@ liblvm_lvm_pv_get_property(pvobject *self, PyObject *args)
return NULL;
prop_value = lvm_pv_get_property(self->pv, name);
- return get_property(self->lvm_obj, &prop_value);
+ return get_property(&prop_value);
}
static PyObject *
@@ -1417,7 +1351,7 @@ liblvm_lvm_pv_resize(pvobject *self, PyObject *args)
}
if ((rval = lvm_pv_resize(self->pv, new_size)) == -1) {
- PyErr_SetObject(LibLVMError, liblvm_get_last_error(self->lvm_obj));
+ PyErr_SetObject(LibLVMError, liblvm_get_last_error());
return NULL;
}
@@ -1454,7 +1388,6 @@ liblvm_lvm_lv_list_pvsegs(pvobject *pv)
}
self->pv_seg = pvsegl->pvseg;
- self->lvm_obj = pv->lvm_obj;
PyTuple_SET_ITEM(pytuple, i, (PyObject *) self);
i++;
}
@@ -1480,7 +1413,7 @@ liblvm_lvm_lvseg_get_property(lvsegobject *self, PyObject *args)
return NULL;
prop_value = lvm_lvseg_get_property(self->lv_seg, name);
- return get_property(self->lvm_obj, &prop_value);
+ return get_property(&prop_value);
}
/* PV seg methods */
@@ -1501,7 +1434,7 @@ liblvm_lvm_pvseg_get_property(pvsegobject *self, PyObject *args)
return NULL;
prop_value = lvm_pvseg_get_property(self->pv_seg, name);
- return get_property(self->lvm_obj, &prop_value);
+ return get_property(&prop_value);
}
/* ----------------------------------------------------------------------
@@ -1513,7 +1446,6 @@ static PyMethodDef Liblvm_methods[] = {
{ "getVersion", (PyCFunction)liblvm_library_get_version, METH_NOARGS },
{ "vgOpen", (PyCFunction)liblvm_lvm_vg_open, METH_VARARGS },
{ "vgCreate", (PyCFunction)liblvm_lvm_vg_create, METH_VARARGS },
- { "close", (PyCFunction)liblvm_close, METH_NOARGS },
{ "configFindBool", (PyCFunction)liblvm_lvm_config_find_bool, METH_VARARGS },
{ "configReload", (PyCFunction)liblvm_lvm_config_reload, METH_NOARGS },
{ "configOverride", (PyCFunction)liblvm_lvm_config_override, METH_VARARGS },
@@ -1606,18 +1538,6 @@ static PyMethodDef liblvm_pvseg_methods[] = {
{ NULL, NULL} /* sentinel */
};
-static PyTypeObject LiblvmType = {
- PyObject_HEAD_INIT(&PyType_Type)
- .tp_name = "liblvm.Liblvm",
- .tp_basicsize = sizeof(lvmobject),
- .tp_new = PyType_GenericNew,
- .tp_dealloc = (destructor)liblvm_dealloc,
- .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
- .tp_doc = "Liblvm objects",
- .tp_methods = Liblvm_methods,
- .tp_init = (initproc)liblvm_init,
-};
-
static PyTypeObject LibLVMvgType = {
PyObject_HEAD_INIT(&PyType_Type)
.tp_name = "liblvm.Liblvm_vg",
@@ -1673,13 +1593,20 @@ static PyTypeObject LibLVMpvsegType = {
.tp_methods = liblvm_pvseg_methods,
};
+static void
+liblvm_cleanup(void)
+{
+ lvm_quit(libh);
+ libh = NULL;
+}
+
PyMODINIT_FUNC
initlvm(void)
{
PyObject *m;
- if (PyType_Ready(&LiblvmType) < 0)
- return;
+ libh = lvm_init(NULL);
+
if (PyType_Ready(&LibLVMvgType) < 0)
return;
if (PyType_Ready(&LibLVMlvType) < 0)
@@ -1695,9 +1622,6 @@ initlvm(void)
if (m == NULL)
return;
- Py_INCREF(&LiblvmType);
- PyModule_AddObject(m, "Liblvm", (PyObject *)&LiblvmType);
-
LibLVMError = PyErr_NewException("Liblvm.LibLVMError",
NULL, NULL);
if (LibLVMError) {
@@ -1708,4 +1632,5 @@ initlvm(void)
PyModule_AddObject(m, "LibLVMError", LibLVMError);
}
+ Py_AtExit(liblvm_cleanup);
}

View File

@ -1,103 +0,0 @@
commit 10ba799ab08001d5435425e65f039f20cadd306e
Author: Tony Asleson <tasleson@redhat.com>
Date: Mon Oct 15 13:54:19 2012 -0700
python-lvm: Update example to work with lvm object removal.
Signed-off-by: Tony Asleson <tasleson@redhat.com>
Signed-off-by: Andy Grover <agrover@redhat.com>
---
python/example.py | 35 +++++++++++++++--------------------
1 file changed, 15 insertions(+), 20 deletions(-)
diff --git a/python/example.py b/python/example.py
index 67bb7e4..5c14ee1 100644
--- a/python/example.py
+++ b/python/example.py
@@ -31,9 +31,9 @@ def print_pv(pv):
#Dump some information about a specific volume group
-def print_vg(h, vg_name):
+def print_vg(vg_name):
#Open read only
- vg = h.vgOpen(vg_name, 'r')
+ vg = lvm.vgOpen(vg_name, 'r')
print 'Volume group:', vg_name, 'Size: ', vg.getSize()
@@ -55,13 +55,13 @@ def print_vg(h, vg_name):
vg.close()
#Returns the name of a vg with space available
-def find_vg_with_free_space(h):
+def find_vg_with_free_space():
free_space = 0
rc = None
- vg_names = l.listVgNames()
+ vg_names = lvm.listVgNames()
for v in vg_names:
- vg = h.vgOpen(v, 'r')
+ vg = lvm.vgOpen(v, 'r')
c_free = vg.getFreeSize()
if c_free > free_space:
free_space = c_free
@@ -72,13 +72,13 @@ def find_vg_with_free_space(h):
#Walk through the volume groups and fine one with space in which we can
#create a new logical volume
-def create_delete_logical_volume(h):
- vg_name = find_vg_with_free_space(h)
+def create_delete_logical_volume():
+ vg_name = find_vg_with_free_space()
print 'Using volume group ', vg_name, ' for example'
if vg_name:
- vg = h.vgOpen(vg_name, 'w')
+ vg = lvm.vgOpen(vg_name, 'w')
lv = vg.createLvLinear('python_lvm_ok_to_delete', vg.getFreeSize())
if lv:
@@ -93,11 +93,11 @@ def create_delete_logical_volume(h):
#Remove tag
lv.removeTag(t)
+ lv.deactivate()
+
#Try to rename
- lv.rename("python_lvm_ok_to_be_removed_shortly")
+ lv.rename("python_lvm_renamed")
print 'LV name= ', lv.getName()
-
- lv.deactivate()
lv.remove()
vg.close()
@@ -105,21 +105,16 @@ def create_delete_logical_volume(h):
print 'No free space available to create demo lv!'
if __name__ == '__main__':
- #Create a new LVM instance
- l = lvm.Liblvm()
-
#What version
- print 'lvm version=', l.getVersion()
+ print 'lvm version=', lvm.getVersion()
#Get a list of volume group names
- vg_names = l.listVgNames()
+ vg_names = lvm.listVgNames()
#For each volume group display some information about each of them
for vg_i in vg_names:
- print_vg(l, vg_i)
+ print_vg(vg_i)
#Demo creating a logical volume
- create_delete_logical_volume(l)
+ create_delete_logical_volume()
- #Close
- l.close()

View File

@ -1,205 +0,0 @@
commit 12b631a6768e6f2a2005ef8ea91c0afbc2455c54
Author: Andy Grover <agrover@redhat.com>
Date: Mon Oct 15 13:34:43 2012 -0700
python-lvm: whitespace and Yoda conditionals
Signed-off-by: Andy Grover <agrover@redhat.com>
---
python/liblvm.c | 50 ++++++++++++++++++++++++--------------------------
1 file changed, 24 insertions(+), 26 deletions(-)
diff --git a/python/liblvm.c b/python/liblvm.c
index 4518cf4..8a73ced 100644
--- a/python/liblvm.c
+++ b/python/liblvm.c
@@ -75,7 +75,7 @@ liblvm_get_last_error(void)
LVM_VALID();
- if((info = PyTuple_New(2)) == NULL)
+ if ((info = PyTuple_New(2)) == NULL)
return NULL;
PyTuple_SetItem(info, 0, PyInt_FromLong((long) lvm_errno(libh)));
@@ -174,7 +174,7 @@ liblvm_lvm_vgname_from_pvid(PyObject *self, PyObject *arg)
if (!PyArg_ParseTuple(arg, "s", &pvid))
return NULL;
- if((vgname = lvm_vgname_from_pvid(libh, pvid)) == NULL) {
+ if ((vgname = lvm_vgname_from_pvid(libh, pvid)) == NULL) {
PyErr_SetObject(LibLVMError, liblvm_get_last_error());
return NULL;
}
@@ -193,7 +193,7 @@ liblvm_lvm_vgname_from_device(PyObject *self, PyObject *arg)
if (!PyArg_ParseTuple(arg, "s", &device))
return NULL;
- if((vgname = lvm_vgname_from_device(libh, device)) == NULL) {
+ if ((vgname = lvm_vgname_from_device(libh, device)) == NULL) {
PyErr_SetObject(LibLVMError, liblvm_get_last_error());
return NULL;
}
@@ -233,7 +233,7 @@ liblvm_lvm_config_reload(void)
LVM_VALID();
- if((rval = lvm_config_reload(libh)) == -1) {
+ if ((rval = lvm_config_reload(libh)) == -1) {
PyErr_SetObject(LibLVMError, liblvm_get_last_error());
return NULL;
}
@@ -250,7 +250,7 @@ liblvm_lvm_scan(void)
LVM_VALID();
- if((rval = lvm_scan(libh)) == -1) {
+ if ((rval = lvm_scan(libh)) == -1) {
PyErr_SetObject(LibLVMError, liblvm_get_last_error());
return NULL;
}
@@ -603,7 +603,7 @@ get_property(struct lvm_property_value *prop)
PyObject *pytuple;
PyObject *setable;
- if( !prop->is_valid ) {
+ if (!prop->is_valid) {
PyErr_SetObject(LibLVMError, liblvm_get_last_error());
return NULL;
}
@@ -612,7 +612,7 @@ get_property(struct lvm_property_value *prop)
if (!pytuple)
return NULL;
- if( prop->is_integer ) {
+ if (prop->is_integer) {
PyTuple_SET_ITEM(pytuple, 0, Py_BuildValue("K", prop->value.integer));
} else {
PyTuple_SET_ITEM(pytuple, 0, PyString_FromString(prop->value.string));
@@ -661,11 +661,11 @@ liblvm_lvm_vg_set_property(vgobject *self, PyObject *args)
lvm_property = lvm_vg_get_property(self->vg, property_name);
- if( !lvm_property.is_valid ) {
+ if (!lvm_property.is_valid ) {
goto lvmerror;
}
- if(PyObject_IsInstance(variant_type_arg, (PyObject*)&PyString_Type)) {
+ if (PyObject_IsInstance(variant_type_arg, (PyObject*)&PyString_Type)) {
if (!lvm_property.is_string) {
PyErr_Format(PyExc_ValueError, "Property requires string value");
@@ -676,7 +676,7 @@ liblvm_lvm_vg_set_property(vgobject *self, PyObject *args)
leak when calling into set_property, need to verify*/
string_value = strdup(PyString_AsString(variant_type_arg));
lvm_property.value.string = string_value;
- if(!lvm_property.value.string) {
+ if (!lvm_property.value.string) {
PyErr_NoMemory();
goto bail;
}
@@ -688,14 +688,12 @@ liblvm_lvm_vg_set_property(vgobject *self, PyObject *args)
goto bail;
}
- if(PyObject_IsInstance(variant_type_arg, (PyObject*)&PyInt_Type)) {
+ if (PyObject_IsInstance(variant_type_arg, (PyObject*)&PyInt_Type)) {
int temp_py_int = PyInt_AsLong(variant_type_arg);
/* -1 could be valid, need to see if an exception was gen. */
- if( -1 == temp_py_int ) {
- if( PyErr_Occurred() ) {
- goto bail;
- }
+ if (temp_py_int == -1 && PyErr_Occurred()) {
+ goto bail;
}
if (temp_py_int < 0) {
@@ -704,10 +702,10 @@ liblvm_lvm_vg_set_property(vgobject *self, PyObject *args)
}
lvm_property.value.integer = temp_py_int;
- } else if(PyObject_IsInstance(variant_type_arg, (PyObject*)&PyLong_Type)){
+ } else if (PyObject_IsInstance(variant_type_arg, (PyObject*)&PyLong_Type)){
/* This will fail on negative numbers */
unsigned long long temp_py_long = PyLong_AsUnsignedLongLong(variant_type_arg);
- if( (unsigned long long)-1 == temp_py_long ) {
+ if (temp_py_long == (unsigned long long)-1) {
goto bail;
}
@@ -718,11 +716,11 @@ liblvm_lvm_vg_set_property(vgobject *self, PyObject *args)
}
}
- if( -1 == lvm_vg_set_property(self->vg, property_name, &lvm_property) ) {
+ if (lvm_vg_set_property(self->vg, property_name, &lvm_property) == -1) {
goto lvmerror;
}
- if( -1 == lvm_vg_write(self->vg)) {
+ if (lvm_vg_write(self->vg) == -1) {
goto lvmerror;
}
@@ -734,7 +732,7 @@ lvmerror:
PyErr_SetObject(LibLVMError, liblvm_get_last_error());
bail:
free(string_value);
- if( variant_type_arg ) {
+ if (variant_type_arg) {
Py_DECREF(variant_type_arg);
variant_type_arg = NULL;
}
@@ -933,13 +931,13 @@ liblvm_lvm_lv_from_N(vgobject *self, PyObject *arg, lv_fetch_by_N method)
return NULL;
lv = method(self->vg, id);
- if( !lv ) {
+ if (!lv) {
PyErr_SetObject(LibLVMError, liblvm_get_last_error());
return NULL;
}
rc = PyObject_New(lvobject, &LibLVMlvType);
- if( !rc ) {
+ if (!rc) {
return NULL;
}
@@ -972,13 +970,13 @@ liblvm_lvm_pv_from_N(vgobject *self, PyObject *arg, pv_fetch_by_N method)
return NULL;
pv = method(self->vg, id);
- if( !pv ) {
+ if (!pv) {
PyErr_SetObject(LibLVMError, liblvm_get_last_error());
return NULL;
}
rc = PyObject_New(pvobject, &LibLVMpvType);
- if( !rc ) {
+ if (!rc) {
return NULL;
}
@@ -1255,7 +1253,7 @@ liblvm_lvm_lv_list_lvsegs(lvobject *lv)
LV_VALID(lv);
lvsegs = lvm_lv_list_lvsegs(lv->lv);
- if(!lvsegs) {
+ if (!lvsegs) {
return Py_BuildValue("()");
}
@@ -1371,7 +1369,7 @@ liblvm_lvm_lv_list_pvsegs(pvobject *pv)
PV_VALID(pv);
pvsegs = lvm_pv_list_pvsegs(pv->pv);
- if(!pvsegs) {
+ if (!pvsegs) {
return Py_BuildValue("()");
}

View File

@ -1,27 +0,0 @@
WHATS_NEW | 1 +
lib/mm/memlock.c | 1 +
2 files changed, 2 insertions(+)
diff --git a/WHATS_NEW b/WHATS_NEW
index e247391..67a24c7 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.99 -
===================================
+ Skip mlocking [vectors] on arm architecture.
Exit pvscan --cache immediately if cluster locking used or lvmetad not used.
Don't use lvmetad in lvm2-monitor.service ExecStop to avoid a systemd issue.
Remove dependency on fedora-storage-init.service in lvm2 systemd units.
diff --git a/lib/mm/memlock.c b/lib/mm/memlock.c
index 2240a1d..6d0996a 100644
--- a/lib/mm/memlock.c
+++ b/lib/mm/memlock.c
@@ -84,6 +84,7 @@ static int _default_priority;
static const char * const _ignore_maps[] = {
"[vdso]",
"[vsyscall]",
+ "[vectors]",
};
/* default blacklist for maps */

View File

@ -1,33 +0,0 @@
commit 0bcd33ecffb97f09e1ffb75868844cea40f3cd77
Author: Peter Rajnoha <prajnoha@redhat.com>
Date: Tue Apr 9 10:07:49 2013 +0200
1
---
WHATS_NEW | 1 +
tools/pvscan.c | 1 +
2 files changed, 2 insertions(+)
diff --git a/WHATS_NEW b/WHATS_NEW
index c481e68..03345d8 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.99 -
===================================
+ Synchronize with udev in pvscan --cache and fix dangling udev_sync cookies.
Fix autoactivation to not autoactivate VG/LV on each change of the PVs used.
Skip mlocking [vectors] on arm architecture.
Exit pvscan --cache immediately if cluster locking used or lvmetad not used.
diff --git a/tools/pvscan.c b/tools/pvscan.c
index 34ab792..fbd524b 100644
--- a/tools/pvscan.c
+++ b/tools/pvscan.c
@@ -223,6 +223,7 @@ static int _pvscan_lvmetad(struct cmd_context *cmd, int argc, char **argv)
}
out:
+ sync_local_dev_names(cmd);
unlock_vg(cmd, VG_GLOBAL);
return ret;

View File

@ -1,48 +0,0 @@
commit 8dedeaa0183d2c87764a4012e443af9597d28575
Author: Peter Rajnoha <prajnoha@redhat.com>
Date: Wed Oct 31 14:15:54 2012 +0100
0
---
WHATS_NEW | 3 +++
scripts/lvm2_monitoring_systemd_red_hat.service.in | 7 ++++---
2 files changed, 7 insertions(+), 3 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index d0e0cd4..12307ed 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,8 @@
Version 2.02.99 -
===================================
+ Don't use lvmetad in lvm2-monitor.service ExecStop to avoid a systemd issue.
+ Remove dependency on fedora-storage-init.service in lvm2 systemd units.
+ Depend on lvm2-lvmetad.socket in lvm2-monitor.service systemd unit.
Initialize lvmetad lazily to avoid early socket access on config overrides.
Hardcode use_lvmetad=0 if cluster locking used and issue a warning msg.
diff --git a/scripts/lvm2_monitoring_systemd_red_hat.service.in b/scripts/lvm2_monitoring_systemd_red_hat.service.in
index 6c4c55f..e6b4814 100644
--- a/scripts/lvm2_monitoring_systemd_red_hat.service.in
+++ b/scripts/lvm2_monitoring_systemd_red_hat.service.in
@@ -1,8 +1,8 @@
[Unit]
Description=Monitoring of LVM2 mirrors, snapshots etc. using dmeventd or progress polling
Documentation=man:dmeventd(8) man:lvcreate(8) man:lvchange(8) man:vgchange(8)
-Requires=dm-event.socket
-After=dm-event.socket fedora-storage-init.service fedora-storage-init-late.service lvm2-activation.service lvm2-lvmetad.service
+Requires=dm-event.socket lvm2-lvmetad.socket
+After=dm-event.socket lvm2-lvmetad.socket lvm2-activation.service lvm2-lvmetad.service
Before=local-fs.target
DefaultDependencies=no
Conflicts=shutdown.target
@@ -11,7 +11,8 @@ Conflicts=shutdown.target
Type=oneshot
Environment=LVM_SUPPRESS_LOCKING_FAILURE_MESSAGES=1
ExecStart=@sbindir@/lvm vgchange --monitor y
-ExecStop=@sbindir@/lvm vgchange --monitor n
+# The lvmetad must be disabled here, it needs https://bugzilla.redhat.com/show_bug.cgi?id=843587 to be resolved first.
+ExecStop=@sbindir@/lvm vgchange --monitor n --config 'global{use_lvmetad=0}'
RemainAfterExit=yes
[Install]

View File

@ -1,30 +0,0 @@
doc/example.conf.in | 2 +-
lib/commands/toolcontext.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/doc/example.conf.in b/doc/example.conf.in
index 10cfe16..442ad64 100644
--- a/doc/example.conf.in
+++ b/doc/example.conf.in
@@ -491,7 +491,7 @@ global {
#
# If lvmetad has been running while use_lvmetad was 0, it MUST be stopped
# before changing use_lvmetad to 1 and started again afterwards.
- use_lvmetad = 0
+ use_lvmetad = 1
# Full path of the utility called to check that a thin metadata device
# is in a state that allows it to be used.
diff --git a/lib/commands/toolcontext.c b/lib/commands/toolcontext.c
index d72b0c0..d7f8ece 100644
--- a/lib/commands/toolcontext.c
+++ b/lib/commands/toolcontext.c
@@ -413,7 +413,7 @@ static int _process_config(struct cmd_context *cmd)
lvmetad_set_socket(lvmetad_socket);
cn = find_config_tree_node(cmd, "devices/global_filter");
lvmetad_set_token(cn ? cn->v : NULL);
- lvmetad_set_active(find_config_tree_int(cmd, "global/use_lvmetad", 0));
+ lvmetad_set_active(find_config_tree_int(cmd, "global/use_lvmetad", 1));
lvmetad_init(cmd);
return 1;

View File

@ -1,15 +0,0 @@
--- LVM2.2.02.58/doc/example.conf.in 2010-01-07 19:54:21.000000000 +0000
+++ LVM2.2.02.58-new/doc/example.conf.in 2010-01-20 18:30:32.000000000 +0000
@@ -23,10 +23,10 @@
# same block device and the tools need to display a name for device,
# all the pathnames are matched against each item in the following
# list of regular expressions in turn and the first match is used.
- preferred_names = [ ]
+ # preferred_names = [ ]
# Try to avoid using undescriptive /dev/dm-N names, if present.
- # preferred_names = [ "^/dev/mpath/", "^/dev/mapper/mpath", "^/dev/[hs]d" ]
+ preferred_names = [ "^/dev/mpath/", "^/dev/mapper/mpath", "^/dev/[hs]d" ]
# A filter that tells LVM2 to only use a restricted set of devices.
# The filter consists of an array of regular expressions. These

View File

@ -1,29 +0,0 @@
lvm2-set-default-preferred_names.patch
lvm2-enable-lvmetad-by-default.patch
lvm2-2_02_99-python-remove-liblvm-object.patch
lvm2-2_02_99-python-whitespace-and-conditional-cleanup.patch
lvm2-2_02_99-python-update-example-to-work-with-lvm-object-removal.patch
lvm2-2_02_99-python-implement-proper-refcounting-for-parent-objects.patch
lvm2-2_02_99-properly-set-cookie_set-var-on-dm_task_set_cookie-call.patch
lvm2-2_02_99-hardcode-use_lvmetad0-if-cluster-locking-used-and-issue-warning-msg.patch
lvm2-2_02_99-init-lvmetad-lazily-to-avoid-early-socket-access-on-config-overrides.patch
lvm2-2_02_99-various-updates-and-fixes-for-systemd-units.patch
lvm2-2_02_99-exit-pvscan-cache-immediately-if-cluster-locking-used-or-lvmetad-not-used.patch
lvm2-2_02_99-skip-mlocking-verctors-on-arm-arch.patch
lvm2-2_02_99-fix-autoactivation-to-not-autoactivate-vg-lv-on-each-pv-change.patch
lvm2-2_02_99-synchronize-with-udev-in-pvscan-cache-and-fix-dangling-udev_sync-cookies.patch
lvm2-2_02_99-also-autoactivate-on-coldplug.patch
lvm2-2_02_99-fire-pvscan-cache-on-change-event-for-md-devs.patch
lvm2-2_02_99-various-thin-support-related-fixes.patch
lvm2-2_02_99-fix-lv_is_active-in-lvcreate.patch
lvm2-2_02_99-fix-crash-in-pvscan-cache-aay-triggered-by-non-mda-pv.patch
lvm2-2_02_99-avoid-global-lock-in-pvs-when-lvmetad-is-in-use.patch
lvm2-2_02_99-fix-possible-deadlock-in-lvmetad-for-parallel-update-and-query.patch
lvm2-2_02_99-fix-possible-race-in-lvmetad-remove_metadata.patch
lvm2-2_02_99-lvmetad-fix-a-race-in-metadata-update.patch
lvm2-2_02_99-fix-handling-of-reappeared-and-missing-pvs-in-lvmetad.patch
lvm2-2_02_99-fix-blkdeactivate-handling-of-nested-mountpoints-and-mangled-mount-paths.patch
lvm2-2_02_99-add-dm-disable-udev-env-var-and-fix-noudevsync-arg.patch
lvm2-2_02_99-fix-premature-dm-version-checking-which-caused-useless-mapper-control-access.patch
lvm2-2_02_99-close-dmeventd-fifo-fds-on-exec.patch
lvm2-2_02_99-fix-dmsetup-splitname-to-not-fail-if-used-without-c-switch.patch

View File

@ -1,7 +1,7 @@
# Template file for 'lvm2'
pkgname=lvm2
version=2.02.98
revision=5
version=2.02.99
revision=1
patch_args="-Np1"
wrksrc=LVM2.${version}
build_style=gnu-configure
@ -19,7 +19,7 @@ maintainer="Juan RP <xtraeme@gmail.com>"
homepage="http://sourceware.org/lvm2/"
license="GPL-2, LGPL-2.1"
distfiles="ftp://sources.redhat.com/pub/lvm2/LVM2.${version}.tgz"
checksum=71030a58fef7e00d82ca4144334548e46aad24551a3cfbe7c3059b1bd137d864
checksum=493c9ad85bada036418671072355b2fc57fc30eb5a63fd14a7dfe8ed28dca040
if [ "$CROSS_BUILD" ]; then
configure_args+=" ac_cv_func_malloc_0_nonnull=yes ac_cv_func_realloc_0_nonnull=yes"
@ -40,7 +40,7 @@ post_install() {
device-mapper-devel_package() {
depends="readline-devel ncurses-devel device-mapper-${version}_${revision}"
short_desc="Device Mapper userspace library -- development files"
short_desc="Device Mapper userspace library - development files"
pkg_install() {
vmove usr/lib/pkgconfig/devmapper.pc
vmove usr/lib/pkgconfig/devmapper-event.pc