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

o adjacent extents are now merged into a single target when activating.

This commit is contained in:
Joe Thornber 2001-11-05 13:37:13 +00:00
parent 9277853f07
commit 80f9662b05
3 changed files with 50 additions and 18 deletions

View File

@ -15,16 +15,51 @@ static void _build_lv_name(char *buffer, size_t s, struct logical_volume *lv)
snprintf(buffer, s, "%s_%s", lv->vg->name, lv->name); snprintf(buffer, s, "%s_%s", lv->vg->name, lv->name);
} }
/*
* Creates a target for the next contiguous run of
* extents.
*/
static int _emit_target(struct dm_task *dmt, struct logical_volume *lv,
unsigned int *ple)
{
char params[1024];
unsigned int le = *ple;
uint64_t esize = lv->vg->extent_size;
int i, count = 0;
struct pe_specifier *pes, *first = NULL;
for (i = le; i < lv->le_count; i++) {
pes = lv->map + i;
if (!first)
first = pes;
else if (first->pv != pes->pv || first->pe != pes->pe + 1)
break; /* no longer contig. */
count++;
}
snprintf(params, sizeof(params), "%s %llu",
dev_name(first->pv->dev),
first->pv->pe_start + (esize * first->pe));
if (!dm_task_add_target(dmt, esize * le, esize * count,
"linear", params)) {
stack;
return 0;
}
*ple = i;
return 1;
}
int lv_activate(struct logical_volume *lv) int lv_activate(struct logical_volume *lv)
{ {
int r = 0; int r = 0;
int i; uint32_t le = 0;
uint64_t esize = lv->vg->extent_size;
uint64_t start = 0ull;
char params[1024];
char name[128]; char name[128];
struct pe_specifier *pes;
struct dm_task *dmt; struct dm_task *dmt;
if (!(dmt = dm_task_create(DM_DEVICE_CREATE))) { if (!(dmt = dm_task_create(DM_DEVICE_CREATE))) {
@ -35,18 +70,15 @@ int lv_activate(struct logical_volume *lv)
_build_lv_name(name, sizeof(name), lv); _build_lv_name(name, sizeof(name), lv);
dm_task_set_name(dmt, name); dm_task_set_name(dmt, name);
for (i = 0; i < lv->le_count; i++) { /*
pes = lv->map + i; * Merge adjacent extents.
snprintf(params, sizeof(params), "%s %llu", */
dev_name(pes->pv->dev), while (le < lv->le_count) {
pes->pv->pe_start + (esize * pes->pe)); if (!_emit_target(dmt, lv, &le)) {
log_err("unable to activate logical volume '%s'",
if (!dm_task_add_target(dmt, start, esize, "linear", params)) { lv->name);
stack;
goto out; goto out;
} }
start += esize;
} }
if (!(r = dm_task_run(dmt))) if (!(r = dm_task_run(dmt)))

View File

@ -178,7 +178,7 @@ int calculate_extent_count(struct physical_volume *pv);
* Low level io routines which read/write * Low level io routines which read/write
* disk_lists. * disk_lists.
*/ */
struct disk_list *read_pvd(struct device *dev, struct pool *mem, struct disk_list *read_disk(struct device *dev, struct pool *mem,
const char *vg_name); const char *vg_name);
int read_pvs_in_vg(const char *vg_name, struct dev_filter *filter, int read_pvs_in_vg(const char *vg_name, struct dev_filter *filter,