master - debug: catch mmap with -DDEBUG_MEMLOCK
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=6d21438d0c6426...
Commit: 6d21438d0c64267ac11b4825ad719c458b80059e
Parent: 31548e4e7c4e3ae3b2f04b7b32491617ec7181d0
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Thu Sep 18 00:40:45 2014 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Thu Sep 18 00:48:06 2014 +0200
debug: catch mmap with -DDEBUG_MEMLOCK
---
lib/mm/memlock.c | 68 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
make.tmpl.in | 4 +++
2 files changed, 72 insertions(+), 0 deletions(-)
diff --git a/lib/mm/memlock.c b/lib/mm/memlock.c
index 7d9a8f3..72575c5 100644
--- a/lib/mm/memlock.c
+++ b/lib/mm/memlock.c
@@ -316,6 +316,71 @@ static int _memlock_maps(struct cmd_context *cmd, lvmlock_t lock, size_t *mstats
return ret;
}
+#ifdef DEBUG_MEMLOCK
+/*
+ * LVM is not supposed to use mmap while devices are suspended.
+ * This code causes a core dump if gets called."
+ */
+# ifdef __i386__
+# define ARCH_X86
+# endif /* __i386__ */
+# ifdef __x86_64__
+# ifndef ARCH_X86
+# define ARCH_X86
+# endif /* ARCH_X86 */
+# endif /* __x86_64__ */
+
+#endif /* DEBUG_MEMLOCK */
+
+#ifdef ARCH_X86
+static char _mmap_orig;
+static unsigned char *_mmap_addr;
+#endif
+
+static int _disable_mmap(void)
+{
+#ifdef ARCH_X86
+ volatile unsigned char *plt, *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_error("Can't find jump entry for mmap remapping.");
+ _mmap_addr = NULL;
+ return 0;
+ }
+#ifdef __x86_64__
+ abs_addr = plt + 6 + *(int32_t *)(plt + 2);
+#endif /* __x86_64__ */
+#ifdef __i386__
+ abs_addr = *(void **)(plt + 2);
+#endif /* __i386__ */
+ _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;
+ }
+ _mmap_orig = *_mmap_addr;
+ }
+ *_mmap_addr = 0xcc;
+ log_debug("Remapped mmap jump entry %x to %x.", _mmap_orig, *_mmap_addr);
+#endif /* ARCH_X86 */
+ return 1;
+}
+
+static int _restore_mmap(void)
+{
+#ifdef ARCH_X86
+ if (!_mmap_addr)
+ return 0;
+ log_debug("Restoring mmap jump entry.");
+ *_mmap_addr = _mmap_orig;
+#endif /* ARCH_X86 */
+ return 1;
+}
+
/* Stop memory getting swapped out */
static void _lock_mem(struct cmd_context *cmd)
{
@@ -345,6 +410,8 @@ static void _lock_mem(struct cmd_context *cmd)
}
log_very_verbose("Locking memory");
+ if (!_disable_mmap())
+ stack;
if (!_memlock_maps(cmd, LVM_MLOCK, &_mstats))
stack;
@@ -366,6 +433,7 @@ static void _unlock_mem(struct cmd_context *cmd)
if (!_memlock_maps(cmd, LVM_MUNLOCK, &unlock_mstats))
stack;
+ _restore_mmap();
if (!_use_mlockall) {
if (close(_maps_fd))
log_sys_error("close", _procselfmaps);
diff --git a/make.tmpl.in b/make.tmpl.in
index 455e9c2..7a178ad 100644
--- a/make.tmpl.in
+++ b/make.tmpl.in
@@ -214,6 +214,10 @@ endif
#DEFS += -DDEBUG_ENFORCE_POOL_LOCKING
#DEFS += -DBOUNDS_CHECK
+# LVM is not supposed to use mmap while devices are suspended.
+# This code causes a core dump if gets called.
+#DEFS += -DDEBUG_MEMLOCK
+
#CFLAGS += -pg
#LDFLAGS += -pg
8 years, 8 months
master - cleanup: detect unsupported options earlier
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=31548e4e7c4e3a...
Commit: 31548e4e7c4e3ae3b2f04b7b32491617ec7181d0
Parent: 8cbb04563ac240346693ec4da1587df20b049df7
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Wed Sep 17 23:31:51 2014 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Thu Sep 18 00:42:53 2014 +0200
cleanup: detect unsupported options earlier
Avoid unnecessary converions of pool.
---
tools/lvconvert.c | 24 ++++++++++++------------
1 files changed, 12 insertions(+), 12 deletions(-)
diff --git a/tools/lvconvert.c b/tools/lvconvert.c
index 4291a9e..b6ef1bf 100644
--- a/tools/lvconvert.c
+++ b/tools/lvconvert.c
@@ -2674,6 +2674,18 @@ static int _lvconvert_pool(struct cmd_context *cmd,
return 0;
}
+ if (arg_is_set(cmd, cachepool_ARG) && lv_is_thin_pool(pool_lv)) {
+ log_error("--cachepool requires a cache pool. %s is a thin pool.",
+ display_lvname(pool_lv));
+ return 0;
+ }
+
+ if (arg_is_set(cmd, thinpool_ARG) && lv_is_cache_pool(pool_lv)) {
+ log_error("--thinpool requires a thin pool. %s is a cache pool.",
+ display_lvname(pool_lv));
+ return 0;
+ }
+
if (lp->pool_metadata_lv_name) {
if (!(lp->pool_metadata_lv = find_lv(vg, lp->pool_metadata_lv_name))) {
log_error("Unknown pool metadata LV %s.", lp->pool_metadata_lv_name);
@@ -2763,18 +2775,6 @@ static int _lvconvert_pool(struct cmd_context *cmd,
if (lv_is_pool(pool_lv)) {
lp->pool_data_lv = pool_lv;
- if (arg_is_set(cmd, cachepool_ARG) && lv_is_thin_pool(pool_lv)) {
- log_error("--cachepool requires a cache pool. %s is a thin pool.",
- display_lvname(pool_lv));
- return 0;
- }
-
- if (arg_is_set(cmd, thinpool_ARG) && lv_is_cache_pool(pool_lv)) {
- log_error("--thinpool requires a thin pool. %s is a cache pool.",
- display_lvname(pool_lv));
- return 0;
- }
-
if (!metadata_lv) {
if (arg_from_list_is_set(cmd, "is invalid with existing pool",
cachemode_ARG,chunksize_ARG, discards_ARG,
8 years, 8 months
master - cache: Enable cache segment type by default.
by Alasdair Kergon
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=8cbb04563ac240...
Commit: 8cbb04563ac240346693ec4da1587df20b049df7
Parent: ab2dacf6f6aa18328a848238e45aeaac2ed0d064
Author: Alasdair G Kergon <agk(a)redhat.com>
AuthorDate: Wed Sep 17 23:13:15 2014 +0100
Committer: Alasdair G Kergon <agk(a)redhat.com>
CommitterDate: Wed Sep 17 23:13:15 2014 +0100
cache: Enable cache segment type by default.
---
WHATS_NEW | 1 +
configure | 5 +++--
configure.in | 4 ++--
3 files changed, 6 insertions(+), 4 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index 67c6482..bceed61 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.112 -
=====================================
+ 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.
Grab cluster lock for active LVs when setting clustered attribute.
diff --git a/configure b/configure
index be3d34d..6a15ed8 100755
--- a/configure
+++ b/configure
@@ -1668,7 +1668,8 @@ Optional Packages:
--with-thin-repair=PATH thin_repair tool: [[autodetect]]
--with-thin-restore=PATH
thin_restore tool: [[autodetect]]
- --with-cache=TYPE cache support: internal/shared/none [[TYPE=none]]
+ --with-cache=TYPE cache support: internal/shared/none
+ [[TYPE=internal]]
--with-cache-check=PATH cache_check tool: [[autodetect]]
--with-cache-dump=PATH cache_dump tool: [[autodetect]]
--with-cache-repair=PATH
@@ -7830,7 +7831,7 @@ $as_echo_n "checking whether to include cache... " >&6; }
if test "${with_cache+set}" = set; then :
withval=$with_cache; CACHE=$withval
else
- CACHE="none"
+ CACHE="internal"
fi
diff --git a/configure.in b/configure.in
index 70f3b78..3956ff0 100644
--- a/configure.in
+++ b/configure.in
@@ -500,8 +500,8 @@ dnl -- cache inclusion type
AC_MSG_CHECKING(whether to include cache)
AC_ARG_WITH(cache,
AC_HELP_STRING([--with-cache=TYPE],
- [cache support: internal/shared/none [[TYPE=none]]]),
- CACHE=$withval, CACHE="none")
+ [cache support: internal/shared/none [[TYPE=internal]]]),
+ CACHE=$withval, CACHE="internal")
AC_ARG_WITH(cache-check,
AC_HELP_STRING([--with-cache-check=PATH],
[cache_check tool: [[autodetect]]]),
8 years, 8 months
master - lvconvert: Further restrictions on cache/pools.
by Alasdair Kergon
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=ab2dacf6f6aa18...
Commit: ab2dacf6f6aa18328a848238e45aeaac2ed0d064
Parent: a2a869afc8f55409fca0f2079facaf57f2539f24
Author: Alasdair G Kergon <agk(a)redhat.com>
AuthorDate: Wed Sep 17 23:00:41 2014 +0100
Committer: Alasdair G Kergon <agk(a)redhat.com>
CommitterDate: Wed Sep 17 23:00:41 2014 +0100
lvconvert: Further restrictions on cache/pools.
Would be better to define what is supported not what isn't, but this'll
have to do for now.
---
lib/metadata/metadata-exported.h | 2 +-
lib/metadata/metadata.h | 2 +-
lib/metadata/snapshot_manip.c | 2 +-
tools/lvconvert.c | 45 ++++++++++++++++++++++++++++++++++++++
4 files changed, 48 insertions(+), 3 deletions(-)
diff --git a/lib/metadata/metadata-exported.h b/lib/metadata/metadata-exported.h
index 0a307ab..9dac46a 100644
--- a/lib/metadata/metadata-exported.h
+++ b/lib/metadata/metadata-exported.h
@@ -66,7 +66,7 @@
#define PVMOVE UINT64_C(0x0000000000002000) /* VG LV SEG */
#define LOCKED UINT64_C(0x0000000000004000) /* LV */
#define MIRRORED UINT64_C(0x0000000000008000) /* LV - internal use only */
-//#define VIRTUAL UINT64_C(0x0000000000010000) /* LV - internal use only */
+#define VIRTUAL UINT64_C(0x0000000000010000) /* LV - internal use only */
#define MIRROR UINT64_C(0x0002000000000000) /* LV - Internal use only */
#define MIRROR_LOG UINT64_C(0x0000000000020000) /* LV - Internal use only */
#define MIRROR_IMAGE UINT64_C(0x0000000000040000) /* LV - Internal use only */
diff --git a/lib/metadata/metadata.h b/lib/metadata/metadata.h
index 439f6b7..f847ddb 100644
--- a/lib/metadata/metadata.h
+++ b/lib/metadata/metadata.h
@@ -55,7 +55,7 @@
#define SPINDOWN_LV UINT64_C(0x00000010) /* LV */
#define BADBLOCK_ON UINT64_C(0x00000020) /* LV */
-#define VIRTUAL UINT64_C(0x00010000) /* LV - internal use only */
+//#define VIRTUAL UINT64_C(0x00010000) /* LV - internal use only */
#define PRECOMMITTED UINT64_C(0x00200000) /* VG - internal use only */
#define POSTORDER_FLAG UINT64_C(0x02000000) /* Not real flags, reserved for */
#define POSTORDER_OPEN_FLAG UINT64_C(0x04000000) /* temporary use inside vg_read_internal. */
diff --git a/lib/metadata/snapshot_manip.c b/lib/metadata/snapshot_manip.c
index dfad615..36a685f 100644
--- a/lib/metadata/snapshot_manip.c
+++ b/lib/metadata/snapshot_manip.c
@@ -193,7 +193,7 @@ void init_snapshot_merge(struct lv_segment *snap_seg,
if (seg_is_thin_volume(snap_seg)) {
snap_seg->merge_lv = origin;
- /* Making thin LV inivisible with regular log */
+ /* Making thin LV invisible with regular log */
lv_set_hidden(snap_seg->lv);
return;
}
diff --git a/tools/lvconvert.c b/tools/lvconvert.c
index eb96bc4..4291a9e 100644
--- a/tools/lvconvert.c
+++ b/tools/lvconvert.c
@@ -2633,10 +2633,14 @@ static int _lvconvert_update_pool_params(struct logical_volume *pool_lv,
}
/*
+ * Converts a data lv and a metadata lv into a thin or cache pool lv.
+ *
* Thin lvconvert version which
* rename metadata
* convert/layers thinpool over data
* attach metadata
+ *
+ * pool_lv might or might not already be a pool.
*/
static int _lvconvert_pool(struct cmd_context *cmd,
struct logical_volume *pool_lv,
@@ -2658,6 +2662,18 @@ static int _lvconvert_pool(struct cmd_context *cmd,
return 0;
}
+ /*
+ * Only linear, striped and raid supported.
+ * FIXME Tidy up all these type restrictions.
+ */
+ if (!lv_is_pool(pool_lv) &&
+ (lv_is_external_origin(pool_lv) || lv_is_origin(pool_lv) || lv_is_thin_type(pool_lv) ||
+ lv_is_mirror_type(pool_lv) || lv_is_cache_type(pool_lv) || lv_is_virtual(pool_lv) ||
+ lv_is_cache_origin(pool_lv) || lv_is_merging_origin(pool_lv) || lv_is_merging_cow(pool_lv))) {
+ log_error("Pool data LV %s is of an unsupported type.", display_lvname(pool_lv));
+ return 0;
+ }
+
if (lp->pool_metadata_lv_name) {
if (!(lp->pool_metadata_lv = find_lv(vg, lp->pool_metadata_lv_name))) {
log_error("Unknown pool metadata LV %s.", lp->pool_metadata_lv_name);
@@ -2671,22 +2687,26 @@ static int _lvconvert_pool(struct cmd_context *cmd,
display_lvname(metadata_lv));
return 0;
}
+
if (lv_is_mirror(metadata_lv)) {
log_error("Mirror logical volumes cannot be used "
"for pool metadata.");
log_error("Try \"raid1\" segment type instead.");
return 0;
}
+
if (lv_is_locked(metadata_lv)) {
log_error("Can't convert locked LV %s.",
display_lvname(metadata_lv));
return 0;
}
+
if (metadata_lv == pool_lv) {
log_error("Can't use same LV for pool data and metadata LV %s.",
display_lvname(metadata_lv));
return 0;
}
+
if (lv_is_thin_type(metadata_lv) ||
lv_is_cache_type(metadata_lv)) {
log_error("Can't use thin or cache type LV %s for pool metadata.",
@@ -2694,6 +2714,16 @@ static int _lvconvert_pool(struct cmd_context *cmd,
return 0;
}
+ /* FIXME Tidy up all these type restrictions. */
+ if (lv_is_external_origin(metadata_lv) || lv_is_virtual(metadata_lv) ||
+ lv_is_origin(metadata_lv) || lv_is_thin_origin(metadata_lv, NULL) ||
+ lv_is_cache_origin(metadata_lv) || lv_is_cow(metadata_lv) ||
+ lv_is_merging_origin(metadata_lv) || lv_is_merging_cow(metadata_lv)) {
+ log_error("Pool metadata LV %s is of an unsupported type.",
+ display_lvname(metadata_lv));
+ return 0;
+ }
+
if (!lv_is_pool(pool_lv)) {
if (!_lvconvert_update_pool_params(pool_lv, lp))
return_0;
@@ -3016,6 +3046,9 @@ revert_new_lv:
#endif
}
+/*
+ * Convert origin into a cache LV by attaching a cache pool.
+ */
static int _lvconvert_cache(struct cmd_context *cmd,
struct logical_volume *origin,
struct lvconvert_params *lp)
@@ -3035,6 +3068,18 @@ static int _lvconvert_cache(struct cmd_context *cmd,
return 0;
}
+ /*
+ * Only linear, striped or raid supported.
+ * FIXME Tidy up all these type restrictions.
+ */
+ 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.",
+ display_lvname(origin));
+ return 0;
+ }
+
if (!archive(origin->vg))
return_0;
8 years, 8 months
master - lvconvert: Disallow mixing of cache and thin pools.
by Alasdair Kergon
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=a2a869afc8f554...
Commit: a2a869afc8f55409fca0f2079facaf57f2539f24
Parent: bdb05cc05e3a0eac72b0921cb5eb500891346e12
Author: Alasdair G Kergon <agk(a)redhat.com>
AuthorDate: Wed Sep 17 17:11:01 2014 +0100
Committer: Alasdair G Kergon <agk(a)redhat.com>
CommitterDate: Wed Sep 17 17:11:01 2014 +0100
lvconvert: Disallow mixing of cache and thin pools.
--cachepool can't take a thin pool and --thinpool can't take a
cache pool.
---
tools/lvconvert.c | 12 ++++++++++++
1 files changed, 12 insertions(+), 0 deletions(-)
diff --git a/tools/lvconvert.c b/tools/lvconvert.c
index 295a4e5..eb96bc4 100644
--- a/tools/lvconvert.c
+++ b/tools/lvconvert.c
@@ -2733,6 +2733,18 @@ static int _lvconvert_pool(struct cmd_context *cmd,
if (lv_is_pool(pool_lv)) {
lp->pool_data_lv = pool_lv;
+ if (arg_is_set(cmd, cachepool_ARG) && lv_is_thin_pool(pool_lv)) {
+ log_error("--cachepool requires a cache pool. %s is a thin pool.",
+ display_lvname(pool_lv));
+ return 0;
+ }
+
+ if (arg_is_set(cmd, thinpool_ARG) && lv_is_cache_pool(pool_lv)) {
+ log_error("--thinpool requires a thin pool. %s is a cache pool.",
+ display_lvname(pool_lv));
+ return 0;
+ }
+
if (!metadata_lv) {
if (arg_from_list_is_set(cmd, "is invalid with existing pool",
cachemode_ARG,chunksize_ARG, discards_ARG,
8 years, 8 months
master - lvconvert: Restrict use of cache LVs.
by Alasdair Kergon
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=bdb05cc05e3a0e...
Commit: bdb05cc05e3a0eac72b0921cb5eb500891346e12
Parent: b4f5be76a3b8c9c89719e5d8699033a79c993b6f
Author: Alasdair G Kergon <agk(a)redhat.com>
AuthorDate: Wed Sep 17 16:41:58 2014 +0100
Committer: Alasdair G Kergon <agk(a)redhat.com>
CommitterDate: Wed Sep 17 16:41:58 2014 +0100
lvconvert: Restrict use of cache LVs.
Refuse use of -m and -s with cache LVs until full support
can be provided.
---
WHATS_NEW | 1 +
tools/lvconvert.c | 12 ++++++++++++
2 files changed, 13 insertions(+), 0 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index 1f64d0d..67c6482 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.112 -
=====================================
+ Ensure only supported volume types are used with cache segments.
Fix inablility to specify cachemode when 'lvconvert'ing to cache-pool.
Grab cluster lock for active LVs when setting clustered attribute.
Use va_copy to properly pass va_list through functions.
diff --git a/tools/lvconvert.c b/tools/lvconvert.c
index 93a2be4..295a4e5 100644
--- a/tools/lvconvert.c
+++ b/tools/lvconvert.c
@@ -1725,6 +1725,12 @@ static int _lvconvert_mirrors(struct cmd_context *cmd,
return 0;
}
+ if (lv_is_cache_type(lv)) {
+ log_error("Mirrors are not yet supported on cache LVs %s.",
+ display_lvname(lv));
+ return 0;
+ }
+
/* Adjust mimage and/or log count */
if (!_lvconvert_mirrors_parse_params(cmd, lv, lp,
&old_mimage_count, &old_log_count,
@@ -2011,6 +2017,12 @@ static int _lvconvert_snapshot(struct cmd_context *cmd,
return 0;
}
+ if (lv_is_cache_type(lv)) {
+ log_error("Snapshots are not yet supported with cache type LVs %s.",
+ display_lvname(lv));
+ return 0;
+ }
+
if (!(org = find_lv(lv->vg, lp->origin_lv_name))) {
log_error("Couldn't find origin volume %s.", lp->origin_lv_name);
return 0;
8 years, 8 months
master - cleanup: Remove metadata.h from tools dir.
by Alasdair Kergon
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=b4f5be76a3b8c9...
Commit: b4f5be76a3b8c9c89719e5d8699033a79c993b6f
Parent: 98414ca7dd2682b64fec141ae58b4c8ed4367fc7
Author: Alasdair G Kergon <agk(a)redhat.com>
AuthorDate: Wed Sep 17 15:50:24 2014 +0100
Committer: Alasdair G Kergon <agk(a)redhat.com>
CommitterDate: Wed Sep 17 15:50:24 2014 +0100
cleanup: Remove metadata.h from tools dir.
metadata.h is meant to be internal to the library.
metadata-exported.h contains the things needed by tools.
---
lib/metadata/metadata-exported.h | 5 +++++
lib/metadata/metadata.h | 5 -----
tools/pvmove.c | 1 -
tools/pvremove.c | 1 -
tools/vgsplit.c | 1 -
5 files changed, 5 insertions(+), 8 deletions(-)
diff --git a/lib/metadata/metadata-exported.h b/lib/metadata/metadata-exported.h
index 01b04ff..0a307ab 100644
--- a/lib/metadata/metadata-exported.h
+++ b/lib/metadata/metadata-exported.h
@@ -615,6 +615,10 @@ struct physical_volume *pv_create(const struct cmd_context *cmd,
unsigned metadataignore,
struct pvcreate_restorable_params *rp);
+int pvremove_single(struct cmd_context *cmd, const char *pv_name,
+ void *handle __attribute__((unused)), unsigned force_count,
+ unsigned prompt);
+
int pv_resize_single(struct cmd_context *cmd,
struct volume_group *vg,
struct physical_volume *pv,
@@ -927,6 +931,7 @@ int get_pv_list_for_lv(struct dm_pool *mem,
/* Find LV segment containing given LE */
struct lv_segment *first_seg(const struct logical_volume *lv);
struct lv_segment *last_seg(const struct logical_volume *lv);
+struct lv_segment *get_only_segment_using_this_lv(const struct logical_volume *lv);
/*
* Useful functions for managing snapshots.
diff --git a/lib/metadata/metadata.h b/lib/metadata/metadata.h
index 518dd21..439f6b7 100644
--- a/lib/metadata/metadata.h
+++ b/lib/metadata/metadata.h
@@ -341,10 +341,6 @@ unsigned long set_pe_align_offset(struct physical_volume *pv,
int pv_write_orphan(struct cmd_context *cmd, struct physical_volume *pv);
-int pvremove_single(struct cmd_context *cmd, const char *pv_name,
- void *handle __attribute__((unused)), unsigned force_count,
- unsigned prompt);
-
struct physical_volume *pvcreate_vol(struct cmd_context *cmd, const char *pv_name,
struct pvcreate_params *pp, int write_now);
@@ -428,7 +424,6 @@ int lv_split_segment(struct logical_volume *lv, uint32_t le);
*/
int add_seg_to_segs_using_this_lv(struct logical_volume *lv, struct lv_segment *seg);
int remove_seg_from_segs_using_this_lv(struct logical_volume *lv, struct lv_segment *seg);
-struct lv_segment *get_only_segment_using_this_lv(const struct logical_volume *lv);
int for_each_sub_lv(struct logical_volume *lv,
int (*fn)(struct logical_volume *lv, void *data),
diff --git a/tools/pvmove.c b/tools/pvmove.c
index a9d750d..3072584 100644
--- a/tools/pvmove.c
+++ b/tools/pvmove.c
@@ -16,7 +16,6 @@
#include "tools.h"
#include "polldaemon.h"
#include "display.h"
-#include "metadata.h" /* for 'get_only_segment_using_this_lv' */
#define PVMOVE_FIRST_TIME 0x00000001 /* Called for first time */
#define PVMOVE_EXCLUSIVE 0x00000002 /* Require exclusive LV */
diff --git a/tools/pvremove.c b/tools/pvremove.c
index dfd6007..035d4fd 100644
--- a/tools/pvremove.c
+++ b/tools/pvremove.c
@@ -14,7 +14,6 @@
*/
#include "tools.h"
-#include "metadata.h"
int pvremove(struct cmd_context *cmd, int argc, char **argv)
{
diff --git a/tools/vgsplit.c b/tools/vgsplit.c
index ad2eb48..362f854 100644
--- a/tools/vgsplit.c
+++ b/tools/vgsplit.c
@@ -14,7 +14,6 @@
*/
#include "tools.h"
-#include "metadata.h" /* for 'get_only_segment_using_this_lv' */
static int _lv_is_in_vg(struct volume_group *vg, struct logical_volume *lv)
{
8 years, 8 months
master - vgchange: support clustered conversion for active lv
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=98414ca7dd2682...
Commit: 98414ca7dd2682b64fec141ae58b4c8ed4367fc7
Parent: f90bc22ca532f5852aeaab92e0c40b36d65ef62d
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Wed Sep 17 14:27:46 2014 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Wed Sep 17 14:41:42 2014 +0200
vgchange: support clustered conversion for active lv
If we want to support conversion of VG to clustered type,
we currently need to relock active LV to get proper DLM lock.
So add extra loop after change of VG clustered attribute
to exlusively activate all active top level LVs.
When doing change -cy -> -cn we should validate LVs are not
active on other cluster nodes - we could be sure about this only
when with local exclusive activation - for other types
we require user to deactivate volumes first.
As a workaround for this limitation there is always
locking_type = 0 which amongs other skip the detection
of active LVs.
FIXME:
clvmd should handle looks for cluster locking type all the time.
---
WHATS_NEW | 2 +-
lib/metadata/vg.c | 35 +++++++++++++++++++++++++++--------
test/shell/vgchange-usage.sh | 15 ++++++++-------
tools/vgchange.c | 29 ++++++++++++++++++++++++++++-
4 files changed, 64 insertions(+), 17 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index 1015835..1f64d0d 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,7 +1,7 @@
Version 2.02.112 -
=====================================
Fix inablility to specify cachemode when 'lvconvert'ing to cache-pool.
- Disable vgchange of clustered attribute with any active LV in VG.
+ Grab cluster lock for active LVs when setting clustered attribute.
Use va_copy to properly pass va_list through functions.
Add function to detect rotational devices.
Review internal checks for mirror/raid/pvmove volumes.
diff --git a/lib/metadata/vg.c b/lib/metadata/vg.c
index acda5be..7b6cb85 100644
--- a/lib/metadata/vg.c
+++ b/lib/metadata/vg.c
@@ -520,7 +520,8 @@ int vg_set_alloc_policy(struct volume_group *vg, alloc_policy_t alloc)
}
/*
- * We do not currently support switching the cluster attribute
+ * Switching the cluster attribute make the active volume
+ * exclusively activate
* with any active logical volumes.
*
* FIXME: resolve logic with reacquiring proper top-level LV locks
@@ -529,14 +530,32 @@ int vg_set_alloc_policy(struct volume_group *vg, alloc_policy_t alloc)
int vg_set_clustered(struct volume_group *vg, int clustered)
{
struct lv_list *lvl;
- struct logical_volume *lv;
+ int fail = 0;
+
+ if (vg_is_clustered(vg) &&
+ locking_is_clustered() &&
+ locking_supports_remote_queries() &&
+ !clustered) {
+ /*
+ * If the volume is locally active but not exclusively
+ * we cannot determine when other nodes also use
+ * locally active (CR lock), so refuse conversion.
+ */
+ dm_list_iterate_items(lvl, &vg->lvs)
+ if ((lv_lock_holder(lvl->lv) == lvl->lv) &&
+ lv_is_active(lvl->lv) &&
+ !lv_is_active_exclusive_locally(lvl->lv)) {
+ /* Show all non-local-exclusively active LVs
+ * this includes i.e. clustered mirrors */
+ log_error("Can't change cluster attribute with "
+ "active logical volume %s.",
+ display_lvname(lvl->lv));
+ fail = 1;
+ }
- dm_list_iterate_items(lvl, &vg->lvs) {
- /* For COW, check lock for origin */
- lv = lv_is_cow(lvl->lv) ? origin_from_cow(lvl->lv) : lvl->lv;
- if (lv_is_active(lv)) {
- log_error("Can't change cluster attribute with active "
- "oogical volume %s.", display_lvname(lv));
+ if (fail) {
+ log_print_unless_silent("Conversion is supported only for "
+ "locally exclusive volumes.");
return 0;
}
}
diff --git a/test/shell/vgchange-usage.sh b/test/shell/vgchange-usage.sh
index ff80722..e564337 100644
--- a/test/shell/vgchange-usage.sh
+++ b/test/shell/vgchange-usage.sh
@@ -89,27 +89,28 @@ fail vgchange -cy |& tee out
grep "y/n" out
check vg_attr_bit cluster $vg "-"
-lvcreate -l1 $vg
+lvcreate -l1 -n $lv1 $vg
# check on cluster
# either skipped as clustered (non-cluster), or already clustered (on cluster)
if test -e LOCAL_CLVMD ; then
- # can't switch with active LV
- not vgchange -cy $vg
- lvchange -an $vg
+ # can switch with active LV
vgchange -cy $vg
fail vgchange -cy $vg
+ # check volume is active locally exclusively
+ check lv_field $vg/$lv1 lv_active "local exclusive"
check vg_attr_bit cluster $vg "c"
+ # check we do not support conversion of just locally active LVs
+ lvchange -an $vg
lvchange -ay $vg
not vgchange -cn $vg
lvchange -an $vg
+ lvchange -aey $vg
vgchange -cn $vg
else
# no clvmd is running
fail vgchange -cy $vg
# can't switch with active LV
- not vgchange --yes -cy $vg
- lvchange -an $vg
vgchange --yes -cy $vg
fail vgchange --yes -cy $vg
fail vgs $vg |& tee out
@@ -117,7 +118,7 @@ else
vgs --ignoreskippedcluster $vg |& tee out
not grep "Skipping clustered volume group" out
# reset back to non-clustered VG with disabled locking
- vgchange -cn --config 'global{locking_type=0}' $vg
+ vgchange -cn $vg --config 'global{locking_type=0}' $vg
fi
check vg_attr_bit cluster $vg "-"
diff --git a/tools/vgchange.c b/tools/vgchange.c
index 29e2d8a..da0a05d 100644
--- a/tools/vgchange.c
+++ b/tools/vgchange.c
@@ -479,7 +479,9 @@ static int vgchange_single(struct cmd_context *cmd, const char *vg_name,
struct volume_group *vg,
void *handle __attribute__((unused)))
{
+ int ret = ECMD_PROCESSED;
unsigned i;
+ struct lv_list *lvl;
static const struct {
int arg;
@@ -534,6 +536,31 @@ static int vgchange_single(struct cmd_context *cmd, const char *vg_name,
backup(vg);
log_print_unless_silent("Volume group \"%s\" successfully changed", vg->name);
+
+ /* FIXME: fix clvmd bug and take DLM lock for non clustered VGs. */
+ if (arg_is_set(cmd, clustered_ARG) &&
+ vg_is_clustered(vg) && /* just switched to clustered */
+ locking_is_clustered() &&
+ locking_supports_remote_queries())
+ dm_list_iterate_items(lvl, &vg->lvs) {
+ if ((lv_lock_holder(lvl->lv) != lvl->lv) ||
+ !lv_is_active(lvl->lv))
+ continue;
+
+ if (!activate_lv_excl_local(cmd, lvl->lv) ||
+ !lv_is_active_exclusive_locally(lvl->lv)) {
+ log_error("Can't reactive logical volume %s, "
+ "please fix manually.",
+ display_lvname(lvl->lv));
+ ret = ECMD_FAILED;
+ }
+
+ if (lv_is_mirror(lvl->lv))
+ /* Give hint for clustered mirroring */
+ log_print_unless_silent("For clustered mirroring of %s "
+ "deactivation and activation is needed.",
+ display_lvname(lvl->lv));
+ }
}
if (arg_count(cmd, activate_ARG)) {
@@ -561,7 +588,7 @@ static int vgchange_single(struct cmd_context *cmd, const char *vg_name,
if (!_vgchange_background_polling(cmd, vg))
return_ECMD_FAILED;
- return ECMD_PROCESSED;
+ return ret;
}
int vgchange(struct cmd_context *cmd, int argc, char **argv)
8 years, 8 months
master - locking: add locking_supports_remote_queries
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=f90bc22ca532f5...
Commit: f90bc22ca532f5852aeaab92e0c40b36d65ef62d
Parent: 9d57aa9a0fe00322cb188ad1f3103d57392546e7
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Wed Sep 17 14:21:41 2014 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Wed Sep 17 14:36:38 2014 +0200
locking: add locking_supports_remote_queries
Add function to detect whether locking could be used to
query for lock type so we could recognize exclusive
activation.
---
lib/locking/cluster_locking.c | 2 +-
lib/locking/locking.c | 5 +++++
lib/locking/locking.h | 1 +
lib/locking/locking_types.h | 1 +
4 files changed, 8 insertions(+), 1 deletions(-)
diff --git a/lib/locking/cluster_locking.c b/lib/locking/cluster_locking.c
index 0a11262..f2f4c80 100644
--- a/lib/locking/cluster_locking.c
+++ b/lib/locking/cluster_locking.c
@@ -611,7 +611,7 @@ int init_cluster_locking(struct locking_type *locking, struct cmd_context *cmd,
locking->query_resource = _query_resource;
locking->fin_locking = _locking_end;
locking->reset_locking = _reset_locking;
- locking->flags = LCK_PRE_MEMLOCK | LCK_CLUSTERED;
+ locking->flags = LCK_PRE_MEMLOCK | LCK_CLUSTERED | LCK_SUPPORTS_REMOTE_QUERIES;
_clvmd_sock = _open_local_sock(suppress_messages);
if (_clvmd_sock == -1)
diff --git a/lib/locking/locking.c b/lib/locking/locking.c
index 9432f84..544751e 100644
--- a/lib/locking/locking.c
+++ b/lib/locking/locking.c
@@ -492,6 +492,11 @@ int locking_is_clustered(void)
return (_locking.flags & LCK_CLUSTERED) ? 1 : 0;
}
+int locking_supports_remote_queries(void)
+{
+ return (_locking.flags & LCK_SUPPORTS_REMOTE_QUERIES) ? 1 : 0;
+}
+
int remote_lock_held(const char *vol, int *exclusive)
{
int mode = LCK_NULL;
diff --git a/lib/locking/locking.h b/lib/locking/locking.h
index 284ce7a..1351cd2 100644
--- a/lib/locking/locking.h
+++ b/lib/locking/locking.h
@@ -26,6 +26,7 @@ void fin_locking(void);
void reset_locking(void);
int vg_write_lock_held(void);
int locking_is_clustered(void);
+int locking_supports_remote_queries(void);
int remote_lock_held(const char *vol, int *exclusive);
diff --git a/lib/locking/locking_types.h b/lib/locking/locking_types.h
index 6e4adcc..5fa5cba 100644
--- a/lib/locking/locking_types.h
+++ b/lib/locking/locking_types.h
@@ -25,6 +25,7 @@ typedef void (*reset_lock_fn) (void);
#define LCK_PRE_MEMLOCK 0x00000001 /* Is memlock() needed before calls? */
#define LCK_CLUSTERED 0x00000002
+#define LCK_SUPPORTS_REMOTE_QUERIES 0x00000004
struct locking_type {
uint32_t flags;
8 years, 8 months
master - cache-pool: Fix specification of cachemode when converting to cache-pool
by Jonathan Brassow
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=9d57aa9a0fe003...
Commit: 9d57aa9a0fe00322cb188ad1f3103d57392546e7
Parent: b87a7683e23c2c309f11929a488230570daf0dc0
Author: Jonathan Brassow <jbrassow(a)redhat.com>
AuthorDate: Tue Sep 16 22:19:53 2014 -0500
Committer: Jonathan Brassow <jbrassow(a)redhat.com>
CommitterDate: Tue Sep 16 22:19:53 2014 -0500
cache-pool: Fix specification of cachemode when converting to cache-pool
Failure to copy the 'feature_flags' lvconvert_param to the matching
lv_segment field meant that when a user specified the cachemode argument,
the request was not honored.
---
WHATS_NEW | 1 +
tools/lvconvert.c | 1 +
2 files changed, 2 insertions(+), 0 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index 6c12186..1015835 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.112 -
=====================================
+ Fix inablility to specify cachemode when 'lvconvert'ing to cache-pool.
Disable vgchange of clustered attribute with any active LV in VG.
Use va_copy to properly pass va_list through functions.
Add function to detect rotational devices.
diff --git a/tools/lvconvert.c b/tools/lvconvert.c
index c7eb02d..93a2be4 100644
--- a/tools/lvconvert.c
+++ b/tools/lvconvert.c
@@ -2925,6 +2925,7 @@ mda_write:
seg->chunk_size = lp->chunk_size;
seg->discards = lp->discards;
seg->zero_new_blocks = lp->zero ? 1 : 0;
+ seg->feature_flags = lp->feature_flags; /* cache-pool */
/* Rename deactivated metadata LV to have _tmeta suffix */
/* Implicit checks if metadata_lv is visible */
8 years, 8 months