Whamcloud - gitweb
LU-3430 nrs: Fix a race condition in the ORR policy
[fs/lustre-release.git] / lustre / include / lu_target.h
index 66e6f76..f87f8ce 100644 (file)
@@ -39,6 +39,7 @@
 
 #include <dt_object.h>
 #include <lustre_export.h>
+#include <lustre_update.h>
 #include <lustre_disk.h>
 
 struct lu_target {
@@ -98,6 +99,8 @@ struct tgt_session_info {
         */
        int                      tsi_reply_fail_id;
        int                      tsi_request_fail_id;
+
+       __u32                    tsi_has_trans:1; /* has txn already? */
 };
 
 static inline struct tgt_session_info *tgt_ses_info(const struct lu_env *env)
@@ -177,6 +180,12 @@ static inline __u64 tgt_conn_flags(struct tgt_session_info *tsi)
        return exp_connect_flags(tsi->tsi_exp);
 }
 
+static inline int req_is_replay(struct ptlrpc_request *req)
+{
+       LASSERT(req->rq_reqmsg);
+       return !!(lustre_msg_get_flags(req->rq_reqmsg) & MSG_REPLAY);
+}
+
 /* target/tgt_handler.c */
 int tgt_request_handle(struct ptlrpc_request *req);
 char *tgt_name(struct lu_target *tgt);
@@ -200,6 +209,14 @@ int tgt_sec_ctx_init(struct tgt_session_info *tsi);
 int tgt_sec_ctx_init_cont(struct tgt_session_info *tsi);
 int tgt_sec_ctx_fini(struct tgt_session_info *tsi);
 
