Whamcloud - gitweb
LU-9312 hsm: add a cookie indexed request hash
[fs/lustre-release.git] / lustre / mdt / mdt_internal.h
index 060303d..89d89ac 100644 (file)
@@ -23,7 +23,7 @@
  * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
  * Use is subject to license terms.
  *
- * Copyright (c) 2011, 2015, Intel Corporation.
+ * Copyright (c) 2011, 2016, Intel Corporation.
  */
 /*
  * This file is part of Lustre, http://www.lustre.org/
@@ -44,7 +44,8 @@
 #ifndef _MDT_INTERNAL_H
 #define _MDT_INTERNAL_H
 
-
+#include <libcfs/libcfs.h>
+#include <libcfs/libcfs_hash.h>
 #include <upcall_cache.h>
 #include <lustre_net.h>
 #include <lustre/lustre_idl.h>
@@ -105,7 +106,8 @@ enum cdt_states { CDT_STOPPED = 0,
  * cdt_request_lock
  */
 struct coordinator {
-       struct ptlrpc_thread     cdt_thread;         /**< coordinator thread */
+       wait_queue_head_t        cdt_waitq;          /**< cdt wait queue */
+       unsigned int             cdt_flags;          /**< cdt event flags */
        struct lu_env            cdt_env;            /**< coordinator lustre
                                                      * env */
        struct lu_context        cdt_session;        /** session for lu_ucred */
@@ -134,8 +136,11 @@ struct coordinator {
                                                       * requests */
        atomic_t                 cdt_request_count;   /**< current count of
                                                       * started requests */
-       struct list_head         cdt_requests;        /**< list of started
-                                                      * requests */
+       /* started requests (struct cdt_agent_req:car_cookie_hash)
+        * indexed by cookie */
+       struct cfs_hash         *cdt_request_cookie_hash;
+       /* started requests (struct cdt_agent_req:car_request_list) */
+       struct list_head         cdt_request_list;
        struct list_head         cdt_agents;          /**< list of register
                                                       * agents */
        struct list_head         cdt_restore_hdl;     /**< list of restore lock
@@ -453,6 +458,7 @@ struct cdt_req_progress {
 };
 
 struct cdt_agent_req {
+       struct hlist_node        car_cookie_hash;  /**< find req by cookie */
        struct list_head         car_request_list; /**< to chain all the req. */
        atomic_t                 car_refcount;     /**< reference counter */
        __u64                    car_compound_id;  /**< compound id */
@@ -637,6 +643,7 @@ int mdt_name_unpack(struct req_capsule *pill,
                    enum mdt_name_flags flags);
 int mdt_close_unpack(struct mdt_thread_info *info);
 int mdt_reint_unpack(struct mdt_thread_info *info, __u32 op);
+void mdt_fix_lov_magic(struct mdt_thread_info *info, void *eadata);
 int mdt_reint_rec(struct mdt_thread_info *, struct mdt_lock_handle *);
 #ifdef CONFIG_FS_POSIX_ACL
 int mdt_pack_acl2body(struct mdt_thread_info *info, struct mdt_body *repbody,
@@ -824,11 +831,10 @@ int mdt_hsm_add_actions(struct mdt_thread_info *info,
                        struct hsm_action_list *hal);
 int mdt_hsm_get_actions(struct mdt_thread_info *mti,
                        struct hsm_action_list *hal);
-int mdt_hsm_get_running(struct mdt_thread_info *mti,
-                       struct hsm_action_list *hal);
 bool mdt_hsm_restore_is_running(struct mdt_thread_info *mti,
                                const struct lu_fid *fid);
 /* mdt/mdt_hsm_cdt_requests.c */
+extern struct cfs_hash_ops cdt_request_cookie_hash_ops;
 extern const struct file_operations mdt_hsm_active_requests_fops;
 void dump_requests(char *prefix, struct coordinator *cdt);
 struct cdt_agent_req *mdt_cdt_alloc_request(__u64 compound_id, __u32 archive_id,
@@ -836,9 +842,7 @@ struct cdt_agent_req *mdt_cdt_alloc_request(__u64 compound_id, __u32 archive_id,
                                            struct hsm_action_item *hai);
 void mdt_cdt_free_request(struct cdt_agent_req *car);
 int mdt_cdt_add_request(struct coordinator *cdt, struct cdt_agent_req *new_car);
-struct cdt_agent_req *mdt_cdt_find_request(struct coordinator *cdt,
-                                          const __u64 cookie,
-                                          const struct lu_fid *fid);
+struct cdt_agent_req *mdt_cdt_find_request(struct coordinator *cdt, u64 cookie);
 void mdt_cdt_get_work_done(struct cdt_agent_req *car, __u64 *done_sz);
 void mdt_cdt_get_request(struct cdt_agent_req *car);
 void mdt_cdt_put_request(struct cdt_agent_req *car);
@@ -907,6 +911,14 @@ static inline struct mdt_device *mdt_exp2dev(struct obd_export *exp)
        return mdt_dev(exp->exp_obd->obd_lu_dev);
 }
 
+static inline bool mdt_rdonly(struct obd_export *exp)
+{
+       if (exp_connect_flags(exp) & OBD_CONNECT_RDONLY ||
+           mdt_exp2dev(exp)->mdt_bottom->dd_rdonly)
+               return true;
+       return false;
+}
+
 typedef void (*mdt_reconstruct_t)(struct mdt_thread_info *mti,
                                   struct mdt_lock_handle *lhc);
 static inline int mdt_check_resent(struct mdt_thread_info *info,
@@ -978,15 +990,17 @@ static inline bool mdt_slc_is_enabled(struct mdt_device *mdt)
 extern mdl_mode_t mdt_mdl_lock_modes[];
 extern enum ldlm_mode mdt_dlm_lock_modes[];
 
+/* LCK_MINMODE which is zero returns false for is_power_of_2 */
+
 static inline mdl_mode_t mdt_dlm_mode2mdl_mode(enum ldlm_mode mode)
 {
-       LASSERT(IS_PO2(mode));
+       LASSERT(mode == LCK_MINMODE || is_power_of_2(mode));
        return mdt_mdl_lock_modes[mode];
 }
 
 static inline enum ldlm_mode mdt_mdl_mode2dlm_mode(mdl_mode_t mode)
 {
-       LASSERT(IS_PO2(mode));
+       LASSERT(mode == MDL_MINMODE || is_power_of_2(mode));
        return mdt_dlm_lock_modes[mode];
 }