+/* context key constructor/destructor: ofd_key_init(), ofd_key_fini() */
+LU_KEY_INIT_FINI(ofd, struct ofd_thread_info);
+
+/**
+ * Implementation of lu_context_key::lct_key_exit.
+ *
+ * Optional method called on lu_context_exit() for all allocated
+ * keys.
+ * It is used in OFD to sanitize context values which may be re-used
+ * during another request processing by the same thread.
+ *
+ * \param[in] ctx execution context
+ * \param[in] key context key
+ * \param[in] data ofd_thread_info
+ */
+static void ofd_key_exit(const struct lu_context *ctx,
+ struct lu_context_key *key, void *data)
+{
+ struct ofd_thread_info *info = data;
+
+ info->fti_env = NULL;
+ info->fti_exp = NULL;
+
+ info->fti_xid = 0;
+ info->fti_pre_version = 0;
+ info->fti_used = 0;
+
+ memset(&info->fti_attr, 0, sizeof info->fti_attr);
+}
+
+struct lu_context_key ofd_thread_key = {
+ .lct_tags = LCT_DT_THREAD,
+ .lct_init = ofd_key_init,
+ .lct_fini = ofd_key_fini,
+ .lct_exit = ofd_key_exit
+};
+
+/**
+ * Initialize OFD device according to parameters in the config log \a cfg.
+ *
+ * This is the main starting point of OFD initialization. It fills all OFD
+ * parameters with their initial values and calls other initializing functions
+ * to set up all OFD subsystems.
+ *
+ * \param[in] env execution environment
+ * \param[in] m OFD device
+ * \param[in] ldt LU device type of OFD
+ * \param[in] cfg configuration log
+ *
+ * \retval 0 if successful
+ * \retval negative value on error
+ */