[dm-devel] [PATCH 4/6] fix change reservtion key to uint8 for memcmp
lixiaokeng
lixiaokeng at huawei.com
Mon Oct 26 09:26:44 UTC 2020
The mpp->reservation_key is uint64_t and the paramp->key
is uint8_t. For example, paramp->key is 0x7d0 and the
mpp->reservation_key is 0x00000000000007d0. When memcmp
is called, it will not return 0. We change reservtion_key
to uint8 to fix that.
Signed-off-by: Jianbing Jiao <jiaojianbing at huawei.com>
Signed-off-by: Lixiaokeng <lixiaokeng at huawei.com>
---
libmpathpersist/mpath_persist.c | 13 +++++++++++--
1 file changed, 11 insertions(+), 2 deletions(-)
diff --git a/libmpathpersist/mpath_persist.c b/libmpathpersist/mpath_persist.c
index 1f9817ed..02d173dc 100644
--- a/libmpathpersist/mpath_persist.c
+++ b/libmpathpersist/mpath_persist.c
@@ -249,6 +249,9 @@ int __mpath_persistent_reserve_out ( int fd, int rq_servact, int rq_scope,
int ret;
uint64_t prkey;
struct config *conf;
+ uint8_t uitmp[8] = {0};
+ uint64_t uireservation = {0};
+ int j;
ret = mpath_get_map(fd, &alias, &mpp);
if (ret != MPATH_PR_SUCCESS)
@@ -274,8 +277,14 @@ int __mpath_persistent_reserve_out ( int fd, int rq_servact, int rq_scope,
}
}
- if (memcmp(paramp->key, &mpp->reservation_key, 8) &&
- memcmp(paramp->sa_key, &mpp->reservation_key, 8)) {
+ uireservation = get_be64(mpp->reservation_key);
+ for (j = 7; j >= 0; --j) {
+ uitmp[j] = (uireservation & 0xff);
+ uireservation >>= 8;
+ }
+
+ if (memcmp(paramp->key, uitmp, 8) &&
+ memcmp(paramp->sa_key, uitmp, 8)) {
condlog(0, "%s: configured reservation key doesn't match: 0x%" PRIx64, alias, get_be64(mpp->reservation_key));
ret = MPATH_PR_SYNTAX_ERROR;
goto out1;
--
More information about the dm-devel
mailing list