main - dev_get_primary_dev: fix invalid path check
by David Teigland
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=f74f94c2ddb1d33d75d...
Commit: f74f94c2ddb1d33d75d325c959344a566a621fd5
Parent: 427121efc76f1a11df5d06c11ea4f095305b6333
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Tue Feb 9 09:47:08 2021 -0600
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Tue Feb 9 09:52:53 2021 -0600
dev_get_primary_dev: fix invalid path check
Fix commit bee9f4efdd81 "filter-mpath: work with nvme devices"
which removed setting the path for readlink.
---
lib/device/dev-type.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/lib/device/dev-type.c b/lib/device/dev-type.c
index b7bca361f..0411572fa 100644
--- a/lib/device/dev-type.c
+++ b/lib/device/dev-type.c
@@ -614,7 +614,12 @@ int dev_get_primary_dev(struct dev_types *dt, struct device *dev, dev_t *result)
* - basename ../../block/md0/md0 = md0
* Parent's 'dev' sysfs attribute = /sys/block/md0/dev
*/
- if ((size = readlink(dirname(path), temp_path, sizeof(temp_path) - 1)) < 0) {
+ if (dm_snprintf(path, sizeof(path), "%s/dev/block/%d:%d",
+ dm_sysfs_dir(), major, minor) < 0) {
+ log_warn("WARNING: %s: major:minor sysfs path is too long.", dev_name(dev));
+ return 0;
+ }
+ if ((size = readlink(path, temp_path, sizeof(temp_path) - 1)) < 0) {
log_warn("WARNING: Readlink of %s failed.", path);
goto out;
}
2 years, 3 months
stable-2.02 - targets: use target_present_version
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=6a1e8104f84849dc198...
Commit: 6a1e8104f84849dc198af1be2f8d51942621a1e2
Parent: 0f074a4d65bb950e25b13d7ac9aa63361ea774a1
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Sun Feb 7 21:48:18 2021 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Tue Feb 9 15:04:18 2021 +0100
targets: use target_present_version
Skip duplicated dm version ioctl() on every startup.
---
lib/mirror/mirrored.c | 3 ++-
lib/raid/raid.c | 6 ++----
lib/snapshot/snapshot.c | 8 ++++----
lib/thin/thin.c | 6 ++----
4 files changed, 10 insertions(+), 13 deletions(-)
diff --git a/lib/mirror/mirrored.c b/lib/mirror/mirrored.c
index 606bcf0ee..ec1cab538 100644
--- a/lib/mirror/mirrored.c
+++ b/lib/mirror/mirrored.c
@@ -412,7 +412,8 @@ static int _mirrored_target_present(struct cmd_context *cmd,
if (!_mirrored_checked) {
_mirrored_checked = 1;
- if (!(_mirrored_present = target_present(cmd, TARGET_NAME_MIRROR, 1)))
+ if (!(_mirrored_present = target_present_version(cmd, TARGET_NAME_MIRROR, 1,
+ &maj, &min, &patchlevel)))
return 0;
/*
diff --git a/lib/raid/raid.c b/lib/raid/raid.c
index f75c676e8..8ab2d20ec 100644
--- a/lib/raid/raid.c
+++ b/lib/raid/raid.c
@@ -550,10 +550,8 @@ static int _raid_target_present(struct cmd_context *cmd,
if (!_raid_checked) {
_raid_checked = 1;
- if (!(_raid_present = target_present(cmd, TARGET_NAME_RAID, 1)))
- return 0;
-
- if (!target_version("raid", &maj, &min, &patchlevel))
+ if (!(_raid_present = target_present_version(cmd, TARGET_NAME_RAID, 1,
+ &maj, &min, &patchlevel)))
return_0;
for (i = 0; i < DM_ARRAY_SIZE(_features); ++i)
diff --git a/lib/snapshot/snapshot.c b/lib/snapshot/snapshot.c
index 5fd39e9f8..695fbd6d4 100644
--- a/lib/snapshot/snapshot.c
+++ b/lib/snapshot/snapshot.c
@@ -151,12 +151,12 @@ static int _snap_target_present(struct cmd_context *cmd,
if (!_snap_checked) {
_snap_checked = 1;
- if (!(_snap_present = target_present(cmd, TARGET_NAME_SNAPSHOT, 1) &&
- target_present(cmd, TARGET_NAME_SNAPSHOT_ORIGIN, 0)))
+ if (!(_snap_present = (target_present_version(cmd, TARGET_NAME_SNAPSHOT, 1,
+ &maj, &min, &patchlevel) &&
+ target_present(cmd, TARGET_NAME_SNAPSHOT_ORIGIN, 0))))
return 0;
- if (target_version(TARGET_NAME_SNAPSHOT, &maj, &min, &patchlevel) &&
- (maj > 1 ||
+ if ((maj > 1 ||
(maj == 1 && (min >= 12 || (min == 10 && patchlevel >= 2)))))
_snap_attrs |= SNAPSHOT_FEATURE_FIXED_LEAK;
else
diff --git a/lib/thin/thin.c b/lib/thin/thin.c
index 8ab60ce1e..c77fe5c7c 100644
--- a/lib/thin/thin.c
+++ b/lib/thin/thin.c
@@ -689,12 +689,10 @@ static int _thin_target_present(struct cmd_context *cmd,
if (!_checked) {
_checked = 1;
- if (!(_present = target_present(cmd, _thin_pool_module, 1)))
+ if (!(_present = target_present_version(cmd, _thin_pool_module, 1,
+ &maj, &min, &patchlevel)))
return 0;
- if (!target_version(_thin_pool_module, &maj, &min, &patchlevel))
- return_0;
-
for (i = 0; i < DM_ARRAY_SIZE(_features); ++i)
if ((maj > _features[i].maj) ||
(maj == _features[i].maj && min >= _features[i].min))
2 years, 3 months
stable-2.02 - tests: support for resized cached LVs
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=0f074a4d65bb950e25b...
Commit: 0f074a4d65bb950e25b13d7ac9aa63361ea774a1
Parent: 4eeb9e76630e204eb3deff386bb0e979f1ca126c
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Sun Feb 7 18:45:43 2021 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Tue Feb 9 15:04:18 2021 +0100
tests: support for resized cached LVs
Support for cached LVs is now enabled.
---
test/shell/lvextend-thin-cache.sh | 19 +++++++++++++------
test/shell/lvextend-thin.sh | 18 +++++++++++++++++-
2 files changed, 30 insertions(+), 7 deletions(-)
diff --git a/test/shell/lvextend-thin-cache.sh b/test/shell/lvextend-thin-cache.sh
index f7bbfd992..40c213b21 100644
--- a/test/shell/lvextend-thin-cache.sh
+++ b/test/shell/lvextend-thin-cache.sh
@@ -1,6 +1,6 @@
#!/usr/bin/env bash
-# Copyright (C) 2017 Red Hat, Inc. All rights reserved.
+# Copyright (C) 2017-2020 Red Hat, Inc. All rights reserved.
#
# This copyrighted material is made available to anyone wishing to use,
# modify, copy, or redistribute it subject to the terms and conditions
@@ -22,15 +22,22 @@ export LVM_TEST_THIN_REPAIR_CMD=${LVM_TEST_THIN_REPAIR_CMD-/bin/false}
aux have_thin 1 0 0 || skip
aux have_cache 1 3 0 || skip
-aux prepare_vg 2
+aux prepare_vg 2 20000
-lvcreate -l2 -T $vg/pool
+lvcreate -l1 -T $vg/pool
# Caching of thin-pool's dataLV
lvcreate -H -L10 $vg/pool
-# Resize is unsupported
-not lvextend -l+2 $vg/pool 2>&1 | tee out
+lvextend -l+2 $vg/pool
-grep "Unable to resize" out
+check lv_first_seg_field $vg/pool seg_size_pe "3"
+
+lvextend -L10G $vg/pool
+
+# Check data are resized and its metadata are matching data size
+check lv_field $vg/pool size "10.00g"
+check lv_field $vg/pool_tdata size "10.00g"
+check lv_field $vg/pool_tdata_corig size "10.00g"
+check lv_field $vg/pool_tmeta size "10.00m"
vgremove -ff $vg
diff --git a/test/shell/lvextend-thin.sh b/test/shell/lvextend-thin.sh
index 3e39ea3eb..d1efd4798 100644
--- a/test/shell/lvextend-thin.sh
+++ b/test/shell/lvextend-thin.sh
@@ -22,6 +22,22 @@ aux have_thin 1 0 0 || skip
aux prepare_vg 3
lvcreate -i2 -l2 -T $vg/pool2
lvextend -l+2 $vg/pool2 "$dev2" "$dev3"
-should lvextend -l+100%FREE $vg/pool2
+lvextend -l+100%FREE $vg/pool2
+
+lvremove -f $vg
+
+lvcreate -L1 -n pool $vg
+# Does work only with thin-pools
+not lvextend --poolmetadatasize +1 $vg/pool
+lvconvert -y --thinpool $vg/pool --poolmetadatasize 2
+
+# _tdata cannot be used with --poolmetadata
+not lvextend --poolmetadatasize +1 $vg/pool_tdata
+lvextend --poolmetadatasize +1 $vg/pool_tmeta
+lvextend --poolmetadatasize +1 --size +1 $vg/pool
+check lv_field $vg/pool_tmeta size "4.00m"
+check lv_field $vg/lvol0_pmspare size "4.00m"
+
+not lvresize --poolmetadatasize -1 $vg/pool
vgremove -ff $vg
2 years, 3 months
stable-2.02 - lv_resize: support resizing of cached volumes
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=4eeb9e76630e204eb3d...
Commit: 4eeb9e76630e204eb3deff386bb0e979f1ca126c
Parent: d3a9bf4a56716072dbb2d9fdc6abe4d0d89dc95e
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Sun Feb 7 20:12:00 2021 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Tue Feb 9 15:04:18 2021 +0100
lv_resize: support resizing of cached volumes
Automatically figure out resizable layer in the LV stack and
resize it online.
Split check for reshaped raids and postpone removal of
unused space after finished reshaping after metadata archiving.
Drop warning about unsupported automatic resize of monitored thin-pool.
Currently there is not yet support for resize of writecache.
---
WHATS_NEW | 1 +
lib/metadata/cache_manip.c | 4 --
lib/metadata/lv_manip.c | 169 ++++++++++++++++++++++++++++-----------------
3 files changed, 105 insertions(+), 69 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index a50762703..dafa4169a 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.188 -
==================================
+ Support resize of cached volumes.
Allocation prints better error when metadata cannot fit on a single PV.
Pvmove can better resolve full thin-pool tree move.
Limit pool metadata spare to 16GiB.
diff --git a/lib/metadata/cache_manip.c b/lib/metadata/cache_manip.c
index ffce73761..fee5a78ee 100644
--- a/lib/metadata/cache_manip.c
+++ b/lib/metadata/cache_manip.c
@@ -131,10 +131,6 @@ void cache_check_for_warns(const struct lv_segment *seg)
first_seg(seg->pool_lv)->cache_mode == CACHE_MODE_WRITEBACK)
log_warn("WARNING: Data redundancy could be lost with writeback "
"caching of raid logical volume!");
-
- if (lv_is_thin_pool_data(seg->lv))
- log_warn("WARNING: Cached thin pool's data cannot be currently "
- "resized and require manual uncache before resize!");
}
/*
diff --git a/lib/metadata/lv_manip.c b/lib/metadata/lv_manip.c
index 6f21d10b9..e9ce8cd28 100644
--- a/lib/metadata/lv_manip.c
+++ b/lib/metadata/lv_manip.c
@@ -1317,6 +1317,43 @@ static int _lv_segment_reduce(struct lv_segment *seg, uint32_t reduction)
return 1;
}
+/* Find the bottommost resizable LV in the stack.
+ * It does not matter which LV is used in this stack for cmdline tool. */
+static struct logical_volume *_get_resizable_layer_lv(struct logical_volume *lv)
+{
+ while (lv_is_cache(lv) || /* _corig */
+ lv_is_thin_pool(lv)) /* _tdata */
+ lv = seg_lv(first_seg(lv), 0); /* component-level down */
+
+ return lv;
+}
+
+/* Check if LV is component of resizable LV.
+ * When resize changes size of LV this also changes the size whole stack upward.
+ * Support syntax suggar - so user can pick any LV in stack for resize. */
+static int _is_layered_lv(struct logical_volume *lv)
+{
+ return (lv_is_cache_origin(lv) ||
+ lv_is_thin_pool_data(lv));
+}
+
+/* Find the topmost LV in the stack - usually such LV is visible. */
+static struct logical_volume *_get_top_layer_lv(struct logical_volume *lv)
+{
+ struct lv_segment *seg;
+
+ while (_is_layered_lv(lv)) {
+ if (!(seg = get_only_segment_using_this_lv(lv))) {
+ log_error(INTERNAL_ERROR "No single component user of logical volume %s.",
+ display_lvname(lv));
+ return NULL;
+ }
+ lv = seg->lv; /* component-level up */
+ }
+
+ return lv;
+}
+
/* Handles also stacking */
static int _setup_lv_size(struct logical_volume *lv, uint32_t extents)
{
@@ -1325,16 +1362,15 @@ static int _setup_lv_size(struct logical_volume *lv, uint32_t extents)
lv->le_count = extents;
lv->size = (uint64_t) extents * lv->vg->extent_size;
- if (lv->size &&
- (lv_is_thin_pool_data(lv))) {
+ while (lv->size && _is_layered_lv(lv)) {
if (!(seg = get_only_segment_using_this_lv(lv)))
return_0;
- /* Update pool segment from the layered LV */
seg->lv->le_count =
seg->len =
seg->area_len = lv->le_count;
seg->lv->size = lv->size;
+ lv = seg->lv;
}
return 1;
@@ -4817,7 +4853,7 @@ static int _lvresize_check(struct logical_volume *lv,
return 0;
}
- if (seg && (seg_is_raid4(seg) || seg_is_any_raid5(seg)) && seg->area_count < 3) {
+ if ((seg_is_raid4(seg) || seg_is_any_raid5(seg)) && seg->area_count < 3) {
log_error("Cannot resize %s LV %s. Convert to more stripes first.",
lvseg_name(seg), display_lvname(lv));
return 0;
@@ -4836,17 +4872,6 @@ static int _lvresize_check(struct logical_volume *lv,
}
}
- if (lp->use_policies && !lv_is_cow(lv) && !lv_is_thin_pool(lv)) {
- log_error("Policy-based resize is supported only for snapshot and thin pool volumes.");
- return 0;
- }
-
- if (lv_is_cache_type(lv) ||
- (lv_is_thin_pool(lv) && lv_is_cache_type(seg_lv(first_seg(lv), 0)))) {
- log_error("Unable to resize logical volumes of cache type.");
- return 0;
- }
-
if (!lv_is_visible(lv) &&
!lv_is_thin_pool_metadata(lv) &&
!lv_is_lockd_sanlock_lv(lv)) {
@@ -4865,11 +4890,6 @@ static int _lvresize_check(struct logical_volume *lv,
return 0;
}
- if (!lv_is_thin_pool(lv) && lp->poolmetadata_size) {
- log_error("--poolmetadatasize can be used only with thin pools.");
- return 0;
- }
-
if (lp->stripe_size) {
if (!(vg->fid->fmt->features & FMT_SEGMENTS)) {
log_print_unless_silent("Varied stripesize not supported. Ignoring.");
@@ -5289,8 +5309,8 @@ static int _lvresize_adjust_extents(struct logical_volume *lv,
return 0;
}
- if (lp->extents == existing_logical_extents) {
- if (!lp->resizefs) {
+ if ((lp->extents == existing_logical_extents) && !lp->use_policies) {
+ if (!lp->resizefs && !lp->poolmetadata_size) {
log_error("New size (%d extents) matches existing size (%d extents).",
lp->extents, existing_logical_extents);
return 0;
@@ -5350,7 +5370,7 @@ static int _lvresize_adjust_extents(struct logical_volume *lv,
}
lp->resize = LV_EXTEND;
} else if ((lp->extents == existing_logical_extents) && !lp->use_policies) {
- if (!lp->resizefs) {
+ if (!lp->resizefs && !lp->poolmetadata_size) {
log_error("New size (%d extents) matches existing size "
"(%d extents)", lp->extents, existing_logical_extents);
return 0;
@@ -5419,6 +5439,12 @@ static int _lvresize_check_type(const struct logical_volume *lv,
}
}
+ /* Prevent resizing on out-of-sync reshapable raid */
+ if (first_seg(lv)->reshape_len && !lv_raid_in_sync(lv)) {
+ log_error("Can't resize reshaping LV %s.", display_lvname(lv));
+ return 0;
+ }
+
return 1;
}
@@ -5467,25 +5493,26 @@ static int _lvresize_volume(struct logical_volume *lv,
return 1;
}
-static int _lvresize_prepare(struct logical_volume **lv,
+static int _lvresize_prepare(struct logical_volume *lv,
struct lvresize_params *lp,
struct dm_list *pvh)
{
- struct volume_group *vg = (*lv)->vg;
-
- if (lv_is_thin_pool(*lv))
- *lv = seg_lv(first_seg(*lv), 0); /* switch to data LV */
-
/* Resolve extents from size */
- if (lp->size && !_lvresize_adjust_size(vg, lp->size, lp->sign, &lp->extents))
+ if (lp->size && !_lvresize_adjust_size(lv->vg, lp->size, lp->sign, &lp->extents))
return_0;
- else if (lp->extents && !_lvresize_extents_from_percent(*lv, lp, pvh))
+ else if (lp->extents && !_lvresize_extents_from_percent(lv, lp, pvh))
return_0;
- if (!_lvresize_adjust_extents(*lv, lp, pvh))
+ /* Ensure stripe boundary extents! */
+ if (!lp->percent && lv_is_raid(lv))
+ lp->extents =_round_to_stripe_boundary(lv->vg, lp->extents,
+ seg_is_raid1(first_seg(lv)) ? 0 : _raid_stripes_count(first_seg(lv)),
+ lp->resize == LV_REDUCE ? 0 : 1);
+
+ if (!_lvresize_adjust_extents(lv, lp, pvh))
return_0;
- if (!_lvresize_check_type(*lv, lp))
+ if (!_lvresize_check_type(lv, lp))
return_0;
return 1;
@@ -5516,27 +5543,20 @@ int lv_resize(struct logical_volume *lv,
struct cmd_context *cmd = vg->cmd;
struct logical_volume *lock_lv = (struct logical_volume*) lv_lock_holder(lv);
struct logical_volume *aux_lv = NULL; /* Note: aux_lv never resizes fs */
+ struct logical_volume *resizable_layer_lv;
struct lvresize_params aux_lp;
struct lv_segment *seg = first_seg(lv);
int activated = 0;
int ret = 0;
int status;
- if (!_lvresize_check(lv, lp))
- return_0;
-
- if (seg->reshape_len) {
- /* Prevent resizing on out-of-sync reshapable raid */
- if (!lv_raid_in_sync(lv)) {
- log_error("Can't resize reshaping LV %s.", display_lvname(lv));
+ if (lp->use_policies) {
+ if (!lv_is_cow(lv) &&
+ !lv_is_thin_pool(lv)) {
+ log_error("Policy-based resize is supported only for snapshot, thin pool and vdo pool volumes.");
return 0;
}
- /* Remove any striped raid reshape space for LV resizing */
- if (!lv_raid_free_reshape_space(lv))
- return_0;
- }
- if (lp->use_policies) {
lp->extents = 0;
lp->sign = SIGN_PLUS;
lp->percent = PERCENT_LV;
@@ -5549,57 +5569,68 @@ int lv_resize(struct logical_volume *lv,
if (!aux_lp.extents)
return 1; /* Nothing to do */
/* Resize thin-pool metadata as mainlv */
- lv = first_seg(lv)->metadata_lv; /* metadata LV */
+ lv = seg->metadata_lv; /* metadata LV */
lp->extents = aux_lp.extents;
} else if (aux_lp.extents) {
/* Also resize thin-pool metadata */
- aux_lv = _lvresize_setup_aux(first_seg(lv)->metadata_lv, &aux_lp);
+ aux_lv = _lvresize_setup_aux(seg->metadata_lv, &aux_lp);
}
} else if (lp->poolmetadata_size) {
+ /* Validate --poolmetadata_size supported volumes here */
+ if (!lv_is_thin_pool(lv) && !lv_is_thin_pool_metadata(lv)) {
+ log_error("--poolmetadatasize can be used only with thin pools.");
+ return 0;
+ }
if (!lp->extents && !lp->size) {
- /* When only --poolmetadatasize given and not --size
+ /* When only --poolmetadatasize given and any size option
* switch directly to resize metadata LV */
- lv = first_seg(lv)->metadata_lv;
+ if (lv_is_thin_pool(lv))
+ lv = seg->metadata_lv;
lp->size = lp->poolmetadata_size;
lp->sign = lp->poolmetadata_sign;
- } else {
+ lp->poolmetadata_size = 0;
+ } else if (lv_is_thin_pool(lv)) {
aux_lp = *lp;
- aux_lv = _lvresize_setup_aux(first_seg(lv)->metadata_lv, &aux_lp);
+ aux_lv = _lvresize_setup_aux(seg->metadata_lv, &aux_lp);
aux_lp.size = lp->poolmetadata_size;
aux_lp.sign = lp->poolmetadata_sign;
+ } else {
+ log_error("--poolmetadatasize for thin-pool metadata cannot be used with size.");
+ return 0;
}
}
- /* Ensure stripe boundary extents! */
- if (!lp->percent && lv_is_raid(lv))
- lp->extents =_round_to_stripe_boundary(lv->vg, lp->extents,
- seg_is_raid1(seg) ? 0 : _raid_stripes_count(seg),
- lp->resize == LV_REDUCE ? 0 : 1);
- if (aux_lv && !_lvresize_prepare(&aux_lv, &aux_lp, pvh))
+ resizable_layer_lv = _get_resizable_layer_lv(lv);
+ if (!(lv = _get_top_layer_lv(lv)))
+ return_0;
+
+ if (!_lvresize_check(lv, lp))
return_0;
/* Always should have lp->size or lp->extents */
- if (!_lvresize_prepare(&lv, lp, pvh))
+ if (!_lvresize_prepare(resizable_layer_lv, lp, pvh))
return_0;
- if (lp->resize != LV_REDUCE && !aux_lv && !lp->poolmetadata_size &&
- &lv->vg->pvs == pvh && lv_is_thin_pool_data(lv)) {
+ if ((lp->resize != LV_REDUCE) && !aux_lv && !lp->poolmetadata_size &&
+ (&vg->pvs == pvh) && lv_is_thin_pool(lv)) {
/* When thin-pool data part is extended, automatically extend also metadata part
* to have the metadata chunks for adressing all data blocks
* Do this only when PV list is not defined and --poolmetadatasize is unspecified */
aux_lp = *lp;
- seg = get_only_segment_using_this_lv(lv);
- aux_lp.size = estimate_thin_pool_metadata_size(lp->extents, lv->vg->extent_size, seg->chunk_size);
+ seg = first_seg(lv);
+ aux_lp.size = estimate_thin_pool_metadata_size(lp->extents, vg->extent_size, seg->chunk_size);
if (aux_lp.size > seg->metadata_lv->size) {
log_verbose("Also going to resize thin-pool metadata to match bigger data.");
aux_lv = _lvresize_setup_aux(seg->metadata_lv, &aux_lp);
aux_lp.sign = SIGN_NONE;
- if (!_lvresize_prepare(&aux_lv, &aux_lp, pvh))
- return_0;
} else
aux_lp.size = 0;
}
+ if (aux_lv && (aux_lv = _get_resizable_layer_lv(aux_lv)) &&
+ !_lvresize_prepare(aux_lv, &aux_lp, pvh))
+ return_0;
+
if (((lp->resize == LV_REDUCE) ||
(aux_lv && aux_lp.resize == LV_REDUCE)) &&
(pvh != &vg->pvs))
@@ -5669,6 +5700,14 @@ int lv_resize(struct logical_volume *lv,
if (!archive(vg))
return_0;
+ /* Remove any striped raid reshape space for LV resizing */
+ if (aux_lv && first_seg(aux_lv)->reshape_len)
+ if (!lv_raid_free_reshape_space(aux_lv))
+ return_0;
+ if (first_seg(resizable_layer_lv)->reshape_len)
+ if (!lv_raid_free_reshape_space(resizable_layer_lv))
+ return_0;
+
if (aux_lv) {
if (!_lvresize_volume(aux_lv, &aux_lp, pvh))
goto_bad;
@@ -5678,7 +5717,7 @@ int lv_resize(struct logical_volume *lv,
goto_bad;
}
- if (!_lvresize_volume(lv, lp, pvh))
+ if (!_lvresize_volume(resizable_layer_lv, lp, pvh))
goto_bad;
/* store vg on disk(s) */
2 years, 3 months
stable-2.02 - lv_manip: reuse function also during reduction
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=d3a9bf4a56716072dbb...
Commit: d3a9bf4a56716072dbb2d9fdc6abe4d0d89dc95e
Parent: 619ad644ccfe08e91be98ef10f13ecd0caeb956b
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Fri Feb 5 11:37:52 2021 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Tue Feb 9 14:56:10 2021 +0100
lv_manip: reuse function also during reduction
Move function _setup_lv_size() in front of _lv_reduce() so
it can be reused also in this function.
Avoid propagating 0 length to upper layer.
---
lib/metadata/lv_manip.c | 58 ++++++++++++++++++++++++-------------------------
1 file changed, 28 insertions(+), 30 deletions(-)
diff --git a/lib/metadata/lv_manip.c b/lib/metadata/lv_manip.c
index e0bc61fa2..6f21d10b9 100644
--- a/lib/metadata/lv_manip.c
+++ b/lib/metadata/lv_manip.c
@@ -1317,6 +1317,29 @@ static int _lv_segment_reduce(struct lv_segment *seg, uint32_t reduction)
return 1;
}
+/* Handles also stacking */
+static int _setup_lv_size(struct logical_volume *lv, uint32_t extents)
+{
+ struct lv_segment *seg;
+
+ lv->le_count = extents;
+ lv->size = (uint64_t) extents * lv->vg->extent_size;
+
+ if (lv->size &&
+ (lv_is_thin_pool_data(lv))) {
+ if (!(seg = get_only_segment_using_this_lv(lv)))
+ return_0;
+
+ /* Update pool segment from the layered LV */
+ seg->lv->le_count =
+ seg->len =
+ seg->area_len = lv->le_count;
+ seg->lv->size = lv->size;
+ }
+
+ return 1;
+}
+
/*
* Entry point for all LV reductions in size.
*/
@@ -1397,18 +1420,15 @@ static int _lv_reduce(struct logical_volume *lv, uint32_t extents, int delete)
count -= reduction;
}
- seg = first_seg(lv);
+ if (!_setup_lv_size(lv, lv->le_count - extents * (is_raid10 ? data_copies : 1)))
+ return_0;
- if (is_raid10) {
- lv->le_count -= extents * data_copies;
- if (seg)
+ if ((seg = first_seg(lv))) {
+ if (is_raid10)
seg->len = seg->area_len = lv->le_count;
- } else
- lv->le_count -= extents;
- lv->size = (uint64_t) lv->le_count * lv->vg->extent_size;
- if (seg)
seg->extents_copied = seg->len;
+ }
if (!delete)
return 1;
@@ -1795,28 +1815,6 @@ static void _init_alloc_parms(struct alloc_handle *ah,
alloc_parms->flags |= A_CAN_SPLIT;
}
-/* Handles also stacking */
-static int _setup_lv_size(struct logical_volume *lv, uint32_t extents)
-{
- struct lv_segment *thin_pool_seg;
-
- lv->le_count = extents;
- lv->size = (uint64_t) extents * lv->vg->extent_size;
-
- if (lv_is_thin_pool_data(lv)) {
- if (!(thin_pool_seg = get_only_segment_using_this_lv(lv)))
- return_0;
-
- /* Update thin pool segment from the layered LV */
- thin_pool_seg->lv->le_count =
- thin_pool_seg->len =
- thin_pool_seg->area_len = lv->le_count;
- thin_pool_seg->lv->size = lv->size;
- }
-
- return 1;
-}
-
static int _setup_alloced_segment(struct logical_volume *lv, uint64_t status,
uint32_t area_count,
uint32_t stripe_size,
2 years, 3 months
stable-2.02 - lv_resize: use 'bad' code path for error case
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=619ad644ccfe08e91be...
Commit: 619ad644ccfe08e91be98ef10f13ecd0caeb956b
Parent: 6c99725261a53c6d984fa262980aab0df2ae6d62
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Sun Feb 7 00:39:13 2021 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Tue Feb 9 14:45:29 2021 +0100
lv_resize: use 'bad' code path for error case
---
lib/metadata/lv_manip.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lib/metadata/lv_manip.c b/lib/metadata/lv_manip.c
index c37757e9a..e0bc61fa2 100644
--- a/lib/metadata/lv_manip.c
+++ b/lib/metadata/lv_manip.c
@@ -5712,7 +5712,7 @@ out:
if (lp->resizefs && (lp->resize == LV_EXTEND) &&
!_fsadm_cmd(FSADM_CMD_RESIZE, lv, lp->extents, lp->yes, lp->force, NULL))
- return_0;
+ goto_bad;
ret = 1;
bad:
2 years, 3 months
stable-2.02 - thin: check for overprovisioning only once
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=6c99725261a53c6d984...
Commit: 6c99725261a53c6d984fa262980aab0df2ae6d62
Parent: cfb9bf13c7073937591fa4dc4a0a93a975016bb1
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Sun Feb 7 00:37:37 2021 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Tue Feb 9 14:45:29 2021 +0100
thin: check for overprovisioning only once
---
lib/metadata/lv_manip.c | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/lib/metadata/lv_manip.c b/lib/metadata/lv_manip.c
index 33624148c..c37757e9a 100644
--- a/lib/metadata/lv_manip.c
+++ b/lib/metadata/lv_manip.c
@@ -5449,10 +5449,6 @@ static int _lvresize_volume(struct logical_volume *lv,
lp->extents - lv->le_count,
pvh, alloc, lp->approx_alloc))
return_0;
- /* Check for over provisioning only when lv_extend() passed,
- * ATM this check does not fail */
- else if (!pool_check_overprovisioning(lv))
- return_0;
if (old_extents == lv->le_count)
log_print_unless_silent("Size of logical volume %s unchanged from %s (%" PRIu32 " extents).",
@@ -5705,6 +5701,11 @@ int lv_resize(struct logical_volume *lv,
backup(vg);
}
+
+ /* Check for over provisioning when extended */
+ if ((lp->resize == LV_EXTEND) && lv_is_thin_type(lv))
+ pool_check_overprovisioning(lv);
+
out:
log_print_unless_silent("Logical volume %s successfully resized.",
display_lvname(lv));
2 years, 3 months
stable-2.02 - thinpool: use lv_config_profil for crop_metadata
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=cfb9bf13c7073937591...
Commit: cfb9bf13c7073937591fa4dc4a0a93a975016bb1
Parent: 18677e24c1ab6e9dff36c048d9e3f6a7fe541c4b
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Thu Feb 4 23:26:08 2021 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Tue Feb 9 14:45:29 2021 +0100
thinpool: use lv_config_profil for crop_metadata
Better support for thin-pools with individual profiles introduced
in the recent patch b4212be2e7e8797bbf8f9a166347659cc39ba075.
---
lib/metadata/lv_manip.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lib/metadata/lv_manip.c b/lib/metadata/lv_manip.c
index e48e5d18f..33624148c 100644
--- a/lib/metadata/lv_manip.c
+++ b/lib/metadata/lv_manip.c
@@ -5209,7 +5209,7 @@ static int _lvresize_adjust_extents(struct logical_volume *lv,
if (!(seg = get_only_segment_using_this_lv(lv)))
return_0;
- max_metadata_size = get_thin_pool_max_metadata_size(cmd, vg->profile, &crop);
+ max_metadata_size = get_thin_pool_max_metadata_size(cmd, lv_config_profile(lv), &crop);
if (((uint64_t)lp->extents * vg->extent_size) > max_metadata_size) {
lp->extents = (max_metadata_size + vg->extent_size - 1) / vg->extent_size;
2 years, 3 months
main - dev-type: sysfs attrs without sectors
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=427121efc76f1a11df5...
Commit: 427121efc76f1a11df5d06c11ea4f095305b6333
Parent: ef2e0d3d680829ad4f4253787cd7a0db0c4597d6
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Tue Feb 9 00:43:13 2021 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Tue Feb 9 00:49:14 2021 +0100
dev-type: sysfs attrs without sectors
Split function for reading attrs in sectors.
---
lib/device/dev-type.c | 56 +++++++++++++++++++++++++++++++++------------------
1 file changed, 36 insertions(+), 20 deletions(-)
diff --git a/lib/device/dev-type.c b/lib/device/dev-type.c
index 11add4b6b..b7bca361f 100644
--- a/lib/device/dev-type.c
+++ b/lib/device/dev-type.c
@@ -936,17 +936,16 @@ static int _snprintf_attr(char *buf, size_t buf_size, const char *sysfs_dir,
return 1;
}
-static unsigned long _dev_topology_attribute(struct dev_types *dt,
- const char *attribute,
- struct device *dev,
- unsigned long default_value)
+static int _dev_sysfs_block_attribute(struct dev_types *dt,
+ const char *attribute,
+ struct device *dev,
+ unsigned long *value)
{
const char *sysfs_dir = dm_sysfs_dir();
char path[PATH_MAX], buffer[64];
FILE *fp;
dev_t primary = 0;
- unsigned long result = default_value;
- unsigned long value = 0UL;
+ int ret = 0;
if (!attribute || !*attribute)
goto_out;
@@ -955,7 +954,7 @@ static unsigned long _dev_topology_attribute(struct dev_types *dt,
goto_out;
if (!_snprintf_attr(path, sizeof(path), sysfs_dir, attribute, dev->dev))
- goto_out;
+ goto_out;
/*
* check if the desired sysfs attribute exists
@@ -986,27 +985,42 @@ static unsigned long _dev_topology_attribute(struct dev_types *dt,
goto out_close;
}
- if (sscanf(buffer, "%lu", &value) != 1) {
+ if (sscanf(buffer, "%lu", value) != 1) {
log_warn("WARNING: sysfs file %s not in expected format: %s", path, buffer);
goto out_close;
}
- log_very_verbose("Device %s: %s is %lu%s.",
- dev_name(dev), attribute, value, default_value ? "" : " bytes");
-
- result = value >> SECTOR_SHIFT;
-
- if (!result && value) {
- log_warn("WARNING: Device %s: %s is %lu and is unexpectedly less than sector.",
- dev_name(dev), attribute, value);
- result = 1;
- }
+ ret = 1;
out_close:
if (fclose(fp))
log_sys_debug("fclose", path);
out:
+ return ret;
+}
+
+static unsigned long _dev_topology_attribute(struct dev_types *dt,
+ const char *attribute,
+ struct device *dev,
+ unsigned long default_value)
+{
+ unsigned long result = default_value;
+ unsigned long value = 0UL;
+
+ if (_dev_sysfs_block_attribute(dt, attribute, dev, &value)) {
+ log_very_verbose("Device %s: %s is %lu%s.",
+ dev_name(dev), attribute, value, default_value ? "" : " bytes");
+
+ result = value >> SECTOR_SHIFT;
+
+ if (!result && value) {
+ log_warn("WARNING: Device %s: %s is %lu and is unexpectedly less than sector.",
+ dev_name(dev), attribute, value);
+ result = 1;
+ }
+ }
+
return result;
}
@@ -1037,13 +1051,15 @@ unsigned long dev_discard_granularity(struct dev_types *dt, struct device *dev)
int dev_is_rotational(struct dev_types *dt, struct device *dev)
{
- return (int) _dev_topology_attribute(dt, "queue/rotational", dev, 1UL);
+ unsigned long value;
+ return _dev_sysfs_block_attribute(dt, "queue/rotational", dev, &value) ? (int) value : 1;
}
/* dev is pmem if /sys/dev/block/<major>:<minor>/queue/dax is 1 */
int dev_is_pmem(struct dev_types *dt, struct device *dev)
{
- return (int) _dev_topology_attribute(dt, "queue/dax", dev, 0UL);
+ unsigned long value;
+ return _dev_sysfs_block_attribute(dt, "queue/dax", dev, &value) ? (int) value : 0;
}
#else
2 years, 4 months
main - typo: fixes
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=ef2e0d3d680829ad4f4...
Commit: ef2e0d3d680829ad4f4253787cd7a0db0c4597d6
Parent: d280999b62c61b9769eb5c3a01a19fa54461259d
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Mon Feb 8 23:51:56 2021 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Mon Feb 8 23:53:41 2021 +0100
typo: fixes
forgotten merge from last batch.
---
lib/snapshot/snapshot.c | 2 +-
lib/writecache/writecache.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/lib/snapshot/snapshot.c b/lib/snapshot/snapshot.c
index b832f890d..8446a6914 100644
--- a/lib/snapshot/snapshot.c
+++ b/lib/snapshot/snapshot.c
@@ -154,7 +154,7 @@ static int _snap_target_present(struct cmd_context *cmd,
if (!(_snap_present = (target_present_version(cmd, TARGET_NAME_SNAPSHOT, 1,
&maj, &min, &patchlevel) &&
- target_present(cmd, TARGET_NAME_SNAPSHOT_ORIGIN, 0)))
+ target_present(cmd, TARGET_NAME_SNAPSHOT_ORIGIN, 0))))
return 0;
if ((maj > 1 ||
diff --git a/lib/writecache/writecache.c b/lib/writecache/writecache.c
index d114d698c..aa2113271 100644
--- a/lib/writecache/writecache.c
+++ b/lib/writecache/writecache.c
@@ -238,7 +238,7 @@ static int _target_present(struct cmd_context *cmd,
if (!_writecache_checked) {
_writecache_checked = 1;
- if (!(_writecache_present = target_present_version(cmd, TARGET_NAME_WRITECACHE, 1.
+ if (!(_writecache_present = target_present_version(cmd, TARGET_NAME_WRITECACHE, 1,
&maj, &min, &patchlevel)))
return 0;
2 years, 4 months