master - cleanup: use log_warn
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=6cb2c35d1654558efc1...
Commit: 6cb2c35d1654558efc1b37ca44d77f83682446c7
Parent: ee37838b1149f3f8d5c34dc2d459421f8e085bbb
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Thu Mar 8 10:29:49 2018 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Thu Mar 8 10:40:27 2018 +0100
cleanup: use log_warn
There message are not causing command failure thus turn them
into warnings.
---
lib/activate/dev_manager.c | 8 +++++---
1 files changed, 5 insertions(+), 3 deletions(-)
diff --git a/lib/activate/dev_manager.c b/lib/activate/dev_manager.c
index dab1603..6b042fb 100644
--- a/lib/activate/dev_manager.c
+++ b/lib/activate/dev_manager.c
@@ -447,13 +447,15 @@ static int _ignore_suspended_snapshot_component(struct device *dev)
next = dm_get_next_target(dmt, next, &start, &length, &target_type, ¶ms);
if (!target_type || !strcmp(target_type, TARGET_NAME_SNAPSHOT)) {
if (!params || sscanf(params, "%d:%d %d:%d", &major1, &minor1, &major2, &minor2) != 4) {
- log_error("Incorrect snapshot table found.");
+ log_warn("WARNING: Incorrect snapshot table found for %d:%d.",
+ (int)MAJOR(dev->dev), (int)MINOR(dev->dev));
goto out;
}
r = r || _device_is_suspended(major1, minor1) || _device_is_suspended(major2, minor2);
} else if (!strcmp(target_type, TARGET_NAME_SNAPSHOT_ORIGIN)) {
if (!params || sscanf(params, "%d:%d", &major1, &minor1) != 2) {
- log_error("Incorrect snapshot-origin table found.");
+ log_warn("WARNING: Incorrect snapshot-origin table found for %d:%d.",
+ (int)MAJOR(dev->dev), (int)MINOR(dev->dev));
goto out;
}
r = r || _device_is_suspended(major1, minor1);
@@ -488,7 +490,7 @@ static int _ignore_unusable_thins(struct device *dev)
dm_get_next_target(dmt, next, &start, &length, &target_type, ¶ms);
if (!params || sscanf(params, "%d:%d", &major, &minor) != 2) {
- log_error("Failed to get thin-pool major:minor for thin device %d:%d.",
+ log_warn("WARNING: Cannot get thin-pool major:minor for thin device %d:%d.",
(int)MAJOR(dev->dev), (int)MINOR(dev->dev));
goto out;
}
6 years, 1 month
master - cache: fix lock usage for cache conversion
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=ee37838b1149f3f8d5c...
Commit: ee37838b1149f3f8d5c34dc2d459421f8e085bbb
Parent: 7421252edccead6ce395cabc361ed175236bcb5c
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Thu Mar 8 10:30:46 2018 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Thu Mar 8 10:39:47 2018 +0100
cache: fix lock usage for cache conversion
Just like with lvcreate, this lvconvert case also need to properly
check which LV actually holds lock for cached origin - as it might
be i.e. thin-pool tdata subLV.
---
lib/metadata/lv_manip.c | 6 ++++--
1 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/lib/metadata/lv_manip.c b/lib/metadata/lv_manip.c
index bde2a00..9566f3e 100644
--- a/lib/metadata/lv_manip.c
+++ b/lib/metadata/lv_manip.c
@@ -7384,6 +7384,7 @@ static struct logical_volume *_lv_create_an_lv(struct volume_group *vg,
struct logical_volume *lv, *origin_lv = NULL;
struct logical_volume *pool_lv = NULL;
struct logical_volume *tmp_lv;
+ const struct logical_volume *lock_lv;
struct lv_segment *seg, *pool_seg;
int thin_pool_was_active = -1; /* not scanned, inactive, active */
int historical;
@@ -7547,11 +7548,12 @@ static struct logical_volume *_lv_create_an_lv(struct volume_group *vg,
}
/* Validate cache origin is exclusively active */
+ lock_lv = lv_lock_holder(origin_lv);
if (vg_is_clustered(origin_lv->vg) &&
locking_is_clustered() &&
locking_supports_remote_queries() &&
- lv_is_active(origin_lv) &&
- !lv_is_active_exclusive(origin_lv)) {
+ lv_is_active(lock_lv) &&
+ !lv_is_active_exclusive(lock_lv)) {
log_error("Cannot cache not exclusively active origin volume %s.",
display_lvname(origin_lv));
return NULL;
6 years, 1 month
master - snapshot: skip invalid snapshost
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=7421252edccead6ce39...
Commit: 7421252edccead6ce395cabc361ed175236bcb5c
Parent: a6fdb9d9d70f51c49ad11a87ab4243344e6701a3
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Thu Mar 8 10:32:15 2018 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Thu Mar 8 10:39:44 2018 +0100
snapshot: skip invalid snapshost
When scanning DM device, skip automatically invalid snapshot devices.
They behave just like 'error' device.
---
WHATS_NEW | 1 +
lib/activate/dev_manager.c | 24 ++++++++++++++++++++++++
2 files changed, 25 insertions(+), 0 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index d0bc386..16ad1d9 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.178 -
=====================================
+ Automatically avoid reading invalid snapshots during device scan.
Ensure COW device is writable even for read-only thick snapshots.
Support activation of component LVs in read-only mode.
Extend internal library to recognize and work with component LV.
diff --git a/lib/activate/dev_manager.c b/lib/activate/dev_manager.c
index b8b937d..dab1603 100644
--- a/lib/activate/dev_manager.c
+++ b/lib/activate/dev_manager.c
@@ -518,6 +518,24 @@ out:
return r;
}
+static int _ignore_invalid_snapshot(const char *params)
+{
+ struct dm_status_snapshot *s;
+ struct dm_pool *mem;
+ int r;
+
+ if (!(mem = dm_pool_create("invalid snapshots", 128)))
+ return_0;
+
+ if (!dm_get_status_snapshot(mem, params, &s))
+ return_0;
+
+ r = s->invalid;
+ dm_pool_destroy(mem);
+
+ return r;
+}
+
/*
* device_is_usable
* @dev
@@ -633,6 +651,12 @@ int device_is_usable(struct device *dev, struct dev_usable_check_params check)
goto out;
}
+ if (target_type && !strcmp(target_type, TARGET_NAME_SNAPSHOT) &&
+ _ignore_invalid_snapshot(params)) {
+ log_debug_activation("%s: Invalid %s device %s not usable.", dev_name(dev), target_type, name);
+ goto out;
+ }
+
/* TODO: extend check struct ? */
if (target_type && !strcmp(target_type, TARGET_NAME_THIN) &&
!_ignore_unusable_thins(dev)) {
6 years, 1 month
master - snapshot: keep COW writable for read-only volumes
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=a6fdb9d9d70f51c49ad...
Commit: a6fdb9d9d70f51c49ad11a87ab4243344e6701a3
Parent: 15b6793528de99a70e988d09502ca33ad1d7c575
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Thu Mar 8 10:27:04 2018 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Thu Mar 8 10:39:03 2018 +0100
snapshot: keep COW writable for read-only volumes
When snapshot is created in read-only mode with 'lvcreate -s -pr...',
lvm2 still needs to be able to write to layered -cow volume
to store metadata and exceptions blocks.
TODO: in some case we might be able to do full tree with read-only
volume but this probably needs futher validation:
1. checking snapshot header already exist
2. origin & snapshot are both in read-only mode.
---
WHATS_NEW | 1 +
lib/activate/activate.c | 2 +-
lib/activate/dev_manager.c | 7 +++++--
lib/activate/dev_manager.h | 2 +-
4 files changed, 8 insertions(+), 4 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index 69345c6..d0bc386 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.178 -
=====================================
+ Ensure COW device is writable even for read-only thick snapshots.
Support activation of component LVs in read-only mode.
Extend internal library to recognize and work with component LV.
Skip duplicate check for active LV when prompting for its removal.
diff --git a/lib/activate/activate.c b/lib/activate/activate.c
index cb9b1cf..777fc21 100644
--- a/lib/activate/activate.c
+++ b/lib/activate/activate.c
@@ -2694,7 +2694,7 @@ static int _lv_activate(struct cmd_context *cmd, const char *lvid_s,
* Nothing to do?
*/
if (info.exists && !info.suspended && info.live_table &&
- (info.read_only == read_only_lv(lv, laopts))) {
+ (info.read_only == read_only_lv(lv, laopts, NULL))) {
r = 1;
log_debug_activation("LV %s is already active.", display_lvname(lv));
goto out;
diff --git a/lib/activate/dev_manager.c b/lib/activate/dev_manager.c
index a40fd2b..b8b937d 100644
--- a/lib/activate/dev_manager.c
+++ b/lib/activate/dev_manager.c
@@ -75,8 +75,11 @@ struct lv_layer {
int visible_component;
};
-int read_only_lv(const struct logical_volume *lv, const struct lv_activate_opts *laopts)
+int read_only_lv(const struct logical_volume *lv, const struct lv_activate_opts *laopts, const char *layer)
{
+ if (layer && lv_is_cow(lv))
+ return 0; /* Keep snapshot's COW volume writable */
+
return (laopts->read_only || !(lv->status & LVM_WRITE));
}
@@ -2824,7 +2827,7 @@ static int _add_new_lv_to_dtree(struct dev_manager *dm, struct dm_tree *dtree,
if (!(dnode = dm_tree_add_new_dev_with_udev_flags(dtree, name, dlid,
layer ? UINT32_C(0) : (uint32_t) lv->major,
layer ? UINT32_C(0) : (uint32_t) lv->minor,
- read_only_lv(lv, laopts),
+ read_only_lv(lv, laopts, layer),
((lv->vg->status & PRECOMMITTED) | laopts->revert) ? 1 : 0,
lvlayer,
_get_udev_flags(dm, lv, layer, laopts->noscan, laopts->temporary,
diff --git a/lib/activate/dev_manager.h b/lib/activate/dev_manager.h
index ba198f5..5be417b 100644
--- a/lib/activate/dev_manager.h
+++ b/lib/activate/dev_manager.h
@@ -27,7 +27,7 @@ struct dm_info;
struct device;
struct lv_seg_status;
-int read_only_lv(const struct logical_volume *lv, const struct lv_activate_opts *laopts);
+int read_only_lv(const struct logical_volume *lv, const struct lv_activate_opts *laopts, const char *layer);
/*
* Constructor and destructor.
6 years, 1 month
master - tests: skipping test waiting for fixed kernel
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=15b6793528de99a70e9...
Commit: 15b6793528de99a70e988d09502ca33ad1d7c575
Parent: b05caca77e3df828d69d13ef52f43cc1531d6481
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Tue Mar 6 15:32:27 2018 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Tue Mar 6 15:42:49 2018 +0100
tests: skipping test waiting for fixed kernel
Once working kernel is released, reenable me...
---
.../lvconvert-raid-reshape-stripes-load-fail.sh | 3 +++
1 files changed, 3 insertions(+), 0 deletions(-)
diff --git a/test/shell/lvconvert-raid-reshape-stripes-load-fail.sh b/test/shell/lvconvert-raid-reshape-stripes-load-fail.sh
index 38af778..3fac9a4 100644
--- a/test/shell/lvconvert-raid-reshape-stripes-load-fail.sh
+++ b/test/shell/lvconvert-raid-reshape-stripes-load-fail.sh
@@ -15,6 +15,9 @@ SKIP_WITH_LVMPOLLD=1
. lib/inittest
+# FIXME - skippping until properly kernel is released
+skip
+
# Test reshaping under io load
which mkfs.ext4 || skip
6 years, 1 month
master - tests: component activation
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=b05caca77e3df828d69...
Commit: b05caca77e3df828d69d13ef52f43cc1531d6481
Parent: eb3597acb3af2e6f21893b2e3bdfa84f2ca301b1
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Fri Mar 2 15:07:25 2018 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Tue Mar 6 15:42:49 2018 +0100
tests: component activation
---
test/shell/component-cache.sh | 92 ++++++++++++++++++++++++++++++++++++++++
test/shell/component-mirror.sh | 70 ++++++++++++++++++++++++++++++
test/shell/component-raid.sh | 50 ++++++++++++++++++++++
test/shell/component-thin.sh | 49 +++++++++++++++++++++
4 files changed, 261 insertions(+), 0 deletions(-)
diff --git a/test/shell/component-cache.sh b/test/shell/component-cache.sh
new file mode 100644
index 0000000..2060b31
--- /dev/null
+++ b/test/shell/component-cache.sh
@@ -0,0 +1,92 @@
+#!/usr/bin/env bash
+
+# Copyright (C) 2018 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
+
+# Exercise activation of cache component devices
+
+SKIP_WITH_LVMLOCKD=1
+SKIP_WITH_LVMPOLLD=1
+
+. lib/inittest
+
+aux have_cache 1 3 0 || skip
+
+aux prepare_vg 5 80
+
+lvcreate --type cache-pool -L 2 -n cpool $vg
+lvcreate -H -L 4 -n corigin --cachepool $vg/cpool
+lvchange -an $vg
+
+for j in 1 2
+do
+
+# Activate supported components
+for i in cpool_cmeta cpool_cdata corigin_corig
+do
+ test ! -e "$DM_DEV_DIR/$vg/$i"
+ lvchange -ay -y $vg/$i
+ # check usable link is there
+ test -e "$DM_DEV_DIR/$vg/$i"
+
+ # cannot take snapshot of any active component LV
+ test "$j" -eq 2 || not lvcreate -s -L1 $vg/$i
+done
+
+# After 1st. phase deactivation works
+# Volumes are left active for vgremove on 2nd.. pass
+test "$j" -eq 2 || lvchange -an $vg
+
+done
+
+# Cannot active cached LV while any component LV is active
+not lvchange -ay $vg/corigin |& tee err
+grep "prohibited" err
+
+lvs -a $vg
+
+# Can split for writethrough|passthrough
+# deactivates all components as well...
+lvconvert --splitcache $vg/corigin
+lvs -a $vg
+
+# Cannot cache LV while components are active
+lvcreate -L 4 -n $lv2 $vg
+lvchange -ay -y $vg/cpool_cmeta
+
+not lvconvert -y --cachepool $vg/cpool -H $lv2
+
+lvremove -f $vg
+lvs -a $vg
+
+if aux have_thin 1 0 0 ; then
+
+lvcreate --type cache-pool -L 2 -n cpool $vg
+lvcreate -H -L 4 -n tpool --cachepool $vg/cpool
+lvchange -an $vg
+lvs -a $vg
+# Cannot convert to thin-pool with component LV active
+lvchange -ay -y $vg/cpool_cmeta
+
+# Conversion does not need to activate data device, so it can proceed ??
+lvconvert -y --thinpool $vg/tpool
+
+# Thin-pool cannot be activated
+not lvchange -ay $vg/tpool |& tee err
+grep "prohibited" err
+
+lvs -a $vg
+
+fi
+
+lvs -a $vg
+
+# And final removal works
+vgremove -f $vg
diff --git a/test/shell/component-mirror.sh b/test/shell/component-mirror.sh
new file mode 100644
index 0000000..b565c98
--- /dev/null
+++ b/test/shell/component-mirror.sh
@@ -0,0 +1,70 @@
+#!/usr/bin/env bash
+
+# Copyright (C) 2018 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
+
+# Exercise activation of mirror component devices
+
+SKIP_WITH_LVMLOCKD=1
+SKIP_WITH_LVMPOLLD=1
+
+. lib/inittest
+
+aux have_cache 1 3 0 || skip
+
+aux prepare_vg 5 80
+
+lvcreate -aey --type mirror -L 2 -m 1 -n $lv1 $vg
+lvchange -an $vg
+
+lvs -a
+
+lvchange -an $vg
+
+for k in 1 2
+do
+
+# Activate supported components
+for i in ${lv1}_mimage_0 ${lv1}_mimage_1 ${lv1}_mlog
+do
+ test ! -e "$DM_DEV_DIR/$vg/$i"
+ lvchange -ay -y $vg/$i
+ # check usable link is there
+ test -e "$DM_DEV_DIR/$vg/$i"
+done
+
+# Deactivation works in 1st. pass
+test $k -eq 2 || lvchange -an $vg
+
+done
+
+# Cannot be resized
+not lvextend -L+20 $vg/$lv1 |& tee err
+grep "Cannot resize" err
+
+not lvresize -L-20 $vg/$lv1 |& tee err
+grep "Cannot resize" err
+
+# Cannot be converted
+lvcreate -aey -L10 -n $lv2 $vg
+not lvconvert -y -s $vg/$lv1 $lv2 |& tee err
+grep "Cannot use" err
+
+# Cannot be splitted
+not lvconvert --splitmirrors 1 -n split $vg/$lv1 |& tee err
+grep "Cannot convert" err
+
+# Cannot add new leg
+not lvconvert -m+1 $vg/$lv1 |& tee err
+grep "Cannot convert" err
+
+lvs -a
+
+vgremove -f $vg
diff --git a/test/shell/component-raid.sh b/test/shell/component-raid.sh
new file mode 100644
index 0000000..84f823f
--- /dev/null
+++ b/test/shell/component-raid.sh
@@ -0,0 +1,50 @@
+#!/usr/bin/env bash
+
+# Copyright (C) 2018 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
+
+# Exercise activation of raid component devices
+
+SKIP_WITH_LVMLOCKD=1
+SKIP_WITH_LVMPOLLD=1
+
+. lib/inittest
+
+aux have_cache 1 3 0 || skip
+
+aux prepare_vg 5 80
+
+lvcreate --type raid1 -L 2 -m 1 -n $lv1 $vg
+lvchange -an $vg
+
+lvs -a $vg
+
+for k in 1 2
+do
+
+# Activate supported components
+for j in 0 1
+do
+for i in ${lv1}_rimage_$j ${lv1}_rmeta_$j
+do
+ test ! -e "$DM_DEV_DIR/$vg/$i"
+ lvchange -ay -y $vg/$i
+ # check usable link is there
+ test -e "$DM_DEV_DIR/$vg/$i"
+done
+done
+
+# Deactivation works in 1st. pass
+test $k -eq 2 || lvchange -an $vg
+
+done
+
+# And final removal works
+vgremove -f $vg
diff --git a/test/shell/component-thin.sh b/test/shell/component-thin.sh
new file mode 100644
index 0000000..4b1a35b
--- /dev/null
+++ b/test/shell/component-thin.sh
@@ -0,0 +1,49 @@
+#!/usr/bin/env bash
+
+# Copyright (C) 2018 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
+
+# Exercise activation of thin component devices
+
+SKIP_WITH_LVMLOCKD=1
+SKIP_WITH_LVMPOLLD=1
+
+. lib/inittest
+
+aux have_thin 1 0 0 || skip
+
+aux prepare_vg 5 80
+
+lvcreate -T -L2 -V20 $vg/pool -n $lv1
+
+lvs -a
+
+lvchange -an $vg
+
+for i in pool_tdata pool_tmeta
+do
+ lvchange -ay -y $vg/$i
+ # check usable is there
+ test -e "$DM_DEV_DIR/$vg/$i"
+done
+
+lvs -a
+
+# When component LVs are active, thin-pool cannot be actived
+not lvcreate -V20 $vg/pool
+
+
+# FIXME: ATM removal of thin volumes goes 1-by-1 and needs to activate thin-pool.
+# And thin-pool cannot be activate thus vgremove fails.
+# To fix this it would need to be able to remove volumes without activation.
+should vgremove -f $vg
+
+# -ff bypass activation failure
+vgremove -ff $vg
6 years, 1 month
master - activation: support proper /dev names for component LVs
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=eb3597acb3af2e6f218...
Commit: eb3597acb3af2e6f21893b2e3bdfa84f2ca301b1
Parent: 112846ce0b01e5353dfa81979a2d8ccb3e25a900
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Wed Feb 28 17:22:09 2018 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Tue Mar 6 15:42:49 2018 +0100
activation: support proper /dev names for component LVs
When LV is activated AS componet LV - ensure there will
be /dev/vgname/lvname link present for such LV.
---
lib/activate/activate.c | 1 +
lib/activate/activate.h | 1 +
lib/activate/dev_manager.c | 18 ++++++++++++------
3 files changed, 14 insertions(+), 6 deletions(-)
diff --git a/lib/activate/activate.c b/lib/activate/activate.c
index 6333ba9..cb9b1cf 100644
--- a/lib/activate/activate.c
+++ b/lib/activate/activate.c
@@ -2677,6 +2677,7 @@ static int _lv_activate(struct cmd_context *cmd, const char *lvid_s,
/* TODO: should not apply for LVs in maintenance mode */
if (!lv_is_visible(lv) && lv_is_component(lv)) {
laopts->read_only = 1;
+ laopts->component_lv = lv;
} else if (filter)
laopts->read_only = _passes_readonly_filter(cmd, lv);
diff --git a/lib/activate/activate.h b/lib/activate/activate.h
index dc4d3cd..2fc74ce 100644
--- a/lib/activate/activate.h
+++ b/lib/activate/activate.h
@@ -83,6 +83,7 @@ struct lv_activate_opts {
* flags are persistent in udev db for any spurious event
* that follows. */
unsigned resuming; /* Set when resuming after a suspend. */
+ const struct logical_volume *component_lv;
};
void set_activation(int activation, int silent);
diff --git a/lib/activate/dev_manager.c b/lib/activate/dev_manager.c
index 8bf0e47..a40fd2b 100644
--- a/lib/activate/dev_manager.c
+++ b/lib/activate/dev_manager.c
@@ -72,6 +72,7 @@ struct dev_manager {
struct lv_layer {
const struct logical_volume *lv;
const char *old_name;
+ int visible_component;
};
int read_only_lv(const struct logical_volume *lv, const struct lv_activate_opts *laopts)
@@ -1590,7 +1591,8 @@ int dev_manager_mknodes(const struct logical_volume *lv)
return_0;
if (dminfo.exists) {
- if (_lv_has_mknode(lv))
+ /* read-only component LV is also made visible */
+ if (_lv_has_mknode(lv) || (dminfo.read_only && lv_is_component(lv)))
r = _dev_manager_lv_mknodes(lv);
} else
r = _dev_manager_lv_rmnodes(lv);
@@ -1652,7 +1654,8 @@ static int _check_udev_fallback(struct cmd_context *cmd)
#endif /* UDEV_SYNC_SUPPORT */
static uint16_t _get_udev_flags(struct dev_manager *dm, const struct logical_volume *lv,
- const char *layer, int noscan, int temporary)
+ const char *layer, int noscan, int temporary,
+ int visible_component)
{
uint16_t udev_flags = 0;
@@ -1668,7 +1671,7 @@ static uint16_t _get_udev_flags(struct dev_manager *dm, const struct logical_vol
* If not, create just the /dev/mapper content.
*/
/* FIXME: add target's method for this */
- if (lv_is_new_thin_pool(lv))
+ if (lv_is_new_thin_pool(lv) || visible_component)
/* New thin-pool is regular LV with -tpool UUID suffix. */
udev_flags |= DM_UDEV_DISABLE_DISK_RULES_FLAG |
DM_UDEV_DISABLE_OTHER_RULES_FLAG;
@@ -1866,7 +1869,8 @@ static int _add_dev_to_dtree(struct dev_manager *dm, struct dm_tree *dtree,
}
if (info.exists && !dm_tree_add_dev_with_udev_flags(dtree, info.major, info.minor,
- _get_udev_flags(dm, lv, layer, 0, 0))) {
+ _get_udev_flags(dm, lv, layer,
+ 0, 0, 0))) {
log_error("Failed to add device (%" PRIu32 ":%" PRIu32") to dtree.",
info.major, info.minor);
return 0;
@@ -2806,6 +2810,7 @@ static int _add_new_lv_to_dtree(struct dev_manager *dm, struct dm_tree *dtree,
}
lvlayer->lv = lv;
+ lvlayer->visible_component = (laopts->component_lv == lv) ? 1 : 0;
/*
* Add LV to dtree.
@@ -2822,7 +2827,8 @@ static int _add_new_lv_to_dtree(struct dev_manager *dm, struct dm_tree *dtree,
read_only_lv(lv, laopts),
((lv->vg->status & PRECOMMITTED) | laopts->revert) ? 1 : 0,
lvlayer,
- _get_udev_flags(dm, lv, layer, laopts->noscan, laopts->temporary))))
+ _get_udev_flags(dm, lv, layer, laopts->noscan, laopts->temporary,
+ lvlayer->visible_component))))
return_0;
/* Store existing name so we can do rename later */
@@ -2966,7 +2972,7 @@ static int _create_lv_symlinks(struct dev_manager *dm, struct dm_tree_node *root
r = 0;
continue;
}
- if (_lv_has_mknode(lvlayer->lv)) {
+ if (_lv_has_mknode(lvlayer->lv) || lvlayer->visible_component) {
if (!_dev_manager_lv_mknodes(lvlayer->lv))
r = 0;
continue;
6 years, 1 month
master - activation: support activation of component LVs
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=112846ce0b01e5353df...
Commit: 112846ce0b01e5353dfa81979a2d8ccb3e25a900
Parent: 6134a71a906744dec2d602f83915f0adb05e77f7
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Wed Feb 28 17:16:17 2018 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Tue Mar 6 15:42:46 2018 +0100
activation: support activation of component LVs
Occasionaly users may need to peek into 'component devices.
Normally lvm2 does not let users activation component.
This patch adds special mode where user can activate
component LV in a 'read-only' mode i.e.:
lvchange -ay vg/pool_tdata
All devices can be deactivated with:
lvchange -an vg | vgchange -an....
---
WHATS_NEW | 1 +
lib/activate/activate.c | 6 +++++-
lib/commands/toolcontext.h | 2 ++
lib/locking/locking.c | 11 +++++++++++
tools/lvchange.c | 27 ++++++++++++++++++++++++++-
tools/toollib.c | 3 ++-
tools/vgchange.c | 4 +++-
7 files changed, 50 insertions(+), 4 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index 9656da7..69345c6 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.178 -
=====================================
+ Support activation of component LVs in read-only mode.
Extend internal library to recognize and work with component LV.
Skip duplicate check for active LV when prompting for its removal.
Activate correct lock holding LV when it is cached.
diff --git a/lib/activate/activate.c b/lib/activate/activate.c
index aa230fe..6333ba9 100644
--- a/lib/activate/activate.c
+++ b/lib/activate/activate.c
@@ -2673,7 +2673,11 @@ static int _lv_activate(struct cmd_context *cmd, const char *lvid_s,
goto out;
}
- if (filter)
+ /* Component LV activation is enforced to be 'read-only' */
+ /* TODO: should not apply for LVs in maintenance mode */
+ if (!lv_is_visible(lv) && lv_is_component(lv)) {
+ laopts->read_only = 1;
+ } else if (filter)
laopts->read_only = _passes_readonly_filter(cmd, lv);
log_debug_activation("Activating %s%s%s%s%s.", display_lvname(lv),
diff --git a/lib/commands/toolcontext.h b/lib/commands/toolcontext.h
index 3921167..4225c57 100644
--- a/lib/commands/toolcontext.h
+++ b/lib/commands/toolcontext.h
@@ -166,6 +166,8 @@ struct cmd_context {
unsigned lv_notify:1;
unsigned pv_notify:1;
unsigned use_aio:1;
+ unsigned activate_component:1; /* command activates component LV */
+ unsigned process_component_lvs:1; /* command processes also component LVs */
/*
* Filtering.
diff --git a/lib/locking/locking.c b/lib/locking/locking.c
index 1e1be56..f90bd2d 100644
--- a/lib/locking/locking.c
+++ b/lib/locking/locking.c
@@ -252,6 +252,7 @@ static int _lock_vol(struct cmd_context *cmd, const char *resource,
uint32_t lck_type = flags & LCK_TYPE_MASK;
uint32_t lck_scope = flags & LCK_SCOPE_MASK;
int ret = 0;
+ const struct logical_volume *active_lv;
block_signals(flags);
_lock_memory(cmd, lv_op);
@@ -268,6 +269,16 @@ static int _lock_vol(struct cmd_context *cmd, const char *resource,
goto out;
}
+ /* When trying activating component LV, make sure none of
+ * sub component LV or LVs that are using it are active */
+ if (lv && ((lck_type == LCK_READ) || (lck_type == LCK_EXCL)) &&
+ ((!lv_is_visible(lv) && (active_lv = lv_holder_is_active(lv))) ||
+ (active_lv = lv_component_is_active(lv)))) {
+ log_error("Activation of logical volume %s is prohibited while logical volume %s is active.",
+ display_lvname(lv), display_lvname(active_lv));
+ goto out;
+ }
+
if (cmd->metadata_read_only && lck_type == LCK_WRITE &&
strcmp(resource, VG_GLOBAL)) {
log_error("Operation prohibited while global/metadata_read_only is set.");
diff --git a/tools/lvchange.c b/tools/lvchange.c
index 288b04c..0aac5ac 100644
--- a/tools/lvchange.c
+++ b/tools/lvchange.c
@@ -1266,6 +1266,11 @@ int lvchange_properties_cmd(struct cmd_context *cmd, int argc, char **argv)
{
int ret;
+ if (cmd->activate_component) {
+ log_error("Cannot change LV properties when activating component LVs.");
+ return 0;
+ }
+
/*
* A command def rule allows only some options when LV is partial,
* so handles_missing_pvs will only affect those.
@@ -1362,7 +1367,10 @@ static int _lvchange_activate_check(struct cmd_context *cmd,
struct processing_handle *handle,
int lv_is_named_arg)
{
- if (!lv_is_visible(lv)) {
+ if (!lv_is_visible(lv) &&
+ !cmd->activate_component && /* activation of named component LV */
+ ((first_seg(lv)->status & MERGING) || /* merging already started */
+ !cmd->process_component_lvs)) { /* deactivation of a component LV */
if (lv_is_named_arg)
log_error("Operation not permitted on hidden LV %s.", display_lvname(lv));
return 0;
@@ -1391,6 +1399,23 @@ int lvchange_activate_cmd(struct cmd_context *cmd, int argc, char **argv)
if (do_activate)
cmd->lockd_vg_enforce_sh = 1;
+ /* When activating, check if given LV is a component LV */
+ if (do_activate) {
+ if ((argc == 1) && is_component_lvname(argv[0])) {
+ /* With single arg with reserved name prompt for component activation */
+ if (arg_is_set(cmd, yes_ARG) ||
+ (yes_no_prompt("Do you want to activate component LV "
+ "in read-only mode? [y/n]: ") == 'y')) {
+ log_print_unless_silent("Allowing activation of component LV.");
+ cmd->activate_component = 1;
+ }
+
+ if (sigint_caught())
+ return_ECMD_FAILED;
+ }
+ } else /* Component LVs might be active, support easy deactivation */
+ cmd->process_component_lvs = 1;
+
ret = process_each_lv(cmd, argc, argv, NULL, NULL, 0,
NULL, &_lvchange_activate_check, &_lvchange_activate_single);
diff --git a/tools/toollib.c b/tools/toollib.c
index 0958f2f..eab6223 100644
--- a/tools/toollib.c
+++ b/tools/toollib.c
@@ -3058,7 +3058,8 @@ int process_each_lv_in_vg(struct cmd_context *cmd, struct volume_group *vg,
* Only let hidden LVs through if --all was used or the LVs
* were specifically named on the command line.
*/
- if (!lvargs_supplied && !lv_is_visible(lvl->lv) && !arg_is_set(cmd, all_ARG))
+ if (!lvargs_supplied && !lv_is_visible(lvl->lv) && !arg_is_set(cmd, all_ARG) &&
+ (!cmd->process_component_lvs || !lv_is_component(lvl->lv)))
continue;
/*
diff --git a/tools/vgchange.c b/tools/vgchange.c
index 616a9d3..6d739fe 100644
--- a/tools/vgchange.c
+++ b/tools/vgchange.c
@@ -92,7 +92,7 @@ static int _activate_lvs_in_vg(struct cmd_context *cmd, struct volume_group *vg,
lv = lvl->lv;
- if (!lv_is_visible(lv))
+ if (!lv_is_visible(lv) && (!cmd->process_component_lvs || !lv_is_component(lv)))
continue;
/* If LV is sparse, activate origin instead */
@@ -222,6 +222,8 @@ int vgchange_activate(struct cmd_context *cmd, struct volume_group *vg,
/* FIXME Move into library where clvmd can use it */
if (do_activate)
check_current_backup(vg);
+ else /* Component LVs might be active, support easy deactivation */
+ cmd->process_component_lvs = 1;
if (do_activate && (active = lvs_in_vg_activated(vg))) {
log_verbose("%d logical volume(s) in volume group \"%s\" "
6 years, 1 month
master - lvconvert: support for convertsion with active component devices
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=6134a71a906744dec2d...
Commit: 6134a71a906744dec2d602f83915f0adb05e77f7
Parent: f92b6f99305a31fe0e12b836942ec429c4828869
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Fri Mar 2 16:34:09 2018 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Tue Mar 6 15:42:07 2018 +0100
lvconvert: support for convertsion with active component devices
If componet devices could be activated alone, ensure they are not breaking
common commands.
TODO: mostly likely this is not a definite list of all needed checks
and more will come later.
---
lib/metadata/cache_manip.c | 7 ++-----
lib/metadata/lv_manip.c | 6 ++++++
tools/lvconvert.c | 12 ++++++++++++
3 files changed, 20 insertions(+), 5 deletions(-)
diff --git a/lib/metadata/cache_manip.c b/lib/metadata/cache_manip.c
index c46266b..5167760 100644
--- a/lib/metadata/cache_manip.c
+++ b/lib/metadata/cache_manip.c
@@ -548,11 +548,8 @@ int lv_cache_remove(struct logical_volume *cache_lv)
/* Localy active volume is needed for writeback */
if (!lv_info(cache_lv->vg->cmd, cache_lv, 1, NULL, 0, 0)) {
/* Give up any remote locks */
- if (!deactivate_lv(cache_lv->vg->cmd, cache_lv)) {
- log_error("Cannot deactivate remotely active cache volume %s.",
- display_lvname(cache_lv));
- return 0;
- }
+ if (!deactivate_lv_with_sub_lv(cache_lv))
+ return_0;
switch (first_seg(cache_seg->pool_lv)->cache_mode) {
case CACHE_MODE_WRITETHROUGH:
diff --git a/lib/metadata/lv_manip.c b/lib/metadata/lv_manip.c
index a1fc0ff..bde2a00 100644
--- a/lib/metadata/lv_manip.c
+++ b/lib/metadata/lv_manip.c
@@ -4872,6 +4872,12 @@ static int _lvresize_check(struct logical_volume *lv,
lp->mirrors = 0;
}
+ if (lv_component_is_active(lv)) {
+ log_error("Cannot resize logical volume %s with active component LV(s).",
+ display_lvname(lv));
+ return 0;
+ }
+
return 1;
}
diff --git a/tools/lvconvert.c b/tools/lvconvert.c
index 63f0715..21db0ef 100644
--- a/tools/lvconvert.c
+++ b/tools/lvconvert.c
@@ -833,6 +833,12 @@ static int _lvconvert_mirrors_aux(struct cmd_context *cmd,
return 1;
}
+ if (lv_component_is_active(lv)) {
+ log_error("Cannot convert logical volume %s with active component LV(s).",
+ display_lvname(lv));
+ return 0;
+ }
+
region_size = adjusted_mirror_region_size(cmd, lv->vg->extent_size,
lv->le_count,
lp->region_size ? : seg->region_size, 0,
@@ -1950,6 +1956,12 @@ static int _lvconvert_snapshot(struct cmd_context *cmd,
if (!validate_snapshot_origin(org))
return_0;
+ if (lv_component_is_active(org)) {
+ log_error("Cannot use logical volume %s with active component LVs for snapshot origin.",
+ display_lvname(org));
+ return 0;
+ }
+
log_warn("WARNING: Converting logical volume %s to snapshot exception store.",
snap_name);
log_warn("THIS WILL DESTROY CONTENT OF LOGICAL VOLUME (filesystem etc.)");
6 years, 1 month
master - lvremove: ensure no subLV is active
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=f92b6f99305a31fe0e1...
Commit: f92b6f99305a31fe0e12b836942ec429c4828869
Parent: 73e93ef5e5e42018c701149a51db17e247dbb9a6
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Fri Mar 2 22:07:14 2018 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Tue Mar 6 15:42:07 2018 +0100
lvremove: ensure no subLV is active
Since component activation is going to be enabled, enusure,
no subLV is active when we deactivate LV.
---
lib/metadata/lv_manip.c | 9 +++------
1 files changed, 3 insertions(+), 6 deletions(-)
diff --git a/lib/metadata/lv_manip.c b/lib/metadata/lv_manip.c
index ff82b2d..a1fc0ff 100644
--- a/lib/metadata/lv_manip.c
+++ b/lib/metadata/lv_manip.c
@@ -1,6 +1,6 @@
/*
* Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved.
- * Copyright (C) 2004-2017 Red Hat, Inc. All rights reserved.
+ * Copyright (C) 2004-2018 Red Hat, Inc. All rights reserved.
*
* This file is part of LVM2.
*
@@ -6086,12 +6086,9 @@ int lv_remove_single(struct cmd_context *cmd, struct logical_volume *lv,
/* Used cache pool, COW or historical LV cannot be activated */
if (!lv_is_used_cache_pool(lv) &&
!lv_is_cow(lv) && !lv_is_historical(lv) &&
- !deactivate_lv(cmd, lv)) {
+ !deactivate_lv_with_sub_lv(lv))
/* FIXME Review and fix the snapshot error paths! */
- log_error("Unable to deactivate logical volume %s.",
- display_lvname(lv));
- return 0;
- }
+ return_0;
if (!archive(vg))
return 0;
6 years, 1 month