+extern struct tgt_handler tgt_sec_ctx_handlers[];
+extern struct tgt_handler tgt_obd_handlers[];
+extern struct tgt_handler tgt_dlm_handlers[];
+extern struct tgt_handler tgt_llog_handlers[];
+extern struct tgt_handler tgt_out_handlers[];
+extern struct tgt_handler fld_handlers[];
+extern struct tgt_handler seq_handlers[];
+
 typedef void (*tgt_cb_t)(struct lu_target *lut, __u64 transno,
                         void *data, int err);
 struct tgt_commit_cb {
@@ -229,9 +246,13 @@ int tgt_client_data_write(const struct lu_env *env, struct lu_target *tg,
 int tgt_server_data_read(const struct lu_env *env, struct lu_target *tg);
 int tgt_server_data_write(const struct lu_env *env, struct lu_target *tg,
                          struct thandle *th);
-int tgt_server_data_update(const struct lu_env *env, struct lu_target *tg, int sync);
-int tgt_truncate_last_rcvd(const struct lu_env *env, struct lu_target *tg, loff_t off);
-
+int tgt_server_data_update(const struct lu_env *env, struct lu_target *tg,
+                          int sync);
+int tgt_truncate_last_rcvd(const struct lu_env *env, struct lu_target *tg,
+                          loff_t off);
+int tgt_last_rcvd_update(const struct lu_env *env, struct lu_target *tgt,
+                        struct dt_object *obj, __u64 opdata,
+                        struct thandle *th, struct ptlrpc_request *req);
 enum {
        ESERIOUS = 0x0001000
 };
@@ -268,46 +289,77 @@ static inline int is_serious(int rc)
        .th_version     = version                                       \
 }
 
+/* MDT Request with a format known in advance */
+#define TGT_MDT_HDL(flags, name, fn)                                   \
+       TGT_RPC_HANDLER(MDS_FIRST_OPC, flags, name, fn, &RQF_ ## name,  \
+                       LUSTRE_MDS_VERSION)
+/* Request with a format we do not yet know */
+#define TGT_MDT_HDL_VAR(flags, name, fn)                               \
+       TGT_RPC_HANDLER(MDS_FIRST_OPC, flags, name, fn, NULL,           \
+                       LUSTRE_MDS_VERSION)
+
 /* MGS request with a format known in advance */
 #define TGT_MGS_HDL(flags, name, fn)                                   \
-       TGT_RPC_HANDLER(MGS_FIRST_OPC, flags, name, fn, &RQF_ ## name,\
-                          LUSTRE_MGS_VERSION)
+       TGT_RPC_HANDLER(MGS_FIRST_OPC, flags, name, fn, &RQF_ ## name,  \
+                       LUSTRE_MGS_VERSION)
 #define TGT_MGS_HDL_VAR(flags, name, fn)                               \
-       TGT_RPC_HANDLER(MGS_FIRST_OPC, flags, name, fn, NULL,   \
-                          LUSTRE_MGS_VERSION)
+       TGT_RPC_HANDLER(MGS_FIRST_OPC, flags, name, fn, NULL,           \
+                       LUSTRE_MGS_VERSION)
 
 /*
  * OBD handler macros and generic functions.
  */
 #define TGT_OBD_HDL(flags, name, fn)                                   \
-       TGT_RPC_HANDLER(OBD_FIRST_OPC, flags, name, fn, &RQF_ ## name,\
-                          LUSTRE_OBD_VERSION)
+       TGT_RPC_HANDLER(OBD_FIRST_OPC, flags, name, fn, &RQF_ ## name,  \
+                       LUSTRE_OBD_VERSION)
+#define TGT_OBD_HDL_VAR(flags, name, fn)                               \
+       TGT_RPC_HANDLER(OBD_FIRST_OPC, flags, name, fn, NULL,           \
+                       LUSTRE_OBD_VERSION)
 
 /*
  * DLM handler macros and generic functions.
  */
 #define TGT_DLM_HDL_VAR(flags, name, fn)                               \
-       TGT_RPC_HANDLER(LDLM_FIRST_OPC, flags, name, fn, NULL,  \
-                          LUSTRE_DLM_VERSION)
+       TGT_RPC_HANDLER(LDLM_FIRST_OPC, flags, name, fn, NULL,          \
+                       LUSTRE_DLM_VERSION)
 #define TGT_DLM_HDL(flags, name, fn)                                   \
-       TGT_RPC_HANDLER(LDLM_FIRST_OPC, flags, name, fn, &RQF_ ## name,\
-                          LUSTRE_DLM_VERSION)
+       TGT_RPC_HANDLER(LDLM_FIRST_OPC, flags, name, fn, &RQF_ ## name, \
+                       LUSTRE_DLM_VERSION)
 
 /*
  * LLOG handler macros and generic functions.
  */
 #define TGT_LLOG_HDL_VAR(flags, name, fn)                              \
-       TGT_RPC_HANDLER(LLOG_FIRST_OPC, flags, name, fn, NULL,  \
-                          LUSTRE_LOG_VERSION)
+       TGT_RPC_HANDLER(LLOG_FIRST_OPC, flags, name, fn, NULL,          \
+                       LUSTRE_LOG_VERSION)
 #define TGT_LLOG_HDL(flags, name, fn)                                  \
-       TGT_RPC_HANDLER(LLOG_FIRST_OPC, flags, name, fn, &RQF_ ## name,\
-                          LUSTRE_LOG_VERSION)
+       TGT_RPC_HANDLER(LLOG_FIRST_OPC, flags, name, fn, &RQF_ ## name, \
+                       LUSTRE_LOG_VERSION)
 
 /*
  * Sec context handler macros and generic functions.
  */
 #define TGT_SEC_HDL_VAR(flags, name, fn)                               \
-       TGT_RPC_HANDLER(SEC_FIRST_OPC, flags, name, fn, NULL,   \
-                          LUSTRE_OBD_VERSION)
+       TGT_RPC_HANDLER(SEC_FIRST_OPC, flags, name, fn, NULL,           \
+                       LUSTRE_OBD_VERSION)
+
+#define TGT_QUOTA_HDL(flags, name, fn)                                 \
+       TGT_RPC_HANDLER(QUOTA_DQACQ, flags, name, fn, &RQF_ ## name,    \
+                       LUSTRE_MDS_VERSION)
+
+/* Sequence service handlers */
+#define TGT_SEQ_HDL(flags, name, fn)                                   \
+       TGT_RPC_HANDLER(SEQ_QUERY, flags, name, fn, &RQF_ ## name,      \
+                       LUSTRE_MDS_VERSION)
+
+/* FID Location Database handlers */
+#define TGT_FLD_HDL(flags, name, fn)                                   \
+       TGT_RPC_HANDLER(FLD_QUERY, flags, name, fn, &RQF_ ## name,      \
+                       LUSTRE_MDS_VERSION)
+
+/* Request with a format known in advance */
+#define TGT_UPDATE_HDL(flags, name, fn)                                        \
+       TGT_RPC_HANDLER(UPDATE_OBJ, flags, name, fn, &RQF_ ## name,     \
+                       LUSTRE_MDS_VERSION)
 
 #endif /* __LUSTRE_LU_TARGET_H */