diff options
author | Chuck Lever <chuck.lever@oracle.com> | 2009-04-23 19:31:55 -0400 |
---|---|---|
committer | J. Bruce Fields <bfields@citi.umich.edu> | 2009-04-28 13:54:27 -0400 |
commit | 0b7c2f6fc7e06867885c7b0f256ff5bd494e0653 (patch) | |
tree | ff4434f78737edb6896275aebd6f6f93252ab34d /fs/nfsd | |
parent | 82d565919aa4138bc481a7473491b71385af4018 (diff) |
NFSD: Refactor socket creation out of __write_ports()
Clean up: Refactor the socket creation logic out of __write_ports() to
make it easier to understand and maintain.
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: J. Bruce Fields <bfields@citi.umich.edu>
Diffstat (limited to 'fs/nfsd')
-rw-r--r-- | fs/nfsd/nfsctl.c | 64 |
1 files changed, 34 insertions, 30 deletions
diff --git a/fs/nfsd/nfsctl.c b/fs/nfsd/nfsctl.c index fa268d1b775f..b6a847faa0bb 100644 --- a/fs/nfsd/nfsctl.c +++ b/fs/nfsd/nfsctl.c | |||
@@ -911,6 +911,37 @@ static ssize_t write_versions(struct file *file, char *buf, size_t size) | |||
911 | } | 911 | } |
912 | 912 | ||
913 | /* | 913 | /* |
914 | * A single 'fd' number was written, in which case it must be for | ||
915 | * a socket of a supported family/protocol, and we use it as an | ||
916 | * nfsd listener. | ||
917 | */ | ||
918 | static ssize_t __write_ports_addfd(char *buf) | ||
919 | { | ||
920 | char *mesg = buf; | ||
921 | int fd, err; | ||
922 | |||
923 | err = get_int(&mesg, &fd); | ||
924 | if (err != 0 || fd < 0) | ||
925 | return -EINVAL; | ||
926 | |||
927 | err = nfsd_create_serv(); | ||
928 | if (err != 0) | ||
929 | return err; | ||
930 | |||
931 | err = svc_addsock(nfsd_serv, fd, buf); | ||
932 | if (err >= 0) { | ||
933 | err = lockd_up(); | ||
934 | if (err < 0) | ||
935 | svc_sock_names(buf + strlen(buf) + 1, nfsd_serv, buf); | ||
936 | |||
937 | /* Decrease the count, but don't shut down the service */ | ||
938 | nfsd_serv->sv_nrthreads--; | ||
939 | } | ||
940 | |||
941 | return err < 0 ? err : 0; | ||
942 | } | ||
943 | |||
944 | /* | ||
914 | * A '-' followed by the 'name' of a socket means we close the socket. | 945 | * A '-' followed by the 'name' of a socket means we close the socket. |
915 | */ | 946 | */ |
916 | static ssize_t __write_ports_delfd(char *buf) | 947 | static ssize_t __write_ports_delfd(char *buf) |
@@ -995,36 +1026,9 @@ static ssize_t __write_ports(struct file *file, char *buf, size_t size) | |||
995 | len = svc_xprt_names(nfsd_serv, buf, 0); | 1026 | len = svc_xprt_names(nfsd_serv, buf, 0); |
996 | return len; | 1027 | return len; |
997 | } | 1028 | } |
998 | /* Either a single 'fd' number is written, in which | 1029 | |
999 | * case it must be for a socket of a supported family/protocol, | 1030 | if (isdigit(buf[0])) |
1000 | * and we use it as an nfsd socket, or | 1031 | return __write_ports_addfd(buf); |
1001 | * A '-' followed by the 'name' of a socket in which case | ||
1002 | * we close the socket. | ||
1003 | */ | ||
1004 | if (isdigit(buf[0])) { | ||
1005 | char *mesg = buf; | ||
1006 | int fd; | ||
1007 | int err; | ||
1008 | err = get_int(&mesg, &fd); | ||
1009 | if (err) | ||
1010 | return -EINVAL; | ||
1011 | if (fd < 0) | ||
1012 | return -EINVAL; | ||
1013 | err = nfsd_create_serv(); | ||
1014 | if (!err) { | ||
1015 | err = svc_addsock(nfsd_serv, fd, buf); | ||
1016 | if (err >= 0) { | ||
1017 | err = lockd_up(); | ||
1018 | if (err < 0) | ||
1019 | svc_sock_names(buf+strlen(buf)+1, nfsd_serv, buf); | ||
1020 | } | ||
1021 | /* Decrease the count, but don't shutdown the | ||
1022 | * the service | ||
1023 | */ | ||
1024 | nfsd_serv->sv_nrthreads--; | ||
1025 | } | ||
1026 | return err < 0 ? err : 0; | ||
1027 | } | ||
1028 | 1032 | ||
1029 | if (buf[0] == '-' && isdigit(buf[1])) | 1033 | if (buf[0] == '-' && isdigit(buf[1])) |
1030 | return __write_ports_delfd(buf); | 1034 | return __write_ports_delfd(buf); |