aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorJ. Bruce Fields <bfields@redhat.com>2012-09-12 11:04:33 -0400
committerJ. Bruce Fields <bfields@redhat.com>2012-10-01 17:40:02 -0400
commit81f0b2a4965da2a48aed5e992f2bc859e5d35066 (patch)
tree4d9f614558e3b57fa66802568dbbf10725f03a4e /fs
parenta827bcb242ecc884d38af8145e1d9a112b739b35 (diff)
nfsd4: separate session allocation and initialization
This will allow some further simplification. Signed-off-by: J. Bruce Fields <bfields@redhat.com>
Diffstat (limited to 'fs')
-rw-r--r--fs/nfsd/nfs4state.c46
1 files changed, 23 insertions, 23 deletions
diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c
index 79f1fdb22dc7..1cd80d576952 100644
--- a/fs/nfsd/nfs4state.c
+++ b/fs/nfsd/nfs4state.c
@@ -946,21 +946,10 @@ static struct nfsd4_session *alloc_session(struct nfsd4_channel_attrs *fchan)
946 return new; 946 return new;
947} 947}
948 948
949static struct nfsd4_session *alloc_init_session(struct svc_rqst *rqstp, struct nfs4_client *clp, struct nfsd4_create_session *cses) 949static struct nfsd4_session *init_session(struct svc_rqst *rqstp, struct nfsd4_session *new, struct nfs4_client *clp, struct nfsd4_create_session *cses)
950{ 950{
951 struct nfsd4_session *new;
952 struct nfsd4_conn *conn;
953 int idx; 951 int idx;
954 952
955 new = alloc_session(&cses->fore_channel);
956 if (!new)
957 return NULL;
958
959 conn = alloc_conn_from_crses(rqstp, cses);
960 if (!conn) {
961 __free_session(new);
962 return NULL;
963 }
964 new->se_client = clp; 953 new->se_client = clp;
965 gen_sessionid(new); 954 gen_sessionid(new);
966 955
@@ -978,7 +967,6 @@ static struct nfsd4_session *alloc_init_session(struct svc_rqst *rqstp, struct n
978 spin_unlock(&clp->cl_lock); 967 spin_unlock(&clp->cl_lock);
979 spin_unlock(&client_lock); 968 spin_unlock(&client_lock);
980 969
981 nfsd4_init_conn(rqstp, conn, new);
982 if (cses->flags & SESSION4_BACK_CHAN) { 970 if (cses->flags & SESSION4_BACK_CHAN) {
983 struct sockaddr *sa = svc_addr(rqstp); 971 struct sockaddr *sa = svc_addr(rqstp);
984 /* 972 /*
@@ -1766,6 +1754,7 @@ nfsd4_create_session(struct svc_rqst *rqstp,
1766 struct sockaddr *sa = svc_addr(rqstp); 1754 struct sockaddr *sa = svc_addr(rqstp);
1767 struct nfs4_client *conf, *unconf; 1755 struct nfs4_client *conf, *unconf;
1768 struct nfsd4_session *new; 1756 struct nfsd4_session *new;
1757 struct nfsd4_conn *conn;
1769 struct nfsd4_clid_slot *cs_slot = NULL; 1758 struct nfsd4_clid_slot *cs_slot = NULL;
1770 bool confirm_me = false; 1759 bool confirm_me = false;
1771 __be32 status = 0; 1760 __be32 status = 0;
@@ -1774,6 +1763,13 @@ nfsd4_create_session(struct svc_rqst *rqstp,
1774 return nfserr_inval; 1763 return nfserr_inval;
1775 if (check_forechannel_attrs(cr_ses->fore_channel)) 1764 if (check_forechannel_attrs(cr_ses->fore_channel))
1776 return nfserr_toosmall; 1765 return nfserr_toosmall;
1766 new = alloc_session(&cr_ses->fore_channel);
1767 if (!new)
1768 return nfserr_jukebox;
1769 status = nfserr_jukebox;
1770 conn = alloc_conn_from_crses(rqstp, cr_ses);
1771 if (!conn)
1772 goto out_free_session;
1777 1773
1778 nfs4_lock_state(); 1774 nfs4_lock_state();
1779 unconf = find_unconfirmed_client(&cr_ses->clientid, true); 1775 unconf = find_unconfirmed_client(&cr_ses->clientid, true);
@@ -1784,41 +1780,40 @@ nfsd4_create_session(struct svc_rqst *rqstp,
1784 status = check_slot_seqid(cr_ses->seqid, cs_slot->sl_seqid, 0); 1780 status = check_slot_seqid(cr_ses->seqid, cs_slot->sl_seqid, 0);
1785 if (status == nfserr_replay_cache) { 1781 if (status == nfserr_replay_cache) {
1786 status = nfsd4_replay_create_session(cr_ses, cs_slot); 1782 status = nfsd4_replay_create_session(cr_ses, cs_slot);
1787 goto out; 1783 goto out_free_conn;
1788 } else if (cr_ses->seqid != cs_slot->sl_seqid + 1) { 1784 } else if (cr_ses->seqid != cs_slot->sl_seqid + 1) {
1789 status = nfserr_seq_misordered; 1785 status = nfserr_seq_misordered;
1790 goto out; 1786 goto out_free_conn;
1791 } 1787 }
1792 } else if (unconf) { 1788 } else if (unconf) {
1793 if (!same_creds(&unconf->cl_cred, &rqstp->rq_cred) || 1789 if (!same_creds(&unconf->cl_cred, &rqstp->rq_cred) ||
1794 !rpc_cmp_addr(sa, (struct sockaddr *) &unconf->cl_addr)) { 1790 !rpc_cmp_addr(sa, (struct sockaddr *) &unconf->cl_addr)) {
1795 status = nfserr_clid_inuse; 1791 status = nfserr_clid_inuse;
1796 goto out; 1792 goto out_free_conn;
1797 } 1793 }
1798 cs_slot = &unconf->cl_cs_slot; 1794 cs_slot = &unconf->cl_cs_slot;
1799 status = check_slot_seqid(cr_ses->seqid, cs_slot->sl_seqid, 0); 1795 status = check_slot_seqid(cr_ses->seqid, cs_slot->sl_seqid, 0);
1800 if (status) { 1796 if (status) {
1801 /* an unconfirmed replay returns misordered */ 1797 /* an unconfirmed replay returns misordered */
1802 status = nfserr_seq_misordered; 1798 status = nfserr_seq_misordered;
1803 goto out; 1799 goto out_free_conn;
1804 } 1800 }
1805 confirm_me = true; 1801 confirm_me = true;
1806 conf = unconf; 1802 conf = unconf;
1807 } else { 1803 } else {
1808 status = nfserr_stale_clientid; 1804 status = nfserr_stale_clientid;
1809 goto out; 1805 goto out_free_conn;
1810 } 1806 }
1807 status = nfs_ok;
1811 /* 1808 /*
1812 * We do not support RDMA or persistent sessions 1809 * We do not support RDMA or persistent sessions
1813 */ 1810 */
1814 cr_ses->flags &= ~SESSION4_PERSIST; 1811 cr_ses->flags &= ~SESSION4_PERSIST;
1815 cr_ses->flags &= ~SESSION4_RDMA; 1812 cr_ses->flags &= ~SESSION4_RDMA;
1816 1813
1817 status = nfserr_jukebox; 1814 init_session(rqstp, new, conf, cr_ses);
1818 new = alloc_init_session(rqstp, conf, cr_ses); 1815 nfsd4_init_conn(rqstp, conn, new);
1819 if (!new) 1816
1820 goto out;
1821 status = nfs_ok;
1822 memcpy(cr_ses->sessionid.data, new->se_sessionid.data, 1817 memcpy(cr_ses->sessionid.data, new->se_sessionid.data,
1823 NFS4_MAX_SESSIONID_LEN); 1818 NFS4_MAX_SESSIONID_LEN);
1824 memcpy(&cr_ses->fore_channel, &new->se_fchannel, 1819 memcpy(&cr_ses->fore_channel, &new->se_fchannel,
@@ -1840,6 +1835,11 @@ out:
1840 nfs4_unlock_state(); 1835 nfs4_unlock_state();
1841 dprintk("%s returns %d\n", __func__, ntohl(status)); 1836 dprintk("%s returns %d\n", __func__, ntohl(status));
1842 return status; 1837 return status;
1838out_free_conn:
1839 free_conn(conn);
1840out_free_session:
1841 __free_session(new);
1842 goto out;
1843} 1843}
1844 1844
1845static bool nfsd4_last_compound_op(struct svc_rqst *rqstp) 1845static bool nfsd4_last_compound_op(struct svc_rqst *rqstp)