Whamcloud - gitweb
LU-1406 ofd: add DLM and LVB code
[fs/lustre-release.git] / lustre / ofd / ofd_internal.h
index c41f992..f3a1a2c 100644 (file)
@@ -407,6 +407,14 @@ void ofd_fmd_drop(struct obd_export *exp, struct lu_fid *fid);
 #define ofd_fmd_drop(exp, fid) do {} while (0)
 #endif
 
+/* ofd_lvb.c */
+extern struct ldlm_valblock_ops ofd_lvbo;
+
+/* ofd_dlm.c */
+int ofd_intent_policy(struct ldlm_namespace *ns, struct ldlm_lock **lockp,
+                     void *req_cookie, ldlm_mode_t mode, int flags,
+                     void *data);
+
 static inline struct ofd_thread_info * ofd_info(const struct lu_env *env)
 {
        struct ofd_thread_info *info;
@@ -437,6 +445,39 @@ static inline struct ofd_thread_info * ofd_info_init(const struct lu_env *env,
        return info;
 }
 
+/* The same as osc_build_res_name() */
+static inline void ofd_build_resid(const struct lu_fid *fid,
+                                  struct ldlm_res_id *resname)
+{
+       if (fid_is_idif(fid)) {
+               /* get id/seq like ostid_idif_pack() does */
+               osc_build_res_name(fid_idif_id(fid_seq(fid), fid_oid(fid),
+                                              fid_ver(fid)),
+                                  FID_SEQ_OST_MDT0, resname);
+       } else {
+               /* In the future, where OSTs have FID sequences allocated. */
+               fid_build_reg_res_name(fid, resname);
+       }
+}
+
+static inline void ofd_fid_from_resid(struct lu_fid *fid,
+                                     const struct ldlm_res_id *name)
+{
+       /* if seq is FID_SEQ_OST_MDT0 then we have IDIF and resid was built
+        * using osc_build_res_name function. */
+       if (fid_seq_is_mdt0(name->name[LUSTRE_RES_ID_VER_OID_OFF])) {
+               struct ost_id ostid;
+
+               ostid.oi_id = name->name[LUSTRE_RES_ID_SEQ_OFF];
+               ostid.oi_seq = name->name[LUSTRE_RES_ID_VER_OID_OFF];
+               fid_ostid_unpack(fid, &ostid, 0);
+       } else {
+               fid->f_seq = name->name[LUSTRE_RES_ID_SEQ_OFF];
+               fid->f_oid = (__u32)name->name[LUSTRE_RES_ID_VER_OID_OFF];
+               fid->f_ver = name->name[LUSTRE_RES_ID_VER_OID_OFF] >> 32;
+       }
+}
+
 /* sync on lock cancel is useless when we force a journal flush,
  * and if we enable async journal commit, we should also turn on
  * sync on lock cancel if it is not enabled already. */