master - clvmd: drop reply_mutex
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=7075656034858e8f825635c8e8a6a0e5122924ae Commit: 7075656034858e8f825635c8e8a6a0e5122924ae Parent: 6115c0d112a181012775af4528e5757ec39072ad Author: Zdenek Kabelac <[email protected]> AuthorDate: Wed Apr 9 08:12:13 2014 +0200 Committer: Zdenek Kabelac <[email protected]> CommitterDate: Mon Apr 14 12:59:07 2014 +0200
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.
--- WHATS_NEW | 1 + daemons/clvmd/clvmd.c | 12 ++++-------- daemons/clvmd/clvmd.h | 2 -- 3 files changed, 5 insertions(+), 10 deletions(-)
WHATS_NEW +1 -0
@@ -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.
daemons/clvmd/clvmd.c +4 -8
@@ -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);
daemons/clvmd/clvmd.h +0 -2
@@ -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 */