1
0
mirror of git://sourceware.org/git/lvm2.git synced 2025-02-23 13:57:47 +03:00

Extend virtual segment instead of adding new one

Before adding a new virtual segment to LV, check first whether
the last segment isn't already of the same type. In this case
extend last segment instead of creating the new one.

Thin volumes should have always only 1 virtual segment, but it
helps also to virtual snapshot or error segtype..
This commit is contained in:
Zdenek Kabelac 2011-10-28 20:17:55 +00:00
parent bd4b840879
commit 2fa836e843
2 changed files with 13 additions and 9 deletions

View File

@ -1,5 +1,6 @@
Version 2.02.89 -
==================================
Increase virtual segment size instead of creating multiple segment list.
Add last_seg(lv) internal function.
Support empty string for log/prefix.
Fix regression that allowed mirrored logs for cluster mirrors.

View File

@ -2043,20 +2043,23 @@ int lv_add_virtual_segment(struct logical_volume *lv, uint64_t status,
thin_pool_lv = lvl->lv;
}
if (!(seg = alloc_lv_segment(segtype, lv, lv->le_count, extents,
status, 0, NULL, thin_pool_lv, 0,
extents, 0, 0, 0, NULL))) {
log_error("Couldn't allocate new zero segment.");
return 0;
if ((seg = last_seg(lv)) && (seg->segtype == segtype)) {
seg->area_len += extents;
seg->len += extents;
} else {
if (!(seg = alloc_lv_segment(segtype, lv, lv->le_count, extents,
status, 0, NULL, thin_pool_lv, 0,
extents, 0, 0, 0, NULL))) {
log_error("Couldn't allocate new zero segment.");
return 0;
}
lv->status |= VIRTUAL;
dm_list_add(&lv->segments, &seg->list);
}
dm_list_add(&lv->segments, &seg->list);
lv->le_count += extents;
lv->size += (uint64_t) extents *lv->vg->extent_size;
lv->status |= VIRTUAL;
return 1;
}