unreleased lock after handler failure
RFC 1/1 unreleased lock after handler failure
Hi, folks
While we are testing with the latest multipathd, we encounter issue that once 'del map' failed, all the following operation will show 'error -1 receiving packet' whatever how long the timeout has been set (we have applied the latest fix which make sure the poll will last for 10 seconds).
After some debugging we found that inside parse_cmd(), the pthread_cleanup_pop() rely on '!r' as indicator for locked or not, while this will be overwritten if the handler return failed (1 in our case), and then the unlock will be missed.
After applied below fix the problem got solved, although the del map failed, the other operation can still works.
Could you please help to review whether this is really the problem to be fixed like that?
Regards,
Michael Wang
multipathd/cli.c +3 -1
@@ -481,6 +481,7 @@ parse_cmd (char * cmd, char ** reply, int * len, void * data, int timeout ) tmo.tv_sec =0 ; }if (h->locked) { +int locked =0 ;struct vectors * vecs = (struct vectors *)data;pthread_cleanup_push (cleanup_lock, &vecs->lock);
@@ -491,10 +492,11 @@ parse_cmd (char * cmd, char ** reply, int * len, void * data, int timeout ) r =0 ; }if (r ==0 ) { + locked =1 ;pthread_testcancel (); r = h->fn (cmdvec, reply, len, data); } -pthread_cleanup_pop (!r); +pthread_cleanup_pop (locked); }else r = h->fn (cmdvec, reply, len, data);free_keys (cmdvec);
Hi, Michael Wang
This patch looks well for me, cleanup_lock() should be called without affected by the return value of h->fn().
Regards,
Tang
发件人: Michael Wang <[email protected]>
收件人: [email protected], [email protected],
日期: 2016/10/12 16:11
主题: [dm-devel] [RFC] unreleased lock after handler failure
发件人: [email protected]
Hi, folks
While we are testing with the latest multipathd, we encounter issue that once
'del map' failed, all the following operation will show 'error -1 receiving packet'
whatever how long the timeout has been set (we have applied the latest fix which
make sure the poll will last for 10 seconds).
After some debugging we found that inside parse_cmd(), the pthread_cleanup_pop()
rely on '!r' as indicator for locked or not, while this will be overwritten if
the handler return failed (1 in our case), and then the unlock will be missed.
After applied below fix the problem got solved, although the del map failed, the
other operation can still works.
Could you please help to review whether this is really the problem to be fixed
like that?
Regards,
Michael Wang
multipathd/cli.c +0 -0
@@ -481,6 +481,7 @@ parse_cmd (char * cmd, char ** reply, int * len, void
* data, int timeout )
tmo.tv_sec = 0;
}
if (h->locked) {
+ int locked = 0;
struct vectors * vecs = (struct vectors *)data;
pthread_cleanup_push(cleanup_lock, &vecs->lock);
@@ -491,10 +492,11 @@ parse_cmd (char * cmd, char ** reply, int * len,
void * data, int timeout )
r = 0;
}
if (r == 0) {
+ locked = 1;
pthread_testcancel();
r = h->fn(cmdvec, reply, len, data);
}
- pthread_cleanup_pop(!r);
+ pthread_cleanup_pop(locked);
} else
r = h->fn(cmdvec, reply, len, data);
free_keys(cmdvec);--
dm-devel mailing list
[email protected]
https://www.redhat.com/mailman/listinfo/dm-devel
Hi, Tang
Quoted 4 lines · On 10/12/2016 10:33 AM, [email protected] wrote:
Hi, Michael Wang
This patch looks well for me,
cleanup_lock()should be called without affectedby the return value ofh->fn().
Thanks for the quick respond, I'll submit a formal patch then :-)
Regards,
Michael Wang
Quoted 64 lines
Regards,
Tang发件人: Michael Wang <[email protected]>
收件人: [email protected], [email protected],
日期: 2016/10/12 16:11
主题: [dm-devel] [RFC] unreleased lock after handler failure
发件人: [email protected]
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------Hi, folks
While we are testing with the latest multipathd, we encounter issue that once 'del map' failed, all the following operation will show 'error -1 receiving packet' whatever how long the timeout has been set (we have applied the latest fix which make sure the poll will last for 10 seconds).
After some debugging we found that inside
parse_cmd(), thepthread_cleanup_pop()rely on '!r' as indicator for locked or not, while this will be overwritten if the handler return failed (1 in our case), and then the unlock will be missed.After applied below fix the problem got solved, although the del map failed, the other operation can still works.
Could you please help to review whether this is really the problem to be fixed like that?
Regards,
Michael Wangmultipathd/cli.c +3
-2@@ -481,6 +481,7 @@ parse_cmd (char * cmd, char ** reply, int * len, void * data, int timeout ) tmo.tv_sec =0 ; }if (h->locked) { +int locked =0 ;struct vectors * vecs = (struct vectors *)data;pthread_cleanup_push (cleanup_lock, &vecs->lock);@@ -491,10 +492,11 @@ parse_cmd (char * cmd, char ** reply, int * len, void * data, int timeout ) r =0 ; }if (r ==0 ) { + locked =1 ;pthread_testcancel (); r = h->fn (cmdvec, reply, len, data); } -pthread_cleanup_pop (!r); +pthread_cleanup_pop (locked); }else r = h->fn (cmdvec, reply, len, data);free_keys (cmdvec); --
Quoted 4 lines
dm-devel mailing list
[email protected]
https://www.redhat.com/mailman/listinfo/dm-devel
--
dm-devel mailing list
[email protected]
https://www.redhat.com/mailman/listinfo/dm-devel