nfsd41: Backchannel: minorversion support for the back channel
[safe/jmp/linux-2.6] / fs / nfsd / nfs4state.c
index 89d9ac5..980a216 100644 (file)
@@ -425,6 +425,11 @@ static int set_forechannel_maxreqs(struct nfsd4_channel_attrs *fchan)
 {
        int status = 0, np = fchan->maxreqs * NFSD_PAGES_PER_SLOT;
 
+       if (fchan->maxreqs < 1)
+               return nfserr_inval;
+       else if (fchan->maxreqs > NFSD_MAX_SLOTS_PER_SESSION)
+               fchan->maxreqs = NFSD_MAX_SLOTS_PER_SESSION;
+
        spin_lock(&nfsd_serv->sv_lock);
        if (np + nfsd_serv->sv_drc_pages_used > nfsd_serv->sv_drc_max_pages)
                np = nfsd_serv->sv_drc_max_pages - nfsd_serv->sv_drc_pages_used;
@@ -444,8 +449,8 @@ static int set_forechannel_maxreqs(struct nfsd4_channel_attrs *fchan)
  * fchan holds the client values on input, and the server values on output
  */
 static int init_forechannel_attrs(struct svc_rqst *rqstp,
-                                   struct nfsd4_session *session,
-                                   struct nfsd4_channel_attrs *fchan)
+                                 struct nfsd4_channel_attrs *session_fchan,
+                                 struct nfsd4_channel_attrs *fchan)
 {
        int status = 0;
        __u32   maxcount = svc_max_payload(rqstp);
@@ -455,21 +460,21 @@ static int init_forechannel_attrs(struct svc_rqst *rqstp,
        /* Use the client's max request and max response size if possible */
        if (fchan->maxreq_sz > maxcount)
                fchan->maxreq_sz = maxcount;
-       session->se_fmaxreq_sz = fchan->maxreq_sz;
+       session_fchan->maxreq_sz = fchan->maxreq_sz;
 
        if (fchan->maxresp_sz > maxcount)
                fchan->maxresp_sz = maxcount;
-       session->se_fmaxresp_sz = fchan->maxresp_sz;
+       session_fchan->maxresp_sz = fchan->maxresp_sz;
 
        /* Set the max response cached size our default which is
         * a multiple of PAGE_SIZE and small */
-       session->se_fmaxresp_cached = NFSD_PAGES_PER_SLOT * PAGE_SIZE;
-       fchan->maxresp_cached = session->se_fmaxresp_cached;
+       session_fchan->maxresp_cached = NFSD_PAGES_PER_SLOT * PAGE_SIZE;
+       fchan->maxresp_cached = session_fchan->maxresp_cached;
 
        /* Use the client's maxops if possible */
        if (fchan->maxops > NFSD_MAX_OPS_PER_COMPOUND)
                fchan->maxops = NFSD_MAX_OPS_PER_COMPOUND;
-       session->se_fmaxops = fchan->maxops;
+       session_fchan->maxops = fchan->maxops;
 
        /* try to use the client requested number of slots */
        if (fchan->maxreqs > NFSD_MAX_SLOTS_PER_SESSION)
@@ -481,7 +486,7 @@ static int init_forechannel_attrs(struct svc_rqst *rqstp,
         */
        status = set_forechannel_maxreqs(fchan);
 
-       session->se_fnumslots = fchan->maxreqs;
+       session_fchan->maxreqs = fchan->maxreqs;
        return status;
 }
 
@@ -495,12 +500,14 @@ alloc_init_session(struct svc_rqst *rqstp, struct nfs4_client *clp,
        memset(&tmp, 0, sizeof(tmp));
 
        /* FIXME: For now, we just accept the client back channel attributes. */
-       status = init_forechannel_attrs(rqstp, &tmp, &cses->fore_channel);
+       tmp.se_bchannel = cses->back_channel;
+       status = init_forechannel_attrs(rqstp, &tmp.se_fchannel,
+                                       &cses->fore_channel);
        if (status)
                goto out;
 
        /* allocate struct nfsd4_session and slot table in one piece */
-       slotsize = tmp.se_fnumslots * sizeof(struct nfsd4_slot);
+       slotsize = tmp.se_fchannel.maxreqs * sizeof(struct nfsd4_slot);
        new = kzalloc(sizeof(*new) + slotsize, GFP_KERNEL);
        if (!new)
                goto out;
@@ -574,7 +581,7 @@ free_session(struct kref *kref)
        int i;
 
        ses = container_of(kref, struct nfsd4_session, se_ref);
-       for (i = 0; i < ses->se_fnumslots; i++) {
+       for (i = 0; i < ses->se_fchannel.maxreqs; i++) {
                struct nfsd4_cache_entry *e = &ses->se_slots[i].sl_cache_entry;
                nfsd4_release_respages(e->ce_respages, e->ce_resused);
        }
@@ -977,6 +984,7 @@ gen_callback(struct nfs4_client *clp, struct nfsd4_setclientid *se)
        if ( !(parse_ipv4(se->se_callback_addr_len, se->se_callback_addr_val,
                         &cb->cb_addr, &cb->cb_port)))
                goto out_err;
+       cb->cb_minorversion = 0;
        cb->cb_prog = se->se_callback_prog;
        cb->cb_ident = se->se_callback_ident;
        return;
@@ -1130,7 +1138,7 @@ nfsd4_replay_cache_entry(struct nfsd4_compoundres *resp,
         * is sent (lease renewal).
         */
        if (seq && nfsd4_not_cached(resp)) {
-               seq->maxslots = resp->cstate.session->se_fnumslots;
+               seq->maxslots = resp->cstate.session->se_fchannel.maxreqs;
                return nfs_ok;
        }
 
@@ -1240,12 +1248,6 @@ nfsd4_exchange_id(struct svc_rqst *rqstp,
                        expire_client(conf);
                        goto out_new;
                }
-               if (ip_addr != conf->cl_addr &&
-                   !(exid->flags & EXCHGID4_FLAG_UPD_CONFIRMED_REC_A)) {
-                       /* Client collision. 18.35.4 case 3 */
-                       status = nfserr_clid_inuse;
-                       goto out;
-               }
                /*
                 * Set bit when the owner id and verifier map to an already
                 * confirmed client id (18.35.3).
@@ -1259,12 +1261,12 @@ nfsd4_exchange_id(struct svc_rqst *rqstp,
                copy_verf(conf, &verf);
                new = conf;
                goto out_copy;
-       } else {
-               /* 18.35.4 case 7 */
-               if (exid->flags & EXCHGID4_FLAG_UPD_CONFIRMED_REC_A) {
-                       status = nfserr_noent;
-                       goto out;
-               }
+       }
+
+       /* 18.35.4 case 7 */
+       if (exid->flags & EXCHGID4_FLAG_UPD_CONFIRMED_REC_A) {
+               status = nfserr_noent;
+               goto out;
        }
 
        unconf  = find_unconfirmed_client_by_str(dname, strhashval, true);
@@ -1473,7 +1475,7 @@ nfsd4_sequence(struct svc_rqst *rqstp,
                goto out;
 
        status = nfserr_badslot;
-       if (seq->slotid >= session->se_fnumslots)
+       if (seq->slotid >= session->se_fchannel.maxreqs)
                goto out;
 
        slot = &session->se_slots[seq->slotid];