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:
parent
7810d55dfc
commit
2cd0aa727a
@ -1,5 +1,6 @@
|
||||
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.
|
||||
|
@ -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);
|
||||
|
||||
/* 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,
|
||||
|
@ -34,6 +34,12 @@ struct lv_segment *find_cow(const struct logical_volume *lv)
|
||||
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,
|
||||
|
@ -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;
|
||||
struct lvinfo info;
|
||||
char *repstr;
|
||||
struct lv_segment *snap_seg;
|
||||
float snap_percent;
|
||||
|
||||
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';
|
||||
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] = '-';
|
||||
@ -377,8 +376,8 @@ static int _lvstatus_disp(struct report_handle *rh, struct field *field,
|
||||
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)
|
||||
@ -491,10 +490,9 @@ static int _origin_disp(struct report_handle *rh, struct field *field,
|
||||
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;
|
||||
@ -667,11 +665,10 @@ static int _chunksize_disp(struct report_handle *rh, struct field *field,
|
||||
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;
|
||||
|
||||
|
@ -83,7 +83,7 @@ static int lvremove_single(struct cmd_context *cmd, struct logical_volume *lv,
|
||||
}
|
||||
|
||||
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;
|
||||
|
@ -116,7 +116,6 @@ static int _lvresize(struct cmd_context *cmd, struct lvresize_params *lp)
|
||||
{
|
||||
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;
|
||||
@ -521,8 +520,8 @@ static int _lvresize(struct cmd_context *cmd, struct lvresize_params *lp)
|
||||
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;
|
||||
|
||||
|
@ -43,9 +43,9 @@ static int lvscan_single(struct cmd_context *cmd, struct logical_volume *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;
|
||||
|
@ -198,7 +198,7 @@ static int _vgchange_clustered(struct cmd_context *cmd,
|
||||
|
||||
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);
|
||||
|
Loading…
Reference in New Issue
Block a user