Whamcloud - gitweb
LU-6142 mdt: remove unused field mti_wait_info.
[fs/lustre-release.git] / lustre / mdt / mdt_internal.h
index b0f4430..e81c671 100644 (file)
@@ -66,6 +66,8 @@ struct mdt_object;
 struct mdt_file_data {
        /**  portals handle must be first */
        struct portals_handle   mfd_open_handle;
+       /* export data of portals_handle */
+       const struct mdt_export_data    *mfd_owner;
        /** open mode provided by client */
        u64                     mfd_open_flags;
        /** protected by med_open_lock */
@@ -132,7 +134,9 @@ struct coordinator {
        struct lu_env            cdt_env;            /**< coordinator lustre
                                                      * env */
        struct lu_context        cdt_session;        /** session for lu_ucred */
-       struct proc_dir_entry   *cdt_proc_dir;       /**< cdt /proc directory */
+       struct dentry           *cdt_debugfs_dir;       /**< cdt debugfs directory */
+       struct completion        cdt_kobj_unregister;
+       struct kobject           cdt_hsm_kobj;          /* hsm sysfs object */
        __u64                    cdt_policy;         /**< policy flags */
        enum cdt_states          cdt_state;           /**< state */
        struct mutex             cdt_state_lock;      /**< cdt_state lock */
@@ -145,14 +149,14 @@ struct coordinator {
                                                       * list */
        struct mutex             cdt_restore_lock;    /**< protect restore
                                                       * list */
-       time64_t                 cdt_loop_period;     /**< llog scan period */
-       time64_t                 cdt_grace_delay;     /**< request grace
+       time_t                   cdt_loop_period;     /**< llog scan period */
+       time_t                   cdt_grace_delay;     /**< request grace
                                                       * delay */
-       time64_t                 cdt_active_req_timeout; /**< request timeout */
+       time_t                   cdt_active_req_timeout; /**< request timeout */
        __u32                    cdt_default_archive_id; /**< archive id used
                                                       * when none are
                                                       * specified */
-       __u64                    cdt_max_requests;    /**< max count of started
+       u64                      cdt_max_requests;    /**< max count of started
                                                       * requests */
        /** Current count of active requests */
        atomic_t                 cdt_request_count;   /** total */
@@ -378,93 +382,92 @@ enum mdt_reint_flag {
  * reduce stack consumption.
  */
 struct mdt_thread_info {
-        /*
-         * XXX: Part One:
-         * The following members will be filled explicitly
-         * with specific data in mdt_thread_info_init().
-         */
-        /* TODO: move this into mdt_session_key(with LCT_SESSION), because
-         * request handling may migrate from one server thread to another.
-         */
-        struct req_capsule        *mti_pill;
-
-        /* although we have export in req, there are cases when it is not
-         * available, e.g. closing files upon export destroy */
-        struct obd_export          *mti_exp;
-        /*
-         * A couple of lock handles.
-         */
-        struct mdt_lock_handle     mti_lh[MDT_LH_NR];
-
-        struct mdt_device         *mti_mdt;
-        const struct lu_env       *mti_env;
-
-        /* transaction number of current request */
-        __u64                      mti_transno;
-
-
-        /*
-         * XXX: Part Two:
-         * The following members will be filled expilictly
-         * with zero in mdt_thread_info_init(). These members may be used
-         * by all requests.
-         */
-
-        /*
-         * Object attributes.
-         */
+       /*
+        * XXX: Part One:
+        * The following members will be filled explicitly
+        * with specific data in mdt_thread_info_init().
+        */
+       /* TODO: move this into mdt_session_key(with LCT_SESSION), because
+        * request handling may migrate from one server thread to another.
+        */
+       struct req_capsule        *mti_pill;
+
+       /* although we have export in req, there are cases when it is not
+        * available, e.g. closing files upon export destroy */
+       struct obd_export          *mti_exp;
+       /*
+        * A couple of lock handles.
+        */
+       struct mdt_lock_handle     mti_lh[MDT_LH_NR];
+
+       struct mdt_device         *mti_mdt;
+       const struct lu_env       *mti_env;
+
+       /* transaction number of current request */
+       __u64                      mti_transno;
+
+       /*
+        * XXX: Part Two:
+        * The following members will be filled expilictly
+        * with zero in mdt_thread_info_init(). These members may be used
+        * by all requests.
+        */
+
+       /*
+        * Object attributes.
+        */
        struct md_attr             mti_attr;
        struct md_attr             mti_attr2; /* mdt_lvb.c */
-        /*
-         * Body for "habeo corpus" operations.
-         */
-        const struct mdt_body     *mti_body;
-        /*
-         * Host object. This is released at the end of mdt_handler().
-         */
-        struct mdt_object         *mti_object;
-        /*
-         * Lock request for "habeo clavis" operations.
-         */
-        const struct ldlm_request *mti_dlm_req;
-
-        __u32                      mti_has_trans:1, /* has txn already? */
+       /*
+        * Body for "habeo corpus" operations.
+        */
+       const struct mdt_body     *mti_body;
+       /*
+        * Host object. This is released at the end of mdt_handler().
+        */
+       struct mdt_object         *mti_object;
+       /*
+        * Lock request for "habeo clavis" operations.
+        */
+       const struct ldlm_request *mti_dlm_req;
+
+       __u32                      mti_has_trans:1, /* has txn already? */
                                   mti_cross_ref:1,
        /* big_lmm buffer was used and must be used in reply */
                                   mti_big_lmm_used:1,
                                   mti_big_acl_used:1,
                                   mti_som_valid:1;
 
-        /* opdata for mdt_reint_open(), has the same as
-         * ldlm_reply:lock_policy_res1.  mdt_update_last_rcvd() stores this
-         * value onto disk for recovery when mdt_trans_stop_cb() is called.
-         */
-        __u64                      mti_opdata;
-
-        /*
-         * XXX: Part Three:
-         * The following members will be filled explicitly
-         * with zero in mdt_reint_unpack(), because they are only used
-         * by reint requests (including mdt_reint_open()).
-         */
-
-        /*
-         * reint record. contains information for reint operations.
-         */
-        struct mdt_reint_record    mti_rr;
-
-        __u64                      mti_ver[PTLRPC_NUM_VERSIONS];
-        /*
-         * Operation specification (currently create and lookup)
-         */
-        struct md_op_spec          mti_spec;
-
-        /*
-         * XXX: Part Four:
-         * The following members will _NOT_ be initialized at all.
-         * DO NOT expect them to contain any valid value.
-         * They should be initialized explicitly by the user themselves.
-         */
+       /* opdata for mdt_reint_open(), has the same as
+        * ldlm_reply:lock_policy_res1.  mdt_update_last_rcvd() stores this
+        * value onto disk for recovery when mdt_trans_stop_cb() is called.
+        */
+       __u64                      mti_opdata;
+
+       /*
+        * XXX: Part Three:
+        * The following members will be filled explicitly
+        * with zero in mdt_reint_unpack(), because they are only used
+        * by reint requests (including mdt_reint_open()).
+        */
+
+       /*
+        * reint record. contains information for reint operations.
+        */
+       struct mdt_reint_record    mti_rr;
+
+       __u64                      mti_ver[PTLRPC_NUM_VERSIONS];
+       /*
+        * Operation specification (currently create and lookup)
+        */
+       struct md_op_spec          mti_spec;
+
+       /*
+        * XXX: Part Four:
+        * The following members will _NOT_ be initialized at all.
+        * DO NOT expect them to contain any valid value.
+        * They should be initialized explicitly by the user themselves.
+        */
 
        /* XXX: If something is in a union, make sure they do not conflict */
        struct lu_fid                   mti_tmp_fid1;
@@ -476,12 +479,10 @@ struct mdt_thread_info {
                char                    ns_name[48];/* for mdt_init0()        */
                struct lustre_cfg_bufs  bufs;       /* for mdt_stack_fini()   */
                struct obd_statfs       osfs;       /* for mdt_statfs()       */
-                struct {
-                        /* for mdt_readpage()      */
-                        struct lu_rdpg     mti_rdpg;
-                        /* for mdt_sendpage()      */
-                        struct l_wait_info mti_wait_info;
-                } rdpg;
+               struct {
+                       /* for mdt_readpage()      */
+                       struct lu_rdpg     mti_rdpg;
+               } rdpg;
                struct {
                        struct md_attr attr;
                } hsm;
@@ -495,8 +496,8 @@ struct mdt_thread_info {
        struct lu_buf              mti_buf;
        struct lu_buf              mti_big_buf;
 
-        /* Ops object filename */
-        struct lu_name             mti_name;
+       /* Ops object filename */
+       struct lu_name             mti_name;
        char                       mti_filename[NAME_MAX + 1];
        /* per-thread values, can be re-used, may be vmalloc'd */
        void                      *mti_big_lmm;
@@ -672,6 +673,7 @@ static inline int mdt_lmm_dom_entry(struct lov_mds_md *lmm)
        struct lov_comp_md_v1 *comp_v1;
        struct lov_mds_md *v1;
        __u32 off;
+       bool has_dom = true;
        int i;
 
        if (le32_to_cpu(lmm->lmm_magic) != LOV_MAGIC_COMP_V1)
@@ -682,15 +684,20 @@ static inline int mdt_lmm_dom_entry(struct lov_mds_md *lmm)
        v1 = (struct lov_mds_md *)((char *)comp_v1 + off);
 
        /* DoM entry is the first entry always */
-       if (lov_pattern(le32_to_cpu(v1->lmm_pattern)) != LOV_PATTERN_MDT)
+       if (lov_pattern(le32_to_cpu(v1->lmm_pattern)) != LOV_PATTERN_MDT &&
+           le16_to_cpu(comp_v1->lcm_mirror_count) == 0)
                return LMM_NO_DOM;
 
-       for (i = 1; i < le16_to_cpu(comp_v1->lcm_entry_count); i++) {
+       for (i = 0; i < le16_to_cpu(comp_v1->lcm_entry_count); i++) {
                int j;
 
                off = le32_to_cpu(comp_v1->lcm_entries[i].lcme_offset);
                v1 = (struct lov_mds_md *)((char *)comp_v1 + off);
 
+               if (lov_pattern(le32_to_cpu(v1->lmm_pattern)) ==
+                   LOV_PATTERN_MDT)
+                       has_dom = true;
+
                for (j = 0; j < le16_to_cpu(v1->lmm_stripe_count); j++) {
                        /* if there is any object on OST */
                        if (le32_to_cpu(v1->lmm_objects[j].l_ost_idx) !=
@@ -698,7 +705,7 @@ static inline int mdt_lmm_dom_entry(struct lov_mds_md *lmm)
                                return LMM_DOM_OST;
                }
        }
-       return LMM_DOM_ONLY;
+       return has_dom ? LMM_DOM_ONLY : LMM_NO_DOM;
 }
 
 static inline bool mdt_lmm_is_flr(struct lov_mds_md *lmm)
@@ -709,6 +716,43 @@ static inline bool mdt_lmm_is_flr(struct lov_mds_md *lmm)
               le16_to_cpu(lcm->lcm_mirror_count) > 0;
 }
 
+static inline bool lmm_is_overstriping(struct lov_mds_md *lmm)
+{
+       if (le32_to_cpu(lmm->lmm_magic) == LOV_MAGIC_V1 ||
+           le32_to_cpu(lmm->lmm_magic) == LOV_MAGIC_V3)
+               return le16_to_cpu(lmm->lmm_pattern) & LOV_PATTERN_OVERSTRIPING;
+
+       return false;
+}
+
+static inline bool mdt_lmm_comp_overstriping(struct lov_mds_md *lmm)
+{
+       struct lov_comp_md_v1 *comp_v1;
+       struct lov_mds_md *v1;
+       __u32 off;
+       int i;
+
+       comp_v1 = (struct lov_comp_md_v1 *)lmm;
+
+       for (i = 1; i < le16_to_cpu(comp_v1->lcm_entry_count); i++) {
+               off = le32_to_cpu(comp_v1->lcm_entries[i].lcme_offset);
+               v1 = (struct lov_mds_md *)((char *)comp_v1 + off);
+
+               if (lmm_is_overstriping(v1))
+                       return true;
+       }
+
+       return false;
+}
+
+static inline bool mdt_lmm_is_overstriping(struct lov_mds_md *lmm)
+{
+       if (le32_to_cpu(lmm->lmm_magic) == LOV_MAGIC_COMP_V1)
+               return mdt_lmm_comp_overstriping(lmm);
+
+       return lmm_is_overstriping(lmm);
+}
+
 static inline bool mdt_is_sum_statfs_client(struct obd_export *exp)
 {
        return exp_connect_flags(exp) & OBD_CONNECT_FLAGS2 &&
@@ -889,6 +933,7 @@ int mdt_intent_lock_replace(struct mdt_thread_info *info,
                            struct mdt_lock_handle *lh,
                            __u64 flags, int result);
 
+int hsm_init_ucred(struct lu_ucred *uc);
 int mdt_hsm_attr_set(struct mdt_thread_info *info, struct mdt_object *obj,
                     const struct md_hsm *mh);
 
@@ -1041,14 +1086,13 @@ static inline void mdt_hsm_cdt_event(struct coordinator *cdt)
        cdt->cdt_event = true;
 }
 
-/* coordinator control /proc interface */
-ssize_t mdt_hsm_cdt_control_seq_write(struct file *file,
-                                     const char __user *buffer,
-                                     size_t count, loff_t *off);
-int mdt_hsm_cdt_control_seq_show(struct seq_file *m, void *data);
-int hsm_cdt_procfs_init(struct mdt_device *mdt);
-void hsm_cdt_procfs_fini(struct mdt_device *mdt);
-struct lprocfs_vars *hsm_cdt_get_proc_vars(void);
+/* coordinator control sysfs interface */
+ssize_t hsm_control_show(struct kobject *kobj, struct attribute *attr,
+                        char *buf);
+ssize_t hsm_control_store(struct kobject *kobj, struct attribute *attr,
+                         const char *buffer, size_t count);
+int hsm_cdt_tunables_init(struct mdt_device *mdt);
+void hsm_cdt_tunables_fini(struct mdt_device *mdt);
 /* md_hsm helpers */
 struct mdt_object *mdt_hsm_get_md_hsm(struct mdt_thread_info *mti,
                                      const struct lu_fid *fid,
@@ -1203,9 +1247,8 @@ int mdt_lsom_update(struct mdt_thread_info *info, struct mdt_object *obj,
 /* mdt_lvb.c */
 extern struct ldlm_valblock_ops mdt_lvbo;
 int mdt_dom_lvb_is_valid(struct ldlm_resource *res);
-int mdt_dom_lvbo_update(const struct lu_env *env, struct ldlm_resource *res,
-                       struct ldlm_lock *lock, struct ptlrpc_request *req,
-                       bool increase_only);
+int mdt_dom_lvbo_update(struct ldlm_resource *res, struct ldlm_lock *lock,
+                       struct ptlrpc_request *req, bool increase_only);
 
 void mdt_enable_cos(struct mdt_device *dev, bool enable);
 int mdt_cos_is_enabled(struct mdt_device *);
@@ -1236,8 +1279,8 @@ enum mdt_stat_idx {
 
 void mdt_counter_incr(struct ptlrpc_request *req, int opcode);
 void mdt_stats_counter_init(struct lprocfs_stats *stats);
-int mdt_procfs_init(struct mdt_device *mdt, const char *name);
-void mdt_procfs_fini(struct mdt_device *mdt);
+int mdt_tunables_init(struct mdt_device *mdt, const char *name);
+void mdt_tunables_fini(struct mdt_device *mdt);
 
 /* lustre/mdt_mdt_lproc.c */
 int lprocfs_mdt_open_files_seq_open(struct inode *inode,
@@ -1294,8 +1337,7 @@ int mdt_brw_enqueue(struct mdt_thread_info *info, struct ldlm_namespace *ns,
                    struct ldlm_lock **lockp, __u64 flags);
 int mdt_dom_read_on_open(struct mdt_thread_info *mti, struct mdt_device *mdt,
                         struct lustre_handle *lh);
-void mdt_dom_discard_data(struct mdt_thread_info *info,
-                         const struct lu_fid *fid);
+void mdt_dom_discard_data(struct mdt_thread_info *info, struct mdt_object *mo);
 int mdt_dom_disk_lvbo_update(const struct lu_env *env, struct mdt_object *mo,
                             struct ldlm_resource *res, bool increase_only);
 void mdt_dom_obj_lvb_update(const struct lu_env *env, struct mdt_object *mo,