mirror of
git://sourceware.org/git/lvm2.git
synced 2025-01-02 01:18:26 +03:00
Separate out _build_dev_string.
This commit is contained in:
parent
a9b5af1d62
commit
a4be2c013c
@ -1,5 +1,6 @@
|
|||||||
Version 2.01.14 -
|
Version 2.01.14 -
|
||||||
================================
|
================================
|
||||||
|
Separate out _build_dev_string.
|
||||||
Move zero_lv to toollib.
|
Move zero_lv to toollib.
|
||||||
Fix pool format handler to work with pv segment code.
|
Fix pool format handler to work with pv segment code.
|
||||||
|
|
||||||
|
@ -727,6 +727,28 @@ static int _emit_target_line(struct dev_manager *dm, struct dm_task *dmt,
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int _build_dev_string(struct dev_manager *dm, char *dlid,
|
||||||
|
char *devbuf, size_t bufsize, const char *desc)
|
||||||
|
{
|
||||||
|
struct dev_layer *dl;
|
||||||
|
|
||||||
|
if (!(dl = hash_lookup(dm->layers, dlid))) {
|
||||||
|
log_error("%s device layer %s missing from hash",
|
||||||
|
desc, dlid);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!dm_format_dev(devbuf, bufsize, dl->info.major,
|
||||||
|
dl->info.minor)) {
|
||||||
|
log_error("Failed to format %s device number for %s as dm "
|
||||||
|
"target (%u,%u)",
|
||||||
|
desc, dlid, dl->info.major, dl->info.minor);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
int compose_log_line(struct dev_manager *dm, struct lv_segment *seg,
|
int compose_log_line(struct dev_manager *dm, struct lv_segment *seg,
|
||||||
char *params, size_t paramsize, int *pos, int areas,
|
char *params, size_t paramsize, int *pos, int areas,
|
||||||
uint32_t region_size)
|
uint32_t region_size)
|
||||||
@ -734,7 +756,6 @@ int compose_log_line(struct dev_manager *dm, struct lv_segment *seg,
|
|||||||
int tw;
|
int tw;
|
||||||
char devbuf[10];
|
char devbuf[10];
|
||||||
char *name;
|
char *name;
|
||||||
struct dev_layer *dl;
|
|
||||||
|
|
||||||
if (!seg->log_lv)
|
if (!seg->log_lv)
|
||||||
tw = lvm_snprintf(params, paramsize, "core 1 %u %u ",
|
tw = lvm_snprintf(params, paramsize, "core 1 %u %u ",
|
||||||
@ -746,17 +767,9 @@ int compose_log_line(struct dev_manager *dm, struct lv_segment *seg,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(dl = hash_lookup(dm->layers, seg->log_lv->lvid.s))) {
|
if (!_build_dev_string(dm, seg->log_lv->lvid.s, devbuf,
|
||||||
log_error("device layer %s missing from hash",
|
sizeof(devbuf), "log")) {
|
||||||
seg->log_lv->lvid.s);
|
stack;
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!dm_format_dev(devbuf, sizeof(devbuf), dl->info.major,
|
|
||||||
dl->info.minor)) {
|
|
||||||
log_error("Failed to format device number as dm "
|
|
||||||
"target (%u,%u)",
|
|
||||||
dl->info.major, dl->info.minor);
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -783,7 +796,6 @@ int compose_areas_line(struct dev_manager *dm, struct lv_segment *seg,
|
|||||||
int tw = 0;
|
int tw = 0;
|
||||||
const char *trailing_space;
|
const char *trailing_space;
|
||||||
uint64_t esize = seg->lv->vg->extent_size;
|
uint64_t esize = seg->lv->vg->extent_size;
|
||||||
struct dev_layer *dl;
|
|
||||||
char devbuf[10];
|
char devbuf[10];
|
||||||
|
|
||||||
for (s = start_area; s < areas; s++, *pos += tw) {
|
for (s = start_area; s < areas; s++, *pos += tw) {
|
||||||
@ -804,18 +816,9 @@ int compose_areas_line(struct dev_manager *dm, struct lv_segment *seg,
|
|||||||
(esize * seg_pe(seg, s))),
|
(esize * seg_pe(seg, s))),
|
||||||
trailing_space);
|
trailing_space);
|
||||||
else if (seg_type(seg, s) == AREA_LV) {
|
else if (seg_type(seg, s) == AREA_LV) {
|
||||||
if (!(dl = hash_lookup(dm->layers,
|
if (!_build_dev_string(dm, seg_lv(seg, s)->lvid.s, devbuf,
|
||||||
seg_lv(seg, s)->lvid.s))) {
|
sizeof(devbuf), "LV")) {
|
||||||
log_error("device layer %s missing from hash",
|
stack;
|
||||||
seg_lv(seg, s)->lvid.s);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
if (!dm_format_dev
|
|
||||||
(devbuf, sizeof(devbuf), dl->info.major,
|
|
||||||
dl->info.minor)) {
|
|
||||||
log_error
|
|
||||||
("Failed to format device number as dm target (%u,%u)",
|
|
||||||
dl->info.major, dl->info.minor);
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
tw = lvm_snprintf(params + *pos, paramsize - *pos,
|
tw = lvm_snprintf(params + *pos, paramsize - *pos,
|
||||||
@ -824,7 +827,7 @@ int compose_areas_line(struct dev_manager *dm, struct lv_segment *seg,
|
|||||||
trailing_space);
|
trailing_space);
|
||||||
} else {
|
} else {
|
||||||
log_error("Internal error: Unassigned area found in LV %s.",
|
log_error("Internal error: Unassigned area found in LV %s.",
|
||||||
seg->lv);
|
seg->lv->name);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -892,22 +895,14 @@ static int _populate_origin(struct dev_manager *dm,
|
|||||||
{
|
{
|
||||||
char *real;
|
char *real;
|
||||||
char params[PATH_MAX + 32];
|
char params[PATH_MAX + 32];
|
||||||
struct dev_layer *dlr;
|
|
||||||
|
|
||||||
if (!(real = _build_dlid(dm->mem, dl->lv->lvid.s, "real"))) {
|
if (!(real = _build_dlid(dm->mem, dl->lv->lvid.s, "real"))) {
|
||||||
stack;
|
stack;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(dlr = hash_lookup(dm->layers, real))) {
|
if (!_build_dev_string(dm, real, params, sizeof(params), "origin")) {
|
||||||
log_error("Couldn't find real device layer %s in hash", real);
|
stack;
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!dm_format_dev(params, sizeof(params), dlr->info.major,
|
|
||||||
dlr->info.minor)) {
|
|
||||||
log_error("Couldn't create origin device parameters for '%s'.",
|
|
||||||
real);
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -928,7 +923,6 @@ static int _populate_snapshot(struct dev_manager *dm,
|
|||||||
char *origin, *cow;
|
char *origin, *cow;
|
||||||
char params[PATH_MAX * 2 + 32];
|
char params[PATH_MAX * 2 + 32];
|
||||||
struct lv_segment *snap_seg;
|
struct lv_segment *snap_seg;
|
||||||
struct dev_layer *dlo, *dlc;
|
|
||||||
char devbufo[10], devbufc[10];
|
char devbufo[10], devbufc[10];
|
||||||
uint64_t size;
|
uint64_t size;
|
||||||
|
|
||||||
@ -948,28 +942,14 @@ static int _populate_snapshot(struct dev_manager *dm,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(dlo = hash_lookup(dm->layers, origin))) {
|
if (!_build_dev_string(dm, origin, devbufo, sizeof(devbufo),
|
||||||
log_error("Couldn't find origin device layer %s in hash",
|
"origin")) {
|
||||||
origin);
|
stack;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(dlc = hash_lookup(dm->layers, cow))) {
|
if (!_build_dev_string(dm, cow, devbufc, sizeof(devbufc), "cow")) {
|
||||||
log_error("Couldn't find cow device layer %s in hash", cow);
|
stack;
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!dm_format_dev(devbufo, sizeof(devbufo), dlo->info.major,
|
|
||||||
dlo->info.minor)) {
|
|
||||||
log_error("Couldn't create origin device parameters for '%s'.",
|
|
||||||
snap_seg->origin->name);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!dm_format_dev(devbufc, sizeof(devbufc), dlc->info.major,
|
|
||||||
dlc->info.minor)) {
|
|
||||||
log_error("Couldn't create cow device parameters for '%s'.",
|
|
||||||
snap_seg->cow->name);
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user