+#ifdef OSD_TRACK_DECLARES
+extern int osd_trans_declare_op2rb[];
+
+static inline void osd_trans_declare_op(const struct lu_env *env,
+ struct osd_thandle *oh,
+ unsigned int op, int credits)
+{
+ struct osd_thread_info *oti = osd_oti_get(env);
+
+ LASSERT(oh->ot_handle == NULL);
+ LASSERT(op < OSD_OT_MAX);
+
+ oti->oti_declare_ops[op]++;
+ oti->oti_declare_ops_cred[op] += credits;
+ oh->ot_credits += credits;
+}
+
+static inline void osd_trans_exec_op(const struct lu_env *env,
+ struct thandle *th, unsigned int op)
+{
+ struct osd_thread_info *oti = osd_oti_get(env);
+ struct osd_thandle *oh = container_of(th, struct osd_thandle,
+ ot_super);
+ unsigned int rb;
+
+ LASSERT(oh->ot_handle != NULL);
+ LASSERT(op < OSD_OT_MAX);
+
+ if (likely(!oti->oti_rollback && oti->oti_declare_ops[op] > 0)) {
+ oti->oti_declare_ops[op]--;
+ oti->oti_declare_ops_rb[op]++;
+ } else {
+ /* all future updates are considered rollback */
+ oti->oti_rollback = true;
+ rb = osd_trans_declare_op2rb[op];
+ LASSERTF(rb < OSD_OT_MAX, "op = %u\n", op);
+ LASSERTF(oti->oti_declare_ops_rb[rb] > 0, "rb = %u\n", rb);
+ oti->oti_declare_ops_rb[rb]--;
+ }
+}
+
+static inline void osd_trans_declare_rb(const struct lu_env *env,
+ struct thandle *th, unsigned int op)
+{
+ struct osd_thread_info *oti = osd_oti_get(env);
+ struct osd_thandle *oh = container_of(th, struct osd_thandle,
+ ot_super);
+
+ LASSERT(oh->ot_handle != NULL);
+ LASSERT(op < OSD_OT_MAX);
+
+ oti->oti_declare_ops_rb[op]++;
+}
+#else
+static inline void osd_trans_declare_op(const struct lu_env *env,
+ struct osd_thandle *oh,
+ unsigned int op, int credits)
+{
+ oh->ot_credits += credits;
+}
+
+static inline void osd_trans_exec_op(const struct lu_env *env,
+ struct thandle *th, unsigned int op)
+{
+}
+
+static inline void osd_trans_declare_rb(const struct lu_env *env,
+ struct thandle *th, unsigned int op)
+{
+}
+#endif
+