master - cleanup: exit earlier in lv_rename_update
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=8bd67f9e5a3d53...
Commit: 8bd67f9e5a3d53d78c83d7c554db300d6f82b97c
Parent: fd31cc9dfc2de1d2867c1c9f09e17403441ca6ad
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Wed Jul 17 14:40:22 2013 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Thu Jul 18 18:16:29 2013 +0200
cleanup: exit earlier in lv_rename_update
List doesn't need to be created when the metadata are not updated.
---
lib/metadata/lv_manip.c | 6 +++---
1 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/lib/metadata/lv_manip.c b/lib/metadata/lv_manip.c
index cb6a6c2..e95deca 100644
--- a/lib/metadata/lv_manip.c
+++ b/lib/metadata/lv_manip.c
@@ -3136,6 +3136,9 @@ int lv_rename_update(struct cmd_context *cmd, struct logical_volume *lv,
return 0;
}
+ if (!update_mda)
+ return 1;
+
lvl.lv = lv;
dm_list_add(&lvs_changed, &lvl.list);
@@ -3143,9 +3146,6 @@ int lv_rename_update(struct cmd_context *cmd, struct logical_volume *lv,
if (lv_is_cow(lv) && lv_is_virtual_origin(lvl2.lv = origin_from_cow(lv)))
dm_list_add_h(&lvs_changed, &lvl2.list);
- if (!update_mda)
- return 1;
-
log_verbose("Writing out updated volume group");
if (!vg_write(vg))
return 0;
10 years, 9 months
master - cleanup: stack and remove braces
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=fd31cc9dfc2de1...
Commit: fd31cc9dfc2de1d2867c1c9f09e17403441ca6ad
Parent: 8606bf316a683ebd14bb4cdf4eb1b3477a790b62
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Tue Jul 16 23:35:56 2013 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Thu Jul 18 18:16:17 2013 +0200
cleanup: stack and remove braces
Add stack trace for error path.
Remove unneeded braces.
---
lib/activate/dev_manager.c | 10 +++++-----
1 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/lib/activate/dev_manager.c b/lib/activate/dev_manager.c
index 281041b..50e52d1 100644
--- a/lib/activate/dev_manager.c
+++ b/lib/activate/dev_manager.c
@@ -817,7 +817,7 @@ static int _percent(struct dev_manager *dm, const char *name, const char *dlid,
event_nr, fail_if_percent_unsupported))
return 1;
- return 0;
+ return_0;
}
/* FIXME Merge with the percent function */
@@ -985,8 +985,8 @@ int dev_manager_snapshot_percent(struct dev_manager *dm,
* Try and get some info on this device.
*/
log_debug_activation("Getting device status percentage for %s", name);
- if (!(_percent(dm, name, dlid, "snapshot", 0, NULL, percent,
- NULL, fail_if_percent_unsupported)))
+ if (!_percent(dm, name, dlid, "snapshot", 0, NULL, percent,
+ NULL, fail_if_percent_unsupported))
return_0;
/* If the snapshot isn't available, percent will be -1 */
@@ -1017,8 +1017,8 @@ int dev_manager_mirror_percent(struct dev_manager *dm,
log_debug_activation("Getting device %s status percentage for %s",
target_type, name);
- if (!(_percent(dm, name, dlid, target_type, wait, lv, percent,
- event_nr, 0)))
+ if (!_percent(dm, name, dlid, target_type, wait, lv, percent,
+ event_nr, 0))
return_0;
return 1;
10 years, 9 months
master - systemd: generator: add lvm2-activation-net.service
by Peter Rajnoha
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=8606bf316a683e...
Commit: 8606bf316a683ebd14bb4cdf4eb1b3477a790b62
Parent: 73e7f6c45ffecc78b1ea4165596355479fb59fe2
Author: Peter Rajnoha <prajnoha(a)redhat.com>
AuthorDate: Wed Jul 17 16:21:18 2013 +0200
Committer: Peter Rajnoha <prajnoha(a)redhat.com>
CommitterDate: Wed Jul 17 16:54:52 2013 +0200
systemd: generator: add lvm2-activation-net.service
The new lvm2-activation-net.service activates LVM volumes
after network-attached devices are set up (iSCSI and FCoE)
if lvmetad is disabled and hence the autoactivation is not
used.
---
WHATS_NEW | 1 +
.../lvm2_activation_generator_systemd_red_hat.c | 60 +++++++++++++-------
2 files changed, 41 insertions(+), 20 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index 5763bdf..ae725bb 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.99 -
===================================
+ Add lvm2-activation-net systemd unit to activate LVs on net-attached storage.
Release memory allocated with _cached_info().
Add whole log_lv and metadata_lv sub volumes when creating partial tree.
Properly use snapshot layer for origin which is also thin volume.
diff --git a/scripts/lvm2_activation_generator_systemd_red_hat.c b/scripts/lvm2_activation_generator_systemd_red_hat.c
index f3a01a2..5514522 100644
--- a/scripts/lvm2_activation_generator_systemd_red_hat.c
+++ b/scripts/lvm2_activation_generator_systemd_red_hat.c
@@ -25,16 +25,27 @@
#define KMSG_DEV_PATH "/dev/kmsg"
#define LVM_CONF_USE_LVMETAD "global/use_lvmetad"
-#define DEFAULT_UNIT_DIR "/tmp"
-#define UNIT_NAME_EARLY "lvm2-activation-early.service"
-#define UNIT_NAME "lvm2-activation.service"
-#define UNIT_TARGET "local-fs.target"
+#define DEFAULT_UNIT_DIR "/tmp"
+#define UNIT_TARGET_LOCAL_FS "local-fs.target"
+#define UNIT_TARGET_REMOTE_FS "remote-fs.target"
static char unit_path[PATH_MAX];
static char target_path[PATH_MAX];
static char message[PATH_MAX];
static int kmsg_fd = -1;
+enum {
+ UNIT_EARLY,
+ UNIT_MAIN,
+ UNIT_NET
+};
+
+static const char *unit_names[] = {
+ [UNIT_EARLY] = "lvm2-activation-early.service",
+ [UNIT_MAIN] = "lvm2-activation.service",
+ [UNIT_NET] = "lvm2-activation-net.service"
+};
+
__attribute__ ((format(printf, 1, 2)))
static void kmsg(const char *format, ...)
{
@@ -92,16 +103,17 @@ out:
return r;
}
-static int generate_unit(const char *dir, int early)
+static int generate_unit(const char *dir, int unit)
{
FILE *f;
- const char *unit = early ? UNIT_NAME_EARLY : UNIT_NAME;
+ const char *unit_name = unit_names[unit];
+ const char *target_name = unit == UNIT_NET ? UNIT_TARGET_REMOTE_FS : UNIT_TARGET_LOCAL_FS;
- if (dm_snprintf(unit_path, PATH_MAX, "%s/%s", dir, unit) < 0)
+ if (dm_snprintf(unit_path, PATH_MAX, "%s/%s", dir, unit_name) < 0)
return 0;
if (!(f = fopen(unit_path, "wxe"))) {
- kmsg("LVM: Failed to create unit file %s: %m.\n", unit);
+ kmsg("LVM: Failed to create unit file %s: %m.\n", unit_name);
return 0;
}
@@ -117,25 +129,31 @@ static int generate_unit(const char *dir, int early)
"SourcePath=/etc/lvm/lvm.conf\n"
"DefaultDependencies=no\n", f);
- if (early) {
- fputs("After=systemd-udev-settle.service\n", f);
- fputs("Before=cryptsetup.target\n", f);
- } else
- fputs("After=lvm2-activation-early.service cryptsetup.target\n", f);
+ if (unit == UNIT_NET) {
+ fputs("After=iscsi.service fcoe.service\n"
+ "Before=remote-fs.target shutdown.target\n", f);
+ } else {
+ if (unit == UNIT_EARLY) {
+ fputs("After=systemd-udev-settle.service\n", f);
+ fputs("Before=cryptsetup.target\n", f);
+ } else
+ fputs("After=lvm2-activation-early.service cryptsetup.target\n", f);
+
+ fputs("Before=local-fs.target shutdown.target\n"
+ "Wants=systemd-udev-settle.service\n\n", f);
+ }
- fputs("Before=local-fs.target shutdown.target\n"
- "Wants=systemd-udev-settle.service\n\n"
- "[Service]\n"
+ fputs("[Service]\n"
"ExecStart=/usr/sbin/lvm vgchange -aay --sysinit\n"
"Type=oneshot\n", f);
if (fclose(f) < 0) {
- kmsg("LVM: Failed to write unit file %s: %m.\n", unit);
+ kmsg("LVM: Failed to write unit file %s: %m.\n", unit_name);
return 0;
}
- if (!register_unit_with_target(dir, unit, UNIT_TARGET)) {
- kmsg("LVM: Failed to register unit %s with target %s.\n", unit, UNIT_TARGET);
+ if (!register_unit_with_target(dir, unit_name, target_name)) {
+ kmsg("LVM: Failed to register unit %s with target %s.\n", unit_name, target_name);
return 0;
}
@@ -162,7 +180,9 @@ int main(int argc, char *argv[])
dir = argc > 1 ? argv[1] : DEFAULT_UNIT_DIR;
- if (!generate_unit(dir, 1) || !generate_unit(dir, 0))
+ if (!generate_unit(dir, UNIT_EARLY) ||
+ !generate_unit(dir, UNIT_MAIN) ||
+ !generate_unit(dir, UNIT_NET))
r = EXIT_FAILURE;
out:
kmsg("LVM: Activation generator %s.\n", r ? "failed" : "successfully completed");
10 years, 9 months
master - profile: move profile assignment to common lv_create_empty fn
by Peter Rajnoha
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=73e7f6c45ffecc...
Commit: 73e7f6c45ffecc78b1ea4165596355479fb59fe2
Parent: b73fbf8f4a225262b2c1d42978aea015af941a50
Author: Peter Rajnoha <prajnoha(a)redhat.com>
AuthorDate: Wed Jul 17 11:31:54 2013 +0200
Committer: Peter Rajnoha <prajnoha(a)redhat.com>
CommitterDate: Wed Jul 17 11:31:54 2013 +0200
profile: move profile assignment to common lv_create_empty fn
---
lib/metadata/lv_manip.c | 6 +++---
1 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/lib/metadata/lv_manip.c b/lib/metadata/lv_manip.c
index 5ec2bd0..cb6a6c2 100644
--- a/lib/metadata/lv_manip.c
+++ b/lib/metadata/lv_manip.c
@@ -4183,6 +4183,9 @@ struct logical_volume *lv_create_empty(const char *name,
if (fi->fmt->ops->lv_setup && !fi->fmt->ops->lv_setup(fi, lv))
goto_bad;
+
+ if (vg->fid->fmt->features & FMT_CONFIG_PROFILE)
+ lv->profile = vg->cmd->profile_params->global_profile;
return lv;
bad:
@@ -5595,9 +5598,6 @@ static struct logical_volume *_lv_create_an_lv(struct volume_group *vg, struct l
status, lp->alloc, vg)))
return_NULL;
- if (vg->fid->fmt->features & FMT_CONFIG_PROFILE)
- lv->profile = vg->cmd->profile_params->global_profile;
-
if (lp->read_ahead != lv->read_ahead) {
log_verbose("Setting read ahead sectors");
lv->read_ahead = lp->read_ahead;
10 years, 9 months
master - config_settings: add comment about possible types
by Peter Rajnoha
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=b73fbf8f4a2252...
Commit: b73fbf8f4a225262b2c1d42978aea015af941a50
Parent: 63d09b75f8e9a8790124f1ee0e2349a94e7a718d
Author: Peter Rajnoha <prajnoha(a)redhat.com>
AuthorDate: Tue Jul 16 15:18:40 2013 +0200
Committer: Peter Rajnoha <prajnoha(a)redhat.com>
CommitterDate: Tue Jul 16 15:18:40 2013 +0200
config_settings: add comment about possible types
---
lib/config/config_settings.h | 6 +++++-
1 files changed, 5 insertions(+), 1 deletions(-)
diff --git a/lib/config/config_settings.h b/lib/config/config_settings.h
index 4d124c8..16a9437 100644
--- a/lib/config/config_settings.h
+++ b/lib/config/config_settings.h
@@ -32,7 +32,11 @@
* CFG_ADVANCED - this node belongs to advanced config set
* CFG_UNSUPPORTED - this node belongs to unsupported config set
* CFG_PROFILABLE - this node is customizable by a profile
- * type: allowed type for the value of simple configuation setting
+ * type: allowed type for the value of simple configuation setting, one of:
+ * CFG_TYPE_BOOL
+ * CFG_TYPE_INT
+ * CFG_TYPE_FLOAT
+ * CFG_TYPE_STRING
* types: allowed types for the values of array configuration setting
* (use logical "OR" to define more than one allowed type,
* e.g. CFG_TYPE_STRING | CFG_TYPE_INT)
10 years, 9 months
master - tests: one missed automatic name
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=63d09b75f8e9a8...
Commit: 63d09b75f8e9a8790124f1ee0e2349a94e7a718d
Parent: 255db4c4e4d8e505bb5cf10892640cffd40ebed2
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Mon Jul 15 16:38:55 2013 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Mon Jul 15 16:38:55 2013 +0200
tests: one missed automatic name
Avoid depending on auto-names lvol%d.
---
test/shell/lvcreate-thin.sh | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/test/shell/lvcreate-thin.sh b/test/shell/lvcreate-thin.sh
index ed2631e..275c56f 100644
--- a/test/shell/lvcreate-thin.sh
+++ b/test/shell/lvcreate-thin.sh
@@ -140,11 +140,11 @@ lvcreate -K -s $vg/lv1 --name snap_lv1
fsck -p $DM_DEV_DIR/$vg/snap_lv1
lvcreate -s $vg/lv1 --name lv2
lvcreate -s $vg/lv1 --name $vg/lv3
-lvcreate --type snapshot $vg/lv1
+lvcreate --type snapshot $vg/lv1 --name lv6
lvcreate --type snapshot $vg/lv1 --name lv4
lvcreate --type snapshot $vg/lv1 --name $vg/lv5
-check_lv_field_modules_ thin-pool lv1 snap_lv1 lv2 lv3 lvol1 lv4 lv5
+check_lv_field_modules_ thin-pool lv1 snap_lv1 lv2 lv3 lv4 lv5 lv6
check vg_field $vg lv_count 8
lvremove -ff $vg
10 years, 9 months
master - tests: thin lvol0 updates
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=255db4c4e4d8e5...
Commit: 255db4c4e4d8e505bb5cf10892640cffd40ebed2
Parent: 3498575b20c3dad46ba4e76fe8a9c3d95f75d1de
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Mon Jul 15 13:37:07 2013 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Mon Jul 15 16:01:29 2013 +0200
tests: thin lvol0 updates
---
test/shell/lvcreate-thin-snap.sh | 4 +-
test/shell/lvcreate-thin.sh | 64 +++++++++++++++++++-------------------
2 files changed, 34 insertions(+), 34 deletions(-)
diff --git a/test/shell/lvcreate-thin-snap.sh b/test/shell/lvcreate-thin-snap.sh
index 6dd16d7..701bb08 100644
--- a/test/shell/lvcreate-thin-snap.sh
+++ b/test/shell/lvcreate-thin-snap.sh
@@ -35,9 +35,9 @@ vgcreate $vg -s 64K $(cat DEVICES)
lvcreate -L10M -V10M -T $vg/pool --name $lv1
mkfs.ext4 $DM_DEV_DIR/$vg/$lv1
# create thin snapshot of thin LV
-lvcreate -K -s $vg/$lv1
+lvcreate -K -s $vg/$lv1 --name snap
# check snapshot filesystem was properly frozen before snapping
-fsck -p $DM_DEV_DIR/$vg/lvol0
+fsck -p $DM_DEV_DIR/$vg/snap
lvcreate -K -s $vg/$lv1 --name $lv2
lvcreate -K -s $vg/$lv1 --name $vg/$lv3
lvcreate --type snapshot $vg/$lv1
diff --git a/test/shell/lvcreate-thin.sh b/test/shell/lvcreate-thin.sh
index 8daa923..ed2631e 100644
--- a/test/shell/lvcreate-thin.sh
+++ b/test/shell/lvcreate-thin.sh
@@ -1,6 +1,6 @@
#!/bin/sh
-# Copyright (C) 2011-2012 Red Hat, Inc. All rights reserved.
+# Copyright (C) 2011-2013 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
@@ -55,7 +55,7 @@ lvcreate -l1 -T $vg
lvcreate -l1 --type thin $vg
lvcreate -l1 --type thin-pool $vg
-lvremove -ff $vg/lvol0 $vg/lvol1 $vg/lvol2
+lvremove -ff $vg
check vg_field $vg lv_count 0
@@ -67,14 +67,14 @@ lvremove -ff $vg
# Create named pool and default thin LV
-lvcreate -L4M -V2G -T $vg/pool1
-lvcreate -L4M -V2G -T --thinpool $vg/pool2
-lvcreate -L4M -V2G -T --thinpool pool3 $vg
-lvcreate -L4M -V2G --type thin $vg/pool4
-lvcreate -L4M -V2G --type thin --thinpool $vg/pool5
-lvcreate -L4M -V2G --type thin --thinpool pool6 $vg
-
-check lv_exists $vg lvol0 lvol1 lvol2 lvol3 lvol4 lvol5
+lvcreate -L4M -V2G --name lvo1 -T $vg/pool1
+lvcreate -L4M -V2G --name lvo2 -T --thinpool $vg/pool2
+lvcreate -L4M -V2G --name lvo3 -T --thinpool pool3 $vg
+lvcreate -L4M -V2G --name lvo4 --type thin $vg/pool4
+lvcreate -L4M -V2G --name lvo5 --type thin --thinpool $vg/pool5
+lvcreate -L4M -V2G --name lvo6 --type thin --thinpool pool6 $vg
+
+check lv_exists $vg lvo1 lvo2 lvo3 lvo4 lvo5 lvo6
lvremove -ff $vg
@@ -103,14 +103,14 @@ lvremove -ff $vg
# Create default thin LV in existing pool
lvcreate -L4M -T $vg/pool
-lvcreate -V2G -T $vg/pool
-lvcreate -V2G -T --thinpool $vg/pool
-lvcreate -V2G -T --thinpool pool $vg
-lvcreate -V2G --type thin $vg/pool
-lvcreate -V2G --type thin --thinpool $vg/pool
-lvcreate -V2G --type thin --thinpool pool $vg
+lvcreate -V2G --name lvo0 -T $vg/pool
+lvcreate -V2G --name lvo1 -T --thinpool $vg/pool
+lvcreate -V2G --name lvo2 -T --thinpool pool $vg
+lvcreate -V2G --name lvo3 --type thin $vg/pool
+lvcreate -V2G --name lvo4 --type thin --thinpool $vg/pool
+lvcreate -V2G --name lvo5 --type thin --thinpool pool $vg
-check lv_exists $vg lvol0 lvol1 lvol2 lvol3 lvol4 lvol5
+check lv_exists $vg lvo0 lvo1 lvo2 lvo3 lvo4 lvo5
# Create named thin LV in existing pool
@@ -136,27 +136,27 @@ check vg_field $vg lv_count 0
# Create thin snapshot of thinLV
lvcreate -L10M -V10M -T $vg/pool --name lv1
mkfs.ext4 $DM_DEV_DIR/$vg/lv1
-lvcreate -s -K $vg/lv1
-fsck -p $DM_DEV_DIR/$vg/lvol0
-lvcreate -s -K $vg/lv1 --name lv2
-lvcreate -s -K $vg/lv1 --name $vg/lv3
-lvcreate --type snapshot -K $vg/lv1
-lvcreate --type snapshot -K $vg/lv1 --name lv4
-lvcreate --type snapshot -K $vg/lv1 --name $vg/lv5
-
-check_lv_field_modules_ thin-pool lv1 lvol0 lv2 lv3 lvol1 lv4 lv5
+lvcreate -K -s $vg/lv1 --name snap_lv1
+fsck -p $DM_DEV_DIR/$vg/snap_lv1
+lvcreate -s $vg/lv1 --name lv2
+lvcreate -s $vg/lv1 --name $vg/lv3
+lvcreate --type snapshot $vg/lv1
+lvcreate --type snapshot $vg/lv1 --name lv4
+lvcreate --type snapshot $vg/lv1 --name $vg/lv5
+
+check_lv_field_modules_ thin-pool lv1 snap_lv1 lv2 lv3 lvol1 lv4 lv5
check vg_field $vg lv_count 8
lvremove -ff $vg
# Normal Snapshots of thinLV
lvcreate -L4M -V2G -T $vg/pool --name lv1
-lvcreate -s -K $vg/lv1 -l1
-lvcreate -s -K $vg/lv1 -l1 --name lv2
-lvcreate -s -K $vg/lv1 -l1 --name $vg/lv3
-lvcreate -s -K lv1 -L4M --name $vg/lv4
+lvcreate -s $vg/lv1 -l1 --name snap_lv1
+lvcreate -s $vg/lv1 -l1 --name lv2
+lvcreate -s $vg/lv1 -l1 --name $vg/lv3
+lvcreate -s lv1 -L4M --name $vg/lv4
-check_lv_field_modules_ snapshot lvol0 lv2 lv3 lv4
+check_lv_field_modules_ snapshot snap_lv1 lv2 lv3 lv4
check vg_field $vg lv_count 6
lvremove -ff $vg
@@ -174,7 +174,7 @@ not lvcreate -L4M --chunksize 2G -T $vg/pool1
lvcreate -L4M -V2G --name lv1 -T $vg/pool1
# Origin name is not accepted
-not lvcreate -s -K $vg/lv1 -L4M -V2G --name $vg/lv4
+not lvcreate -s $vg/lv1 -L4M -V2G --name $vg/lv4
# Check we cannot create mirror and thin or thinpool together
not lvcreate -T mirpool -L4M --alloc anywhere -m1 $vg
10 years, 9 months
master - tests: more thin external origin tests
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=3498575b20c3da...
Commit: 3498575b20c3dad46ba4e76fe8a9c3d95f75d1de
Parent: 9a060948242e830555436678f5b15b84bca70b04
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Mon Jul 15 14:46:52 2013 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Mon Jul 15 16:01:28 2013 +0200
tests: more thin external origin tests
---
test/shell/lvconvert-thin-external.sh | 73 +++++++++++++++++++++-----------
test/shell/lvcreate-thin-external.sh | 20 +++++-----
2 files changed, 58 insertions(+), 35 deletions(-)
diff --git a/test/shell/lvconvert-thin-external.sh b/test/shell/lvconvert-thin-external.sh
index 1bcf0b6..9f53fcb 100644
--- a/test/shell/lvconvert-thin-external.sh
+++ b/test/shell/lvconvert-thin-external.sh
@@ -24,12 +24,32 @@ aux have_thin 1 5 0 || skip
aux prepare_pvs 2 64
-vgcreate $vg -s 64K $(cat DEVICES)
+vgcreate $vg --metadatasize 128K -s 64K $(cat DEVICES)
-# create thin pool
-lvcreate -L8M -T $vg/pool
+if test 0 -eq 1 ; then
+# FIXME: needs patch to allow inactive old-snap creation
+lvcreate -l10 -T $vg/pool
+lvcreate -an -pr --zero n -l10 --name $lv1 $vg
+lvcreate -s $vg/$lv1 --name $lv2 --thinpool $vg/pool
+vgchange -an $vg
+# oldstyle read-only inactive snapshot
+lvcreate -an -s $vg/$lv2 -l10 -p r --name $lv3
-# create plain LV
+lvcreate -s $vg/$lv3 --name $lv4 --thinpool $vg/pool
+lvremove -ff $vg/$lv3
+
+lvremove -ff $vg
+fi
+
+#lvcreate -L20M --name orig $vg
+#lvconvert -T --thinpool $vg/pool $vg/orig
+#lvcreate -s -aey -L10M $vg/orig
+#lvremove -f $vg
+#exit 0
+
+lvcreate -l10 -T $vg/pool
+
+# create plain LV (will be used for external origin)
lvcreate -L8M -n $lv1 $vg
mkfs.ext2 $DM_DEV_DIR/$vg/$lv1
@@ -44,14 +64,17 @@ dd if=/dev/zero of=mnt/test1 bs=1M count=1
lvconvert -T --originname extorg --thinpool $vg/pool $vg/$lv1
check active $vg $lv1
+# FIXME handling attr is ...
+get lv_field $vg/extorg attr | grep "^ori"
check inactive $vg extorg
touch mnt/test
umount mnt
+# check fs is without errors
fsck -n $DM_DEV_DIR/$vg/$lv1
-lvchange -ay $vg/extorg
+lvchange -aey $vg/extorg
lvchange -an $vg/$lv1
check active $vg extorg
@@ -60,43 +83,42 @@ check inactive $vg $lv1
# fsck in read-only mode
fsck -n $DM_DEV_DIR/$vg/extorg
-#not lvresize -l+8 $vg/extorg
-#not lvresize -l-4 $vg/extorg
-#not lvchange -p rw $vg/extorg
+not lvresize -l+8 $vg/extorg
+not lvresize -l-4 $vg/extorg
+not lvchange -p rw $vg/extorg
#lvresize -L+8M $vg/$lv1
#lvresize -L-4M $vg/$lv1
#lvchange -p r $vg/$lv1
#lvchange -p rw $vg/$lv1
-lvchange -ay $vg
+lvchange -aey $vg
lvs -a -o+origin_size,seg_size $vg
-lvconvert --originname extorg1 --thinpool $vg/pool -T $vg/extorg
+# Chain external origins
+lvconvert --originname extorg1 --thinpool $vg/pool -T $vg/extorg
check inactive $vg extorg1
-lvconvert --originname extorglv1 --thinpool $vg/pool -T $vg/extorg1
-
-lvs -a -o+origin_size,seg_size $vg
+lvconvert --originname extorg2 --thinpool $vg/pool -T $vg/extorg1
+check inactive $vg extorg1
+check inactive $vg extorg2
lvchange -an $vg/extorg
-lvs -a -o+origin_size,seg_size $vg
-check inactive $vg extorglv1
-
lvchange -ay $vg/extorg1
-lvs -a -o+origin_size,seg_size $vg
lvcreate -l4 -s $vg/$lv1 -n $lv2
lvcreate -l8 -s $vg/extorg -n $lv3
lvcreate -l12 -s $vg/extorg1 -n $lv4
-lvcreate -l16 -s $vg/extorglv1 -n $lv5
-
-lvs -a -o+origin_size,seg_size,segtype $vg
-
+lvcreate -l16 -s $vg/extorg2 -n $lv5
+#vgchange -aey $vg
+#lvremove -f $vg/extorg2
+#exit 0
# Converting old-snapshot into external origin is not supported
not lvconvert -T --thinpool $vg/pool --originname lv5origin $vg/$lv4
+lvs -a -o +segtype $vg
+
check lv_field $vg/$lv1 segtype thin
check lv_field $vg/$lv2 segtype linear
check lv_field $vg/$lv3 segtype linear
@@ -104,17 +126,18 @@ check lv_field $vg/$lv4 segtype linear
check lv_field $vg/$lv5 segtype linear
check lv_field $vg/extorg segtype thin
check lv_field $vg/extorg1 segtype thin
-check lv_field $vg/extorglv1 segtype linear
+check lv_field $vg/extorg2 segtype linear
vgchange -ay $vg
lvs -a -o+origin_size,seg_size $vg
-lvchange -an $vg/extorglv1
-check inactive $vg extorglv1
+lvchange -an $vg/extorg2
+check inactive $vg extorg2
# Remove all volumes dependent on external origin
-lvremove -f $vg/extorglv1
+lvs -a -o+origin_size,seg_size,segtype $vg
+lvremove -f $vg/extorg2
# Only pool is left
check vg_field $vg lv_count 1
diff --git a/test/shell/lvcreate-thin-external.sh b/test/shell/lvcreate-thin-external.sh
index fdc7528..c9aba6f 100644
--- a/test/shell/lvcreate-thin-external.sh
+++ b/test/shell/lvcreate-thin-external.sh
@@ -32,32 +32,32 @@ mkfs.ext2 $DM_DEV_DIR/$vg/$lv1
lvcreate -L4M -n $lv2 $vg
mkfs.ext2 $DM_DEV_DIR/$vg/$lv2
-# Fail to create snapshot of rw LV
-not lvcreate -s -K $vg/$lv2 --thinpool $vg/pool
+# Fail to create external origin snapshot of rw LV
+not lvcreate -s $vg/$lv2 --thinpool $vg/pool
lvchange -p r $vg/$lv2
# Fail to create snapshot of active r LV
# FIXME: kernel update needed
-not lvcreate -s -K $vg/$lv2 --thinpool $vg/pool
+not lvcreate -s $vg/$lv2 --thinpool $vg/pool
# Deactivate LV we want to use as external origin
# once kernel will ensure read-only this condition may go away
lvchange -an $vg/$lv2
-lvcreate -s -K $vg/$lv2 --thinpool $vg/pool
+lvcreate -s $vg/$lv2 --thinpool $vg/pool
# Fail with --thin and --snapshot
-not lvcreate -s -K $vg/$lv5 --name $vg/$lv7 -T $vg/newpool
+not lvcreate -s $vg/$lv5 --name $vg/$lv7 -T $vg/newpool
# Fail to create already existing pool
-not lvcreate -s -K $vg/$lv2 -L10 --thinpool $vg/pool
-not lvcreate -s -K $vg/$lv2 --chunksize 64 --thinpool $vg/pool
-not lvcreate -s -K $vg/$lv2 --zero y --thinpool $vg/pool
-not lvcreate -s -K $vg/$lv2 --poolmetadata $vg/$lv1 --thinpool $vg/pool
+not lvcreate -s $vg/$lv2 -L10 --thinpool $vg/pool
+not lvcreate -s $vg/$lv2 --chunksize 64 --thinpool $vg/pool
+not lvcreate -s $vg/$lv2 --zero y --thinpool $vg/pool
+not lvcreate -s $vg/$lv2 --poolmetadata $vg/$lv1 --thinpool $vg/pool
# Fail with nonexistent pool
-not lvcreate -s -K $vg/$lv2 --thinpool $vg/newpool
+not lvcreate -s $vg/$lv2 --thinpool $vg/newpool
# Create pool and snap
lvcreate -s -K $vg/$lv2 --name $vg/$lv3 -L20 --chunksize 128 --thinpool $vg/newpool
10 years, 9 months
master - thin: improve external origin tree creation
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=9a060948242e83...
Commit: 9a060948242e830555436678f5b15b84bca70b04
Parent: 57be501aa3d723fcd41781e6c37579991a714751
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Tue Jul 9 12:34:49 2013 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Mon Jul 15 16:00:06 2013 +0200
thin: improve external origin tree creation
When tree for thin LVs was using external_lv, there has been
far less optimal solution, that has tried to add certain
existing dependencie only when new node was added.
However this has lead to way to complex tree construction since
many repeated checks have been made during such tree build.
This patch move this detection to the proper _partial_tree generation
code and uses for it new 'activation' flag, which is set when
tree for ACTIVATION or PRELOAD is generated.
It increases performance when thins with external origins are used.
(in release update)
---
lib/activate/dev_manager.c | 115 +++++++++++++++++++++++++++-----------------
1 files changed, 70 insertions(+), 45 deletions(-)
diff --git a/lib/activate/dev_manager.c b/lib/activate/dev_manager.c
index 6a2cc68..281041b 100644
--- a/lib/activate/dev_manager.c
+++ b/lib/activate/dev_manager.c
@@ -48,6 +48,8 @@ struct dev_manager {
void *target_state;
uint32_t pvmove_mirror_count;
int flush_required;
+ int activation; /* building activation tree */
+ int skip_external_lv;
unsigned track_pvmove_deps;
char *vg_name;
@@ -1695,19 +1697,39 @@ static int _add_lv_to_dtree(struct dev_manager *dm, struct dm_tree *dtree,
#endif
}
+ if (origin_only && dm->activation && !dm->skip_external_lv &&
+ lv_is_external_origin(lv)) {
+ /* Find possible users of external origin lv */
+ dm->skip_external_lv = 1; /* avoid recursion */
+ dm_list_iterate_items(sl, &lv->segs_using_this_lv)
+ /* Match only external_lv users */
+ if ((sl->seg->external_lv == lv) &&
+ !_add_lv_to_dtree(dm, dtree, sl->seg->lv, 1))
+ return_0;
+ dm->skip_external_lv = 0;
+ }
+
if (lv_is_thin_pool(lv)) {
+ /*
+ * For both origin_only and !origin_only
+ * skips test for -tpool-real and tpool-cow
+ */
if (!_add_dev_to_dtree(dm, dtree, lv, lv_layer(lv)))
return_0;
- /* Setup callback for deactivation based on partial tree */
- if (!(uuid = build_dm_uuid(dm->mem, lv->lvid.s, lv_layer(lv))))
- return_0;
- if ((thin_node = dm_tree_find_node_by_uuid(dtree, uuid)) &&
- !_thin_pool_register_callback(dm, thin_node, lv))
- return_0;
+ if (!dm->activation) {
+ /* Setup callback for non-activation partial tree */
+ /* Activation gets own callback when needed */
+ /* TODO: extend _cached_info() to return dnode */
+ if (!(uuid = build_dm_uuid(dm->mem, lv->lvid.s, lv_layer(lv))))
+ return_0;
+ if ((thin_node = dm_tree_find_node_by_uuid(dtree, uuid)) &&
+ !_thin_pool_register_callback(dm, thin_node, lv))
+ return_0;
+ }
}
/* Add any snapshots of this LV */
- if (lv_is_origin(lv) && (lv_is_external_origin(lv) || !origin_only))
+ if (!origin_only && lv_is_origin(lv))
dm_list_iterate(snh, &lv->snapshot_segs)
if (!_add_lv_to_dtree(dm, dtree, dm_list_struct_base(snh, struct lv_segment, origin_list)->cow, 0))
return_0;
@@ -1726,7 +1748,7 @@ static int _add_lv_to_dtree(struct dev_manager *dm, struct dm_tree *dtree,
/* Add any LVs used by segments in this LV */
dm_list_iterate_items(seg, &lv->segments) {
- if (seg->external_lv &&
+ if (seg->external_lv && !dm->skip_external_lv &&
!_add_lv_to_dtree(dm, dtree, seg->external_lv, 1)) /* stack */
return_0;
if (seg->log_lv &&
@@ -1735,7 +1757,7 @@ static int _add_lv_to_dtree(struct dev_manager *dm, struct dm_tree *dtree,
if (seg->metadata_lv &&
!_add_lv_to_dtree(dm, dtree, seg->metadata_lv, 0))
return_0;
- if (seg->pool_lv &&
+ if (seg->pool_lv && !dm->skip_external_lv &&
!_add_lv_to_dtree(dm, dtree, seg->pool_lv, 1)) /* stack */
return_0;
@@ -2113,41 +2135,49 @@ static int _add_replicator_dev_target_to_dtree(struct dev_manager *dm,
return 1;
}
-static int _add_active_externals_to_dtree(struct dev_manager *dm,
- struct dm_tree *dtree,
- struct lv_segment *seg,
- struct lv_activate_opts *laopts)
+static int _add_new_external_lv_to_dtree(struct dev_manager *dm,
+ struct dm_tree *dtree,
+ struct logical_volume *external_lv,
+ struct lv_activate_opts *laopts)
{
struct seg_list *sl;
- /* Add any ACTIVE LVs using this external origin LV */
- log_debug_activation("Adding active users of external lv %s",
- seg->external_lv->name);
- dm_list_iterate_items(sl, &seg->external_lv->segs_using_this_lv) {
- if (sl->seg->external_lv != seg->external_lv ||
- sl->seg == seg)
- continue;
+ /* Do not want to recursively add externals again */
+ if (dm->skip_external_lv)
+ return 1;
- /*
- * Find if the LV is active
- * These LVs are not scanned the generic partial dtree
- * since in most cases we do not want to work with them.
- * However when new EO user is added all users must be known.
- *
- * As EO could have been chained and passed to a new
- * volume, whole device needs to be tested, so the
- * removal of layered EO (-real) happens.
- */
- if (!_add_lv_to_dtree(dm, dtree, sl->seg->lv, 0))
- return_0;
+ /*
+ * Any LV can have only 1 external origin, so we will
+ * process all LVs related to this LV, and we want to
+ * skip repeated invocation of external lv processing
+ */
+ dm->skip_external_lv = 1;
+
+ log_debug_activation("Adding external origin lv %s and all active users.",
+ external_lv->name);
- /* Only layer check is needed here (also avoids loop) */
- if (_cached_info(dm->mem, dtree, sl->seg->lv,
+ if (!_add_new_lv_to_dtree(dm, dtree, external_lv, laopts,
+ lv_layer(external_lv)))
+ return_0;
+
+ /*
+ * Add all ACTIVE LVs using this external origin LV. This is
+ * needed because of conversion of thin which could have been
+ * also an old-snapshot to external origin.
+ */
+ //if (lv_is_origin(external_lv))
+ dm_list_iterate_items(sl, &external_lv->segs_using_this_lv)
+ if ((sl->seg->external_lv == external_lv) &&
+ /* Add only active layered devices (also avoids loop) */
+ _cached_info(dm->mem, dtree, sl->seg->lv,
lv_layer(sl->seg->lv)) &&
!_add_new_lv_to_dtree(dm, dtree, sl->seg->lv,
laopts, lv_layer(sl->seg->lv)))
return_0;
- }
+
+ log_debug_activation("Finished adding external origin lv %s and all active users.",
+ external_lv->name);
+ dm->skip_external_lv = 0;
return 1;
}
@@ -2182,16 +2212,9 @@ static int _add_segment_to_dtree(struct dev_manager *dm,
}
/* Add external origin layer */
- if (seg->external_lv) {
- if (!_add_new_lv_to_dtree(dm, dtree, seg->external_lv, laopts,
- lv_layer(seg->external_lv)))
- return_0;
-
- if (!layer &&
- !_add_active_externals_to_dtree(dm, dtree, seg, laopts))
- return_0;
- }
-
+ if (seg->external_lv &&
+ !_add_new_external_lv_to_dtree(dm, dtree, seg->external_lv, laopts))
+ return_0;
/* Add mirror log */
if (seg->log_lv &&
!_add_new_lv_to_dtree(dm, dtree, seg->log_lv, laopts, NULL))
@@ -2567,6 +2590,8 @@ static int _tree_action(struct dev_manager *dm, struct logical_volume *lv,
char *dlid;
int r = 0;
+ /* Some targets may build bigger tree for activation */
+ dm->activation = ((action == PRELOAD) || (action == ACTIVATE));
if (!(dtree = _create_partial_dtree(dm, lv, laopts->origin_only)))
return_0;
10 years, 9 months
master - dev_manager: lower memory usage
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=57be501aa3d723...
Commit: 57be501aa3d723fcd41781e6c37579991a714751
Parent: 0443c42e3bff5b3e0bca6cfdc489d59cd45ada8a
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Sun Jul 14 15:08:26 2013 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Mon Jul 15 15:59:20 2013 +0200
dev_manager: lower memory usage
Created dlid for test is not needed afterward, so lower a memory
usage of this call is repeatedly used for building some large tree.
TODO: create function to use given buffer on stack as much cheaper.
---
WHATS_NEW | 1 +
lib/activate/dev_manager.c | 18 ++++++++++--------
2 files changed, 11 insertions(+), 8 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index 7aa3df9..5763bdf 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.99 -
===================================
+ Release memory allocated with _cached_info().
Add whole log_lv and metadata_lv sub volumes when creating partial tree.
Properly use snapshot layer for origin which is also thin volume.
Avoid generating metadata backup when calling update_pool_lv().
diff --git a/lib/activate/dev_manager.c b/lib/activate/dev_manager.c
index 260cb3e..6a2cc68 100644
--- a/lib/activate/dev_manager.c
+++ b/lib/activate/dev_manager.c
@@ -485,25 +485,27 @@ static const struct dm_info *_cached_info(struct dm_pool *mem,
const struct logical_volume *lv,
const char *layer)
{
- const char *dlid;
- struct dm_tree_node *dnode;
- const struct dm_info *dinfo;
+ char *dlid;
+ const struct dm_tree_node *dnode;
+ const struct dm_info *dinfo = NULL;
if (!(dlid = build_dm_uuid(mem, lv->lvid.s, layer))) {
- log_error("dlid build failed for %s", lv->name);
+ log_error("Failed to build dlid for %s.", lv->name);
return NULL;
}
if (!(dnode = dm_tree_find_node_by_uuid(dtree, dlid)))
- return NULL;
+ goto out;
if (!(dinfo = dm_tree_node_get_info(dnode))) {
- log_error("failed to get info from tree node for %s", lv->name);
- return NULL;
+ log_error("Failed to get info from tree node for %s.", lv->name);
+ goto out;
}
if (!dinfo->exists)
- return NULL;
+ dinfo = NULL;
+out:
+ dm_pool_free(mem, dlid);
return dinfo;
}
10 years, 9 months