mirror of
git://sourceware.org/git/lvm2.git
synced 2025-03-10 16:58:47 +03:00
o pv_write for orphan pv's
This commit is contained in:
parent
6320fd9e52
commit
de9acc04f6
@ -400,6 +400,12 @@ static int _write_all_pv(struct disk_list *data)
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Stop here for orphan pv's.
|
||||
*/
|
||||
if (data->pv.vg_name[0] == '\0')
|
||||
return 1;
|
||||
|
||||
if (!_write_vg(data)) {
|
||||
log_err("failed to write vg data to %s", pv_name);
|
||||
return 0;
|
||||
|
@ -314,8 +314,47 @@ static int _pv_setup(struct io_space *is, struct physical_volume *pv,
|
||||
|
||||
static int _pv_write(struct io_space *is, struct physical_volume *pv)
|
||||
{
|
||||
log_err("format1:pv_write not implemented.");
|
||||
struct pool *mem;
|
||||
struct disk_list *dl;
|
||||
struct list_head pvs;
|
||||
|
||||
INIT_LIST_HEAD(&pvs);
|
||||
|
||||
if (pv->vg_name) {
|
||||
log_info("pv_write should only be called for an orphan pv");
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!(mem = pool_create(1024))) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
if (!(dl = pool_alloc(mem, sizeof(*dl)))) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
dl->mem = mem;
|
||||
dl->dev = pv->dev;
|
||||
|
||||
if (!export_pv(&dl->pv, pv)) {
|
||||
stack;
|
||||
goto bad;
|
||||
}
|
||||
|
||||
list_add(&dl->list, &pvs);
|
||||
if (!write_pvs(&pvs)) {
|
||||
stack;
|
||||
goto bad;
|
||||
}
|
||||
|
||||
pool_destroy(mem);
|
||||
return 1;
|
||||
|
||||
bad:
|
||||
pool_destroy(mem);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
@ -124,7 +124,10 @@ int export_pv(struct pv_disk *pvd, struct physical_volume *pv)
|
||||
return 0;
|
||||
}
|
||||
|
||||
strcpy(pvd->vg_name, pv->vg_name);
|
||||
memset(pvd->vg_name, 0, sizeof(pvd->vg_name));
|
||||
|
||||
if (pv->vg_name)
|
||||
strcpy(pvd->vg_name, pv->vg_name);
|
||||
|
||||
//pvd->pv_major = MAJOR(pv->dev);
|
||||
//pvd->pv_number = ??;
|
||||
|
Loading…
x
Reference in New Issue
Block a user