mirror of
git://sourceware.org/git/lvm2.git
synced 2025-01-03 05:18:29 +03:00
Cope better when format functions are missing.
This commit is contained in:
parent
8b7a435dee
commit
29ebccc3e2
@ -280,6 +280,11 @@ int label_write(struct device *dev, struct label *label)
|
|||||||
struct label_header *lh = (struct label_header *) buf;
|
struct label_header *lh = (struct label_header *) buf;
|
||||||
int r = 1;
|
int r = 1;
|
||||||
|
|
||||||
|
if (!label->labeller->ops->write) {
|
||||||
|
log_err("Label handler does not support label writes");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
if ((LABEL_SIZE + (label->sector << SECTOR_SHIFT)) > LABEL_SCAN_SIZE) {
|
if ((LABEL_SIZE + (label->sector << SECTOR_SHIFT)) > LABEL_SCAN_SIZE) {
|
||||||
log_error("Label sector %" PRIu64 " beyond range (%ld)",
|
log_error("Label sector %" PRIu64 " beyond range (%ld)",
|
||||||
label->sector, LABEL_SCAN_SECTORS);
|
label->sector, LABEL_SCAN_SECTORS);
|
||||||
@ -292,8 +297,10 @@ int label_write(struct device *dev, struct label *label)
|
|||||||
lh->sector_xl = xlate64(label->sector);
|
lh->sector_xl = xlate64(label->sector);
|
||||||
lh->offset_xl = xlate32(sizeof(*lh));
|
lh->offset_xl = xlate32(sizeof(*lh));
|
||||||
|
|
||||||
if (!label->labeller->ops->write(label, buf))
|
if (!label->labeller->ops->write(label, buf)) {
|
||||||
|
stack;
|
||||||
return 0;
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
lh->crc_xl = xlate32(calc_crc(INITIAL_CRC, &lh->offset_xl, LABEL_SIZE -
|
lh->crc_xl = xlate32(calc_crc(INITIAL_CRC, &lh->offset_xl, LABEL_SIZE -
|
||||||
((void *) &lh->offset_xl - (void *) lh)));
|
((void *) &lh->offset_xl - (void *) lh)));
|
||||||
@ -327,7 +334,7 @@ int label_verify(struct device *dev)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
return l->ops->verify(l, buf, sector);
|
return ((l->ops->verify) ? l->ops->verify(l, buf, sector) : 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void label_destroy(struct label *label)
|
void label_destroy(struct label *label)
|
||||||
|
@ -217,7 +217,8 @@ struct volume_group *vg_create(struct cmd_context *cmd, const char *vg_name,
|
|||||||
goto bad;
|
goto bad;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!vg->fid->fmt->ops->vg_setup(vg->fid, vg)) {
|
if (vg->fid->fmt->ops->vg_setup &&
|
||||||
|
!vg->fid->fmt->ops->vg_setup(vg->fid, vg)) {
|
||||||
log_error("Format specific setup of volume group '%s' failed.",
|
log_error("Format specific setup of volume group '%s' failed.",
|
||||||
vg_name);
|
vg_name);
|
||||||
goto bad;
|
goto bad;
|
||||||
@ -463,6 +464,19 @@ int vg_write(struct volume_group *vg)
|
|||||||
/* Write to each copy of the metadata area */
|
/* Write to each copy of the metadata area */
|
||||||
list_iterate(mdah, &vg->fid->metadata_areas) {
|
list_iterate(mdah, &vg->fid->metadata_areas) {
|
||||||
mda = list_item(mdah, struct metadata_area);
|
mda = list_item(mdah, struct metadata_area);
|
||||||
|
if(!mda->ops->vg_write) {
|
||||||
|
log_error("Format does not support writing volume"
|
||||||
|
"group metadata areas");
|
||||||
|
/* Revert */
|
||||||
|
list_uniterate(mdah2, &vg->fid->metadata_areas, mdah) {
|
||||||
|
mda = list_item(mdah2, struct metadata_area);
|
||||||
|
if (mda->ops->vg_revert &&
|
||||||
|
!mda->ops->vg_revert(vg->fid, vg, mda)) {
|
||||||
|
stack;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
if (!mda->ops->vg_write(vg->fid, vg, mda)) {
|
if (!mda->ops->vg_write(vg->fid, vg, mda)) {
|
||||||
stack;
|
stack;
|
||||||
/* Revert */
|
/* Revert */
|
||||||
@ -869,6 +883,11 @@ struct list *get_pvs(struct cmd_context *cmd)
|
|||||||
int pv_write(struct cmd_context *cmd, struct physical_volume *pv,
|
int pv_write(struct cmd_context *cmd, struct physical_volume *pv,
|
||||||
struct list *mdas, int64_t label_sector)
|
struct list *mdas, int64_t label_sector)
|
||||||
{
|
{
|
||||||
|
if (!pv->fmt->ops->pv_write) {
|
||||||
|
log_error("Format does not support writing physical volumes");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
if (*pv->vg_name || pv->pe_alloc_count) {
|
if (*pv->vg_name || pv->pe_alloc_count) {
|
||||||
log_error("Assertion failed: can't _pv_write non-orphan PV "
|
log_error("Assertion failed: can't _pv_write non-orphan PV "
|
||||||
"(in VG %s)", pv->vg_name);
|
"(in VG %s)", pv->vg_name);
|
||||||
|
Loading…
Reference in New Issue
Block a user