mirror of
git://sourceware.org/git/lvm2.git
synced 2025-03-10 16:58:47 +03:00
Basic support for (read-only) partial activation if any PVs are
missing from a VG. (Linear targets use the device-mapper 'error' target which returns ioerror; striped targets use '/dev/ioerror' for now - which must already exist e.g. as a sufficiently large block device version of /dev/zero).
This commit is contained in:
parent
08907484f5
commit
7ae5a778d5
@ -191,11 +191,23 @@ static int _emit_target(struct dm_task *dmt, struct stripe_segment *seg)
|
||||
char params[1024];
|
||||
uint64_t esize = seg->lv->vg->extent_size;
|
||||
uint32_t s, stripes = seg->stripes;
|
||||
int w = 0, tw = 0;
|
||||
int w = 0, tw = 0, error = 0;
|
||||
const char *no_space =
|
||||
"Insufficient space to write target parameters.";
|
||||
char *filler = "/dev/ioerror";
|
||||
char *target;
|
||||
|
||||
if (stripes == 1) {
|
||||
if (!seg->area[0].pv) {
|
||||
target = "error";
|
||||
error = 1;
|
||||
}
|
||||
else
|
||||
target = "linear";
|
||||
}
|
||||
|
||||
if (stripes > 1) {
|
||||
target = "striped";
|
||||
tw = lvm_snprintf(params, sizeof(params), "%u %u ",
|
||||
stripes, seg->stripe_size);
|
||||
|
||||
@ -207,39 +219,35 @@ static int _emit_target(struct dm_task *dmt, struct stripe_segment *seg)
|
||||
w = tw;
|
||||
}
|
||||
|
||||
if (!error) {
|
||||
for (s = 0; s < stripes; s++, w += tw) {
|
||||
if (!seg->area[s].pv)
|
||||
tw = lvm_snprintf(
|
||||
params + w, sizeof(params) - w,
|
||||
"%s 0%s", filler,
|
||||
s == (stripes - 1) ? "" : " ");
|
||||
else
|
||||
tw = lvm_snprintf(
|
||||
params + w, sizeof(params) - w,
|
||||
"%s %" PRIu64 "%s",
|
||||
dev_name(seg->area[s].pv->dev),
|
||||
(seg->area[s].pv->pe_start +
|
||||
(esize * seg->area[s].pe)),
|
||||
s == (stripes - 1) ? "" : " ");
|
||||
|
||||
for (s = 0; s < stripes; s++, w += tw) {
|
||||
/******
|
||||
log_debug("stripes: %d", stripes);
|
||||
log_debug("dev_name(seg->area[s].pv->dev): %s",
|
||||
dev_name(seg->area[s].pv->dev));
|
||||
log_debug("esize: %" PRIu64, esize);
|
||||
log_debug("seg->area[s].pe: %" PRIu64, seg->area[s].pe);
|
||||
log_debug("seg->area[s].pv->pe_start: %" PRIu64,
|
||||
seg->area[s].pv->pe_start);
|
||||
*******/
|
||||
|
||||
tw = lvm_snprintf(params + w, sizeof(params) - w,
|
||||
"%s %" PRIu64 "%s",
|
||||
dev_name(seg->area[s].pv->dev),
|
||||
(seg->area[s].pv->pe_start +
|
||||
(esize * seg->area[s].pe)),
|
||||
s == (stripes - 1) ? "" : " ");
|
||||
|
||||
if (tw < 0) {
|
||||
log_err(no_space);
|
||||
return 0;
|
||||
if (tw < 0) {
|
||||
log_err(no_space);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
log_debug("Adding target: %" PRIu64 " %" PRIu64 " %s %s",
|
||||
log_very_verbose("Adding target: %" PRIu64 " %" PRIu64 " %s %s",
|
||||
esize * seg->le, esize * seg->len,
|
||||
stripes == 1 ? "linear" : "striped",
|
||||
params);
|
||||
target, params);
|
||||
|
||||
if (!dm_task_add_target(dmt, esize * seg->le, esize * seg->len,
|
||||
stripes == 1 ? "linear" : "striped",
|
||||
params)) {
|
||||
target, params)) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
|
@ -377,11 +377,11 @@ void _display_stripe(struct stripe_segment *seg, int s, const char *pre)
|
||||
uint32_t len = seg->len / seg->stripes;
|
||||
|
||||
log_print("%sphysical volume\t%s", pre,
|
||||
dev_name(seg->area[s].pv->dev));
|
||||
seg->area[s].pv ? dev_name(seg->area[s].pv->dev) : "Missing");
|
||||
|
||||
log_print("%sphysical extents\t%d to %d",
|
||||
pre,
|
||||
seg->area[s].pe, seg->area[s].pe + len - 1);
|
||||
if (seg->area[s].pv)
|
||||
log_print("%sphysical extents\t%d to %d", pre,
|
||||
seg->area[s].pe, seg->area[s].pe + len - 1);
|
||||
}
|
||||
|
||||
int lvdisplay_segments(struct logical_volume *lv)
|
||||
|
@ -164,6 +164,7 @@ static int _fill_maps(struct hash_table *maps, struct volume_group *vg,
|
||||
static int _check_single_map(struct lv_map *lvm)
|
||||
{
|
||||
uint32_t i;
|
||||
|
||||
for (i = 0; i < lvm->lv->le_count; i++) {
|
||||
if (!lvm->map[i].pv) {
|
||||
log_err("Logical volume (%s) contains an incomplete "
|
||||
@ -349,8 +350,7 @@ int import_extents(struct pool *mem, struct volume_group *vg, struct list *pvds)
|
||||
goto out;
|
||||
}
|
||||
|
||||
/* FIXME Support partial activation if (vg->status & PARTIAL_VG) */
|
||||
if (!_check_maps_are_complete(maps)) {
|
||||
if (!_check_maps_are_complete(maps) && !(vg->status & PARTIAL_VG)) {
|
||||
stack;
|
||||
goto out;
|
||||
}
|
||||
|
@ -217,7 +217,9 @@ static int _print_vg(struct formatter *f, struct volume_group *vg)
|
||||
static inline const char *
|
||||
_get_pv_name(struct formatter *f, struct physical_volume *pv)
|
||||
{
|
||||
return (const char *) hash_lookup(f->pv_names, dev_name(pv->dev));
|
||||
return (pv) ? (const char *)
|
||||
hash_lookup(f->pv_names, dev_name(pv->dev)) :
|
||||
"Missing";
|
||||
}
|
||||
|
||||
static int _print_pvs(struct formatter *f, struct volume_group *vg)
|
||||
|
@ -108,10 +108,11 @@ xx(lvdisplay,
|
||||
"\t[-D/--disk]\n"
|
||||
"\t[-h/-?/--help]\n"
|
||||
"\t[-m/--maps]\n"
|
||||
"\t[-P/--partial] " "\n"
|
||||
"\t[-v/--verbose]\n"
|
||||
"\tLogicalVolume[Path] [LogicalVolume[Path]...]\n",
|
||||
|
||||
colon_ARG, disk_ARG, maps_ARG)
|
||||
colon_ARG, disk_ARG, maps_ARG, partial_ARG)
|
||||
|
||||
xx(lvextend,
|
||||
"Add space to a logical volume",
|
||||
@ -405,11 +406,12 @@ xx(vgdisplay,
|
||||
"\t[-c|--colon | -s|--short | -v|--verbose]" "\n"
|
||||
"\t[-d|--debug] " "\n"
|
||||
"\t[-h|--help] " "\n"
|
||||
"\t[--version]" "\n"
|
||||
"\t[-P|--partial] " "\n"
|
||||
"\t[-A|--activevolumegroups | [-D|--disk]" "\n"
|
||||
"\t[--version]" "\n"
|
||||
"\t[VolumeGroupName...] ]\n",
|
||||
|
||||
activevolumegroups_ARG, colon_ARG, disk_ARG, short_ARG)
|
||||
activevolumegroups_ARG, colon_ARG, disk_ARG, short_ARG, partial_ARG)
|
||||
|
||||
xx(vgexport,
|
||||
"Unregister volume group(s) from the system",
|
||||
|
Loading…
x
Reference in New Issue
Block a user