master - python-lvm: Make second lv.snapshot() argument optional
by Andy Grover
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=0958905b1bc0a5...
Commit: 0958905b1bc0a59d34a4092377bae7c59f424181
Parent: 0e3093979e901384aecb22e08d83b5acb2ef12c1
Author: Andy Grover <agrover(a)redhat.com>
AuthorDate: Fri Dec 14 14:10:41 2012 -0800
Committer: Andy Grover <agrover(a)redhat.com>
CommitterDate: Fri Dec 14 14:10:41 2012 -0800
python-lvm: Make second lv.snapshot() argument optional
If no size is given, size defaults to 0, which in lvm_lv_snapshot will
allocate extents equal to the original LV be allocated for the new
snapshot.
Signed-off-by: Andy Grover <agrover(a)redhat.com>
---
python/liblvm.c | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/python/liblvm.c b/python/liblvm.c
index 906825e..4db507c 100644
--- a/python/liblvm.c
+++ b/python/liblvm.c
@@ -1317,12 +1317,12 @@ static PyObject *
liblvm_lvm_lv_snapshot(lvobject *self, PyObject *args)
{
const char *vgname;
- uint64_t size;
+ uint64_t size = 0;
lvobject *lvobj;
LV_VALID(self);
- if (!PyArg_ParseTuple(args, "sl", &vgname, &size)) {
+ if (!PyArg_ParseTuple(args, "s|l", &vgname, &size)) {
return NULL;
}
11 years, 4 months
master - python-lvm: whitespace in python/liblvm.c.
by Andy Grover
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=0e3093979e9013...
Commit: 0e3093979e901384aecb22e08d83b5acb2ef12c1
Parent: 58b61c252a57e3e18e82cfd9cc24567339ca4508
Author: Andy Grover <agrover(a)redhat.com>
AuthorDate: Fri Dec 14 10:32:35 2012 -0800
Committer: Andy Grover <agrover(a)redhat.com>
CommitterDate: Fri Dec 14 10:32:35 2012 -0800
python-lvm: whitespace in python/liblvm.c.
Sorry, it bugged me. Should be perfect now.
Signed-off-by: Andy Grover <agrover(a)redhat.com>
---
python/liblvm.c | 44 ++++++++++++++++++++++----------------------
1 files changed, 22 insertions(+), 22 deletions(-)
diff --git a/python/liblvm.c b/python/liblvm.c
index 3b1a4f2..906825e 100644
--- a/python/liblvm.c
+++ b/python/liblvm.c
@@ -29,31 +29,31 @@ static lvm_t libh;
typedef struct {
PyObject_HEAD
- vg_t vg; /* vg handle */
+ vg_t vg; /* vg handle */
} vgobject;
typedef struct {
PyObject_HEAD
- lv_t lv; /* lv handle */
- vgobject *parent_vgobj;
+ lv_t lv; /* lv handle */
+ vgobject *parent_vgobj;
} lvobject;
typedef struct {
PyObject_HEAD
- pv_t pv; /* pv handle */
- vgobject *parent_vgobj;
+ pv_t pv; /* pv handle */
+ vgobject *parent_vgobj;
} pvobject;
typedef struct {
PyObject_HEAD
- lvseg_t lv_seg; /* lv segment handle */
- lvobject *parent_lvobj;
+ lvseg_t lv_seg; /* lv segment handle */
+ lvobject *parent_lvobj;
} lvsegobject;
typedef struct {
PyObject_HEAD
- pvseg_t pv_seg; /* pv segment handle */
- pvobject *parent_pvobj;
+ pvseg_t pv_seg; /* pv segment handle */
+ pvobject *parent_pvobj;
} pvsegobject;
static PyTypeObject LibLVMvgType;
@@ -643,7 +643,7 @@ get_property(struct lvm_property_value *prop)
/* This will return a tuple of (value, bool) with the value being a string or
integer and bool indicating if property is settable */
static PyObject *
-liblvm_lvm_vg_get_property(vgobject *self, PyObject *args)
+liblvm_lvm_vg_get_property(vgobject *self, PyObject *args)
{
const char *name;
struct lvm_property_value prop_value;
@@ -658,7 +658,7 @@ liblvm_lvm_vg_get_property(vgobject *self, PyObject *args)
}
static PyObject *
-liblvm_lvm_vg_set_property(vgobject *self, PyObject *args)
+liblvm_lvm_vg_set_property(vgobject *self, PyObject *args)
{
const char *property_name = NULL;
PyObject *variant_type_arg = NULL;
@@ -1277,8 +1277,8 @@ liblvm_lvm_lv_resize(lvobject *self, PyObject *args)
static PyObject *
liblvm_lvm_lv_list_lvsegs(lvobject *self)
{
- struct dm_list *lvsegs;
- lvseg_list_t *lvsegl;
+ struct dm_list *lvsegs;
+ lvseg_list_t *lvsegl;
PyObject * pytuple;
lvsegobject *lvsegobj;
int i = 0;
@@ -1377,7 +1377,7 @@ liblvm_lvm_pv_get_mda_count(pvobject *self)
}
static PyObject *
-liblvm_lvm_pv_get_property(pvobject *self, PyObject *args)
+liblvm_lvm_pv_get_property(pvobject *self, PyObject *args)
{
const char *name;
struct lvm_property_value prop_value;
@@ -1491,7 +1491,7 @@ liblvm_lvseg_dealloc(lvsegobject *self)
}
static PyObject *
-liblvm_lvm_lvseg_get_property(lvsegobject *self, PyObject *args)
+liblvm_lvm_lvseg_get_property(lvsegobject *self, PyObject *args)
{
const char *name;
struct lvm_property_value prop_value;
@@ -1521,7 +1521,7 @@ liblvm_pvseg_dealloc(pvsegobject *self)
}
static PyObject *
-liblvm_lvm_pvseg_get_property(pvsegobject *self, PyObject *args)
+liblvm_lvm_pvseg_get_property(pvsegobject *self, PyObject *args)
{
const char *name;
struct lvm_property_value prop_value;
@@ -1553,7 +1553,7 @@ static PyMethodDef Liblvm_methods[] = {
{ "percentToFloat", (PyCFunction)liblvm_lvm_percent_to_float, METH_VARARGS },
{ "vgNameFromPvid", (PyCFunction)liblvm_lvm_vgname_from_pvid, METH_VARARGS },
{ "vgNameFromDevice", (PyCFunction)liblvm_lvm_vgname_from_device, METH_VARARGS },
- { NULL, NULL} /* sentinel */
+ { NULL, NULL } /* sentinel */
};
static PyMethodDef liblvm_vg_methods[] = {
@@ -1589,7 +1589,7 @@ static PyMethodDef liblvm_vg_methods[] = {
{ "pvFromUuid", (PyCFunction)liblvm_lvm_pv_from_uuid, METH_VARARGS },
{ "getTags", (PyCFunction)liblvm_lvm_vg_get_tags, METH_NOARGS },
{ "createLvLinear", (PyCFunction)liblvm_lvm_vg_create_lv_linear, METH_VARARGS },
- { NULL, NULL} /* sentinel */
+ { NULL, NULL } /* sentinel */
};
static PyMethodDef liblvm_lv_methods[] = {
@@ -1610,7 +1610,7 @@ static PyMethodDef liblvm_lv_methods[] = {
{ "resize", (PyCFunction)liblvm_lvm_lv_resize, METH_VARARGS },
{ "listLVsegs", (PyCFunction)liblvm_lvm_lv_list_lvsegs, METH_NOARGS },
{ "snapshot", (PyCFunction)liblvm_lvm_lv_snapshot, METH_VARARGS },
- { NULL, NULL} /* sentinel */
+ { NULL, NULL } /* sentinel */
};
static PyMethodDef liblvm_pv_methods[] = {
@@ -1624,17 +1624,17 @@ static PyMethodDef liblvm_pv_methods[] = {
{ "getFree", (PyCFunction)liblvm_lvm_pv_get_free, METH_NOARGS },
{ "resize", (PyCFunction)liblvm_lvm_pv_resize, METH_VARARGS },
{ "listPVsegs", (PyCFunction)liblvm_lvm_pv_list_pvsegs, METH_NOARGS },
- { NULL, NULL} /* sentinel */
+ { NULL, NULL } /* sentinel */
};
static PyMethodDef liblvm_lvseg_methods[] = {
{ "getProperty", (PyCFunction)liblvm_lvm_lvseg_get_property, METH_VARARGS },
- { NULL, NULL} /* sentinel */
+ { NULL, NULL } /* sentinel */
};
static PyMethodDef liblvm_pvseg_methods[] = {
{ "getProperty", (PyCFunction)liblvm_lvm_pvseg_get_property, METH_VARARGS },
- { NULL, NULL} /* sentinel */
+ { NULL, NULL } /* sentinel */
};
static PyTypeObject LibLVMvgType = {
11 years, 4 months
master - python-lvm: Small fixups to new create_lv_snapshot
by Andy Grover
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=58b61c252a57e3...
Commit: 58b61c252a57e3e18e82cfd9cc24567339ca4508
Parent: 0db733f18ab8dd4e51c050938c699932c8dca08d
Author: Andy Grover <agrover(a)redhat.com>
AuthorDate: Fri Dec 14 10:17:29 2012 -0800
Committer: Andy Grover <agrover(a)redhat.com>
CommitterDate: Fri Dec 14 10:30:26 2012 -0800
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(a)redhat.com>
---
WHATS_NEW | 1 +
python/liblvm.c | 23 +++++++----------------
2 files changed, 8 insertions(+), 16 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index 075fda2..697e4d2 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -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.
diff --git a/python/liblvm.c b/python/liblvm.c
index 11f5f72..3b1a4f2 100644
--- a/python/liblvm.c
+++ b/python/liblvm.c
@@ -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 */
};
11 years, 4 months
master - python-lvm: Add snapshot support
by Andy Grover
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=0db733f18ab8dd...
Commit: 0db733f18ab8dd4e51c050938c699932c8dca08d
Parent: 90467a1412e8c227f83ba7825250e33a4d39607d
Author: James Antill <james.antill(a)redhat.com>
AuthorDate: Thu Dec 13 17:39:09 2012 -0800
Committer: Andy Grover <agrover(a)redhat.com>
CommitterDate: Fri Dec 14 10:30:13 2012 -0800
python-lvm: Add snapshot support
Signed-off-by: Andy Grover <agrover(a)redhat.com>
---
python/liblvm.c | 39 +++++++++++++++++++++++++++++++++++++++
1 files changed, 39 insertions(+), 0 deletions(-)
diff --git a/python/liblvm.c b/python/liblvm.c
index 6ccc5ba..11f5f72 100644
--- a/python/liblvm.c
+++ b/python/liblvm.c
@@ -1312,6 +1312,44 @@ liblvm_lvm_lv_list_lvsegs(lvobject *self)
return pytuple;
}
+static PyObject *
+liblvm_lvm_vg_create_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)) {
+ 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) {
+ PyErr_SetObject(LibLVMError, liblvm_get_last_error());
+ Py_DECREF(lvobj);
+ return NULL;
+ }
+
+ lvobj->parent_vgobj = vgobj;
+ Py_INCREF(lvobj->parent_vgobj);
+
+ return (PyObject *)lvobj;
+}
+
/* PV Methods */
#define PV_VALID(pvobject) \
@@ -1580,6 +1618,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 },
{ NULL, NULL} /* sentinel */
};
11 years, 4 months
master - lvm2app: Add lv snapshot support
by Andy Grover
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=90467a1412e8c2...
Commit: 90467a1412e8c227f83ba7825250e33a4d39607d
Parent: e8025aa67a05af046878f52dfb45fca30ed70084
Author: Tony Asleson <tasleson(a)redhat.com>
AuthorDate: Thu Dec 13 17:57:38 2012 -0800
Committer: Andy Grover <agrover(a)redhat.com>
CommitterDate: Thu Dec 13 17:58:48 2012 -0800
lvm2app: Add lv snapshot support
Signed-off-by: Tony Asleson <tasleson(a)redhat.com>
Signed-off-by: Andy Grover <agrover(a)redhat.com>
---
liblvm/lvm2app.h | 21 +++++++++++++++++++
liblvm/lvm_lv.c | 57 ++++++++++++++++++++++++++++++++++++++++++++++++++++-
2 files changed, 76 insertions(+), 2 deletions(-)
diff --git a/liblvm/lvm2app.h b/liblvm/lvm2app.h
index b758945..93a78c3 100644
--- a/liblvm/lvm2app.h
+++ b/liblvm/lvm2app.h
@@ -1379,6 +1379,27 @@ int lvm_lv_rename(lv_t lv, const char *new_name);
*/
int lvm_lv_resize(const lv_t lv, uint64_t new_size);
+/**
+ * Create a snapshot of a logical volume
+ *
+ * \memberof lv_t
+ *
+ * \param lv
+ * Logical volume handle.
+ *
+ * \param snap_name
+ * Name of the snapshot.
+ *
+ * \param max_snap_size
+ * Max snapshot space to use. If you pass zero the same amount of space as
+ * the origin will be used.
+ *
+ * \return
+ * Valid lv pointer on success, else NULL on error.
+ *
+ */
+lv_t lvm_lv_snapshot(const lv_t lv, const char *snap_name, uint64_t max_snap_size);
+
/************************** physical volume handling ************************/
/**
diff --git a/liblvm/lvm_lv.c b/liblvm/lvm_lv.c
index b2a604d..a02e68d 100644
--- a/liblvm/lvm_lv.c
+++ b/liblvm/lvm_lv.c
@@ -122,12 +122,19 @@ static void _lv_set_default_params(struct lvcreate_params *lp,
dm_list_init(&lp->tags);
}
+static struct segment_type * _get_segtype(struct cmd_context *cmd) {
+ struct segment_type *rc = get_segtype_from_string(cmd, "striped");
+ if (!rc) {
+ log_error(INTERNAL_ERROR "Segtype striped not found.");
+ }
+ return rc;
+}
+
/* Set default for linear segment specific LV parameters */
static int _lv_set_default_linear_params(struct cmd_context *cmd,
struct lvcreate_params *lp)
{
- if (!(lp->segtype = get_segtype_from_string(cmd, "striped"))) {
- log_error(INTERNAL_ERROR "Segtype striped not found.");
+ if (!(lp->segtype = _get_segtype(cmd))) {
return 0;
}
@@ -306,3 +313,49 @@ int lvm_lv_resize(const lv_t lv, uint64_t new_size)
log_error("NOT IMPLEMENTED YET");
return -1;
}
+
+lv_t lvm_lv_snapshot(const lv_t lv, const char *snap_name, uint64_t max_snap_size)
+{
+ struct lvcreate_params lp = { 0 };
+ uint64_t extents = 0;
+ uint64_t size = 0;
+ struct lv_list *lvl = NULL;
+
+ if (vg_read_error(lv->vg))
+ return NULL;
+ if (!vg_check_write_mode(lv->vg))
+ return NULL;
+
+ /* Determine the correct size */
+ if (0 == max_snap_size){
+ size = lv->size;
+ } else {
+ size = max_snap_size >> SECTOR_SHIFT;
+
+ if (size > lv->size) {
+ size = lv->size;
+ }
+ }
+
+ if (!(extents = extents_from_size(lv->vg->cmd, size,
+ lv->vg->extent_size))) {
+ log_error("Unable to create LV snapshot without size.");
+ return NULL;
+ }
+
+ _lv_set_default_params(&lp, lv->vg, snap_name, extents);
+
+ /* Fill out required default input values */
+ lp.snapshot = 1;
+ lp.segtype = _get_segtype(lv->vg->cmd);
+ lp.stripes = 1;
+ lp.origin = lv->name;
+
+ if (!lp.segtype)
+ return_NULL;
+ if (!lv_create_single(lv->vg, &lp))
+ return_NULL;
+ if (!(lvl = find_lv_in_vg(lv->vg, snap_name)))
+ return NULL;
+ return (lv_t) lvl->lv;
+}
11 years, 4 months
master - lvconvert: also allow --type with --stripes
by Peter Rajnoha
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=e8025aa67a05af...
Commit: e8025aa67a05af046878f52dfb45fca30ed70084
Parent: c089029b70d64e4f7d2851336d463ce40f1b7023
Author: Peter Rajnoha <prajnoha(a)redhat.com>
AuthorDate: Thu Dec 13 11:15:37 2012 +0100
Committer: Peter Rajnoha <prajnoha(a)redhat.com>
CommitterDate: Thu Dec 13 11:19:11 2012 +0100
lvconvert: also allow --type with --stripes
We can also use this for conversion between different mirror segment
types. Each new segment type converter then needs to check itself
whether the --stripes is applicable.
---
tools/lvconvert.c | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/tools/lvconvert.c b/tools/lvconvert.c
index 9c947d7..fa3b1ec 100644
--- a/tools/lvconvert.c
+++ b/tools/lvconvert.c
@@ -169,9 +169,9 @@ static int _read_params(struct lvconvert_params *lp, struct cmd_context *cmd,
if ((arg_count(cmd, stripes_long_ARG) || arg_count(cmd, stripesize_ARG)) &&
!(arg_count(cmd, mirrors_ARG) || arg_count(cmd, repair_ARG) ||
- arg_count(cmd, thinpool_ARG))) {
+ arg_count(cmd, thinpool_ARG) || arg_count(cmd, type_ARG))) {
log_error("--stripes or --stripesize argument is only valid "
- "with --mirrors, --repair or --thinpool");
+ "with --mirrors, --repair, --thinpool or --type");
return 0;
}
11 years, 4 months
master - Update WHATS_NEW.
by Petr Rockai
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=c089029b70d64e...
Commit: c089029b70d64e4f7d2851336d463ce40f1b7023
Parent: b19f840af82cf176a26c8bddc2217fe862087794
Author: Petr Rockai <prockai(a)redhat.com>
AuthorDate: Wed Dec 12 15:17:08 2012 +0100
Committer: Petr Rockai <prockai(a)redhat.com>
CommitterDate: Wed Dec 12 15:17:08 2012 +0100
Update WHATS_NEW.
---
WHATS_NEW | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index 4214b27..075fda2 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.99 -
===================================
+ 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.
Fix memleak in device_is_usable mirror testing function.
11 years, 5 months
master - toollib: Avoid a global lock in process_each_pv if lvmetad is used.
by Petr Rockai
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=b19f840af82cf1...
Commit: b19f840af82cf176a26c8bddc2217fe862087794
Parent: e5709a32be746ad0d21b13df18f23387bcccabef
Author: Petr Rockai <prockai(a)redhat.com>
AuthorDate: Wed Dec 12 14:39:52 2012 +0100
Committer: Petr Rockai <prockai(a)redhat.com>
CommitterDate: Wed Dec 12 14:44:03 2012 +0100
toollib: Avoid a global lock in process_each_pv if lvmetad is used.
The motivation to grab the global lock is to avoid a scan and metadata parsing
for each PV, but the cost of obtaining metadata is _mostly_ mitigated by having
lvmetad around. Not taking the global lock improves throughput when multiple pvs
or related commands are running in parallel, like in RHEV.
---
tools/toollib.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/tools/toollib.c b/tools/toollib.c
index 817580f..1d67e5d 100644
--- a/tools/toollib.c
+++ b/tools/toollib.c
@@ -701,7 +701,7 @@ int process_each_pv(struct cmd_context *cmd, int argc, char **argv,
int opt = 0;
int ret_max = ECMD_PROCESSED;
int ret = 0;
- int lock_global = !(flags & READ_WITHOUT_LOCK) && !(flags & READ_FOR_UPDATE);
+ int lock_global = !(flags & READ_WITHOUT_LOCK) && !(flags & READ_FOR_UPDATE) && !lvmetad_active();
struct pv_list *pvl;
struct physical_volume *pv;
11 years, 5 months
master - lvmetad: fix compiler warning and add WHATS_NEW line for previous commit
by Peter Rajnoha
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=e5709a32be746a...
Commit: e5709a32be746ad0d21b13df18f23387bcccabef
Parent: f14f2d4378c066e50e2420e30407c8673cc7112a
Author: Peter Rajnoha <prajnoha(a)redhat.com>
AuthorDate: Wed Dec 12 13:27:25 2012 +0100
Committer: Peter Rajnoha <prajnoha(a)redhat.com>
CommitterDate: Wed Dec 12 13:27:25 2012 +0100
lvmetad: fix compiler warning and add WHATS_NEW line for previous commit
---
WHATS_NEW | 1 +
tools/pvscan.c | 2 +-
2 files changed, 2 insertions(+), 1 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index dbd59bf..4214b27 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.99 -
===================================
+ Fix crash in pvscan --cache -aay triggered by non-mda PV.
Allow lvconvert --stripes/stripesize only with --mirrors/--repair/--thinpool.
Fix memleak in device_is_usable mirror testing function.
Do not ignore -f in lvconvert --repair -y -f for mirror and raid volumes.
diff --git a/tools/pvscan.c b/tools/pvscan.c
index 81849f5..c2e6f5c 100644
--- a/tools/pvscan.c
+++ b/tools/pvscan.c
@@ -106,7 +106,7 @@ static int _auto_activation_handler(struct cmd_context *cmd,
id_read_format(&vgid_raw, vgid);
/* NB. This is safe because we know lvmetad is running and we won't hit
* disk. */
- if (!(vg = vg_read_internal(cmd, NULL, &vgid_raw, 0, &consistent)))
+ if (!(vg = vg_read_internal(cmd, NULL, (const char *) &vgid_raw, 0, &consistent)))
return 1;
if (vg_is_clustered(vg)) {
11 years, 5 months
master - lvmetad: Fix autoactivation for MDA-less PVs.
by Petr Rockai
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=f14f2d4378c066...
Commit: f14f2d4378c066e50e2420e30407c8673cc7112a
Parent: cad22be3942809bac979d42195ea5a861a91a71f
Author: Petr Rockai <prockai(a)redhat.com>
AuthorDate: Wed Dec 12 12:51:28 2012 +0100
Committer: Petr Rockai <prockai(a)redhat.com>
CommitterDate: Wed Dec 12 13:19:04 2012 +0100
lvmetad: Fix autoactivation for MDA-less PVs.
Calling pvscan --cache with -aay on a PV without an MDA would spuriously fail
with an internal error, because of an incorrect assumption that a parsed VG
structure was always available. This is not true and the autoactivation handler
needs to call vg_read to obtain metadata in cases where the PV had no MDAs to
parse. Therefore, we pass vgid into the handler instead of the (possibly NULL)
VG coming from the PV's MDA.
---
lib/cache/lvmetad.c | 12 +++------
lib/cache/lvmetad.h | 3 +-
test/shell/lvmetad-pvscan-nomda.sh | 49 ++++++++++++++++++++++++++++++++++++
tools/pvscan.c | 22 ++++++++++++++-
4 files changed, 75 insertions(+), 11 deletions(-)
diff --git a/lib/cache/lvmetad.c b/lib/cache/lvmetad.c
index e5c5f51..a636f43 100644
--- a/lib/cache/lvmetad.c
+++ b/lib/cache/lvmetad.c
@@ -675,7 +675,7 @@ int lvmetad_pv_found(const struct id *pvid, struct device *device, const struct
daemon_reply reply;
struct lvmcache_info *info;
struct dm_config_tree *pvmeta, *vgmeta;
- const char *status;
+ const char *status, *vgid;
int result;
if (!lvmetad_active() || test_mode())
@@ -724,11 +724,6 @@ int lvmetad_pv_found(const struct id *pvid, struct device *device, const struct
NULL);
dm_config_destroy(vgmeta);
} else {
- if (handler) {
- log_error(INTERNAL_ERROR "Handler needs existing VG.");
- dm_config_destroy(pvmeta);
- return 0;
- }
/* There are no MDAs on this PV. */
reply = _lvmetad_send("pv_found", "pvmeta = %t", pvmeta, NULL);
}
@@ -744,10 +739,11 @@ int lvmetad_pv_found(const struct id *pvid, struct device *device, const struct
if (result && handler) {
status = daemon_reply_str(reply, "status", "<missing>");
+ vgid = daemon_reply_str(reply, "vgid", "<missing>");
if (!strcmp(status, "partial"))
- handler(vg, 1, CHANGE_AAY);
+ handler(_lvmetad_cmd, vgid, 1, CHANGE_AAY);
else if (!strcmp(status, "complete"))
- handler(vg, 0, CHANGE_AAY);
+ handler(_lvmetad_cmd, vgid, 0, CHANGE_AAY);
else if (!strcmp(status, "orphan"))
;
else
diff --git a/lib/cache/lvmetad.h b/lib/cache/lvmetad.h
index 5f0f552..c644069 100644
--- a/lib/cache/lvmetad.h
+++ b/lib/cache/lvmetad.h
@@ -22,7 +22,8 @@ struct cmd_context;
struct dm_config_tree;
enum activation_change;
-typedef int (*activation_handler) (struct volume_group *vg, int partial,
+typedef int (*activation_handler) (struct cmd_context *cmd,
+ const char *vgid, int partial,
enum activation_change activate);
#ifdef LVMETAD_SUPPORT
diff --git a/test/shell/lvmetad-pvscan-nomda.sh b/test/shell/lvmetad-pvscan-nomda.sh
new file mode 100644
index 0000000..c04a275
--- /dev/null
+++ b/test/shell/lvmetad-pvscan-nomda.sh
@@ -0,0 +1,49 @@
+#!/bin/sh
+# Copyright (C) 2012 Red Hat, Inc. All rights reserved.
+#
+# This copyrighted material is made available to anyone wishing to use,
+# modify, copy, or redistribute it subject to the terms and conditions
+# of the GNU General Public License v.2.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software Foundation,
+# Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+. lib/test
+
+test -e LOCAL_LVMETAD || skip
+kill $(cat LOCAL_LVMETAD)
+rm LOCAL_LVMETAD
+
+aux prepare_devs 2
+
+pvcreate --metadatacopies 0 $dev1
+pvcreate --metadatacopies 1 $dev2
+vgcreate $vg1 $dev1 $dev2
+lvcreate -n foo -l 1 -an --zero n $vg1
+
+# start lvmetad but make sure it doesn't know about $dev1 or $dev2
+aux disable_dev $dev1
+aux disable_dev $dev2
+aux prepare_lvmetad
+lvs
+mv LOCAL_LVMETAD XXX
+aux enable_dev $dev2
+aux enable_dev $dev1
+mv XXX LOCAL_LVMETAD
+
+aux lvmconf 'global/use_lvmetad = 0'
+check inactive $vg1 foo
+aux lvmconf 'global/use_lvmetad = 1'
+
+pvscan --cache $dev2 -aay
+
+aux lvmconf 'global/use_lvmetad = 0'
+check inactive $vg1 foo
+aux lvmconf 'global/use_lvmetad = 1'
+
+pvscan --cache $dev1 -aay
+
+aux lvmconf 'global/use_lvmetad = 0'
+check active $vg1 foo
+aux lvmconf 'global/use_lvmetad = 1'
diff --git a/tools/pvscan.c b/tools/pvscan.c
index 34ab792..81849f5 100644
--- a/tools/pvscan.c
+++ b/tools/pvscan.c
@@ -91,18 +91,36 @@ static void _pvscan_display_single(struct cmd_context *cmd,
display_size(cmd, (uint64_t) (pv_pe_count(pv) - pv_pe_alloc_count(pv)) * pv_pe_size(pv)));
}
-static int _auto_activation_handler(struct volume_group *vg, int partial,
+static int _auto_activation_handler(struct cmd_context *cmd,
+ const char *vgid, int partial,
activation_change_t activate)
{
+ struct volume_group *vg;
+ int consistent = 0;
+ struct id vgid_raw;
+
/* TODO: add support for partial and clustered VGs */
- if (partial || vg_is_clustered(vg))
+ if (partial)
return 1;
+ id_read_format(&vgid_raw, vgid);
+ /* NB. This is safe because we know lvmetad is running and we won't hit
+ * disk. */
+ if (!(vg = vg_read_internal(cmd, NULL, &vgid_raw, 0, &consistent)))
+ return 1;
+
+ if (vg_is_clustered(vg)) {
+ release_vg(vg);
+ return 1;
+ }
+
if (!vgchange_activate(vg->cmd, vg, activate)) {
log_error("%s: autoactivation failed.", vg->name);
+ release_vg(vg);
return 0;
}
+ release_vg(vg);
return 1;
}
11 years, 5 months