Whamcloud - gitweb
LU-3336 lfsck: namespace visible lost+found directory
[fs/lustre-release.git] / lustre / include / lustre_fid.h
index a048bdb..5d44838 100644 (file)
@@ -38,8 +38,8 @@
  * 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;
 extern const struct lu_seq_range LUSTRE_SEQ_ZERO_RANGE;
 extern const struct lu_fid LUSTRE_BFL_FID;
 extern const struct lu_fid LU_OBF_FID;
+extern const struct lu_fid LU_LPF_FID;
 extern const struct lu_fid LU_DOT_LUSTRE_FID;
 
 enum {
@@ -234,6 +234,7 @@ enum local_oid {
        MDD_LOV_OBJ_OSEQ        = 4121UL,
        LFSCK_NAMESPACE_OID     = 4122UL,
        REMOTE_PARENT_DIR_OID   = 4123UL,
+       SLAVE_LLOG_CATALOGS_OID = 4124UL,
 };
 
 static inline void lu_local_obj_fid(struct lu_fid *fid, __u32 oid)
@@ -290,6 +291,11 @@ static inline int fid_is_quota(const struct lu_fid *fid)
               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);
@@ -307,10 +313,10 @@ static inline int fid_seq_in_fldb(__u64 seq)
               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);
@@ -320,6 +326,12 @@ static inline void lu_last_id_fid(struct lu_fid *fid, __u64 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
@@ -364,9 +376,9 @@ struct lu_client_seq {
         /* 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 */
@@ -426,16 +438,14 @@ struct lu_server_seq {
        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);
@@ -448,9 +458,9 @@ int seq_server_alloc_meta(struct lu_server_seq *seq,
                           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,
@@ -472,6 +482,7 @@ int seq_site_fini(const struct lu_env *env, struct seq_server_site *ss);
 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);
@@ -589,19 +600,6 @@ static inline void ostid_build_res_name(struct ost_id *oi,
        }
 }
 
-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.
  */
@@ -635,14 +633,15 @@ static inline void ost_fid_build_resid(const struct lu_fid *fid,
 }
 
 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);
@@ -679,9 +678,9 @@ static inline __u64 fid_flatten(const struct lu_fid *fid)
 
 static inline __u32 fid_hash(const struct lu_fid *f, int bits)
 {
-        /* all objects with same id and different versions will belong to same
-         * collisions list. */
-        return cfs_hash_long(fid_flatten(f), bits);
+       /* all objects with same id and different versions will belong to same
+        * collisions list. */
+       return hash_long(fid_flatten(f), bits);
 }
 
 /**
@@ -758,6 +757,27 @@ static inline void range_be_to_cpu(struct lu_seq_range *dst, const struct lu_seq
         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 */