1
0
mirror of git://sourceware.org/git/lvm2.git synced 2024-10-28 03:27:58 +03:00

Conditionally push down either the "snapshot-origin" or

"snapshot-merge" target based on whether the LV is a merging snapshot.

When activating a snapshot-merge target do not attempt to monitor the
LV for events; the polldaemon will monitor the snapshot as it is
merged.

Allow "snapshot-merge" target's usage to be parsed via standard
"snapshot" methods.

NOTE: follow on fixes to the _percent_run change are still needed
This commit is contained in:
Mike Snitzer 2010-01-13 01:43:32 +00:00
parent aa6f4e51a7
commit c21b944a35
2 changed files with 55 additions and 5 deletions

View File

@ -754,7 +754,7 @@ int monitor_dev_for_events(struct cmd_context *cmd,
* In case of a snapshot device, we monitor lv->snapshot->lv,
* not the actual LV itself.
*/
if (lv_is_cow(lv))
if (lv_is_cow(lv) && !(find_cow(lv)->status & SNAPSHOT_MERGE))
return monitor_dev_for_events(cmd, lv->snapshot->lv, monitor);
/*

View File

@ -395,10 +395,16 @@ static int _percent_run(struct dev_manager *dm, const char *name,
seg = dm_list_item(segh, struct lv_segment);
}
if (!type || !params || strcmp(type, target_type))
/*
* If target status doesn't have 'params' or 'type' is not in the same
* target base class as 'target_type' (e.g. snapshot*, mirror*) skip it
* - allows the situation when 'type' is "snapshot-merge" and
* 'target_type' is "snapshot"
*/
if (!type || !params || strncmp(type, target_type, strlen(target_type)))
continue;
if (!(segtype = get_segtype_from_string(dm->cmd, type)))
if (!(segtype = get_segtype_from_string(dm->cmd, target_type)))
continue;
if (segtype->ops->target_percent &&
@ -890,6 +896,29 @@ static int _add_origin_target_to_dtree(struct dev_manager *dm,
return 1;
}
static int _add_snapshot_merge_target_to_dtree(struct dev_manager *dm,
struct dm_tree_node *dnode,
struct logical_volume *lv)
{
const char *origin_dlid, *cow_dlid, *merge_dlid;
if (!(origin_dlid = build_dlid(dm, lv->lvid.s, "real")))
return_0;
if (!(cow_dlid = build_dlid(dm, lv->merging_snapshot->cow->lvid.s, "cow")))
return_0;
if (!(merge_dlid = build_dlid(dm, lv->merging_snapshot->cow->lvid.s, NULL)))
return_0;
if (!dm_tree_node_add_snapshot_merge_target(dnode, lv->size, origin_dlid,
cow_dlid, merge_dlid,
lv->merging_snapshot->chunk_size))
return_0;
return 1;
}
static int _add_snapshot_target_to_dtree(struct dev_manager *dm,
struct dm_tree_node *dnode,
struct logical_volume *lv)
@ -904,6 +933,9 @@ static int _add_snapshot_target_to_dtree(struct dev_manager *dm,
return 0;
}
if (snap_seg->status & SNAPSHOT_MERGE)
return 1;
if (!(origin_dlid = build_dlid(dm, snap_seg->origin->lvid.s, "real")))
return_0;
@ -971,11 +1003,21 @@ static int _add_segment_to_dtree(struct dev_manager *dm,
return_0;
/* If this is a snapshot origin, add real LV */
/* If this is a snapshot origin w/ merging snapshot, add cow and real LV */
if (lv_is_origin(seg->lv) && !layer) {
if (vg_is_clustered(seg->lv->vg)) {
log_error("Clustered snapshots are not yet supported");
return 0;
}
if (seg->lv->merging_snapshot) {
if (!_add_new_lv_to_dtree(dm, dtree,
seg->lv->merging_snapshot->cow, "cow"))
return_0;
/*
* Must also add "real" LV for use when
* snapshot-merge target is added
*/
}
if (!_add_new_lv_to_dtree(dm, dtree, seg->lv, "real"))
return_0;
} else if (lv_is_cow(seg->lv) && !layer) {
@ -992,8 +1034,13 @@ static int _add_segment_to_dtree(struct dev_manager *dm,
/* Now we've added its dependencies, we can add the target itself */
if (lv_is_origin(seg->lv) && !layer) {
if (!_add_origin_target_to_dtree(dm, dnode, seg->lv))
return_0;
if (!seg->lv->merging_snapshot) {
if (!_add_origin_target_to_dtree(dm, dnode, seg->lv))
return_0;
} else {
if (!_add_snapshot_merge_target_to_dtree(dm, dnode, seg->lv))
return_0;
}
} else if (lv_is_cow(seg->lv) && !layer) {
if (!_add_snapshot_target_to_dtree(dm, dnode, seg->lv))
return_0;
@ -1021,6 +1068,9 @@ static int _add_new_lv_to_dtree(struct dev_manager *dm, struct dm_tree *dtree,
uint32_t read_ahead_flags = UINT32_C(0);
uint16_t udev_flags = 0;
if (lv_is_cow(lv) && find_cow(lv)->status & SNAPSHOT_MERGE && !layer)
return 1;
if (!(name = build_dm_name(dm->mem, lv->vg->name, lv->name, layer)))
return_0;