This is an automated email from the git hooks/post-receive script.
nsoffer pushed a commit to branch master
in repository sanlock.
commit 67b246873ff433c332d757ba3af3272930b64d8f
Author: Nir Soffer <nsoffer(a)redhat.com>
AuthorDate: Tue May 7 00:49:05 2019 +0300
python: Add align and sector arguments to read_resource_owners()
We forgot to add the flags to this function, and it works with 4k
storage because sanlock implements a fallback mechanism. Since we
require align and sector arguments in read_resource(), we should also
require them for consistency in read_resource_owners().
Signed-off-by: Nir Soffer <nsoffer(a)redhat.com>
---
python/example.py | 2 +-
python/sanlock.c | 24 +++++++++++++++++++-----
2 files changed, 20 insertions(+), 6 deletions(-)
diff --git a/python/example.py b/python/example.py
index cb8f3e9..6ef9f7d 100644
--- a/python/example.py
+++ b/python/example.py
@@ -54,7 +54,7 @@ def main():
time.sleep(5)
print "Resource '%s' owners: " % RESOURCE_NAME, \
sanlock.read_resource_owners(
- LOCKSPACE_NAME, RESOURCE_NAME, SNLK_DISKS)
+ LOCKSPACE_NAME, RESOURCE_NAME, SNLK_DISKS, align=1048576, sector=512)
print "Releasing '%s' on '%s'" % (RESOURCE_NAME,
LOCKSPACE_NAME)
sanlock.release(LOCKSPACE_NAME, RESOURCE_NAME, SNLK_DISKS, slkfd=fd)
except Exception as e:
diff --git a/python/sanlock.c b/python/sanlock.c
index d6841e8..0b9a61e 100644
--- a/python/sanlock.c
+++ b/python/sanlock.c
@@ -1197,26 +1197,32 @@ exit_fail:
/* read_resource_owners */
PyDoc_STRVAR(pydoc_read_resource_owners, "\
-read_resource_owners(lockspace, resource, disks) -> list\n\
+read_resource_owners(lockspace, resource, disks, align=1048576, sector=512) \
+-> list\n\
Returns the list of hosts owning a resource, the list is not filtered and\n\
it might contain hosts that are currently failing or dead. The hosts are\n\
returned in the same format used by get_hosts.\n\
-The disks must be in the format: [(path, offset), ... ]");
+The disks must be in the format: [(path, offset), ... ].\n\
+Align can be one of (1048576, 2097152, 4194304, 8388608).\n\
+Sector can be one of (512, 4096).");
static PyObject *
py_read_resource_owners(PyObject *self __unused, PyObject *args, PyObject *keywds)
{
int rv, hss_count = 0;
+ int sector = SECTOR_SIZE_512;
+ long align = ALIGNMENT_1M;
const char *lockspace, *resource;
struct sanlk_resource *res = NULL;
struct sanlk_host *hss = NULL;
PyObject *disks, *ls_list = NULL;
- static char *kwlist[] = {"lockspace", "resource",
"disks", NULL};
+ static char *kwlist[] = {"lockspace", "resource",
"disks", "align",
+ "sector", NULL};
/* parse python tuple */
- if (!PyArg_ParseTupleAndKeywords(args, keywds, "ssO!", kwlist,
- &lockspace, &resource, &PyList_Type, &disks)) {
+ if (!PyArg_ParseTupleAndKeywords(args, keywds, "ssO!|li", kwlist,
+ &lockspace, &resource, &PyList_Type, &disks, &align,
§or)) {
return NULL;
}
@@ -1229,6 +1235,14 @@ py_read_resource_owners(PyObject *self __unused, PyObject *args,
PyObject *keywd
strncpy(res->lockspace_name, lockspace, SANLK_NAME_LEN);
strncpy(res->name, resource, SANLK_NAME_LEN);
+ /* set resource alignment and sector flags */
+
+ if (add_align_flag(align, &res->flags) == -1)
+ goto exit_fail;
+
+ if (add_sector_flag(sector, &res->flags) == -1)
+ goto exit_fail;
+
/* read resource owners (gil disabled) */
Py_BEGIN_ALLOW_THREADS
rv = sanlock_read_resource_owners(res, 0, &hss, &hss_count);
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.