public inbox for lvm2-cvs@sourceware.org
help / color / mirror / Atom feed
* LVM2 ./WHATS_NEW lib/activate/activate.c lib/d ...
@ 2009-05-13 21:27 mbroz
0 siblings, 0 replies; 2+ messages in thread
From: mbroz @ 2009-05-13 21:27 UTC (permalink / raw)
To: lvm-devel, lvm2-cvs
CVSROOT: /cvs/lvm2
Module name: LVM2
Changes by: mbroz@sourceware.org 2009-05-13 21:27:45
Modified files:
. : WHATS_NEW
lib/activate : activate.c
lib/display : display.c
lib/format1 : import-export.c
lib/format_text: export.c
lib/metadata : lv_manip.c metadata-exported.h metadata.c
metadata.h snapshot_manip.c
lib/report : report.c
tools : lvchange.c lvdisplay.c lvscan.c reporter.c
vgchange.c
Log message:
Merge lv_is_displayable and lv_is_visible.
Displayable and visible is the same thing.
volumes_count(vg) is now vg_visible_lvs() and always
returns number of LVs from user perspective.
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.1108&r2=1.1109
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/activate/activate.c.diff?cvsroot=lvm2&r1=1.146&r2=1.147
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/display/display.c.diff?cvsroot=lvm2&r1=1.96&r2=1.97
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/format1/import-export.c.diff?cvsroot=lvm2&r1=1.105&r2=1.106
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/format_text/export.c.diff?cvsroot=lvm2&r1=1.67&r2=1.68
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/lv_manip.c.diff?cvsroot=lvm2&r1=1.169&r2=1.170
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata-exported.h.diff?cvsroot=lvm2&r1=1.70&r2=1.71
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.c.diff?cvsroot=lvm2&r1=1.217&r2=1.218
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.h.diff?cvsroot=lvm2&r1=1.193&r2=1.194
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/snapshot_manip.c.diff?cvsroot=lvm2&r1=1.40&r2=1.41
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/report/report.c.diff?cvsroot=lvm2&r1=1.98&r2=1.99
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/lvchange.c.diff?cvsroot=lvm2&r1=1.99&r2=1.100
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/lvdisplay.c.diff?cvsroot=lvm2&r1=1.21&r2=1.22
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/lvscan.c.diff?cvsroot=lvm2&r1=1.37&r2=1.38
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/reporter.c.diff?cvsroot=lvm2&r1=1.47&r2=1.48
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/vgchange.c.diff?cvsroot=lvm2&r1=1.70&r2=1.71
--- LVM2/WHATS_NEW 2009/05/13 21:26:45 1.1108
+++ LVM2/WHATS_NEW 2009/05/13 21:27:43 1.1109
@@ -1,5 +1,6 @@
Version 2.02.46 -
================================
+ Merge lv_is_displayable and lv_is_visible functions.
Introduce lv_set_visible & lv_set_invisible functions.
Fix lv_is_visible to handle virtual origin.
Introduce link_lv_to_vg and unlink_lv_from_vg functions.
--- LVM2/lib/activate/activate.c 2009/05/13 21:26:45 1.146
+++ LVM2/lib/activate/activate.c 2009/05/13 21:27:43 1.147
@@ -673,7 +673,7 @@
return 0;
dm_list_iterate_items(lvl, &vg->lvs) {
- if (lv_is_displayable(lvl->lv))
+ if (lv_is_visible(lvl->lv))
count += (_lv_open_count(vg->cmd, lvl->lv) > 0);
}
--- LVM2/lib/display/display.c 2008/12/04 15:54:27 1.96
+++ LVM2/lib/display/display.c 2009/05/13 21:27:43 1.97
@@ -606,7 +606,7 @@
}
log_print("MAX LV %u", vg->max_lv);
- log_print("Cur LV %u", displayable_lvs_in_vg(vg));
+ log_print("Cur LV %u", vg_visible_lvs(vg));
log_print("Open LV %u", lvs_in_vg_opened(vg));
/****** FIXME Max LV Size
log_print ( "MAX LV Size %s",
@@ -681,7 +681,7 @@
vg->status,
/* internal volume group number; obsolete */
vg->max_lv,
- displayable_lvs_in_vg(vg),
+ vg_visible_lvs(vg),
lvs_in_vg_opened(vg),
/* FIXME: maximum logical volume size */
vg->max_pv,
--- LVM2/lib/format1/import-export.c 2009/05/13 21:25:01 1.105
+++ LVM2/lib/format1/import-export.c 2009/05/13 21:27:43 1.106
@@ -282,7 +282,7 @@
vgd->vg_status |= VG_EXTENDABLE;
vgd->lv_max = vg->max_lv;
- vgd->lv_cur = volumes_count(vg) + snapshot_count(vg);
+ vgd->lv_cur = vg_visible_lvs(vg) + snapshot_count(vg);
vgd->pv_max = vg->max_pv;
vgd->pv_cur = vg->pv_count;
--- LVM2/lib/format_text/export.c 2009/02/22 22:11:58 1.67
+++ LVM2/lib/format_text/export.c 2009/05/13 21:27:43 1.68
@@ -592,14 +592,14 @@
* Write visible LVs first
*/
dm_list_iterate_items(lvl, &vg->lvs) {
- if (!(lv_is_displayable(lvl->lv)))
+ if (!(lv_is_visible(lvl->lv)))
continue;
if (!_print_lv(f, lvl->lv))
return_0;
}
dm_list_iterate_items(lvl, &vg->lvs) {
- if ((lv_is_displayable(lvl->lv)))
+ if ((lv_is_visible(lvl->lv)))
continue;
if (!_print_lv(f, lvl->lv))
return_0;
--- LVM2/lib/metadata/lv_manip.c 2009/05/13 21:26:45 1.169
+++ LVM2/lib/metadata/lv_manip.c 2009/05/13 21:27:43 1.170
@@ -1732,7 +1732,7 @@
int r = 0;
/* rename is not allowed on sub LVs */
- if (!lv_is_displayable(lv)) {
+ if (!lv_is_visible(lv)) {
log_error("Cannot rename internal LV \"%s\".", lv->name);
return 0;
}
@@ -1818,7 +1818,7 @@
struct logical_volume *lv;
char dname[NAME_LEN];
- if (vg->max_lv && (vg->max_lv == volumes_count(vg))) {
+ if (vg->max_lv && (vg->max_lv == vg_visible_lvs(vg))) {
log_error("Maximum number of logical volumes (%u) reached "
"in volume group %s", vg->max_lv, vg->name);
return NULL;
--- LVM2/lib/metadata/metadata-exported.h 2009/05/13 21:26:45 1.70
+++ LVM2/lib/metadata/metadata-exported.h 2009/05/13 21:27:43 1.71
@@ -238,18 +238,16 @@
/*
* logical volumes
* The following relationship should always hold:
- * dm_list_size(lvs) = lv_count + 2 * snapshot_count
+ * dm_list_size(lvs) = user visible lv_count + snapshot_count + other invisible LVs
*
* Snapshots consist of 2 instances of "struct logical_volume":
* - cow (lv_name is visible to the user)
* - snapshot (lv_name is 'snapshotN')
- * Neither of these instances is reflected in lv_count.
*
* Mirrors consist of multiple instances of "struct logical_volume":
* - one for the mirror log
* - one for each mirror leg
* - one for the user-visible mirror LV
- * all of the instances are reflected in lv_count.
*/
struct dm_list lvs;
@@ -539,10 +537,9 @@
int lv_is_origin(const struct logical_volume *lv);
int lv_is_virtual_origin(const struct logical_volume *lv);
int lv_is_cow(const struct logical_volume *lv);
-int lv_is_visible(const struct logical_volume *lv);
/* Test if given LV is visible from user's perspective */
-int lv_is_displayable(const struct logical_volume *lv);
+int lv_is_visible(const struct logical_volume *lv);
int pv_is_in_vg(struct volume_group *vg, struct physical_volume *pv);
@@ -563,7 +560,10 @@
int vg_check_status(const struct volume_group *vg, uint32_t status);
-unsigned volumes_count(const struct volume_group *vg);
+/*
+ * Returns visible LV count - number of LVs from user perspective
+ */
+unsigned vg_visible_lvs(const struct volume_group *vg);
/*
* Mirroring functions
--- LVM2/lib/metadata/metadata.c 2009/05/13 21:22:57 1.217
+++ LVM2/lib/metadata/metadata.c 2009/05/13 21:27:43 1.218
@@ -376,7 +376,7 @@
if (!vg_check_status(vg, EXPORTED_VG))
return 0;
- lv_count = displayable_lvs_in_vg(vg);
+ lv_count = vg_visible_lvs(vg);
if (lv_count) {
if ((force == PROMPT) &&
@@ -391,8 +391,8 @@
return 0;
}
- lv_count = displayable_lvs_in_vg(vg);
-
+ lv_count = vg_visible_lvs(vg);
+
if (lv_count) {
log_error("Volume group \"%s\" still contains %u "
"logical volume(s)", vg_name, lv_count);
@@ -1140,18 +1140,6 @@
return 1;
}
-unsigned displayable_lvs_in_vg(const struct volume_group *vg)
-{
- struct lv_list *lvl;
- unsigned lv_count = 0;
-
- dm_list_iterate_items(lvl, &vg->lvs)
- if (lv_is_displayable(lvl->lv))
- lv_count++;
-
- return lv_count;
-}
-
unsigned snapshot_count(const struct volume_group *vg)
{
struct lv_list *lvl;
@@ -1164,17 +1152,14 @@
return num_snapshots;
}
-unsigned volumes_count(const struct volume_group *vg)
+unsigned vg_visible_lvs(const struct volume_group *vg)
{
struct lv_list *lvl;
unsigned lv_count = 0;
dm_list_iterate_items(lvl, &vg->lvs) {
- if (lv_is_cow(lvl->lv))
- continue;
- if (lvl->lv->status & SNAPSHOT)
- continue;
- lv_count++;
+ if (lv_is_visible(lvl->lv))
+ lv_count++;
}
return lv_count;
@@ -1214,7 +1199,7 @@
}
if (vg_to->max_lv &&
- (vg_to->max_lv < volumes_count(vg_to) + volumes_count(vg_from))) {
+ (vg_to->max_lv < vg_visible_lvs(vg_to) + vg_visible_lvs(vg_from))) {
log_error("Maximum number of logical volumes (%d) exceeded "
" for \"%s\" and \"%s\"", vg_to->max_lv, vg_to->name,
vg_from->name);
@@ -1469,12 +1454,38 @@
r = 0;
}
- if ((lv_count = (uint32_t) dm_list_size(&vg->lvs)) !=
- volumes_count(vg) + 2 * snapshot_count(vg)) {
+ /*
+ * Count all non-snapshot invisible LVs
+ */
+ lv_count = 0;
+ dm_list_iterate_items(lvl, &vg->lvs) {
+ if (lvl->lv->status & VISIBLE_LV)
+ continue;
+
+ /* snapshots */
+ if (lv_is_cow(lvl->lv) || lv_is_origin(lvl->lv))
+ continue;
+
+ /* count other non-snapshot invisible volumes */
+ lv_count++;
+
+ /*
+ * FIXME: add check for unreferenced invisible LVs
+ * - snapshot cow & origin
+ * - mirror log & images
+ * - mirror conversion volumes (_mimagetmp*)
+ */
+ }
+
+ /*
+ * all volumes = visible LVs + snapshot_cows + invisible LVs
+ */
+ if (((uint32_t) dm_list_size(&vg->lvs)) !=
+ vg_visible_lvs(vg) + snapshot_count(vg) + lv_count) {
log_error("Internal error: #internal LVs (%u) != #LVs (%"
- PRIu32 ") + 2 * #snapshots (%" PRIu32 ") in VG %s",
- dm_list_size(&vg->lvs), volumes_count(vg),
- snapshot_count(vg), vg->name);
+ PRIu32 ") + #snapshots (%" PRIu32 ") + #invisible LVs %u in VG %s",
+ dm_list_size(&vg->lvs), vg_visible_lvs(vg),
+ snapshot_count(vg), lv_count, vg->name);
r = 0;
}
@@ -1517,10 +1528,10 @@
r = 0;
}
- if (vg->max_lv && (vg->max_lv < volumes_count(vg))) {
+ if (vg->max_lv && (vg->max_lv < vg_visible_lvs(vg))) {
log_error("Internal error: Volume group %s contains %u volumes"
" but the limit is set to %u.",
- vg->name, volumes_count(vg), vg->max_lv);
+ vg->name, vg_visible_lvs(vg), vg->max_lv);
r = 0;
}
--- LVM2/lib/metadata/metadata.h 2009/05/12 19:12:10 1.193
+++ LVM2/lib/metadata/metadata.h 2009/05/13 21:27:43 1.194
@@ -340,11 +340,6 @@
struct lv_segment *get_only_segment_using_this_lv(struct logical_volume *lv);
/*
- * Count LVs that are visible from user's perspective.
- */
-unsigned displayable_lvs_in_vg(const struct volume_group *vg);
-
-/*
* Count snapshot LVs.
*/
unsigned snapshot_count(const struct volume_group *vg);
--- LVM2/lib/metadata/snapshot_manip.c 2009/05/13 21:26:45 1.40
+++ LVM2/lib/metadata/snapshot_manip.c 2009/05/13 21:27:43 1.41
@@ -43,14 +43,6 @@
return lv->status & VISIBLE_LV ? 1 : 0;
}
-int lv_is_displayable(const struct logical_volume *lv)
-{
- if (lv->status & SNAPSHOT)
- return 0;
-
- return (lv->status & VISIBLE_LV) || lv_is_cow(lv) ? 1 : 0;
-}
-
int lv_is_virtual_origin(const struct logical_volume *lv)
{
return (lv->status & VIRTUAL_ORIGIN) ? 1 : 0;
--- LVM2/lib/report/report.c 2009/05/12 19:12:10 1.98
+++ LVM2/lib/report/report.c 2009/05/13 21:27:44 1.99
@@ -497,7 +497,7 @@
char *repstr, *lvname;
size_t len;
- if (lv_is_displayable(lv)) {
+ if (lv_is_visible(lv)) {
repstr = lv->name;
return dm_report_field_string(rh, field, (const char **) &repstr);
}
@@ -974,7 +974,7 @@
const struct volume_group *vg = (const struct volume_group *) data;
uint32_t count;
- count = displayable_lvs_in_vg(vg);
+ count = vg_visible_lvs(vg);
return _uint32_disp(rh, mem, field, &count, private);
}
--- LVM2/tools/lvchange.c 2009/04/25 01:18:00 1.99
+++ LVM2/tools/lvchange.c 2009/05/13 21:27:44 1.100
@@ -584,7 +584,7 @@
return ECMD_FAILED;
}
- if (!(lv_is_displayable(lv))) {
+ if (!(lv_is_visible(lv))) {
log_error("Unable to change internal LV %s directly",
lv->name);
return ECMD_FAILED;
--- LVM2/tools/lvdisplay.c 2008/12/04 15:54:27 1.21
+++ LVM2/tools/lvdisplay.c 2009/05/13 21:27:44 1.22
@@ -18,7 +18,7 @@
static int _lvdisplay_single(struct cmd_context *cmd, struct logical_volume *lv,
void *handle)
{
- if (!arg_count(cmd, all_ARG) && !lv_is_displayable(lv))
+ if (!arg_count(cmd, all_ARG) && !lv_is_visible(lv))
return ECMD_PROCESSED;
if (arg_count(cmd, colon_ARG))
--- LVM2/tools/lvscan.c 2008/12/04 15:54:27 1.37
+++ LVM2/tools/lvscan.c 2009/05/13 21:27:44 1.38
@@ -27,7 +27,7 @@
const char *active_str, *snapshot_str;
- if (!arg_count(cmd, all_ARG) && !lv_is_displayable(lv))
+ if (!arg_count(cmd, all_ARG) && !lv_is_visible(lv))
return ECMD_PROCESSED;
inkernel = lv_info(cmd, lv, &info, 1, 0) && info.exists;
--- LVM2/tools/reporter.c 2009/04/21 12:59:19 1.47
+++ LVM2/tools/reporter.c 2009/05/13 21:27:44 1.48
@@ -36,7 +36,7 @@
static int _lvs_single(struct cmd_context *cmd, struct logical_volume *lv,
void *handle)
{
- if (!arg_count(cmd, all_ARG) && !lv_is_displayable(lv))
+ if (!arg_count(cmd, all_ARG) && !lv_is_visible(lv))
return ECMD_PROCESSED;
if (!report_object(handle, lv->vg, lv, NULL, NULL, NULL))
@@ -113,7 +113,7 @@
static int _lvsegs_single(struct cmd_context *cmd, struct logical_volume *lv,
void *handle)
{
- if (!arg_count(cmd, all_ARG) && !lv_is_displayable(lv))
+ if (!arg_count(cmd, all_ARG) && !lv_is_visible(lv))
return ECMD_PROCESSED;
return process_each_segment_in_lv(cmd, lv, handle, _segs_single);
--- LVM2/tools/vgchange.c 2009/05/13 21:22:57 1.70
+++ LVM2/tools/vgchange.c 2009/05/13 21:27:44 1.71
@@ -308,9 +308,9 @@
}
}
- if (max_lv && max_lv < volumes_count(vg)) {
+ if (max_lv && max_lv < vg_visible_lvs(vg)) {
log_error("MaxLogicalVolume is less than the current number "
- "%d of LVs for %s", volumes_count(vg),
+ "%d of LVs for %s", vg_visible_lvs(vg),
vg->name);
return ECMD_FAILED;
}
^ permalink raw reply [flat|nested] 2+ messages in thread
* LVM2 ./WHATS_NEW lib/activate/activate.c lib/d ...
@ 2008-12-04 15:54 prajnoha
0 siblings, 0 replies; 2+ messages in thread
From: prajnoha @ 2008-12-04 15:54 UTC (permalink / raw)
To: lvm-devel, lvm2-cvs
CVSROOT: /cvs/lvm2
Module name: LVM2
Changes by: prajnoha@sourceware.org 2008-12-04 15:54:27
Modified files:
. : WHATS_NEW
lib/activate : activate.c
lib/display : display.c
lib/format_text: export.c
lib/metadata : lv_manip.c metadata-exported.h metadata.c
metadata.h snapshot_manip.c
lib/report : report.c
tools : lvchange.c lvdisplay.c lvscan.c reporter.c
Log message:
Added displayable_lvs_in_vg and lv_is_displayable functions to deal with
the counts of visible LVs from user's perspective consistently throughout
the code.
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.1003&r2=1.1004
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/activate/activate.c.diff?cvsroot=lvm2&r1=1.140&r2=1.141
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/display/display.c.diff?cvsroot=lvm2&r1=1.95&r2=1.96
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/format_text/export.c.diff?cvsroot=lvm2&r1=1.65&r2=1.66
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/lv_manip.c.diff?cvsroot=lvm2&r1=1.159&r2=1.160
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata-exported.h.diff?cvsroot=lvm2&r1=1.55&r2=1.56
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.c.diff?cvsroot=lvm2&r1=1.195&r2=1.196
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.h.diff?cvsroot=lvm2&r1=1.184&r2=1.185
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/snapshot_manip.c.diff?cvsroot=lvm2&r1=1.32&r2=1.33
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/report/report.c.diff?cvsroot=lvm2&r1=1.89&r2=1.90
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/lvchange.c.diff?cvsroot=lvm2&r1=1.93&r2=1.94
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/lvdisplay.c.diff?cvsroot=lvm2&r1=1.20&r2=1.21
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/lvscan.c.diff?cvsroot=lvm2&r1=1.36&r2=1.37
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/reporter.c.diff?cvsroot=lvm2&r1=1.41&r2=1.42
--- LVM2/WHATS_NEW 2008/12/01 20:14:33 1.1003
+++ LVM2/WHATS_NEW 2008/12/04 15:54:26 1.1004
@@ -1,5 +1,6 @@
Version 2.02.44 -
====================================
+ Use displayable_lvs_in_vg and lv_is_displayable for consistency throughout.
Fix race in vgcreate that would result in second caller overwriting first.
Fix uninitialised lv_count in vgdisplay -c.
Don't skip updating pvid hash when lvmcache_info struct got swapped.
--- LVM2/lib/activate/activate.c 2008/11/03 22:14:27 1.140
+++ LVM2/lib/activate/activate.c 2008/12/04 15:54:26 1.141
@@ -666,7 +666,7 @@
return 0;
dm_list_iterate_items(lvl, &vg->lvs) {
- if (lvl->lv->status & VISIBLE_LV)
+ if (lv_is_displayable(lvl->lv))
count += (_lv_open_count(vg->cmd, lvl->lv) > 0);
}
--- LVM2/lib/display/display.c 2008/12/01 17:38:35 1.95
+++ LVM2/lib/display/display.c 2008/12/04 15:54:27 1.96
@@ -574,8 +574,6 @@
{
uint32_t access_str;
uint32_t active_pvs;
- uint32_t lv_count = 0;
- struct lv_list *lvl;
char uuid[64] __attribute((aligned(8)));
active_pvs = vg->pv_count - vg_missing_pv_count(vg);
@@ -607,12 +605,8 @@
vg->status & SHARED ? "yes" : "no");
}
- dm_list_iterate_items(lvl, &vg->lvs)
- if (lv_is_visible(lvl->lv) && !(lvl->lv->status & SNAPSHOT))
- lv_count++;
-
log_print("MAX LV %u", vg->max_lv);
- log_print("Cur LV %u", lv_count);
+ log_print("Cur LV %u", displayable_lvs_in_vg(vg));
log_print("Open LV %u", lvs_in_vg_opened(vg));
/****** FIXME Max LV Size
log_print ( "MAX LV Size %s",
@@ -656,17 +650,11 @@
void vgdisplay_colons(const struct volume_group *vg)
{
uint32_t active_pvs;
- uint32_t lv_count = 0;
- struct lv_list *lvl;
const char *access_str;
char uuid[64] __attribute((aligned(8)));
active_pvs = vg->pv_count - vg_missing_pv_count(vg);
- dm_list_iterate_items(lvl, &vg->lvs)
- if (lv_is_visible(lvl->lv) && !(lvl->lv->status & SNAPSHOT))
- lv_count++;
-
switch (vg->status & (LVM_READ | LVM_WRITE)) {
case LVM_READ | LVM_WRITE:
access_str = "r/w";
@@ -693,7 +681,7 @@
vg->status,
/* internal volume group number; obsolete */
vg->max_lv,
- vg->lv_count,
+ displayable_lvs_in_vg(vg),
lvs_in_vg_opened(vg),
/* FIXME: maximum logical volume size */
vg->max_pv,
--- LVM2/lib/format_text/export.c 2008/11/03 22:14:28 1.65
+++ LVM2/lib/format_text/export.c 2008/12/04 15:54:27 1.66
@@ -592,14 +592,14 @@
* Write visible LVs first
*/
dm_list_iterate_items(lvl, &vg->lvs) {
- if (!(lvl->lv->status & VISIBLE_LV))
+ if (!(lv_is_displayable(lvl->lv)))
continue;
if (!_print_lv(f, lvl->lv))
return_0;
}
dm_list_iterate_items(lvl, &vg->lvs) {
- if ((lvl->lv->status & VISIBLE_LV))
+ if ((lv_is_displayable(lvl->lv)))
continue;
if (!_print_lv(f, lvl->lv))
return_0;
--- LVM2/lib/metadata/lv_manip.c 2008/11/03 22:14:29 1.159
+++ LVM2/lib/metadata/lv_manip.c 2008/12/04 15:54:27 1.160
@@ -1715,7 +1715,7 @@
struct lv_names lv_names;
/* rename is not allowed on sub LVs */
- if (!lv_is_visible(lv)) {
+ if (!lv_is_displayable(lv)) {
log_error("Cannot rename internal LV \"%s\".", lv->name);
return 0;
}
--- LVM2/lib/metadata/metadata-exported.h 2008/11/03 22:14:29 1.55
+++ LVM2/lib/metadata/metadata-exported.h 2008/12/04 15:54:27 1.56
@@ -483,6 +483,9 @@
int lv_is_cow(const struct logical_volume *lv);
int lv_is_visible(const struct logical_volume *lv);
+/* Test if given LV is visible from user's perspective */
+int lv_is_displayable(const struct logical_volume *lv);
+
int pv_is_in_vg(struct volume_group *vg, struct physical_volume *pv);
/* Given a cow LV, return return the snapshot lv_segment that uses it */
--- LVM2/lib/metadata/metadata.c 2008/11/03 22:14:29 1.195
+++ LVM2/lib/metadata/metadata.c 2008/12/04 15:54:27 1.196
@@ -337,6 +337,7 @@
{
struct physical_volume *pv;
struct pv_list *pvl;
+ unsigned lv_count;
int ret = 1;
if (!vg || !consistent || vg_missing_pv_count(vg)) {
@@ -350,22 +351,26 @@
if (!vg_check_status(vg, EXPORTED_VG))
return 0;
- if (vg->lv_count) {
+ lv_count = displayable_lvs_in_vg(vg);
+
+ if (lv_count) {
if ((force == PROMPT) &&
(yes_no_prompt("Do you really want to remove volume "
- "group \"%s\" containing %d "
+ "group \"%s\" containing %u "
"logical volumes? [y/n]: ",
- vg_name, vg->lv_count) == 'n')) {
+ vg_name, lv_count) == 'n')) {
log_print("Volume group \"%s\" not removed", vg_name);
return 0;
}
if (!remove_lvs_in_vg(cmd, vg, force))
return 0;
}
+
+ lv_count = displayable_lvs_in_vg(vg);
- if (vg->lv_count) {
- log_error("Volume group \"%s\" still contains %d "
- "logical volume(s)", vg_name, vg->lv_count);
+ if (lv_count) {
+ log_error("Volume group \"%s\" still contains %u "
+ "logical volume(s)", vg_name, lv_count);
return 0;
}
@@ -1098,6 +1103,18 @@
return 1;
}
+unsigned displayable_lvs_in_vg(const struct volume_group *vg)
+{
+ struct lv_list *lvl;
+ unsigned lv_count = 0;
+
+ dm_list_iterate_items(lvl, &vg->lvs)
+ if (lv_is_displayable(lvl->lv))
+ lv_count++;
+
+ return lv_count;
+}
+
/*
* Determine whether two vgs are compatible for merging.
*/
--- LVM2/lib/metadata/metadata.h 2008/11/03 22:14:29 1.184
+++ LVM2/lib/metadata/metadata.h 2008/12/04 15:54:27 1.185
@@ -321,6 +321,11 @@
struct lv_segment *get_only_segment_using_this_lv(struct logical_volume *lv);
/*
+ * Count LVs that are visible from user's perspective.
+ */
+unsigned displayable_lvs_in_vg(const struct volume_group *vg);
+
+/*
* For internal metadata caching.
*/
int export_vg_to_buffer(struct volume_group *vg, char **buf);
--- LVM2/lib/metadata/snapshot_manip.c 2008/11/03 22:14:29 1.32
+++ LVM2/lib/metadata/snapshot_manip.c 2008/12/04 15:54:27 1.33
@@ -36,6 +36,14 @@
return lv->status & VISIBLE_LV ? 1 : 0;
}
+int lv_is_displayable(const struct logical_volume *lv)
+{
+ if (lv->status & SNAPSHOT)
+ return 0;
+
+ return (lv->status & VISIBLE_LV) || lv_is_cow(lv) ? 1 : 0;
+}
+
/* Given a cow LV, return the snapshot lv_segment that uses it */
struct lv_segment *find_cow(const struct logical_volume *lv)
{
--- LVM2/lib/report/report.c 2008/11/03 22:14:29 1.89
+++ LVM2/lib/report/report.c 2008/12/04 15:54:27 1.90
@@ -511,7 +511,7 @@
char *repstr, *lvname;
size_t len;
- if (lv_is_visible(lv)) {
+ if (lv_is_displayable(lv)) {
repstr = lv->name;
return dm_report_field_string(rh, field, (const char **) &repstr);
}
@@ -911,12 +911,9 @@
const void *data, void *private)
{
const struct volume_group *vg = (const struct volume_group *) data;
- struct lv_list *lvl;
- uint32_t count = 0;
+ uint32_t count;
- dm_list_iterate_items(lvl, &vg->lvs)
- if (lv_is_visible(lvl->lv) && !(lvl->lv->status & SNAPSHOT))
- count++;
+ count = displayable_lvs_in_vg(vg);
return _uint32_disp(rh, mem, field, &count, private);
}
--- LVM2/tools/lvchange.c 2008/07/31 13:03:01 1.93
+++ LVM2/tools/lvchange.c 2008/12/04 15:54:27 1.94
@@ -590,7 +590,7 @@
return ECMD_FAILED;
}
- if (!(lv->status & VISIBLE_LV)) {
+ if (!(lv_is_displayable(lv))) {
log_error("Unable to change internal LV %s directly",
lv->name);
return ECMD_FAILED;
--- LVM2/tools/lvdisplay.c 2008/01/30 14:00:01 1.20
+++ LVM2/tools/lvdisplay.c 2008/12/04 15:54:27 1.21
@@ -18,7 +18,7 @@
static int _lvdisplay_single(struct cmd_context *cmd, struct logical_volume *lv,
void *handle)
{
- if (!arg_count(cmd, all_ARG) && !lv_is_visible(lv))
+ if (!arg_count(cmd, all_ARG) && !lv_is_displayable(lv))
return ECMD_PROCESSED;
if (arg_count(cmd, colon_ARG))
--- LVM2/tools/lvscan.c 2008/11/03 22:14:30 1.36
+++ LVM2/tools/lvscan.c 2008/12/04 15:54:27 1.37
@@ -27,7 +27,7 @@
const char *active_str, *snapshot_str;
- if (!arg_count(cmd, all_ARG) && !lv_is_visible(lv))
+ if (!arg_count(cmd, all_ARG) && !lv_is_displayable(lv))
return ECMD_PROCESSED;
inkernel = lv_info(cmd, lv, &info, 1, 0) && info.exists;
--- LVM2/tools/reporter.c 2008/11/03 22:14:30 1.41
+++ LVM2/tools/reporter.c 2008/12/04 15:54:27 1.42
@@ -36,7 +36,7 @@
static int _lvs_single(struct cmd_context *cmd, struct logical_volume *lv,
void *handle)
{
- if (!arg_count(cmd, all_ARG) && !lv_is_visible(lv))
+ if (!arg_count(cmd, all_ARG) && !lv_is_displayable(lv))
return ECMD_PROCESSED;
if (!report_object(handle, lv->vg, lv, NULL, NULL, NULL))
@@ -102,7 +102,7 @@
static int _lvsegs_single(struct cmd_context *cmd, struct logical_volume *lv,
void *handle)
{
- if (!arg_count(cmd, all_ARG) && !lv_is_visible(lv))
+ if (!arg_count(cmd, all_ARG) && !lv_is_displayable(lv))
return ECMD_PROCESSED;
return process_each_segment_in_lv(cmd, lv, handle, _segs_single);
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2009-05-13 21:27 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-05-13 21:27 LVM2 ./WHATS_NEW lib/activate/activate.c lib/d mbroz
-- strict thread matches above, loose matches on Subject: below --
2008-12-04 15:54 prajnoha
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).