master - clvmd: Fix freeze if client dies holding locks.
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=be662439331abf6ccb16dd996bfe15eb613b4e53 Commit: be662439331abf6ccb16dd996bfe15eb613b4e53 Parent: 57534733b7750f17f5ffa115306dcb650d8015b9 Author: Alasdair G Kergon <[email protected]> AuthorDate: Thu Jul 23 23:10:16 2015 +0100 Committer: Alasdair G Kergon <[email protected]> CommitterDate: Thu Jul 23 23:10:16 2015 +0100
clvmd: Fix freeze if client dies holding locks.
Simply running concurrent copies of 'pvscan | true' is enough to make clvmd freeze: pvscan exits on the EPIPE without first releasing the global lock.
clvmd notices the client disappear but because the cleanup code that releases the locks is triggered from within some processing after the next select() returns, and that processing can 'break' after doing just one action, it sometimes never releases the locks to other clients.
Move the cleanup code before the select.
Check all fds after select().
Improve some debug messages and warn in the unlikely event that select() capacity could soon be exceeded.
--- WHATS_NEW | 1 + daemons/clvmd/clvmd-command.c | 4 +- daemons/clvmd/clvmd.c | 67 +++++++++++++++++++++++++++-------------- 3 files changed, 47 insertions(+), 25 deletions(-)
WHATS_NEW +1 -0
@@ -1,5 +1,6 @@ Version 2.02.126 - ================================ + Fix clvmd freeze if client disappears without first releasing its locks. Fix lvconvert segfaults while performing snapshots merge. Ignore errors during detection if use_blkid_wiping=1 and --force is used. Recognise DM_ABORT_ON_INTERNAL_ERRORS env var override in lvm logging fn.
daemons/clvmd/clvmd-command.c +2 -2
@@ -323,6 +323,7 @@ void cmd_client_cleanup(struct local_client *client)int lkid;char *lockname; +DEBUGLOG ("Client thread cleanup (%p)\n" , client);if (!client->bits.localsock.private)return ;
@@ -331,7 +332,7 @@ void cmd_client_cleanup(struct local_client *client) dm_hash_iterate(v, lock_hash) { lkid = (int )(long )dm_hash_get_data (lock_hash, v); lockname =dm_hash_get_key (lock_hash, v); -DEBUGLOG ("cleanup: Unlocking lock %s %x\n" , lockname, lkid); +DEBUGLOG ("Cleanup (%p): Unlocking lock %s %x\n" , client, lockname, lkid); (void )sync_unlock (lockname, lkid); }
@@ -339,7 +340,6 @@ void cmd_client_cleanup(struct local_client *client) client->bits.localsock.private =NULL ; } -static int restart_clvmd (void ) {const char **argv;
daemons/clvmd/clvmd.c +44 -23
158 lines not on this page · raw message
daemons/clvmd/clvmd.c static void main_loop(int cmd_timeout) · line 873
Quoted 4 lines · Alasdair Kergon
daemons/clvmd/clvmd.c +4
-0+if (max_fd >FD_SETSIZE -32 ) { +fprintf (stderr,"WARNING: There are too many connections to clvmd. Investigate and take action now!\n" ); +fprintf (stderr,"WARNING: Your cluster may freeze up if the number of clvmd file descriptors (%d) exceeds %d.\n" , max_fd +1 ,FD_SETSIZE ); + }
Just an outsider question: why do you use stderr here instead of some generic logging function? If clvmd is run as a daemon, stderr is /dev/null, thus these messages are lost.
Signature · 2 lines
Thanks, Feri.
Quoted 3 lines · Ferenc Wagner
Just an outsider question: why do you use stderr here instead of some generic logging function? If clvmd is run as a daemon, stderr is
/dev/null, thus these messages are lost.
Because I used a quick cut-and-paste. Yes, syslog would be better...
Alasdair