1
0
mirror of git://sourceware.org/git/lvm2.git synced 2025-01-02 01:18:26 +03:00

Introduce origin_from_cow()

This commit is contained in:
Alasdair Kergon 2006-04-06 13:39:16 +00:00
parent 7810d55dfc
commit 2cd0aa727a
8 changed files with 24 additions and 17 deletions

View File

@ -1,5 +1,6 @@
Version 2.02.03 - Version 2.02.03 -
=================================== ===================================
Introduce origin_from_cow().
pvremove without -f now fails if there's no PV label. pvremove without -f now fails if there's no PV label.
Support lvconvert -s. Support lvconvert -s.
Suppress locking library load failure message if --ignorelockingfailure. Suppress locking library load failure message if --ignorelockingfailure.

View File

@ -538,8 +538,12 @@ int lv_is_cow(const struct logical_volume *lv);
int pv_is_in_vg(struct volume_group *vg, struct physical_volume *pv); 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); 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, int vg_add_snapshot(struct format_instance *fid, const char *name,
struct logical_volume *origin, struct logical_volume *cow, struct logical_volume *origin, struct logical_volume *cow,
union lvid *lvid, uint32_t extent_count, union lvid *lvid, uint32_t extent_count,

View File

@ -34,6 +34,12 @@ struct lv_segment *find_cow(const struct logical_volume *lv)
return lv->snapshot; 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, int vg_add_snapshot(struct format_instance *fid, const char *name,
struct logical_volume *origin, struct logical_volume *origin,
struct logical_volume *cow, union lvid *lvid, struct logical_volume *cow, union lvid *lvid,

View File

@ -324,7 +324,6 @@ static int _lvstatus_disp(struct report_handle *rh, struct field *field,
const struct logical_volume *lv = (const struct logical_volume *) data; const struct logical_volume *lv = (const struct logical_volume *) data;
struct lvinfo info; struct lvinfo info;
char *repstr; char *repstr;
struct lv_segment *snap_seg;
float snap_percent; float snap_percent;
if (!(repstr = dm_pool_zalloc(rh->mem, 7))) { if (!(repstr = dm_pool_zalloc(rh->mem, 7))) {
@ -344,7 +343,7 @@ static int _lvstatus_disp(struct report_handle *rh, struct field *field,
repstr[0] = 'v'; repstr[0] = 'v';
else if (lv_is_origin(lv)) else if (lv_is_origin(lv))
repstr[0] = 'o'; repstr[0] = 'o';
else if (find_cow(lv)) else if (lv_is_cow(lv))
repstr[0] = 's'; repstr[0] = 's';
else else
repstr[0] = '-'; repstr[0] = '-';
@ -377,8 +376,8 @@ static int _lvstatus_disp(struct report_handle *rh, struct field *field,
repstr[4] = 'd'; /* Inactive without table */ repstr[4] = 'd'; /* Inactive without table */
/* Snapshot dropped? */ /* Snapshot dropped? */
if (info.live_table && (snap_seg = find_cow(lv)) && if (info.live_table && lv_is_cow(lv) &&
(!lv_snapshot_percent(snap_seg->cow, &snap_percent) || (!lv_snapshot_percent(find_cow(lv)->cow, &snap_percent) ||
snap_percent < 0 || snap_percent >= 100)) { snap_percent < 0 || snap_percent >= 100)) {
repstr[0] = toupper(repstr[0]); repstr[0] = toupper(repstr[0]);
if (info.suspended) if (info.suspended)
@ -491,10 +490,9 @@ static int _origin_disp(struct report_handle *rh, struct field *field,
const void *data) const void *data)
{ {
const struct logical_volume *lv = (const struct logical_volume *) data; const struct logical_volume *lv = (const struct logical_volume *) data;
struct lv_segment *snap_seg;
if ((snap_seg = find_cow(lv))) if (lv_is_cow(lv))
return _string_disp(rh, field, &snap_seg->origin->name); return _string_disp(rh, field, &origin_from_cow(lv)->name);
field->report_string = ""; field->report_string = "";
field->sort_value = (const void *) field->report_string; field->sort_value = (const void *) field->report_string;
@ -667,11 +665,10 @@ static int _chunksize_disp(struct report_handle *rh, struct field *field,
const void *data) const void *data)
{ {
const struct lv_segment *seg = (const struct lv_segment *) data; const struct lv_segment *seg = (const struct lv_segment *) data;
struct lv_segment *snap_seg;
uint64_t size; uint64_t size;
if ((snap_seg = find_cow(seg->lv))) if (lv_is_cow(seg->lv))
size = (uint64_t) snap_seg->chunk_size; size = (uint64_t) find_cow(seg->lv)->chunk_size;
else else
size = 0; size = 0;

View File

@ -83,7 +83,7 @@ static int lvremove_single(struct cmd_context *cmd, struct logical_volume *lv,
} }
if (lv_is_cow(lv)) { if (lv_is_cow(lv)) {
origin = find_cow(lv)->origin; origin = origin_from_cow(lv);
log_verbose("Removing snapshot %s", lv->name); log_verbose("Removing snapshot %s", lv->name);
if (!vg_remove_snapshot(lv)) { if (!vg_remove_snapshot(lv)) {
stack; stack;

View File

@ -116,7 +116,6 @@ static int _lvresize(struct cmd_context *cmd, struct lvresize_params *lp)
{ {
struct volume_group *vg; struct volume_group *vg;
struct logical_volume *lv; struct logical_volume *lv;
struct lv_segment *snap_seg;
struct lvinfo info; struct lvinfo info;
uint32_t stripesize_extents = 0; uint32_t stripesize_extents = 0;
uint32_t seg_stripes = 0, seg_stripesize = 0, seg_size = 0; uint32_t seg_stripes = 0, seg_stripesize = 0, seg_size = 0;
@ -521,8 +520,8 @@ static int _lvresize(struct cmd_context *cmd, struct lvresize_params *lp)
backup(vg); backup(vg);
/* If snapshot, must suspend all associated devices */ /* If snapshot, must suspend all associated devices */
if ((snap_seg = find_cow(lv))) if (lv_is_cow(lv))
lock_lv = snap_seg->origin; lock_lv = origin_from_cow(lv);
else else
lock_lv = lv; lock_lv = lv;

View File

@ -43,9 +43,9 @@ static int lvscan_single(struct cmd_context *cmd, struct logical_volume *lv,
snap_active = 0; snap_active = 0;
} }
snap_seg = NULL; snap_seg = NULL;
} else if ((snap_seg = find_cow(lv))) { } else if (lv_is_cow(lv)) {
if (inkernel && if (inkernel &&
(snap_active = lv_snapshot_percent(snap_seg->cow, (snap_active = lv_snapshot_percent(find_cow(lv)->cow,
&snap_percent))) &snap_percent)))
if (snap_percent < 0 || snap_percent >= 100) if (snap_percent < 0 || snap_percent >= 100)
snap_active = 0; snap_active = 0;

View File

@ -198,7 +198,7 @@ static int _vgchange_clustered(struct cmd_context *cmd,
if (clustered) { if (clustered) {
list_iterate_items(lvl, &vg->lvs) { 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 " log_error("Volume group %s contains snapshots "
"that are not yet supported.", "that are not yet supported.",
vg->name); vg->name);