mirror of
https://github.com/samba-team/samba.git
synced 2025-09-11 09:44:19 +03:00
ctdb-locking: Instead of comparing key, compare key hash
This replaces memory comparison of the key with integer comparison. In addition, this also avoids scheduling locks with the same hash. Signed-off-by: Amitay Isaacs <amitay@gmail.com> Reviewed-by: Martin Schwenke <martin@meltin.net> Autobuild-User(master): Martin Schwenke <martins@samba.org> Autobuild-Date(master): Fri Mar 28 05:28:58 CET 2014 on sn-devel-104
This commit is contained in:
committed by
Martin Schwenke
parent
d1c8f8d635
commit
f99a759ce7
@@ -79,6 +79,7 @@ struct lock_context {
|
|||||||
pid_t block_child;
|
pid_t block_child;
|
||||||
int block_fd[2];
|
int block_fd[2];
|
||||||
struct timeval start_time;
|
struct timeval start_time;
|
||||||
|
uint32_t key_hash;
|
||||||
};
|
};
|
||||||
|
|
||||||
/* lock_request is the client specific part for a lock request */
|
/* lock_request is the client specific part for a lock request */
|
||||||
@@ -672,7 +673,8 @@ static struct lock_context *find_lock_context(struct lock_context *lock_list,
|
|||||||
struct ctdb_db_context *ctdb_db,
|
struct ctdb_db_context *ctdb_db,
|
||||||
TDB_DATA key,
|
TDB_DATA key,
|
||||||
uint32_t priority,
|
uint32_t priority,
|
||||||
enum lock_type type)
|
enum lock_type type,
|
||||||
|
uint32_t key_hash)
|
||||||
{
|
{
|
||||||
struct lock_context *lock_ctx;
|
struct lock_context *lock_ctx;
|
||||||
|
|
||||||
@@ -685,8 +687,7 @@ static struct lock_context *find_lock_context(struct lock_context *lock_list,
|
|||||||
switch (lock_ctx->type) {
|
switch (lock_ctx->type) {
|
||||||
case LOCK_RECORD:
|
case LOCK_RECORD:
|
||||||
if (ctdb_db == lock_ctx->ctdb_db &&
|
if (ctdb_db == lock_ctx->ctdb_db &&
|
||||||
key.dsize == lock_ctx->key.dsize &&
|
key_hash == lock_ctx->key_hash) {
|
||||||
memcmp(key.dptr, lock_ctx->key.dptr, key.dsize) == 0) {
|
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -763,7 +764,7 @@ static void ctdb_lock_schedule(struct ctdb_context *ctdb)
|
|||||||
} else {
|
} else {
|
||||||
active_ctx = find_lock_context(ctdb->lock_current, lock_ctx->ctdb_db,
|
active_ctx = find_lock_context(ctdb->lock_current, lock_ctx->ctdb_db,
|
||||||
lock_ctx->key, lock_ctx->priority,
|
lock_ctx->key, lock_ctx->priority,
|
||||||
lock_ctx->type);
|
lock_ctx->type, lock_ctx->key_hash);
|
||||||
if (active_ctx == NULL) {
|
if (active_ctx == NULL) {
|
||||||
if (lock_ctx->ctdb_db == NULL ||
|
if (lock_ctx->ctdb_db == NULL ||
|
||||||
lock_ctx->ctdb_db->lock_num_current < MAX_LOCK_PROCESSES_PER_DB) {
|
lock_ctx->ctdb_db->lock_num_current < MAX_LOCK_PROCESSES_PER_DB) {
|
||||||
@@ -932,6 +933,7 @@ static struct lock_request *ctdb_lock_internal(struct ctdb_context *ctdb,
|
|||||||
talloc_free(lock_ctx);
|
talloc_free(lock_ctx);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
lock_ctx->key_hash = ctdb_hash(&key);
|
||||||
} else {
|
} else {
|
||||||
lock_ctx->key.dptr = NULL;
|
lock_ctx->key.dptr = NULL;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user