master - cleanup: indent
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=406d6de651fd1ae3bda...
Commit: 406d6de651fd1ae3bda80f3597d7aa8733b0389a
Parent: 16c209c613b35307105e7d022a95f58f897243aa
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Mon Feb 26 14:44:51 2018 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Wed Feb 28 21:15:55 2018 +0100
cleanup: indent
---
lib/metadata/lv_manip.c | 5 +++--
tools/lvchange.c | 3 ++-
tools/lvconvert.c | 2 +-
3 files changed, 6 insertions(+), 4 deletions(-)
diff --git a/lib/metadata/lv_manip.c b/lib/metadata/lv_manip.c
index 1e2cfc6..044214c 100644
--- a/lib/metadata/lv_manip.c
+++ b/lib/metadata/lv_manip.c
@@ -1049,12 +1049,13 @@ static int _release_and_discard_lv_segment_area(struct lv_segment *seg, uint32_t
}
if (lv_is_raid_image(lv)) {
- /* Calculate the amount of extents to reduce per rmate/rimage LV */
+ /* Calculate the amount of extents to reduce per rmeta/rimage LV */
uint32_t rimage_extents;
struct lv_segment *seg1 = first_seg(lv);
/* FIXME: avoid extra seg_is_*() conditionals here */
- rimage_extents = raid_rimage_extents(seg1->segtype, area_reduction, seg_is_any_raid0(seg) ? 0 : _raid_stripes_count(seg),
+ rimage_extents = raid_rimage_extents(seg1->segtype, area_reduction,
+ seg_is_any_raid0(seg) ? 0 : _raid_stripes_count(seg),
seg_is_raid10(seg) ? 1 :_raid_data_copies(seg));
if (!rimage_extents)
return 0;
diff --git a/tools/lvchange.c b/tools/lvchange.c
index 83dbf97..288b04c 100644
--- a/tools/lvchange.c
+++ b/tools/lvchange.c
@@ -1374,6 +1374,7 @@ static int _lvchange_activate_check(struct cmd_context *cmd,
int lvchange_activate_cmd(struct cmd_context *cmd, int argc, char **argv)
{
int ret;
+ int do_activate = is_change_activating((activation_change_t)arg_uint_value(cmd, activate_ARG, CHANGE_AY));
init_background_polling(arg_is_set(cmd, sysinit_ARG) ? 0 : arg_int_value(cmd, poll_ARG, DEFAULT_BACKGROUND_POLLING));
cmd->handles_missing_pvs = 1;
@@ -1387,7 +1388,7 @@ int lvchange_activate_cmd(struct cmd_context *cmd, int argc, char **argv)
cmd->include_active_foreign_vgs = 1;
/* Allow deactivating if locks fail. */
- if (is_change_activating((activation_change_t)arg_uint_value(cmd, activate_ARG, CHANGE_AY)))
+ if (do_activate)
cmd->lockd_vg_enforce_sh = 1;
ret = process_each_lv(cmd, argc, argv, NULL, NULL, 0,
diff --git a/tools/lvconvert.c b/tools/lvconvert.c
index 8006699..63f0715 100644
--- a/tools/lvconvert.c
+++ b/tools/lvconvert.c
@@ -1948,7 +1948,7 @@ static int _lvconvert_snapshot(struct cmd_context *cmd,
* LV_foo specification because this LV is not processed by process_each_lv.
*/
if (!validate_snapshot_origin(org))
- return_0;
+ return_0;
log_warn("WARNING: Converting logical volume %s to snapshot exception store.",
snap_name);
5 years, 7 months
master - cleanup: use lv_is_used_cache_pool
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=16c209c613b35307105...
Commit: 16c209c613b35307105e7d022a95f58f897243aa
Parent: e643de6e61e9329c84286941511242f0f0d2e71b
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Wed Feb 28 17:38:43 2018 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Wed Feb 28 21:15:55 2018 +0100
cleanup: use lv_is_used_cache_pool
Use lv_is_used_cache_pool() to simplify the code.
Function was introduced later and this code missed to use it.
---
lib/metadata/lv_manip.c | 16 +++++++---------
1 files changed, 7 insertions(+), 9 deletions(-)
diff --git a/lib/metadata/lv_manip.c b/lib/metadata/lv_manip.c
index 28f00ab..1e2cfc6 100644
--- a/lib/metadata/lv_manip.c
+++ b/lib/metadata/lv_manip.c
@@ -6084,7 +6084,7 @@ int lv_remove_single(struct cmd_context *cmd, struct logical_volume *lv,
}
/* Used cache pool, COW or historical LV cannot be activated */
- if ((!lv_is_cache_pool(lv) || dm_list_empty(&lv->segs_using_this_lv)) &&
+ if (!lv_is_used_cache_pool(lv) &&
!lv_is_cow(lv) && !lv_is_historical(lv) &&
!deactivate_lv(cmd, lv)) {
/* FIXME Review and fix the snapshot error paths! */
@@ -6134,16 +6134,14 @@ int lv_remove_single(struct cmd_context *cmd, struct logical_volume *lv,
}
}
- if (lv_is_cache_pool(lv)) {
+ if (lv_is_used_cache_pool(lv)) {
/* Cache pool removal drops cache layer
* If the cache pool is not linked, we can simply remove it. */
- if (!dm_list_empty(&lv->segs_using_this_lv)) {
- if (!(cache_seg = get_only_segment_using_this_lv(lv)))
- return_0;
- /* TODO: polling */
- if (!lv_cache_remove(cache_seg->lv))
- return_0;
- }
+ if (!(cache_seg = get_only_segment_using_this_lv(lv)))
+ return_0;
+ /* TODO: polling */
+ if (!lv_cache_remove(cache_seg->lv))
+ return_0;
}
visible = lv_is_visible(lv);
5 years, 7 months
master - cleanup: explicitely ignore result code
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=e643de6e61e9329c842...
Commit: e643de6e61e9329c84286941511242f0f0d2e71b
Parent: 805bf6ec740845de0de55d3706220d84f3ad6edb
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Sun Feb 25 16:18:31 2018 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Wed Feb 28 21:15:55 2018 +0100
cleanup: explicitely ignore result code
ATM too long prefix is silently ignored.
---
lib/log/log.c | 3 ++-
1 files changed, 2 insertions(+), 1 deletions(-)
diff --git a/lib/log/log.c b/lib/log/log.c
index 808090f..79fbd7a 100644
--- a/lib/log/log.c
+++ b/lib/log/log.c
@@ -376,7 +376,8 @@ void fin_syslog(void)
void init_msg_prefix(const char *prefix)
{
if (prefix)
- dm_strncpy(_msg_prefix, prefix, sizeof(_msg_prefix));
+ /* Cut away too long prefix */
+ (void) dm_strncpy(_msg_prefix, prefix, sizeof(_msg_prefix));
}
void init_indent(int indent)
5 years, 7 months
master - cleanup: unused header file
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=805bf6ec740845de0de...
Commit: 805bf6ec740845de0de55d3706220d84f3ad6edb
Parent: 6ba94fdd816a70f084ea86ec0a3ff2243daae158
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Sun Feb 25 16:18:11 2018 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Wed Feb 28 21:15:55 2018 +0100
cleanup: unused header file
---
lib/label/label.c | 1 -
1 files changed, 0 insertions(+), 1 deletions(-)
diff --git a/lib/label/label.c b/lib/label/label.c
index ae3a2c1..32fad82 100644
--- a/lib/label/label.c
+++ b/lib/label/label.c
@@ -18,7 +18,6 @@
#include "crc.h"
#include "xlate.h"
#include "lvmcache.h"
-#include "lvmetad.h"
#include <sys/stat.h>
#include <fcntl.h>
5 years, 7 months
master - debug: change message severity
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=6ba94fdd816a70f084e...
Commit: 6ba94fdd816a70f084ea86ec0a3ff2243daae158
Parent: cc4855acbe98cea36228afeeaa6ce7f800459308
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Wed Feb 21 14:08:17 2018 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Wed Feb 28 21:15:55 2018 +0100
debug: change message severity
Although it's internal issue - in this case command continue without
any reported error - thus hide this internal error into debug.
---
lib/metadata/cache_manip.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/lib/metadata/cache_manip.c b/lib/metadata/cache_manip.c
index 97a3339..c46266b 100644
--- a/lib/metadata/cache_manip.c
+++ b/lib/metadata/cache_manip.c
@@ -540,7 +540,7 @@ int lv_cache_remove(struct logical_volume *cache_lv)
}
if (lv_is_pending_delete(cache_lv)) {
- log_error(INTERNAL_ERROR "LV %s is already dropped cache volume.",
+ log_debug(INTERNAL_ERROR "LV %s is already dropped cache volume.",
display_lvname(cache_lv));
goto remove; /* Already dropped */
}
5 years, 7 months
master - tests: check inactive extorig resize
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=cc4855acbe98cea3622...
Commit: cc4855acbe98cea36228afeeaa6ce7f800459308
Parent: 052f28746d1d90883f63e9fb1ef86efb03133fe7
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Wed Feb 28 19:03:20 2018 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Wed Feb 28 21:15:55 2018 +0100
tests: check inactive extorig resize
---
test/shell/lvresize-thin-external-origin.sh | 7 +++++++
1 files changed, 7 insertions(+), 0 deletions(-)
diff --git a/test/shell/lvresize-thin-external-origin.sh b/test/shell/lvresize-thin-external-origin.sh
index aa5e4bf..6dbfe4a 100644
--- a/test/shell/lvresize-thin-external-origin.sh
+++ b/test/shell/lvresize-thin-external-origin.sh
@@ -43,8 +43,15 @@ not lvresize -L+10 $vg/$lv1
lvresize -L-5 -f $vg/$lv1
check lv_field $vg/$lv1 lv_size "5.00" --units m --nosuffix
+# Inactive LV cannot be resized as well
+lvchange -an $vg
not lvresize -L+15 -y $vg/$lv1
check lv_field $vg/$lv1 lv_size "5.00" --units m --nosuffix
+lvchange -ay $vg/$lv1
+
+not lvresize -L+15 -y $vg/$lv1
+check lv_field $vg/$lv1 lv_size "5.00" --units m --nosuffix
+
# Try to resize again back up to the size of external origin
lvresize -L+5 -f $vg/$lv1
5 years, 7 months
master - lvresize: check external origin with new size
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=052f28746d1d90883f6...
Commit: 052f28746d1d90883f63e9fb1ef86efb03133fe7
Parent: b09ea3b6f764f6a853b816da65aeb3d0d351f77c
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Wed Feb 28 17:04:26 2018 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Wed Feb 28 21:15:55 2018 +0100
lvresize: check external origin with new size
Instead of checking with existing size of external origin LV,
use correctly the new 'wanted' size of this LV whether it fits
the limitiation requirements for older thin-pool target.
Otherwise code started to the the resize, updates metadata and
just fails during 'resize' in case the LV was active. For
inactive LV operation could have actually passed.
---
WHATS_NEW | 1 +
lib/metadata/lv_manip.c | 2 +-
2 files changed, 2 insertions(+), 1 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index 6a0a0dc..46f66b0 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.178 -
=====================================
+ Fix compatibility size test of extended external origin.
Add external_origin visiting in for_each_sub_lv().
Ensure cluster commands drop their device cache before locking VG.
Do not report LV as remotely active when it's locally exclusive in cluster.
diff --git a/lib/metadata/lv_manip.c b/lib/metadata/lv_manip.c
index 12f444b..28f00ab 100644
--- a/lib/metadata/lv_manip.c
+++ b/lib/metadata/lv_manip.c
@@ -5334,7 +5334,7 @@ static int _lvresize_check_type(const struct logical_volume *lv,
/* Validate thin target supports bigger size of thin volume then external origin */
if (lv_is_thin_volume(lv) && first_seg(lv)->external_lv &&
- (lv->size > first_seg(lv)->external_lv->size) &&
+ (lp->extents > first_seg(lv)->external_lv->le_count) &&
!thin_pool_feature_supported(first_seg(lv)->pool_lv, THIN_FEATURE_EXTERNAL_ORIGIN_EXTEND)) {
log_error("Thin target does not support external origin smaller then thin volume.");
return 0;
5 years, 7 months
master - lvremove: drop unneded check
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=b09ea3b6f764f6a853b...
Commit: b09ea3b6f764f6a853b816da65aeb3d0d351f77c
Parent: 749372caf3e977f2e3f69848e8535fea397695e6
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Wed Feb 28 17:37:03 2018 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Wed Feb 28 21:08:40 2018 +0100
lvremove: drop unneded check
Checking here for cache_pool is not necessary and in effect
the check is not even right - since there are internal
states that do allow to active such LV.
---
lib/metadata/lv_manip.c | 3 +--
1 files changed, 1 insertions(+), 2 deletions(-)
diff --git a/lib/metadata/lv_manip.c b/lib/metadata/lv_manip.c
index 35c805c..12f444b 100644
--- a/lib/metadata/lv_manip.c
+++ b/lib/metadata/lv_manip.c
@@ -6033,8 +6033,7 @@ 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_pool(lv) && /* cache pool cannot be active */
- lv_is_active(lv)) {
+ if (lv_is_active(lv)) {
if (!lv_check_not_in_use(lv, 1))
return_0;
5 years, 7 months
master - command: use bigger buffer
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=749372caf3e977f2e3f...
Commit: 749372caf3e977f2e3f69848e8535fea397695e6
Parent: bc1adc32cbd593dd1839526da82521b429b13141
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Wed Feb 28 16:57:53 2018 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Wed Feb 28 21:08:40 2018 +0100
command: use bigger buffer
Instead of use 'silently' shortened passed string - always
make sure we take either a full copy or return error.
---
tools/command.c | 6 ++++--
1 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/tools/command.c b/tools/command.c
index 5a5f351..f974474 100644
--- a/tools/command.c
+++ b/tools/command.c
@@ -334,13 +334,15 @@ static char *_split_line(char *buf, int *argc, char **argv, char sep)
static int _val_str_to_num(char *str)
{
- char name[32];
+ char name[MAX_LINE_ARGC];
char *new;
int i;
/* compare the name before any suffix like _new or _<lvtype> */
- dm_strncpy(name, str, sizeof(name));
+ if (!dm_strncpy(name, str, sizeof(name)))
+ return 0; /* Buffer is too short */
+
if ((new = strchr(name, '_')))
*new = '\0';
5 years, 7 months
master - lv_manip: enhance for_each_sub_lv
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=bc1adc32cbd593dd183...
Commit: bc1adc32cbd593dd1839526da82521b429b13141
Parent: 6b48868cf0754b13e4efaaaec33cf8c9deba2d40
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Wed Feb 28 17:00:33 2018 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Wed Feb 28 21:08:38 2018 +0100
lv_manip: enhance for_each_sub_lv
Fix missing 'externalLV' traversing for thins with external origins.
Replace extra for_each_sub_lv_except_pools() with better
internal logic allowing selectively to cut of processed subLV tree.
Extend error code for function 'fn()' when it returns -1 it will
stop futher tree scan for given LV.
Also a bit simplify code to have only one place that
is calling 'fn()' and use level counter to know
depth of traversing.
Update renaming travering to skip trees for pools
and external origins.
---
WHATS_NEW | 1 +
lib/metadata/lv_manip.c | 72 +++++++++++++++++++++++-----------------------
lib/metadata/metadata.h | 3 --
3 files changed, 37 insertions(+), 39 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index 5791930..6a0a0dc 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.178 -
=====================================
+ Add external_origin visiting in for_each_sub_lv().
Ensure cluster commands drop their device cache before locking VG.
Do not report LV as remotely active when it's locally exclusive in cluster.
Add deprecate messages for usage of mirrors with mirrorlog.
diff --git a/lib/metadata/lv_manip.c b/lib/metadata/lv_manip.c
index ac30dad..35c805c 100644
--- a/lib/metadata/lv_manip.c
+++ b/lib/metadata/lv_manip.c
@@ -4341,53 +4341,62 @@ static int _rename_cb(struct logical_volume *lv, void *data)
return _rename_sub_lv(lv, lv_names->old, lv_names->new);
}
+static int _rename_skip_pools_externals_cb(struct logical_volume *lv, void *data)
+{
+ if (lv_is_pool(lv) || lv_is_external_origin(lv))
+ return -1; /* and skip subLVs */
+
+ return _rename_cb(lv, data);
+}
+
/*
* Loop down sub LVs and call fn for each.
* fn is responsible to log necessary information on failure.
+ * Return value '0' stops whole traversal.
+ * Return value '-1' stops subtree traversal.
*/
-static int _for_each_sub_lv(struct logical_volume *lv, int skip_pools,
+static int _for_each_sub_lv(struct logical_volume *lv, int level,
int (*fn)(struct logical_volume *lv, void *data),
void *data)
{
struct logical_volume *org;
struct lv_segment *seg;
uint32_t s;
+ int r;
- if (lv_is_cow(lv) && lv_is_virtual_origin(org = origin_from_cow(lv))) {
- if (!fn(org, data))
+ if (!lv)
+ return 1;
+
+ if (level++) {
+ if (!(r = fn(lv, data)))
return_0;
- if (!_for_each_sub_lv(org, skip_pools, fn, data))
+ /* Only r == 1 lets you run for_each... */
+ if (r == -1)
+ return 1;
+ }
+
+ if (lv_is_cow(lv) && lv_is_virtual_origin(org = origin_from_cow(lv))) {
+ if (!_for_each_sub_lv(org, level, fn, data))
return_0;
}
dm_list_iterate_items(seg, &lv->segments) {
- if (seg->log_lv) {
- if (!fn(seg->log_lv, data))
- return_0;
- if (!_for_each_sub_lv(seg->log_lv, skip_pools, fn, data))
- return_0;
- }
+ if (!_for_each_sub_lv(seg->external_lv, level, fn, data))
+ return_0;
- if (seg->metadata_lv) {
- if (!fn(seg->metadata_lv, data))
- return_0;
- if (!_for_each_sub_lv(seg->metadata_lv, skip_pools, fn, data))
- return_0;
- }
+ if (!_for_each_sub_lv(seg->log_lv, level, fn, data))
+ return_0;
- if (seg->pool_lv && !skip_pools) {
- if (!fn(seg->pool_lv, data))
- return_0;
- if (!_for_each_sub_lv(seg->pool_lv, skip_pools, fn, data))
- return_0;
- }
+ if (!_for_each_sub_lv(seg->metadata_lv, level, fn, data))
+ return_0;
+
+ if (!_for_each_sub_lv(seg->pool_lv, level, fn, data))
+ return_0;
for (s = 0; s < seg->area_count; s++) {
if (seg_type(seg, s) != AREA_LV)
continue;
- if (!fn(seg_lv(seg, s), data))
- return_0;
- if (!_for_each_sub_lv(seg_lv(seg, s), skip_pools, fn, data))
+ if (!_for_each_sub_lv(seg_lv(seg, s), level, fn, data))
return_0;
}
@@ -4398,9 +4407,7 @@ static int _for_each_sub_lv(struct logical_volume *lv, int skip_pools,
for (s = 0; s < seg->area_count; s++) {
if ((seg_metatype(seg, s) != AREA_LV) || !seg_metalv(seg, s))
continue;
- if (!fn(seg_metalv(seg, s), data))
- return_0;
- if (!_for_each_sub_lv(seg_metalv(seg, s), skip_pools, fn, data))
+ if (!_for_each_sub_lv(seg_metalv(seg, s), level, fn, data))
return_0;
}
}
@@ -4415,13 +4422,6 @@ int for_each_sub_lv(struct logical_volume *lv,
return _for_each_sub_lv(lv, 0, fn, data);
}
-int for_each_sub_lv_except_pools(struct logical_volume *lv,
- int (*fn)(struct logical_volume *lv, void *data),
- void *data)
-{
- return _for_each_sub_lv(lv, 1, fn, data);
-}
-
/*
* Core of LV renaming routine.
* VG must be locked by caller.
@@ -4475,7 +4475,7 @@ int lv_rename_update(struct cmd_context *cmd, struct logical_volume *lv,
}
/* rename sub LVs */
- if (!for_each_sub_lv_except_pools(lv, _rename_cb, (void *) &lv_names))
+ if (!for_each_sub_lv(lv, _rename_skip_pools_externals_cb, (void *) &lv_names))
return_0;
/* rename main LV */
diff --git a/lib/metadata/metadata.h b/lib/metadata/metadata.h
index df660a7..f6b19f4 100644
--- a/lib/metadata/metadata.h
+++ b/lib/metadata/metadata.h
@@ -444,9 +444,6 @@ int add_glv_to_indirect_glvs(struct dm_pool *mem,
int remove_glv_from_indirect_glvs(struct generic_logical_volume *origin_glv,
struct generic_logical_volume *glv);
-int for_each_sub_lv_except_pools(struct logical_volume *lv,
- int (*fn)(struct logical_volume *lv, void *data),
- void *data);
int for_each_sub_lv(struct logical_volume *lv,
int (*fn)(struct logical_volume *lv, void *data),
void *data);
5 years, 7 months