mirror of
git://sourceware.org/git/lvm2.git
synced 2025-01-03 05:18:29 +03:00
o Added function find_snapshots to snapshot_manip.c that returns a list
of snapshots whose origin is the lv passed in. o Used this new function to make lvdisplay properly display all snapshots attached to a origin.
This commit is contained in:
parent
0474ad51c2
commit
fccc39a3a7
@ -247,12 +247,17 @@ int lvdisplay_full(struct cmd_context *cmd, struct logical_volume *lv)
|
||||
log_print("LV Write Access %s",
|
||||
(lv->status & LVM_WRITE) ? "read/write" : "read only");
|
||||
|
||||
/* see if this LV is an origina for a snapshot */
|
||||
/* see if this LV is an origin for a snapshot */
|
||||
if ((snap = find_origin(lv))) {
|
||||
struct list *slh, *snaplist = find_snapshots(lv);
|
||||
|
||||
list_iterate(slh, snaplist) {
|
||||
snap = list_item(slh, struct snapshot_list)->snapshot;
|
||||
log_print("LV snapshot status source of");
|
||||
log_print(" %s%s/%s [%s]",
|
||||
lv->vg->cmd->dev_dir, lv->vg->name, snap->cow->name,
|
||||
"active");
|
||||
lv->vg->cmd->dev_dir, lv->vg->name,
|
||||
snap->cow->name, "active");
|
||||
}
|
||||
/* reset so we don't try to use this to display other snapshot
|
||||
* related information. */
|
||||
snap = NULL;
|
||||
|
@ -394,6 +394,7 @@ int lv_is_cow(struct logical_volume *lv);
|
||||
|
||||
struct snapshot *find_cow(struct logical_volume *lv);
|
||||
struct snapshot *find_origin(struct logical_volume *lv);
|
||||
struct list *find_snapshots(struct logical_volume *lv);
|
||||
|
||||
int vg_add_snapshot(struct logical_volume *origin,
|
||||
struct logical_volume *cow,
|
||||
|
@ -64,6 +64,39 @@ struct snapshot *find_cow(struct logical_volume *lv)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
struct list *find_snapshots(struct logical_volume *lv)
|
||||
{
|
||||
struct list *slh;
|
||||
struct list *snaplist;
|
||||
struct snapshot_list *sl, *newsl;
|
||||
struct pool *mem = lv->vg->cmd->mem;
|
||||
|
||||
if (!(snaplist = pool_alloc(mem, sizeof(*snaplist)))) {
|
||||
log_error("snapshot name list allocation failed");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
list_init(snaplist);
|
||||
|
||||
list_iterate(slh, &lv->vg->snapshots) {
|
||||
sl = list_item(slh, struct snapshot_list);
|
||||
if (sl->snapshot->origin == lv) {
|
||||
if(!(newsl = pool_alloc(mem, sizeof(*newsl)))) {
|
||||
log_error("snapshot_list structure allocation"
|
||||
" failed");
|
||||
pool_free(mem, snaplist);
|
||||
return NULL;
|
||||
}
|
||||
newsl->snapshot = sl->snapshot;
|
||||
list_add(snaplist, &newsl->list);
|
||||
}
|
||||
}
|
||||
|
||||
return snaplist;
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int vg_add_snapshot(struct logical_volume *origin,
|
||||
struct logical_volume *cow,
|
||||
int persistent, uint32_t chunk_size)
|
||||
|
Loading…
Reference in New Issue
Block a user