#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>
#include <obd_class.h>
#include <lustre_disk.h>
*/
#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
*/
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
* 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 */
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;
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
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;
};
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 */
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);
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,
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,
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);
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;
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,
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);
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,
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,
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,
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];
}