X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=blobdiff_plain;f=lustre%2Fmdt%2Fmdt_internal.h;h=c67d0905eb28e5f9c8714428eb3967da2ac8c16d;hp=98ce15261c7340bbd6714127543d25e61470721e;hb=cc6ef11d2f972ebc440013bddda87a536a09750c;hpb=4c90aef2f0712d8da720f6a66cd09b88df7d0573 diff --git a/lustre/mdt/mdt_internal.h b/lustre/mdt/mdt_internal.h index 98ce152..c67d090 100644 --- a/lustre/mdt/mdt_internal.h +++ b/lustre/mdt/mdt_internal.h @@ -44,9 +44,9 @@ #ifndef _MDT_INTERNAL_H #define _MDT_INTERNAL_H - +#include +#include #include -#include #include #include #include @@ -91,11 +91,33 @@ struct mdt_file_data { */ #define CDT_DEFAULT_POLICY CDT_NORETRY_ACTION +/* Coordinator states. Keep the cdt_transition table in sync. */ enum cdt_states { CDT_STOPPED = 0, CDT_INIT, CDT_RUNNING, CDT_DISABLE, - CDT_STOPPING }; + CDT_STOPPING, + + CDT_STATES_COUNT +}; + +static inline char *cdt_mdt_state2str(int state) +{ + switch (state) { + case CDT_INIT: + return "init"; + case CDT_RUNNING: + return "enabled"; + case CDT_STOPPING: + return "stopping"; + case CDT_STOPPED: + return "stopped"; + case CDT_DISABLE: + return "disabled"; + default: + return "unknown"; + } +} /* when multiple lock are needed, the lock order is * cdt_llog_lock @@ -106,18 +128,20 @@ enum cdt_states { CDT_STOPPED = 0, */ struct coordinator { wait_queue_head_t cdt_waitq; /**< cdt wait queue */ - unsigned int cdt_flags; /**< cdt event flags */ + bool cdt_event; /**< coordinator event */ + struct task_struct *cdt_task; /**< cdt thread handle */ 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 */ __u64 cdt_policy; /**< policy flags */ enum cdt_states cdt_state; /**< state */ + spinlock_t cdt_state_lock; /**< cdt_state lock */ atomic_t cdt_compound_id; /**< compound id * counter */ __u64 cdt_last_cookie; /**< last cookie * allocated */ - struct mutex cdt_llog_lock; /**< protect llog + struct rw_semaphore cdt_llog_lock; /**< protect llog * access */ struct rw_semaphore cdt_agent_lock; /**< protect agent list */ struct rw_semaphore cdt_request_lock; /**< protect request @@ -135,16 +159,27 @@ 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 * handles */ + + /* Hash of cookies to locations of record locations in agent + * request log. */ + struct cfs_hash *cdt_agent_record_hash; + /* Bitmasks indexed by the HSMA_XXX constants. */ __u64 cdt_user_request_mask; __u64 cdt_group_request_mask; __u64 cdt_other_request_mask; + + /* Remove archive on last unlink policy */ + bool cdt_remove_archive_on_last_unlink; }; /* mdt state flag bits */ @@ -173,8 +208,7 @@ struct mdt_device { unsigned int mo_user_xattr:1, mo_acl:1, mo_cos:1, - mo_evict_tgt_nids:1, - mo_coordinator:1; + mo_evict_tgt_nids:1; } mdt_opts; /* mdt state flags */ unsigned long mdt_state; @@ -358,7 +392,10 @@ struct mdt_thread_info { const struct ldlm_request *mti_dlm_req; __u32 mti_has_trans:1, /* has txn already? */ - mti_cross_ref:1; + 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; /* opdata for mdt_reint_open(), has the same as * ldlm_reply:lock_policy_res1. mdt_update_last_rcvd() stores this @@ -421,9 +458,9 @@ struct mdt_thread_info { struct lu_name mti_name; /* per-thread values, can be re-used, may be vmalloc'd */ void *mti_big_lmm; + void *mti_big_acl; int mti_big_lmmsize; - /* big_lmm buffer was used and must be used in reply */ - int mti_big_lmm_used; + int mti_big_aclsize; /* should be enough to fit lustre_mdt_attrs */ char mti_xattr_buf[128]; struct ldlm_enqueue_info mti_einfo; @@ -454,6 +491,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 */ @@ -596,11 +634,8 @@ int mdt_reint_object_lock(struct mdt_thread_info *info, struct mdt_object *o, bool cos_incompat); int mdt_object_lock_try(struct mdt_thread_info *info, struct mdt_object *mo, - struct mdt_lock_handle *lh, __u64 ibits); - -int mdt_reint_object_lock_try(struct mdt_thread_info *info, - struct mdt_object *o, struct mdt_lock_handle *lh, - __u64 ibits, bool cos_incompat); + struct mdt_lock_handle *lh, __u64 *ibits, + __u64 trybits, bool cos_incompat); void mdt_object_unlock(struct mdt_thread_info *info, struct mdt_object *mo, struct mdt_lock_handle *lh, int decref); @@ -625,8 +660,7 @@ void mdt_client_compatibility(struct mdt_thread_info *info); int mdt_remote_object_lock(struct mdt_thread_info *mti, struct mdt_object *o, const struct lu_fid *fid, struct lustre_handle *lh, - enum ldlm_mode mode, __u64 ibits, bool nonblock, - bool cache); + enum ldlm_mode mode, __u64 ibits, bool cache); enum mdt_name_flags { MNF_FIX_ANON = 1, @@ -638,6 +672,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, @@ -700,7 +735,7 @@ int mdt_add_dirty_flag(struct mdt_thread_info *info, struct mdt_object *mo, struct md_attr *ma); int mdt_fix_reply(struct mdt_thread_info *info); int mdt_handle_last_unlink(struct mdt_thread_info *, struct mdt_object *, - const struct md_attr *); + struct md_attr *); void mdt_reconstruct_open(struct mdt_thread_info *, struct mdt_lock_handle *); struct lu_buf *mdt_buf(const struct lu_env *env, void *area, ssize_t len); @@ -793,13 +828,19 @@ extern const struct file_operations mdt_hsm_actions_fops; void dump_llog_agent_req_rec(const char *prefix, const struct llog_agent_req_rec *larr); int cdt_llog_process(const struct lu_env *env, struct mdt_device *mdt, - llog_cb_t cb, void *data); + llog_cb_t cb, void *data, u32 start_cat_idx, + u32 start_rec_idx, int rw); int mdt_agent_record_add(const struct lu_env *env, struct mdt_device *mdt, __u64 compound_id, __u32 archive_id, __u64 flags, struct hsm_action_item *hai); int mdt_agent_record_update(const struct lu_env *env, struct mdt_device *mdt, __u64 *cookies, int cookies_count, enum agent_req_status status); +void cdt_agent_record_hash_add(struct coordinator *cdt, u64 cookie, u32 cat_idt, + u32 rec_idx); +void cdt_agent_record_hash_lookup(struct coordinator *cdt, u64 cookie, + u32 *cat_idt, u32 *rec_idx); +void cdt_agent_record_hash_del(struct coordinator *cdt, u64 cookie); /* mdt/mdt_hsm_cdt_agent.c */ extern const struct file_operations mdt_hsm_agent_fops; @@ -825,11 +866,11 @@ 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 struct cfs_hash_ops cdt_agent_record_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, @@ -837,9 +878,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); @@ -855,7 +894,15 @@ struct cdt_restore_handle *mdt_hsm_restore_hdl_find(struct coordinator *cdt, int mdt_hsm_cdt_init(struct mdt_device *mdt); int mdt_hsm_cdt_stop(struct mdt_device *mdt); int mdt_hsm_cdt_fini(struct mdt_device *mdt); -int mdt_hsm_cdt_wakeup(struct mdt_device *mdt); + +/* + * Signal the coordinator has work to do + * \param cdt [IN] coordinator + */ +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, @@ -873,7 +920,7 @@ struct mdt_object *mdt_hsm_get_md_hsm(struct mdt_thread_info *mti, int mdt_hsm_add_hal(struct mdt_thread_info *mti, struct hsm_action_list *hal, struct obd_uuid *uuid); bool mdt_hsm_is_action_compat(const struct hsm_action_item *hai, - const int hal_an, const __u64 rq_flags, + u32 archive_id, u64 rq_flags, const struct md_hsm *hsm); int mdt_hsm_update_request_state(struct mdt_thread_info *mti, struct hsm_progress_kernel *pgs,