From 4a96b629a69d06abe73490f03bf6d62cdda08cd6 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Wed, 26 Oct 2011 13:43:07 +0200 Subject: s3: Use serverids_exist in parse_share_modes This is the main reason for the preceding commits. We need to reduce the number of round-trips to ctdb when checking the locking record entries for existence. Using the plural version of process_exists gets the number of round-trips to ctdb for process_exists down to 1. --- source3/locking/locking.c | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) (limited to 'source3/locking') diff --git a/source3/locking/locking.c b/source3/locking/locking.c index 3177fc109f..1947b185e6 100644 --- a/source3/locking/locking.c +++ b/source3/locking/locking.c @@ -645,6 +645,8 @@ static bool parse_share_modes(const TDB_DATA dbuf, struct share_mode_lock *lck) struct locking_data data; int delete_tokens_size; int i; + struct server_id *pids; + bool *pid_exists; if (dbuf.dsize < sizeof(struct locking_data)) { smb_panic("parse_share_modes: buffer too short"); @@ -719,6 +721,24 @@ static bool parse_share_modes(const TDB_DATA dbuf, struct share_mode_lock *lck) * Ensure that each entry has a real process attached. */ + pids = talloc_array(talloc_tos(), struct server_id, + lck->num_share_modes); + if (pids == NULL) { + smb_panic("parse_share_modes: talloc_array failed"); + } + pid_exists = talloc_array(talloc_tos(), bool, lck->num_share_modes); + if (pid_exists == NULL) { + smb_panic("parse_share_modes: talloc_array failed"); + } + + for (i=0; inum_share_modes; i++) { + pids[i] = lck->share_modes[i].pid; + } + + if (!serverids_exist(pids, lck->num_share_modes, pid_exists)) { + smb_panic("parse_share_modes: serverids_exist failed"); + } + for (i = 0; i < lck->num_share_modes; i++) { struct share_mode_entry *entry_p = &lck->share_modes[i]; char *str = NULL; @@ -727,7 +747,7 @@ static bool parse_share_modes(const TDB_DATA dbuf, struct share_mode_lock *lck) } DEBUG(10,("parse_share_modes: %s\n", str ? str : "")); - if (!serverid_exists(&entry_p->pid)) { + if (!pid_exists[i]) { DEBUG(10,("parse_share_modes: deleted %s\n", str ? str : "")); entry_p->op_type = UNUSED_SHARE_MODE_ENTRY; @@ -735,6 +755,8 @@ static bool parse_share_modes(const TDB_DATA dbuf, struct share_mode_lock *lck) } TALLOC_FREE(str); } + TALLOC_FREE(pid_exists); + TALLOC_FREE(pids); return True; } -- cgit