master - pvscan: do activation when lvmetad is not running
by David Teigland
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=15da467b524650...
Commit: 15da467b52465076a8d587b94cc638bab8a0a95c
Parent: ae0a8740c5899520ec4c94fbf080623167d8ecba
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Wed Jun 15 14:19:18 2016 -0500
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Wed Jun 15 14:19:18 2016 -0500
pvscan: do activation when lvmetad is not running
When pvscan --cache -aay fails to connect to lvmetad it will
simply exit and do nothing. Change this so that it will
skip the lvmetad cache step and do the activation step from
disk.
---
tools/pvscan.c | 9 ++++++++-
1 files changed, 8 insertions(+), 1 deletions(-)
diff --git a/tools/pvscan.c b/tools/pvscan.c
index 3e9efef..5987e8b 100644
--- a/tools/pvscan.c
+++ b/tools/pvscan.c
@@ -315,7 +315,7 @@ static int _pvscan_cache(struct cmd_context *cmd, int argc, char **argv)
dm_list_init(&found_vgnames);
dm_list_init(&pp.changed_vgnames);
- if (!lvmetad_used()) {
+ if (!lvmetad_used() && !arg_is_set(cmd, activate_ARG)) {
log_verbose("Ignoring pvscan --cache command because lvmetad is not in use.");
return ret;
}
@@ -341,6 +341,13 @@ static int _pvscan_cache(struct cmd_context *cmd, int argc, char **argv)
return ECMD_FAILED;
}
+ if (!lvmetad_used() && do_activate) {
+ log_verbose("Activating all VGs without lvmetad running.");
+ all_vgs = 1;
+ devno_args = 0;
+ goto activate;
+ }
+
/*
* Scan all devices when no args are given.
*/
7 years, 11 months
master - lvmlockd: fix rescanning VG
by David Teigland
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=ae0a8740c58995...
Commit: ae0a8740c5899520ec4c94fbf080623167d8ecba
Parent: 49a8d1a85eb035a0dfb1febd76e3ae4fa5e976d5
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Tue Jun 14 14:51:03 2016 -0500
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Wed Jun 15 11:36:30 2016 -0500
lvmlockd: fix rescanning VG
Previously, new PVs that were added to the VG were not scanned.
---
lib/cache/lvmetad.c | 165 +++++++++++++++++++++++++++++++++++++++++++++------
tools/lvmcmdline.c | 1 +
2 files changed, 147 insertions(+), 19 deletions(-)
diff --git a/lib/cache/lvmetad.c b/lib/cache/lvmetad.c
index 70adbb4..0f1f269 100644
--- a/lib/cache/lvmetad.c
+++ b/lib/cache/lvmetad.c
@@ -1085,6 +1085,8 @@ struct volume_group *lvmetad_vg_lookup(struct cmd_context *cmd, const char *vgna
if (!(vg2 = lvmetad_pvscan_vg(cmd, vg))) {
log_debug_lvmetad("VG %s from lvmetad not found during rescan.", vgname);
fid = NULL;
+ release_vg(vg);
+ vg = NULL;
goto out;
}
release_vg(vg);
@@ -1666,41 +1668,99 @@ static int _lvmetad_pvscan_single(struct metadata_area *mda, void *baton)
static struct volume_group *lvmetad_pvscan_vg(struct cmd_context *cmd, struct volume_group *vg)
{
+ char pvid_s[ID_LEN + 1] __attribute__((aligned(8)));
+ char uuid[64] __attribute__((aligned(8)));
+ struct label *label;
struct volume_group *vg_ret = NULL;
struct dm_config_tree *vgmeta_ret = NULL;
struct dm_config_tree *vgmeta;
- struct pv_list *pvl;
+ struct pv_list *pvl, *pvl_new;
+ struct device_list *devl, *devl_new;
+ struct dm_list pvs_scan;
+ struct dm_list pvs_new;
struct lvmcache_info *info;
struct format_instance *fid;
struct format_instance_ctx fic = { .type = 0 };
struct _lvmetad_pvscan_baton baton;
struct device *save_dev = NULL;
uint32_t save_seqno = 0;
+ int missing_devs = 0;
+ int check_new_pvs = 0;
+ int found;
+
+ dm_list_init(&pvs_scan);
+ dm_list_init(&pvs_new);
+
+ log_debug_lvmetad("Rescanning VG %s (seqno %u).", vg->name, vg->seqno);
+
+ /*
+ * Another host may have added a PV to the VG, and some
+ * commands do not always populate their lvmcache with
+ * all devs from lvmetad, so they would fail to find
+ * the new PV when scanning the VG. So make sure this
+ * command knows about all PVs from lvmetad.
+ */
+ lvmcache_seed_infos_from_lvmetad(cmd);
+ /*
+ * Start with the list of PVs that we last saw in the VG.
+ * Some may now be gone, and some new PVs may have been added.
+ */
dm_list_iterate_items(pvl, &vg->pvs) {
- /* missing pv */
- if (!pvl->pv->dev)
+ if (!(devl = dm_pool_zalloc(cmd->mem, sizeof(*devl))))
+ return_NULL;
+ devl->dev = pvl->pv->dev;
+ dm_list_add(&pvs_scan, &devl->list);
+ }
+
+ /*
+ * Drop stale info from lvmetad.
+ */
+ dm_list_iterate_items(devl, &pvs_scan) {
+ if (!devl->dev)
continue;
+ log_debug_lvmetad("Rescan VG %s dropping %s.", vg->name, dev_name(devl->dev));
+ if (!lvmetad_pv_gone_by_dev(devl->dev))
+ return_NULL;
+ }
- if (!(info = lvmcache_info_from_pvid((const char *)&pvl->pv->id, pvl->pv->dev, 0))) {
- log_error("Failed to find cached info for PV %s.", pv_dev_name(pvl->pv));
- return NULL;
+scan_more:
+
+ /*
+ * Run the equivalent of lvmetad_pvscan_single on each dev in the VG.
+ */
+ dm_list_iterate_items(devl, &pvs_scan) {
+ if (!devl->dev)
+ continue;
+
+ log_debug_lvmetad("Rescan VG %s scanning %s.", vg->name, dev_name(devl->dev));
+
+ if (!label_read(devl->dev, &label, 0)) {
+ /* Another host removed this PV from the VG. */
+ log_debug_lvmetad("Rescan VG %s found %s was removed.", vg->name, dev_name(devl->dev));
+
+ if ((info = lvmcache_info_from_pvid(devl->dev->pvid, NULL, 0)))
+ lvmcache_del(info);
+
+ continue;
}
+ info = (struct lvmcache_info *) label->info;
+
baton.vg = NULL;
baton.fid = lvmcache_fmt(info)->ops->create_instance(lvmcache_fmt(info), &fic);
-
if (!baton.fid)
- return NULL;
+ return_NULL;
if (baton.fid->fmt->features & FMT_OBSOLETE) {
+ log_debug_lvmetad("Ignoring obsolete format on PV %s in VG %s.", dev_name(devl->dev), vg->name);
lvmcache_fmt(info)->ops->destroy_instance(baton.fid);
- log_warn("WARNING: Disabling lvmetad cache which does not support obsolete (lvm1) metadata.");
- lvmetad_set_disabled(cmd, LVMETAD_DISABLE_REASON_LVM1);
- _found_lvm1_metadata = 1;
- return NULL;
+ continue;
}
+ /*
+ * Read VG metadata from this dev's mdas.
+ */
lvmcache_foreach_mda(info, _lvmetad_pvscan_single, &baton);
/*
@@ -1708,8 +1768,10 @@ static struct volume_group *lvmetad_pvscan_vg(struct cmd_context *cmd, struct vo
* since we last read the VG.
*/
if (!baton.vg) {
- log_debug_lvmetad("Did not find VG %s in scan of PV %s", vg->name, dev_name(pvl->pv->dev));
+ log_debug_lvmetad("Rescan VG %s did not find %s.", vg->name, dev_name(devl->dev));
lvmcache_fmt(info)->ops->destroy_instance(baton.fid);
+ lvmetad_pv_found(cmd, (const struct id *) &devl->dev->pvid, devl->dev,
+ lvmcache_fmt(info), label->sector, NULL, NULL, NULL);
continue;
}
@@ -1718,12 +1780,20 @@ static struct volume_group *lvmetad_pvscan_vg(struct cmd_context *cmd, struct vo
* different VG since we last read the VG.
*/
if (strcmp(baton.vg->name, vg->name)) {
- log_debug_lvmetad("Did not find VG %s in scan of PV %s which is now VG %s",
- vg->name, dev_name(pvl->pv->dev), baton.vg->name);
+ log_debug_lvmetad("Rescan VG %s found different VG %s on PV %s.",
+ vg->name, baton.vg->name, dev_name(devl->dev));
release_vg(baton.vg);
+ lvmetad_pv_found(cmd, (const struct id *) &devl->dev->pvid, devl->dev,
+ lvmcache_fmt(info), label->sector, NULL, NULL, NULL);
continue;
}
+ /*
+ * The VG metadata read from each dev should match. Save the
+ * metadata from the first dev, and compare it to the metadata
+ * read from each other dev.
+ */
+
if (!save_seqno)
save_seqno = baton.vg->seqno;
@@ -1735,11 +1805,11 @@ static struct volume_group *lvmetad_pvscan_vg(struct cmd_context *cmd, struct vo
if (!vgmeta_ret) {
vgmeta_ret = vgmeta;
- save_dev = pvl->pv->dev;
+ save_dev = devl->dev;
} else {
if (compare_config(vgmeta_ret->root, vgmeta->root)) {
log_error("VG %s metadata comparison failed for device %s vs %s",
- vg->name, dev_name(pvl->pv->dev), save_dev ? dev_name(save_dev) : "none");
+ vg->name, dev_name(devl->dev), save_dev ? dev_name(save_dev) : "none");
_log_debug_inequality(vg->name, vgmeta_ret->root, vgmeta->root);
dm_config_destroy(vgmeta);
dm_config_destroy(vgmeta_ret);
@@ -1749,9 +1819,63 @@ static struct volume_group *lvmetad_pvscan_vg(struct cmd_context *cmd, struct vo
dm_config_destroy(vgmeta);
}
+ /*
+ * Look for any new PVs in the VG metadata that were not in our
+ * previous version of the VG. Add them to pvs_new to be
+ * scanned in this loop just like the old PVs.
+ */
+ if (!check_new_pvs) {
+ check_new_pvs = 1;
+ dm_list_iterate_items(pvl_new, &baton.vg->pvs) {
+ found = 0;
+ dm_list_iterate_items(pvl, &vg->pvs) {
+ if (pvl_new->pv->dev != pvl->pv->dev)
+ continue;
+ found = 1;
+ break;
+ }
+ if (found)
+ continue;
+ if (!pvl_new->pv->dev) {
+ strncpy(pvid_s, (char *) &pvl_new->pv->id, sizeof(pvid_s) - 1);
+ if (!id_write_format((const struct id *)&pvid_s, uuid, sizeof(uuid)))
+ stack;
+ log_error("Device not found for PV %s in VG %s", uuid, vg->name);
+ missing_devs++;
+ continue;
+ }
+ if (!(devl_new = dm_pool_zalloc(cmd->mem, sizeof(*devl_new))))
+ return_NULL;
+ devl_new->dev = pvl_new->pv->dev;
+ dm_list_add(&pvs_new, &devl_new->list);
+ log_debug_lvmetad("Rescan VG %s found %s was added.", vg->name, dev_name(devl_new->dev));
+ }
+ }
+
release_vg(baton.vg);
}
+ /*
+ * Do the same scanning above for any new PVs.
+ */
+ if (!dm_list_empty(&pvs_new)) {
+ dm_list_init(&pvs_scan);
+ dm_list_splice(&pvs_scan, &pvs_new);
+ dm_list_init(&pvs_new);
+ log_debug_lvmetad("Rescan VG %s found new PVs to scan.", vg->name);
+ goto scan_more;
+ }
+
+ if (missing_devs) {
+ if (vgmeta_ret)
+ dm_config_destroy(vgmeta_ret);
+ return_NULL;
+ }
+
+ /*
+ * Change the metadata into a vg struct to return.
+ */
+
if (vgmeta_ret) {
fid = lvmcache_fmt(info)->ops->create_instance(lvmcache_fmt(info), &fic);
if (!(vg_ret = import_vg_from_config_tree(vgmeta_ret, fid))) {
@@ -1767,8 +1891,8 @@ static struct volume_group *lvmetad_pvscan_vg(struct cmd_context *cmd, struct vo
* to send the metadata cft to lvmetad.
*/
if (save_seqno != vg->seqno) {
- log_debug_lvmetad("Update lvmetad from seqno %u to seqno %u for VG %s",
- vg->seqno, save_seqno, vg->name);
+ log_debug_lvmetad("Rescan VG %s updating lvmetad from seqno %u to seqno %u.",
+ vg->name, vg->seqno, save_seqno);
vg_ret->cft_precommitted = vgmeta_ret;
if (!lvmetad_vg_update(vg_ret))
log_error("Failed to update lvmetad with new VG meta");
@@ -1777,6 +1901,7 @@ static struct volume_group *lvmetad_pvscan_vg(struct cmd_context *cmd, struct vo
dm_config_destroy(vgmeta_ret);
}
out:
+ log_debug_lvmetad("Rescan VG %s done (seqno %u).", vg_ret->name, vg_ret->seqno);
return vg_ret;
}
@@ -2330,6 +2455,8 @@ void lvmetad_validate_global_cache(struct cmd_context *cmd, int force)
_lvmetad_get_pv_cache_list(cmd, &pvc_after);
_update_changed_pvs_in_udev(cmd, &pvc_before, &pvc_after);
}
+
+ log_debug_lvmetad("Validating global lvmetad cache finished");
}
int lvmetad_vg_is_foreign(struct cmd_context *cmd, const char *vgname, const char *vgid)
diff --git a/tools/lvmcmdline.c b/tools/lvmcmdline.c
index be6821b..452e6aa 100644
--- a/tools/lvmcmdline.c
+++ b/tools/lvmcmdline.c
@@ -1599,6 +1599,7 @@ int lvm_run_command(struct cmd_context *cmd, int argc, char **argv)
init_dmeventd_monitor(monitoring);
log_debug("Processing: %s", cmd->cmd_line);
+ log_debug("Command pid: %d", getpid());
log_debug("system ID: %s", cmd->system_id ? : "");
#ifdef O_DIRECT_SUPPORT
7 years, 11 months
v2_02_156 annotated tag has been created
by Alasdair Kergon
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=dc2a9aaa637ffc...
Commit: dc2a9aaa637ffc7b38829dba86a30ddd22fe4c75
Parent: 0000000000000000000000000000000000000000
Author: Alasdair G Kergon <agk(a)redhat.com>
AuthorDate: 2016-06-10 23:08 +0000
Committer: Alasdair G Kergon <agk(a)redhat.com>
CommitterDate: 2016-06-10 23:08 +0000
annotated tag: v2_02_156 has been created
at dc2a9aaa637ffc7b38829dba86a30ddd22fe4c75 (tag)
tagging f2d1f5e9273232fccc05cc819b28ea47f7da7ff9 (commit)
replaces v2_02_155
Release 2.02.156.
Another development release with an assortment of bug fixes and some
extensions to the not-yet-finalised D-Bus support.
29 files changed, 939 insertions(+), 307 deletions(-)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.14 (GNU/Linux)
iEYEABECAAYFAldbSQgACgkQIoGRwVZ+LBd0HwCeIcQOovZtM4ES7zipS5Tdeb3l
iLoAn0o/0C1bkpTIOcm0F1CBtrOkr6nB
=gbnf
-----END PGP SIGNATURE-----
Alasdair G Kergon (2):
post-release
pre-release
David Teigland (7):
lvmetad: define special update in progress string
lvmetad: remove disabled case for "scan error"
lvmetad: handle update failures
lvmcache: add optional dev arg to lvmcache_info_from_pvid
lvmcache: fix duplicate handling with multiple scans
vgcreate, pvcreate, vgextend: don't use a device with duplicates
WHATS_NEW: add recent changes
Peter Rajnoha (2):
blkdeactivate: fix regression in blkdeactivate causing dm and md devices to be skipped.
lvmdump: also collect output from lsblk command when running lvmdump -s
Tony Asleson (9):
lvmdbusd: Add roles property to LV common interface
lvmdbusd: Add data_lv and metadata_lv to cache pool interface
lvmdbusd: Bug fix for missing LV properties
lvmdbusd: Change print statement to py3 syntax
lvmdbusd: Rename get_object_path_by_lvm_id
lvmdbusd: Add method get_object_path_by_lvm_id
lvmdbusd: Create correct LV object type
lvmdbusd: Add test for DataLv & MetaDataLv
lvmdbusd: Remove duplicate test code
Zdenek Kabelac (2):
display: yes no prompt improvement
cleanup: typo in WHATS_NEW_DM
7 years, 11 months
master - post-release
by Alasdair Kergon
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=49a8d1a85eb035...
Commit: 49a8d1a85eb035a0dfb1febd76e3ae4fa5e976d5
Parent: f2d1f5e9273232fccc05cc819b28ea47f7da7ff9
Author: Alasdair G Kergon <agk(a)redhat.com>
AuthorDate: Sat Jun 11 00:14:00 2016 +0100
Committer: Alasdair G Kergon <agk(a)redhat.com>
CommitterDate: Sat Jun 11 00:14:00 2016 +0100
post-release
---
VERSION | 2 +-
VERSION_DM | 2 +-
WHATS_NEW | 3 +++
WHATS_NEW_DM | 3 +++
4 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/VERSION b/VERSION
index 0802557..a7628a4 100644
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-2.02.156(2)-git (2016-06-11)
+2.02.157(2)-git (2016-06-11)
diff --git a/VERSION_DM b/VERSION_DM
index 35c3a63..a1416c0 100644
--- a/VERSION_DM
+++ b/VERSION_DM
@@ -1 +1 @@
-1.02.127-git (2016-06-11)
+1.02.128-git (2016-06-11)
diff --git a/WHATS_NEW b/WHATS_NEW
index 046f77a..61b58b4 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,3 +1,6 @@
+Version 2.02.157 -
+=================================
+
Version 2.02.156 - 11th June 2016
=================================
Don't allow duplicate orphan PVs to be used with vgcreate/vgextend/pvcreate.
diff --git a/WHATS_NEW_DM b/WHATS_NEW_DM
index 1135a62..bd17f1b 100644
--- a/WHATS_NEW_DM
+++ b/WHATS_NEW_DM
@@ -1,3 +1,6 @@
+Version 1.02.128 -
+=================================
+
Version 1.02.127 - 11th June 2016
=================================
Fix blkdeactivate regression causing skipping of dm + md devices. (1.02.126)
7 years, 11 months
master - pre-release
by Alasdair Kergon
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=f2d1f5e9273232...
Commit: f2d1f5e9273232fccc05cc819b28ea47f7da7ff9
Parent: 2d384954adf6355364257045738c9bd6c5dedad5
Author: Alasdair G Kergon <agk(a)redhat.com>
AuthorDate: Sat Jun 11 00:08:08 2016 +0100
Committer: Alasdair G Kergon <agk(a)redhat.com>
CommitterDate: Sat Jun 11 00:08:08 2016 +0100
pre-release
---
VERSION | 2 +-
VERSION_DM | 2 +-
WHATS_NEW | 5 ++---
WHATS_NEW_DM | 5 +++--
4 files changed, 7 insertions(+), 7 deletions(-)
diff --git a/VERSION b/VERSION
index e2b1146..0802557 100644
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-2.02.156(2)-git (2016-06-03)
+2.02.156(2)-git (2016-06-11)
diff --git a/VERSION_DM b/VERSION_DM
index fddb2ee..35c3a63 100644
--- a/VERSION_DM
+++ b/VERSION_DM
@@ -1 +1 @@
-1.02.127-git (2016-06-03)
+1.02.127-git (2016-06-11)
diff --git a/WHATS_NEW b/WHATS_NEW
index 9c8ae71..046f77a 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,10 +1,9 @@
-Version 2.02.156 -
-================================
+Version 2.02.156 - 11th June 2016
+=================================
Don't allow duplicate orphan PVs to be used with vgcreate/vgextend/pvcreate.
Improve handling of lvmetad update failures.
Yes/No prompt accepts '^[ ^t]*([Yy]([Ee]([Ss]|)|)|[Nn]([Oo]|))[ ^t]*$'.
If available, also collect output from lsblk command when running lvmdump -s.
- Fix regression in blkdeactivate causing dm and md devices to be skipped. (2.02.155)
Version 2.02.155 - 3rd June 2016
================================
diff --git a/WHATS_NEW_DM b/WHATS_NEW_DM
index 371e8b5..1135a62 100644
--- a/WHATS_NEW_DM
+++ b/WHATS_NEW_DM
@@ -1,5 +1,6 @@
-Version 1.02.127 -
-================================
+Version 1.02.127 - 11th June 2016
+=================================
+ Fix blkdeactivate regression causing skipping of dm + md devices. (1.02.126)
Version 1.02.126 - 3rd June 2016
================================
7 years, 11 months
master - lvmdbusd: Remove duplicate test code
by tasleson
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=2d384954adf635...
Commit: 2d384954adf6355364257045738c9bd6c5dedad5
Parent: a1febff85783b46b5b044bce6f29ece8413ce934
Author: Tony Asleson <tasleson(a)redhat.com>
AuthorDate: Fri Jun 10 13:45:59 2016 -0500
Committer: Tony Asleson <tasleson(a)redhat.com>
CommitterDate: Fri Jun 10 16:05:03 2016 -0500
lvmdbusd: Remove duplicate test code
---
test/dbus/lvmdbustest.py | 30 ++++--------------------------
1 files changed, 4 insertions(+), 26 deletions(-)
diff --git a/test/dbus/lvmdbustest.py b/test/dbus/lvmdbustest.py
index 0cb3bb6..4443b0c 100755
--- a/test/dbus/lvmdbustest.py
+++ b/test/dbus/lvmdbustest.py
@@ -158,8 +158,7 @@ class TestDbusService(unittest.TestCase):
self.assertTrue(rc == '/')
self.assertEqual(self._refresh(), 0)
-
- def _create_raid5_thin_pool(self, vg = None):
+ def _create_raid5_thin_pool(self, vg=None):
if not vg:
pv_paths = []
@@ -200,7 +199,6 @@ class TestDbusService(unittest.TestCase):
cached_thin_pool_path = cache_pool.\
CachePool.CacheLv(thin_pool.object_path, -1, {})[0]
-
# Get object proxy for cached thin pool
cached_thin_pool_object = ClientProxy(self.bus, cached_thin_pool_path)
@@ -208,8 +206,6 @@ class TestDbusService(unittest.TestCase):
self.assertTrue(cached_thin_pool_object.ThinPool.DataLv != '/')
self.assertTrue(cached_thin_pool_object.ThinPool.MetaDataLv != '/')
- self.assertTrue(cached_thin_pool_path != '/')
-
def _lookup(self, lvm_id):
return self.objs[MANAGER_INT][0].Manager.LookUpByLvmId(lvm_id)
@@ -258,9 +254,10 @@ class TestDbusService(unittest.TestCase):
mgr = self.objs[MANAGER_INT][0].Manager
# Do a vg lookup
- path = self.objs[MANAGER_INT][0].Manager.LookUpByLvmId(vg.Name)
+ path = mgr.LookUpByLvmId(vg.Name)
vg_name_start = vg.Name
+
prev_path = path
self.assertTrue(path != '/', "%s" % (path))
@@ -317,30 +314,11 @@ class TestDbusService(unittest.TestCase):
def test_vg_rename_with_thin_pool(self):
- pv_paths = []
- for pp in self.objs[PV_INT]:
- pv_paths.append(pp.object_path)
-
- vg = self._vg_create(pv_paths).Vg
+ (vg, thin_pool) = self._create_raid5_thin_pool()
vg_name_start = vg.Name
-
mgr = self.objs[MANAGER_INT][0].Manager
- # Let's create a thin pool which uses a raid 5 meta and raid5 data
- # areas
- lv_meta_path = vg.LvCreateRaid(
- "meta_r5", "raid5", mib(4), 0, 0, -1, {})[0]
-
- lv_data_path = vg.LvCreateRaid(
- "data_r5", "raid5", mib(16), 0, 0, -1, {})[0]
-
- thin_pool_path = vg.CreateThinPool(
- lv_meta_path, lv_data_path, -1, {})[0]
-
- # Lets create some thin LVs
- thin_pool = ClientProxy(self.bus, thin_pool_path)
-
# noinspection PyTypeChecker
self._verify_hidden_lookups(thin_pool.LvCommon, vg_name_start)
7 years, 11 months
master - lvmdbusd: Add test for DataLv & MetaDataLv
by tasleson
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=a1febff85783b4...
Commit: a1febff85783b46b5b044bce6f29ece8413ce934
Parent: cdf06044e189ec1adeaba101a21598c31752b9cd
Author: Tony Asleson <tasleson(a)redhat.com>
AuthorDate: Fri Jun 10 13:36:53 2016 -0500
Committer: Tony Asleson <tasleson(a)redhat.com>
CommitterDate: Fri Jun 10 16:05:03 2016 -0500
lvmdbusd: Add test for DataLv & MetaDataLv
Added tests which expose an issue found with these properties.
---
test/dbus/lvmdbustest.py | 60 +++++++++++++++++++++++++++++++++++++++++++--
1 files changed, 57 insertions(+), 3 deletions(-)
diff --git a/test/dbus/lvmdbustest.py b/test/dbus/lvmdbustest.py
index 4c58552..0cb3bb6 100755
--- a/test/dbus/lvmdbustest.py
+++ b/test/dbus/lvmdbustest.py
@@ -158,6 +158,58 @@ class TestDbusService(unittest.TestCase):
self.assertTrue(rc == '/')
self.assertEqual(self._refresh(), 0)
+
+ def _create_raid5_thin_pool(self, vg = None):
+
+ if not vg:
+ pv_paths = []
+ for pp in self.objs[PV_INT]:
+ pv_paths.append(pp.object_path)
+
+ vg = self._vg_create(pv_paths).Vg
+
+ lv_meta_path = vg.LvCreateRaid(
+ "meta_r5", "raid5", mib(4), 0, 0, -1, {})[0]
+
+ lv_data_path = vg.LvCreateRaid(
+ "data_r5", "raid5", mib(16), 0, 0, -1, {})[0]
+
+ thin_pool_path = vg.CreateThinPool(
+ lv_meta_path, lv_data_path, -1, {})[0]
+
+ # Get thin pool client proxy
+ thin_pool = ClientProxy(self.bus, thin_pool_path)
+
+ return vg, thin_pool
+
+ def test_meta_lv_data_lv_props(self):
+ # Ensure that metadata lv and data lv for thin pools and cache pools
+ # point to a valid LV
+ (vg, thin_pool) = self._create_raid5_thin_pool()
+
+ # Check properties on thin pool
+ self.assertTrue(thin_pool.ThinPool.DataLv != '/')
+ self.assertTrue(thin_pool.ThinPool.MetaDataLv != '/')
+
+ (vg, cache_pool) = self._create_cache_pool(vg)
+
+ self.assertTrue(cache_pool.CachePool.DataLv != '/')
+ self.assertTrue(cache_pool.CachePool.MetaDataLv != '/')
+
+ # Cache the thin pool
+ cached_thin_pool_path = cache_pool.\
+ CachePool.CacheLv(thin_pool.object_path, -1, {})[0]
+
+
+ # Get object proxy for cached thin pool
+ cached_thin_pool_object = ClientProxy(self.bus, cached_thin_pool_path)
+
+ # Check properties on cache pool
+ self.assertTrue(cached_thin_pool_object.ThinPool.DataLv != '/')
+ self.assertTrue(cached_thin_pool_object.ThinPool.MetaDataLv != '/')
+
+ self.assertTrue(cached_thin_pool_path != '/')
+
def _lookup(self, lvm_id):
return self.objs[MANAGER_INT][0].Manager.LookUpByLvmId(lvm_id)
@@ -974,8 +1026,10 @@ class TestDbusService(unittest.TestCase):
self.assertTrue(job_path != '/')
self._wait_for_job(job_path)
- def _create_cache_pool(self):
- vg = self._vg_create().Vg
+ def _create_cache_pool(self, vg=None):
+
+ if not vg:
+ vg = self._vg_create().Vg
md = self._create_lv(size=(mib(8)), vg=vg)
data = self._create_lv(size=(mib(8)), vg=vg)
@@ -985,7 +1039,7 @@ class TestDbusService(unittest.TestCase):
cp = ClientProxy(self.bus, cache_pool_path)
- return (vg, cp)
+ return vg, cp
def test_cache_pool_create(self):
7 years, 11 months
master - lvmdbusd: Create correct LV object type
by tasleson
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=cdf06044e189ec...
Commit: cdf06044e189ec1adeaba101a21598c31752b9cd
Parent: b81186e535f0c93ef8b276cfb2b7bcf55268aec0
Author: Tony Asleson <tasleson(a)redhat.com>
AuthorDate: Fri Jun 10 12:11:17 2016 -0500
Committer: Tony Asleson <tasleson(a)redhat.com>
CommitterDate: Fri Jun 10 16:05:03 2016 -0500
lvmdbusd: Create correct LV object type
We were initially looking to see if an LV was hidden and if it was we were
creating an instance of a LvCommon object to represent it. Thus if we
had a hidden cache pool for example we were missing the methods and
properties for the cache pool. However, when we create the object path,
any hidden LVs, regardless of type/functionality will be placed in the
hidden path.
---
daemons/lvmdbusd/lv.py | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/daemons/lvmdbusd/lv.py b/daemons/lvmdbusd/lv.py
index e32f8e5..5c7b3b5 100644
--- a/daemons/lvmdbusd/lv.py
+++ b/daemons/lvmdbusd/lv.py
@@ -176,8 +176,6 @@ class LvState(State):
self.Name, (self.Attr, self.layout, self.role))
def _object_type_create(self):
- if self.Name[0] == '[':
- return LvCommon
if self.Attr[0] == 't':
return LvThinPool
elif self.Attr[0] == 'C':
@@ -185,6 +183,8 @@ class LvState(State):
return LvCachePool
else:
return LvCacheLv
+ elif self.Name[0] == '[':
+ return LvCommon
elif self.OriginLv != '/':
return LvSnapShot
else:
7 years, 11 months
master - lvmdbusd: Add method get_object_path_by_lvm_id
by tasleson
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=b81186e535f0c9...
Commit: b81186e535f0c93ef8b276cfb2b7bcf55268aec0
Parent: b717e8fe1d926d6dd6e5a03354706351d90477d2
Author: Tony Asleson <tasleson(a)redhat.com>
AuthorDate: Fri Jun 10 12:05:52 2016 -0500
Committer: Tony Asleson <tasleson(a)redhat.com>
CommitterDate: Fri Jun 10 16:04:43 2016 -0500
lvmdbusd: Add method get_object_path_by_lvm_id
The object manager method get_object_by_lvm_id was used in many cases for
the sole reason of getting the object path for the object. Instead of
retrieving the object and then calling 'dbus_object_path' on the object, we
are adding a method which returns the object path.
---
daemons/lvmdbusd/lv.py | 14 +++-----------
daemons/lvmdbusd/objectmanager.py | 11 +++++++++++
daemons/lvmdbusd/vg.py | 7 +------
3 files changed, 15 insertions(+), 17 deletions(-)
diff --git a/daemons/lvmdbusd/lv.py b/daemons/lvmdbusd/lv.py
index 4638a31..e32f8e5 100644
--- a/daemons/lvmdbusd/lv.py
+++ b/daemons/lvmdbusd/lv.py
@@ -354,12 +354,7 @@ class Lv(LvCommon):
# The name is vg/name
full_name = "%s/%s" % (self.vg_name_lookup(), name)
-
- o = cfg.om.get_object_by_lvm_id(full_name)
- if o:
- return o.dbus_object_path()
-
- return '/'
+ return cfg.om.get_object_path_by_lvm_id(full_name)
def _get_data_meta(self):
@@ -783,8 +778,7 @@ class LvCachePool(Lv):
cfg.om.remove_object(lv_to_cache, emit_signal=True)
cfg.load()
- lv_converted = \
- cfg.om.get_object_by_lvm_id(fcn).dbus_object_path()
+ lv_converted = cfg.om.get_object_path_by_lvm_id(fcn)
else:
raise dbus.exceptions.DBusException(
@@ -847,9 +841,7 @@ class LvCacheLv(Lv):
cfg.om.remove_object(dbo, emit_signal=True)
cfg.load()
- uncached_lv_path = \
- cfg.om.get_object_by_lvm_id(lv_name).dbus_object_path()
-
+ uncached_lv_path = cfg.om.get_object_path_by_lvm_id(lv_name)
else:
raise dbus.exceptions.DBusException(
LV_INTERFACE,
diff --git a/daemons/lvmdbusd/objectmanager.py b/daemons/lvmdbusd/objectmanager.py
index cd44480..c93f207 100644
--- a/daemons/lvmdbusd/objectmanager.py
+++ b/daemons/lvmdbusd/objectmanager.py
@@ -185,6 +185,17 @@ class ObjectManager(AutomatedProperties):
return self.get_object_by_path(self._id_to_object_path[lvm_id])
return None
+ def get_object_path_by_lvm_id(self, lvm_id):
+ """
+ Given an lvm identifier, return the object path for it
+ :param lvm_id: The lvm identifier
+ :return: Object path or '/' if not found
+ """
+ with self.rlock:
+ if lvm_id in self._id_to_object_path:
+ return self._id_to_object_path[lvm_id]
+ return '/'
+
def _uuid_verify(self, path, uuid, lvm_id):
"""
Ensure uuid is present for a successful lvm_id lookup
diff --git a/daemons/lvmdbusd/vg.py b/daemons/lvmdbusd/vg.py
index 45b4030..c700667 100644
--- a/daemons/lvmdbusd/vg.py
+++ b/daemons/lvmdbusd/vg.py
@@ -144,13 +144,8 @@ class Vg(AutomatedProperties):
@staticmethod
def fetch_new_lv(vg_name, lv_name):
- full_name = "%s/%s" % (vg_name, lv_name)
-
cfg.load()
- l = cfg.om.get_object_by_lvm_id(full_name)
- created_lv = l.dbus_object_path()
-
- return created_lv
+ return cfg.om.get_object_by_lvm_id("%s/%s" % (vg_name, lv_name))
@staticmethod
def _rename(uuid, vg_name, new_name, rename_options):
7 years, 11 months
master - lvmdbusd: Rename get_object_path_by_lvm_id
by tasleson
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=b717e8fe1d926d...
Commit: b717e8fe1d926d6dd6e5a03354706351d90477d2
Parent: 41ebed707700e926d4224bc62289ea47014d9a0d
Author: Tony Asleson <tasleson(a)redhat.com>
AuthorDate: Fri Jun 10 12:03:04 2016 -0500
Committer: Tony Asleson <tasleson(a)redhat.com>
CommitterDate: Fri Jun 10 15:28:42 2016 -0500
lvmdbusd: Rename get_object_path_by_lvm_id
Renaming to get_object_path_by_uuid_lvm_id, to clarify that both the uuid
and the lvm id are required.
---
daemons/lvmdbusd/lv.py | 12 ++++++------
daemons/lvmdbusd/manager.py | 4 ++--
daemons/lvmdbusd/objectmanager.py | 6 +++---
daemons/lvmdbusd/pv.py | 8 ++++----
daemons/lvmdbusd/vg.py | 6 +++---
5 files changed, 18 insertions(+), 18 deletions(-)
diff --git a/daemons/lvmdbusd/lv.py b/daemons/lvmdbusd/lv.py
index 2786f68..4638a31 100644
--- a/daemons/lvmdbusd/lv.py
+++ b/daemons/lvmdbusd/lv.py
@@ -100,7 +100,7 @@ class LvState(State):
rc = []
for pv in sorted(cfg.db.lv_contained_pv(uuid)):
(pv_uuid, pv_name, pv_segs) = pv
- pv_obj = cfg.om.get_object_path_by_lvm_id(
+ pv_obj = cfg.om.get_object_path_by_uuid_lvm_id(
pv_uuid, pv_name, gen_new=False)
rc.append((pv_obj, pv_segs))
@@ -123,7 +123,7 @@ class LvState(State):
for l in cfg.db.hidden_lvs(self.Uuid):
full_name = "%s/%s" % (vg_name, l[1])
- op = cfg.om.get_object_path_by_lvm_id(
+ op = cfg.om.get_object_path_by_uuid_lvm_id(
l[0], full_name, gen_new=False)
assert op
rc.append(op)
@@ -143,7 +143,7 @@ class LvState(State):
else:
self._segs.extend(set(segtypes))
- self.Vg = cfg.om.get_object_path_by_lvm_id(
+ self.Vg = cfg.om.get_object_path_by_uuid_lvm_id(
vg_uuid, vg_name, vg_obj_path_generate)
self.Devices = LvState._pv_devices(self.Uuid)
@@ -151,7 +151,7 @@ class LvState(State):
if PoolLv:
gen = utils.lv_object_path_method(Name, (Attr, layout, role))
- self.PoolLv = cfg.om.get_object_path_by_lvm_id(
+ self.PoolLv = cfg.om.get_object_path_by_uuid_lvm_id(
pool_lv_uuid, '%s/%s' % (vg_name, PoolLv),
gen)
else:
@@ -159,7 +159,7 @@ class LvState(State):
if OriginLv:
self.OriginLv = \
- cfg.om.get_object_path_by_lvm_id(
+ cfg.om.get_object_path_by_uuid_lvm_id(
origin_uuid, '%s/%s' % (vg_name, OriginLv),
vg_obj_path_generate)
else:
@@ -192,7 +192,7 @@ class LvState(State):
def create_dbus_object(self, path):
if not path:
- path = cfg.om.get_object_path_by_lvm_id(
+ path = cfg.om.get_object_path_by_uuid_lvm_id(
self.Uuid, self.lvm_id, self._object_path_create())
obj_ctor = self._object_type_create()
diff --git a/daemons/lvmdbusd/manager.py b/daemons/lvmdbusd/manager.py
index c728439..2388d8a 100644
--- a/daemons/lvmdbusd/manager.py
+++ b/daemons/lvmdbusd/manager.py
@@ -36,7 +36,7 @@ class Manager(AutomatedProperties):
# Check to see if we are already trying to create a PV for an existing
# PV
- pv = cfg.om.get_object_path_by_lvm_id(
+ pv = cfg.om.get_object_path_by_uuid_lvm_id(
device, device, None, False)
if pv:
raise dbus.exceptions.DBusException(
@@ -159,7 +159,7 @@ class Manager(AutomatedProperties):
:param key: The lookup value
:return: Return the object path. If object not found you will get '/'
"""
- p = cfg.om.get_object_path_by_lvm_id(
+ p = cfg.om.get_object_path_by_uuid_lvm_id(
key, key, gen_new=False)
if p:
return p
diff --git a/daemons/lvmdbusd/objectmanager.py b/daemons/lvmdbusd/objectmanager.py
index f8f6d97..cd44480 100644
--- a/daemons/lvmdbusd/objectmanager.py
+++ b/daemons/lvmdbusd/objectmanager.py
@@ -173,7 +173,7 @@ class ObjectManager(AutomatedProperties):
def get_object_by_uuid_lvm_id(self, uuid, lvm_id):
with self.rlock:
return self.get_object_by_path(
- self.get_object_path_by_lvm_id(uuid, lvm_id, None, False))
+ self.get_object_path_by_uuid_lvm_id(uuid, lvm_id, None, False))
def get_object_by_lvm_id(self, lvm_id):
"""
@@ -212,8 +212,8 @@ class ObjectManager(AutomatedProperties):
self._uuid_verify(path, uuid, lvm_identifier)
return path
- def get_object_path_by_lvm_id(self, uuid, lvm_id, path_create=None,
- gen_new=True):
+ def get_object_path_by_uuid_lvm_id(self, uuid, lvm_id, path_create=None,
+ gen_new=True):
"""
For a given lvm asset return the dbus object registered to it. If the
object is not found and gen_new == True and path_create is a valid
diff --git a/daemons/lvmdbusd/pv.py b/daemons/lvmdbusd/pv.py
index 287825f..bbd76f1 100644
--- a/daemons/lvmdbusd/pv.py
+++ b/daemons/lvmdbusd/pv.py
@@ -65,7 +65,7 @@ class PvState(State):
full_name = "%s/%s" % (vg_name, lv_name)
path_create = lv_object_path_method(lv_name, meta)
- lv_path = cfg.om.get_object_path_by_lvm_id(
+ lv_path = cfg.om.get_object_path_by_uuid_lvm_id(
lv_uuid, full_name, path_create)
rc.append((lv_path, segs))
@@ -83,7 +83,7 @@ class PvState(State):
self.lv = self._lv_object_list(vg_name)
if vg_name:
- self.vg_path = cfg.om.get_object_path_by_lvm_id(
+ self.vg_path = cfg.om.get_object_path_by_uuid_lvm_id(
vg_uuid, vg_name, vg_obj_path_generate)
else:
self.vg_path = '/'
@@ -93,8 +93,8 @@ class PvState(State):
def create_dbus_object(self, path):
if not path:
- path = cfg.om.get_object_path_by_lvm_id(self.Uuid, self.Name,
- pv_obj_path_generate)
+ path = cfg.om.get_object_path_by_uuid_lvm_id(self.Uuid, self.Name,
+ pv_obj_path_generate)
return Pv(path, self)
# noinspection PyMethodMayBeStatic
diff --git a/daemons/lvmdbusd/vg.py b/daemons/lvmdbusd/vg.py
index f5b3e45..45b4030 100644
--- a/daemons/lvmdbusd/vg.py
+++ b/daemons/lvmdbusd/vg.py
@@ -66,7 +66,7 @@ class VgState(State):
gen = utils.lv_object_path_method(lv_name, meta)
- lv_path = cfg.om.get_object_path_by_lvm_id(
+ lv_path = cfg.om.get_object_path_by_uuid_lvm_id(
lv_uuid, full_name, gen)
rc.append(lv_path)
return dbus.Array(rc, signature='o')
@@ -75,7 +75,7 @@ class VgState(State):
rc = []
for p in cfg.db.pvs_in_vg(self.Uuid):
(pv_name, pv_uuid) = p
- rc.append(cfg.om.get_object_path_by_lvm_id(
+ rc.append(cfg.om.get_object_path_by_uuid_lvm_id(
pv_uuid, pv_name, pv_obj_path_generate))
return dbus.Array(rc, signature='o')
@@ -90,7 +90,7 @@ class VgState(State):
def create_dbus_object(self, path):
if not path:
- path = cfg.om.get_object_path_by_lvm_id(
+ path = cfg.om.get_object_path_by_uuid_lvm_id(
self.Uuid, self.Name, vg_obj_path_generate)
return Vg(path, self)
7 years, 11 months