Whamcloud - gitweb
b=21244 lustre_idl.h compilable from userspace
[fs/lustre-release.git] / lustre / include / lustre_fid.h
index 6e952b5..6d9d725 100644 (file)
 #ifndef __LINUX_FID_H
 #define __LINUX_FID_H
 
+/** \defgroup fid fid
+ *
+ * @{
+ */
+
 /*
  * struct lu_fid
  */
+#include <libcfs/libcfs.h>
 #include <lustre/lustre_idl.h>
 #include <lustre_req_layout.h>
 #include <lustre_mdt.h>
 
-#include <libcfs/libcfs.h>
 
 struct lu_site;
 struct lu_context;
@@ -62,23 +67,25 @@ extern const struct lu_fid LU_DOT_LUSTRE_FID;
 
 enum {
         /*
-         * This is how may FIDs may be allocated in one sequence. 16384 for
-         * now.
+         * This is how may FIDs may be allocated in one sequence(128k)
          */
-        LUSTRE_SEQ_MAX_WIDTH = 0x0000000000000400ULL,
+        LUSTRE_SEQ_MAX_WIDTH = 0x0000000000020000ULL,
 
         /*
-         * How many sequences may be allocate for meta-sequence (this is 128
-         * sequences).
+         * How many sequences to allocate to a client at once.
          */
-        /* changed to 16 to avoid overflow in test11 */
-        LUSTRE_SEQ_META_WIDTH = 0x0000000000000010ULL,
+        LUSTRE_SEQ_META_WIDTH = 0x0000000000000001ULL,
+
+         /*
+          * seq allocation pool size.
+          */
+        LUSTRE_SEQ_BATCH_WIDTH = LUSTRE_SEQ_META_WIDTH * 1000,
 
         /*
          * This is how many sequences may be in one super-sequence allocated to
          * MDTs.
          */
-        LUSTRE_SEQ_SUPER_WIDTH = (LUSTRE_SEQ_META_WIDTH * LUSTRE_SEQ_META_WIDTH)
+        LUSTRE_SEQ_SUPER_WIDTH = ((1ULL << 30ULL) * LUSTRE_SEQ_META_WIDTH)
 };
 
 /** special fid seq: used for local object create. */
@@ -178,6 +185,10 @@ struct lu_server_seq {
         /* Available sequences space */
         struct lu_seq_range         lss_space;
 
+        /* keeps highwater in lsr_end for seq allocation algorithm */
+        struct lu_seq_range         lss_lowater_set;
+        struct lu_seq_range         lss_hiwater_set;
+
         /*
          * Device for server side seq manager needs (saving sequences to backing
          * store).
@@ -211,6 +222,14 @@ struct lu_server_seq {
          */
         __u64                   lss_width;
 
+        /*
+         * minimum lss_alloc_set size that should be allocated from
+         * lss_space
+         */
+        __u64                   lss_set_width;
+
+        /* transaction no of seq update write operation */
+        __u64                   lss_set_transno;
         /**
          * Pointer to site object, required to access site fld.
          */
@@ -231,12 +250,10 @@ void seq_server_fini(struct lu_server_seq *seq,
                      const struct lu_env *env);
 
 int seq_server_alloc_super(struct lu_server_seq *seq,
-                           struct lu_seq_range *in,
                            struct lu_seq_range *out,
                            const struct lu_env *env);
 
 int seq_server_alloc_meta(struct lu_server_seq *seq,
-                          struct lu_seq_range *in,
                           struct lu_seq_range *out,
                           const struct lu_env *env);
 
@@ -310,9 +327,51 @@ fid_build_pdo_res_name(const struct lu_fid *f,
         return name;
 }
 
+
+/**
+ * Flatten 128-bit FID values into a 64-bit value for
+ * use as an inode number.  For non-IGIF FIDs this
+ * starts just over 2^32, and continues without conflict
+ * until 2^64, at which point we wrap the high 32 bits
+ * of the SEQ into the range where there may not be many
+ * OID values in use, to minimize the risk of conflict.
+ *
+ * The time between re-used inode numbers is very long -
+ * 2^32 SEQ numbers, or about 2^32 client mounts. */
 static inline __u64 fid_flatten(const struct lu_fid *fid)
 {
-        return (fid_seq(fid) - 1) * LUSTRE_SEQ_MAX_WIDTH + fid_oid(fid);
+        __u64 ino;
+        __u64 seq;
+
+        if (fid_is_igif(fid)) {
+                ino = lu_igif_ino(fid);
+                RETURN(ino);
+        }
+
+        seq = fid_seq(fid);
+
+        ino = (seq << 24) + ((seq >> (64-8)) & 0xffffff0000ULL) + fid_oid(fid);
+
+        RETURN(ino ? ino : fid_oid(fid));
+}
+
+/**
+ * map fid to 32 bit value for ino on 32bit systems. */
+static inline __u32 fid_flatten32(const struct lu_fid *fid)
+{
+        __u32 ino;
+        __u64 seq;
+
+        if (fid_is_igif(fid)) {
+                ino = lu_igif_ino(fid);
+                RETURN(ino);
+        }
+
+        seq = fid_seq(fid) - FID_SEQ_START;
+
+        ino = ((seq & 0xfffffULL) << 12) + ((seq >> 8) & 0xfffff000) +
+                (seq >> (64 - (40-8)) & 0xffffff00) + fid_oid(fid);
+        RETURN(ino ? ino : fid_oid(fid));
 }
 
 #define LUSTRE_SEQ_SRV_NAME "seq_srv"
@@ -347,4 +406,6 @@ static inline void range_be_to_cpu(struct lu_seq_range *dst, const struct lu_seq
         dst->lsr_mdt = be32_to_cpu(src->lsr_mdt);
 }
 
+/** @} fid */
+
 #endif /* __LINUX_FID_H */