diff options
author | Chuck Lever <chuck.lever@oracle.com> | 2009-04-23 19:31:48 -0400 |
---|---|---|
committer | J. Bruce Fields <bfields@citi.umich.edu> | 2009-04-28 13:54:26 -0400 |
commit | 82d565919aa4138bc481a7473491b71385af4018 (patch) | |
tree | 4bc51f1a754af10989cf04ddd2cb278ce96ca154 /fs | |
parent | 4eb68c266cb1754ffa0040e882882680ece8cf34 (diff) |
NFSD: Refactor portlist socket closing into a helper
Clean up: Refactor the socket closing 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')
-rw-r--r-- | fs/nfsd/nfsctl.c | 36 |
1 files changed, 24 insertions, 12 deletions
diff --git a/fs/nfsd/nfsctl.c b/fs/nfsd/nfsctl.c index 748532b93fd9..fa268d1b775f 100644 --- a/fs/nfsd/nfsctl.c +++ b/fs/nfsd/nfsctl.c | |||
@@ -911,6 +911,27 @@ static ssize_t write_versions(struct file *file, char *buf, size_t size) | |||
911 | } | 911 | } |
912 | 912 | ||
913 | /* | 913 | /* |
914 | * A '-' followed by the 'name' of a socket means we close the socket. | ||
915 | */ | ||
916 | static ssize_t __write_ports_delfd(char *buf) | ||
917 | { | ||
918 | char *toclose; | ||
919 | int len = 0; | ||
920 | |||
921 | toclose = kstrdup(buf + 1, GFP_KERNEL); | ||
922 | if (toclose == NULL) | ||
923 | return -ENOMEM; | ||
924 | |||
925 | if (nfsd_serv != NULL) | ||
926 | len = svc_sock_names(buf, nfsd_serv, toclose); | ||
927 | if (len >= 0) | ||
928 | lockd_down(); | ||
929 | |||
930 | kfree(toclose); | ||
931 | return len; | ||
932 | } | ||
933 | |||
934 | /* | ||
914 | * A transport listener is added by writing it's transport name and | 935 | * A transport listener is added by writing it's transport name and |
915 | * a port number. | 936 | * a port number. |
916 | */ | 937 | */ |
@@ -1004,18 +1025,9 @@ static ssize_t __write_ports(struct file *file, char *buf, size_t size) | |||
1004 | } | 1025 | } |
1005 | return err < 0 ? err : 0; | 1026 | return err < 0 ? err : 0; |
1006 | } | 1027 | } |
1007 | if (buf[0] == '-' && isdigit(buf[1])) { | 1028 | |
1008 | char *toclose = kstrdup(buf+1, GFP_KERNEL); | 1029 | if (buf[0] == '-' && isdigit(buf[1])) |
1009 | int len = 0; | 1030 | return __write_ports_delfd(buf); |
1010 | if (!toclose) | ||
1011 | return -ENOMEM; | ||
1012 | if (nfsd_serv) | ||
1013 | len = svc_sock_names(buf, nfsd_serv, toclose); | ||
1014 | if (len >= 0) | ||
1015 | lockd_down(); | ||
1016 | kfree(toclose); | ||
1017 | return len; | ||
1018 | } | ||
1019 | 1031 | ||
1020 | if (isalpha(buf[0])) | 1032 | if (isalpha(buf[0])) |
1021 | return __write_ports_addxprt(buf); | 1033 | return __write_ports_addxprt(buf); |