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 8184713 python: Fix issues introduced in latest 4k API changes
8184713 is described below
commit 8184713b5e0fbfe52cb243b3c938183ee15f56b2
Author: Nir Soffer <nirsof(a)gmail.com>
AuthorDate: Sun May 5 15:33:58 2019 +0300
python: Fix issues introduced in latest 4k API changes
Fix few issues in the latests 4k API changes:
- Fix ValueError when using align=8388608 - a break was missing.
- Remove the unneeded ALIGNX and SECTORX constants - seems that David
merged an older version of the patch which did not remove them.
- Fix capitalization and punctuation in new comments.
- Remove trailing whitespace.
- Wrap long enum difinition.
Signed-off-by: Nir Soffer <nsoffer(a)redhat.com>
---
python/sanlock.c | 20 +++++++++-----------
tests/python_test.py | 8 ++++----
2 files changed, 13 insertions(+), 15 deletions(-)
diff --git a/python/sanlock.c b/python/sanlock.c
index a1215bd..d6841e8 100644
--- a/python/sanlock.c
+++ b/python/sanlock.c
@@ -154,7 +154,12 @@ add_sector_flag(int sector, uint32_t *flags)
return 0;
}
-enum {ALIGNMENT_1M = 1048576, ALIGNMENT_2M = 2097152, ALIGNMENT_4M = 4194304,
ALIGNMENT_8M = 8388608};
+enum {
+ ALIGNMENT_1M = 1048576,
+ ALIGNMENT_2M = 2097152,
+ ALIGNMENT_4M = 4194304,
+ ALIGNMENT_8M = 8388608
+};
static int
add_align_flag(long align, uint32_t *flags)
@@ -171,6 +176,7 @@ add_align_flag(long align, uint32_t *flags)
break;
case ALIGNMENT_8M:
*flags |= SANLK_RES_ALIGN8M;
+ break;
default:
PyErr_Format(PyExc_ValueError, "Invalid align value: %ld", align);
return -1;
@@ -441,7 +447,7 @@ py_write_lockspace(PyObject *self __unused, PyObject *args, PyObject
*keywds)
if (add_sector_flag(sector, &ls.flags) == -1)
return NULL;
-
+
/* write sanlock lockspace (gil disabled) */
Py_BEGIN_ALLOW_THREADS
rv = sanlock_write_lockspace(&ls, max_hosts, 0, io_timeout);
@@ -1720,14 +1726,6 @@ initsanlock(void)
PYSNLK_INIT_ADD_CONSTANT(SANLK_SETEV_REPLACE_EVENT,
"SETEV_REPLACE_EVENT");
PYSNLK_INIT_ADD_CONSTANT(SANLK_SETEV_ALL_HOSTS, "SETEV_ALL_HOSTS");
- /* Sector and align size flags */
- PYSNLK_INIT_ADD_CONSTANT(SANLK_RES_SECTOR512, "SECTOR512");
- PYSNLK_INIT_ADD_CONSTANT(SANLK_RES_SECTOR4K, "SECTOR4K");
- PYSNLK_INIT_ADD_CONSTANT(SANLK_RES_ALIGN1M, "ALIGN1M");
- PYSNLK_INIT_ADD_CONSTANT(SANLK_RES_ALIGN2M, "ALIGN2M");
- PYSNLK_INIT_ADD_CONSTANT(SANLK_RES_ALIGN4M, "ALIGN4M");
- PYSNLK_INIT_ADD_CONSTANT(SANLK_RES_ALIGN8M, "ALIGN8M");
-
#undef PYSNLK_INIT_ADD_CONSTANT
/* Tuples with supported sector size and alignment values */
@@ -1738,7 +1736,7 @@ initsanlock(void)
Py_DECREF(sector);
return;
}
-
+
PyObject *align = Py_BuildValue("llll", ALIGNMENT_1M, ALIGNMENT_2M,
ALIGNMENT_4M, ALIGNMENT_8M);
if (!align)
return;
diff --git a/tests/python_test.py b/tests/python_test.py
index a0474f1..1a6bbbd 100644
--- a/tests/python_test.py
+++ b/tests/python_test.py
@@ -37,13 +37,13 @@ def test_write_lockspace(tmpdir, sanlock_daemon, size, offset):
path = str(tmpdir.join("lockspace"))
util.create_file(path, size)
- # test read and write with default alignment and sector size values
+ # Test read and write with default alignment and sector size values.
sanlock.write_lockspace("name", path, offset=offset, iotimeout=1)
ls = sanlock.read_lockspace(path, offset=offset)
assert ls == {"iotimeout": 1, "lockspace": "name"}
- # test read and write with explicit alignment and sector size values
+ # Test read and write with explicit alignment and sector size values.
sanlock.write_lockspace(
"name", path, offset=offset, iotimeout=1, align=ALIGNMENT_1M,
sector=SECTOR_SIZE_512)
@@ -77,7 +77,7 @@ def test_write_resource(tmpdir, sanlock_daemon, size, offset):
util.create_file(path, size)
disks = [(path, offset)]
- # test read and write with default alignment and sector size values
+ # Test read and write with default alignment and sector size values.
sanlock.write_resource("ls_name", "res_name", disks)
res = sanlock.read_resource(path, offset=offset)
@@ -87,7 +87,7 @@ def test_write_resource(tmpdir, sanlock_daemon, size, offset):
"version": 0
}
- # test read and write with explicit alignment and sector size values
+ # Test read and write with explicit alignment and sector size values.
sanlock.write_resource(
"ls_name", "res_name", disks, align=ALIGNMENT_1M,
sector=SECTOR_SIZE_512)
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.