Version 2.02.46 -
================================
+ Remove snapshot_count from VG and use function instead.
Fix first_seg() call for empty segment list.
Add make install_lvm2 as complement to device-mapper install.
Reject missing PVs from allocation in toollib.
vgd->vg_status |= VG_EXTENDABLE;
vgd->lv_max = vg->max_lv;
- vgd->lv_cur = vg->lv_count + vg->snapshot_count;
+ vgd->lv_cur = vg->lv_count + snapshot_count(vg);
vgd->pv_max = vg->max_pv;
vgd->pv_cur = vg->pv_count;
vg->extent_count = 0;
vg->pv_count = 0;
vg->lv_count = 0;
- vg->snapshot_count = 0;
vg->seqno = 1;
vg->system_id = NULL;
dm_list_init(&vg->pvs);
* 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, but we
- * multiply the snapshot_count by 2.
+ * Neither of these instances is reflected in lv_count.
*
* Mirrors consist of multiple instances of "struct logical_volume":
* - one for the mirror log
* all of the instances are reflected in lv_count.
*/
uint32_t lv_count;
- uint32_t snapshot_count;
struct dm_list lvs;
struct dm_list tags;
vg->lv_count = 0;
dm_list_init(&vg->lvs);
- vg->snapshot_count = 0;
-
dm_list_init(&vg->tags);
if (!(vg->fid = cmd->fmt->ops->create_instance(cmd->fmt, vg_name,
return lv_count;
}
+unsigned snapshot_count(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))
+ lv_count++;
+
+ return lv_count;
+}
+
/*
* Determine whether two vgs are compatible for merging.
*/
}
if ((lv_count = (uint32_t) dm_list_size(&vg->lvs)) !=
- vg->lv_count + 2 * vg->snapshot_count) {
+ vg->lv_count + 2 * snapshot_count(vg)) {
log_error("Internal error: #internal LVs (%u) != #LVs (%"
PRIu32 ") + 2 * #snapshots (%" PRIu32 ") in VG %s",
dm_list_size(&vg->lvs), vg->lv_count,
- vg->snapshot_count, vg->name);
+ snapshot_count(vg), vg->name);
r = 0;
}
*/
unsigned displayable_lvs_in_vg(const struct volume_group *vg);
+/*
+ * Count snapshot LVs.
+ */
+unsigned snapshot_count(const struct volume_group *vg);
+
/*
* For internal metadata caching.
*/
seg->lv->status |= SNAPSHOT;
origin->origin_count++;
- origin->vg->snapshot_count++;
cow->snapshot = seg;
cow->status &= ~VISIBLE_LV;
cow->snapshot = NULL;
- cow->vg->snapshot_count--;
cow->vg->lv_count++;
cow->status |= VISIBLE_LV;
FIELD(VGS, vg, NUM, "MaxPV", max_pv, 5, uint32, "max_pv", "Maximum number of PVs allowed in VG or 0 if unlimited.")
FIELD(VGS, vg, NUM, "#PV", pv_count, 3, uint32, "pv_count", "Number of PVs.")
FIELD(VGS, vg, NUM, "#LV", cmd, 3, lvcount, "lv_count", "Number of LVs.")
-FIELD(VGS, vg, NUM, "#SN", snapshot_count, 3, uint32, "snap_count", "Number of snapshots.")
+FIELD(VGS, vg, NUM, "#SN", cmd, 3, snapcount, "snap_count", "Number of snapshots.")
FIELD(VGS, vg, NUM, "Seq", seqno, 3, uint32, "vg_seqno", "Revision number of internal metadata. Incremented whenever it changes.")
FIELD(VGS, vg, STR, "VG Tags", tags, 7, tags, "vg_tags", "Tags, if any.")
FIELD(VGS, vg, NUM, "#VMda", cmd, 5, vgmdas, "vg_mda_count", "Number of metadata areas in use by this VG.")
return _uint32_disp(rh, mem, field, &count, private);
}
+static int _snapcount_disp(struct dm_report *rh, struct dm_pool *mem,
+ struct dm_report_field *field,
+ const void *data, void *private)
+{
+ const struct volume_group *vg = (const struct volume_group *) data;
+ uint32_t count;
+
+ count = snapshot_count(vg);
+
+ return _uint32_disp(rh, mem, field, &count, private);
+}
+
static int _snpercent_disp(struct dm_report *rh __attribute((unused)), struct dm_pool *mem,
struct dm_report_field *field,
const void *data, void *private __attribute((unused)))
}
vg_to->lv_count += vg_from->lv_count;
- vg_to->snapshot_count += vg_from->snapshot_count;
-
vg_to->extent_count += vg_from->extent_count;
vg_to->free_count += vg_from->free_count;
return 0;
}
- if (lv->status & SNAPSHOT) {
- vg_from->snapshot_count--;
- vg_to->snapshot_count++;
- } else if (!lv_is_cow(lv)) {
+ if (!(lv->status & SNAPSHOT) && !lv_is_cow(lv)) {
vg_from->lv_count--;
vg_to->lv_count++;
}