nfsd41: move channel attributes from nfsd4_session to a nfsd4_channel_attr struct
[safe/jmp/linux-2.6] / include / linux / nfsd / xdr4.h
index 1b65326..2bacf75 100644 (file)
 #define XDR_LEN(n)                     (((n) + 3) & ~3)
 
 struct nfsd4_compound_state {
-       struct svc_fh current_fh;
-       struct svc_fh save_fh;
-       struct nfs4_stateowner *replay_owner;
-};
+       struct svc_fh           current_fh;
+       struct svc_fh           save_fh;
+       struct nfs4_stateowner  *replay_owner;
+       /* For sessions DRC */
+       struct nfsd4_session    *session;
+       struct nfsd4_slot       *slot;
+       __be32                  *statp;
+       size_t                  iovlen;
+       u32                     minorversion;
+       u32                     status;
+};
+
+static inline bool nfsd4_has_session(struct nfsd4_compound_state *cs)
+{
+       return cs->slot != NULL;
+}
 
 struct nfsd4_change_info {
        u32             atomic;
+       bool            change_supported;
        u32             before_ctime_sec;
        u32             before_ctime_nsec;
+       u64             before_change;
        u32             after_ctime_sec;
        u32             after_ctime_nsec;
+       u64             after_change;
 };
 
 struct nfsd4_access {
@@ -90,7 +105,7 @@ struct nfsd4_create {
                        u32 specdata2;
                } dev;    /* NF4BLK, NF4CHR */
        } u;
-       u32             cr_bmval[2];        /* request */
+       u32             cr_bmval[3];        /* request */
        struct iattr    cr_iattr;           /* request */
        struct nfsd4_change_info  cr_cinfo; /* response */
        struct nfs4_acl *cr_acl;
@@ -105,7 +120,7 @@ struct nfsd4_delegreturn {
 };
 
 struct nfsd4_getattr {
-       u32             ga_bmval[2];        /* request */
+       u32             ga_bmval[3];        /* request */
        struct svc_fh   *ga_fhp;            /* response */
 };
 
