Skip to content

Commit

Permalink
NFSD: move lockd_up() before svc_addsock()
Browse files Browse the repository at this point in the history
Clean up.

A couple of years ago, a series of commits, finishing with commit
5680c44, swapped the order of the lockd_up() and svc_addsock() calls
in __write_ports().  At that time lockd_up() needed to know the
transport protocol of the passed-in socket to start a listener on the
same transport protocol.

These days, lockd_up() doesn't take a protocol argument; it always
starts both a UDP and TCP listener.  It's now more straightforward to
try the lockd_up() first, then do a lockd_down() if the svc_addsock()
fails.

Careful review of this code shows that the svc_sock_names() call is
used only to close the just-opened socket in case lockd_up() fails.
So it is no longer needed if lockd_up() is done first.

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: J. Bruce Fields <bfields@citi.umich.edu>
  • Loading branch information
Chuck Lever authored and J. Bruce Fields committed Apr 28, 2009
1 parent 0a5372d commit ea068ba
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions fs/nfsd/nfsctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -939,17 +939,18 @@ static ssize_t __write_ports_addfd(char *buf)
if (err != 0)
return err;

err = svc_addsock(nfsd_serv, fd, buf);
if (err >= 0) {
err = lockd_up();
if (err < 0)
svc_sock_names(buf + strlen(buf) + 1, nfsd_serv, buf);
err = lockd_up();
if (err != 0)
goto out;

/* Decrease the count, but don't shut down the service */
nfsd_serv->sv_nrthreads--;
}
err = svc_addsock(nfsd_serv, fd, buf);
if (err < 0)
lockd_down();

return err < 0 ? err : 0;
out:
/* Decrease the count, but don't shut down the service */
nfsd_serv->sv_nrthreads--;
return err;
}

/*
Expand Down

0 comments on commit ea068ba

Please sign in to comment.