1
0
mirror of git://sourceware.org/git/lvm2.git synced 2024-12-21 13:34:40 +03:00

snapshot: relocate alloc_snapshot_seg

Move alloc_snapshot_seg to snapshot_manip and make it local static.
This commit is contained in:
Zdenek Kabelac 2016-01-07 12:16:18 +01:00
parent 8857b22764
commit 753a496348
3 changed files with 23 additions and 30 deletions

View File

@ -31,9 +31,6 @@ struct lv_segment *alloc_lv_segment(const struct segment_type *segtype,
uint32_t extents_copied,
struct lv_segment *pvmove_source_seg);
struct lv_segment *alloc_snapshot_seg(struct logical_volume *lv,
uint64_t status, uint32_t old_le_count);
int set_lv_segment_area_pv(struct lv_segment *seg, uint32_t area_num,
struct physical_volume *pv, uint32_t pe);
int set_lv_segment_area_lv(struct lv_segment *seg, uint32_t area_num,

View File

@ -1038,32 +1038,6 @@ struct lv_segment *alloc_lv_segment(const struct segment_type *segtype,
return seg;
}
struct lv_segment *alloc_snapshot_seg(struct logical_volume *lv,
uint64_t status, uint32_t old_le_count)
{
struct lv_segment *seg;
const struct segment_type *segtype;
segtype = get_segtype_from_string(lv->vg->cmd, SEG_TYPE_NAME_SNAPSHOT);
if (!segtype) {
log_error("Failed to find snapshot segtype");
return NULL;
}
if (!(seg = alloc_lv_segment(segtype, lv, old_le_count,
lv->le_count - old_le_count, status, 0,
NULL, 0, lv->le_count - old_le_count,
0, 0, 0, NULL))) {
log_error("Couldn't allocate new snapshot segment.");
return NULL;
}
dm_list_add(&lv->segments, &seg->list);
lv->status |= VIRTUAL;
return seg;
}
static int _release_and_discard_lv_segment_area(struct lv_segment *seg, uint32_t s,
uint32_t area_reduction, int with_discard)
{

View File

@ -214,6 +214,28 @@ void clear_snapshot_merge(struct logical_volume *origin)
origin->status &= ~MERGING;
}
static struct lv_segment *_alloc_snapshot_seg(struct logical_volume *lv)
{
struct lv_segment *seg;
const struct segment_type *segtype;
segtype = get_segtype_from_string(lv->vg->cmd, SEG_TYPE_NAME_SNAPSHOT);
if (!segtype) {
log_error("Failed to find snapshot segtype");
return NULL;
}
if (!(seg = alloc_lv_segment(segtype, lv, 0, lv->le_count, 0, 0,
NULL, 0, lv->le_count, 0, 0, 0, NULL))) {
log_error("Couldn't allocate new snapshot segment.");
return NULL;
}
dm_list_add(&lv->segments, &seg->list);
return seg;
}
int vg_add_snapshot(struct logical_volume *origin,
struct logical_volume *cow, union lvid *lvid,
uint32_t extent_count, uint32_t chunk_size)
@ -241,7 +263,7 @@ int vg_add_snapshot(struct logical_volume *origin,
snap->le_count = extent_count;
if (!(seg = alloc_snapshot_seg(snap, 0, 0)))
if (!(seg = _alloc_snapshot_seg(snap)))
return_0;
init_snapshot_seg(seg, origin, cow, chunk_size, 0);