This is an automated email from the git hooks/post-receive script.
nsoffer pushed a commit to branch master
in repository sanlock.
commit 9488ad21dc4f7612708cd15d97cde07b18e6bd08
Author: Nir Soffer <nsoffer(a)redhat.com>
AuthorDate: Sun May 12 04:04:58 2019 +0300
sanlock: Fail read_resource_owners with incorrect align size
Previously if sector size was not set, we modified both sector size and
align size, dropping the caller align size silently.
This can cause two issues:
- User align size was correct, but sanlock guessed the wrong value -
in this case sanlock logs a debug message and perform another read.
- User align size was incorrect, but sanlock guess was correct, hiding a
bug in caller code.
Change the behaviour to be more consistent with the way we validate
sector size, and reject invalid value set by the user.
Signed-off-by: Nir Soffer <nsoffer(a)redhat.com>
---
src/resource.c | 17 +++++++++++++----
tests/python_test.py | 1 -
2 files changed, 13 insertions(+), 5 deletions(-)
diff --git a/src/resource.c b/src/resource.c
index 21dbe84..76d506c 100644
--- a/src/resource.c
+++ b/src/resource.c
@@ -170,6 +170,7 @@ int read_resource_owners(struct task *task, struct token *token,
char *lease_buf = NULL;
char *hosts_buf = NULL;
const int sector_size_set = token->sector_size != 0;
+ const int align_size_set = token->align_size != 0;
int align_size;
int host_count = 0;
int i, rv;
@@ -177,11 +178,12 @@ int read_resource_owners(struct task *task, struct token *token,
disk = &token->disks[0];
/* If sector size not set, start with the smaller one. */
-
- if (!sector_size_set) {
+ if (!sector_size_set)
token->sector_size = 512;
- token->align_size = sector_size_to_align_size_old(512);
- }
+
+ /* If align size not set, default to the older align. */
+ if (!align_size_set)
+ token->align_size = sector_size_to_align_size_old(token->sector_size);
/* we could in-line paxos_read_buf here like we do in read_mode_block */
retry:
@@ -213,6 +215,13 @@ int read_resource_owners(struct task *task, struct token *token,
goto out;
}
+ if (align_size_set && token->align_size != align_size) {
+ log_errot(token, "read_resource_owners invalid align_size: %d actual: %d",
+ token->align_size, align_size);
+ rv = -EINVAL;
+ goto out;
+ }
+
/*
* If the caller did not specify sector size and our guess was wrong,
* retry with the actual value
diff --git a/tests/python_test.py b/tests/python_test.py
index 49460b5..12358c7 100644
--- a/tests/python_test.py
+++ b/tests/python_test.py
@@ -237,7 +237,6 @@ def test_read_resource_owners_4k_invalid_sector_size(
assert e.value.errno == errno.EINVAL
-(a)pytest.mark.xfail(reason="fallback hides invalid user value")
def test_read_resource_owners_invalid_align_size(tmpdir, sanlock_daemon):
path = str(tmpdir.join("path"))
util.create_file(path, 1024**3)
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
Show replies by date