Version 2.02.03 -
===================================
+ Introduce origin_from_cow().
pvremove without -f now fails if there's no PV label.
Support lvconvert -s.
Suppress locking library load failure message if --ignorelockingfailure.
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 */
struct lv_segment *find_cow(const struct logical_volume *lv);
+/* Given a cow LV, return its origin */
+struct logical_volume *origin_from_cow(const struct logical_volume *lv);
+
int vg_add_snapshot(struct format_instance *fid, const char *name,
struct logical_volume *origin, struct logical_volume *cow,
union lvid *lvid, uint32_t extent_count,
return lv->snapshot;
}
+/* Given a cow LV, return its origin */
+struct logical_volume *origin_from_cow(const struct logical_volume *lv)
+{
+ return lv->snapshot->origin;
+}
+
int vg_add_snapshot(struct format_instance *fid, const char *name,
struct logical_volume *origin,
struct logical_volume *cow, union lvid *lvid,
const struct logical_volume *lv = (const struct logical_volume *) data;
struct lvinfo info;
char *repstr;
- struct lv_segment *snap_seg;
float snap_percent;
if (!(repstr = dm_pool_zalloc(rh->mem, 7))) {
repstr[0] = 'v';
else if (lv_is_origin(lv))
repstr[0] = 'o';
- else if (find_cow(lv))
+ else if (lv_is_cow(lv))
repstr[0] = 's';
else
repstr[0] = '-';
repstr[4] = 'd'; /* Inactive without table */
/* Snapshot dropped? */
- if (info.live_table && (snap_seg = find_cow(lv)) &&
- (!lv_snapshot_percent(snap_seg->cow, &snap_percent) ||
+ if (info.live_table && lv_is_cow(lv) &&
+ (!lv_snapshot_percent(find_cow(lv)->cow, &snap_percent) ||
snap_percent < 0 || snap_percent >= 100)) {
repstr[0] = toupper(repstr[0]);
if (info.suspended)
const void *data)
{
const struct logical_volume *lv = (const struct logical_volume *) data;
- struct lv_segment *snap_seg;
- if ((snap_seg = find_cow(lv)))
- return _string_disp(rh, field, &snap_seg->origin->name);
+ if (lv_is_cow(lv))
+ return _string_disp(rh, field, &origin_from_cow(lv)->name);
field->report_string = "";
field->sort_value = (const void *) field->report_string;
const void *data)
{
const struct lv_segment *seg = (const struct lv_segment *) data;
- struct lv_segment *snap_seg;
uint64_t size;
- if ((snap_seg = find_cow(seg->lv)))
- size = (uint64_t) snap_seg->chunk_size;
+ if (lv_is_cow(seg->lv))
+ size = (uint64_t) find_cow(seg->lv)->chunk_size;
else
size = 0;
}
if (lv_is_cow(lv)) {
- origin = find_cow(lv)->origin;
+ origin = origin_from_cow(lv);
log_verbose("Removing snapshot %s", lv->name);
if (!vg_remove_snapshot(lv)) {
stack;
{
struct volume_group *vg;
struct logical_volume *lv;
- struct lv_segment *snap_seg;
struct lvinfo info;
uint32_t stripesize_extents = 0;
uint32_t seg_stripes = 0, seg_stripesize = 0, seg_size = 0;
backup(vg);
/* If snapshot, must suspend all associated devices */
- if ((snap_seg = find_cow(lv)))
- lock_lv = snap_seg->origin;
+ if (lv_is_cow(lv))
+ lock_lv = origin_from_cow(lv);
else
lock_lv = lv;
snap_active = 0;
}
snap_seg = NULL;
- } else if ((snap_seg = find_cow(lv))) {
+ } else if (lv_is_cow(lv)) {
if (inkernel &&
- (snap_active = lv_snapshot_percent(snap_seg->cow,
+ (snap_active = lv_snapshot_percent(find_cow(lv)->cow,
&snap_percent)))
if (snap_percent < 0 || snap_percent >= 100)
snap_active = 0;
if (clustered) {
list_iterate_items(lvl, &vg->lvs) {
- if (lvl->lv->origin_count || lvl->lv->snapshot) {
+ if (lv_is_origin(lvl->lv) || lv_is_cow(lvl->lv)) {
log_error("Volume group %s contains snapshots "
"that are not yet supported.",
vg->name);