master - cleanup: use const for cmd context
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=656ba3a744af55...
Commit: 656ba3a744af5548ee0a5983590698aeee3dd326
Parent: e2312d28ed031dd5c53084b4789763f3c5e6410c
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Fri Sep 19 14:29:12 2014 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Fri Sep 19 15:51:31 2014 +0200
cleanup: use const for cmd context
---
tools/lvmcmdline.c | 18 +++++++++---------
tools/tools.h | 20 ++++++++++----------
2 files changed, 19 insertions(+), 19 deletions(-)
diff --git a/tools/lvmcmdline.c b/tools/lvmcmdline.c
index 04598e2..d90ef91 100644
--- a/tools/lvmcmdline.c
+++ b/tools/lvmcmdline.c
@@ -137,12 +137,12 @@ const char *arg_long_option_name(int a)
return _cmdline.arg_props[a].long_arg;
}
-const char *arg_value(struct cmd_context *cmd, int a)
+const char *arg_value(const struct cmd_context *cmd, int a)
{
return cmd->arg_values[a].value;
}
-const char *arg_str_value(struct cmd_context *cmd, int a, const char *def)
+const char *arg_str_value(const struct cmd_context *cmd, int a, const char *def)
{
return arg_count(cmd, a) ? cmd->arg_values[a].value : def;
}
@@ -157,7 +157,7 @@ int32_t grouped_arg_int_value(const struct arg_values *av, int a, const int32_t
return grouped_arg_count(av, a) ? av[a].i_value : def;
}
-int32_t first_grouped_arg_int_value(struct cmd_context *cmd, int a, const int32_t def)
+int32_t first_grouped_arg_int_value(const struct cmd_context *cmd, int a, const int32_t def)
{
struct arg_value_group_list *current_group;
struct arg_values *av;
@@ -171,23 +171,23 @@ int32_t first_grouped_arg_int_value(struct cmd_context *cmd, int a, const int32_
return def;
}
-int32_t arg_int_value(struct cmd_context *cmd, int a, const int32_t def)
+int32_t arg_int_value(const struct cmd_context *cmd, int a, const int32_t def)
{
return (_cmdline.arg_props[a].flags & ARG_GROUPABLE) ?
first_grouped_arg_int_value(cmd, a, def) : (arg_count(cmd, a) ? cmd->arg_values[a].i_value : def);
}
-uint32_t arg_uint_value(struct cmd_context *cmd, int a, const uint32_t def)
+uint32_t arg_uint_value(const struct cmd_context *cmd, int a, const uint32_t def)
{
return arg_count(cmd, a) ? cmd->arg_values[a].ui_value : def;
}
-int64_t arg_int64_value(struct cmd_context *cmd, int a, const int64_t def)
+int64_t arg_int64_value(const struct cmd_context *cmd, int a, const int64_t def)
{
return arg_count(cmd, a) ? cmd->arg_values[a].i64_value : def;
}
-uint64_t arg_uint64_value(struct cmd_context *cmd, int a, const uint64_t def)
+uint64_t arg_uint64_value(const struct cmd_context *cmd, int a, const uint64_t def)
{
return arg_count(cmd, a) ? cmd->arg_values[a].ui64_value : def;
}
@@ -199,12 +199,12 @@ const void *arg_ptr_value(struct cmd_context *cmd, int a, const void *def)
}
*/
-sign_t arg_sign_value(struct cmd_context *cmd, int a, const sign_t def)
+sign_t arg_sign_value(const struct cmd_context *cmd, int a, const sign_t def)
{
return arg_count(cmd, a) ? cmd->arg_values[a].sign : def;
}
-percent_type_t arg_percent_value(struct cmd_context *cmd, int a, const percent_type_t def)
+percent_type_t arg_percent_value(const struct cmd_context *cmd, int a, const percent_type_t def)
{
return arg_count(cmd, a) ? cmd->arg_values[a].percent : def;
}
diff --git a/tools/tools.h b/tools/tools.h
index beb1671..51c6a4e 100644
--- a/tools/tools.h
+++ b/tools/tools.h
@@ -147,16 +147,16 @@ unsigned arg_is_set(const struct cmd_context *cmd, int a);
int arg_from_list_is_set(const struct cmd_context *cmd, const char *err_found, ...);
int arg_outside_list_is_set(const struct cmd_context *cmd, const char *err_found, ...);
const char *arg_long_option_name(int a);
-const char *arg_value(struct cmd_context *cmd, int a);
-const char *arg_str_value(struct cmd_context *cmd, int a, const char *def);
-int32_t arg_int_value(struct cmd_context *cmd, int a, const int32_t def);
-int32_t first_grouped_arg_int_value(struct cmd_context *cmd, int a, const int32_t def);
-uint32_t arg_uint_value(struct cmd_context *cmd, int a, const uint32_t def);
-int64_t arg_int64_value(struct cmd_context *cmd, int a, const int64_t def);
-uint64_t arg_uint64_value(struct cmd_context *cmd, int a, const uint64_t def);
-const void *arg_ptr_value(struct cmd_context *cmd, int a, const void *def);
-sign_t arg_sign_value(struct cmd_context *cmd, int a, const sign_t def);
-percent_type_t arg_percent_value(struct cmd_context *cmd, int a, const percent_type_t def);
+const char *arg_value(const struct cmd_context *cmd, int a);
+const char *arg_str_value(const struct cmd_context *cmd, int a, const char *def);
+int32_t arg_int_value(const struct cmd_context *cmd, int a, const int32_t def);
+int32_t first_grouped_arg_int_value(const struct cmd_context *cmd, int a, const int32_t def);
+uint32_t arg_uint_value(const struct cmd_context *cmd, int a, const uint32_t def);
+int64_t arg_int64_value(const struct cmd_context *cmd, int a, const int64_t def);
+uint64_t arg_uint64_value(const struct cmd_context *cmd, int a, const uint64_t def);
+const void *arg_ptr_value(const struct cmd_context *cmd, int a, const void *def);
+sign_t arg_sign_value(const struct cmd_context *cmd, int a, const sign_t def);
+percent_type_t arg_percent_value(const struct cmd_context *cmd, int a, const percent_type_t def);
int arg_count_increment(struct cmd_context *cmd, int a);
unsigned grouped_arg_count(const struct arg_values *av, int a);
8 years, 8 months
master - cleanup: switch to use CHANGE_AEY
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=e2312d28ed031d...
Commit: e2312d28ed031dd5c53084b4789763f3c5e6410c
Parent: f1e9e94a5b2d4aa6b7c454634c2b45b2a1082822
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Fri Sep 19 14:28:28 2014 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Fri Sep 19 15:51:31 2014 +0200
cleanup: switch to use CHANGE_AEY
Since for other enums we use 'Y' or 'N' use it with 'AE' as well.
---
lib/metadata/lv.c | 2 +-
lib/metadata/metadata-exported.h | 2 +-
tools/lvconvert.c | 2 +-
tools/lvmcmdline.c | 4 ++--
4 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/lib/metadata/lv.c b/lib/metadata/lv.c
index 3ebb14d..d29e787 100644
--- a/lib/metadata/lv.c
+++ b/lib/metadata/lv.c
@@ -888,7 +888,7 @@ deactivate:
return_0;
}
break;
- case CHANGE_AE:
+ case CHANGE_AEY:
exclusive:
log_verbose("Activating logical volume \"%s\" exclusively.",
lv->name);
diff --git a/lib/metadata/metadata-exported.h b/lib/metadata/metadata-exported.h
index 9dac46a..935d3f7 100644
--- a/lib/metadata/metadata-exported.h
+++ b/lib/metadata/metadata-exported.h
@@ -776,7 +776,7 @@ int is_mirror_image_removable(struct logical_volume *mimage_lv, void *baton);
typedef enum activation_change {
CHANGE_AY = 0, /* activate */
CHANGE_AN = 1, /* deactivate */
- CHANGE_AE = 2, /* activate exclusively */
+ CHANGE_AEY = 2, /* activate exclusively */
CHANGE_ALY = 3, /* activate locally */
CHANGE_ALN = 4, /* deactivate locally */
CHANGE_AAY = 5 /* automatic activation */
diff --git a/tools/lvconvert.c b/tools/lvconvert.c
index 2cd5ba6..6a2676b 100644
--- a/tools/lvconvert.c
+++ b/tools/lvconvert.c
@@ -2513,7 +2513,7 @@ static int _lvconvert_thin(struct cmd_context *cmd,
struct logical_volume *torigin_lv, *pool_lv = lp->pool_data_lv;
struct volume_group *vg = pool_lv->vg;
struct lvcreate_params lvc = {
- .activate = CHANGE_AE,
+ .activate = CHANGE_AEY,
.alloc = ALLOC_INHERIT,
.lv_name = lp->origin_lv_name,
.major = -1,
diff --git a/tools/lvmcmdline.c b/tools/lvmcmdline.c
index 14ea7a6..04598e2 100644
--- a/tools/lvmcmdline.c
+++ b/tools/lvmcmdline.c
@@ -242,8 +242,8 @@ int activation_arg(struct cmd_context *cmd __attribute__((unused)), struct arg_v
if (!strcmp(av->value, "e") || !strcmp(av->value, "ey") ||
!strcmp(av->value, "ye")) {
- av->i_value = CHANGE_AE;
- av->ui_value = CHANGE_AE;
+ av->i_value = CHANGE_AEY;
+ av->ui_value = CHANGE_AEY;
}
else if (!strcmp(av->value, "y")) {
8 years, 8 months
master - wipe_lv: move sync_local_dev_names in front
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=f1e9e94a5b2d4a...
Commit: f1e9e94a5b2d4aa6b7c454634c2b45b2a1082822
Parent: d8b775f4eb871e771c9f18dcd9f6b28509e7e52a
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Fri Sep 19 11:06:31 2014 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Fri Sep 19 15:51:30 2014 +0200
wipe_lv: move sync_local_dev_names in front
Synchronize things before checking for locally active volume.
---
lib/metadata/lv_manip.c | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/lib/metadata/lv_manip.c b/lib/metadata/lv_manip.c
index 2e683b9..968b8d0 100644
--- a/lib/metadata/lv_manip.c
+++ b/lib/metadata/lv_manip.c
@@ -6360,6 +6360,8 @@ int wipe_lv(struct logical_volume *lv, struct wipe_params wp)
/* nothing to do */
return 1;
+ sync_local_dev_names(lv->vg->cmd); /* Wait until devices are available */
+
if (!lv_is_active_locally(lv)) {
log_error("Volume \"%s/%s\" is not active locally.",
lv->vg->name, lv->name);
@@ -6379,8 +6381,6 @@ int wipe_lv(struct logical_volume *lv, struct wipe_params wp)
return 0;
}
- sync_local_dev_names(lv->vg->cmd); /* Wait until devices are available */
-
if (!(dev = dev_cache_get(name, NULL))) {
log_error("%s: not found: device not cleared", name);
return 0;
8 years, 8 months
master - memlock: drop uneeded lock
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=d8b775f4eb871e...
Commit: d8b775f4eb871e771c9f18dcd9f6b28509e7e52a
Parent: b0bd8ce4086531f4f83ce417ddb988d8b4e0907a
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Fri Sep 19 01:09:36 2014 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Fri Sep 19 01:13:49 2014 +0200
memlock: drop uneeded lock
Avoid doing buffered operation within memory lock.
---
lib/metadata/lv_manip.c | 4 ++++
lib/metadata/thin_manip.c | 4 ++++
2 files changed, 8 insertions(+), 0 deletions(-)
diff --git a/lib/metadata/lv_manip.c b/lib/metadata/lv_manip.c
index 58bc79b..2e683b9 100644
--- a/lib/metadata/lv_manip.c
+++ b/lib/metadata/lv_manip.c
@@ -29,6 +29,7 @@
#include "defaults.h"
#include "lvm-exec.h"
#include "lvm-signal.h"
+#include "memlock.h"
typedef enum {
PREFERRED,
@@ -6877,6 +6878,9 @@ static struct logical_volume *_lv_create_an_lv(struct volume_group *vg,
thin_name, lp->pvh, lp->alloc, lp->approx_alloc))
return_NULL;
+ /* Unlock memory if possible */
+ memlock_unlock(vg->cmd);
+
if (seg_is_cache_pool(lp)) {
first_seg(lv)->chunk_size = lp->chunk_size;
first_seg(lv)->feature_flags = lp->feature_flags;
diff --git a/lib/metadata/thin_manip.c b/lib/metadata/thin_manip.c
index 61e9c6e..b781e02 100644
--- a/lib/metadata/thin_manip.c
+++ b/lib/metadata/thin_manip.c
@@ -15,6 +15,7 @@
#include "lib.h"
#include "activate.h"
#include "locking.h"
+#include "memlock.h"
#include "metadata.h"
#include "segtype.h"
#include "defaults.h"
@@ -370,6 +371,9 @@ int update_pool_lv(struct logical_volume *lv, int activate)
return_0;
}
init_dmeventd_monitor(monitored);
+
+ /* Unlock memory if possible */
+ memlock_unlock(lv->vg->cmd);
}
/*
* Resume active pool to send thin messages.
8 years, 8 months
master - memlock: ensure memory is allocation before locking
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=b0bd8ce4086531...
Commit: b0bd8ce4086531f4f83ce417ddb988d8b4e0907a
Parent: 2263a3bcf559ef1eba68a6ef6216aca4deaf4d3e
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Fri Sep 19 01:07:32 2014 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Fri Sep 19 01:12:03 2014 +0200
memlock: ensure memory is allocation before locking
strerror may mmap ram if it was not yet used.
dm_udev_get_sync_support may initilize udev if it was still not used.
---
lib/mm/memlock.c | 6 +++---
1 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/lib/mm/memlock.c b/lib/mm/memlock.c
index a58efd9..0658800 100644
--- a/lib/mm/memlock.c
+++ b/lib/mm/memlock.c
@@ -266,9 +266,6 @@ static int _memlock_maps(struct cmd_context *cmd, lvmlock_t lock, size_t *mstats
#endif
}
- /* Force libc.mo load */
- if (lock == LVM_MLOCK)
- (void)strerror(0);
/* Reset statistic counters */
*mstats = 0;
@@ -442,6 +439,9 @@ static void _lock_mem(struct cmd_context *cmd)
stack;
}
+ (void)strerror(0); /* Force libc.mo load */
+ (void)dm_udev_get_sync_support(); /* udev is initialized */
+
log_very_verbose("Locking memory");
if (!_memlock_maps(cmd, LVM_MLOCK, &_mstats))
stack;
8 years, 8 months
master - debug: mmap traps mmap and mmap64 on i386
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=2263a3bcf559ef...
Commit: 2263a3bcf559ef1eba68a6ef6216aca4deaf4d3e
Parent: 9ffc8615e54c804180137b02106c5bff2671061c
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Fri Sep 19 00:59:46 2014 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Fri Sep 19 01:10:58 2014 +0200
debug: mmap traps mmap and mmap64 on i386
Add code to trap both mmap implementation on 32bit arch.
Use dlsym()
Use hlt instraction instead of int3 - generates usable stack trace
when problem is catched.
---
lib/mm/memlock.c | 62 ++++++++++++++++++++++++++++++++++++++++--------------
1 files changed, 46 insertions(+), 16 deletions(-)
diff --git a/lib/mm/memlock.c b/lib/mm/memlock.c
index 25d55f3..a58efd9 100644
--- a/lib/mm/memlock.c
+++ b/lib/mm/memlock.c
@@ -333,30 +333,35 @@ static int _memlock_maps(struct cmd_context *cmd, lvmlock_t lock, size_t *mstats
#endif /* DEBUG_MEMLOCK */
#ifdef ARCH_X86
+#ifndef _GNU_SOURCE
+#define _GNU_SOURCE
+#endif
+#include <dlfcn.h>
static char _mmap_orig;
static unsigned char *_mmap_addr;
-#endif
+#ifdef __i386__
+static char _mmap64_orig;
+static unsigned char *_mmap64_addr;
+#endif /* __i386__ */
+#endif /* ARCH_X86 */
static int _disable_mmap(void)
{
#ifdef ARCH_X86
- volatile unsigned char *plt, *abs_addr;
+ volatile unsigned char *abs_addr;
if (!_mmap_addr) {
- (void) mmap(NULL, -1, -1, -1, -1, -1);
- plt = (unsigned char *)mmap;
- if (plt[0] != 0xff || plt[1] != 0x25) {
- log_debug("Can't find PLT jump entry assuming -fPIE linkage.");
- _mmap_addr = plt;
- } else {
+ _mmap_addr = (unsigned char *) dlsym(RTLD_NEXT, "mmap");
+ if (_mmap_addr[0] == 0xff && _mmap_addr[1] == 0x25) { /* plt */
#ifdef __x86_64__
- abs_addr = plt + 6 + *(int32_t *)(plt + 2);
+ abs_addr = _mmap_addr + 6 + *(int32_t *)(_mmap_addr + 2);
#endif /* __x86_64__ */
#ifdef __i386__
- abs_addr = *(void **)(plt + 2);
+ abs_addr = *(void **)(_mmap_addr + 2);
#endif /* __i386__ */
_mmap_addr = *(void **)abs_addr;
- }
+ } else
+ log_debug("Can't find PLT jump entry assuming -fPIE linkage.");
if (mprotect((void *)((unsigned long)_mmap_addr & ~4095UL), 4096, PROT_READ|PROT_WRITE|PROT_EXEC)) {
log_sys_error("mprotect", "");
_mmap_addr = NULL;
@@ -364,8 +369,27 @@ static int _disable_mmap(void)
}
_mmap_orig = *_mmap_addr;
}
- *_mmap_addr = 0xcc;
+ *_mmap_addr = 0xf4;
log_debug("Remapped mmap jump entry %x to %x.", _mmap_orig, *_mmap_addr);
+
+#ifdef __i386__
+ if (!_mmap64_addr) {
+ _mmap64_addr = (unsigned char *) dlsym(RTLD_NEXT, "mmap64");
+ if (_mmap64_addr[0] == 0xff && _mmap64_addr[1] == 0x25) {
+ abs_addr = *(void **)(_mmap64_addr + 2);
+ _mmap64_addr = *(void **)abs_addr;
+ } else
+ log_debug("Can't find PLT jump entry assuming -fPIE linkage.");
+ if (mprotect((void *)((unsigned long)_mmap64_addr & ~4095UL), 4096, PROT_READ|PROT_WRITE|PROT_EXEC)) {
+ log_sys_error("mprotect", "");
+ _mmap64_addr = NULL;
+ return 0;
+ }
+ _mmap64_orig = *_mmap64_addr;
+ }
+ *_mmap64_addr = 0xf4;
+ log_debug("Remapped mmap64 jump entry %x to %x.", _mmap64_orig, *_mmap64_addr);
+#endif /* __i386__ */
#endif /* ARCH_X86 */
return 1;
}
@@ -373,10 +397,16 @@ static int _disable_mmap(void)
static int _restore_mmap(void)
{
#ifdef ARCH_X86
- if (!_mmap_addr)
- return 0;
- log_debug("Restoring mmap jump entry.");
- *_mmap_addr = _mmap_orig;
+ if (_mmap_addr) {
+ log_debug("Restoring mmap jump entry.");
+ *_mmap_addr = _mmap_orig;
+ }
+#ifdef __i386__
+ if (_mmap64_addr) {
+ log_debug("Restoring mmap64 jump entry.");
+ *_mmap64_addr = _mmap64_orig;
+ }
+#endif /* __i386__ */
#endif /* ARCH_X86 */
return 1;
}
8 years, 8 months
master - WHATS_NEW
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=9ffc8615e54c80...
Commit: 9ffc8615e54c804180137b02106c5bff2671061c
Parent: b72e9d3a933fd72eb4c08f13f5a3d3a7259a7741
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Thu Sep 18 18:19:16 2014 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Thu Sep 18 18:19:16 2014 +0200
WHATS_NEW
---
WHATS_NEW | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index bceed61..e06fcc2 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.112 -
=====================================
+ Use -fPIE when linking -pie executables.
Enable cache segment type by default.
Ensure only supported volume types are used with cache segments.
Fix inablility to specify cachemode when 'lvconvert'ing to cache-pool.
8 years, 8 months
master - makefiles: fix linking of PIE code
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=b72e9d3a933fd7...
Commit: b72e9d3a933fd72eb4c08f13f5a3d3a7259a7741
Parent: d450c7fb102652985a7271f3ea76ed72235060e7
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Thu Sep 18 18:14:21 2014 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Thu Sep 18 18:14:21 2014 +0200
makefiles: fix linking of PIE code
PIE documentation:
:
https://gcc.gnu.org/onlinedocs/gcc/Code-Gen-Options.html
http://lfs.osuosl.org/hlfs/view/unstable/glibc/chapter02/pie.html
suggest to suply -fPIE (or -fpie) with -pie
during executable compilation.
When -fPIC and -fPIE are used together - -fPIE wins
Drop usage of -DPIE - we are not using this flag anywhere
TODO: cleanup linking flags
---
make.tmpl.in | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/make.tmpl.in b/make.tmpl.in
index 7a178ad..7efe46b 100644
--- a/make.tmpl.in
+++ b/make.tmpl.in
@@ -158,8 +158,8 @@ endif
ifneq ("@STATIC_LINK@", "yes")
ifeq ("@HAVE_PIE@", "yes")
ifeq ("@HAVE_FULL_RELRO@", "yes")
- EXTRA_EXEC_CFLAGS += -fPIE -DPIE
- EXTRA_EXEC_LDFLAGS += -Wl,-z,relro,-z,now -pie
+ EXTRA_EXEC_CFLAGS += -fPIE
+ EXTRA_EXEC_LDFLAGS += -Wl,-z,relro,-z,now -pie -fPIE
CLDFLAGS += -Wl,-z,relro
endif
endif
8 years, 8 months
master - debug: enhance trap of mmap
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=d450c7fb102652...
Commit: d450c7fb102652985a7271f3ea76ed72235060e7
Parent: 34bdb83c52ddc3533b16d923953435e576699877
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Thu Sep 18 16:56:13 2014 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Thu Sep 18 16:56:13 2014 +0200
debug: enhance trap of mmap
Don't install trap for mlockall case
Add another code path for -fPIE compilation,
in this case the address of mmap function is 'plt' address.
---
lib/mm/memlock.c | 23 ++++++++++++-----------
1 files changed, 12 insertions(+), 11 deletions(-)
diff --git a/lib/mm/memlock.c b/lib/mm/memlock.c
index 72575c5..25d55f3 100644
--- a/lib/mm/memlock.c
+++ b/lib/mm/memlock.c
@@ -346,21 +346,21 @@ static int _disable_mmap(void)
(void) mmap(NULL, -1, -1, -1, -1, -1);
plt = (unsigned char *)mmap;
if (plt[0] != 0xff || plt[1] != 0x25) {
- log_error("Can't find jump entry for mmap remapping.");
- _mmap_addr = NULL;
- return 0;
- }
+ log_debug("Can't find PLT jump entry assuming -fPIE linkage.");
+ _mmap_addr = plt;
+ } else {
#ifdef __x86_64__
- abs_addr = plt + 6 + *(int32_t *)(plt + 2);
+ abs_addr = plt + 6 + *(int32_t *)(plt + 2);
#endif /* __x86_64__ */
#ifdef __i386__
- abs_addr = *(void **)(plt + 2);
+ abs_addr = *(void **)(plt + 2);
#endif /* __i386__ */
- _mmap_addr = *(void **)abs_addr;
+ _mmap_addr = *(void **)abs_addr;
+ }
if (mprotect((void *)((unsigned long)_mmap_addr & ~4095UL), 4096, PROT_READ|PROT_WRITE|PROT_EXEC)) {
log_sys_error("mprotect", "");
_mmap_addr = NULL;
- return 1;
+ return 0;
}
_mmap_orig = *_mmap_addr;
}
@@ -407,11 +407,12 @@ static void _lock_mem(struct cmd_context *cmd)
log_sys_error("open", _procselfmaps);
return;
}
+
+ if (!_disable_mmap())
+ stack;
}
log_very_verbose("Locking memory");
- if (!_disable_mmap())
- stack;
if (!_memlock_maps(cmd, LVM_MLOCK, &_mstats))
stack;
@@ -433,8 +434,8 @@ static void _unlock_mem(struct cmd_context *cmd)
if (!_memlock_maps(cmd, LVM_MUNLOCK, &unlock_mstats))
stack;
- _restore_mmap();
if (!_use_mlockall) {
+ _restore_mmap();
if (close(_maps_fd))
log_sys_error("close", _procselfmaps);
dm_free(_maps_buffer);
8 years, 8 months
master - cleanup: update message
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=34bdb83c52ddc3...
Commit: 34bdb83c52ddc3533b16d923953435e576699877
Parent: 6d21438d0c64267ac11b4825ad719c458b80059e
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Thu Sep 18 00:53:42 2014 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Thu Sep 18 00:53:42 2014 +0200
cleanup: update message
---
tools/lvconvert.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/tools/lvconvert.c b/tools/lvconvert.c
index b6ef1bf..2cd5ba6 100644
--- a/tools/lvconvert.c
+++ b/tools/lvconvert.c
@@ -3075,7 +3075,7 @@ static int _lvconvert_cache(struct cmd_context *cmd,
if (lv_is_external_origin(origin) || lv_is_origin(origin) || lv_is_thin_type(origin) ||
lv_is_mirror_type(origin) || lv_is_cache_origin(origin) || lv_is_virtual(origin) ||
lv_is_cow(origin) || lv_is_merging_origin(origin) || lv_is_merging_cow(origin)) {
- log_error("Cache is not supported with origin LV type.",
+ log_error("Cache is not supported with origin LV %s type.",
display_lvname(origin));
return 0;
}
8 years, 8 months