master - RAID: Allow remove/replace of sub-LVs composed of error segments.
by Jonathan Brassow
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=bd0ee420b597d3...
Commit: bd0ee420b597d38e37cfe738951cb1242f527638
Parent: 845852d6b4b486075f3ed866890f79b278a990ce
Author: Jonathan Brassow <jbrassow(a)redhat.com>
AuthorDate: Wed Feb 20 14:58:56 2013 -0600
Committer: Jonathan Brassow <jbrassow(a)redhat.com>
CommitterDate: Wed Feb 20 14:58:56 2013 -0600
RAID: Allow remove/replace of sub-LVs composed of error segments.
When a device fails, we may wish to replace those segments with an
error segment. (Like when a 'vgreduce --removemissing' removes a
failed device that happens to be a RAID image/meta.) We are then left
with images that we will eventually want to remove or replace.
This patch allows us to pull out these virtual "error" sub-LVs. This
allows a user to 'lvconvert -m -1 vg/lv' to extract the bad sub-LVs.
Sub-LVs with error segments are considered for extraction before other
possible devices so that good devices are not accidentally removed.
This patch also adds the ability to replace RAID images that contain error
segments. The user will still be unable to run 'lvconvert --replace'
because there is no way to address the 'error' segment (i.e. no PV
that it is associated with). However, 'lvconvert --repair' can be
used to replace the image's error segment with a new PV. This is also
the most appropriate way to do it, since the LV will continue to be
reported as 'partial'.
---
WHATS_NEW | 1 +
lib/metadata/raid_manip.c | 73 +++++++++++++++++++++++++++++++++++----------
2 files changed, 58 insertions(+), 16 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index d237386..33993e4 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.99 -
===================================
+ Allow remove/replace of RAID sub-LVs that are composed of error targets.
Make 'vgreduce --removemissing' able to handle RAID LVs with missing PVs.
Rename lvm.conf setting 'mirror_region_size' to 'raid_region_size'.
Fix pvs -o pv_free reporting for PVs with zero PE count.
diff --git a/lib/metadata/raid_manip.c b/lib/metadata/raid_manip.c
index 74bb80a..f716664 100644
--- a/lib/metadata/raid_manip.c
+++ b/lib/metadata/raid_manip.c
@@ -958,10 +958,11 @@ static int _raid_extract_images(struct logical_volume *lv, uint32_t new_count,
struct dm_list *extracted_meta_lvs,
struct dm_list *extracted_data_lvs)
{
- int s, extract, lvl_idx = 0;
+ int ss, s, extract, lvl_idx = 0;
struct lv_list *lvl_array;
struct lv_segment *seg = first_seg(lv);
struct logical_volume *rmeta_lv, *rimage_lv;
+ struct segment_type *error_segtype;
extract = seg->area_count - new_count;
log_verbose("Extracting %u %s from %s/%s", extract,
@@ -973,18 +974,53 @@ static int _raid_extract_images(struct logical_volume *lv, uint32_t new_count,
if (!lvl_array)
return_0;
- for (s = seg->area_count - 1; (s >= 0) && extract; s--) {
- if (!_lv_is_on_pvs(seg_lv(seg, s), target_pvs) ||
- !_lv_is_on_pvs(seg_metalv(seg, s), target_pvs))
- continue;
- if (!_raid_in_sync(lv) &&
- (!seg_is_mirrored(seg) || (s == 0))) {
- log_error("Unable to extract %sRAID image"
- " while RAID array is not in-sync",
- seg_is_mirrored(seg) ? "primary " : "");
- return 0;
- }
+ error_segtype = get_segtype_from_string(lv->vg->cmd, "error");
+
+ /*
+ * We make two passes over the devices.
+ * - The first pass we look for error LVs
+ * - The second pass we look for PVs that match target_pvs
+ */
+ for (ss = (seg->area_count * 2) - 1; (ss >= 0) && extract; ss--) {
+ s = ss % seg->area_count;
+
+ if (ss / seg->area_count) {
+ /* Conditions for first pass */
+ if ((first_seg(seg_lv(seg, s))->segtype != error_segtype) &&
+ (first_seg(seg_metalv(seg, s))->segtype != error_segtype))
+ continue;
+ if (target_pvs && !dm_list_empty(target_pvs) &&
+ (target_pvs != &lv->vg->pvs)) {
+ /*
+ * User has supplied a list of PVs, but we
+ * cannot honor that list because error LVs
+ * must come first.
+ */
+ log_error("%s has components with error targets"
+ " that must be removed first: %s",
+ lv->name, seg_lv(seg, s)->name);
+
+ log_error("Try removing the PV list and rerun"
+ " the command.");
+ return 0;
+ }
+ log_debug("LVs with error segments to be removed: %s %s",
+ seg_metalv(seg, s)->name, seg_lv(seg, s)->name);
+ } else {
+ /* Conditions for second pass */
+ if (!_lv_is_on_pvs(seg_lv(seg, s), target_pvs) ||
+ !_lv_is_on_pvs(seg_metalv(seg, s), target_pvs))
+ continue;
+
+ if (!_raid_in_sync(lv) &&
+ (!seg_is_mirrored(seg) || (s == 0))) {
+ log_error("Unable to extract %sRAID image"
+ " while RAID array is not in-sync",
+ seg_is_mirrored(seg) ? "primary " : "");
+ return 0;
+ }
+ }
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);
@@ -1595,8 +1631,8 @@ int lv_raid_reshape(struct logical_volume *lv,
/*
* lv_raid_replace
* @lv
- * @replace_pvs
- * @allocatable_pvs
+ * @remove_pvs
+ * @allocate_pvs
*
* Replace the specified PVs.
*/
@@ -1639,7 +1675,10 @@ int lv_raid_replace(struct logical_volume *lv,
return 0;
}
- if (_lv_is_on_pvs(seg_lv(raid_seg, s), remove_pvs) ||
+ // FIXME: safe to use 'virtual' as a substitute for 'error'?
+ if (lv_is_virtual(seg_lv(raid_seg, s)) ||
+ lv_is_virtual(seg_metalv(raid_seg, s)) ||
+ _lv_is_on_pvs(seg_lv(raid_seg, s), remove_pvs) ||
_lv_is_on_pvs(seg_metalv(raid_seg, s), remove_pvs))
match_count++;
}
@@ -1669,7 +1708,9 @@ int lv_raid_replace(struct logical_volume *lv,
if (!(i % copies))
rebuilds_per_group = 0;
if (_lv_is_on_pvs(seg_lv(raid_seg, s), remove_pvs) ||
- _lv_is_on_pvs(seg_metalv(raid_seg, s), remove_pvs))
+ _lv_is_on_pvs(seg_metalv(raid_seg, s), remove_pvs) ||
+ lv_is_virtual(seg_lv(raid_seg, s)) ||
+ lv_is_virtual(seg_metalv(raid_seg, s)))
rebuilds_per_group++;
if (rebuilds_per_group >= copies) {
log_error("Unable to replace all the devices "
11 years, 2 months
master - RAID: Make 'vgreduce --removemissing' work with RAID LVs
by Jonathan Brassow
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=845852d6b4b486...
Commit: 845852d6b4b486075f3ed866890f79b278a990ce
Parent: 0e4ffd9d3b9cc8bf88662e3a0d023602360c6993
Author: Jonathan Brassow <jbrassow(a)redhat.com>
AuthorDate: Wed Feb 20 14:52:46 2013 -0600
Committer: Jonathan Brassow <jbrassow(a)redhat.com>
CommitterDate: Wed Feb 20 14:52:46 2013 -0600
RAID: Make 'vgreduce --removemissing' work with RAID LVs
Currently it is impossible to remove a failed PV which has a RAID LV
on it. This patch fixes the issue by replacing the failed PV with an
'error' segment within the affected sub-LVs. Once there is no longer
a RAID LV using the PV, it can be removed.
Most often, it is better to replace a failed RAID device with a spare.
(You can use 'lvconvert --repair <vg>/<LV>' to accomplish that.)
However, if there are no spares in the volume group and none will be
added, it is useful to be able to removed the failed device.
Following patches address the ability to perform 'lvconvert' operations
on RAID LVs that contain sub-LVs composed of 'error' segments.
---
WHATS_NEW | 1 +
lib/metadata/metadata-exported.h | 1 +
lib/metadata/raid_manip.c | 64 ++++++++++++++++++++++++++++++++++++++
tools/vgreduce.c | 6 +++
4 files changed, 72 insertions(+), 0 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index f827508..d237386 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.99 -
===================================
+ Make 'vgreduce --removemissing' able to handle RAID LVs with missing PVs.
Rename lvm.conf setting 'mirror_region_size' to 'raid_region_size'.
Fix pvs -o pv_free reporting for PVs with zero PE count.
Fix missing cleanup of flags when the LV is detached from pool.
diff --git a/lib/metadata/metadata-exported.h b/lib/metadata/metadata-exported.h
index 406491c..890aa18 100644
--- a/lib/metadata/metadata-exported.h
+++ b/lib/metadata/metadata-exported.h
@@ -808,6 +808,7 @@ int lv_raid_reshape(struct logical_volume *lv,
const struct segment_type *new_segtype);
int lv_raid_replace(struct logical_volume *lv, struct dm_list *remove_pvs,
struct dm_list *allocate_pvs);
+int lv_raid_remove_missing(struct logical_volume *lv);
/* -- metadata/raid_manip.c */
diff --git a/lib/metadata/raid_manip.c b/lib/metadata/raid_manip.c
index 896ad42..74bb80a 100644
--- a/lib/metadata/raid_manip.c
+++ b/lib/metadata/raid_manip.c
@@ -1853,3 +1853,67 @@ try_again:
return 1;
}
+
+int lv_raid_remove_missing(struct logical_volume *lv)
+{
+ uint32_t s, lvl_idx;
+ struct lv_segment *seg = first_seg(lv);
+ struct cmd_context *cmd = lv->vg->cmd;
+
+ if (!(lv->status & PARTIAL_LV)) {
+ log_error(INTERNAL_ERROR "%s/%s is not a partial LV",
+ lv->vg->name, lv->name);
+ return 0;
+ }
+
+ log_debug("Attempting to remove missing devices from %s LV, %s",
+ seg->segtype->ops->name(seg), lv->name);
+
+ /*
+ * FIXME: Make sure # of compromised components will not affect RAID
+ */
+
+ for (s = 0, lvl_idx = 0; s < seg->area_count; s++) {
+ if (!(seg_lv(seg, s)->status & PARTIAL_LV) &&
+ !(seg_metalv(seg, s)->status & PARTIAL_LV))
+ continue;
+
+ log_debug("Replacing %s and %s segments with error target",
+ seg_lv(seg, s)->name, seg_metalv(seg, s)->name);
+ if (!replace_lv_with_error_segment(seg_lv(seg, s))) {
+ log_error("Failed to replace %s/%s's extents"
+ " with error target", lv->vg->name,
+ seg_lv(seg, s)->name);
+ return 0;
+ }
+ if (!replace_lv_with_error_segment(seg_metalv(seg, s))) {
+ log_error("Failed to replace %s/%s's extents"
+ " with error target", lv->vg->name,
+ seg_metalv(seg, s)->name);
+ return 0;
+ }
+ }
+
+ if (!vg_write(lv->vg)) {
+ log_error("Failed to write changes to %s in %s",
+ lv->name, lv->vg->name);
+ return 0;
+ }
+
+ if (!suspend_lv(cmd, lv)) {
+ log_error("Failed to suspend %s/%s before committing changes",
+ lv->vg->name, lv->name);
+ return 0;
+ }
+
+ if (!vg_commit(lv->vg)) {
+ log_error("Failed to commit changes to %s in %s",
+ lv->name, lv->vg->name);
+ return 0;
+ }
+
+ if (!resume_lv(cmd, lv))
+ return_0;
+
+ return 1;
+}
diff --git a/tools/vgreduce.c b/tools/vgreduce.c
index 1b04a49..c068b26 100644
--- a/tools/vgreduce.c
+++ b/tools/vgreduce.c
@@ -89,6 +89,12 @@ static int _make_vg_consistent(struct cmd_context *cmd, struct volume_group *vg)
/* Are any segments of this LV on missing PVs? */
if (lv->status & PARTIAL_LV) {
+ if (seg_is_raid(first_seg(lv))) {
+ if (!lv_raid_remove_missing(lv))
+ return_0;
+ goto restart;
+ }
+
if (lv->status & MIRRORED) {
if (!mirror_remove_missing(cmd, lv, 1))
return_0;
11 years, 2 months
master - clean-up: Rename lvm.conf setting 'mirror_region_size' to 'raid_region_size'
by Jonathan Brassow
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=0e4ffd9d3b9cc8...
Commit: 0e4ffd9d3b9cc8bf88662e3a0d023602360c6993
Parent: a7d6a612b800ac53ded216842d0386f41e504c4e
Author: Jonathan Brassow <jbrassow(a)redhat.com>
AuthorDate: Wed Feb 20 14:40:17 2013 -0600
Committer: Jonathan Brassow <jbrassow(a)redhat.com>
CommitterDate: Wed Feb 20 14:40:17 2013 -0600
clean-up: Rename lvm.conf setting 'mirror_region_size' to 'raid_region_size'
We have been using 'mirror_region_size' in lvm.conf as the default region
size for RAID logical volumes as well as mirror logical volumes. Since,
"raid" is more inclusive and representative than "mirror", I have changed
the name of this setting. We must still check for the old setting and warn
the user if we are overriding it with the new setting if both happen to be
present.
---
WHATS_NEW | 1 +
doc/example.conf.in | 8 +++++-
lib/config/defaults.h | 2 +-
lib/metadata/lv_manip.c | 43 ++++++++++++++++++++++++++++++++++++++
lib/metadata/metadata-exported.h | 1 +
lib/metadata/raid_manip.c | 7 ++---
lib/mirror/mirrored.c | 5 +---
tools/lvconvert.c | 4 +--
tools/lvcreate.c | 4 +--
9 files changed, 58 insertions(+), 17 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index 426f302..f827508 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.99 -
===================================
+ Rename lvm.conf setting 'mirror_region_size' to 'raid_region_size'.
Fix pvs -o pv_free reporting for PVs with zero PE count.
Fix missing cleanup of flags when the LV is detached from pool.
Fix check for some forbidden discards conversion of thin pools.
diff --git a/doc/example.conf.in b/doc/example.conf.in
index 256e012..a1ba5f8 100644
--- a/doc/example.conf.in
+++ b/doc/example.conf.in
@@ -637,8 +637,12 @@ activation {
#
# read_only_volume_list = [ "vg1", "vg2/lvol1", "@tag1", "@*" ]
- # Size (in KB) of each copy operation when mirroring
- mirror_region_size = 512
+ # For RAID or 'mirror' segment types, 'raid_region_size' is the
+ # size (in kiB) of each:
+ # - synchronization operation when initializing
+ # - each copy operation when performing a 'pvmove' (using 'mirror' segtype)
+ # This setting has replaced 'mirror_region_size' since version 2.02.99
+ raid_region_size = 512
# Setting to use when there is no readahead value stored in the metadata.
#
diff --git a/lib/config/defaults.h b/lib/config/defaults.h
index 3518240..0a98254 100644
--- a/lib/config/defaults.h
+++ b/lib/config/defaults.h
@@ -142,7 +142,7 @@
#define DEFAULT_USE_LINEAR_TARGET 1
#define DEFAULT_STRIPE_FILLER "error"
-#define DEFAULT_MIRROR_REGION_SIZE 512 /* KB */
+#define DEFAULT_RAID_REGION_SIZE 512 /* KB */
#define DEFAULT_INTERVAL 15
#ifdef READLINE_SUPPORT
diff --git a/lib/metadata/lv_manip.c b/lib/metadata/lv_manip.c
index 50e42dc..818e740 100644
--- a/lib/metadata/lv_manip.c
+++ b/lib/metadata/lv_manip.c
@@ -72,6 +72,49 @@ struct lv_names {
const char *new;
};
+/*
+ * get_default_region_size
+ * @cmd
+ *
+ * 'mirror_region_size' and 'raid_region_size' are effectively the same thing.
+ * However, "raid" is more inclusive than "mirror", so the name has been
+ * changed. This function checks for the old setting and warns the user if
+ * it is being overridden by the new setting (i.e. warn if both settings are
+ * present).
+ *
+ * Note that the config files give defaults in kiB terms, but we
+ * return the value in terms of sectors.
+ *
+ * Returns: default region_size in sectors
+ */
+int get_default_region_size(struct cmd_context *cmd)
+{
+ int mrs, rrs;
+
+ /*
+ * 'mirror_region_size' is the old setting. It is overridden
+ * by the new setting, 'raid_region_size'.
+ */
+ mrs = 2 * find_config_tree_int(cmd, "activation/mirror_region_size", 0);
+ rrs = 2 * find_config_tree_int(cmd, "activation/raid_region_size", 0);
+
+ if (!mrs && !rrs)
+ return DEFAULT_RAID_REGION_SIZE * 2;
+
+ if (!mrs)
+ return rrs;
+
+ if (!rrs)
+ return mrs;
+
+ if (mrs != rrs)
+ log_verbose("Overriding default 'mirror_region_size' setting"
+ " with 'raid_region_size' setting of %u kiB",
+ rrs / 2);
+
+ return rrs;
+}
+
int add_seg_to_segs_using_this_lv(struct logical_volume *lv,
struct lv_segment *seg)
{
diff --git a/lib/metadata/metadata-exported.h b/lib/metadata/metadata-exported.h
index db62d51..406491c 100644
--- a/lib/metadata/metadata-exported.h
+++ b/lib/metadata/metadata-exported.h
@@ -727,6 +727,7 @@ int vg_max_lv_reached(struct volume_group *vg);
/*
* Mirroring functions
*/
+int get_default_region_size(struct cmd_context *cmd); /* in lv_manip.c */
struct lv_segment *find_mirror_seg(struct lv_segment *seg);
int lv_add_mirrors(struct cmd_context *cmd, struct logical_volume *lv,
uint32_t mirrors, uint32_t stripes, uint32_t stripe_size,
diff --git a/lib/metadata/raid_manip.c b/lib/metadata/raid_manip.c
index 3031506..896ad42 100644
--- a/lib/metadata/raid_manip.c
+++ b/lib/metadata/raid_manip.c
@@ -21,8 +21,6 @@
#include "lv_alloc.h"
#include "lvm-string.h"
-#define RAID_REGION_SIZE 1024
-
static int _lv_is_raid_with_tracking(const struct logical_volume *lv,
struct logical_volume **tracking)
{
@@ -528,7 +526,7 @@ static int _alloc_image_components(struct logical_volume *lv,
return_0;
if (seg_is_linear(seg))
- region_size = RAID_REGION_SIZE;
+ region_size = get_default_region_size(lv->vg->cmd);
else
region_size = seg->region_size;
@@ -730,7 +728,8 @@ static int _raid_add_images(struct logical_volume *lv,
lv->status |= RAID;
seg = first_seg(lv);
seg_lv(seg, 0)->status |= RAID_IMAGE | LVM_READ | LVM_WRITE;
- seg->region_size = RAID_REGION_SIZE;
+ seg->region_size = get_default_region_size(lv->vg->cmd);
+
/* MD's bitmap is limited to tracking 2^21 regions */
while (seg->region_size < (lv->size / (1 << 21))) {
seg->region_size *= 2;
diff --git a/lib/mirror/mirrored.c b/lib/mirror/mirrored.c
index 23a6371..58afab3 100644
--- a/lib/mirror/mirrored.c
+++ b/lib/mirror/mirrored.c
@@ -162,10 +162,7 @@ static struct mirror_state *_mirrored_init_target(struct dm_pool *mem,
return NULL;
}
- mirr_state->default_region_size = 2 *
- find_config_tree_int(cmd,
- "activation/mirror_region_size",
- DEFAULT_MIRROR_REGION_SIZE);
+ mirr_state->default_region_size = get_default_region_size(cmd);
return mirr_state;
}
diff --git a/tools/lvconvert.c b/tools/lvconvert.c
index 0e15888..9b41722 100644
--- a/tools/lvconvert.c
+++ b/tools/lvconvert.c
@@ -404,9 +404,7 @@ static int _read_params(struct lvconvert_params *lp, struct cmd_context *cmd,
}
lp->region_size = arg_uint_value(cmd, regionsize_ARG, 0);
} else {
- region_size = 2 * find_config_tree_int(cmd,
- "activation/mirror_region_size",
- DEFAULT_MIRROR_REGION_SIZE);
+ region_size = get_default_region_size(cmd);
if (region_size < 0) {
log_error("Negative regionsize in "
"configuration file is invalid");
diff --git a/tools/lvcreate.c b/tools/lvcreate.c
index 78292f7..8919ba4 100644
--- a/tools/lvcreate.c
+++ b/tools/lvcreate.c
@@ -457,9 +457,7 @@ static int _read_mirror_params(struct lvcreate_params *lp,
}
lp->region_size = arg_uint_value(cmd, regionsize_ARG, 0);
} else {
- region_size = 2 * find_config_tree_int(cmd,
- "activation/mirror_region_size",
- DEFAULT_MIRROR_REGION_SIZE);
+ region_size = get_default_region_size(cmd);
if (region_size < 0) {
log_error("Negative regionsize in configuration file "
"is invalid");
11 years, 2 months
master - fix: 'Couldn't read extent size' --> '... extent start'
by Peter Rajnoha
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=a7d6a612b800ac...
Commit: a7d6a612b800ac53ded216842d0386f41e504c4e
Parent: 722ca363f03f805cb583156eb42886c72f9c93b8
Author: Peter Rajnoha <prajnoha(a)redhat.com>
AuthorDate: Thu Feb 21 13:33:27 2013 +0100
Committer: Peter Rajnoha <prajnoha(a)redhat.com>
CommitterDate: Thu Feb 21 13:33:27 2013 +0100
fix: 'Couldn't read extent size' --> '... extent start'
---
lib/format_text/import_vsn1.c | 3 ++-
1 files changed, 2 insertions(+), 1 deletions(-)
diff --git a/lib/format_text/import_vsn1.c b/lib/format_text/import_vsn1.c
index e73c475..33ad37d 100644
--- a/lib/format_text/import_vsn1.c
+++ b/lib/format_text/import_vsn1.c
@@ -235,7 +235,8 @@ static int _read_pv(struct format_instance *fid,
}
if (!_read_uint64(pvn, "pe_start", &pv->pe_start)) {
- log_error("Couldn't read extent size for physical volume.");
+ log_error("Couldn't read extent start value (pe_start) "
+ "for physical volume.");
return 0;
}
11 years, 2 months
master - report: fix pvs -o pv_free reporting for PVs with 0 PEs
by Peter Rajnoha
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=722ca363f03f80...
Commit: 722ca363f03f805cb583156eb42886c72f9c93b8
Parent: e566faaae605cfbb35a97b46e211c68d3c7bcfd5
Author: Peter Rajnoha <prajnoha(a)redhat.com>
AuthorDate: Thu Feb 21 13:28:07 2013 +0100
Committer: Peter Rajnoha <prajnoha(a)redhat.com>
CommitterDate: Thu Feb 21 13:28:07 2013 +0100
report: fix pvs -o pv_free reporting for PVs with 0 PEs
[0] raw/~ # lsblk -o NAME,SIZE /dev/sda
NAME SIZE
sda 128M
[0] raw/~ # pvcreate --dataalignment 128m /dev/sda
Physical volume "/dev/sda" successfully created
[0] raw/~ # vgcreate vg /dev/sda
Volume group "vg" successfully created
[0] raw/~ # lvcreate -l1 vg
Volume group "vg" has insufficient free space (0 extents): 1 required.
Before this patch:
[0] raw/~ # pvs -o pv_name,pv_free
PV PFree
/dev/sda 128.00m
After this patch:
[0] raw/~ # pvs -o pv_name,pv_free
PV PFree
/dev/sda 0
---
WHATS_NEW | 1 +
lib/metadata/pv.c | 2 +-
2 files changed, 2 insertions(+), 1 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index c08f2a5..426f302 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.99 -
===================================
+ Fix pvs -o pv_free reporting for PVs with zero PE count.
Fix missing cleanup of flags when the LV is detached from pool.
Fix check for some forbidden discards conversion of thin pools.
Add pool_is_active() to check for any pool related active LV.
diff --git a/lib/metadata/pv.c b/lib/metadata/pv.c
index 09b869b..3cd06aa 100644
--- a/lib/metadata/pv.c
+++ b/lib/metadata/pv.c
@@ -106,7 +106,7 @@ uint64_t pv_free(const struct physical_volume *pv)
{
uint64_t freespace;
- if (!pv->pe_count)
+ if (!pv->vg || is_orphan_vg(pv->vg->name))
freespace = pv->size;
else
freespace = (uint64_t)
11 years, 2 months
master - cleanup: old style gcc
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=e566faaae605cf...
Commit: e566faaae605cfbb35a97b46e211c68d3c7bcfd5
Parent: d97605beafab98572e7e797139548dffde91274c
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Tue Feb 5 16:48:48 2013 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Tue Feb 5 16:54:12 2013 +0100
cleanup: old style gcc
---
lib/cache/lvmetad.c | 6 ++++--
1 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/lib/cache/lvmetad.c b/lib/cache/lvmetad.c
index e7f00ac..886f163 100644
--- a/lib/cache/lvmetad.c
+++ b/lib/cache/lvmetad.c
@@ -46,7 +46,7 @@ void lvmetad_init(struct cmd_context *cmd)
_lvmetad_cmd = cmd;
}
-static void _lvmetad_connect()
+static void _lvmetad_connect(void)
{
if (!_lvmetad_use || !_lvmetad_socket || _lvmetad_connected)
return;
@@ -156,8 +156,10 @@ retry:
static int _token_update(void)
{
+ daemon_reply repl;
+
log_debug_lvmetad("Sending updated token to lvmetad: %s", _lvmetad_token ? : "<NONE>");
- daemon_reply repl = _lvmetad_send("token_update", NULL);
+ repl = _lvmetad_send("token_update", NULL);
if (repl.error || strcmp(daemon_reply_str(repl, "response", ""), "OK")) {
daemon_reply_destroy(repl);
11 years, 3 months
master - cleanup: preserve signesss and type size on return values
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=d97605beafab98...
Commit: d97605beafab98572e7e797139548dffde91274c
Parent: 7910b6c0badbf222e7c434f4cb3c0ad2ed3bd3a7
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Tue Feb 5 16:43:16 2013 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Tue Feb 5 16:54:11 2013 +0100
cleanup: preserve signesss and type size on return values
---
lib/cache/lvmcache.c | 4 ++--
lib/cache/lvmcache.h | 4 ++--
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/lib/cache/lvmcache.c b/lib/cache/lvmcache.c
index 6ef1556..acdd1c8 100644
--- a/lib/cache/lvmcache.c
+++ b/lib/cache/lvmcache.c
@@ -1814,7 +1814,7 @@ int lvmcache_foreach_mda(struct lvmcache_info *info,
return 1;
}
-int lvmcache_mda_count(struct lvmcache_info *info)
+unsigned lvmcache_mda_count(struct lvmcache_info *info)
{
return dm_list_size(&info->mdas);
}
@@ -1887,7 +1887,7 @@ int lvmcache_uncertain_ownership(struct lvmcache_info *info) {
return mdas_empty_or_ignored(&info->mdas);
}
-int lvmcache_smallest_mda_size(struct lvmcache_info *info)
+uint64_t lvmcache_smallest_mda_size(struct lvmcache_info *info)
{
return find_min_mda_size(&info->mdas);
}
diff --git a/lib/cache/lvmcache.h b/lib/cache/lvmcache.h
index 615f466..768cd4c 100644
--- a/lib/cache/lvmcache.h
+++ b/lib/cache/lvmcache.h
@@ -145,8 +145,8 @@ struct device *lvmcache_device(struct lvmcache_info *info);
void lvmcache_make_valid(struct lvmcache_info *info);
int lvmcache_is_orphan(struct lvmcache_info *info);
int lvmcache_uncertain_ownership(struct lvmcache_info *info);
-int lvmcache_mda_count(struct lvmcache_info *info);
+unsigned lvmcache_mda_count(struct lvmcache_info *info);
int lvmcache_vgid_is_cached(const char *vgid);
-int lvmcache_smallest_mda_size(struct lvmcache_info *info);
+uint64_t lvmcache_smallest_mda_size(struct lvmcache_info *info);
#endif
11 years, 3 months
master - thin: update pool_is_active
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=7910b6c0badbf2...
Commit: 7910b6c0badbf222e7c434f4cb3c0ad2ed3bd3a7
Parent: c984d8fbab73face6a137cd72c114e3c2edb0448
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Tue Feb 5 16:49:09 2013 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Tue Feb 5 16:54:11 2013 +0100
thin: update pool_is_active
Change it to take LV and move it to exported header - seems
to be a better fit for usability from tools/ directory.
---
lib/metadata/metadata-exported.h | 1 +
lib/metadata/metadata.h | 1 -
lib/metadata/thin_manip.c | 5 ++---
tools/lvchange.c | 2 +-
4 files changed, 4 insertions(+), 5 deletions(-)
diff --git a/lib/metadata/metadata-exported.h b/lib/metadata/metadata-exported.h
index ffec129..db62d51 100644
--- a/lib/metadata/metadata-exported.h
+++ b/lib/metadata/metadata-exported.h
@@ -566,6 +566,7 @@ int lv_rename_update(struct cmd_context *cmd, struct logical_volume *lv,
uint64_t extents_from_size(struct cmd_context *cmd, uint64_t size,
uint32_t extent_size);
+int pool_is_active(const struct logical_volume *pool_lv);
int update_pool_lv(struct logical_volume *lv, int activate);
int get_pool_discards(const char *str, thin_discards_t *discards);
const char *get_pool_discards_name(thin_discards_t discards);
diff --git a/lib/metadata/metadata.h b/lib/metadata/metadata.h
index 8a80147..19bf742 100644
--- a/lib/metadata/metadata.h
+++ b/lib/metadata/metadata.h
@@ -472,7 +472,6 @@ int attach_pool_message(struct lv_segment *pool_seg, dm_thin_message_t type,
int auto_increment);
int pool_has_message(const struct lv_segment *seg,
const struct logical_volume *lv, uint32_t device_id);
-int pool_is_active(const struct lv_segment *pool_seg);
int pool_below_threshold(const struct lv_segment *pool_seg);
int extend_pool(struct logical_volume *lv, const struct segment_type *segtype,
struct alloc_handle *ah, uint32_t stripes, uint32_t stripe_size);
diff --git a/lib/metadata/thin_manip.c b/lib/metadata/thin_manip.c
index 6ec97d4..05fc052 100644
--- a/lib/metadata/thin_manip.c
+++ b/lib/metadata/thin_manip.c
@@ -234,13 +234,12 @@ int pool_has_message(const struct lv_segment *seg,
return 0;
}
-int pool_is_active(const struct lv_segment *pool_seg)
+int pool_is_active(const struct logical_volume *lv)
{
struct lvinfo info;
const struct seg_list *sl;
- const struct logical_volume *lv = pool_seg->lv;
- if (!seg_is_thin_pool(pool_seg)) {
+ if (!lv_is_thin_pool(lv)) {
log_error(INTERNAL_ERROR "LV %s is not pool.", lv->name);
return 0;
}
diff --git a/tools/lvchange.c b/tools/lvchange.c
index 0ea2e78..07015e7 100644
--- a/tools/lvchange.c
+++ b/tools/lvchange.c
@@ -113,7 +113,7 @@ static int lvchange_pool_update(struct cmd_context *cmd,
if (discards != first_seg(lv)->discards) {
if (((discards == THIN_DISCARDS_IGNORE) ||
(first_seg(lv)->discards == THIN_DISCARDS_IGNORE)) &&
- pool_is_active(first_seg(lv)))
+ pool_is_active(lv))
log_error("Cannot change discards state for active "
"pool volume \"%s\".", lv->name);
else {
11 years, 3 months
master - thin: properly unmark volume after detach
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=c984d8fbab73fa...
Commit: c984d8fbab73face6a137cd72c114e3c2edb0448
Parent: 416eb4b9b352c65e019cbd0a11265050b7360c63
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Tue Feb 5 11:07:09 2013 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Tue Feb 5 14:40:37 2013 +0100
thin: properly unmark volume after detach
When the volume is detached form thin pool,
unmask THIN_VOLUME flag and reset related pointers.
---
WHATS_NEW | 1 +
lib/metadata/thin_manip.c | 6 +++++-
2 files changed, 6 insertions(+), 1 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index b6c1785..c08f2a5 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.99 -
===================================
+ Fix missing cleanup of flags when the LV is detached from pool.
Fix check for some forbidden discards conversion of thin pools.
Add pool_is_active() to check for any pool related active LV.
Report blank field if the LV doesn't have an origin instead of 0.
diff --git a/lib/metadata/thin_manip.c b/lib/metadata/thin_manip.c
index 51f3d16..6ec97d4 100644
--- a/lib/metadata/thin_manip.c
+++ b/lib/metadata/thin_manip.c
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2011-2012 Red Hat, Inc. All rights reserved.
+ * Copyright (C) 2011-2013 Red Hat, Inc. All rights reserved.
*
* This file is part of LVM2.
*
@@ -136,6 +136,10 @@ int detach_pool_lv(struct lv_segment *seg)
sl->seg->origin = NULL;
}
+ seg->lv->status &= ~THIN_VOLUME;
+ seg->pool_lv = NULL;
+ seg->origin = NULL;
+
return 1;
}
11 years, 3 months
master - test: update using exclusive activation
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=416eb4b9b352c6...
Commit: 416eb4b9b352c65e019cbd0a11265050b7360c63
Parent: a5b9b4bf02b42baf1f1c033eaa98c5fe23951b43
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Tue Feb 5 09:20:17 2013 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Tue Feb 5 14:39:11 2013 +0100
test: update using exclusive activation
For testing in cluster exclusive activation of origin is needed.
---
test/shell/snapshot-lvm1.sh | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/test/shell/snapshot-lvm1.sh b/test/shell/snapshot-lvm1.sh
index cb55ed6..4d06f0a 100644
--- a/test/shell/snapshot-lvm1.sh
+++ b/test/shell/snapshot-lvm1.sh
@@ -19,7 +19,7 @@ aux prepare_devs 2
vgcreate --metadatatype 1 $vg $(cat DEVICES)
# Make origin volume
-lvcreate -l5 $vg -n origin
+lvcreate -ae -l5 $vg -n origin
# Create a snap of origin
lvcreate -s $vg/origin -n snap_with_lvm1_meta -l4
11 years, 3 months