master - libdm: clear region table in dm_stats_list()
by Bryn Reeves
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=009b711834d266...
Commit: 009b711834d26610d23d14bd8b7540eb69c836a7
Parent: 8d6ac1c3ba2ee72e9832383609b6ff030d9883ce
Author: Bryn M. Reeves <bmr(a)redhat.com>
AuthorDate: Thu Dec 15 19:03:42 2016 +0000
Committer: Bryn M. Reeves <bmr(a)redhat.com>
CommitterDate: Sun Dec 18 20:44:31 2016 +0000
libdm: clear region table in dm_stats_list()
Call _stats_regions_destroy() from dm_stats_list() if dms->regions
is non-NULL. This avoids leaking any pool allocations and ensures
the handle is in a known state: if an error occurs during the list,
dms->regions will be NULL and the handle will appear empty.
---
libdm/libdm-stats.c | 3 +++
1 files changed, 3 insertions(+), 0 deletions(-)
diff --git a/libdm/libdm-stats.c b/libdm/libdm-stats.c
index 8d202d2..3978244 100644
--- a/libdm/libdm-stats.c
+++ b/libdm/libdm-stats.c
@@ -1083,6 +1083,9 @@ int dm_stats_list(struct dm_stats *dms, const char *program_id)
if (!_stats_set_name_cache(dms))
return_0;
+ if (dms->regions)
+ _stats_regions_destroy(dms);
+
r = dm_snprintf(msg, sizeof(msg), "@stats_list %s", program_id);
if (r < 0) {
7 years, 4 months
master - tests: using cached LV for external origin
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=8d6ac1c3ba2ee7...
Commit: 8d6ac1c3ba2ee72e9832383609b6ff030d9883ce
Parent: 8c17233af585b4e46a86acca8ddb126beb5faf95
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Sun Dec 18 17:43:05 2016 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Sun Dec 18 19:38:51 2016 +0100
tests: using cached LV for external origin
---
test/shell/lvconvert-thin-external-cache.sh | 107 +++++++++++++++++++++++++++
1 files changed, 107 insertions(+), 0 deletions(-)
diff --git a/test/shell/lvconvert-thin-external-cache.sh b/test/shell/lvconvert-thin-external-cache.sh
new file mode 100644
index 0000000..5fc1ff8
--- /dev/null
+++ b/test/shell/lvconvert-thin-external-cache.sh
@@ -0,0 +1,107 @@
+#!/bin/sh
+
+# Copyright (C) 2016 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+
+# Test conversion cached LV to thin with cached external origin
+
+SKIP_WITH_LVMLOCKD=1
+SKIP_WITH_LVMPOLLD=1
+
+export LVM_TEST_THIN_REPAIR_CMD=${LVM_TEST_THIN_REPAIR_CMD-/bin/false}
+
+. lib/inittest
+
+which mkfs.ext2 || skip
+which fsck || skip
+
+#
+# Main
+#
+aux have_thin 1 5 0 || skip
+aux have_cache 1 7 0 || skip
+
+aux prepare_vg 2 64
+
+# Test will use thin-pool
+lvcreate -L10 -T $vg/tpool
+
+lvcreate -aey -L20 -n $lv1 $vg
+
+
+mkfs.ext2 "$DM_DEV_DIR/$vg/$lv1"
+mkdir mnt
+mount "$DM_DEV_DIR/$vg/$lv1" mnt
+touch mnt/test
+
+# Prepared cached LV - first in 'writeback' mode
+lvcreate -H --cachemode writeback -L10 -n cpool $vg/$lv1
+
+# Can't convert 'writeback' cache
+not lvconvert --thin --thinpool $vg/tpool $vg/$lv1
+
+# Switch to 'writethrough' - this should be supported
+lvchange --cachemode writethrough $vg/$lv1
+
+lvconvert --thin $vg/$lv1 --originname extorg --thinpool $vg/tpool
+
+# check cache exist as extorg-real
+check grep_dmsetup table ${vg}-extorg-real "cache"
+
+
+# Split cache from external origin (while in-use)
+lvconvert --splitcache $vg/extorg
+
+# check linear exist as extorg-real
+check grep_dmsetup table ${vg}-extorg-real "linear"
+check lv_field $vg/extorg segtype linear
+
+# Cache external origin in-use again
+lvconvert -y -H $vg/extorg --cachepool $vg/cpool
+
+get lv_field $vg/extorg attr | grep "^ori"
+
+umount mnt
+
+# Is filesystem still ok ?
+fsck -n "$DM_DEV_DIR/$vg/$lv1"
+
+lvchange -an $vg
+lvchange -ay $vg
+
+# Remove thin, external origin remains
+lvremove -f $vg/$lv1
+
+#lvchange -prw $vg/extorg
+lvconvert --uncache $vg/extorg
+
+lvremove -f $vg
+
+#
+# Check some more API variants
+#
+
+lvcreate -L10 -n pool $vg
+
+lvcreate -aey -L2 -n $lv1 $vg
+lvcreate -H -L2 $vg/$lv1
+
+# Converts $vg/pool to thin-pool AND $vg/$lv1 to thin
+lvconvert -y --type thin $vg/$lv1 --originname extorg --thinpool $vg/pool
+
+check lv_field $vg/$lv1 segtype thin
+check lv_field $vg/pool segtype thin-pool
+check lv_field $vg/extorg segtype cache
+
+lvconvert --uncache $vg/extorg
+
+check lv_field $vg/extorg segtype linear
+
+vgremove -ff $vg
7 years, 4 months
master - debug: add debug message showing new lv
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=8c17233af585b4...
Commit: 8c17233af585b4e46a86acca8ddb126beb5faf95
Parent: 034931f68dec96265519af6f35ea3726ba7eec82
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Sun Dec 18 15:05:18 2016 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Sun Dec 18 19:38:51 2016 +0100
debug: add debug message showing new lv
Make trace easier to follow knowing which LV was added to dtree.
---
lib/activate/dev_manager.c | 2 ++
1 files changed, 2 insertions(+), 0 deletions(-)
diff --git a/lib/activate/dev_manager.c b/lib/activate/dev_manager.c
index 73229b3..685c055 100644
--- a/lib/activate/dev_manager.c
+++ b/lib/activate/dev_manager.c
@@ -2718,6 +2718,8 @@ static int _add_new_lv_to_dtree(struct dev_manager *dm, struct dm_tree *dtree,
int save_pending_delete = dm->track_pending_delete;
int merge_in_progress = 0;
+ log_debug_activation("Adding new LV %s%s%s to dtree", display_lvname(lv),
+ layer ? "-" : "", layer ? : "");
/* LV with pending delete is never put new into a table */
if (lv_is_pending_delete(lv) && !_cached_dm_info(dm->mem, dtree, lv, NULL))
return 1; /* Replace with error only when already exists */
7 years, 4 months
master - activate: further _info API refinement
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=034931f68dec96...
Commit: 034931f68dec96265519af6f35ea3726ba7eec82
Parent: 79121416dfd695900a02711e6f63146e532b825b
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Sun Dec 18 14:57:16 2016 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Sun Dec 18 19:38:51 2016 +0100
activate: further _info API refinement
Another cleanup of internal _info() API simplifying code.
Also make sure 'error' on _info() call is properly passed upward
(return 0 is error path).
---
lib/activate/dev_manager.c | 88 ++++++++++++++++++++-----------------------
1 files changed, 41 insertions(+), 47 deletions(-)
diff --git a/lib/activate/dev_manager.c b/lib/activate/dev_manager.c
index 520a0a1..73229b3 100644
--- a/lib/activate/dev_manager.c
+++ b/lib/activate/dev_manager.c
@@ -214,8 +214,8 @@ typedef enum {
STATUS, /* DM_DEVICE_STATUS ioctl */
} info_type_t;
-static int _info_run(info_type_t type, const char *dlid,
- struct dm_info *dminfo, uint32_t *read_ahead,
+static int _info_run(const char *dlid, struct dm_info *dminfo,
+ uint32_t *read_ahead,
struct lv_seg_status *seg_status,
int with_open_count, int with_read_ahead,
uint32_t major, uint32_t minor)
@@ -223,26 +223,21 @@ static int _info_run(info_type_t type, const char *dlid,
int r = 0;
struct dm_task *dmt;
int dmtask;
+ int with_flush; /* TODO: arg for _info_run */
void *target = NULL;
uint64_t target_start, target_length, start, length;
char *target_name, *target_params;
- int with_flush = 1; /* TODO: arg for _info_run */
- switch (type) {
- case INFO:
- dmtask = DM_DEVICE_INFO;
- break;
- case STATUS:
- dmtask = DM_DEVICE_STATUS;
- with_flush = 0;
- break;
- default:
- log_error(INTERNAL_ERROR "_info_run: unhandled info type.");
- return 0;
+ if (seg_status) {
+ dmtask = DM_DEVICE_STATUS;
+ with_flush = 0;
+ } else {
+ dmtask = DM_DEVICE_INFO;
+ with_flush = 1; /* doesn't really matter */
}
- if (!(dmt = _setup_task_run(dmtask, dminfo,
- NULL, dlid, 0, major, minor, with_open_count, with_flush, 0)))
+ if (!(dmt = _setup_task_run(dmtask, dminfo, NULL, dlid, 0, major, minor,
+ with_open_count, with_flush, 0)))
return_0;
if (with_read_ahead && dminfo->exists) {
@@ -252,7 +247,7 @@ static int _info_run(info_type_t type, const char *dlid,
*read_ahead = DM_READ_AHEAD_NONE;
/* Query status only for active device */
- if ((type == STATUS) && dminfo->exists) {
+ if (seg_status && dminfo->exists) {
start = length = seg_status->seg->lv->vg->extent_size;
start *= seg_status->seg->le;
length *= seg_status->seg->len;
@@ -674,18 +669,24 @@ static int _original_uuid_format_check_required(struct cmd_context *cmd)
return (_kernel_major == -1);
}
-static int _info(struct cmd_context *cmd, const char *dlid, int with_open_count, int with_read_ahead,
+static int _info(struct cmd_context *cmd,
+ const char *name, const char *dlid,
+ int with_open_count, int with_read_ahead,
struct dm_info *dminfo, uint32_t *read_ahead,
struct lv_seg_status *seg_status)
{
- int r = 0;
char old_style_dlid[sizeof(UUID_PREFIX) + 2 * ID_LEN];
const char *suffix, *suffix_position;
unsigned i = 0;
+ log_debug_activation("Getting device info for %s [%s].", name, dlid);
+
/* Check for dlid */
- if ((r = _info_run(seg_status ? STATUS : INFO, dlid, dminfo, read_ahead,
- seg_status, with_open_count, with_read_ahead, 0, 0)) && dminfo->exists)
+ if (!_info_run(dlid, dminfo, read_ahead, seg_status,
+ with_open_count, with_read_ahead, 0, 0))
+ return_0;
+
+ if (dminfo->exists)
return 1;
/* Check for original version of dlid before the suffixes got added in 2.02.106 */
@@ -696,33 +697,33 @@ static int _info(struct cmd_context *cmd, const char *dlid, int with_open_count,
(void) strncpy(old_style_dlid, dlid, sizeof(old_style_dlid));
old_style_dlid[sizeof(old_style_dlid) - 1] = '\0';
- if ((r = _info_run(seg_status ? STATUS : INFO, old_style_dlid, dminfo,
- read_ahead, seg_status, with_open_count,
- with_read_ahead, 0, 0)) && dminfo->exists)
+ if (!_info_run(old_style_dlid, dminfo, read_ahead, seg_status,
+ with_open_count, with_read_ahead, 0, 0))
+ return_0;
+ if (dminfo->exists)
return 1;
}
}
/* Must we still check for the pre-2.02.00 dm uuid format? */
if (!_original_uuid_format_check_required(cmd))
- return r;
+ return 1;
/* Check for dlid before UUID_PREFIX was added */
- if ((r = _info_run(seg_status ? STATUS : INFO, dlid + sizeof(UUID_PREFIX) - 1,
- dminfo, read_ahead, seg_status, with_open_count,
- with_read_ahead, 0, 0)) && dminfo->exists)
- return 1;
+ if (!_info_run(dlid + sizeof(UUID_PREFIX) - 1, dminfo, read_ahead, seg_status,
+ with_open_count, with_read_ahead, 0, 0))
+ return_0;
- return r;
+ return 1;
}
static int _info_by_dev(uint32_t major, uint32_t minor, struct dm_info *info)
{
- return _info_run(INFO, NULL, info, NULL, 0, 0, 0, major, minor);
+ return _info_run(NULL, info, NULL, 0, 0, 0, major, minor);
}
-int dev_manager_info(struct cmd_context *cmd, const struct logical_volume *lv,
- const char *layer,
+int dev_manager_info(struct cmd_context *cmd,
+ const struct logical_volume *lv, const char *layer,
int with_open_count, int with_read_ahead,
struct dm_info *dminfo, uint32_t *read_ahead,
struct lv_seg_status *seg_status)
@@ -736,9 +737,9 @@ int dev_manager_info(struct cmd_context *cmd, const struct logical_volume *lv,
if (!(dlid = build_dm_uuid(cmd->mem, lv, layer)))
goto_out;
- log_debug_activation("Getting device info for %s [%s].", name, dlid);
- r = _info(cmd, dlid, with_open_count, with_read_ahead,
- dminfo, read_ahead, seg_status);
+ if (!(r = _info(cmd, name, dlid, with_open_count, with_read_ahead,
+ dminfo, read_ahead, seg_status)))
+ stack;
out:
dm_pool_free(cmd->mem, name);
@@ -1713,12 +1714,8 @@ static int _add_dev_to_dtree(struct dev_manager *dm, struct dm_tree *dtree,
if (!(dlid = build_dm_uuid(dm->mem, lv, layer)))
return_0;
- log_debug_activation("Getting device info for %s [%s].", name, dlid);
-
- if (!_info(dm->cmd, dlid, 1, 0, &info, NULL, NULL)) {
- log_error("Failed to get info for %s [%s].", name, dlid);
- return 0;
- }
+ if (!_info(dm->cmd, name, dlid, 1, 0, &info, NULL, NULL))
+ return_0;
/*
* For top level volumes verify that existing device match
@@ -2241,11 +2238,8 @@ static char *_add_error_or_zero_device(struct dev_manager *dm, struct dm_tree *d
seg->lv->name, errid)))
return_NULL;
- log_debug_activation("Getting device info for %s [%s].", name, dlid);
- if (!_info(dm->cmd, dlid, 1, 0, &info, NULL, NULL)) {
- log_error("Failed to get info for %s [%s].", name, dlid);
- return 0;
- }
+ if (!_info(dm->cmd, name, dlid, 1, 0, &info, NULL, NULL))
+ return_NULL;
if (!info.exists) {
/* Create new node */
7 years, 4 months
master - thin: add comment with future extension
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=79121416dfd695...
Commit: 79121416dfd695900a02711e6f63146e532b825b
Parent: 75f23880934a8c1cb192e9a898261320db15043a
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Sun Dec 18 15:06:12 2016 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Sun Dec 18 19:38:51 2016 +0100
thin: add comment with future extension
It could be actually better to use even cache origin in
read-only mode so there could no be some 'acidental'
change being done on this volume.
This however need further tools enhancment - where we would need
to handle whole subtree on 'lvchange -pr/-prw'.
---
lib/metadata/thin_manip.c | 4 ++++
1 files changed, 4 insertions(+), 0 deletions(-)
diff --git a/lib/metadata/thin_manip.c b/lib/metadata/thin_manip.c
index e7a2c33..42ec552 100644
--- a/lib/metadata/thin_manip.c
+++ b/lib/metadata/thin_manip.c
@@ -99,6 +99,10 @@ int attach_thin_external_origin(struct lv_segment *seg,
external_lv->name);
external_lv->status &= ~LVM_WRITE;
}
+
+ // TODO: should we mark even origin read-only ?
+ //if (lv_is_cache(external_lv)) /* read-only corigin of cache LV */
+ // seg_lv(first_seg(external_lv), 0)->status &= ~LVM_WRITE;
}
return 1;
7 years, 4 months
master - backup: show warning once per command
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=75f23880934a8c...
Commit: 75f23880934a8c1cb192e9a898261320db15043a
Parent: 5bb6266046b11e6e4b47596689e3f4a75ba692a3
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Sun Dec 18 16:36:33 2016 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Sun Dec 18 19:38:30 2016 +0100
backup: show warning once per command
When command calls backup() more then once (which is actually not
wanted) this warning message is shown repeatedly:
"WARNING: This metadata update is NOT backed up."
Instead now print message just once and less confuse user.
---
WHATS_NEW | 1 +
lib/format_text/archiver.c | 4 +++-
2 files changed, 4 insertions(+), 1 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index e7abf59..fbaa369 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.169 -
=====================================
+ Warn about command not making metadata backup just once per command.
Enable usage of cached volume as thin volume's external origin.
Support cache volume activation with -real layer.
Improve search of lock-holder for external origin and thin-pool.
diff --git a/lib/format_text/archiver.c b/lib/format_text/archiver.c
index 92799e4..d381155 100644
--- a/lib/format_text/archiver.c
+++ b/lib/format_text/archiver.c
@@ -35,6 +35,7 @@ struct archive_params {
struct backup_params {
int enabled;
char *dir;
+ int suppress;
};
int archive_init(struct cmd_context *cmd, const char *dir,
@@ -235,7 +236,8 @@ static int _backup(struct volume_group *vg)
int backup_locally(struct volume_group *vg)
{
if (!vg->cmd->backup_params->enabled || !vg->cmd->backup_params->dir) {
- log_warn("WARNING: This metadata update is NOT backed up");
+ log_warn_suppress(vg->cmd->backup_params->suppress++,
+ "WARNING: This metadata update is NOT backed up.");
return 1;
}
7 years, 4 months
master - lvconvert: support cache to external origin conversion
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=5bb6266046b11e...
Commit: 5bb6266046b11e6e4b47596689e3f4a75ba692a3
Parent: 69434c2eca5bb7667d73916a28d03b8c687aea32
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Sat Dec 17 22:41:27 2016 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Sun Dec 18 19:35:27 2016 +0100
lvconvert: support cache to external origin conversion
Add this functionality to lvconvert:
'lvconvert --thin cachedLV --thinpool vg/poll'
Converts cachedLV to external origin (which will be read-only).
New thin volume is created in thinpool LV and it's using external
origin as source for unprovisioned chunks.
This conversion happens online (while volume is in use).
Thin LV remains fully writable.
Cached external origin no longer could be written so cache will be used
ONLY for read operations. For this limitation we require cache mode
to be writethrough (as writeback cannot write to read-only volumes).
When thinLV is later removed cached external origin is again
fully usable, just note, LV remain in 'read-only' mode.
When read-write is needed, 'lvchange -prw' has to be used.
Single external origin could be user by multiple thinLV in
multiple differen thin pool.
---
WHATS_NEW | 1 +
lib/metadata/cache_manip.c | 1 -
tools/lvconvert.c | 39 +++++++++++++++++++++++++++++++++++++--
3 files changed, 38 insertions(+), 3 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index 74638fd..e7abf59 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.169 -
=====================================
+ Enable usage of cached volume as thin volume's external origin.
Support cache volume activation with -real layer.
Improve search of lock-holder for external origin and thin-pool.
Support status checking of cache volume used in layer.
diff --git a/lib/metadata/cache_manip.c b/lib/metadata/cache_manip.c
index ed72fae..12b1054 100644
--- a/lib/metadata/cache_manip.c
+++ b/lib/metadata/cache_manip.c
@@ -324,7 +324,6 @@ int validate_lv_cache_create_origin(const struct logical_volume *origin_lv)
lv_is_thin_volume(origin_lv) || lv_is_thin_pool_metadata(origin_lv) ||
lv_is_origin(origin_lv) || lv_is_merging_origin(origin_lv) ||
lv_is_cow(origin_lv) || lv_is_merging_cow(origin_lv) ||
- lv_is_external_origin(origin_lv) ||
lv_is_virtual(origin_lv)) {
log_error("Cache is not supported with %s segment type of the original logical volume %s.",
first_seg(origin_lv)->segtype->name, display_lvname(origin_lv));
diff --git a/tools/lvconvert.c b/tools/lvconvert.c
index dc32e37..393d286 100644
--- a/tools/lvconvert.c
+++ b/tools/lvconvert.c
@@ -2825,7 +2825,6 @@ static int _lvconvert_thin(struct cmd_context *cmd,
if (lv_is_locked(lv) ||
!lv_is_visible(lv) ||
- lv_is_cache_type(lv) ||
lv_is_cow(lv) ||
lv_is_pool(lv) ||
lv_is_pool_data(lv) ||
@@ -3725,6 +3724,12 @@ static int _convert_cache_volume_splitmirrors(struct cmd_context *cmd, struct lo
* Convert a cache LV to a thin pool (using the cache LV for thin pool data).
* lvconvert --type thin-pool LV
*
+ * Convert a cache LV to a thin volume with cached external origin using given
+ * thinpool tpLV (when not yet Thinpool convert it to thin-pool first).
+ * Conversion is 2-step process in this case.
+ * Only writethrough cacheLV can be converted as external origin is read-only.
+ * lvconvert --thin cacheLV --thinpool tpLV
+ *
* Alternate syntax:
* This is equivalent to above, but not preferred because it's ambiguous and inconsistent.
* lvconvert --thinpool LV
@@ -3732,7 +3737,37 @@ static int _convert_cache_volume_splitmirrors(struct cmd_context *cmd, struct lo
static int _convert_cache_volume_thin_pool(struct cmd_context *cmd, struct logical_volume *lv,
struct lvconvert_params *lp)
{
- return _lvconvert_pool(cmd, lv, lp);
+ int is_clean;
+ const struct lv_segment *pool_seg;
+
+ if (!_lvconvert_pool(cmd, lv, lp))
+ return_0;
+
+ if (lv_is_cache(lv) && !lv_is_pool_data(lv)) {
+ pool_seg = first_seg(first_seg(lv)->pool_lv);
+ if (pool_seg->cache_mode != CACHE_MODE_WRITETHROUGH) {
+ log_error("Cannot convert cache volume %s with %s cache mode to external origin.",
+ display_lvname(lv),
+ get_cache_mode_name(pool_seg));
+ log_error("To proceed, run 'lvchange --cachemode writethrough %s'.",
+ display_lvname(lv));
+ return 0;
+ }
+
+ if (!lv_cache_wait_for_clean(lv, &is_clean))
+ return_0;
+
+ if (!is_clean) {
+ log_error("Cache %s is not clean, refusing to convert to external origin.",
+ display_lvname(lv));
+ return 0;
+ }
+
+ if (!_lvconvert_thin(cmd, lv, lp))
+ return_0;
+ }
+
+ return 1;
}
/*
7 years, 4 months
master - cache: improve activation with -real
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=69434c2eca5bb7...
Commit: 69434c2eca5bb7667d73916a28d03b8c687aea32
Parent: 954c59779d35436a6d2f28482ec1ed6dc128844c
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Sun Dec 18 15:05:31 2016 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Sun Dec 18 19:30:50 2016 +0100
cache: improve activation with -real
When cache volume may be converted from normal to -real layer LV
we need to improve logic for call cache_check.
With this patch, we register call for cache_check only when metadata LV
is not yet present in active table slot (should match initial table
load).
This avoids unwanted checking when cache would become layer device
online.
---
WHATS_NEW | 1 +
lib/activate/dev_manager.c | 4 ++++
2 files changed, 5 insertions(+), 0 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index 6ab2b19..74638fd 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.169 -
=====================================
+ Support cache volume activation with -real layer.
Improve search of lock-holder for external origin and thin-pool.
Support status checking of cache volume used in layer.
Avoid shifting by one number of blocks when clearing dirty cache volume.
diff --git a/lib/activate/dev_manager.c b/lib/activate/dev_manager.c
index 8245454..520a0a1 100644
--- a/lib/activate/dev_manager.c
+++ b/lib/activate/dev_manager.c
@@ -2901,6 +2901,10 @@ static int _add_new_lv_to_dtree(struct dev_manager *dm, struct dm_tree *dtree,
return_0;
if (lv_is_cache(lv) &&
+ /* Register callback only for layer activation or non-layered cache LV */
+ (layer || !lv_layer(lv)) &&
+ /* Register callback when metadata LV is NOT already active */
+ !_cached_dm_info(dm->mem, dtree, first_seg(first_seg(lv)->pool_lv)->metadata_lv, NULL) &&
!_pool_register_callback(dm, dnode, lv))
return_0;
7 years, 4 months
master - libdm: drop callback on revert path
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=954c59779d3543...
Commit: 954c59779d35436a6d2f28482ec1ed6dc128844c
Parent: 29b0e42be3026a11c86fc05f82f6a14e71d26cc8
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Sat Dec 17 22:40:59 2016 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Sun Dec 18 19:29:08 2016 +0100
libdm: drop callback on revert path
The system is likely in some very inconsisten state.
Do not try to make it even more problematic with trying
to invoke tools like thin_check via callback.
---
WHATS_NEW_DM | 1 +
libdm/libdm-deptree.c | 4 ++++
2 files changed, 5 insertions(+), 0 deletions(-)
diff --git a/WHATS_NEW_DM b/WHATS_NEW_DM
index ab32bdb..d57ddd7 100644
--- a/WHATS_NEW_DM
+++ b/WHATS_NEW_DM
@@ -1,5 +1,6 @@
Version 1.02.138 -
=====================================
+ Do not try call callback when reverting activation on error path.
Fix file mapping for extents with physically adjacent extents.
Validation vsnprintf result in runtime translate of dm_log (1.02.136).
Separate filemap extent allocation from region table.
diff --git a/libdm/libdm-deptree.c b/libdm/libdm-deptree.c
index cf6a06e..c5226a7 100644
--- a/libdm/libdm-deptree.c
+++ b/libdm/libdm-deptree.c
@@ -2778,6 +2778,10 @@ static int _dm_tree_revert_activated(struct dm_tree_node *parent)
dm_list_iterate_items_gen(child, &parent->activated, activated_list) {
log_debug_activation("Reverting %s.", child->name);
+ if (child->callback) {
+ log_debug_activation("Dropping callback for %s.", child->name);
+ child->callback = NULL;
+ }
if (!_deactivate_node(child->name, child->info.major, child->info.minor,
&child->dtree->cookie, child->udev_flags, 0)) {
log_error("Unable to deactivate %s (%" PRIu32
7 years, 4 months
master - lv: fix lock holder for external origin
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=29b0e42be3026a...
Commit: 29b0e42be3026a11c86fc05f82f6a14e71d26cc8
Parent: a24eae6e82f365c66f4faeabc975ead0c476916b
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Sat Dec 17 22:40:14 2016 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Sun Dec 18 19:25:25 2016 +0100
lv: fix lock holder for external origin
External origin could be reloaded via more locks.
It's actually even more complex then thin-pool,
as it may be active on more nodes for linear LVs
(and maybe even more types).
External origin is always read-only thus unmodifiable
device so there should not be a problem accesing it
through multiple nodes.
Also for thin-pool check first presence of active thin-pool.
FIXME:
It's not easy to detect on which nodes this device is active
Thus manipulation with such device may require checking every
node and it active state and refresh.
But since such setup is quite complex to prepare and use,
hopefully there are not user trying to 'explore' this usage yet.
---
WHATS_NEW | 1 +
lib/metadata/lv.c | 24 +++++++++++++-----------
2 files changed, 14 insertions(+), 11 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index 6b9a310..6ab2b19 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.169 -
=====================================
+ Improve search of lock-holder for external origin and thin-pool.
Support status checking of cache volume used in layer.
Avoid shifting by one number of blocks when clearing dirty cache volume.
Extend metadata validation of external origin LV use count.
diff --git a/lib/metadata/lv.c b/lib/metadata/lv.c
index 1084149..8587902 100644
--- a/lib/metadata/lv.c
+++ b/lib/metadata/lv.c
@@ -1551,14 +1551,19 @@ const struct logical_volume *lv_lock_holder(const struct logical_volume *lv)
if (lv_is_cow(lv))
return lv_lock_holder(origin_from_cow(lv));
- if (lv_is_thin_pool(lv)) {
- /* Find any active LV from the pool */
- dm_list_iterate_items(sl, &lv->segs_using_this_lv)
- if (lv_is_active(sl->seg->lv)) {
- log_debug_activation("Thin volume %s is active.",
- display_lvname(lv));
- return sl->seg->lv;
- }
+ if (lv_is_thin_pool(lv) ||
+ lv_is_external_origin(lv)) {
+ /* FIXME: Ensure cluster keeps thin-pool active exlusively.
+ * External origin can be activated on more nodes (depends on type).
+ */
+ if (!lv_is_active(lv))
+ /* Find any active LV from the pool or external origin */
+ dm_list_iterate_items(sl, &lv->segs_using_this_lv)
+ if (lv_is_active(sl->seg->lv)) {
+ log_debug_activation("Thin volume %s is active.",
+ display_lvname(lv));
+ return sl->seg->lv;
+ }
return lv;
}
@@ -1573,9 +1578,6 @@ const struct logical_volume *lv_lock_holder(const struct logical_volume *lv)
lv_is_thin_volume(sl->seg->lv) &&
first_seg(lv)->pool_lv == sl->seg->pool_lv)
continue; /* Skip thin snaphost */
- if (lv_is_external_origin(lv) &&
- lv_is_thin_volume(sl->seg->lv))
- continue; /* Skip external origin */
if (lv_is_pending_delete(sl->seg->lv))
continue; /* Skip deleted LVs */
return lv_lock_holder(sl->seg->lv);
7 years, 4 months