master - cleanup: clvmd drop unused enum state
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=d896abc705d8ae...
Commit: d896abc705d8aedd1d74c6fc01985fc88e7e44ed
Parent: e2f194952a218562b198c47e78f7337572cfb29e
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Wed Apr 9 08:11:49 2014 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Mon Apr 14 13:02:27 2014 +0200
cleanup: clvmd drop unused enum state
---
daemons/clvmd/clvmd.h | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/daemons/clvmd/clvmd.h b/daemons/clvmd/clvmd.h
index 5ecf582..f11c033 100644
--- a/daemons/clvmd/clvmd.h
+++ b/daemons/clvmd/clvmd.h
@@ -56,7 +56,7 @@ struct localsock_bits {
int cleanup_needed; /* helper for cleanup_zombie */
struct local_client *pipe_client;
pthread_t threadid;
- enum { PRE_COMMAND, POST_COMMAND, QUIT } state;
+ enum { PRE_COMMAND, POST_COMMAND } state;
pthread_mutex_t mutex; /* Main thread and worker synchronisation */
pthread_cond_t cond;
};
10 years, 1 month
master - cleanup: clvmd reindent local_pipe_callback
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=e2f194952a2185...
Commit: e2f194952a218562b198c47e78f7337572cfb29e
Parent: eccc50d86199921e8f2e0cf349db96e517b2625d
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Thu Apr 10 22:10:37 2014 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Mon Apr 14 13:02:27 2014 +0200
cleanup: clvmd reindent local_pipe_callback
Move !node_up check in front and reindent
rest of the function to the left.
---
daemons/clvmd/clvmd.c | 31 ++++++++++++++++---------------
1 files changed, 16 insertions(+), 15 deletions(-)
diff --git a/daemons/clvmd/clvmd.c b/daemons/clvmd/clvmd.c
index b1fe396..3e92490 100644
--- a/daemons/clvmd/clvmd.c
+++ b/daemons/clvmd/clvmd.c
@@ -779,25 +779,26 @@ static int local_pipe_callback(struct local_client *thisfd, char *buf,
static void timedout_callback(struct local_client *client, const char *csid,
int node_up)
{
- if (node_up) {
- struct node_reply *reply;
- char nodename[max_cluster_member_name_len];
+ struct node_reply *reply;
+ char nodename[max_cluster_member_name_len];
- clops->name_from_csid(csid, nodename);
- DEBUGLOG("Checking for a reply from %s\n", nodename);
- pthread_mutex_lock(&client->bits.localsock.mutex);
+ if (!node_up)
+ return;
- reply = client->bits.localsock.replies;
- while (reply && strcmp(reply->node, nodename) != 0)
- reply = reply->next;
+ clops->name_from_csid(csid, nodename);
+ DEBUGLOG("Checking for a reply from %s\n", nodename);
+ pthread_mutex_lock(&client->bits.localsock.mutex);
- pthread_mutex_unlock(&client->bits.localsock.mutex);
+ reply = client->bits.localsock.replies;
+ while (reply && strcmp(reply->node, nodename) != 0)
+ reply = reply->next;
- if (!reply) {
- DEBUGLOG("Node %s timed-out\n", nodename);
- add_reply_to_list(client, ETIMEDOUT, csid,
- "Command timed out", 18);
- }
+ pthread_mutex_unlock(&client->bits.localsock.mutex);
+
+ if (!reply) {
+ DEBUGLOG("Node %s timed-out\n", nodename);
+ add_reply_to_list(client, ETIMEDOUT, csid,
+ "Command timed out", 18);
}
}
10 years, 1 month
master - clvmd: use thread-safe ctime_r when debugging
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=eccc50d8619992...
Commit: eccc50d86199921e8f2e0cf349db96e517b2625d
Parent: 639983b6b7ac3257fc305624f22325fd3f6f0261
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Wed Apr 9 07:51:36 2014 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Mon Apr 14 13:02:25 2014 +0200
clvmd: use thread-safe ctime_r when debugging
Use thread friendly version of ctime
TODO:should be probably replaced with strftime()
---
WHATS_NEW | 1 +
daemons/clvmd/clvmd.c | 3 ++-
2 files changed, 3 insertions(+), 1 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index efc296d..61723e5 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.107 -
==================================
+ Use thread-safe ctime_r() for clvmd debug logging.
Skip adding replies to already finished reply thread.
Use mutex to check number of replies in request_timed_out() in clvmd.
Drop usage of extra reply_mutex for localsock in clvmd.
diff --git a/daemons/clvmd/clvmd.c b/daemons/clvmd/clvmd.c
index ee6e301..b1fe396 100644
--- a/daemons/clvmd/clvmd.c
+++ b/daemons/clvmd/clvmd.c
@@ -212,12 +212,13 @@ void debuglog(const char *fmt, ...)
time_t P;
va_list ap;
static int syslog_init = 0;
+ char buf_ctime[64];
switch (clvmd_get_debug()) {
case DEBUG_STDERR:
va_start(ap,fmt);
time(&P);
- fprintf(stderr, "CLVMD[%x]: %.15s ", (int)pthread_self(), ctime(&P)+4 );
+ fprintf(stderr, "CLVMD[%x]: %.15s ", (int)pthread_self(), ctime_r(&P, buf_ctime) + 4);
vfprintf(stderr, fmt, ap);
va_end(ap);
break;
10 years, 1 month
master - clvmd: skip adding reply when finished
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=639983b6b7ac32...
Commit: 639983b6b7ac3257fc305624f22325fd3f6f0261
Parent: 7236b92857cb8a0207376d1349e42ba26172a519
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Mon Apr 14 12:40:23 2014 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Mon Apr 14 13:01:42 2014 +0200
clvmd: skip adding reply when finished
Prior adding new reply to the list, check
if the reply thread is not already finished.
In that case discard adding message
(which would otherwise be leaked).
---
WHATS_NEW | 1 +
daemons/clvmd/clvmd.c | 26 +++++++++++++++-----------
2 files changed, 16 insertions(+), 11 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index a90906e..efc296d 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.107 -
==================================
+ Skip adding replies to already finished reply thread.
Use mutex to check number of replies in request_timed_out() in clvmd.
Drop usage of extra reply_mutex for localsock in clvmd.
Protect manipulation with finished flag with mutex in clvmd.
diff --git a/daemons/clvmd/clvmd.c b/daemons/clvmd/clvmd.c
index ec24be9..ee6e301 100644
--- a/daemons/clvmd/clvmd.c
+++ b/daemons/clvmd/clvmd.c
@@ -1636,21 +1636,25 @@ static void add_reply_to_list(struct local_client *client, int status,
reply->replymsg = NULL;
pthread_mutex_lock(&client->bits.localsock.mutex);
- /* Hook it onto the reply chain */
- reply->next = client->bits.localsock.replies;
- client->bits.localsock.replies = reply;
- DEBUGLOG("Got %d replies, expecting: %d\n",
- client->bits.localsock.num_replies + 1,
- client->bits.localsock.expected_replies);
-
- /* If we have the whole lot then do the post-process */
- if (++client->bits.localsock.num_replies ==
- client->bits.localsock.expected_replies) {
+
+ if (client->bits.localsock.finished) {
+ dm_free(reply->replymsg);
+ dm_free(reply);
+ } else {
+ /* Hook it onto the reply chain */
+ reply->next = client->bits.localsock.replies;
+ client->bits.localsock.replies = reply;
+
+ /* If we have the whole lot then do the post-process */
/* Post-process the command */
- if (client->bits.localsock.threadid) {
+ if (++client->bits.localsock.num_replies ==
+ client->bits.localsock.expected_replies) {
client->bits.localsock.state = POST_COMMAND;
pthread_cond_signal(&client->bits.localsock.cond);
}
+ DEBUGLOG("Got %d replies, expecting: %d\n",
+ client->bits.localsock.num_replies,
+ client->bits.localsock.expected_replies);
}
pthread_mutex_unlock(&client->bits.localsock.mutex);
}
10 years, 1 month
master - clvmd: improve mutex usage in request_timed_out
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=7236b92857cb8a...
Commit: 7236b92857cb8a0207376d1349e42ba26172a519
Parent: 7075656034858e8f825635c8e8a6a0e5122924ae
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Mon Apr 14 11:39:24 2014 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Mon Apr 14 13:00:51 2014 +0200
clvmd: improve mutex usage in request_timed_out
Use mutex to access localsock values, so check
num_replies when the thread is not yet finished.
Check for threadid prior the mutex taking
(though this check is probably not really needed)
---
WHATS_NEW | 1 +
daemons/clvmd/clvmd.c | 20 ++++++++++++--------
2 files changed, 13 insertions(+), 8 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index 19ee0a7..a90906e 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.107 -
==================================
+ Use mutex to check number of replies in request_timed_out() in clvmd.
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.
diff --git a/daemons/clvmd/clvmd.c b/daemons/clvmd/clvmd.c
index b70543b..ec24be9 100644
--- a/daemons/clvmd/clvmd.c
+++ b/daemons/clvmd/clvmd.c
@@ -812,16 +812,20 @@ static void request_timed_out(struct local_client *client)
DEBUGLOG("Request timed-out. padding\n");
clops->cluster_do_node_callback(client, timedout_callback);
- if (client->bits.localsock.num_replies !=
- client->bits.localsock.expected_replies) {
+ if (!client->bits.localsock.threadid)
+ return;
+
+ pthread_mutex_lock(&client->bits.localsock.mutex);
+
+ if (!client->bits.localsock.finished &&
+ (client->bits.localsock.num_replies !=
+ 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);
- }
+ client->bits.localsock.state = POST_COMMAND;
+ pthread_cond_signal(&client->bits.localsock.cond);
}
+
+ pthread_mutex_unlock(&client->bits.localsock.mutex);
}
/* This is where the real work happens */
10 years, 1 month
master - clvmd: drop reply_mutex
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=7075656034858e...
Commit: 7075656034858e8f825635c8e8a6a0e5122924ae
Parent: 6115c0d112a181012775af4528e5757ec39072ad
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Wed Apr 9 08:12:13 2014 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
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(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index ee6fccd..19ee0a7 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -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 6c186e8..b70543b 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 0f837dd..5ecf582 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 */
10 years, 1 month
master - clvmd: set finished flag with mutex
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=6115c0d112a181...
Commit: 6115c0d112a181012775af4528e5757ec39072ad
Parent: cc0096ebdd1168ebb0d482e88952bdc14caffd96
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Wed Apr 9 10:36:25 2014 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Mon Apr 14 12:58:28 2014 +0200
clvmd: set finished flag with mutex
Setting this variable needs to be protected with mutex.
---
WHATS_NEW | 1 +
daemons/clvmd/clvmd.c | 4 ++--
2 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index 16e39dc..ee6fccd 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.107 -
==================================
+ 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.
Skip more libraries to be mlocked in memory.
diff --git a/daemons/clvmd/clvmd.c b/daemons/clvmd/clvmd.c
index 93c2224..6c186e8 100644
--- a/daemons/clvmd/clvmd.c
+++ b/daemons/clvmd/clvmd.c
@@ -1149,8 +1149,6 @@ static int cleanup_zombie(struct local_client *thisfd)
DEBUGLOG("EOF on local socket: inprogress=%d\n",
thisfd->bits.localsock.in_progress);
- thisfd->bits.localsock.finished = 1;
-
if ((pipe_client = thisfd->bits.localsock.pipe_client))
pipe_client = pipe_client->bits.pipe.client;
@@ -1161,6 +1159,7 @@ static int cleanup_zombie(struct local_client *thisfd)
if (pthread_mutex_trylock(&thisfd->bits.localsock.mutex))
return 1;
thisfd->bits.localsock.state = POST_COMMAND;
+ thisfd->bits.localsock.finished = 1;
pthread_cond_signal(&thisfd->bits.localsock.cond);
pthread_mutex_unlock(&thisfd->bits.localsock.mutex);
@@ -1173,6 +1172,7 @@ static int cleanup_zombie(struct local_client *thisfd)
DEBUGLOG("Waiting for pre&post thread (%p)\n", pipe_client);
pthread_mutex_lock(&thisfd->bits.localsock.mutex);
thisfd->bits.localsock.state = PRE_COMMAND;
+ thisfd->bits.localsock.finished = 1;
pthread_cond_signal(&thisfd->bits.localsock.cond);
pthread_mutex_unlock(&thisfd->bits.localsock.mutex);
10 years, 1 month
master - clvmd: move mutex init and detroy
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=cc0096ebdd1168...
Commit: cc0096ebdd1168ebb0d482e88952bdc14caffd96
Parent: 91f4e09b48a2e9f909f3686c8d3a9dba274d1779
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Wed Apr 9 08:06:16 2014 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Mon Apr 14 12:57:39 2014 +0200
clvmd: move mutex init and detroy
Move the pthread mutex and condition creation and destroy
to correct place right after client memory is allocatedd
or is going to be released.
In the original place it's been in race with lvm thread
which could have still unlock mutex while it's been already
destroyed.
---
WHATS_NEW | 1 +
daemons/clvmd/clvmd.c | 19 +++++++------------
2 files changed, 8 insertions(+), 12 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index 9c42344..16e39dc 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.107 -
==================================
+ Shift mutex creation and destroy for localsock in clvmd to correct place.
Fix usage of --test option in clvmd.
Skip more libraries to be mlocked in memory.
Remove LOCKED flag for pvmove replaced with error target.
diff --git a/daemons/clvmd/clvmd.c b/daemons/clvmd/clvmd.c
index 0ad0c3a..93c2224 100644
--- a/daemons/clvmd/clvmd.c
+++ b/daemons/clvmd/clvmd.c
@@ -685,6 +685,10 @@ static int local_rendezvous_callback(struct local_client *thisfd, char *buf,
return 1;
}
+ 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));
@@ -1179,8 +1183,6 @@ static int cleanup_zombie(struct local_client *thisfd)
DEBUGLOG("Joined pre&post thread\n");
thisfd->bits.localsock.threadid = 0;
- pthread_cond_destroy(&thisfd->bits.localsock.cond);
- pthread_mutex_destroy(&thisfd->bits.localsock.mutex);
/* Remove the pipe client */
if (thisfd->bits.localsock.pipe_client) {
@@ -1321,16 +1323,6 @@ static int read_from_local_sock(struct local_client *thisfd)
}
}
- /*
- * Initialise and lock the mutex so the subthread will wait
- * after finishing the PRE routine
- */
- if (!thisfd->bits.localsock.threadid) {
- pthread_mutex_init(&thisfd->bits.localsock.mutex, NULL);
- pthread_cond_init(&thisfd->bits.localsock.cond, NULL);
- pthread_mutex_init(&thisfd->bits.localsock.reply_mutex, NULL);
- }
-
/* Only run the command if all the cluster nodes are running CLVMD */
if (((inheader->flags & CLVMD_FLAG_LOCAL) == 0) &&
(check_all_clvmds_running(thisfd) == -1)) {
@@ -1975,6 +1967,9 @@ 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);
return 0;
}
10 years, 1 month
master - clvmd: fix test mode race
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=91f4e09b48a2e9...
Commit: 91f4e09b48a2e9f909f3686c8d3a9dba274d1779
Parent: bd3e44643de16ba0171af05413626a55a0a51b42
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Wed Apr 9 07:58:40 2014 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Mon Apr 14 12:55:46 2014 +0200
clvmd: fix test mode race
When TEST_MODE flag is passed around the cluster,
it's been use in thread unprotected way, so it may have
influenced behaviour of other running parallel lvm commands
(activation/deactivation/suspend/resume).
Fix it by set/query function only under lvm mutex.
For hold_un/lock function calls check lock_flags bits directly.
---
WHATS_NEW | 1 +
daemons/clvmd/clvmd-command.c | 13 -------------
daemons/clvmd/clvmd.c | 1 -
daemons/clvmd/lvm-functions.c | 32 ++++++++++++++++++--------------
4 files changed, 19 insertions(+), 28 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index 4a35b7e..9c42344 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.107 -
==================================
+ Fix usage of --test option in clvmd.
Skip more libraries to be mlocked in memory.
Remove LOCKED flag for pvmove replaced with error target.
Return invalid command when specifying negative polling interval.
diff --git a/daemons/clvmd/clvmd-command.c b/daemons/clvmd/clvmd-command.c
index 611f6bf..9e59e51 100644
--- a/daemons/clvmd/clvmd-command.c
+++ b/daemons/clvmd/clvmd-command.c
@@ -78,9 +78,6 @@ int do_command(struct local_client *client, struct clvm_header *msg, int msglen,
unsigned char lock_cmd;
unsigned char lock_flags;
- /* Reset test mode before we start */
- init_test(0);
-
/* Do the command */
switch (msg->cmd) {
/* Just a test message */
@@ -112,8 +109,6 @@ int do_command(struct local_client *client, struct clvm_header *msg, int msglen,
lockname = &args[2];
/* Check to see if the VG is in use by LVM1 */
status = do_check_lvm1(lockname);
- if (lock_flags & LCK_TEST_MODE)
- init_test(1);
do_lock_vg(lock_cmd, lock_flags, lockname);
break;
@@ -122,8 +117,6 @@ int do_command(struct local_client *client, struct clvm_header *msg, int msglen,
lock_cmd = args[0];
lock_flags = args[1];
lockname = &args[2];
- if (lock_flags & LCK_TEST_MODE)
- init_test(1);
status = do_lock_lv(lock_cmd, lock_flags, lockname);
/* Replace EIO with something less scary */
if (status == EIO) {
@@ -252,7 +245,6 @@ int do_pre_command(struct local_client *client)
int status = 0;
char *lockname;
- init_test(0);
switch (header->cmd) {
case CLVMD_CMD_TEST:
status = sync_lock("CLVMD_TEST", LCK_EXCL, 0, &lockid);
@@ -271,8 +263,6 @@ int do_pre_command(struct local_client *client)
lock_cmd = args[0];
lock_flags = args[1];
lockname = &args[2];
- if (lock_flags & LCK_TEST_MODE)
- init_test(1);
status = pre_lock_lv(lock_cmd, lock_flags, lockname);
break;
@@ -304,7 +294,6 @@ int do_post_command(struct local_client *client)
char *args = header->node + strlen(header->node) + 1;
char *lockname;
- init_test(0);
switch (header->cmd) {
case CLVMD_CMD_TEST:
status = sync_unlock("CLVMD_TEST", (int) (long) client->bits.localsock.private);
@@ -315,8 +304,6 @@ int do_post_command(struct local_client *client)
lock_cmd = args[0];
lock_flags = args[1];
lockname = &args[2];
- if (lock_flags & LCK_TEST_MODE)
- init_test(1);
status = post_lock_lv(lock_cmd, lock_flags, lockname);
break;
diff --git a/daemons/clvmd/clvmd.c b/daemons/clvmd/clvmd.c
index bc98ccb..0ad0c3a 100644
--- a/daemons/clvmd/clvmd.c
+++ b/daemons/clvmd/clvmd.c
@@ -1762,7 +1762,6 @@ static int process_local_command(struct clvm_header *msg, int msglen,
if (msg->flags & CLVMD_FLAG_REMOTE)
status = 0;
else
- /* FIXME: usage of init_test() is unprotected */
status = do_command(client, msg, msglen, &replybuf, buflen, &replylen);
if (status)
diff --git a/daemons/clvmd/lvm-functions.c b/daemons/clvmd/lvm-functions.c
index f4fb7fd..2ecf7d7 100644
--- a/daemons/clvmd/lvm-functions.c
+++ b/daemons/clvmd/lvm-functions.c
@@ -251,9 +251,6 @@ static int hold_lock(char *resource, int mode, int flags)
int saved_errno;
struct lv_info *lvi;
- if (test_mode())
- return 0;
-
/* Mask off invalid options */
flags &= LCKF_NOQUEUE | LCKF_CONVERT;
@@ -319,9 +316,6 @@ static int hold_unlock(char *resource)
int status;
int saved_errno;
- if (test_mode())
- return 0;
-
if (!(lvi = lookup_info(resource))) {
DEBUGLOG("hold_unlock, lock not already held\n");
return 0;
@@ -381,7 +375,7 @@ static int do_activate_lv(char *resource, unsigned char command, unsigned char l
* Use lock conversion only if requested, to prevent implicit conversion
* of exclusive lock to shared one during activation.
*/
- if (command & LCK_CLUSTER_VG) {
+ if (!test_mode() && command & LCK_CLUSTER_VG) {
status = hold_lock(resource, mode, LCKF_NOQUEUE | (lock_flags & LCK_CONVERT ? LCKF_CONVERT:0));
if (status) {
/* Return an LVM-sensible error for this.
@@ -415,7 +409,7 @@ static int do_activate_lv(char *resource, unsigned char command, unsigned char l
return 0;
error:
- if (oldmode == -1 || oldmode != mode)
+ if (!test_mode() && (oldmode == -1 || oldmode != mode))
(void)hold_unlock(resource);
return EIO;
}
@@ -479,7 +473,7 @@ static int do_deactivate_lv(char *resource, unsigned char command, unsigned char
if (!lv_deactivate(cmd, resource, NULL))
return EIO;
- if (command & LCK_CLUSTER_VG) {
+ if (!test_mode() && command & LCK_CLUSTER_VG) {
status = hold_unlock(resource);
if (status)
return errno;
@@ -526,6 +520,8 @@ int do_lock_lv(unsigned char command, unsigned char lock_flags, char *resource)
}
pthread_mutex_lock(&lvm_lock);
+ init_test((lock_flags & LCK_TEST_MODE) ? 1 : 0);
+
if (lock_flags & LCK_MIRROR_NOSYNC_MODE)
init_mirror_in_sync(1);
@@ -578,6 +574,7 @@ int do_lock_lv(unsigned char command, unsigned char lock_flags, char *resource)
/* clean the pool for another command */
dm_pool_empty(cmd->mem);
+ init_test(0);
pthread_mutex_unlock(&lvm_lock);
DEBUGLOG("Command return is %d, critical_section is %d\n", status, critical_section());
@@ -597,7 +594,8 @@ int pre_lock_lv(unsigned char command, unsigned char lock_flags, char *resource)
DEBUGLOG("pre_lock_lv: resource '%s', cmd = %s, flags = %s\n",
resource, decode_locking_cmd(command), decode_flags(lock_flags));
- if (hold_lock(resource, LCK_WRITE, LCKF_NOQUEUE | LCKF_CONVERT))
+ if (!(lock_flags & LCK_TEST_MODE) &&
+ hold_lock(resource, LCK_WRITE, LCKF_NOQUEUE | LCKF_CONVERT))
return errno;
}
return 0;
@@ -629,11 +627,13 @@ int post_lock_lv(unsigned char command, unsigned char lock_flags,
if (!status)
return EIO;
- if (lvi.exists) {
- if (hold_lock(resource, LCK_READ, LCKF_CONVERT))
+ if (!(lock_flags & LCK_TEST_MODE)) {
+ if (lvi.exists) {
+ if (hold_lock(resource, LCK_READ, LCKF_CONVERT))
+ return errno;
+ } else if (hold_unlock(resource))
return errno;
- } else if (hold_unlock(resource))
- return errno;
+ }
}
}
return 0;
@@ -697,6 +697,8 @@ void do_lock_vg(unsigned char command, unsigned char lock_flags, char *resource)
}
pthread_mutex_lock(&lvm_lock);
+ init_test((lock_flags & LCK_TEST_MODE) ? 1 : 0);
+
switch (lock_cmd) {
case LCK_VG_COMMIT:
DEBUGLOG("vg_commit notification for VG %s\n", vgname);
@@ -711,6 +713,8 @@ void do_lock_vg(unsigned char command, unsigned char lock_flags, char *resource)
DEBUGLOG("Invalidating cached metadata for VG %s\n", vgname);
lvmcache_drop_metadata(vgname, 0);
}
+
+ init_test(0);
pthread_mutex_unlock(&lvm_lock);
}
10 years, 1 month
master - memlock: ignore more libraries
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=bd3e44643de16b...
Commit: bd3e44643de16ba0171af05413626a55a0a51b42
Parent: 84ff3ae703ec7d2859398f01eee726134c543723
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Thu Apr 10 10:52:44 2014 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Mon Apr 14 12:53:07 2014 +0200
memlock: ignore more libraries
Extend the list of ignored libraries. Since we do not
use those libraries during suspend, skip their locking.
---
WHATS_NEW | 1 +
lib/mm/memlock.c | 8 +++++++-
2 files changed, 8 insertions(+), 1 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index e7e74ed..4a35b7e 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.107 -
==================================
+ Skip more libraries to be mlocked in memory.
Remove LOCKED flag for pvmove replaced with error target.
Return invalid command when specifying negative polling interval.
diff --git a/lib/mm/memlock.c b/lib/mm/memlock.c
index e626a6a..153ae17 100644
--- a/lib/mm/memlock.c
+++ b/lib/mm/memlock.c
@@ -92,9 +92,15 @@ static const char * const _blacklist_maps[] = {
"locale/locale-archive",
"/LC_MESSAGES/",
"gconv/gconv-modules.cache",
- "/libreadline.so.", /* not using readline during mlock */
+ "/libblkid.so.", /* not using lzma during mlock (selinux) */
+ "/liblzma.so.", /* not using lzma during mlock (selinux) */
"/libncurses.so.", /* not using ncurses during mlock */
+ "/libpcre.so.", /* not using pcre during mlock (selinux) */
+ "/libreadline.so.", /* not using readline during mlock */
+ "/libselinux.so.", /* not using selinux during mlock */
+ "/libsepol.so.", /* not using sepol during mlock */
"/libtinfo.so.", /* not using tinfo during mlock */
+ "/libuuid.so.", /* not using uuid during mlock (blkid) */
"/libdl-", /* not using dlopen,dlsym during mlock */
/* "/libdevmapper-event.so" */
};
10 years, 1 month