1
0
mirror of git://sourceware.org/git/lvm2.git synced 2025-01-02 01:18:26 +03:00

o First pass at activation

This commit is contained in:
Joe Thornber 2001-11-02 13:45:05 +00:00
parent 0a5e4a1442
commit ae2bb66535

View File

@ -7,17 +7,76 @@
#include "metadata.h" #include "metadata.h"
#include "activate.h" #include "activate.h"
#include <device-mapper/libdm.h>
int lv_activate(struct logical_volume *lv) int lv_activate(struct logical_volume *lv)
{ {
return 0; int r = 0;
uint64_t esize = lv->vg->extent_size;
uint64_t start = 0ull;
char params[1024];
struct pe_specifier *pes;
struct dm_task *dmt;
if (!(dmt = dm_task_create(DM_DEVICE_CREATE))) {
stack;
return 0;
}
dm_command_set_name(c, lv->uuid);
for (i = 0; i < lv->le_count; i++) {
pes = lv->map + i;
snprintf(params, sizeof(params), "%s %ull",
dev_name(pes->pv.dev),
pes->pv->pe_start + (esize * pes->pe));
if (!dm_task_add_target(dmt, start, size, "linear", params)) {
stack;
goto out;
}
start += esize;
}
if (!(r = dm_task_run(c)))
stack;
out:
dm_command_destroy(c);
return r;
}
int activate_lvs_in_vg(struct volume_group *vg)
{
struct list *lvh;
int done = 0;
list_iterate(lvh, &vg->lvs)
done += lv_activate(&list_item(lvh, struct lv_list)->lv);
return done;
} }
int lv_deactivate(struct logical_volume *lv) int lv_deactivate(struct logical_volume *lv)
{ {
return 0; struct dm_task *dmt = dm_command_create(DM_DEVICE_REMOVE);
if (!c) {
stack;
return 0;
}
dm_command_set_name(c, lv->uuid);
if (!(r = dm_command_run()))
stack;
out:
dm_task_destroy(dmt);
return r;
} }
int lvs_in_vg_activated(struct volume_group *vg) int lv_deactivate(struct volume_group *vg, struct logical_volume *lv)
{ {
return 0; return 0;
} }
@ -27,28 +86,14 @@ int lv_update_write_access(struct logical_volume *lv)
return 0; return 0;
} }
int activate_lvs_in_vg(struct volume_group *vg)
{
struct list *lvh;
int done = 0;
list_iterate(lvh, &vg->lvs)
done += lv_activate(&list_item(lvh, struct lv_list)->lv);
return done;
}
int deactivate_lvs_in_vg(struct volume_group *vg) int deactivate_lvs_in_vg(struct volume_group *vg)
{ {
struct list *lvh; struct list *lvh;
int done = 0; int done = 0;
list_iterate(lvh, &vg->lvs) list_iterate(lvh, &vg->lvs)
done += lv_deactivate(&list_item(lvh, struct lv_list)->lv); done += lv_deactivate(&list_item(lvh, struct lv_list)->lv);
return done; return done;
} }