Skip to content

Commit

Permalink
nfsd: fix error handling in __write_ports_addxprt
Browse files Browse the repository at this point in the history
__write_ports_addxprt calls nfsd_create_serv. That increases the
refcount of nfsd_serv (which is tracked in sv_nrthreads). The service
only decrements the thread count on error, not on success like
__write_ports_addfd does, so using this interface leaves the nfsd
thread count high.

Fix this by having this function call svc_destroy() on error to release
the reference (and possibly to tear down the service) and simply
decrement the refcount without tearing down the service on success.

This makes the sv_threads handling work basically the same in both
__write_ports_addxprt and __write_ports_addfd.

Signed-off-by: Jeff Layton <jlayton@redhat.com>
Signed-off-by: J. Bruce Fields <bfields@redhat.com>
  • Loading branch information
Jeff Layton authored and J. Bruce Fields committed Jul 23, 2010
1 parent 78a8d7c commit 0cd14a0
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions fs/nfsd/nfsctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -1018,6 +1018,9 @@ static ssize_t __write_ports_addxprt(char *buf)
PF_INET6, port, SVC_SOCK_ANONYMOUS);
if (err < 0 && err != -EAFNOSUPPORT)
goto out_close;

/* Decrease the count, but don't shut down the service */
nfsd_serv->sv_nrthreads--;
return 0;
out_close:
xprt = svc_find_xprt(nfsd_serv, transport, PF_INET, port);
Expand All @@ -1026,8 +1029,7 @@ static ssize_t __write_ports_addxprt(char *buf)
svc_xprt_put(xprt);
}
out_err:
/* Decrease the count, but don't shut down the service */
nfsd_serv->sv_nrthreads--;
svc_destroy(nfsd_serv);
return err;
}

Expand Down

0 comments on commit 0cd14a0

Please sign in to comment.