master - libdm: dm_tree_node_size_changed recognizes reduction
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=9ef820a2a5e174...
Commit: 9ef820a2a5e174cd08097981d7879e1f4cbded01
Parent: 40eea582aea512db7fceafd8559bf66df0733b55
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Sun Oct 25 19:27:09 2015 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Sun Oct 25 21:05:15 2015 +0100
libdm: dm_tree_node_size_changed recognizes reduction
Add more functionality to size_changed function.
While 'existing' API only detected 0 for
unchanged, and !0 for changed,
new improved API will also detected if the
size has only went bigger - or there was
size reduction.
Function work for the whole dm-tree - so
no change is size is always 0.
only size extension 1.
and if some size reduction is there - returns -1.
This result can be used for better evaluation
whether we need to flush before suspend.
---
WHATS_NEW_DM | 1 +
libdm/.exported_symbols.Base | 1 -
libdm/.exported_symbols.DM_1_02_110 | 1 +
libdm/libdevmapper.h | 5 +++++
libdm/libdm-deptree.c | 25 ++++++++++++++++++++++---
5 files changed, 29 insertions(+), 4 deletions(-)
diff --git a/WHATS_NEW_DM b/WHATS_NEW_DM
index 910f6d6..e09ab63 100644
--- a/WHATS_NEW_DM
+++ b/WHATS_NEW_DM
@@ -1,5 +1,6 @@
Version 1.02.110 -
======================================
+ Enhance dm_tree_node_size_changed() to recognize size reduction.
Support exit on idle for dmenventd (1 hour).
Add support to allow unmonitor device from plugin itself.
New design for thread co-operation in dmeventd.
diff --git a/libdm/.exported_symbols.Base b/libdm/.exported_symbols.Base
index f9c3cb1..27fef53 100644
--- a/libdm/.exported_symbols.Base
+++ b/libdm/.exported_symbols.Base
@@ -262,7 +262,6 @@ dm_tree_node_set_thin_external_origin
dm_tree_node_set_thin_pool_discard
dm_tree_node_set_thin_pool_error_if_no_space
dm_tree_node_set_udev_flags
-dm_tree_node_size_changed
dm_tree_preload_children
dm_tree_retry_remove
dm_tree_set_cookie
diff --git a/libdm/.exported_symbols.DM_1_02_110 b/libdm/.exported_symbols.DM_1_02_110
index da742ee..eba5625 100644
--- a/libdm/.exported_symbols.DM_1_02_110
+++ b/libdm/.exported_symbols.DM_1_02_110
@@ -1,2 +1,3 @@
dm_report_compact_given_fields
dm_hold_control_dev
+dm_tree_node_size_changed
diff --git a/libdm/libdevmapper.h b/libdm/libdevmapper.h
index 08b24fe..f7ab257 100644
--- a/libdm/libdevmapper.h
+++ b/libdm/libdevmapper.h
@@ -1256,6 +1256,11 @@ const char *dm_tree_node_get_name(const struct dm_tree_node *node);
const char *dm_tree_node_get_uuid(const struct dm_tree_node *node);
const struct dm_info *dm_tree_node_get_info(const struct dm_tree_node *node);
void *dm_tree_node_get_context(const struct dm_tree_node *node);
+/*
+ * Returns 0 when node size and its children is unchanged.
+ * Returns 1 when node or any of its children has increased size.
+ * Rerurns -1 when node or any of its children has reduced size.
+ */
int dm_tree_node_size_changed(const struct dm_tree_node *dnode);
/*
diff --git a/libdm/libdm-deptree.c b/libdm/libdm-deptree.c
index afdce8d..d7e2143 100644
--- a/libdm/libdm-deptree.c
+++ b/libdm/libdm-deptree.c
@@ -220,7 +220,7 @@ struct load_properties {
uint32_t read_ahead_flags;
unsigned segment_count;
- unsigned size_changed;
+ int size_changed;
struct dm_list segs;
const char *new_name;
@@ -2729,7 +2729,8 @@ static int _load_node(struct dm_tree_node *dnode)
existing_table_size = dm_task_get_existing_table_size(dmt);
if ((dnode->props.size_changed =
- (existing_table_size == seg_start) ? 0 : 1)) {
+ (existing_table_size == seg_start) ? 0 :
+ (existing_table_size > seg_start) ? -1 : 1)) {
/*
* Kernel usually skips size validation on zero-length devices
* now so no need to preload them.
@@ -2825,8 +2826,10 @@ int dm_tree_preload_children(struct dm_tree_node *dnode,
}
/* Propagate device size change change */
- if (child->props.size_changed)
+ if (child->props.size_changed > 0 && !dnode->props.size_changed)
dnode->props.size_changed = 1;
+ else if (child->props.size_changed < 0)
+ dnode->props.size_changed = -1;
/* Resume device immediately if it has parents and its size changed */
if (!dm_tree_node_num_children(child, 1) || !child->props.size_changed)
@@ -3853,3 +3856,19 @@ void dm_tree_node_set_callback(struct dm_tree_node *dnode,
dnode->callback = cb;
dnode->callback_data = data;
}
+
+/*
+ * Backward compatible dm_tree_node_size_changed() implementations.
+ *
+ * Keep these at the end of the file to avoid adding clutter around the
+ * current dm_tree_node_size_changed() version.
+ */
+#if defined(__GNUC__)
+int dm_tree_node_size_changed_base(const struct dm_tree_node *dnode);
+DM_EXPORT_SYMBOL_BASE(dm_tree_node_size_changed);
+int dm_tree_node_size_changed_base(const struct dm_tree_node *dnode)
+{
+ /* Base does not make difference between smaller and bigger */
+ return dm_tree_node_size_changed(dnode) ? 1 : 0;
+}
+#endif
8 years, 6 months
master - lv_manip: ensure it will fit bellow threshold
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=40eea582aea512...
Commit: 40eea582aea512db7fceafd8559bf66df0733b55
Parent: b780d329aa9ce249bf5164154c81cefd9b276970
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Sun Oct 25 19:19:39 2015 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Sun Oct 25 21:03:11 2015 +0100
lv_manip: ensure it will fit bellow threshold
Use single code to evaluate if the percentage value has
crossed threshold.
Recalculate amount value to always fit bellow
threshold so there are not need any extra reiterations
to reach this state in case policy amount is too small.
---
WHATS_NEW | 1 +
lib/metadata/lv_manip.c | 37 +++++++++++++++++++++++++------------
2 files changed, 26 insertions(+), 12 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index 0495e46..8ca0aa7 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.133 -
======================================
+ Ensure --use-policy will resize volume to fit below threshold.
Correct percentage evaluation when checking thin-pool over threshold.
Fix lvmcache to move PV from VG to orphans if VG is removed and lvmetad used.
Fix lvmcache to not cache even invalid info about PV which got removed.
diff --git a/lib/metadata/lv_manip.c b/lib/metadata/lv_manip.c
index 19032e9..8029dab 100644
--- a/lib/metadata/lv_manip.c
+++ b/lib/metadata/lv_manip.c
@@ -4424,6 +4424,25 @@ static int _fsadm_cmd(struct cmd_context *cmd,
return exec_cmd(cmd, argv, status, 1);
}
+static int _adjust_amount(dm_percent_t percent, int policy_threshold, int *policy_amount)
+{
+ if (!(DM_PERCENT_0 < percent && percent <= DM_PERCENT_100) ||
+ percent <= (policy_threshold * DM_PERCENT_1))
+ return 0;
+ /*
+ * Evaluate the minimal amount needed to get bellow threshold.
+ * Keep using DM_PERCENT_1 units for better precision.
+ * Round-up to needed percentage value
+ */
+ percent = (percent/policy_threshold + (DM_PERCENT_1 - 1) / 100) / (DM_PERCENT_1 / 100) - 100;
+
+ /* Use it if current policy amount is smaller */
+ if (*policy_amount < percent)
+ *policy_amount = percent;
+
+ return 1;
+}
+
static int _adjust_policy_params(struct cmd_context *cmd,
struct logical_volume *lv, struct lvresize_params *lp)
{
@@ -4469,35 +4488,29 @@ static int _adjust_policy_params(struct cmd_context *cmd,
return 0;
}
- policy_threshold *= DM_PERCENT_1;
-
if (lv_is_thin_pool(lv)) {
if (!lv_thin_pool_percent(lv, 1, &percent))
return_0;
- if ((DM_PERCENT_0 < percent && percent <= DM_PERCENT_100) &&
- (percent > policy_threshold)) {
+ if (_adjust_amount(percent, policy_threshold, &policy_amount)) {
if (!thin_pool_feature_supported(lv, THIN_FEATURE_METADATA_RESIZE)) {
- log_error_once("Online metadata resize for %s/%s is not supported.",
- lv->vg->name, lv->name);
+ log_error_once("Online metadata resize for %s is not supported.",
+ display_lvname(lv));
return 0;
}
lp->poolmetadatasize = (first_seg(lv)->metadata_lv->size *
policy_amount + 99) / 100;
lp->poolmetadatasign = SIGN_PLUS;
}
-
if (!lv_thin_pool_percent(lv, 0, &percent))
return_0;
- if (!(DM_PERCENT_0 < percent && percent <= DM_PERCENT_100) ||
- percent <= policy_threshold)
- return 1;
} else {
if (!lv_snapshot_percent(lv, &percent))
return_0;
- if (!(DM_PERCENT_0 < percent && percent <= DM_PERCENT_100) || percent <= policy_threshold)
- return 1; /* nothing to do */
}
+ if (!_adjust_amount(percent, policy_threshold, &policy_amount))
+ return 1; /* nothing to do */
+
lp->extents = policy_amount;
lp->sizeargs = (lp->extents) ? 1 : 0;
8 years, 6 months
master - thin: fix percentage compare
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=b780d329aa9ce2...
Commit: b780d329aa9ce249bf5164154c81cefd9b276970
Parent: 8f269697d21035035ffb4954f31bd702a6dd7ca8
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Sun Oct 25 19:13:53 2015 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Sun Oct 25 21:01:54 2015 +0100
thin: fix percentage compare
Since plugin's percentage compare has been fixed,
it's now revealed wrong compare here.
The logic for threshold is - to allow to go as high
as given value e.g. 80% - so if pool is exactlu 80%
full it's still allowed to use it (dmeventd will not
resize it).
---
WHATS_NEW | 1 +
lib/metadata/thin_manip.c | 4 ++--
2 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index 5911c64..0495e46 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.133 -
======================================
+ Correct percentage evaluation when checking thin-pool over threshold.
Fix lvmcache to move PV from VG to orphans if VG is removed and lvmetad used.
Fix lvmcache to not cache even invalid info about PV which got removed.
Support checking of memlock daemon counter.
diff --git a/lib/metadata/thin_manip.c b/lib/metadata/thin_manip.c
index 37bf4cb..6b22ce5 100644
--- a/lib/metadata/thin_manip.c
+++ b/lib/metadata/thin_manip.c
@@ -224,7 +224,7 @@ int pool_below_threshold(const struct lv_segment *pool_seg)
if (!lv_thin_pool_percent(pool_seg->lv, 0, &percent))
return_0;
- if (percent >= threshold) {
+ if (percent > threshold) {
log_debug("Threshold configured for free data space in "
"thin pool %s has been reached (%.2f%% >= %.2f%%).",
display_lvname(pool_seg->lv),
@@ -237,7 +237,7 @@ int pool_below_threshold(const struct lv_segment *pool_seg)
if (!lv_thin_pool_percent(pool_seg->lv, 1, &percent))
return_0;
- if (percent >= threshold) {
+ if (percent > threshold) {
log_debug("Threshold configured for free metadata space in "
"thin pool %s has been reached (%.2f%% > %.2f%%).",
display_lvname(pool_seg->lv),
8 years, 6 months
master - vg_read: remove unused inconsistent check
by David Teigland
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=8f269697d21035...
Commit: 8f269697d21035035ffb4954f31bd702a6dd7ca8
Parent: 98d81a43ea31ec963a36b8610f3b5a9be28b4cc1
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Fri Oct 23 12:19:11 2015 -0500
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Fri Oct 23 12:19:11 2015 -0500
vg_read: remove unused inconsistent check
Commit 1a74171ca5682a684d0e05c6090c3d33cab8795b added
a check to ignore a VG that was FAILED_INCONSISTENT
if the command doesn't care if the VG is not found.
Remove that check because that case is never reached
by the current code.
---
tools/toollib.c | 6 ------
1 files changed, 0 insertions(+), 6 deletions(-)
diff --git a/tools/toollib.c b/tools/toollib.c
index 39bf0ac..fba075a 100644
--- a/tools/toollib.c
+++ b/tools/toollib.c
@@ -195,12 +195,6 @@ static int _ignore_vg(struct volume_group *vg, const char *vg_name,
return 0;
}
- if ((read_error & FAILED_INCONSISTENT) && (read_flags & READ_OK_NOTFOUND)) {
- read_error &= ~FAILED_INCONSISTENT;
- *skip = 1;
- return 0;
- }
-
if ((read_error & FAILED_INCONSISTENT) && (read_flags & READ_ALLOW_INCONSISTENT))
read_error &= ~FAILED_INCONSISTENT; /* Check for other errors */
8 years, 6 months
master - vgextend: fix use of the wrong flag
by David Teigland
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=98d81a43ea31ec...
Commit: 98d81a43ea31ec963a36b8610f3b5a9be28b4cc1
Parent: 1a74171ca5682a684d0e05c6090c3d33cab8795b
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Fri Oct 23 10:21:06 2015 -0500
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Fri Oct 23 10:21:06 2015 -0500
vgextend: fix use of the wrong flag
The ONE_VGNAME_ARG was being passed and tested as
vg_read() flag but it's a cmd struct flag.
(It affects command arg processing in toollib,
not vg_read behavior. Flags related to command
processing are generally cmd struct flags, while
vg_read arg flags are generally related to vg_read
behavior.)
---
tools/commands.h | 2 +-
tools/toollib.c | 2 +-
tools/vgextend.c | 2 +-
3 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/tools/commands.h b/tools/commands.h
index 92d13fd..ae5dff7 100644
--- a/tools/commands.h
+++ b/tools/commands.h
@@ -1211,7 +1211,7 @@ xx(vgexport,
xx(vgextend,
"Add physical volumes to a volume group",
- 0,
+ ONE_VGNAME_ARG,
"vgextend\n"
"\t[-A|--autobackup y|n]\n"
"\t[--restoremissing]\n"
diff --git a/tools/toollib.c b/tools/toollib.c
index b17fe53..39bf0ac 100644
--- a/tools/toollib.c
+++ b/tools/toollib.c
@@ -2032,7 +2032,7 @@ int process_each_vg(struct cmd_context *cmd, int argc, char **argv,
struct dm_list vgnameids_to_process; /* vgnameid_list */
int enable_all_vgs = (cmd->command->flags & ALL_VGS_IS_DEFAULT);
- unsigned one_vgname_arg = (flags & ONE_VGNAME_ARG);
+ int one_vgname_arg = (cmd->command->flags & ONE_VGNAME_ARG);
int ret;
/* Disable error in vg_read so we can print it from ignore_vg. */
diff --git a/tools/vgextend.c b/tools/vgextend.c
index 581c211..bddc22f 100644
--- a/tools/vgextend.c
+++ b/tools/vgextend.c
@@ -170,7 +170,7 @@ int vgextend(struct cmd_context *cmd, int argc, char **argv)
return_ECMD_FAILED;
ret = process_each_vg(cmd, argc, argv,
- READ_FOR_UPDATE | ONE_VGNAME_ARG, handle,
+ READ_FOR_UPDATE, handle,
restoremissing ? &_vgextend_restoremissing : &_vgextend_single);
destroy_processing_handle(cmd, handle);
8 years, 6 months
master - vg_read: sometimes ignore read errors
by David Teigland
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=1a74171ca5682a...
Commit: 1a74171ca5682a684d0e05c6090c3d33cab8795b
Parent: 51735f09f79794d6609913b4c117f1a4a0e491fe
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Thu Oct 22 14:56:22 2015 -0500
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Fri Oct 23 10:12:34 2015 -0500
vg_read: sometimes ignore read errors
Running "vgremove -f VG & pvs" results in the pvs
command reporting that the VG is not found or is
inconsistent. If the VG is gone or being removed,
the pvs command should just skip it and not print
errors about it.
"Not found" is because the pvs command created the
list of VGs to process, including VG, then vgremove
removed the VG, then the pvs command came to to read
the VG to process it and did not find it.
An "inconsistent" error could be reported if vgremove
had only partially completed removing VG when pvs did
vg_read on the VG to process it, causing pvs to find
the VG in a partially-removed state.
This fix adds a flag that pvs uses to ignore a VG
that can't be read or is inconsistent.
---
lib/metadata/metadata-exported.h | 9 +++----
lib/metadata/metadata.c | 33 +++++++++++++++-------------
tools/toollib.c | 43 ++++++++++++++++++++++++++++++--------
3 files changed, 56 insertions(+), 29 deletions(-)
diff --git a/lib/metadata/metadata-exported.h b/lib/metadata/metadata-exported.h
index 25320fd..41838a8 100644
--- a/lib/metadata/metadata-exported.h
+++ b/lib/metadata/metadata-exported.h
@@ -163,10 +163,9 @@
/* vg_read and vg_read_for_update flags */
#define READ_ALLOW_INCONSISTENT 0x00010000U
#define READ_ALLOW_EXPORTED 0x00020000U
+#define READ_OK_NOTFOUND 0x00040000U
#define READ_WARN_INCONSISTENT 0x00080000U
-
-/* A meta-flag, useful with toollib for_each_* functions. */
-#define READ_FOR_UPDATE 0x00100000U
+#define READ_FOR_UPDATE 0x00100000U /* A meta-flag, useful with toollib for_each_* functions. */
/* vg's "read_status" field */
#define FAILED_INCONSISTENT 0x00000001U
@@ -650,9 +649,9 @@ int lv_resize(struct cmd_context *cmd, struct logical_volume *lv,
* Return a handle to VG metadata.
*/
struct volume_group *vg_read(struct cmd_context *cmd, const char *vg_name,
- const char *vgid, uint32_t flags, uint32_t lockd_state);
+ const char *vgid, uint32_t read_flags, uint32_t lockd_state);
struct volume_group *vg_read_for_update(struct cmd_context *cmd, const char *vg_name,
- const char *vgid, uint32_t flags, uint32_t lockd_state);
+ const char *vgid, uint32_t read_flags, uint32_t lockd_state);
/*
* Test validity of a VG handle.
diff --git a/lib/metadata/metadata.c b/lib/metadata/metadata.c
index 9bd42c9..1db8f58 100644
--- a/lib/metadata/metadata.c
+++ b/lib/metadata/metadata.c
@@ -4925,7 +4925,7 @@ static int _vg_access_permitted(struct cmd_context *cmd, struct volume_group *vg
* Consolidated locking, reading, and status flag checking.
*
* If the metadata is inconsistent, setting READ_ALLOW_INCONSISTENT in
- * misc_flags will return it with FAILED_INCONSISTENT set instead of
+ * read_flags will return it with FAILED_INCONSISTENT set instead of
* giving you nothing.
*
* Use vg_read_error(vg) to determine the result. Nonzero means there were
@@ -4933,8 +4933,10 @@ static int _vg_access_permitted(struct cmd_context *cmd, struct volume_group *vg
* Zero value means that the VG is open and appropriate locks are held.
*/
static struct volume_group *_vg_lock_and_read(struct cmd_context *cmd, const char *vg_name,
- const char *vgid, uint32_t lock_flags,
- uint64_t status_flags, uint32_t misc_flags,
+ const char *vgid,
+ uint32_t lock_flags,
+ uint64_t status_flags,
+ uint32_t read_flags,
uint32_t lockd_state)
{
struct volume_group *vg = NULL;
@@ -4944,7 +4946,7 @@ static struct volume_group *_vg_lock_and_read(struct cmd_context *cmd, const cha
uint32_t warn_flags = 0;
int already_locked;
- if (misc_flags & READ_ALLOW_INCONSISTENT || lock_flags != LCK_VG_WRITE)
+ if ((read_flags & READ_ALLOW_INCONSISTENT) || (lock_flags != LCK_VG_WRITE))
consistent = 0;
if (!validate_name(vg_name) && !is_orphan_vg(vg_name)) {
@@ -4967,7 +4969,7 @@ static struct volume_group *_vg_lock_and_read(struct cmd_context *cmd, const cha
consistent_in = consistent;
warn_flags = WARN_PV_READ;
- if (consistent || (misc_flags & READ_WARN_INCONSISTENT))
+ if (consistent || (read_flags & READ_WARN_INCONSISTENT))
warn_flags |= WARN_INCONSISTENT;
/* If consistent == 1, we get NULL here if correction fails. */
@@ -4976,7 +4978,8 @@ static struct volume_group *_vg_lock_and_read(struct cmd_context *cmd, const cha
failure |= FAILED_INCONSISTENT;
goto bad;
}
- log_error("Volume group \"%s\" not found", vg_name);
+ if (!(read_flags & READ_OK_NOTFOUND))
+ log_error("Volume group \"%s\" not found", vg_name);
failure |= FAILED_NOTFOUND;
goto bad;
}
@@ -5057,20 +5060,20 @@ bad_no_unlock:
* *consistent = 1.
*/
struct volume_group *vg_read(struct cmd_context *cmd, const char *vg_name,
- const char *vgid, uint32_t flags, uint32_t lockd_state)
+ const char *vgid, uint32_t read_flags, uint32_t lockd_state)
{
- uint64_t status = UINT64_C(0);
+ uint64_t status_flags = UINT64_C(0);
uint32_t lock_flags = LCK_VG_READ;
- if (flags & READ_FOR_UPDATE) {
- status |= EXPORTED_VG | LVM_WRITE;
+ if (read_flags & READ_FOR_UPDATE) {
+ status_flags |= EXPORTED_VG | LVM_WRITE;
lock_flags = LCK_VG_WRITE;
}
- if (flags & READ_ALLOW_EXPORTED)
- status &= ~EXPORTED_VG;
+ if (read_flags & READ_ALLOW_EXPORTED)
+ status_flags &= ~EXPORTED_VG;
- return _vg_lock_and_read(cmd, vg_name, vgid, lock_flags, status, flags, lockd_state);
+ return _vg_lock_and_read(cmd, vg_name, vgid, lock_flags, status_flags, read_flags, lockd_state);
}
/*
@@ -5079,9 +5082,9 @@ struct volume_group *vg_read(struct cmd_context *cmd, const char *vg_name,
* request the new metadata to be written and committed).
*/
struct volume_group *vg_read_for_update(struct cmd_context *cmd, const char *vg_name,
- const char *vgid, uint32_t flags, uint32_t lockd_state)
+ const char *vgid, uint32_t read_flags, uint32_t lockd_state)
{
- return vg_read(cmd, vg_name, vgid, flags | READ_FOR_UPDATE, lockd_state);
+ return vg_read(cmd, vg_name, vgid, read_flags | READ_FOR_UPDATE, lockd_state);
}
/*
diff --git a/tools/toollib.c b/tools/toollib.c
index dfb2b87..b17fe53 100644
--- a/tools/toollib.c
+++ b/tools/toollib.c
@@ -184,12 +184,24 @@ const char *skip_dev_dir(struct cmd_context *cmd, const char *vg_name,
* If *skip is 1, it's OK for the caller to read the list of PVs in the VG.
*/
static int _ignore_vg(struct volume_group *vg, const char *vg_name,
- struct dm_list *arg_vgnames, int allow_inconsistent, int *skip)
+ struct dm_list *arg_vgnames, uint32_t read_flags, int *skip)
{
uint32_t read_error = vg_read_error(vg);
*skip = 0;
- if ((read_error & FAILED_INCONSISTENT) && allow_inconsistent)
+ if ((read_error & FAILED_NOTFOUND) && (read_flags & READ_OK_NOTFOUND)) {
+ read_error &= ~FAILED_NOTFOUND;
+ *skip = 1;
+ return 0;
+ }
+
+ if ((read_error & FAILED_INCONSISTENT) && (read_flags & READ_OK_NOTFOUND)) {
+ read_error &= ~FAILED_INCONSISTENT;
+ *skip = 1;
+ return 0;
+ }
+
+ if ((read_error & FAILED_INCONSISTENT) && (read_flags & READ_ALLOW_INCONSISTENT))
read_error &= ~FAILED_INCONSISTENT; /* Check for other errors */
if ((read_error & FAILED_CLUSTERED) && vg->cmd->ignore_clustered_vgs) {
@@ -1943,7 +1955,7 @@ static int _process_vgnameid_list(struct cmd_context *cmd, uint32_t flags,
}
vg = vg_read(cmd, vg_name, vg_uuid, flags, lockd_state);
- if (_ignore_vg(vg, vg_name, arg_vgnames, flags & READ_ALLOW_INCONSISTENT, &skip)) {
+ if (_ignore_vg(vg, vg_name, arg_vgnames, flags, &skip)) {
stack;
ret_max = ECMD_FAILED;
goto endvg;
@@ -2431,7 +2443,7 @@ static int _process_lv_vgnameid_list(struct cmd_context *cmd, uint32_t flags,
}
vg = vg_read(cmd, vg_name, vg_uuid, flags, lockd_state);
- if (_ignore_vg(vg, vg_name, arg_vgnames, flags & READ_ALLOW_INCONSISTENT, &skip)) {
+ if (_ignore_vg(vg, vg_name, arg_vgnames, flags, &skip)) {
stack;
ret_max = ECMD_FAILED;
goto endvg;
@@ -2897,7 +2909,7 @@ out:
* should produce an error. Any devices remaining in all_devices were
* not found and should be processed by process_device_list().
*/
-static int _process_pvs_in_vgs(struct cmd_context *cmd, uint32_t flags,
+static int _process_pvs_in_vgs(struct cmd_context *cmd, uint32_t read_flags,
struct dm_list *all_vgnameids,
struct dm_list *all_devices,
struct dm_list *arg_devices,
@@ -2929,8 +2941,8 @@ static int _process_pvs_in_vgs(struct cmd_context *cmd, uint32_t flags,
continue;
}
- vg = vg_read(cmd, vg_name, vg_uuid, flags | READ_WARN_INCONSISTENT, lockd_state);
- if (_ignore_vg(vg, vg_name, NULL, flags & READ_ALLOW_INCONSISTENT, &skip)) {
+ vg = vg_read(cmd, vg_name, vg_uuid, read_flags, lockd_state);
+ if (_ignore_vg(vg, vg_name, NULL, read_flags, &skip)) {
stack;
ret_max = ECMD_FAILED;
if (!skip)
@@ -2969,7 +2981,7 @@ endvg:
int process_each_pv(struct cmd_context *cmd,
int argc, char **argv,
const char *only_this_vgname,
- uint32_t flags,
+ uint32_t read_flags,
struct processing_handle *handle,
process_single_pv_fn_t process_single_pv)
{
@@ -2984,6 +2996,19 @@ int process_each_pv(struct cmd_context *cmd,
int ret_max = ECMD_PROCESSED;
int ret;
+ /*
+ * When processing a specific VG name, warn if it's inconsistent and
+ * print an error if it's not found. Otherwise we're processing all
+ * VGs, in which case the command doesn't care if the VG is inconsisent
+ * or not found; it just wants to skip that VG. (It may be not found
+ * if it was removed between creating the list of all VGs and then
+ * processing each VG.
+ */
+ if (only_this_vgname)
+ read_flags |= READ_WARN_INCONSISTENT;
+ else
+ read_flags |= READ_OK_NOTFOUND;
+
/* Disable error in vg_read so we can print it from ignore_vg. */
cmd->vg_read_print_access_error = 0;
@@ -3040,7 +3065,7 @@ int process_each_pv(struct cmd_context *cmd,
/* get_arg_devices reports the error for any PV names not found. */
ret_max = ECMD_FAILED;
- ret = _process_pvs_in_vgs(cmd, flags, &all_vgnameids, &all_devices,
+ ret = _process_pvs_in_vgs(cmd, read_flags, &all_vgnameids, &all_devices,
&arg_devices, &arg_tags,
process_all_pvs, process_all_devices,
handle, process_single_pv);
8 years, 6 months
master - thin: Fix typo in policy threshold message.
by Alasdair Kergon
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=51735f09f79794...
Commit: 51735f09f79794d6609913b4c117f1a4a0e491fe
Parent: 3a42c13ccf151c3afdeab362c8541b5d249fb01e
Author: Alasdair G Kergon <agk(a)redhat.com>
AuthorDate: Fri Oct 23 15:38:31 2015 +0100
Committer: Alasdair G Kergon <agk(a)redhat.com>
CommitterDate: Fri Oct 23 15:38:31 2015 +0100
thin: Fix typo in policy threshold message.
---
lib/metadata/lv_manip.c | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/lib/metadata/lv_manip.c b/lib/metadata/lv_manip.c
index 738343f..19032e9 100644
--- a/lib/metadata/lv_manip.c
+++ b/lib/metadata/lv_manip.c
@@ -4438,8 +4438,8 @@ static int _adjust_policy_params(struct cmd_context *cmd,
find_config_tree_int(cmd, activation_thin_pool_autoextend_percent_CFG,
lv_config_profile(lv));
if (policy_threshold < 50) {
- log_warn("WARNING: Thin pool autoextend threshold %d%% is set bellow "
- "minimal supported value 50%%.", policy_threshold);
+ log_warn("WARNING: Thin pool autoextend threshold %d%% is set below "
+ "minimum supported 50%%.", policy_threshold);
policy_threshold = 50;
}
} else {
8 years, 6 months
master - lvmcache: update cached info properly when moving from VG to orphan while lvmetad is used
by Peter Rajnoha
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=3a42c13ccf151c...
Commit: 3a42c13ccf151c3afdeab362c8541b5d249fb01e
Parent: 8b965bd3d5df808aef2012494602cc0cf73d7398
Author: Peter Rajnoha <prajnoha(a)redhat.com>
AuthorDate: Fri Oct 23 15:05:48 2015 +0200
Committer: Peter Rajnoha <prajnoha(a)redhat.com>
CommitterDate: Fri Oct 23 15:58:31 2015 +0200
lvmcache: update cached info properly when moving from VG to orphan while lvmetad is used
When lvmetad is used and lvmcache update function (lvmcache_update_vgname_and_id)
was called to update existing lvmcache records, a condition was met
which made to retun from the update function immediately, effectively
making it NOOP.
It seems there's no reason for such condition and lvmcache should be
update appropriately even when lvmetad used as lvmcache may be reused,
most notably in lvm shell.
It's possible this is a remnant of the lvmetad development code which
didn't get removed for some reason and the bug didn't get spotted
because lvm shell is not used often (the condition dates back to 2012
or so).
Example, lvmetad and lvm shell used:
lvm> pvs
PV VG Fmt Attr PSize PFree
/dev/sda vg lvm2 a-- 124.00m 124.00m
Before this patch:
==================
lvm> vgremove vg
Volume group "vg" successfully removed
lvm> pvs
With this patch applied:
========================
lvm> vgremove vg
Volume group "vg" successfully removed
lvm> pvs
PV VG Fmt Attr PSize PFree
/dev/sda lvm2 --- 128.00m 128.00m
---
WHATS_NEW | 1 +
lib/cache/lvmcache.c | 4 ----
2 files changed, 1 insertions(+), 4 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index 6462e18..5911c64 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.133 -
======================================
+ Fix lvmcache to move PV from VG to orphans if VG is removed and lvmetad used.
Fix lvmcache to not cache even invalid info about PV which got removed.
Support checking of memlock daemon counter.
Allow all log levels to be used with the lvmetad -l option.
diff --git a/lib/cache/lvmcache.c b/lib/cache/lvmcache.c
index 1bc4241..31f2aa9 100644
--- a/lib/cache/lvmcache.c
+++ b/lib/cache/lvmcache.c
@@ -1542,10 +1542,6 @@ int lvmcache_update_vgname_and_id(struct lvmcache_info *info, struct lvmcache_vg
vgid = vgname;
}
- /* When using lvmetad, the PV could not have become orphaned. */
- if (lvmetad_active() && is_orphan_vg(vgname) && info->vginfo)
- return 1;
-
/* If PV without mdas is already in a real VG, don't make it orphan */
if (is_orphan_vg(vgname) && info->vginfo &&
mdas_empty_or_ignored(&info->mdas) &&
8 years, 6 months
master - pvremove: make sure even invalid info is removed from lvmcache on pvremove
by Peter Rajnoha
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=8b965bd3d5df80...
Commit: 8b965bd3d5df808aef2012494602cc0cf73d7398
Parent: 1a7bea0f0f187a3d3332dda2cca2ecd0300b8031
Author: Peter Rajnoha <prajnoha(a)redhat.com>
AuthorDate: Fri Oct 23 14:11:16 2015 +0200
Committer: Peter Rajnoha <prajnoha(a)redhat.com>
CommitterDate: Fri Oct 23 15:48:06 2015 +0200
pvremove: make sure even invalid info is removed from lvmcache on pvremove
The lvmcache info might be resued, most notably in lvm shell.
We need to be sure that even lvmcache_info marked as invalid
is removed from the lvmcache so it does not confuse any subsequent
code/commands executed later on.
Problematic example with the lvm shell:
lvm> pvs
PV VG Fmt Attr PSize PFree
/dev/sda lvm2 --- 128.00m 128.00m
Before this patch (/dev/sda still displayed in a way):
======================================================
lvm> pvremove /dev/sda
Labels on physical volume "/dev/sda" successfully wiped
(without lvmetad)
lvm> pvs
No physical volume label read from /dev/sda
(with lvmetad)
lvm> pvs
PV VG Fmt Attr PSize PFree
/dev/sda lvm2 --- 128.00m 128.00m
With this patch applied:
========================
lvm> pvremove /dev/sda
Labels on physical volume "/dev/sda" successfully wiped
(without lvmetad)
lvm> pvs
(with lvmetad)
lvm> pvs
---
WHATS_NEW | 1 +
lib/metadata/pv_manip.c | 2 +-
2 files changed, 2 insertions(+), 1 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index 8ffbeca..6462e18 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.133 -
======================================
+ Fix lvmcache to not cache even invalid info about PV which got removed.
Support checking of memlock daemon counter.
Allow all log levels to be used with the lvmetad -l option.
Add optional shutdown when idle support for lvmetad.
diff --git a/lib/metadata/pv_manip.c b/lib/metadata/pv_manip.c
index ce7f661..e48fe42 100644
--- a/lib/metadata/pv_manip.c
+++ b/lib/metadata/pv_manip.c
@@ -781,7 +781,7 @@ int pvremove_single(struct cmd_context *cmd, const char *pv_name,
goto out;
}
- info = lvmcache_info_from_pvid(dev->pvid, 1);
+ info = lvmcache_info_from_pvid(dev->pvid, 0);
if (!dev_test_excl(dev)) {
/* FIXME Detect whether device-mapper is still using the device */
8 years, 6 months
master - cleanup: drop debug
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=1a7bea0f0f187a...
Commit: 1a7bea0f0f187a3d3332dda2cca2ecd0300b8031
Parent: b5b2a5483450dff10fd23a7b712649729e619b0d
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Fri Oct 23 10:46:58 2015 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Fri Oct 23 10:54:13 2015 +0200
cleanup: drop debug
---
daemons/dmeventd/plugins/lvm2/dmeventd_lvm.c | 1 -
1 files changed, 0 insertions(+), 1 deletions(-)
diff --git a/daemons/dmeventd/plugins/lvm2/dmeventd_lvm.c b/daemons/dmeventd/plugins/lvm2/dmeventd_lvm.c
index aaf9a49..cda19a3 100644
--- a/daemons/dmeventd/plugins/lvm2/dmeventd_lvm.c
+++ b/daemons/dmeventd/plugins/lvm2/dmeventd_lvm.c
@@ -100,7 +100,6 @@ void dmeventd_lvm2_exit(void)
lvm2_run(_lvm_handle, "_memlock_dec");
dm_pool_destroy(_mem_pool);
_mem_pool = NULL;
- log_debug("lvm plugin exiting.");
lvm2_exit(_lvm_handle);
_lvm_handle = NULL;
log_debug("lvm plugin exited.");
8 years, 6 months