diff options
author | Zdenek Kabelac <zkabelac@redhat.com> | 2014-04-09 08:12:13 +0200 |
---|---|---|
committer | Zdenek Kabelac <zkabelac@redhat.com> | 2014-04-14 12:59:07 +0200 |
commit | 7075656034858e8f825635c8e8a6a0e5122924ae (patch) | |
tree | 3860c776c94912f71a5b474ee6d04536da623f21 | |
parent | 6115c0d112a181012775af4528e5757ec39072ad (diff) | |
download | lvm2-7075656034858e8f825635c8e8a6a0e5122924ae.tar.gz |
clvmd: drop reply_mutex
Added complexity with extra reply mutex is not worth the troubles.
The only place which may slightly benefit from this mutex is timeout
and since this is rather error case - let's convert it to
localsock.mutex and keep it simple.
-rw-r--r-- | WHATS_NEW | 1 | ||||
-rw-r--r-- | daemons/clvmd/clvmd.c | 12 | ||||
-rw-r--r-- | daemons/clvmd/clvmd.h | 2 |
3 files changed, 5 insertions, 10 deletions
@@ -1,5 +1,6 @@ Version 2.02.107 - ================================== + Drop usage of extra reply_mutex for localsock in clvmd. Protect manipulation with finished flag with mutex in clvmd. Shift mutex creation and destroy for localsock in clvmd to correct place. Fix usage of --test option in clvmd. diff --git a/daemons/clvmd/clvmd.c b/daemons/clvmd/clvmd.c index 6c186e82f..b70543b14 100644 --- a/daemons/clvmd/clvmd.c +++ b/daemons/clvmd/clvmd.c @@ -687,7 +687,6 @@ static int local_rendezvous_callback(struct local_client *thisfd, char *buf, pthread_cond_init(&newfd->bits.localsock.cond, NULL); pthread_mutex_init(&newfd->bits.localsock.mutex, NULL); - pthread_mutex_init(&newfd->bits.localsock.reply_mutex, NULL); if (fcntl(client_fd, F_SETFD, 1)) DEBUGLOG("Setting CLOEXEC on client fd failed: %s\n", strerror(errno)); @@ -785,13 +784,13 @@ static void timedout_callback(struct local_client *client, const char *csid, clops->name_from_csid(csid, nodename); DEBUGLOG("Checking for a reply from %s\n", nodename); - pthread_mutex_lock(&client->bits.localsock.reply_mutex); + pthread_mutex_lock(&client->bits.localsock.mutex); reply = client->bits.localsock.replies; while (reply && strcmp(reply->node, nodename) != 0) reply = reply->next; - pthread_mutex_unlock(&client->bits.localsock.reply_mutex); + pthread_mutex_unlock(&client->bits.localsock.mutex); if (!reply) { DEBUGLOG("Node %s timed-out\n", nodename); @@ -1632,7 +1631,7 @@ static void add_reply_to_list(struct local_client *client, int status, } else reply->replymsg = NULL; - pthread_mutex_lock(&client->bits.localsock.reply_mutex); + pthread_mutex_lock(&client->bits.localsock.mutex); /* Hook it onto the reply chain */ reply->next = client->bits.localsock.replies; client->bits.localsock.replies = reply; @@ -1645,13 +1644,11 @@ static void add_reply_to_list(struct local_client *client, int status, client->bits.localsock.expected_replies) { /* Post-process the command */ if (client->bits.localsock.threadid) { - pthread_mutex_lock(&client->bits.localsock.mutex); client->bits.localsock.state = POST_COMMAND; pthread_cond_signal(&client->bits.localsock.cond); - pthread_mutex_unlock(&client->bits.localsock.mutex); } } - pthread_mutex_unlock(&client->bits.localsock.reply_mutex); + pthread_mutex_unlock(&client->bits.localsock.mutex); } /* This is the thread that runs the PRE and post commands for a particular connection */ @@ -1967,7 +1964,6 @@ static int process_work_item(struct lvm_thread_cmd *cmd) if (cmd->msg == NULL) { DEBUGLOG("process_work_item: free fd %d\n", cmd->client->fd); cmd_client_cleanup(cmd->client); - pthread_mutex_destroy(&cmd->client->bits.localsock.reply_mutex); pthread_mutex_destroy(&cmd->client->bits.localsock.mutex); pthread_cond_destroy(&cmd->client->bits.localsock.cond); dm_free(cmd->client); diff --git a/daemons/clvmd/clvmd.h b/daemons/clvmd/clvmd.h index 0f837dd65..5ecf582f3 100644 --- a/daemons/clvmd/clvmd.h +++ b/daemons/clvmd/clvmd.h @@ -59,8 +59,6 @@ struct localsock_bits { enum { PRE_COMMAND, POST_COMMAND, QUIT } state; pthread_mutex_t mutex; /* Main thread and worker synchronisation */ pthread_cond_t cond; - - pthread_mutex_t reply_mutex; /* Protect reply structure */ }; /* Entries for PIPE clients */ |