Skip to content

Commit

Permalink
[PATCH] knfsd: Fixed handling of lockd fail when adding nfsd socket
Browse files Browse the repository at this point in the history
Arrgg..  We cannot 'lockd_up' before 'svc_addsock' as we don't know the
protocol yet....  So switch it around again and save the name of the created
sockets so that it can be closed if lock_up fails.

Signed-off-by: Neil Brown <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
neilbrown authored and Linus Torvalds committed Oct 4, 2006
1 parent cda9e0c commit 5680c44
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
12 changes: 6 additions & 6 deletions fs/nfsd/nfsctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -523,11 +523,11 @@ static ssize_t write_ports(struct file *file, char *buf, size_t size)
err = nfsd_create_serv();
if (!err) {
int proto = 0;
err = lockd_up(proto);
if (!err) {
err = svc_addsock(nfsd_serv, fd, buf, &proto);
if (err)
lockd_down();
err = svc_addsock(nfsd_serv, fd, buf, &proto);
if (err >= 0) {
err = lockd_up(proto);
if (err < 0)
svc_sock_names(buf+strlen(buf)+1, nfsd_serv, buf);
}
/* Decrease the count, but don't shutdown the
* the service
Expand All @@ -536,7 +536,7 @@ static ssize_t write_ports(struct file *file, char *buf, size_t size)
nfsd_serv->sv_nrthreads--;
unlock_kernel();
}
return err;
return err < 0 ? err : 0;
}
if (buf[0] == '-') {
char *toclose = kstrdup(buf+1, GFP_KERNEL);
Expand Down
3 changes: 3 additions & 0 deletions net/sunrpc/svcsock.c
Original file line number Diff line number Diff line change
Expand Up @@ -492,6 +492,9 @@ svc_sock_names(char *buf, struct svc_serv *serv, char *toclose)
}
spin_unlock(&serv->sv_lock);
if (closesk)
/* Should unregister with portmap, but you cannot
* unregister just one protocol...
*/
svc_delete_socket(closesk);
else if (toclose)
return -ENOENT;
Expand Down

0 comments on commit 5680c44

Please sign in to comment.