master - libdm: ensure first extent is always counted
by Bryn Reeves
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=f4401fe351f636...
Commit: f4401fe351f63679ae8f4bab448a9283fb631a4a
Parent: fce7449d7311b49839f339b714c48e953e9a837a
Author: Bryn M. Reeves <bmr(a)redhat.com>
AuthorDate: Tue Dec 13 21:36:11 2016 +0000
Committer: Bryn M. Reeves <bmr(a)redhat.com>
CommitterDate: Tue Dec 13 21:41:31 2016 +0000
libdm: ensure first extent is always counted
If FIEMAP returns a single extent after the first call, no extent
boundary is detected and the first extent is not counted by the
normal mechanism.
In this case, increment nr_extents at the same time the extent is
added to the region table, before returning.
---
libdm/libdm-stats.c | 4 +++-
1 files changed, 3 insertions(+), 1 deletions(-)
diff --git a/libdm/libdm-stats.c b/libdm/libdm-stats.c
index 02a30dc..8d202d2 100644
--- a/libdm/libdm-stats.c
+++ b/libdm/libdm-stats.c
@@ -4286,8 +4286,10 @@ static uint64_t _stats_map_extents(struct dm_pool *mem,
* If the file only has a single extent, no boundary is ever
* detected to trigger addition of the first extent.
*/
- if (fm_ext[i - 1].fe_logical == 0)
+ if (fm_ext[i - 1].fe_logical == 0) {
_stats_add_extent(mem, fm_pending, nr_extents);
+ nr_extents++;
+ }
fiemap->fm_start = (fm_ext[i - 1].fe_logical +
fm_ext[i - 1].fe_length);
6 years, 9 months
master - cleanup: remove wrapping function
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=fce7449d7311b4...
Commit: fce7449d7311b49839f339b714c48e953e9a837a
Parent: c7da16e5f162193db16f2a1845200fc99ed6ebc3
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Tue Dec 13 12:28:12 2016 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Tue Dec 13 22:07:52 2016 +0100
cleanup: remove wrapping function
backup is not 'tested' for success and also it should
actually happen just when command is finished.
We do not target to make backups with each inter-step
metadata change.
---
lib/metadata/raid_manip.c | 23 ++++++-----------------
1 files changed, 6 insertions(+), 17 deletions(-)
diff --git a/lib/metadata/raid_manip.c b/lib/metadata/raid_manip.c
index 56fe6a7..049102a 100644
--- a/lib/metadata/raid_manip.c
+++ b/lib/metadata/raid_manip.c
@@ -226,21 +226,6 @@ static void _clear_allocation_prohibited(struct dm_list *pvs)
pvl->pv->status &= ~PV_ALLOCATION_PROHIBITED;
}
-/* FIXME Move this out */
-/* Write, commit and optionally backup metadata of vg */
-static int _vg_write_commit_backup(struct volume_group *vg)
-{
- if (!vg_write(vg) || !vg_commit(vg)) {
- log_error("Failed to commit VG %s metadata.", vg->name);
- return 0;
- }
-
- if (!backup(vg))
- log_warn("WARNING: Backup of VG %s metadata failed. Continuing.", vg->name);
-
- return 1;
-}
-
/*
* Deactivate and remove the LVs on removal_lvs list from vg.
*/
@@ -1898,8 +1883,12 @@ static int _eliminate_extracted_lvs_optional_write_vg(struct volume_group *vg,
dm_list_init(removal_lvs);
- if (vg_write_requested && !_vg_write_commit_backup(vg))
- return_0;
+ if (vg_write_requested) {
+ if (!vg_write(vg) || !vg_commit(vg))
+ return_0;
+
+ backup(vg);
+ }
return 1;
}
6 years, 9 months
master - cleanup: log message updates
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=c7da16e5f16219...
Commit: c7da16e5f162193db16f2a1845200fc99ed6ebc3
Parent: a8f5e1f2744a568779445aa5def423f7e1210ee7
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Tue Dec 13 00:10:01 2016 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Tue Dec 13 22:07:52 2016 +0100
cleanup: log message updates
---
lib/metadata/raid_manip.c | 42 ++++++++++++++++++++++++------------------
1 files changed, 24 insertions(+), 18 deletions(-)
diff --git a/lib/metadata/raid_manip.c b/lib/metadata/raid_manip.c
index 81e2ac2..56fe6a7 100644
--- a/lib/metadata/raid_manip.c
+++ b/lib/metadata/raid_manip.c
@@ -1056,8 +1056,10 @@ static int _extract_image_components(struct lv_segment *seg, uint32_t idx,
struct logical_volume *data_lv = seg_lv(seg, idx);
struct logical_volume *meta_lv = seg_metalv(seg, idx);
- log_very_verbose("Extracting image components %s and %s from %s",
- data_lv->name, meta_lv->name, seg->lv->name);
+ log_very_verbose("Extracting image components %s and %s from %s.",
+ display_lvname(data_lv),
+ display_lvname(meta_lv),
+ display_lvname(seg->lv));
data_lv->status &= ~RAID_IMAGE;
meta_lv->status &= ~RAID_META;
@@ -1185,8 +1187,9 @@ static int _raid_extract_images(struct logical_volume *lv,
}
}
if (!_extract_image_components(seg, s, &rmeta_lv, &rimage_lv)) {
- log_error("Failed to extract %s from %s",
- seg_lv(seg, s)->name, lv->name);
+ log_error("Failed to extract %s from %s.",
+ display_lvname(seg_lv(seg, s)),
+ display_lvname(lv));
return 0;
}
@@ -1362,7 +1365,7 @@ int lv_raid_split(struct logical_volume *lv, const char *split_name,
if (!lv_is_on_pvs(tracking, splittable_pvs)) {
log_error("Unable to split additional image from %s "
"while tracking changes for %s.",
- display_lvname(lv), tracking->name);
+ display_lvname(lv), display_lvname(tracking));
return 0;
}
@@ -1502,7 +1505,7 @@ int lv_raid_split_and_track(struct logical_volume *lv,
}
if (s < 0) {
- log_error("Unable to find image to satisfy request");
+ log_error("Unable to find image to satisfy request.");
return 0;
}
@@ -2042,12 +2045,12 @@ static int _adjust_data_lvs(struct logical_volume *lv, enum mirror_raid_conv dir
dlv = seg_lv(seg, s);
if (!(sublv_name_suffix = first_substring(dlv->name, "_mimage_", "_rimage_", NULL))) {
- log_error(INTERNAL_ERROR "name lags image part");
+ log_error(INTERNAL_ERROR "Name %s lags image part.", dlv->name);
return 0;
}
*(sublv_name_suffix + 1) = conv[direction].type_char;
- log_debug_metadata("data LV renamed to %s.", display_lvname(dlv));
+ log_debug_metadata("Data LV renamed to %s.", display_lvname(dlv));
dlv->status &= ~conv[direction].reset_flag;
dlv->status |= conv[direction].set_flag;
@@ -3084,7 +3087,7 @@ static int _raid456_to_raid0_or_striped_wrapper(TAKEOVER_FN_ARGS)
if (!yes && yes_no_prompt("Are you sure you want to convert \"%s\" LV %s to \"%s\" "
"type losing all resilience? [y/n]: ",
lvseg_name(seg), display_lvname(lv), new_segtype->name) == 'n') {
- log_error("Logical volume %s NOT converted to \"%s\"",
+ log_error("Logical volume %s NOT converted to \"%s\".",
display_lvname(lv), new_segtype->name);
return 0;
}
@@ -3108,7 +3111,8 @@ static int _raid456_to_raid0_or_striped_wrapper(TAKEOVER_FN_ARGS)
if (segtype_is_any_raid0(new_segtype) &&
!(rename_sublvs = _rename_area_lvs(lv, "_"))) {
- log_error("Failed to rename %s LV %s MetaLVs", lvseg_name(seg), display_lvname(lv));
+ log_error("Failed to rename %s LV %s MetaLVs.",
+ lvseg_name(seg), display_lvname(lv));
return 0;
}
@@ -3138,7 +3142,8 @@ static int _raid456_to_raid0_or_striped_wrapper(TAKEOVER_FN_ARGS)
if (rename_sublvs) {
if (!_rename_area_lvs(lv, NULL)) {
- log_error("Failed to rename %s LV %s MetaLVs", lvseg_name(seg), display_lvname(lv));
+ log_error("Failed to rename %s LV %s MetaLVs.",
+ lvseg_name(seg), display_lvname(lv));
return 0;
}
if (!lv_update_and_reload(lv))
@@ -3181,19 +3186,19 @@ static int _striped_or_raid0_to_raid45610_wrapper(TAKEOVER_FN_ARGS)
return _takeover_unsupported_yet(lv, new_stripes, new_segtype);
if (new_data_copies > new_image_count) {
- log_error("N number of data_copies \"--mirrors N-1\" may not be larger than number of stripes");
+ log_error("N number of data_copies \"--mirrors N-1\" may not be larger than number of stripes.");
return 0;
}
if (new_stripes && new_stripes != seg->area_count) {
- log_error("Can't restripe LV %s during conversion", display_lvname(lv));
+ log_error("Can't restripe LV %s during conversion.", display_lvname(lv));
return 0;
}
/* FIXME: restricted to raid4 for the time being... */
if (!segtype_is_raid4(new_segtype)) {
/* Can't convert striped/raid0* to e.g. raid10_offset */
- log_error("Can't convert %s to %s", display_lvname(lv), new_segtype->name);
+ log_error("Can't convert %s to %s.", display_lvname(lv), new_segtype->name);
return 0;
}
@@ -3211,7 +3216,7 @@ static int _striped_or_raid0_to_raid45610_wrapper(TAKEOVER_FN_ARGS)
/* Add metadata LVs */
if (seg_is_raid0(seg)) {
- log_debug_metadata("Adding metadata LVs to %s", display_lvname(lv));
+ log_debug_metadata("Adding metadata LVs to %s.", display_lvname(lv));
if (!_raid0_add_or_remove_metadata_lvs(lv, 1 /* update_and_reload */, allocate_pvs, NULL))
return_0;
/* raid0_meta -> raid4 needs clearing of MetaLVs in order to avoid raid disk role cahnge issues in the kernel */
@@ -3220,7 +3225,8 @@ static int _striped_or_raid0_to_raid45610_wrapper(TAKEOVER_FN_ARGS)
return_0;
/* Add the additional component LV pairs */
- log_debug_metadata("Adding %" PRIu32 " component LV pair(s) to %s", new_image_count - lv_raid_image_count(lv),
+ log_debug_metadata("Adding %" PRIu32 " component LV pair(s) to %s.",
+ new_image_count - lv_raid_image_count(lv),
display_lvname(lv));
if (!_lv_raid_change_image_count(lv, new_image_count, allocate_pvs, NULL, 0, 1))
return_0;
@@ -3228,7 +3234,7 @@ static int _striped_or_raid0_to_raid45610_wrapper(TAKEOVER_FN_ARGS)
if (segtype_is_raid4(new_segtype) &&
(!_shift_parity_dev(seg) ||
!_rename_area_lvs(lv, "_"))) {
- log_error("Can't convert %s to %s", display_lvname(lv), new_segtype->name);
+ log_error("Can't convert %s to %s.", display_lvname(lv), new_segtype->name);
return 0;
}
@@ -3239,7 +3245,7 @@ static int _striped_or_raid0_to_raid45610_wrapper(TAKEOVER_FN_ARGS)
_check_and_adjust_region_size(lv);
- log_debug_metadata("Updating VG metadata and reloading %s LV %s",
+ log_debug_metadata("Updating VG metadata and reloading %s LV %s.",
lvseg_name(seg), display_lvname(lv));
if (!_lv_update_reload_fns_reset_eliminate_lvs(lv, NULL))
return_0;
6 years, 9 months
master - cleanup: more lv_is_ usage
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=a8f5e1f2744a56...
Commit: a8f5e1f2744a568779445aa5def423f7e1210ee7
Parent: 47b96c3537968caf0cfb8ffa3874d64944715bec
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Tue Dec 13 00:09:15 2016 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Tue Dec 13 22:07:52 2016 +0100
cleanup: more lv_is_ usage
---
lib/format1/import-export.c | 2 +-
lib/format1/import-extents.c | 2 +-
lib/format_pool/import_export.c | 2 +-
lib/format_text/import_vsn1.c | 2 +-
lib/locking/lvmlockd.c | 2 +-
lib/metadata/lv.c | 2 +-
lib/metadata/lv_manip.c | 7 +++----
lib/metadata/raid_manip.c | 2 +-
lib/metadata/snapshot_manip.c | 2 +-
tools/toollib.c | 2 +-
tools/vgchange.c | 4 ++--
tools/vgconvert.c | 2 +-
tools/vgsplit.c | 4 ++--
13 files changed, 17 insertions(+), 18 deletions(-)
diff --git a/lib/format1/import-export.c b/lib/format1/import-export.c
index 9b7f5ef..146623e 100644
--- a/lib/format1/import-export.c
+++ b/lib/format1/import-export.c
@@ -510,7 +510,7 @@ int export_lvs(struct disk_list *dl, struct volume_group *vg,
goto_out;
dm_list_iterate_items(ll, &vg->lvs) {
- if (ll->lv->status & SNAPSHOT)
+ if (lv_is_snapshot(ll->lv))
continue;
if (!(lvdl = dm_pool_alloc(dl->mem, sizeof(*lvdl))))
diff --git a/lib/format1/import-extents.c b/lib/format1/import-extents.c
index 5cad4f2..3ab3ac4 100644
--- a/lib/format1/import-extents.c
+++ b/lib/format1/import-extents.c
@@ -56,7 +56,7 @@ static struct dm_hash_table *_create_lv_maps(struct dm_pool *mem,
}
dm_list_iterate_items(ll, &vg->lvs) {
- if (ll->lv->status & SNAPSHOT)
+ if (lv_is_snapshot(ll->lv))
continue;
if (!(lvm = dm_pool_alloc(mem, sizeof(*lvm))))
diff --git a/lib/format_pool/import_export.c b/lib/format_pool/import_export.c
index 1529df5..2f0f2eb 100644
--- a/lib/format_pool/import_export.c
+++ b/lib/format_pool/import_export.c
@@ -267,7 +267,7 @@ int import_pool_segments(struct dm_list *lvs, struct dm_pool *mem,
dm_list_iterate_items(lvl, lvs) {
lv = lvl->lv;
- if (lv->status & SNAPSHOT)
+ if (lv_is_snapshot(lv))
continue;
for (i = 0; i < subpools; i++) {
diff --git a/lib/format_text/import_vsn1.c b/lib/format_text/import_vsn1.c
index e11b16b..00caf21 100644
--- a/lib/format_text/import_vsn1.c
+++ b/lib/format_text/import_vsn1.c
@@ -512,7 +512,7 @@ static int _read_segments(struct logical_volume *lv, const struct dm_config_node
count++;
}
/* FIXME Remove this restriction */
- if ((lv->status & SNAPSHOT) && count > 1) {
+ if (lv_is_snapshot(lv) && count > 1) {
log_error("Only one segment permitted for snapshot");
return 0;
}
diff --git a/lib/locking/lvmlockd.c b/lib/locking/lvmlockd.c
index 8acf69c..92a970a 100644
--- a/lib/locking/lvmlockd.c
+++ b/lib/locking/lvmlockd.c
@@ -2651,7 +2651,7 @@ int lockd_lv_uses_lock(struct logical_volume *lv)
if (lv_is_cow(lv))
return 0;
- if (lv->status & SNAPSHOT)
+ if (lv_is_snapshot(lv))
return 0;
/* FIXME: lv_is_virtual_origin ? */
diff --git a/lib/metadata/lv.c b/lib/metadata/lv.c
index 8f13f6b..1084149 100644
--- a/lib/metadata/lv.c
+++ b/lib/metadata/lv.c
@@ -971,7 +971,7 @@ int lv_mirror_image_in_sync(const struct logical_volume *lv)
struct lv_segment *seg = first_seg(lv);
struct lv_segment *mirror_seg;
- if (!(lv->status & MIRROR_IMAGE) || !seg ||
+ if (!lv_is_mirror_image(lv) || !seg ||
!(mirror_seg = find_mirror_seg(seg))) {
log_error(INTERNAL_ERROR "Cannot find mirror segment.");
return 0;
diff --git a/lib/metadata/lv_manip.c b/lib/metadata/lv_manip.c
index fdfee36..211b190 100644
--- a/lib/metadata/lv_manip.c
+++ b/lib/metadata/lv_manip.c
@@ -1139,7 +1139,8 @@ int set_lv_segment_area_lv(struct lv_segment *seg, uint32_t area_num,
display_lvname(seg->lv), seg->le, area_num,
display_lvname(lv), le);
- if (status & RAID_META) {
+ lv->status |= status;
+ if (lv_is_raid_metadata(lv)) {
seg->meta_areas[area_num].type = AREA_LV;
seg_metalv(seg, area_num) = lv;
if (le) {
@@ -1152,7 +1153,6 @@ int set_lv_segment_area_lv(struct lv_segment *seg, uint32_t area_num,
seg_lv(seg, area_num) = lv;
seg_le(seg, area_num) = le;
}
- lv->status |= status;
if (!add_seg_to_segs_using_this_lv(lv, seg))
return_0;
@@ -4678,8 +4678,7 @@ static int _lvresize_check(struct logical_volume *lv,
if (lv_is_raid_image(lv) || lv_is_raid_metadata(lv)) {
log_error("Cannot resize a RAID %s directly",
- (lv->status & RAID_IMAGE) ? "image" :
- "metadata area");
+ lv_is_raid_image(lv) ? "image" : "metadata area");
return 0;
}
diff --git a/lib/metadata/raid_manip.c b/lib/metadata/raid_manip.c
index b8a47c0..81e2ac2 100644
--- a/lib/metadata/raid_manip.c
+++ b/lib/metadata/raid_manip.c
@@ -135,7 +135,7 @@ static int _lv_is_raid_with_tracking(const struct logical_volume *lv,
*tracking = NULL;
- if (!(lv->status & RAID))
+ if (!lv_is_raid(lv))
return 0;
for (s = 0; s < seg->area_count; s++)
diff --git a/lib/metadata/snapshot_manip.c b/lib/metadata/snapshot_manip.c
index 2f13ac9..b5fb60c 100644
--- a/lib/metadata/snapshot_manip.c
+++ b/lib/metadata/snapshot_manip.c
@@ -121,7 +121,7 @@ int lv_is_visible(const struct logical_volume *lv)
if (lv_is_historical(lv))
return 1;
- if (lv->status & SNAPSHOT)
+ if (lv_is_snapshot(lv))
return 0;
if (lv_is_cow(lv)) {
diff --git a/tools/toollib.c b/tools/toollib.c
index 9f399b8..235e535 100644
--- a/tools/toollib.c
+++ b/tools/toollib.c
@@ -2402,7 +2402,7 @@ int process_each_lv_in_vg(struct cmd_context *cmd, struct volume_group *vg,
goto_out;
}
- if (lvl->lv->status & SNAPSHOT)
+ if (lv_is_snapshot(lvl->lv))
continue;
/* Skip availability change for non-virt snaps when processing all LVs */
diff --git a/tools/vgchange.c b/tools/vgchange.c
index 455f688..ca0f450 100644
--- a/tools/vgchange.c
+++ b/tools/vgchange.c
@@ -107,11 +107,11 @@ static int _activate_lvs_in_vg(struct cmd_context *cmd, struct volume_group *vg,
lv = origin_from_cow(lv);
/* Only request activation of snapshot origin devices */
- if ((lv->status & SNAPSHOT) || lv_is_cow(lv))
+ if (lv_is_snapshot(lv) || lv_is_cow(lv))
continue;
/* Only request activation of mirror LV */
- if ((lv->status & MIRROR_IMAGE) || (lv->status & MIRROR_LOG))
+ if (lv_is_mirror_image(lv) || lv_is_mirror_log(lv))
continue;
/* Only request activation of the first replicator-dev LV */
diff --git a/tools/vgconvert.c b/tools/vgconvert.c
index 4f28ba3..2c0ac08 100644
--- a/tools/vgconvert.c
+++ b/tools/vgconvert.c
@@ -97,7 +97,7 @@ static int vgconvert_single(struct cmd_context *cmd, const char *vg_name,
if (cmd->fmt->features & FMT_RESTRICTED_LVIDS) {
dm_list_iterate_items(lvl, &vg->lvs) {
lv = lvl->lv;
- if (lv->status & SNAPSHOT)
+ if (lv_is_snapshot(lv))
continue;
if (lvnum_from_lvid(&lv->lvid) < MAX_RESTRICTED_LVS)
continue;
diff --git a/tools/vgsplit.c b/tools/vgsplit.c
index 52f603f..e2ba6f7 100644
--- a/tools/vgsplit.c
+++ b/tools/vgsplit.c
@@ -112,7 +112,7 @@ static int _move_lvs(struct volume_group *vg_from, struct volume_group *vg_to)
dm_list_iterate_safe(lvh, lvht, &vg_from->lvs) {
lv = dm_list_item(lvh, struct lv_list)->lv;
- if ((lv->status & SNAPSHOT))
+ if (lv_is_snapshot(lv))
continue;
if (lv_is_raid(lv))
@@ -193,7 +193,7 @@ static int _move_snapshots(struct volume_group *vg_from,
dm_list_iterate_safe(lvh, lvht, &vg_from->lvs) {
lv = dm_list_item(lvh, struct lv_list)->lv;
- if (!(lv->status & SNAPSHOT))
+ if (!lv_is_snapshot(lv))
continue;
dm_list_iterate_items(seg, &lv->segments) {
6 years, 9 months
master - cleanup: allocate NAME_LEN size for lv name
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=47b96c3537968c...
Commit: 47b96c3537968caf0cfb8ffa3874d64944715bec
Parent: d0fe3ec0c58ccd5dfcc4f5fd40ddabab0c9defe5
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Tue Dec 13 00:09:38 2016 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Tue Dec 13 22:07:52 2016 +0100
cleanup: allocate NAME_LEN size for lv name
---
lib/metadata/raid_manip.c | 18 ++++++++++--------
1 files changed, 10 insertions(+), 8 deletions(-)
diff --git a/lib/metadata/raid_manip.c b/lib/metadata/raid_manip.c
index c70ce3e..b8a47c0 100644
--- a/lib/metadata/raid_manip.c
+++ b/lib/metadata/raid_manip.c
@@ -548,18 +548,15 @@ static char *_generate_raid_name(struct logical_volume *lv,
const char *suffix, int count)
{
const char *format = (count >= 0) ? "%s_%s_%u" : "%s_%s";
- size_t len = strlen(lv->name) + strlen(suffix) + ((count >= 0) ? 5 : 2);
- char *name;
+ char name[NAME_LEN], *lvname;
int historical;
- if (!(name = dm_pool_alloc(lv->vg->vgmem, len))) {
- log_error("Failed to allocate new name.");
+ if (dm_snprintf(name, sizeof(name), format, lv->name, suffix, count) < 0) {
+ log_error("Failed to new raid name for %s.",
+ display_lvname(lv));
return NULL;
}
- if (dm_snprintf(name, len, format, lv->name, suffix, count) < 0)
- return_NULL;
-
if (!validate_name(name)) {
log_error("New logical volume name \"%s\" is not valid.", name);
return NULL;
@@ -571,7 +568,12 @@ static char *_generate_raid_name(struct logical_volume *lv,
return NULL;
}
- return name;
+ if (!(lvname = dm_pool_strdup(lv->vg->vgmem, name))) {
+ log_error("Failed to allocate new name.");
+ return NULL;
+ }
+
+ return lvname;
}
/*
* Create an LV of specified type. Set visible after creation.
6 years, 9 months
master - raid: avoid manipulation of segment status
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=d0fe3ec0c58ccd...
Commit: d0fe3ec0c58ccd5dfcc4f5fd40ddabab0c9defe5
Parent: d1e398c474032716679f704008026b5d17e9469a
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Tue Dec 13 14:52:06 2016 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Tue Dec 13 22:07:52 2016 +0100
raid: avoid manipulation of segment status
RAID is LV property
TODO: only 2 flags are seg->status: PVMOVE & MERGING
At least the second one should be soon elimanted as again
we merge LV not a segment.
---
WHATS_NEW | 1 +
lib/metadata/raid_manip.c | 6 ++----
lib/raid/raid.c | 1 -
3 files changed, 3 insertions(+), 5 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index 0561074..60e8fa5 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.169 -
=====================================
+ Do not use LV RAID status bit for segment status.
Check segtype directly instead of checking RAID in segment status.
Reusing exiting code for raid image removal.
Fix pvmove leaving -pvmove0 error device in clustered VG.
diff --git a/lib/metadata/raid_manip.c b/lib/metadata/raid_manip.c
index f2c0b26..c70ce3e 100644
--- a/lib/metadata/raid_manip.c
+++ b/lib/metadata/raid_manip.c
@@ -1701,7 +1701,7 @@ static int _alloc_and_add_new_striped_segment(struct logical_volume *lv,
/* Allocate a segment with seg->area_count areas */
if (!(new_seg = alloc_lv_segment(striped_segtype, lv, le, area_len * seg->area_count,
- seg->status & ~RAID,
+ 0,
seg->stripe_size, NULL, seg->area_count,
area_len, seg->chunk_size, 0, 0, NULL)))
return_0;
@@ -2150,7 +2150,6 @@ static int _convert_mirror_to_raid1(struct logical_volume *lv,
lv->status &= ~MIRROR;
lv->status &= ~MIRRORED;
lv->status |= RAID;
- seg->status |= RAID;
if (!lv_update_and_reload(lv))
return_0;
@@ -2220,7 +2219,6 @@ static int _convert_raid1_to_mirror(struct logical_volume *lv,
seg->segtype = new_segtype;
seg->region_size = new_region_size;
lv->status &= ~RAID;
- seg->status &= ~RAID;
lv->status |= (MIRROR | MIRRORED);
if (!attach_mirror_log(first_seg(lv), log_lv))
@@ -2473,7 +2471,7 @@ static struct lv_segment *_convert_striped_to_raid0(struct logical_volume *lv,
seg = first_seg(dm_list_item(dm_list_first(&data_lvs), struct lv_list)->lv);
if (!(raid0_seg = alloc_lv_segment(segtype, lv,
0 /* le */, lv->le_count /* len */,
- seg->status | SEG_RAID,
+ 0,
stripe_size, NULL /* log_lv */,
area_count, area_len,
0 /* chunk_size */,
diff --git a/lib/raid/raid.c b/lib/raid/raid.c
index 21fad92..1e562ff 100644
--- a/lib/raid/raid.c
+++ b/lib/raid/raid.c
@@ -167,7 +167,6 @@ static int _raid_text_import(struct lv_segment *seg,
if (seg_is_any_raid0(seg))
seg->area_len /= seg->area_count;
- seg->status |= RAID;
return 1;
}
6 years, 9 months
master - segtype: check for seg type instead of status
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=d1e398c4740327...
Commit: d1e398c474032716679f704008026b5d17e9469a
Parent: 069039204002e5c8514050fe541bbd378c383a02
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Tue Dec 13 14:50:48 2016 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Tue Dec 13 22:07:52 2016 +0100
segtype: check for seg type instead of status
RAID is LV property - which has single segment of raid type.
---
WHATS_NEW | 1 +
lib/format_text/export.c | 2 +-
lib/metadata/merge.c | 8 ++++----
3 files changed, 6 insertions(+), 5 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index a75183e..0561074 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.169 -
=====================================
+ Check segtype directly instead of checking RAID in segment status.
Reusing exiting code for raid image removal.
Fix pvmove leaving -pvmove0 error device in clustered VG.
Avoid adding extra '_' at end of raid extracted images or metadata.
diff --git a/lib/format_text/export.c b/lib/format_text/export.c
index 1ecc362..199c185 100644
--- a/lib/format_text/export.c
+++ b/lib/format_text/export.c
@@ -623,7 +623,7 @@ int out_areas(struct formatter *f, const struct lv_segment *seg,
break;
case AREA_LV:
/* FIXME This helper code should be target-independent! Check for metadata LV property. */
- if (!(seg->status & RAID)) {
+ if (!seg_is_raid(seg)) {
outf(f, "\"%s\", %u%s",
seg_lv(seg, s)->name,
seg_le(seg, s),
diff --git a/lib/metadata/merge.c b/lib/metadata/merge.c
index bf0d2c0..6d52bc4 100644
--- a/lib/metadata/merge.c
+++ b/lib/metadata/merge.c
@@ -431,7 +431,7 @@ int check_lv_segments(struct logical_volume *lv, int complete_vg)
}
if (complete_vg && seg->log_lv &&
- !seg_is_mirrored(seg) && !(seg->status & RAID_IMAGE)) {
+ !seg_is_mirrored(seg) && lv_is_raid_image(lv)) {
log_error("LV %s: segment %u log LV %s is not a "
"mirror log or a RAID image",
lv->name, seg_count, seg->log_lv->name);
@@ -458,9 +458,9 @@ int check_lv_segments(struct logical_volume *lv, int complete_vg)
}
}
- if (complete_vg && seg->status & MIRROR_IMAGE) {
- if (!find_mirror_seg(seg) ||
- !seg_is_mirrored(find_mirror_seg(seg))) {
+ if (complete_vg && lv_is_mirror_image(lv)) {
+ if (!(seg2 = find_mirror_seg(seg)) ||
+ !seg_is_mirrored(seg2)) {
log_error("LV %s: segment %u mirror image "
"is not mirrored",
lv->name, seg_count);
6 years, 9 months
master - raid: improve table reload sequence
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=069039204002e5...
Commit: 069039204002e5c8514050fe541bbd378c383a02
Parent: 7dff632c11e6ddce77dc9cde8f9011bb22970589
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Tue Dec 13 12:31:28 2016 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Tue Dec 13 22:07:52 2016 +0100
raid: improve table reload sequence
This is another place for 'common' use pattern or
reload and activation of deleted devices.
(Moving the exclusive activation to _deactivate_and_remove_lvs()).
TODO: looks like halve of raid function is reloading
just 'origin' - and the other full LV.
---
WHATS_NEW | 1 +
lib/metadata/raid_manip.c | 60 ++++++--------------------------------------
2 files changed, 10 insertions(+), 51 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index ea15903..a75183e 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.169 -
=====================================
+ Reusing exiting code for raid image removal.
Fix pvmove leaving -pvmove0 error device in clustered VG.
Avoid adding extra '_' at end of raid extracted images or metadata.
Optimize another _rmeta clearing code.
diff --git a/lib/metadata/raid_manip.c b/lib/metadata/raid_manip.c
index 98f30e2..f2c0b26 100644
--- a/lib/metadata/raid_manip.c
+++ b/lib/metadata/raid_manip.c
@@ -248,11 +248,10 @@ static int _deactivate_and_remove_lvs(struct volume_group *vg, struct dm_list *r
{
struct lv_list *lvl;
- if (vg_is_clustered(vg))
- /* Need to take lock for proper deactivation */
- dm_list_iterate_items(lvl, removal_lvs)
- if (!activate_lv_excl_local(vg->cmd, lvl->lv))
- return_0;
+ /* Need to take lock/resume for proper deactivation */
+ dm_list_iterate_items(lvl, removal_lvs)
+ if (!activate_lv_excl_local(vg->cmd, lvl->lv))
+ return_0;
dm_list_iterate_items(lvl, removal_lvs) {
if (!deactivate_lv(vg->cmd, lvl->lv))
@@ -1214,15 +1213,14 @@ static int _raid_remove_images(struct logical_volume *lv,
struct dm_list *removal_lvs, int commit)
{
struct dm_list removed_lvs;
- struct lv_list *lvl;
-
- dm_list_init(&removed_lvs);
if (!archive(lv->vg))
return_0;
- if (!removal_lvs)
+ if (!removal_lvs) {
+ dm_list_init(&removed_lvs);
removal_lvs = &removed_lvs;
+ }
if (!_raid_extract_images(lv, 0, new_count, allocate_pvs, 1,
removal_lvs, removal_lvs)) {
@@ -1245,48 +1243,8 @@ static int _raid_remove_images(struct logical_volume *lv,
if (!commit)
return 1;
- if (!vg_write(lv->vg)) {
- log_error("Failed to write changes for %s.",
- display_lvname(lv));
- return 0;
- }
-
- if (!suspend_lv(lv->vg->cmd, lv)) {
- log_error("Failed to suspend %s before committing changes.",
- display_lvname(lv));
- vg_revert(lv->vg);
- return 0;
- }
-
- if (!vg_commit(lv->vg)) {
- log_error("Failed to commit changes for %s.",
- display_lvname(lv));
- return 0;
- }
-
- /*
- * We activate the extracted sub-LVs first so they are renamed
- * and won't conflict with the remaining (possibly shifted)
- * sub-LVs.
- */
- dm_list_iterate_items(lvl, removal_lvs) {
- if (!activate_lv_excl_local(lv->vg->cmd, lvl->lv)) {
- log_error("Failed to resume extracted LVs.");
- return 0;
- }
- }
-
- if (!resume_lv(lv->vg->cmd, lv)) {
- log_error("Failed to resume %s after committing changes.",
- display_lvname(lv));
- return 0;
- }
-
- if (!sync_local_dev_names(lv->vg->cmd)) {
- log_error("Failed to sync local devices after committing changes for %s.",
- display_lvname(lv));
- return 0;
- }
+ if (!lv_update_and_reload(lv))
+ return_0;
/*
* Eliminate the extracted LVs
6 years, 9 months
master - libdm: add min_num_bits to dm_bitset_parse_list()
by Bryn Reeves
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=7dff632c11e6dd...
Commit: 7dff632c11e6ddce77dc9cde8f9011bb22970589
Parent: e8d966bc31741f846dc6d0d4af9a565d19560b98
Author: Bryn M. Reeves <bmr(a)redhat.com>
AuthorDate: Sun Dec 11 22:41:45 2016 +0000
Committer: Bryn M. Reeves <bmr(a)redhat.com>
CommitterDate: Tue Dec 13 21:02:18 2016 +0000
libdm: add min_num_bits to dm_bitset_parse_list()
It's useful to be able to specify a minimum number of bits for a
new bitmap parsed from a list, for e.g. to allow for expansing a
group without needing to copy/reallocate the bitmap.
Add a backwards compatible symbol for programs linked against old
versions of the library.
---
libdm/.exported_symbols.DM_1_02_138 | 1 +
libdm/datastruct/bitset.c | 22 +++++++++++++++++++++-
libdm/libdevmapper.h | 3 ++-
libdm/libdm-stats.c | 5 +++--
4 files changed, 27 insertions(+), 4 deletions(-)
diff --git a/libdm/.exported_symbols.DM_1_02_138 b/libdm/.exported_symbols.DM_1_02_138
index 63fc2b8..7535829 100644
--- a/libdm/.exported_symbols.DM_1_02_138
+++ b/libdm/.exported_symbols.DM_1_02_138
@@ -1,2 +1,3 @@
dm_bit_get_last
dm_bit_get_prev
+dm_bitset_parse_list
diff --git a/libdm/datastruct/bitset.c b/libdm/datastruct/bitset.c
index 90efec6..b0826e1 100644
--- a/libdm/datastruct/bitset.c
+++ b/libdm/datastruct/bitset.c
@@ -145,7 +145,8 @@ int dm_bit_get_last(dm_bitset_t bs)
/*
* Based on the Linux kernel __bitmap_parselist from lib/bitmap.c
*/
-dm_bitset_t dm_bitset_parse_list(const char *str, struct dm_pool *mem)
+dm_bitset_t dm_bitset_parse_list(const char *str, struct dm_pool *mem,
+ size_t min_num_bits)
{
unsigned a, b;
int c, old_c, totaldigits, ndigits, nmaskbits;
@@ -221,6 +222,9 @@ scan:
} while (len && c == ',');
if (!mask) {
+ if (min_num_bits && (nmaskbits < min_num_bits))
+ nmaskbits = min_num_bits;
+
if (!(mask = dm_bitset_create(mem, nmaskbits)))
goto_bad;
str = start;
@@ -237,3 +241,19 @@ bad:
}
return NULL;
}
+
+#if defined(__GNUC__)
+/*
+ * Maintain backward compatibility with older versions that did not
+ * accept a 'min_num_bits' argument to dm_bitset_parse_list().
+ */
+dm_bitset_t dm_bitset_parse_list_v1_02_129(const char *str, struct dm_pool *mem);
+dm_bitset_t dm_bitset_parse_list_v1_02_129(const char *str, struct dm_pool *mem)
+{
+ return dm_bitset_parse_list(str, mem, 0);
+}
+DM_EXPORT_SYMBOL(dm_bitset_parse_list, 1_02_129);
+
+#else /* if defined(__GNUC__) */
+
+#endif
diff --git a/libdm/libdevmapper.h b/libdm/libdevmapper.h
index 44aa55c..bcf784b 100644
--- a/libdm/libdevmapper.h
+++ b/libdm/libdevmapper.h
@@ -2100,7 +2100,8 @@ int dm_bit_get_prev(dm_bitset_t bs, int last_bit);
* dm_malloc(). Otherwise the bitset will be allocated using the supplied
* dm_pool.
*/
-dm_bitset_t dm_bitset_parse_list(const char *str, struct dm_pool *mem);
+dm_bitset_t dm_bitset_parse_list(const char *str, struct dm_pool *mem,
+ size_t min_num_bits);
/* Returns number of set bits */
static inline unsigned hweight32(uint32_t i)
diff --git a/libdm/libdm-stats.c b/libdm/libdm-stats.c
index 8210a93..02a30dc 100644
--- a/libdm/libdm-stats.c
+++ b/libdm/libdm-stats.c
@@ -675,6 +675,7 @@ static void _check_group_regions_present(struct dm_stats *dms,
#define DMS_GROUP_TAG_LEN (sizeof(DMS_GROUP_TAG) - 1)
#define DMS_GROUP_SEP ':'
#define DMS_AUX_SEP "#"
+
static int _parse_aux_data_group(struct dm_stats *dms,
struct dm_stats_region *region,
struct dm_stats_group *group)
@@ -718,7 +719,7 @@ static int _parse_aux_data_group(struct dm_stats *dms,
end = c + strlen(c);
*(end++) = '\0';
- if (!(regions = dm_bitset_parse_list(c, NULL))) {
+ if (!(regions = dm_bitset_parse_list(c, NULL, 0))) {
log_error("Could not parse member list while "
"reading group aux_data");
return 0;
@@ -3992,7 +3993,7 @@ int dm_stats_create_group(struct dm_stats *dms, const char *members,
return 0;
};
- if (!(regions = dm_bitset_parse_list(members, NULL))) {
+ if (!(regions = dm_bitset_parse_list(members, NULL, 0))) {
log_error("Could not parse list: '%s'", members);
return 0;
}
6 years, 9 months
master - libdm: use dm_bit_get_last() in _stats_group_tag_fill()
by Bryn Reeves
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=e8d966bc31741f...
Commit: e8d966bc31741f846dc6d0d4af9a565d19560b98
Parent: 5d1d65e735b6dcc5f02d0e536e3b63617f40ce83
Author: Bryn M. Reeves <bmr(a)redhat.com>
AuthorDate: Tue Dec 13 10:32:29 2016 +0000
Committer: Bryn M. Reeves <bmr(a)redhat.com>
CommitterDate: Tue Dec 13 21:02:18 2016 +0000
libdm: use dm_bit_get_last() in _stats_group_tag_fill()
Instead of iterating over all bits, use dm_bit_get_last() to find
the last set bit in the group bitmap.
---
libdm/libdm-stats.c | 4 +---
1 files changed, 1 insertions(+), 3 deletions(-)
diff --git a/libdm/libdm-stats.c b/libdm/libdm-stats.c
index 471bd7b..8210a93 100644
--- a/libdm/libdm-stats.c
+++ b/libdm/libdm-stats.c
@@ -1716,9 +1716,7 @@ static size_t _stats_group_tag_fill(const struct dm_stats *dms,
int i, j, r, next, last = 0;
size_t used = 0;
- i = dm_bit_get_first(regions);
- for (; i >= 0; i = dm_bit_get_next(regions, i))
- last = i;
+ last = dm_bit_get_last(regions);
i = dm_bit_get_first(regions);
for(; i >= 0; i = dm_bit_get_next(regions, i)) {
6 years, 9 months