main - hash: use individual hint sizes
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=2d64ffaee521222e64b...
Commit: 2d64ffaee521222e64b5c0bdfec367617e503f05
Parent: 78c7ae7cd2dab7abf9ece9bec37979fa3b33c978
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Sun Mar 7 15:33:50 2021 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Mon Mar 8 15:33:15 2021 +0100
hash: use individual hint sizes
Use different 'hint' size for dm_hash_create() call - so
when debug info about hash is printed we can recognize which
hash was in use.
This patch doesn't change actual used size since that is always
rounded to be power of 2 and >=16 - so as such is only a
help to developer.
We could eventually use 'name' arg, but since this would have changed
API and this patchset will be routed to libdm & stable - we will
just use this small trick.
---
device_mapper/libdm-deptree.c | 4 ++--
device_mapper/libdm-report.c | 2 +-
lib/cache/lvmcache.c | 6 +++---
lib/config/config.c | 2 +-
lib/device/dev-cache.c | 6 +++---
lib/filters/filter-mpath.c | 2 +-
lib/filters/filter-persistent.c | 2 +-
lib/format_text/export.c | 2 +-
lib/format_text/format-text.c | 2 +-
lib/format_text/import_vsn1.c | 4 ++--
lib/log/log.c | 2 +-
lib/metadata/vg.c | 2 +-
12 files changed, 18 insertions(+), 18 deletions(-)
diff --git a/device_mapper/libdm-deptree.c b/device_mapper/libdm-deptree.c
index 7045e1f26..ede75ef77 100644
--- a/device_mapper/libdm-deptree.c
+++ b/device_mapper/libdm-deptree.c
@@ -380,13 +380,13 @@ struct dm_tree *dm_tree_create(void)
dtree->mem = dmem;
dtree->optional_uuid_suffixes = NULL;
- if (!(dtree->devs = dm_hash_create(8))) {
+ if (!(dtree->devs = dm_hash_create(61))) {
log_error("dtree hash creation failed");
dm_pool_destroy(dtree->mem);
return NULL;
}
- if (!(dtree->uuids = dm_hash_create(32))) {
+ if (!(dtree->uuids = dm_hash_create(31))) {
log_error("dtree uuid hash creation failed");
dm_hash_destroy(dtree->devs);
dm_pool_destroy(dtree->mem);
diff --git a/device_mapper/libdm-report.c b/device_mapper/libdm-report.c
index 1928354d3..f14aa8bc7 100644
--- a/device_mapper/libdm-report.c
+++ b/device_mapper/libdm-report.c
@@ -2474,7 +2474,7 @@ dm_percent_t dm_make_percent(uint64_t numerator, uint64_t denominator)
int dm_report_value_cache_set(struct dm_report *rh, const char *name, const void *data)
{
- if (!rh->value_cache && (!(rh->value_cache = dm_hash_create(64)))) {
+ if (!rh->value_cache && (!(rh->value_cache = dm_hash_create(63)))) {
log_error("Failed to create cache for values used during reporting.");
return 0;
}
diff --git a/lib/cache/lvmcache.c b/lib/cache/lvmcache.c
index b78262b65..d4acec509 100644
--- a/lib/cache/lvmcache.c
+++ b/lib/cache/lvmcache.c
@@ -101,13 +101,13 @@ int lvmcache_init(struct cmd_context *cmd)
dm_list_init(&_unused_duplicates);
dm_list_init(&_prev_unused_duplicate_devs);
- if (!(_vgname_hash = dm_hash_create(128)))
+ if (!(_vgname_hash = dm_hash_create(127)))
return 0;
- if (!(_vgid_hash = dm_hash_create(128)))
+ if (!(_vgid_hash = dm_hash_create(126)))
return 0;
- if (!(_pvid_hash = dm_hash_create(128)))
+ if (!(_pvid_hash = dm_hash_create(125)))
return 0;
return 1;
diff --git a/lib/config/config.c b/lib/config/config.c
index 9725dece3..409555096 100644
--- a/lib/config/config.c
+++ b/lib/config/config.c
@@ -1142,7 +1142,7 @@ int config_def_check(struct cft_check_handle *handle)
* If section name is variable, use '#' as a substitute.
*/
if (!handle->cmd->cft_def_hash) {
- if (!(handle->cmd->cft_def_hash = dm_hash_create(64))) {
+ if (!(handle->cmd->cft_def_hash = dm_hash_create(60))) {
log_error("Failed to create configuration definition hash.");
r = 0; goto out;
}
diff --git a/lib/device/dev-cache.c b/lib/device/dev-cache.c
index 5632456bf..cf6334564 100644
--- a/lib/device/dev-cache.c
+++ b/lib/device/dev-cache.c
@@ -1222,9 +1222,9 @@ int dev_cache_init(struct cmd_context *cmd)
if (!(_cache.mem = dm_pool_create("dev_cache", 10 * 1024)))
return_0;
- if (!(_cache.names = dm_hash_create(128)) ||
- !(_cache.vgid_index = dm_hash_create(32)) ||
- !(_cache.lvid_index = dm_hash_create(32))) {
+ if (!(_cache.names = dm_hash_create(120)) ||
+ !(_cache.vgid_index = dm_hash_create(30)) ||
+ !(_cache.lvid_index = dm_hash_create(29))) {
dm_pool_destroy(_cache.mem);
_cache.mem = 0;
return_0;
diff --git a/lib/filters/filter-mpath.c b/lib/filters/filter-mpath.c
index 853a2c569..202296458 100644
--- a/lib/filters/filter-mpath.c
+++ b/lib/filters/filter-mpath.c
@@ -374,7 +374,7 @@ struct dev_filter *mpath_filter_create(struct dev_types *dt)
return NULL;
}
- if (!(hash = dm_hash_create(128))) {
+ if (!(hash = dm_hash_create(110))) {
log_error("mpath hash table creation failed.");
return NULL;
}
diff --git a/lib/filters/filter-persistent.c b/lib/filters/filter-persistent.c
index 291f3932f..3f7007e4d 100644
--- a/lib/filters/filter-persistent.c
+++ b/lib/filters/filter-persistent.c
@@ -58,7 +58,7 @@ static int _init_hash(struct pfilter *pf)
if (pf->devices)
dm_hash_destroy(pf->devices);
- if (!(pf->devices = dm_hash_create(128)))
+ if (!(pf->devices = dm_hash_create(111)))
return_0;
return 1;
diff --git a/lib/format_text/export.c b/lib/format_text/export.c
index 33844a2fd..7a95bdba4 100644
--- a/lib/format_text/export.c
+++ b/lib/format_text/export.c
@@ -960,7 +960,7 @@ static int _build_pv_names(struct formatter *f, struct volume_group *vg)
if (!(f->mem = dm_pool_create("text pv_names", 512)))
return_0;
- if (!(f->pv_names = dm_hash_create(128)))
+ if (!(f->pv_names = dm_hash_create(115)))
return_0;
dm_list_iterate_items(pvl, &vg->pvs) {
diff --git a/lib/format_text/format-text.c b/lib/format_text/format-text.c
index bf1b9b3a4..3ed6aa54a 100644
--- a/lib/format_text/format-text.c
+++ b/lib/format_text/format-text.c
@@ -2223,7 +2223,7 @@ static int _create_vg_text_instance(struct format_instance *fid,
vg_name = fic->context.vg_ref.vg_name;
vg_id = fic->context.vg_ref.vg_id;
- if (!(fid->metadata_areas_index = dm_hash_create(128))) {
+ if (!(fid->metadata_areas_index = dm_hash_create(116))) {
log_error("Couldn't create metadata index for format "
"instance of VG %s.", vg_name);
return 0;
diff --git a/lib/format_text/import_vsn1.c b/lib/format_text/import_vsn1.c
index ee56502e1..ef25369a6 100644
--- a/lib/format_text/import_vsn1.c
+++ b/lib/format_text/import_vsn1.c
@@ -1074,7 +1074,7 @@ static struct volume_group *_read_vg(struct cmd_context *cmd,
* The pv hash memorises the pv section names -> pv
* structures.
*/
- if (!(pv_hash = dm_hash_create(64))) {
+ if (!(pv_hash = dm_hash_create(59))) {
log_error("Couldn't create pv hash table.");
goto bad;
}
@@ -1083,7 +1083,7 @@ static struct volume_group *_read_vg(struct cmd_context *cmd,
* The lv hash memorises the lv section names -> lv
* structures.
*/
- if (!(lv_hash = dm_hash_create(1024))) {
+ if (!(lv_hash = dm_hash_create(1023))) {
log_error("Couldn't create lv hash table.");
goto bad;
}
diff --git a/lib/log/log.c b/lib/log/log.c
index ebf26b4de..cd676f2ae 100644
--- a/lib/log/log.c
+++ b/lib/log/log.c
@@ -576,7 +576,7 @@ static void _vprint_log(int level, const char *file, int line, int dm_errno_or_c
if (log_once) {
if (!_duplicated)
- _duplicated = dm_hash_create(128);
+ _duplicated = dm_hash_create(117);
if (_duplicated) {
if (dm_hash_lookup(_duplicated, message))
level = _LOG_NOTICE;
diff --git a/lib/metadata/vg.c b/lib/metadata/vg.c
index e659579c2..3f9ec8d35 100644
--- a/lib/metadata/vg.c
+++ b/lib/metadata/vg.c
@@ -46,7 +46,7 @@ struct volume_group *alloc_vg(const char *pool_name, struct cmd_context *cmd,
vg->vgmem = vgmem;
vg->alloc = ALLOC_NORMAL;
- if (!(vg->hostnames = dm_hash_create(16))) {
+ if (!(vg->hostnames = dm_hash_create(14))) {
log_error("Failed to allocate VG hostname hashtable.");
dm_pool_destroy(vgmem);
return NULL;
3 years, 1 month
main - lvremove: reduce ioctl count
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=78c7ae7cd2dab7abf9e...
Commit: 78c7ae7cd2dab7abf9ece9bec37979fa3b33c978
Parent: dceef4709d7ee5d06fb61120cc15fc29feb3e6b8
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Mon Mar 8 14:22:43 2021 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Mon Mar 8 15:32:10 2021 +0100
lvremove: reduce ioctl count
Just like with deactivation, call of 'lv_is_not_in_use()'
now has embeded report for inactivate LV.
Note: this patch cannot be backported to stable-2.02 - as
there lv_is_active() has 'cluster' meaning and differs from lvinfo().
---
lib/metadata/lv_manip.c | 39 ++++++++++++++++++++-------------------
1 file changed, 20 insertions(+), 19 deletions(-)
diff --git a/lib/metadata/lv_manip.c b/lib/metadata/lv_manip.c
index b93f18e6e..5573e6f43 100644
--- a/lib/metadata/lv_manip.c
+++ b/lib/metadata/lv_manip.c
@@ -6602,26 +6602,27 @@ int lv_remove_single(struct cmd_context *cmd, struct logical_volume *lv,
/* FIXME Ensure not referred to by another existing LVs */
ask_discard = find_config_tree_bool(cmd, devices_issue_discards_CFG, NULL);
- if (!lv_is_cache_vol(lv) &&
- lv_is_active(lv)) {
- if (!lv_check_not_in_use(lv, 1))
- return_0;
-
- if ((force == PROMPT) &&
- !lv_is_pending_delete(lv) &&
- lv_is_visible(lv)) {
- if (vg->needs_write_and_commit && (!vg_write(vg) || !vg_commit(vg)))
- return 0;
- if (yes_no_prompt("Do you really want to remove%s active "
- "%slogical volume %s? [y/n]: ",
- ask_discard ? " and DISCARD" : "",
- vg_is_clustered(vg) ? "clustered " : "",
- display_lvname(lv)) == 'n') {
- log_error("Logical volume %s not removed.", display_lvname(lv));
- return 0;
+ if (!lv_is_cache_vol(lv)) {
+ switch (lv_check_not_in_use(lv, 1)) {
+ case 0: return_0;
+ case 1: /* Active, not in use */
+ if ((force == PROMPT) &&
+ !lv_is_pending_delete(lv) &&
+ lv_is_visible(lv)) {
+ if (vg->needs_write_and_commit && (!vg_write(vg) || !vg_commit(vg)))
+ return 0;
+ if (yes_no_prompt("Do you really want to remove%s active "
+ "%slogical volume %s? [y/n]: ",
+ ask_discard ? " and DISCARD" : "",
+ vg_is_clustered(vg) ? "clustered " : "",
+ display_lvname(lv)) == 'n') {
+ log_error("Logical volume %s not removed.", display_lvname(lv));
+ return 0;
+ }
+ ask_discard = 0;
}
-
- ask_discard = 0;
+ break;
+ default: /* Not active */ ;
}
}
3 years, 1 month
main - deactivation: reduce ioctl count
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=dceef4709d7ee5d06fb...
Commit: dceef4709d7ee5d06fb61120cc15fc29feb3e6b8
Parent: 936c7b5104e4fb6fb489845b87d9ba2cd1a69d0a
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Sun Mar 7 01:54:50 2021 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Mon Mar 8 15:30:18 2021 +0100
deactivation: reduce ioctl count
When LV is deactivativate, we check for presence, and later
for some LV types also for being in use.
We can however do this check in 1 step for them a remove extra ioctl.
Add return value '2' to lv_check_not_in_use() to recognize LV is not
present.
Existing users were just testing for 0, so no change for them.
---
lib/activate/activate.c | 70 ++++++++++++++++++++++++++-----------------------
1 file changed, 37 insertions(+), 33 deletions(-)
diff --git a/lib/activate/activate.c b/lib/activate/activate.c
index 75248aa63..a56227118 100644
--- a/lib/activate/activate.c
+++ b/lib/activate/activate.c
@@ -828,13 +828,14 @@ int lv_info_with_seg_status(struct cmd_context *cmd,
#define OPEN_COUNT_CHECK_USLEEP_DELAY 200000
/* Only report error if error_if_used is set */
+/* Returns 0 if in use, 1 if it is unused, 2 when it is not present in table */
int lv_check_not_in_use(const struct logical_volume *lv, int error_if_used)
{
struct lvinfo info;
unsigned int open_count_check_retries;
if (!lv_info(lv->vg->cmd, lv, 0, &info, 1, 0) || !info.exists || !info.open_count)
- return 1;
+ return !info.exists ? 2 : 1;
/* If sysfs is not used, use open_count information only. */
if (dm_sysfs_dir()) {
@@ -2408,44 +2409,47 @@ int lv_deactivate(struct cmd_context *cmd, const char *lvid_s, const struct logi
log_debug_activation("Deactivating %s.", display_lvname(lv));
- if (!lv_info(cmd, lv, 0, &info, 0, 0))
- goto_out;
-
- if (!info.exists) {
- r = 1;
- /* Check attached snapshot segments are also inactive */
- dm_list_iterate(snh, &lv->snapshot_segs) {
- if (!lv_info(cmd, dm_list_struct_base(snh, struct lv_segment, origin_list)->cow,
- 0, &info, 0, 0))
- goto_out;
- if (info.exists) {
- r = 0; /* Snapshot left in table? */
- break;
- }
+ if (lv_is_visible(lv) || lv_is_virtual_origin(lv) ||
+ lv_is_merging_thin_snapshot(lv)) {
+ switch (lv_check_not_in_use(lv, 1)) {
+ case 0: goto_out;
+ case 2: goto no_exists;
}
- if (lv_is_vdo_pool(lv)) {
- /* If someone has remove 'linear' mapping over VDO device
- * we may still be able to deactivate the rest of the tree
- * i.e. in test-suite we simulate this via 'dmsetup remove' */
- if (!lv_info(cmd, lv, 1, &info, 1, 0))
- goto_out;
+ if (lv_is_origin(lv) && _lv_has_open_snapshots(lv))
+ goto_out;
+ } else {
+ if (!lv_info(cmd, lv, 0, &info, 0, 0))
+ goto_out;
- if (info.exists && !info.open_count)
- r = 0; /* Unused VDO device left in table? */
- }
+ if (!info.exists) {
+ no_exists:
+ r = 1;
+ /* Check attached snapshot segments are also inactive */
+ dm_list_iterate(snh, &lv->snapshot_segs) {
+ if (!lv_info(cmd, dm_list_struct_base(snh, struct lv_segment, origin_list)->cow,
+ 0, &info, 0, 0))
+ goto_out;
+ if (info.exists) {
+ r = 0; /* Snapshot left in table? */
+ break;
+ }
+ }
- if (r)
- goto out;
- }
+ if (lv_is_vdo_pool(lv)) {
+ /* If someone has remove 'linear' mapping over VDO device
+ * we may still be able to deactivate the rest of the tree
+ * i.e. in test-suite we simulate this via 'dmsetup remove' */
+ if (!lv_info(cmd, lv, 1, &info, 1, 0))
+ goto_out;
- if (lv_is_visible(lv) || lv_is_virtual_origin(lv) ||
- lv_is_merging_thin_snapshot(lv)) {
- if (!lv_check_not_in_use(lv, 1))
- goto_out;
+ if (info.exists && !info.open_count)
+ r = 0; /* Unused VDO device left in table? */
+ }
- if (lv_is_origin(lv) && _lv_has_open_snapshots(lv))
- goto_out;
+ if (r)
+ goto out;
+ }
}
if (!monitor_dev_for_events(cmd, lv, &laopts, 0))
3 years, 1 month
main - vg_read: reuse already parsed config tree
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=936c7b5104e4fb6fb48...
Commit: 936c7b5104e4fb6fb489845b87d9ba2cd1a69d0a
Parent: bc0cb663043bb9c67151f88061ff22c53c6883ea
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Fri Mar 5 23:04:44 2021 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Mon Mar 8 15:30:18 2021 +0100
vg_read: reuse already parsed config tree
When parsing VG metadata we can create from a single config tree
also 'vg_committed' that is always created for writable VG.
This avoids extra uncessary step of serializing and deserilizing
just parsed VG.
---
lib/format_text/import.c | 5 ++++-
lib/metadata/metadata.c | 10 ++++------
lib/metadata/vg.c | 2 ++
lib/metadata/vg.h | 4 ++--
4 files changed, 12 insertions(+), 9 deletions(-)
diff --git a/lib/format_text/import.c b/lib/format_text/import.c
index 2dc80f13f..2687d172e 100644
--- a/lib/format_text/import.c
+++ b/lib/format_text/import.c
@@ -186,6 +186,8 @@ struct volume_group *text_read_metadata(struct format_instance *fid,
goto_out;
(*vsn)->read_desc(vg->vgmem, cft, when, desc);
+ vg->committed_cft = cft; /* Reuse CFT for recreation of committed VG */
+ cft = NULL;
break;
}
@@ -198,7 +200,8 @@ struct volume_group *text_read_metadata(struct format_instance *fid,
*use_previous_vg = 0;
out:
- config_destroy(cft);
+ if (cft)
+ config_destroy(cft);
return vg;
}
diff --git a/lib/metadata/metadata.c b/lib/metadata/metadata.c
index daf49827f..5410eac60 100644
--- a/lib/metadata/metadata.c
+++ b/lib/metadata/metadata.c
@@ -5186,8 +5186,6 @@ struct volume_group *vg_read(struct cmd_context *cmd, const char *vg_name, const
* FIXME: be specific about exactly when this works correctly.
*/
if (writing) {
- struct dm_config_tree *cft;
-
if (dm_pool_locked(vg->vgmem)) {
/* FIXME: can this happen? */
log_warn("WARNING: vg_read no vg copy: pool locked.");
@@ -5208,15 +5206,15 @@ struct volume_group *vg_read(struct cmd_context *cmd, const char *vg_name, const
vg->vg_precommitted = NULL;
}
- if (!(cft = export_vg_to_config_tree(vg))) {
+ if (!vg->committed_cft) {
log_warn("WARNING: vg_read no vg copy: copy export failed.");
- goto out;
+ if (!(vg->committed_cft = export_vg_to_config_tree(vg)))
+ goto out;
}
- if (!(vg->vg_committed = import_vg_from_config_tree(cmd, vg->fid, cft)))
+ if (!(vg->vg_committed = import_vg_from_config_tree(cmd, vg->fid, vg->committed_cft)))
log_warn("WARNING: vg_read no vg copy: copy import failed.");
- dm_config_destroy(cft);
} else {
if (vg->vg_precommitted)
log_error(INTERNAL_ERROR "vg_read vg %p vg_precommitted %p", (void *)vg, (void *)vg->vg_precommitted);
diff --git a/lib/metadata/vg.c b/lib/metadata/vg.c
index 9a8693c0b..e659579c2 100644
--- a/lib/metadata/vg.c
+++ b/lib/metadata/vg.c
@@ -79,6 +79,8 @@ static void _free_vg(struct volume_group *vg)
log_debug_mem("Freeing VG %s at %p.", vg->name ? : "<no name>", (void *)vg);
+ if (vg->committed_cft)
+ config_destroy(vg->committed_cft);
dm_hash_destroy(vg->hostnames);
dm_pool_destroy(vg->vgmem);
}
diff --git a/lib/metadata/vg.h b/lib/metadata/vg.h
index fa1b03621..36d1ed155 100644
--- a/lib/metadata/vg.h
+++ b/lib/metadata/vg.h
@@ -50,9 +50,9 @@ struct volume_group {
* The parsed committed (on-disk) copy of this VG; is NULL if this VG is committed
* version (i.e. vg_committed == NULL *implies* this is the committed copy,
* there is no guarantee that if this VG is the same as the committed one
- * this will be NULL). The pointer is maintained by calls to
- * _vg_update_vg_committed.
+ * this will be NULL). The pointer is maintained by calls to vg_write & vg_commit
*/
+ struct dm_config_tree *committed_cft;
struct volume_group *vg_committed;
struct volume_group *vg_precommitted;
3 years, 1 month
main - vg_write: optimize caching of precommitted VG
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=bc0cb663043bb9c6715...
Commit: bc0cb663043bb9c67151f88061ff22c53c6883ea
Parent: a125a3bb505cc2f0374715f850f4c1e02c7d4e3c
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Fri Mar 5 22:12:58 2021 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Mon Mar 8 15:30:18 2021 +0100
vg_write: optimize caching of precommitted VG
Every vg_write stores new 'metadata' into precommitted slot.
For this step we use 'serialized buffer' to ascii metadata.
Instead of recreating this buffer after whole 'vg_write()' we
use this buffer instantly for creating of precommitted VG.
This has also the advantage of catching any problems with
reparsing of ascii metadata back to VG early before any write.
---
lib/format_text/format-text.c | 17 +++++++++++++++++
lib/metadata/metadata.c | 29 -----------------------------
2 files changed, 17 insertions(+), 29 deletions(-)
diff --git a/lib/format_text/format-text.c b/lib/format_text/format-text.c
index e8533d5dc..bf1b9b3a4 100644
--- a/lib/format_text/format-text.c
+++ b/lib/format_text/format-text.c
@@ -28,6 +28,7 @@
#include "lib/mm/xlate.h"
#include "lib/label/label.h"
#include "lib/cache/lvmcache.h"
+#include "libdaemon/client/config-util.h"
#include <unistd.h>
#include <limits.h>
@@ -579,6 +580,7 @@ static int _vg_write_raw(struct format_instance *fid, struct volume_group *vg,
struct metadata_area *mda)
{
char desc[2048];
+ struct dm_config_tree *cft;
struct mda_context *mdac = (struct mda_context *) mda->metadata_locn;
struct text_fid_context *fidtc = (struct text_fid_context *) fid->private;
struct raw_locn *rlocn_old;
@@ -662,6 +664,21 @@ static int _vg_write_raw(struct format_instance *fid, struct volume_group *vg,
fidtc->write_buf = write_buf;
fidtc->write_buf_size = write_buf_size;
fidtc->new_metadata_size = new_size;
+
+ /* Immediatelly reuse existing buffer for parsing metadata back.
+ * Such VG is then used for as precommitted VG and later committed VG.
+ *
+ * 'Lazy' creation of such VG might improve performance, but we
+ * lose important validation that written metadata can be parsed. */
+ if (!(cft = config_tree_from_string_without_dup_node_check(write_buf))) {
+ log_error("Error parsing metadata for VG %s.", vg->name);
+ goto out;
+ }
+ release_vg(vg->vg_precommitted);
+ vg->vg_precommitted = import_vg_from_config_tree(vg->cmd, vg->fid, cft);
+ dm_config_destroy(cft);
+ if (!vg->vg_precommitted)
+ goto_out;
}
if (!new_size || !write_buf) {
diff --git a/lib/metadata/metadata.c b/lib/metadata/metadata.c
index 2915c1d07..daf49827f 100644
--- a/lib/metadata/metadata.c
+++ b/lib/metadata/metadata.c
@@ -996,32 +996,6 @@ static void _vg_move_cached_precommitted_to_committed(struct volume_group *vg)
vg->vg_precommitted = NULL;
}
-/*
- * Update content of precommitted VG
- *
- * TODO: Optimize in the future, since lvmetad needs similar
- * config tree processing in lvmetad_vg_update().
- */
-static int _vg_update_embedded_copy(struct volume_group *vg, struct volume_group **vg_embedded)
-{
- struct dm_config_tree *cft;
-
- _vg_wipe_cached_precommitted(vg);
-
- /* Copy the VG using an export followed by import */
- if (!(cft = export_vg_to_config_tree(vg)))
- return_0;
-
- if (!(*vg_embedded = import_vg_from_config_tree(vg->cmd, vg->fid, cft))) {
- dm_config_destroy(cft);
- return_0;
- }
-
- dm_config_destroy(cft);
-
- return 1;
-}
-
int lv_has_unknown_segments(const struct logical_volume *lv)
{
struct lv_segment *seg;
@@ -3121,9 +3095,6 @@ int vg_write(struct volume_group *vg)
}
}
- if (!_vg_update_embedded_copy(vg, &vg->vg_precommitted)) /* prepare precommited */
- return_0;
-
lockd_vg_update(vg);
return 1;
3 years, 1 month
main - lv_remove: reduce commits for removed LVs
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=a125a3bb505cc2f0374...
Commit: a125a3bb505cc2f0374715f850f4c1e02c7d4e3c
Parent: ee9488488f1b97e7e3257e6490188d7ad5afafe0
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Fri Mar 5 16:21:50 2021 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Mon Mar 8 15:25:05 2021 +0100
lv_remove: reduce commits for removed LVs
This patch postpones update of lvm metadata for each removed
LV for later moment depending on LV type.
It also queues messages to be printed after such write & commit.
As such there is some change in the behavior - although before
prompt we do make write&commit happens automatically in some
other error case we rather keep 'existing' state - so there
could be difference in amount of removed & commited LVs.
IMHO introduce logic is slightly better and more save.
But some cases still need the early commit - i.e. thin-removal
and fixing this needs some more thinking.
TODO: improve removal at least with the case of the whole thin-pool.
i.e. we can simply recognize removal of 'all LVs/whole VG'.
---
lib/metadata/lv_manip.c | 42 ++++++++++++++++++++++++++++++------------
lib/metadata/metadata.c | 9 +++++++++
lib/metadata/vg.c | 1 +
lib/metadata/vg.h | 2 ++
tools/toollib.c | 4 ++++
5 files changed, 46 insertions(+), 12 deletions(-)
diff --git a/lib/metadata/lv_manip.c b/lib/metadata/lv_manip.c
index 4ac95063c..b93f18e6e 100644
--- a/lib/metadata/lv_manip.c
+++ b/lib/metadata/lv_manip.c
@@ -6538,6 +6538,7 @@ int lv_remove_single(struct cmd_context *cmd, struct logical_volume *lv,
int ask_discard;
struct seg_list *sl;
struct lv_segment *seg = first_seg(lv);
+ char msg[NAME_LEN + 300], *msg_dup;
vg = lv->vg;
@@ -6609,6 +6610,8 @@ int lv_remove_single(struct cmd_context *cmd, struct logical_volume *lv,
if ((force == PROMPT) &&
!lv_is_pending_delete(lv) &&
lv_is_visible(lv)) {
+ if (vg->needs_write_and_commit && (!vg_write(vg) || !vg_commit(vg)))
+ return 0;
if (yes_no_prompt("Do you really want to remove%s active "
"%slogical volume %s? [y/n]: ",
ask_discard ? " and DISCARD" : "",
@@ -6644,12 +6647,16 @@ int lv_remove_single(struct cmd_context *cmd, struct logical_volume *lv,
}
}
- if (!lv_is_historical(lv) && (force == PROMPT) && ask_discard &&
- yes_no_prompt("Do you really want to remove and DISCARD "
- "logical volume %s? [y/n]: ",
- display_lvname(lv)) == 'n') {
- log_error("Logical volume %s not removed.", display_lvname(lv));
- return 0;
+ if (!lv_is_historical(lv) && (force == PROMPT) && ask_discard) {
+ /* try to store on disks already confirmed removals */
+ if (vg->needs_write_and_commit && (!vg_write(vg) || !vg_commit(vg)))
+ return 0;
+ if (yes_no_prompt("Do you really want to remove and DISCARD "
+ "logical volume %s? [y/n]: ",
+ display_lvname(lv)) == 'n') {
+ log_error("Logical volume %s not removed.", display_lvname(lv));
+ return 0;
+ }
}
if (lv_is_cache(lv) && !lv_is_pending_delete(lv)) {
@@ -6765,8 +6772,11 @@ int lv_remove_single(struct cmd_context *cmd, struct logical_volume *lv,
return 0;
}
- /* store it on disks */
- if (!vg_write(vg) || !vg_commit(vg))
+ if (!pool_lv && (!strcmp(cmd->name, "lvremove") || !strcmp(cmd->name, "vgremove"))) {
+ /* With lvremove & vgremove try to postpone commit after last such LV */
+ vg->needs_write_and_commit = 1;
+ log_debug_metadata("Postponing write and commit.");
+ } else if (!vg_write(vg) || !vg_commit(vg)) /* store it on disks */
return_0;
/* Release unneeded blocks in thin pool */
@@ -6785,10 +6795,18 @@ int lv_remove_single(struct cmd_context *cmd, struct logical_volume *lv,
lockd_lv(cmd, lock_lv, "un", LDLV_PERSISTENT);
lockd_free_lv(cmd, vg, lv->name, &lv->lvid.id[1], lv->lock_args);
- if (!suppress_remove_message && (visible || historical))
- log_print_unless_silent("%sogical volume \"%s\" successfully removed",
- historical ? "Historical l" : "L",
- historical ? lv->this_glv->historical->name : lv->name);
+ if (!suppress_remove_message && (visible || historical)) {
+ (void) dm_snprintf(msg, sizeof(msg),
+ "%sogical volume \"%s\" successfully removed",
+ historical ? "Historical l" : "L",
+ historical ? lv->this_glv->historical->name : lv->name);
+ if (!vg->needs_write_and_commit)
+ log_print_unless_silent("%s", msg);
+ /* Keep print message for later display with next vg_write() and vg_commit() */
+ else if (!(msg_dup = dm_pool_strdup(vg->vgmem, msg)) ||
+ !str_list_add_no_dup_check(vg->vgmem, &vg->msg_list, msg_dup))
+ return_0;
+ }
return 1;
}
diff --git a/lib/metadata/metadata.c b/lib/metadata/metadata.c
index 692094ec8..2915c1d07 100644
--- a/lib/metadata/metadata.c
+++ b/lib/metadata/metadata.c
@@ -3173,6 +3173,7 @@ static int _vg_commit_mdas(struct volume_group *vg)
int vg_commit(struct volume_group *vg)
{
struct pv_list *pvl;
+ struct dm_str_list *sl;
int ret;
ret = _vg_commit_mdas(vg);
@@ -3190,6 +3191,14 @@ int vg_commit(struct volume_group *vg)
/* This *is* the original now that it's commited. */
_vg_move_cached_precommitted_to_committed(vg);
+
+ if (vg->needs_write_and_commit){
+ /* Print buffered messages that have been finished with this commit. */
+ dm_list_iterate_items(sl, &vg->msg_list)
+ log_print_unless_silent("%s", sl->str);
+ dm_list_init(&vg->msg_list);
+ vg->needs_write_and_commit = 0;
+ }
}
/* If at least one mda commit succeeded, it was committed */
diff --git a/lib/metadata/vg.c b/lib/metadata/vg.c
index a809115f6..9a8693c0b 100644
--- a/lib/metadata/vg.c
+++ b/lib/metadata/vg.c
@@ -60,6 +60,7 @@ struct volume_group *alloc_vg(const char *pool_name, struct cmd_context *cmd,
dm_list_init(&vg->removed_lvs);
dm_list_init(&vg->removed_historical_lvs);
dm_list_init(&vg->removed_pvs);
+ dm_list_init(&vg->msg_list);
log_debug_mem("Allocated VG %s at %p.", vg->name ? : "<no name>", (void *)vg);
diff --git a/lib/metadata/vg.h b/lib/metadata/vg.h
index 386d5b450..fa1b03621 100644
--- a/lib/metadata/vg.h
+++ b/lib/metadata/vg.h
@@ -43,6 +43,7 @@ struct volume_group {
uint32_t seqno; /* Metadata sequence number */
unsigned skip_validate_lock_args : 1;
unsigned needs_backup : 1;
+ unsigned needs_write_and_commit : 1;
uint32_t write_count; /* count the number of vg_write calls */
/*
@@ -129,6 +130,7 @@ struct volume_group {
struct dm_hash_table *hostnames; /* map of creation hostnames */
struct logical_volume *pool_metadata_spare_lv; /* one per VG */
struct logical_volume *sanlock_lv; /* one per VG */
+ struct dm_list msg_list;
};
struct volume_group *alloc_vg(const char *pool_name, struct cmd_context *cmd,
diff --git a/tools/toollib.c b/tools/toollib.c
index 67422e3b4..41e722c5c 100644
--- a/tools/toollib.c
+++ b/tools/toollib.c
@@ -3216,6 +3216,10 @@ int process_each_lv_in_vg(struct cmd_context *cmd, struct volume_group *vg,
log_set_report_object_name_and_id(NULL, NULL);
}
+ if (vg->needs_write_and_commit && (ret_max == ECMD_PROCESSED) &&
+ (!vg_write(vg) || !vg_commit(vg)))
+ return_0;
+
if (vg->needs_backup)
backup(vg);
3 years, 1 month
main - makefiles: fix location of basedir
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=ee9488488f1b97e7e32...
Commit: ee9488488f1b97e7e3257e6490188d7ad5afafe0
Parent: 7df4a13282a32029ab51b01d0ace14c296c0e8e3
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Wed Mar 3 14:45:25 2021 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Mon Mar 8 15:22:27 2021 +0100
makefiles: fix location of basedir
---
daemons/lvmdbusd/Makefile.in | 15 ++++++++-------
1 file changed, 8 insertions(+), 7 deletions(-)
diff --git a/daemons/lvmdbusd/Makefile.in b/daemons/lvmdbusd/Makefile.in
index dee37122a..d9cf5d886 100644
--- a/daemons/lvmdbusd/Makefile.in
+++ b/daemons/lvmdbusd/Makefile.in
@@ -15,7 +15,8 @@ srcdir = @srcdir@
top_srcdir = @top_srcdir@
top_builddir = @top_builddir@
-lvmdbusdir = $(python3dir)/lvmdbusd
+lvmdbuspydir = $(python3dir)/lvmdbusd
+lvmdbusdir = $(DESTDIR)$(lvmdbuspydir)
LVMDBUS_SRCDIR_FILES = \
automatedproperties.py \
@@ -57,12 +58,12 @@ install_lvmdbusd: $(LVMDBUSD)
@echo " [INSTALL] $<"
$(Q) $(INSTALL_DIR) $(sbindir)
$(Q) $(INSTALL_SCRIPT) $(LVMDBUSD) $(sbindir)
- $(Q) $(INSTALL_DIR) $(DESTDIR)$(lvmdbusdir)
- $(Q) (cd $(srcdir); $(INSTALL_DATA) $(LVMDBUS_SRCDIR_FILES) $(DESTDIR)$(lvmdbusdir))
- $(Q) $(INSTALL_DATA) $(LVMDBUS_BUILDDIR_FILES) $(DESTDIR)$(lvmdbusdir)
- $(Q) PYTHON=$(PYTHON3) $(PYCOMPILE) --destdir "$(DESTDIR)" --basedir "$(lvmdbusdir)" $(LVMDBUS_SRCDIR_FILES) $(LVMDBUS_BUILDDIR_FILES)
- $(Q) $(CHMOD) 755 $(DESTDIR)$(lvmdbusdir)/__pycache__
- $(Q) $(CHMOD) 444 $(DESTDIR)$(lvmdbusdir)/__pycache__/*.py[co]
+ $(Q) $(INSTALL_DIR) $(lvmdbusdir)
+ $(Q) (cd $(srcdir); $(INSTALL_DATA) $(LVMDBUS_SRCDIR_FILES) $(lvmdbusdir))
+ $(Q) $(INSTALL_DATA) $(LVMDBUS_BUILDDIR_FILES) $(lvmdbusdir)
+ $(Q) PYTHON=$(PYTHON3) $(PYCOMPILE) --destdir "$(DESTDIR)" --basedir "$(lvmdbuspydir)" $(LVMDBUS_SRCDIR_FILES) $(LVMDBUS_BUILDDIR_FILES)
+ $(Q) $(CHMOD) 755 $(lvmdbusdir)/__pycache__
+ $(Q) $(CHMOD) 444 $(lvmdbusdir)/__pycache__/*.py[co]
install_lvm2: install_lvmdbusd
3 years, 1 month
main - makefiles: make rpm respect --disable-silent-rules
by Marian Csontos
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=7df4a13282a32029ab5...
Commit: 7df4a13282a32029ab51b01d0ace14c296c0e8e3
Parent: e10633394d64d5a1d2434fb0166689bbfb732bef
Author: Marian Csontos <mcsontos(a)redhat.com>
AuthorDate: Mon Mar 8 14:10:17 2021 +0100
Committer: Marian Csontos <mcsontos(a)redhat.com>
CommitterDate: Mon Mar 8 14:10:17 2021 +0100
makefiles: make rpm respect --disable-silent-rules
---
Makefile.in | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/Makefile.in b/Makefile.in
index 6bc3a9414..c0915fac7 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -121,7 +121,7 @@ rpm: dist
-e "s,^\(Version:[^0-9%]*\)[0-9.]*$$,\1 $(LVM_VER)," \
-e "s,^\(Release:[^0-9%]*\)[0-9.]\+,\1 $$GIT_VER," \
$(top_srcdir)/spec/source.inc >$(rpmbuilddir)/SOURCES/source.inc
- rpmbuild -v --define "_topdir $(rpmbuilddir)" -ba $(top_srcdir)/spec/lvm2.spec
+ V=$(V) rpmbuild -v --define "_topdir $(rpmbuilddir)" -ba $(top_srcdir)/spec/lvm2.spec
generate: conf.generate man.generate
$(MAKE) -C conf generate
3 years, 1 month
main - makefiles: Revert most of 456b659
by Marian Csontos
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=e10633394d64d5a1d24...
Commit: e10633394d64d5a1d2434fb0166689bbfb732bef
Parent: 2244a56021475179b8cc3633c8cb6534eaa18025
Author: Marian Csontos <mcsontos(a)redhat.com>
AuthorDate: Mon Mar 8 13:59:26 2021 +0100
Committer: Marian Csontos <mcsontos(a)redhat.com>
CommitterDate: Mon Mar 8 13:59:26 2021 +0100
makefiles: Revert most of 456b659
Must not use DESTDIR with --basedir.
Reverts: 456b659b4edfc758b5aa0b72af25677a4f5042ea
---
daemons/lvmdbusd/Makefile.in | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/daemons/lvmdbusd/Makefile.in b/daemons/lvmdbusd/Makefile.in
index 56d5c6602..dee37122a 100644
--- a/daemons/lvmdbusd/Makefile.in
+++ b/daemons/lvmdbusd/Makefile.in
@@ -15,7 +15,7 @@ srcdir = @srcdir@
top_srcdir = @top_srcdir@
top_builddir = @top_builddir@
-lvmdbusdir = $(DESTDIR)$(python3dir)/lvmdbusd
+lvmdbusdir = $(python3dir)/lvmdbusd
LVMDBUS_SRCDIR_FILES = \
automatedproperties.py \
@@ -57,12 +57,12 @@ install_lvmdbusd: $(LVMDBUSD)
@echo " [INSTALL] $<"
$(Q) $(INSTALL_DIR) $(sbindir)
$(Q) $(INSTALL_SCRIPT) $(LVMDBUSD) $(sbindir)
- $(Q) $(INSTALL_DIR) $(lvmdbusdir)
- $(Q) (cd $(srcdir); $(INSTALL_DATA) $(LVMDBUS_SRCDIR_FILES) $(lvmdbusdir))
- $(Q) $(INSTALL_DATA) $(LVMDBUS_BUILDDIR_FILES) $(lvmdbusdir)
+ $(Q) $(INSTALL_DIR) $(DESTDIR)$(lvmdbusdir)
+ $(Q) (cd $(srcdir); $(INSTALL_DATA) $(LVMDBUS_SRCDIR_FILES) $(DESTDIR)$(lvmdbusdir))
+ $(Q) $(INSTALL_DATA) $(LVMDBUS_BUILDDIR_FILES) $(DESTDIR)$(lvmdbusdir)
$(Q) PYTHON=$(PYTHON3) $(PYCOMPILE) --destdir "$(DESTDIR)" --basedir "$(lvmdbusdir)" $(LVMDBUS_SRCDIR_FILES) $(LVMDBUS_BUILDDIR_FILES)
- $(Q) $(CHMOD) 755 $(lvmdbusdir)/__pycache__
- $(Q) $(CHMOD) 444 $(lvmdbusdir)/__pycache__/*.py[co]
+ $(Q) $(CHMOD) 755 $(DESTDIR)$(lvmdbusdir)/__pycache__
+ $(Q) $(CHMOD) 444 $(DESTDIR)$(lvmdbusdir)/__pycache__/*.py[co]
install_lvm2: install_lvmdbusd
3 years, 1 month
main - make: generate
by Marian Csontos
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=2244a56021475179b8c...
Commit: 2244a56021475179b8cc3633c8cb6534eaa18025
Parent: 3bea8937334ab9a7852947a30862d6e457f093b6
Author: Marian Csontos <mcsontos(a)redhat.com>
AuthorDate: Fri Mar 5 12:53:35 2021 +0100
Committer: Marian Csontos <mcsontos(a)redhat.com>
CommitterDate: Fri Mar 5 12:53:35 2021 +0100
make: generate
---
conf/example.conf.in | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/conf/example.conf.in b/conf/example.conf.in
index 8ac376303..204ec82d1 100644
--- a/conf/example.conf.in
+++ b/conf/example.conf.in
@@ -1122,6 +1122,17 @@ global {
# This configuration option has an automatic default value.
# sanlock_lv_extend = 256
+ # Configuration option global/lvmlockctl_kill_command.
+ # The command that lvmlockctl --kill should use to force LVs offline.
+ # The lvmlockctl --kill command is run when a shared VG has lost
+ # access to locks (e.g. when sanlock has lost access to storage.)
+ # An empty string means that there will be no automatic attempt by
+ # lvmlockctl --kill to forcibly shut down LVs in the VG, and the user
+ # can manually intervene as described in lvmlockd(8).
+ # The VG name will be appended to the command specified here.
+ # This configuration option has an automatic default value.
+ # lvmlockctl_kill_command = ""
+
# Configuration option global/thin_check_executable.
# The full path to the thin_check command.
# LVM uses this command to check that a thin metadata device is in a
3 years, 1 month