Whamcloud - gitweb
LU-822 osd: use bitmask to calculate seq hash
[fs/lustre-release.git] / lustre / osd-ldiskfs / osd_internal.h
index 97b87be..abb5c49 100644 (file)
@@ -30,6 +30,9 @@
  * Use is subject to license terms.
  */
 /*
+ * Copyright (c) 2011 Whamcloud, Inc.
+ */
+/*
  * This file is part of Lustre, http://www.lustre.org/
  * Lustre is a trademark of Sun Microsystems, Inc.
  *
 #ifdef HAVE_EXT4_LDISKFS
 #include <ldiskfs/ldiskfs.h>
 #include <ldiskfs/ldiskfs_jbd2.h>
-#define osd_journal_callback_set(handle, func, jcb) jbd2_journal_callback_set(handle, func, jcb)
+# ifdef HAVE_LDISKFS_JOURNAL_CALLBACK_ADD
+#  define journal_callback ldiskfs_journal_cb_entry
+#  define osd_journal_callback_set(handle, func, jcb) ldiskfs_journal_callback_add(handle, func, jcb)
+# else
+#  define osd_journal_callback_set(handle, func, jcb) jbd2_journal_callback_set(handle, func, jcb)
+# endif
 #else
 #include <linux/jbd.h>
 #include <linux/ldiskfs_fs.h>
@@ -90,6 +98,55 @@ struct osd_ctxt {
 };
 #endif
 
+#ifdef HAVE_LDISKFS_PDO
+
+#define osd_ldiskfs_find_entry(dir, dentry, de, lock)   \
+        ll_ldiskfs_find_entry(dir, dentry, de, lock)
+#define osd_ldiskfs_add_entry(handle, child, cinode, hlock) \
+        ldiskfs_add_entry(handle, child, cinode, hlock)
+
+#else /* HAVE_LDISKFS_PDO */
+
+struct htree_lock {
+        int     dummy;
+};
+
+struct htree_lock_head {
+        int     dummy;
+};
+
+#define ldiskfs_htree_lock(lock, head, inode, op)  do { LBUG(); } while (0)
+#define ldiskfs_htree_unlock(lock)                 do { LBUG(); } while (0)
+
+static inline struct htree_lock_head *ldiskfs_htree_lock_head_alloc(int dep)
+{
+        LBUG();
+        return NULL;
+}
+
+#define ldiskfs_htree_lock_head_free(lh)           do { LBUG(); } while (0)
+
+#define LDISKFS_DUMMY_HTREE_LOCK        0xbabecafe
+
+static inline struct htree_lock *ldiskfs_htree_lock_alloc(void)
+{
+        return (struct htree_lock *)LDISKFS_DUMMY_HTREE_LOCK;
+}
+
+static inline void ldiskfs_htree_lock_free(struct htree_lock *lk)
+{
+        LASSERT((unsigned long)lk == LDISKFS_DUMMY_HTREE_LOCK);
+}
+
+#define HTREE_HBITS_DEF         0
+
+#define osd_ldiskfs_find_entry(dir, dentry, de, lock)   \
+        ll_ldiskfs_find_entry(dir, dentry, de)
+#define osd_ldiskfs_add_entry(handle, child, cinode, lock) \
+        ldiskfs_add_entry(handle, child, cinode)
+
+#endif /* HAVE_LDISKFS_PDO */
+
 /*
  * osd device.
  */
@@ -98,22 +155,15 @@ struct osd_device {
         struct dt_device          od_dt_dev;
         /* information about underlying file system */
         struct lustre_mount_info *od_mount;
-        /* object index */
-        struct osd_oi             od_oi;
         /*
          * XXX temporary stuff for object index: directory where every object
          * is named by its fid.
          */
         struct dt_object         *od_obj_area;
-
-        /* Environment for transaction commit callback.
-         * Currently, OSD is based on ext3/JBD. Transaction commit in ext3/JBD
-         * is serialized, that is there is no more than one transaction commit
-         * at a time (JBD journal_commit_transaction() is serialized).
-         * This means that it's enough to have _one_ lu_context.
-         */
-        struct lu_env             od_env_for_commit;
-
+        /* object index */
+        struct osd_oi            *od_oi_table;
+        /* total number of OI containers */
+        int                       od_oi_count;
         /*
          * Fid Capability
          */
@@ -219,15 +269,14 @@ struct osd_thread_info {
 
         /** dentry for Iterator context. */
         struct dentry          oti_it_dentry;
+        struct htree_lock     *oti_hlock;
 
         struct lu_fid          oti_fid;
         struct osd_inode_id    oti_id;
         /*
          * XXX temporary: for ->i_op calls.
          */
-        struct txn_param       oti_txn;
         struct timespec        oti_time;
-        struct timespec        oti_time2;
         /*
          * XXX temporary: fake struct file for osd_object_sync
          */
@@ -290,6 +339,8 @@ struct osd_thread_info {
         char                   oti_ldp2[OSD_FID_REC_SZ];
 };
 
+extern int ldiskfs_pdo;
+
 #ifdef LPROCFS
 /* osd_lproc.c */
 void lprocfs_osd_init_vars(struct lprocfs_static_vars *lvars);
@@ -344,5 +395,17 @@ static inline int osd_fid_is_igif(const struct lu_fid *fid)
         return fid_is_igif(fid) || osd_fid_is_root(fid);
 }
 
+static inline struct osd_oi *
+osd_fid2oi(struct osd_device *osd, const struct lu_fid *fid)
+{
+        if (!fid_is_norm(fid))
+                return NULL;
+
+        LASSERT(osd->od_oi_table != NULL && osd->od_oi_count >= 1);
+        /* It can work even od_oi_count equals to 1 although it's unexpected,
+         * the only reason we set it to 1 is for performance measurement */
+        return &osd->od_oi_table[fid->f_seq & (osd->od_oi_count - 1)];
+}
+
 #endif /* __KERNEL__ */
 #endif /* _OSD_INTERNAL_H */