diff options
| author | J. Bruce Fields <bfields@redhat.com> | 2012-09-11 17:10:25 -0400 |
|---|---|---|
| committer | J. Bruce Fields <bfields@redhat.com> | 2012-10-01 17:40:00 -0400 |
| commit | e1ff371f9da57c1965400b9cc6607705d76a67bd (patch) | |
| tree | 5268f10434e04f6e454f4d6ccb4173949f01ee6d | |
| parent | 3ba6367124f3f07c91ea45a3ea24bbf4c5429bfc (diff) | |
nfsd4: new_conn_from_crses should only allocate
Do the initialization in the caller, and clarify that the only failure
ever possible here was due to allocation.
Signed-off-by: J. Bruce Fields <bfields@redhat.com>
| -rw-r--r-- | fs/nfsd/nfs4state.c | 26 |
1 files changed, 10 insertions, 16 deletions
diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c index 101ccd856e6a..8b7f8f84d5a4 100644 --- a/fs/nfsd/nfs4state.c +++ b/fs/nfsd/nfs4state.c | |||
| @@ -852,7 +852,7 @@ static int nfsd4_register_conn(struct nfsd4_conn *conn) | |||
| 852 | return register_xpt_user(conn->cn_xprt, &conn->cn_xpt_user); | 852 | return register_xpt_user(conn->cn_xprt, &conn->cn_xpt_user); |
| 853 | } | 853 | } |
| 854 | 854 | ||
| 855 | static void nfsd4_init_conn(struct svc_rqst *rqstp, struct nfsd4_conn *conn, struct nfsd4_session *ses, u32 dir) | 855 | static void nfsd4_init_conn(struct svc_rqst *rqstp, struct nfsd4_conn *conn, struct nfsd4_session *ses) |
| 856 | { | 856 | { |
| 857 | int ret; | 857 | int ret; |
| 858 | 858 | ||
| @@ -862,25 +862,19 @@ static void nfsd4_init_conn(struct svc_rqst *rqstp, struct nfsd4_conn *conn, str | |||
| 862 | /* oops; xprt is already down: */ | 862 | /* oops; xprt is already down: */ |
| 863 | nfsd4_conn_lost(&conn->cn_xpt_user); | 863 | nfsd4_conn_lost(&conn->cn_xpt_user); |
| 864 | if (ses->se_client->cl_cb_state == NFSD4_CB_DOWN && | 864 | if (ses->se_client->cl_cb_state == NFSD4_CB_DOWN && |
| 865 | dir & NFS4_CDFC4_BACK) { | 865 | conn->cn_flags & NFS4_CDFC4_BACK) { |
| 866 | /* callback channel may be back up */ | 866 | /* callback channel may be back up */ |
| 867 | nfsd4_probe_callback(ses->se_client); | 867 | nfsd4_probe_callback(ses->se_client); |
| 868 | } | 868 | } |
| 869 | } | 869 | } |
| 870 | 870 | ||
| 871 | static __be32 nfsd4_new_conn_from_crses(struct svc_rqst *rqstp, struct nfsd4_session *ses) | 871 | static struct nfsd4_conn *alloc_conn_from_crses(struct svc_rqst *rqstp, struct nfsd4_create_session *cses) |
| 872 | { | 872 | { |
| 873 | struct nfsd4_conn *conn; | ||
| 874 | u32 dir = NFS4_CDFC4_FORE; | 873 | u32 dir = NFS4_CDFC4_FORE; |
| 875 | 874 | ||
| 876 | if (ses->se_flags & SESSION4_BACK_CHAN) | 875 | if (cses->flags & SESSION4_BACK_CHAN) |
| 877 | dir |= NFS4_CDFC4_BACK; | 876 | dir |= NFS4_CDFC4_BACK; |
| 878 | 877 | return alloc_conn(rqstp, dir); | |
| 879 | conn = alloc_conn(rqstp, dir); | ||
| 880 | if (!conn) | ||
| 881 | return nfserr_jukebox; | ||
| 882 | nfsd4_init_conn(rqstp, conn, ses, dir); | ||
| 883 | return nfs_ok; | ||
| 884 | } | 878 | } |
| 885 | 879 | ||
| 886 | /* must be called under client_lock */ | 880 | /* must be called under client_lock */ |
| @@ -929,9 +923,9 @@ void nfsd4_put_session(struct nfsd4_session *ses) | |||
| 929 | static struct nfsd4_session *alloc_init_session(struct svc_rqst *rqstp, struct nfs4_client *clp, struct nfsd4_create_session *cses) | 923 | static struct nfsd4_session *alloc_init_session(struct svc_rqst *rqstp, struct nfs4_client *clp, struct nfsd4_create_session *cses) |
| 930 | { | 924 | { |
| 931 | struct nfsd4_session *new; | 925 | struct nfsd4_session *new; |
| 926 | struct nfsd4_conn *conn; | ||
| 932 | struct nfsd4_channel_attrs *fchan = &cses->fore_channel; | 927 | struct nfsd4_channel_attrs *fchan = &cses->fore_channel; |
| 933 | int numslots, slotsize; | 928 | int numslots, slotsize; |
| 934 | __be32 status; | ||
| 935 | int idx; | 929 | int idx; |
| 936 | 930 | ||
| 937 | /* | 931 | /* |
| @@ -970,14 +964,14 @@ static struct nfsd4_session *alloc_init_session(struct svc_rqst *rqstp, struct n | |||
| 970 | spin_unlock(&clp->cl_lock); | 964 | spin_unlock(&clp->cl_lock); |
| 971 | spin_unlock(&client_lock); | 965 | spin_unlock(&client_lock); |
| 972 | 966 | ||
| 973 | status = nfsd4_new_conn_from_crses(rqstp, new); | 967 | conn = alloc_conn_from_crses(rqstp, cses); |
| 974 | /* whoops: benny points out, status is ignored! (err, or bogus) */ | 968 | if (!conn) { |
| 975 | if (status) { | ||
| 976 | spin_lock(&client_lock); | 969 | spin_lock(&client_lock); |
| 977 | free_session(&new->se_ref); | 970 | free_session(&new->se_ref); |
| 978 | spin_unlock(&client_lock); | 971 | spin_unlock(&client_lock); |
| 979 | return NULL; | 972 | return NULL; |
| 980 | } | 973 | } |
| 974 | nfsd4_init_conn(rqstp, conn, new); | ||
| 981 | if (cses->flags & SESSION4_BACK_CHAN) { | 975 | if (cses->flags & SESSION4_BACK_CHAN) { |
| 982 | struct sockaddr *sa = svc_addr(rqstp); | 976 | struct sockaddr *sa = svc_addr(rqstp); |
| 983 | /* | 977 | /* |
| @@ -1890,7 +1884,7 @@ __be32 nfsd4_bind_conn_to_session(struct svc_rqst *rqstp, | |||
| 1890 | conn = alloc_conn(rqstp, bcts->dir); | 1884 | conn = alloc_conn(rqstp, bcts->dir); |
| 1891 | if (!conn) | 1885 | if (!conn) |
| 1892 | return nfserr_jukebox; | 1886 | return nfserr_jukebox; |
| 1893 | nfsd4_init_conn(rqstp, conn, cstate->session, bcts->dir); | 1887 | nfsd4_init_conn(rqstp, conn, cstate->session); |
| 1894 | return nfs_ok; | 1888 | return nfs_ok; |
| 1895 | } | 1889 | } |
| 1896 | 1890 | ||
