* Author: Yury Umanets <umka@clusterfs.com>
*/
-#ifndef __LINUX_FID_H
-#define __LINUX_FID_H
+#ifndef __LUSTRE_FID_H
+#define __LUSTRE_FID_H
/** \defgroup fid fid
*
#include <libcfs/libcfs.h>
#include <lustre/lustre_idl.h>
-#include <lustre_req_layout.h>
-#include <lustre_mdt.h>
-#include <obd.h>
-
+struct lu_env;
struct lu_site;
struct lu_context;
+struct obd_device;
+struct obd_export;
/* Whole sequences space range and zero range definitions */
extern const struct lu_seq_range LUSTRE_SEQ_SPACE_RANGE;
fid_seq(fid) == FID_SEQ_QUOTA_GLB;
}
+static inline int fid_is_name_llog(const struct lu_fid *fid)
+{
+ return fid_seq(fid) == FID_SEQ_LLOG_NAME;
+}
+
static inline int fid_is_namespace_visible(const struct lu_fid *fid)
{
const __u64 seq = fid_seq(fid);
fid_seq_is_root(seq) || fid_seq_is_dot(seq);
}
-static inline void lu_last_id_fid(struct lu_fid *fid, __u64 seq)
+static inline void lu_last_id_fid(struct lu_fid *fid, __u64 seq, __u32 ost_idx)
{
if (fid_seq_is_mdt0(seq)) {
- fid->f_seq = fid_idif_seq(0, 0);
+ fid->f_seq = fid_idif_seq(0, ost_idx);
} else {
LASSERTF(fid_seq_is_norm(seq) || fid_seq_is_echo(seq) ||
fid_seq_is_idif(seq), LPX64"\n", seq);
fid->f_ver = 0;
}
+/* seq client type */
+enum lu_cli_type {
+ LUSTRE_SEQ_METADATA = 1,
+ LUSTRE_SEQ_DATA
+};
+
enum lu_mgr_type {
LUSTRE_SEQ_SERVER,
LUSTRE_SEQ_CONTROLLER
/* Seq-server for direct talking */
struct lu_server_seq *lcs_srv;
- /* wait queue for fid allocation and update indicator */
- cfs_waitq_t lcs_waitq;
- int lcs_update;
+ /* wait queue for fid allocation and update indicator */
+ wait_queue_head_t lcs_waitq;
+ int lcs_update;
};
/* server sequence manager interface */
struct seq_server_site *lss_site;
};
-int seq_query(struct com_thread_info *info);
-int seq_handle(struct ptlrpc_request *req);
-
/* Server methods */
-int seq_server_init(struct lu_server_seq *seq,
+
+int seq_server_init(const struct lu_env *env,
+ struct lu_server_seq *seq,
struct dt_device *dev,
const char *prefix,
enum lu_mgr_type type,
- struct seq_server_site *ss,
- const struct lu_env *env);
+ struct seq_server_site *ss);
void seq_server_fini(struct lu_server_seq *seq,
const struct lu_env *env);
struct lu_seq_range *out,
const struct lu_env *env);
-int seq_server_set_cli(struct lu_server_seq *seq,
- struct lu_client_seq *cli,
- const struct lu_env *env);
+int seq_server_set_cli(const struct lu_env *env,
+ struct lu_server_seq *seq,
+ struct lu_client_seq *cli);
/* Client methods */
int seq_client_init(struct lu_client_seq *seq,
int fid_is_local(const struct lu_env *env,
struct lu_site *site, const struct lu_fid *fid);
+enum lu_cli_type;
int client_fid_init(struct obd_device *obd, struct obd_export *exp,
enum lu_cli_type type);
int client_fid_fini(struct obd_device *obd);
}
}
-static inline void ostid_res_name_to_id(struct ost_id *oi,
- struct ldlm_res_id *name)
-{
- if (fid_seq_is_mdt0(name->name[LUSTRE_RES_ID_SEQ_OFF])) {
- /* old resid */
- ostid_set_seq(oi, name->name[LUSTRE_RES_ID_VER_OID_OFF]);
- ostid_set_id(oi, name->name[LUSTRE_RES_ID_SEQ_OFF]);
- } else {
- /* new resid */
- fid_extract_from_res_name(&oi->oi_fid, name);
- }
-}
-
/**
* Return true if the resource is for the object identified by this id & group.
*/
}
static inline void ost_fid_from_resid(struct lu_fid *fid,
- const struct ldlm_res_id *name)
+ const struct ldlm_res_id *name,
+ int ost_idx)
{
if (fid_seq_is_mdt0(name->name[LUSTRE_RES_ID_VER_OID_OFF])) {
/* old resid */
struct ost_id oi;
ostid_set_seq(&oi, name->name[LUSTRE_RES_ID_VER_OID_OFF]);
ostid_set_id(&oi, name->name[LUSTRE_RES_ID_SEQ_OFF]);
- ostid_to_fid(fid, &oi, 0);
+ ostid_to_fid(fid, &oi, ost_idx);
} else {
/* new resid */
fid_extract_from_res_name(fid, name);
dst->lsr_flags = be32_to_cpu(src->lsr_flags);
}
+static inline void range_array_cpu_to_le(struct lu_seq_range_array *dst,
+ const struct lu_seq_range_array *src)
+{
+ int i;
+
+ for (i = 0; i < src->lsra_count; i++)
+ range_cpu_to_le(&dst->lsra_lsr[i], &src->lsra_lsr[i]);
+
+ dst->lsra_count = cpu_to_le32(src->lsra_count);
+}
+
+static inline void range_array_le_to_cpu(struct lu_seq_range_array *dst,
+ const struct lu_seq_range_array *src)
+{
+ int i;
+
+ dst->lsra_count = le32_to_cpu(src->lsra_count);
+ for (i = 0; i < dst->lsra_count; i++)
+ range_le_to_cpu(&dst->lsra_lsr[i], &src->lsra_lsr[i]);
+}
+
/** @} fid */
-#endif /* __LINUX_FID_H */
+#endif /* __LUSTRE_FID_H */