Commit 78a8d7c8ca3f0cb5cd2a276c6fc17c8c006d0b3c

Authored by Jeff Layton
Committed by J. Bruce Fields
1 parent 4ad9a344be

nfsd: fix error handling when starting nfsd with rpcbind down

The refcounting for nfsd is a little goofy. What happens is that we
create the nfsd RPC service, attach sockets to it but don't actually
start the threads until someone writes to the "threads" procfile. To do
this, __write_ports_addfd will create the nfsd service and then will
decrement the refcount when exiting but won't actually destroy the
service.

This is fine when there aren't errors, but when there are this can
cause later attempts to start nfsd to fail. nfsd_serv will be set,
and that causes __write_versions to return EBUSY.

Fix this by calling svc_destroy on nfsd_serv when this function is
going to return error.

Signed-off-by: Jeff Layton <jlayton@redhat.com>
Signed-off-by: J. Bruce Fields <bfields@redhat.com>

Showing 1 changed file with 8 additions and 4 deletions Side-by-side Diff

... ... @@ -950,14 +950,18 @@
950 950 return err;
951 951  
952 952 err = lockd_up();
953   - if (err != 0)
954   - goto out;
  953 + if (err != 0) {
  954 + svc_destroy(nfsd_serv);
  955 + return err;
  956 + }
955 957  
956 958 err = svc_addsock(nfsd_serv, fd, buf, SIMPLE_TRANSACTION_LIMIT);
957   - if (err < 0)
  959 + if (err < 0) {
958 960 lockd_down();
  961 + svc_destroy(nfsd_serv);
  962 + return err;
  963 + }
959 964  
960   -out:
961 965 /* Decrease the count, but don't shut down the service */
962 966 nfsd_serv->sv_nrthreads--;
963 967 return err;