@@ -206,11 +221,9 @@ struct nfsd4_open {
        stateid_t       op_delegate_stateid; /* request - response */
        u32             op_create;          /* request */
        u32             op_createmode;      /* request */
-       u32             op_bmval[2];        /* request */
-       union {                             /* request */
-               struct iattr    iattr;                      /* UNCHECKED4,GUARDED4 */
-               nfs4_verifier   verf;                                /* EXCLUSIVE4 */
-       } u;
+       u32             op_bmval[3];        /* request */
+       struct iattr    iattr;              /* UNCHECKED4, GUARDED4, EXCLUSIVE4_1 */
+       nfs4_verifier   verf;               /* EXCLUSIVE4 */
        clientid_t      op_clientid;        /* request */
        struct xdr_netobj op_owner;           /* request */
        u32             op_seqid;           /* request */
@@ -224,8 +237,8 @@ struct nfsd4_open {
        struct nfs4_stateowner *op_stateowner; /* used during processing */
        struct nfs4_acl *op_acl;
 };
-#define op_iattr       u.iattr
-#define op_verf                u.verf
+#define op_iattr       iattr
+#define op_verf                verf
 
 struct nfsd4_open_confirm {
        stateid_t       oc_req_stateid          /* request */;
@@ -259,7 +272,7 @@ struct nfsd4_readdir {
        nfs4_verifier   rd_verf;            /* request */
        u32             rd_dircount;        /* request */
        u32             rd_maxcount;        /* request */
-       u32             rd_bmval[2];        /* request */
+       u32             rd_bmval[3];        /* request */
        struct svc_rqst *rd_rqstp;          /* response */
        struct svc_fh * rd_fhp;             /* response */
 
@@ -301,7 +314,7 @@ struct nfsd4_secinfo {
 
 struct nfsd4_setattr {
        stateid_t       sa_stateid;         /* request */
-       u32             sa_bmval[2];        /* request */
+       u32             sa_bmval[3];        /* request */
        struct iattr    sa_iattr;           /* request */
        struct nfs4_acl *sa_acl;
 };
@@ -327,7 +340,7 @@ struct nfsd4_setclientid_confirm {
 
 /* also used for NVERIFY */
 struct nfsd4_verify {
-       u32             ve_bmval[2];        /* request */
+       u32             ve_bmval[3];        /* request */
        u32             ve_attrlen;         /* request */
        char *          ve_attrval;         /* request */
 };
@@ -344,6 +357,43 @@ struct nfsd4_write {
        nfs4_verifier   wr_verifier;        /* response */
 };
 
+struct nfsd4_exchange_id {
+       nfs4_verifier   verifier;
+       struct xdr_netobj clname;
+       u32             flags;
+       clientid_t      clientid;
+       u32             seqid;
+       int             spa_how;
+};
+
+struct nfsd4_create_session {
+       clientid_t              clientid;
+       struct nfs4_sessionid   sessionid;
+       u32                     seqid;
+       u32                     flags;
+       struct nfsd4_channel_attrs fore_channel;
+       struct nfsd4_channel_attrs back_channel;
+       u32                     callback_prog;
+       u32                     uid;
+       u32                     gid;
+};
+
+struct nfsd4_sequence {
+       struct nfs4_sessionid   sessionid;              /* request/response */
+       u32                     seqid;                  /* request/response */
+       u32                     slotid;                 /* request/response */
+       u32                     maxslots;               /* request/response */
+       u32                     cachethis;              /* request */
+#if 0
+       u32                     target_maxslots;        /* response */
+       u32                     status_flags;           /* response */
+#endif /* not yet */
+};
+
+struct nfsd4_destroy_session {
+       struct nfs4_sessionid   sessionid;
+};
+
 struct nfsd4_op {
        int                                     opnum;
        __be32                                  status;
@@ -378,6 +428,12 @@ struct nfsd4_op {
                struct nfsd4_verify             verify;
                struct nfsd4_write              write;
                struct nfsd4_release_lockowner  release_lockowner;
+
+               /* NFSv4.1 */
+               struct nfsd4_exchange_id        exchange_id;
+               struct nfsd4_create_session     create_session;
+               struct nfsd4_destroy_session    destroy_session;
+               struct nfsd4_sequence           sequence;
        } u;
        struct nfs4_replay *                    replay;
 };
@@ -416,9 +472,22 @@ struct nfsd4_compoundres {
        u32                             taglen;
        char *                          tag;
        u32                             opcnt;
-       __be32 *                        tagp; /* where to encode tag and  opcount */
+       __be32 *                        tagp; /* tag, opcount encode location */
+       struct nfsd4_compound_state     cstate;
 };
 
+static inline bool nfsd4_is_solo_sequence(struct nfsd4_compoundres *resp)
+{
+       struct nfsd4_compoundargs *args = resp->rqstp->rq_argp;
+       return args->opcnt == 1;
+}
+
+static inline bool nfsd4_not_cached(struct nfsd4_compoundres *resp)
+{
+       return !resp->cstate.slot->sl_cache_entry.ce_cachethis ||
+                       nfsd4_is_solo_sequence(resp);
+}
+
 #define NFS4_SVC_XDRSIZE               sizeof(struct nfsd4_compoundargs)
 
 static inline void
@@ -426,10 +495,16 @@ set_change_info(struct nfsd4_change_info *cinfo, struct svc_fh *fhp)
 {
        BUG_ON(!fhp->fh_pre_saved || !fhp->fh_post_saved);
        cinfo->atomic = 1;
-       cinfo->before_ctime_sec = fhp->fh_pre_ctime.tv_sec;
-       cinfo->before_ctime_nsec = fhp->fh_pre_ctime.tv_nsec;
-       cinfo->after_ctime_sec = fhp->fh_post_ctime.tv_sec;
-       cinfo->after_ctime_nsec = fhp->fh_post_ctime.tv_nsec;
+       cinfo->change_supported = IS_I_VERSION(fhp->fh_dentry->d_inode);
+       if (cinfo->change_supported) {
+               cinfo->before_change = fhp->fh_pre_change;
+               cinfo->after_change = fhp->fh_post_change;
+       } else {
+               cinfo->before_ctime_sec = fhp->fh_pre_ctime.tv_sec;
+               cinfo->before_ctime_nsec = fhp->fh_pre_ctime.tv_nsec;
+               cinfo->after_ctime_sec = fhp->fh_post_attr.ctime.tv_sec;
+               cinfo->after_ctime_nsec = fhp->fh_post_attr.ctime.tv_nsec;
+       }
 }
 
 int nfs4svc_encode_voidres(struct svc_rqst *, __be32 *, void *);
@@ -441,14 +516,30 @@ void nfsd4_encode_operation(struct nfsd4_compoundres *, struct nfsd4_op *);
 void nfsd4_encode_replay(struct nfsd4_compoundres *resp, struct nfsd4_op *op);
 __be32 nfsd4_encode_fattr(struct svc_fh *fhp, struct svc_export *exp,
                       struct dentry *dentry, __be32 *buffer, int *countp,
-                      u32 *bmval, struct svc_rqst *);
+                      u32 *bmval, struct svc_rqst *, int ignore_crossmnt);
 extern __be32 nfsd4_setclientid(struct svc_rqst *rqstp,
                struct nfsd4_compound_state *,
                struct nfsd4_setclientid *setclid);
 extern __be32 nfsd4_setclientid_confirm(struct svc_rqst *rqstp,
                struct nfsd4_compound_state *,
                struct nfsd4_setclientid_confirm *setclientid_confirm);
-extern __be32 nfsd4_process_open1(struct nfsd4_open *open);
+extern void nfsd4_store_cache_entry(struct nfsd4_compoundres *resp);
+extern __be32 nfsd4_replay_cache_entry(struct nfsd4_compoundres *resp,
+               struct nfsd4_sequence *seq);
+extern __be32 nfsd4_exchange_id(struct svc_rqst *rqstp,
+               struct nfsd4_compound_state *,
+struct nfsd4_exchange_id *);
+               extern __be32 nfsd4_create_session(struct svc_rqst *,
+               struct nfsd4_compound_state *,
+               struct nfsd4_create_session *);
+extern __be32 nfsd4_sequence(struct svc_rqst *,
+               struct nfsd4_compound_state *,
+               struct nfsd4_sequence *);
+extern __be32 nfsd4_destroy_session(struct svc_rqst *,
+               struct nfsd4_compound_state *,
+               struct nfsd4_destroy_session *);
+extern __be32 nfsd4_process_open1(struct nfsd4_compound_state *,
+               struct nfsd4_open *open);
 extern __be32 nfsd4_process_open2(struct svc_rqst *rqstp,
                struct svc_fh *current_fh, struct nfsd4_open *open);
 extern __be32 nfsd4_open_confirm(struct svc_rqst *rqstp,