1
0
mirror of git://sourceware.org/git/lvm2.git synced 2024-12-21 13:34:40 +03:00

python-lvm: Small fixups to new create_lv_snapshot

Tabify

Remove use of asize, unneeded.

Don't initialize lvobj->parent_vgobj to NULL, the object ctor already
zeroed everything on alloc.

Redo call to lvm_lv_snapshot to use the liblvm snapshot implementation
we went with.

Add {}s to silence warning in lv_dealloc.

Rename snapshot function for consistency.

Update WHATS_NEW.

Signed-off-by: Andy Grover <agrover@redhat.com>
This commit is contained in:
Andy Grover 2012-12-14 10:17:29 -08:00
parent 0db733f18a
commit 58b61c252a
2 changed files with 8 additions and 16 deletions

View File

@ -1,5 +1,6 @@
Version 2.02.99 -
===================================
Add LV snapshot support to liblvm and python-lvm.
Avoid a global lock in pvs when lvmetad is in use.
Fix crash in pvscan --cache -aay triggered by non-mda PV.
Allow lvconvert --stripes/stripesize only with --mirrors/--repair/--thinpool.

View File

@ -897,8 +897,9 @@ static void
liblvm_lv_dealloc(lvobject *self)
{
/* We can dealloc an object that didn't get fully created */
if (self->parent_vgobj)
if (self->parent_vgobj) {
Py_DECREF(self->parent_vgobj);
}
PyObject_Del(self);
}
@ -1313,38 +1314,28 @@ liblvm_lvm_lv_list_lvsegs(lvobject *self)
}
static PyObject *
liblvm_lvm_vg_create_lv_snapshot(lvobject *self, PyObject *args)
liblvm_lvm_lv_snapshot(lvobject *self, PyObject *args)
{
const char *vgname;
uint64_t size;
unsigned long asize;
lvobject *lvobj;
vgobject *vgobj;
const char *selfname = NULL;
LV_VALID(self);
if (!PyArg_ParseTuple(args, "sl", &vgname, &asize)) {
if (!PyArg_ParseTuple(args, "sl", &vgname, &size)) {
return NULL;
}
size = asize;
if ((lvobj = PyObject_New(lvobject, &LibLVMlvType)) == NULL)
return NULL;
/* Initialize the parent ptr in case lv create fails and we dealloc lvobj */
lvobj->parent_vgobj = NULL;
selfname = lvm_lv_get_name(self->lv);
vgobj = self->parent_vgobj;
if ((lvobj->lv = lvm_vg_create_lv_snapshot(vgobj->vg, selfname,
vgname, size)) == NULL) {
if ((lvobj->lv = lvm_lv_snapshot(self->lv, vgname, size)) == NULL) {
PyErr_SetObject(LibLVMError, liblvm_get_last_error());
Py_DECREF(lvobj);
return NULL;
}
lvobj->parent_vgobj = vgobj;
lvobj->parent_vgobj = self->parent_vgobj;
Py_INCREF(lvobj->parent_vgobj);
return (PyObject *)lvobj;
@ -1618,7 +1609,7 @@ static PyMethodDef liblvm_lv_methods[] = {
{ "rename", (PyCFunction)liblvm_lvm_lv_rename, METH_VARARGS },
{ "resize", (PyCFunction)liblvm_lvm_lv_resize, METH_VARARGS },
{ "listLVsegs", (PyCFunction)liblvm_lvm_lv_list_lvsegs, METH_NOARGS },
{ "snapshot", (PyCFunction)liblvm_lvm_vg_create_lv_snapshot, METH_VARARGS },
{ "snapshot", (PyCFunction)liblvm_lvm_lv_snapshot, METH_VARARGS },
{ NULL, NULL} /* sentinel */
};