Commit f97c650d authored by Jeff Layton's avatar Jeff Layton Committed by J. Bruce Fields

NLM: don't let lockd exit on unexpected svc_recv errors (try #2)

When svc_recv returns an unexpected error, lockd will print a warning
and exit. This problematic for several reasons. In particular, it will
cause the reference counts for the thread to be wrong, and can lead to a
potential BUG() call.

Rather than exiting on error from svc_recv, have the thread do a 1s
sleep and then retry the loop. This is unlikely to cause any harm, and
if the error turns out to be something temporary then it may be able to
recover.
Signed-off-by: default avatarJeff Layton <jlayton@redhat.com>
Signed-off-by: default avatarJ. Bruce Fields <bfields@citi.umich.edu>
parent 06e02d66
...@@ -112,7 +112,7 @@ static inline void clear_grace_period(void) ...@@ -112,7 +112,7 @@ static inline void clear_grace_period(void)
static int static int
lockd(void *vrqstp) lockd(void *vrqstp)
{ {
int err = 0; int err = 0, preverr = 0;
struct svc_rqst *rqstp = vrqstp; struct svc_rqst *rqstp = vrqstp;
unsigned long grace_period_expire; unsigned long grace_period_expire;
...@@ -172,14 +172,20 @@ lockd(void *vrqstp) ...@@ -172,14 +172,20 @@ lockd(void *vrqstp)
* recvfrom routine. * recvfrom routine.
*/ */
err = svc_recv(rqstp, timeout); err = svc_recv(rqstp, timeout);
if (err == -EAGAIN || err == -EINTR) if (err == -EAGAIN || err == -EINTR) {
preverr = err;
continue; continue;
}
if (err < 0) { if (err < 0) {
printk(KERN_WARNING if (err != preverr) {
"lockd: terminating on error %d\n", printk(KERN_WARNING "%s: unexpected error "
-err); "from svc_recv (%d)\n", __func__, err);
break; preverr = err;
}
schedule_timeout_interruptible(HZ);
continue;
} }
preverr = err;
dprintk("lockd: request from %s\n", dprintk("lockd: request from %s\n",
svc_print_addr(rqstp, buf, sizeof(buf))); svc_print_addr(rqstp, buf, sizeof(buf)));
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment