vserver 1.9.5.x5
[linux-2.6.git] / include / linux / nfsd / state.h
index 06da185..d08cf66 100644 (file)
@@ -38,6 +38,8 @@
 #define _NFSD4_STATE_H
 
 #include <linux/list.h>
+#include <linux/kref.h>
+#include <linux/sunrpc/clnt.h>
 
 #define NFS4_OPAQUE_LIMIT 1024
 typedef struct {
@@ -65,6 +67,56 @@ extern stateid_t onestateid;
 #define ZERO_STATEID(stateid)       (!memcmp((stateid), &zerostateid, sizeof(stateid_t)))
 #define ONE_STATEID(stateid)        (!memcmp((stateid), &onestateid, sizeof(stateid_t)))
 
+/* Delegation recall states */
+#define NFS4_NO_RECALL                 0x000
+#define NFS4_RECALL_IN_PROGRESS                0x001
+#define NFS4_RECALL_COMPLETE           0x002
+#define NFS4_REAP_DELEG                        0x004
+
+struct nfs4_cb_recall {
+       u32                     cbr_ident;
+       int                     cbr_trunc;
+       stateid_t               cbr_stateid;
+       u32                     cbr_fhlen;
+       u32                     cbr_fhval[NFS4_FHSIZE];
+       struct nfs4_delegation  *cbr_dp;
+};
+
+struct nfs4_delegation {
+       struct list_head        dl_del_perfile; /* nfs4_file->fi_del_perfile */
+       struct list_head        dl_del_perclnt; /* nfs4_client->cl_del_perclnt*/
+       struct list_head        dl_recall_lru;  /* delegation recalled */
+       atomic_t                dl_recall_cnt;  /* resend cb_recall only once */
+       atomic_t                dl_count;       /* ref count */
+       atomic_t                dl_state;       /* recall state */
+       struct nfs4_client      *dl_client;
+       struct nfs4_file        *dl_file;
+       struct file_lock        *dl_flock;
+       struct nfs4_stateid     *dl_stp;
+       u32                     dl_type;
+       time_t                  dl_time;
+       struct nfs4_cb_recall   dl_recall;
+};
+
+#define dl_stateid      dl_recall.cbr_stateid
+#define dl_fhlen        dl_recall.cbr_fhlen
+#define dl_fhval        dl_recall.cbr_fhval
+
+/* client delegation callback info */
+struct nfs4_callback {
+       /* SETCLIENTID info */
+       u32                     cb_parsed;  /* addr parsed */
+       u32                     cb_addr;
+       unsigned short          cb_port;
+       u32                     cb_prog;
+       u32                     cb_ident;
+       /* RPC client info */
+       atomic_t                cb_set;     /* successful CB_NULL call */
+       struct rpc_program      cb_program;
+       struct rpc_stat         cb_stat;
+       struct rpc_clnt *       cb_client;
+};
+
 /*
  * struct nfs4_client - one per client.  Clientids live here.
  *     o Each nfs4_client is hashed by clientid.
@@ -79,6 +131,7 @@ struct nfs4_client {
        struct list_head        cl_idhash;      /* hash by cl_clientid.id */
        struct list_head        cl_strhash;     /* hash by cl_name */
        struct list_head        cl_perclient;   /* list: stateowners */
+       struct list_head        cl_del_perclnt; /* list: delegations */
        struct list_head        cl_lru;         /* tail queue */
        struct xdr_netobj       cl_name;        /* id generated by client */
        nfs4_verifier           cl_verifier;    /* generated by client */
@@ -87,6 +140,21 @@ struct nfs4_client {
        struct svc_cred         cl_cred;        /* setclientid principal */
        clientid_t              cl_clientid;    /* generated by server */
        nfs4_verifier           cl_confirm;     /* generated by server */
+       struct nfs4_callback    cl_callback;    /* callback info */
+       time_t                  cl_first_state; /* first state aquisition*/
+       atomic_t                cl_count;       /* ref count */
+};
+
+/* struct nfs4_client_reset
+ * one per old client. Populates reset_str_hashtbl. Filled from conf_id_hashtbl
+ * upon lease reset, or from upcall to state_daemon (to read in state
+ * from non-volitile storage) upon reboot.
+ */
+struct nfs4_client_reclaim {
+       struct list_head        cr_strhash;     /* hash by cr_name */
+       struct xdr_netobj       cr_name;        /* id generated by client */
+       time_t                  cr_first_state; /* first state aquisition */
+       u32                     cr_expired;     /* boolean: lease expired? */
 };
 
 static inline void
@@ -137,6 +205,7 @@ struct nfs4_replay {
 *         reaped by laundramat thread after lease period.
 */
 struct nfs4_stateowner {
+       struct kref             so_ref;
        struct list_head        so_idhash;   /* hash by so_id */
        struct list_head        so_strhash;   /* hash by op_name */
        struct list_head        so_perclient; /* nfs4_client->cl_perclient */
@@ -161,6 +230,7 @@ struct nfs4_stateowner {
 struct nfs4_file {
        struct list_head        fi_hash;    /* hash by "struct inode *" */
        struct list_head        fi_perfile; /* list: nfs4_stateid */
+       struct list_head        fi_del_perfile; /* list: nfs4_delegation */
        struct inode            *fi_inode;
        u32                     fi_id;      /* used with stateowner->so_id 
                                             * for stateid_hashtbl hash */
@@ -187,7 +257,7 @@ struct nfs4_stateid {
        struct nfs4_stateowner      * st_stateowner;
        struct nfs4_file            * st_file;
        stateid_t                     st_stateid;
-       struct file                   st_vfs_file;
+       struct file                 * st_vfs_file;
        int                           st_vfs_set;
        unsigned long                 st_access_bmap;
        unsigned long                 st_deny_bmap;
@@ -198,8 +268,10 @@ struct nfs4_stateid {
 #define CONFIRM                 0x00000002
 #define OPEN_STATE              0x00000004
 #define LOCK_STATE              0x00000008
-#define RDWR_STATE              0x00000010
-#define CLOSE_STATE             0x00000020
+#define RD_STATE               0x00000010
+#define WR_STATE               0x00000020
+#define CLOSE_STATE             0x00000040
+#define DELEG_RET               0x00000080
 
 #define seqid_mutating_err(err)                       \
        (((err) != nfserr_stale_clientid) &&    \
@@ -210,11 +282,28 @@ struct nfs4_stateid {
 extern time_t nfs4_laundromat(void);
 extern int nfsd4_renew(clientid_t *clid);
 extern int nfs4_preprocess_stateid_op(struct svc_fh *current_fh, 
-               stateid_t *stateid, int flags, struct nfs4_stateid **stpp);
+               stateid_t *stateid, int flags);
 extern int nfs4_share_conflict(struct svc_fh *current_fh, 
                unsigned int deny_type);
 extern void nfs4_lock_state(void);
 extern void nfs4_unlock_state(void);
 extern int nfs4_in_grace(void);
-extern int nfs4_in_no_grace(void);
+extern int nfs4_check_open_reclaim(clientid_t *clid);
+extern void put_nfs4_client(struct nfs4_client *clp);
+extern void nfs4_free_stateowner(struct kref *kref);
+extern void nfsd4_probe_callback(struct nfs4_client *clp);
+extern int nfsd4_cb_recall(struct nfs4_delegation *dp);
+
+static inline void
+nfs4_put_stateowner(struct nfs4_stateowner *so)
+{
+       kref_put(&so->so_ref, nfs4_free_stateowner);
+}
+
+static inline void
+nfs4_get_stateowner(struct nfs4_stateowner *so)
+{
+       kref_get(&so->so_ref);
+}
+
 #endif   /* NFSD4_STATE_H */