[sanlock] 09/09: python: improve lvb tests
by pagure@pagure.io
This is an automated email from the git hooks/post-receive script.
teigland pushed a commit to branch rhel83
in repository sanlock.
commit 058ad1c7e4566696475241ea0897bbf799144d1c
Author: Benny Zlotnik <bzlotnik(a)redhat.com>
AuthorDate: Wed Dec 9 19:14:36 2020 +0200
python: improve lvb tests
- Remove null byte test, it is now tested in the basic test
- Add test for reading less than sector size
Testing storage with 4k sector size needs more work.
Signed-off-by: Benny Zlotnik <bzlotnik(a)redhat.com>
Signed-off-by: Nir Soffer <nsoffer(a)redhat.com>
---
tests/python_test.py | 64 ++++++++++++++++++----------------------------------
1 file changed, 22 insertions(+), 42 deletions(-)
diff --git a/tests/python_test.py b/tests/python_test.py
index 5e034a7..448b043 100644
--- a/tests/python_test.py
+++ b/tests/python_test.py
@@ -800,70 +800,50 @@ def test_acquire_path_length(no_sanlock_daemon):
def test_lvb(tmpdir, sanlock_daemon):
ls_path = str(tmpdir.join("ls_name"))
util.create_file(ls_path, MiB)
-
res_path = str(tmpdir.join("res_name"))
util.create_file(res_path, MiB)
-
sanlock.write_lockspace(b"ls_name", ls_path, offset=0, iotimeout=1)
sanlock.add_lockspace(b"ls_name", 1, ls_path, offset=0, iotimeout=1)
-
disks = [(res_path, 0)]
sanlock.write_resource(b"ls_name", b"res_name", disks)
fd = sanlock.register()
- sanlock.acquire(b"ls_name", b"res_name", disks, slkfd=fd, lvb=True)
- sanlock.set_lvb(b"ls_name", b"res_name", disks, b"{gen:0}")
+ lvb_data = b"first\0second"
+ lvb_sector = lvb_data.ljust(512, b"\0")
- result = sanlock.get_lvb(b"ls_name", b"res_name", disks)
+ sanlock.acquire(b"ls_name", b"res_name", disks, slkfd=fd, lvb=True)
+ sanlock.set_lvb(b"ls_name", b"res_name", disks, lvb_sector)
sanlock.release(b"ls_name", b"res_name", disks, slkfd=fd)
- assert result == b"{gen:0}"
+ # Test reading complete sector (typical usage).
+ sanlock.acquire(b"ls_name", b"res_name", disks, slkfd=fd, lvb=True)
+ result = sanlock.get_lvb(b"ls_name", b"res_name", disks, len(lvb_sector))
+ sanlock.release(b"ls_name", b"res_name", disks, slkfd=fd)
-def test_lvb_value_too_long(tmpdir, sanlock_daemon):
- ls_path = str(tmpdir.join("ls_name"))
- util.create_file(ls_path, MiB)
-
- res_path = str(tmpdir.join("res_name"))
- util.create_file(res_path, MiB)
-
- sanlock.write_lockspace(b"ls_name", ls_path, offset=0, iotimeout=1)
- sanlock.add_lockspace(b"ls_name", 1, ls_path, offset=0, iotimeout=1)
-
- disks = [(res_path, 0)]
- sanlock.write_resource(b"ls_name", b"res_name", disks)
+ assert result == lvb_sector
- fd = sanlock.register()
+ # Test reading less than sector size.
- long_val = b"a" * 513
sanlock.acquire(b"ls_name", b"res_name", disks, slkfd=fd, lvb=True)
- with raises_sanlock_errno(errno.E2BIG):
- sanlock.set_lvb(b"ls_name", b"res_name", disks, long_val)
-
+ result = sanlock.get_lvb(b"ls_name", b"res_name", disks, len(lvb_data))
sanlock.release(b"ls_name", b"res_name", disks, slkfd=fd)
+ assert result == lvb_data
-def test_lvb_null_bytes(tmpdir, sanlock_daemon):
- ls_path = str(tmpdir.join("ls_name"))
- util.create_file(ls_path, MiB)
-
- res_path = str(tmpdir.join("res_name"))
- util.create_file(res_path, MiB)
-
- sanlock.write_lockspace(b"ls_name", ls_path, offset=0, iotimeout=1)
- sanlock.add_lockspace(b"ls_name", 1, ls_path, offset=0, iotimeout=1)
+ # Test failure to write more then sector size.
- disks = [(res_path, 0)]
- sanlock.write_resource(b"ls_name", b"res_name", disks)
+ sanlock.acquire(b"ls_name", b"res_name", disks, slkfd=fd, lvb=True)
+ with raises_sanlock_errno(errno.E2BIG):
+ sanlock.set_lvb(b"ls_name", b"res_name", disks, lvb_sector + b"x")
- fd = sanlock.register()
- sanlock.acquire(b"ls_name", b"res_name", disks, slkfd=fd, lvb=True)
- sanlock.set_lvb(b"ls_name", b"res_name", disks, b"{ge\x00:0}")
+def test_lvb_invalid_value():
+ disks = [("/no/such/path", 0)]
- result = sanlock.get_lvb(b"ls_name", b"res_name", disks)
- sanlock.release(b"ls_name", b"res_name", disks, slkfd=fd)
+ with pytest.raises(ValueError):
+ sanlock.get_lvb(b"ls_name", b"res_name", disks, 0)
- # Check that the string we passed is terminated by the null-byte
- assert result == b"{ge"
+ with pytest.raises(ValueError):
+ sanlock.get_lvb(b"ls_name", b"res_name", disks, 4097)
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
3 years, 1 month
[sanlock] 08/09: python: support size in get_lvb
by pagure@pagure.io
This is an automated email from the git hooks/post-receive script.
teigland pushed a commit to branch rhel83
in repository sanlock.
commit 9117f93fa7909dd7b77e1bef6ddcc289d9643db6
Author: Benny Zlotnik <bzlotnik(a)redhat.com>
AuthorDate: Wed Dec 9 16:36:09 2020 +0200
python: support size in get_lvb
Add a size parameter to allow the user choose how much data to get back,
the API will now look like this:
sanlock.get_lvb(lockspace, resource, disks, size)
Signed-off-by: Benny Zlotnik <bzlotnik(a)redhat.com>
Signed-off-by: Nir Soffer <nsoffer(a)redhat.com>
---
python/sanlock.c | 33 ++++++++++++++++++++++++---------
1 file changed, 24 insertions(+), 9 deletions(-)
diff --git a/python/sanlock.c b/python/sanlock.c
index 2220cf3..e5a0cff 100644
--- a/python/sanlock.c
+++ b/python/sanlock.c
@@ -1754,35 +1754,43 @@ finally:
}
PyDoc_STRVAR(pydoc_get_lvb, "\
-get_lvb(lockspace, resource, disks) -> bytes\n\
+get_lvb(lockspace, resource, disks, size) -> bytes\n\
Read Lock Value Block for a given resource\n\
\n\
Arguments\n\
lockspace lockspace name (str)\n\
resource resource name (int)\n\
disks path and offset (tuple)\n\
+ size amount of data to read (int)\n\
\n\
Returns\n\
data data written with set_lvb\n\
\n\
Notes\n\
The resource must be acquired with lvb=True.\n\
+ size has to be in range 0 < n <= 4096.\n\
");
static PyObject *
py_get_lvb(PyObject *self __unused, PyObject *args, PyObject *keywds)
{
uint32_t flags = 0;
+ uint32_t lvb_len = 0;
int rv = -1;
struct sanlk_resource *res = NULL;
PyObject *lockspace = NULL, *resource = NULL;
- PyObject *disks;
- char data[512];
+ PyObject *disks = NULL;
+ PyObject *result = NULL;
- static char *kwlist[] = {"lockspace", "resource", "disks", NULL};
- if (!PyArg_ParseTupleAndKeywords(args, keywds, "O&O&O!", kwlist,
+ static char *kwlist[] = {"lockspace", "resource", "disks", "size", NULL};
+ if (!PyArg_ParseTupleAndKeywords(args, keywds, "O&O&O!I", kwlist,
convert_to_pybytes, &lockspace, convert_to_pybytes, &resource,
- &PyList_Type, &disks)) {
+ &PyList_Type, &disks, &lvb_len)) {
+ goto finally;
+ }
+
+ if (lvb_len < 1 || lvb_len > 4096) {
+ PyErr_Format(PyExc_ValueError, "Invalid size %d, must be in range: 0 < size <= 4096", lvb_len);
goto finally;
}
@@ -1793,8 +1801,15 @@ py_get_lvb(PyObject *self __unused, PyObject *args, PyObject *keywds)
strncpy(res->lockspace_name, PyBytes_AsString(lockspace), SANLK_NAME_LEN);
strncpy(res->name, PyBytes_AsString(resource), SANLK_NAME_LEN);
+ result = PyBytes_FromStringAndSize(NULL, lvb_len);
+ if (result == NULL) {
+ goto finally;
+ }
+
+ memset(PyBytes_AS_STRING(result), 0, lvb_len);
+
Py_BEGIN_ALLOW_THREADS
- rv = sanlock_get_lvb(flags, res, data, sizeof(data));
+ rv = sanlock_get_lvb(flags, res, PyBytes_AS_STRING(result), lvb_len);
Py_END_ALLOW_THREADS
if (rv < 0) {
@@ -1807,9 +1822,9 @@ finally:
Py_XDECREF(resource);
free(res);
if (rv < 0)
- return NULL;
+ Py_CLEAR(result);
- return Py_BuildValue("y", data);
+ return result;
}
static PyMethodDef
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
3 years, 1 month
[sanlock] 07/09: python: improve get/set_lvb documentation
by pagure@pagure.io
This is an automated email from the git hooks/post-receive script.
teigland pushed a commit to branch rhel83
in repository sanlock.
commit 51489e1e5cf346a9e35b300fc2c89588173c839a
Author: Benny Zlotnik <bzlotnik(a)redhat.com>
AuthorDate: Wed Dec 9 09:57:54 2020 +0200
python: improve get/set_lvb documentation
- Specify lvb=True explicitly instead of mentioning the sanlock flag
- Document when data is written and visible
- Unify whitespace in function documentation, consistent with other
functions.
Signed-off-by: Benny Zlotnik <bzlotnik(a)redhat.com>
Signed-off-by: Nir Soffer <nsoffer(a)redhat.com>
---
python/sanlock.c | 13 +++++++++----
1 file changed, 9 insertions(+), 4 deletions(-)
diff --git a/python/sanlock.c b/python/sanlock.c
index 40d3b88..2220cf3 100644
--- a/python/sanlock.c
+++ b/python/sanlock.c
@@ -1707,8 +1707,11 @@ Arguments\n\
data data to write (bytes)\n\
\n\
Notes\n\
-\n\
-The resource must be acquired with the SANLK_ACQUIRE_LVB flag\n");
+ The resource must be acquired with lvb=true.\n\
+ The size of data is limited by the sector size (512/4K).\n\
+ The new data is visible after the resource is released.\n\
+");
+
static PyObject *
py_set_lvb(PyObject *self __unused, PyObject *args, PyObject *keywds)
{
@@ -1761,9 +1764,11 @@ Arguments\n\
\n\
Returns\n\
data data written with set_lvb\n\
-Notes\n\
\n\
-The resource must be acquired with the SANLK_ACQUIRE_LVB flag\n");
+Notes\n\
+ The resource must be acquired with lvb=True.\n\
+");
+
static PyObject *
py_get_lvb(PyObject *self __unused, PyObject *args, PyObject *keywds)
{
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
3 years, 1 month
[sanlock] 06/09: tests: add a test for LVB operation
by pagure@pagure.io
This is an automated email from the git hooks/post-receive script.
teigland pushed a commit to branch rhel83
in repository sanlock.
commit 3eff548a846ea756db9f8440511874fcaa4580e0
Author: Benny Zlotnik <bzlotnik(a)redhat.com>
AuthorDate: Mon Oct 5 13:20:27 2020 +0300
tests: add a test for LVB operation
This patch tests writing and reading to LVB via python bindings.
Signed-off-by: Benny Zlotnik <bzlotnik(a)redhat.com>
---
tests/python_test.py | 72 ++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 72 insertions(+)
diff --git a/tests/python_test.py b/tests/python_test.py
index 719bcb6..5e034a7 100644
--- a/tests/python_test.py
+++ b/tests/python_test.py
@@ -795,3 +795,75 @@ def test_acquire_path_length(no_sanlock_daemon):
path = "x" * (constants.SANLK_PATH_LEN - 1)
with raises_sanlock_errno():
sanlock.acquire(b"ls_name", b"res_name", [(path, 0)], pid=os.getpid())
+
+
+def test_lvb(tmpdir, sanlock_daemon):
+ ls_path = str(tmpdir.join("ls_name"))
+ util.create_file(ls_path, MiB)
+
+ res_path = str(tmpdir.join("res_name"))
+ util.create_file(res_path, MiB)
+
+ sanlock.write_lockspace(b"ls_name", ls_path, offset=0, iotimeout=1)
+ sanlock.add_lockspace(b"ls_name", 1, ls_path, offset=0, iotimeout=1)
+
+ disks = [(res_path, 0)]
+ sanlock.write_resource(b"ls_name", b"res_name", disks)
+
+ fd = sanlock.register()
+
+ sanlock.acquire(b"ls_name", b"res_name", disks, slkfd=fd, lvb=True)
+ sanlock.set_lvb(b"ls_name", b"res_name", disks, b"{gen:0}")
+
+ result = sanlock.get_lvb(b"ls_name", b"res_name", disks)
+ sanlock.release(b"ls_name", b"res_name", disks, slkfd=fd)
+
+ assert result == b"{gen:0}"
+
+
+def test_lvb_value_too_long(tmpdir, sanlock_daemon):
+ ls_path = str(tmpdir.join("ls_name"))
+ util.create_file(ls_path, MiB)
+
+ res_path = str(tmpdir.join("res_name"))
+ util.create_file(res_path, MiB)
+
+ sanlock.write_lockspace(b"ls_name", ls_path, offset=0, iotimeout=1)
+ sanlock.add_lockspace(b"ls_name", 1, ls_path, offset=0, iotimeout=1)
+
+ disks = [(res_path, 0)]
+ sanlock.write_resource(b"ls_name", b"res_name", disks)
+
+ fd = sanlock.register()
+
+ long_val = b"a" * 513
+ sanlock.acquire(b"ls_name", b"res_name", disks, slkfd=fd, lvb=True)
+ with raises_sanlock_errno(errno.E2BIG):
+ sanlock.set_lvb(b"ls_name", b"res_name", disks, long_val)
+
+ sanlock.release(b"ls_name", b"res_name", disks, slkfd=fd)
+
+
+def test_lvb_null_bytes(tmpdir, sanlock_daemon):
+ ls_path = str(tmpdir.join("ls_name"))
+ util.create_file(ls_path, MiB)
+
+ res_path = str(tmpdir.join("res_name"))
+ util.create_file(res_path, MiB)
+
+ sanlock.write_lockspace(b"ls_name", ls_path, offset=0, iotimeout=1)
+ sanlock.add_lockspace(b"ls_name", 1, ls_path, offset=0, iotimeout=1)
+
+ disks = [(res_path, 0)]
+ sanlock.write_resource(b"ls_name", b"res_name", disks)
+
+ fd = sanlock.register()
+
+ sanlock.acquire(b"ls_name", b"res_name", disks, slkfd=fd, lvb=True)
+ sanlock.set_lvb(b"ls_name", b"res_name", disks, b"{ge\x00:0}")
+
+ result = sanlock.get_lvb(b"ls_name", b"res_name", disks)
+ sanlock.release(b"ls_name", b"res_name", disks, slkfd=fd)
+
+ # Check that the string we passed is terminated by the null-byte
+ assert result == b"{ge"
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
3 years, 1 month
[sanlock] 05/09: python: expose get_lvb
by pagure@pagure.io
This is an automated email from the git hooks/post-receive script.
teigland pushed a commit to branch rhel83
in repository sanlock.
commit 54435856a134468c97112bfe44815ca48e1b424f
Author: Benny Zlotnik <bzlotnik(a)redhat.com>
AuthorDate: Mon Oct 5 13:18:05 2020 +0300
python: expose get_lvb
Add a binding to the get_lvb function to allow reading data from LVB.
Signed-off-by: Benny Zlotnik <bzlotnik(a)redhat.com>
---
python/sanlock.c | 59 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 59 insertions(+)
diff --git a/python/sanlock.c b/python/sanlock.c
index 498cb88..40d3b88 100644
--- a/python/sanlock.c
+++ b/python/sanlock.c
@@ -1750,6 +1750,63 @@ finally:
Py_RETURN_NONE;
}
+PyDoc_STRVAR(pydoc_get_lvb, "\
+get_lvb(lockspace, resource, disks) -> bytes\n\
+Read Lock Value Block for a given resource\n\
+\n\
+Arguments\n\
+ lockspace lockspace name (str)\n\
+ resource resource name (int)\n\
+ disks path and offset (tuple)\n\
+\n\
+Returns\n\
+ data data written with set_lvb\n\
+Notes\n\
+\n\
+The resource must be acquired with the SANLK_ACQUIRE_LVB flag\n");
+static PyObject *
+py_get_lvb(PyObject *self __unused, PyObject *args, PyObject *keywds)
+{
+ uint32_t flags = 0;
+ int rv = -1;
+ struct sanlk_resource *res = NULL;
+ PyObject *lockspace = NULL, *resource = NULL;
+ PyObject *disks;
+ char data[512];
+
+ static char *kwlist[] = {"lockspace", "resource", "disks", NULL};
+ if (!PyArg_ParseTupleAndKeywords(args, keywds, "O&O&O!", kwlist,
+ convert_to_pybytes, &lockspace, convert_to_pybytes, &resource,
+ &PyList_Type, &disks)) {
+ goto finally;
+ }
+
+ if (parse_disks(disks, &res) < 0) {
+ goto finally;
+ }
+
+ strncpy(res->lockspace_name, PyBytes_AsString(lockspace), SANLK_NAME_LEN);
+ strncpy(res->name, PyBytes_AsString(resource), SANLK_NAME_LEN);
+
+ Py_BEGIN_ALLOW_THREADS
+ rv = sanlock_get_lvb(flags, res, data, sizeof(data));
+ Py_END_ALLOW_THREADS
+
+ if (rv < 0) {
+ set_sanlock_error(rv, "Unable to get lvb");
+ goto finally;
+ }
+
+finally:
+ Py_XDECREF(lockspace);
+ Py_XDECREF(resource);
+ free(res);
+ if (rv < 0)
+ return NULL;
+
+ return Py_BuildValue("y", data);
+}
+
static PyMethodDef
sanlock_methods[] = {
{"register", py_register, METH_NOARGS, pydoc_register},
@@ -1793,6 +1850,8 @@ sanlock_methods[] = {
METH_VARARGS|METH_KEYWORDS, pydoc_set_event},
{"set_lvb", (PyCFunction) py_set_lvb,
METH_VARARGS|METH_KEYWORDS, pydoc_set_lvb},
+ {"get_lvb", (PyCFunction) py_get_lvb,
+ METH_VARARGS|METH_KEYWORDS, pydoc_get_lvb},
{NULL, NULL, 0, NULL}
};
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
3 years, 1 month
[sanlock] 04/09: python: expose set_lvb
by pagure@pagure.io
This is an automated email from the git hooks/post-receive script.
teigland pushed a commit to branch rhel83
in repository sanlock.
commit b0681cbc76d7dc398bd79b6f4cbb919dd539a92f
Author: Benny Zlotnik <bzlotnik(a)redhat.com>
AuthorDate: Mon Oct 5 13:04:13 2020 +0300
python: expose set_lvb
Add a binding to the set_lvb function to allow writing data to LVB.
Signed-off-by: Benny Zlotnik <bzlotnik(a)redhat.com>
---
python/sanlock.c | 58 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 58 insertions(+)
diff --git a/python/sanlock.c b/python/sanlock.c
index d26e618..498cb88 100644
--- a/python/sanlock.c
+++ b/python/sanlock.c
@@ -1695,6 +1695,61 @@ finally:
Py_RETURN_NONE;
}
+/* set_lvb */
+PyDoc_STRVAR(pydoc_set_lvb, "\
+set_lvb(lockspace, resource, disks, data)\n\
+Set Lock Value Block for a given resource\n\
+\n\
+Arguments\n\
+ lockspace lockspace name (str)\n\
+ resource resource name (int)\n\
+ disks path and offset (tuple)\n\
+ data data to write (bytes)\n\
+\n\
+Notes\n\
+\n\
+The resource must be acquired with the SANLK_ACQUIRE_LVB flag\n");
+static PyObject *
+py_set_lvb(PyObject *self __unused, PyObject *args, PyObject *keywds)
+{
+ uint32_t flags = 0;
+ int rv = -1;
+ struct sanlk_resource *res = NULL;
+ PyObject *lockspace = NULL, *resource = NULL, *data = NULL;
+ PyObject *disks;
+
+ static char *kwlist[] = {"lockspace", "resource", "disks", "data", NULL};
+ if (!PyArg_ParseTupleAndKeywords(args, keywds, "O&O&O!O&", kwlist,
+ convert_to_pybytes, &lockspace, convert_to_pybytes, &resource,
+ &PyList_Type, &disks, convert_to_pybytes, &data)) {
+ goto finally;
+ }
+
+ if (parse_disks(disks, &res) < 0) {
+ goto finally;
+ }
+
+ strncpy(res->lockspace_name, PyBytes_AsString(lockspace), SANLK_NAME_LEN);
+ strncpy(res->name, PyBytes_AsString(resource), SANLK_NAME_LEN);
+
+ Py_BEGIN_ALLOW_THREADS
+ rv = sanlock_set_lvb(flags, res, PyBytes_AS_STRING(data), PyBytes_GET_SIZE(data));
+ Py_END_ALLOW_THREADS
+
+ if (rv < 0) {
+ set_sanlock_error(rv, "Unable to set lvb");
+ goto finally;
+ }
+
+finally:
+ Py_XDECREF(lockspace);
+ Py_XDECREF(resource);
+ free(res);
+ if (rv < 0)
+ return NULL;
+ Py_RETURN_NONE;
+}
+
static PyMethodDef
sanlock_methods[] = {
{"register", py_register, METH_NOARGS, pydoc_register},
@@ -1736,6 +1791,9 @@ sanlock_methods[] = {
{"end_event", (PyCFunction) py_end_event, METH_VARARGS, pydoc_end_event},
{"set_event", (PyCFunction) py_set_event,
METH_VARARGS|METH_KEYWORDS, pydoc_set_event},
+ {"set_lvb", (PyCFunction) py_set_lvb,
+ METH_VARARGS|METH_KEYWORDS, pydoc_set_lvb},
+
{NULL, NULL, 0, NULL}
};
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
3 years, 1 month
[sanlock] 03/09: python: add lvb flag to sanlock.acquire
by pagure@pagure.io
This is an automated email from the git hooks/post-receive script.
teigland pushed a commit to branch rhel83
in repository sanlock.
commit f2457f033f4cd55280628f1033f648d2497d30d0
Author: Benny Zlotnik <bzlotnik(a)redhat.com>
AuthorDate: Mon Oct 5 12:49:31 2020 +0300
python: add lvb flag to sanlock.acquire
The flag will allow to acquire a resource with the SANLK_ACQUIRE_LVB
flag, allowing the user to write or read data from LVB space.
Signed-off-by: Benny Zlotnik <bzlotnik(a)redhat.com>
---
python/sanlock.c | 21 ++++++++++++++-------
1 file changed, 14 insertions(+), 7 deletions(-)
diff --git a/python/sanlock.c b/python/sanlock.c
index 7c50aba..d26e618 100644
--- a/python/sanlock.c
+++ b/python/sanlock.c
@@ -1082,28 +1082,31 @@ finally:
/* acquire */
PyDoc_STRVAR(pydoc_acquire, "\
acquire(lockspace, resource, disks \
-[, slkfd=fd, pid=owner, shared=False, version=None])\n\
+[, slkfd=fd, pid=owner, shared=False, version=None, lvb=False])\n\
Acquire a resource lease for the current process (using the slkfd argument\n\
to specify the sanlock file descriptor) or for an other process (using the\n\
pid argument). If shared is True the resource will be acquired in the shared\n\
mode. The version is the version of the lease that must be acquired or fail.\n\
-The disks must be in the format: [(path, offset), ... ]\n");
+The disks must be in the format: [(path, offset), ... ]\n\
+If lvb is True the resource will be acquired with the LVB flag enabled\n\
+to allow access to LVB data.\n");
static PyObject *
py_acquire(PyObject *self __unused, PyObject *args, PyObject *keywds)
{
- int rv = -1, sanlockfd = -1, pid = -1, shared = 0;
+ int rv = -1, sanlockfd = -1, pid = -1, shared = 0, lvb = 0;
+ uint32_t flags = 0;
PyObject *lockspace = NULL, *resource = NULL;
struct sanlk_resource *res = NULL;
PyObject *disks, *version = Py_None;
static char *kwlist[] = {"lockspace", "resource", "disks", "slkfd",
- "pid", "shared", "version", NULL};
+ "pid", "shared", "lvb", "version", NULL};
/* parse python tuple */
- if (!PyArg_ParseTupleAndKeywords(args, keywds, "O&O&O!|iiiO", kwlist,
+ if (!PyArg_ParseTupleAndKeywords(args, keywds, "O&O&O!|iiiiO", kwlist,
convert_to_pybytes, &lockspace, convert_to_pybytes, &resource,
- &PyList_Type, &disks, &sanlockfd, &pid, &shared, &version)) {
+ &PyList_Type, &disks, &sanlockfd, &pid, &shared, &lvb, &version)) {
goto finally;
}
@@ -1127,6 +1130,10 @@ py_acquire(PyObject *self __unused, PyObject *args, PyObject *keywds)
res->flags |= SANLK_RES_SHARED;
}
+ if (lvb) {
+ flags |= SANLK_ACQUIRE_LVB;
+ }
+
/* prepare the resource version */
if (version != Py_None) {
res->flags |= SANLK_RES_LVER;
@@ -1139,7 +1146,7 @@ py_acquire(PyObject *self __unused, PyObject *args, PyObject *keywds)
/* acquire sanlock resource (gil disabled) */
Py_BEGIN_ALLOW_THREADS
- rv = sanlock_acquire(sanlockfd, pid, 0, 1, &res, 0);
+ rv = sanlock_acquire(sanlockfd, pid, flags, 1, &res, 0);
Py_END_ALLOW_THREADS
if (rv != 0) {
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
3 years, 1 month
[sanlock] 02/09: sanlock: Report actual max_worker_threads
by pagure@pagure.io
This is an automated email from the git hooks/post-receive script.
teigland pushed a commit to branch rhel83
in repository sanlock.
commit 6d90211ada8d6c3566409d6c188bf84068a2ab0d
Author: Nir Soffer <nsoffer(a)redhat.com>
AuthorDate: Sun Dec 6 20:14:11 2020 +0200
sanlock: Report actual max_worker_threads
Report actual max_worker_threads in "sanlock client status -D". This
allows detecting the issue when sanlock configuration was updated, but
sanlock daemon needs a restart to pick up the new configuration.
Signed-off-by: Nir Soffer <nsoffer(a)redhat.com>
---
src/cmd.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/src/cmd.c b/src/cmd.c
index a5fa30f..3137df0 100644
--- a/src/cmd.c
+++ b/src/cmd.c
@@ -2265,6 +2265,7 @@ static int print_state_daemon(char *str)
"max_sectors_kb_ignore=%d "
"max_sectors_kb_align=%d "
"max_sectors_kb_num=%d "
+ "max_worker_threads=%d "
"write_init_io_timeout=%u "
"use_aio=%d "
"kill_grace_seconds=%d "
@@ -2292,6 +2293,7 @@ static int print_state_daemon(char *str)
com.max_sectors_kb_ignore,
com.max_sectors_kb_align,
com.max_sectors_kb_num,
+ com.max_worker_threads,
com.write_init_io_timeout,
main_task.use_aio,
kill_grace_seconds,
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
3 years, 1 month
[sanlock] 01/09: config: Add max_worker_threads
by pagure@pagure.io
This is an automated email from the git hooks/post-receive script.
teigland pushed a commit to branch rhel83
in repository sanlock.
commit ddb973d566b409064db18debede04f7c3a8fd089
Author: Nir Soffer <nsoffer(a)redhat.com>
AuthorDate: Mon Nov 30 15:02:33 2020 -0600
config: Add max_worker_threads
Concurrent async add_lockspace calls are limited by the number of worker
threads. Using larger number of worker threads shorten the time to add
many locksapces in large setups.
Previously this value could be modified only via the command line. Now
it can be modified via the sanlock configuration file for easier
deployment.
Buglink: https://bugzilla.redhat.com/1902468
Signed-off-by: Nir Soffer <nsoffer(a)redhat.com>
---
src/main.c | 7 +++++++
src/sanlock.8 | 5 +++++
src/sanlock.conf | 3 +++
3 files changed, 15 insertions(+)
diff --git a/src/main.c b/src/main.c
index e2901f3..63d8cff 100644
--- a/src/main.c
+++ b/src/main.c
@@ -2877,6 +2877,13 @@ static void read_config_file(void)
} else {
log_error("ignore unknown max_sectors_kb %s", str);
}
+
+ } else if (!strcmp(str, "max_worker_threads")) {
+ get_val_int(line, &val);
+ if (val < DEFAULT_MIN_WORKER_THREADS)
+ val = DEFAULT_MIN_WORKER_THREADS;
+ com.max_worker_threads = val;
+
}
}
diff --git a/src/sanlock.8 b/src/sanlock.8
index d77f24c..9611b47 100644
--- a/src/sanlock.8
+++ b/src/sanlock.8
@@ -1372,6 +1372,11 @@ The io timeout to use when initializing ondisk lease structures
for a lockspace or resource. This timeout is not used as a part
of either lease algorithm (as the standard io_timeout is.)
+.IP \[bu] 2
+max_worker_threads = <num>
+.br
+See -t
+
.SH SEE ALSO
.BR wdmd (8)
diff --git a/src/sanlock.conf b/src/sanlock.conf
index 9b78e5c..2909a9c 100644
--- a/src/sanlock.conf
+++ b/src/sanlock.conf
@@ -66,3 +66,6 @@
#
# write_init_io_timeout = <seconds>
# command line: n/a
+#
+# max_worker_threads = 8
+# command line: -t 8
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
3 years, 1 month
[sanlock] branch master updated: release 3.8.3
by pagure@pagure.io
This is an automated email from the git hooks/post-receive script.
teigland pushed a commit to branch master
in repository sanlock.
The following commit(s) were added to refs/heads/master by this push:
new 3a750fe release 3.8.3
3a750fe is described below
commit 3a750fed849405c745dcb7b4ceb85f662c53d8d0
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Tue Jan 19 13:47:32 2021 -0600
release 3.8.3
---
VERSION | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/VERSION b/VERSION
index a08ffae..269aa9c 100644
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-3.8.2
+3.8.3
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
3 years, 1 month