Whamcloud - gitweb
LU-6142 lustre: convert use of container_of0 in include/
[fs/lustre-release.git] / lustre / include / lu_object.h
index 668dfdc..782384a 100644 (file)
@@ -38,6 +38,7 @@
 #include <uapi/linux/lustre/lustre_idl.h>
 #include <lu_ref.h>
 #include <linux/percpu_counter.h>
+#include <linux/rhashtable.h>
 #include <linux/ctype.h>
 #include <obd_target.h>
 
@@ -499,11 +500,6 @@ enum lu_object_header_flags {
         * intialized yet, the object allocator will initialize it.
         */
        LU_OBJECT_INITED        = 2,
-       /**
-        * Object is being purged, so mustn't be returned by
-        * htable_lookup()
-        */
-       LU_OBJECT_PURGING       = 3,
 };
 
 enum lu_object_header_attr {
@@ -527,6 +523,8 @@ enum lu_object_header_attr {
  * it is created for things like not-yet-existing child created by mkdir or
  * create calls. lu_object_operations::loo_exists() can be used to check
  * whether object is backed by persistent storage entity.
+ * Any object containing this structre which might be placed in an
+ * rhashtable via loh_hash MUST be freed using call_rcu() or rcu_kfree().
  */
 struct lu_object_header {
        /**
@@ -548,9 +546,9 @@ struct lu_object_header {
         */
        __u32                   loh_attr;
        /**
-        * Linkage into per-site hash table. Protected by lu_site::ls_guard.
+        * Linkage into per-site hash table.
         */
-       struct hlist_node       loh_hash;
+       struct rhash_head       loh_hash;
        /**
         * Linkage into per-site LRU list. Protected by lu_site::ls_guard.
         */
@@ -596,7 +594,7 @@ struct lu_site {
         /**
          * objects hash table
          */
-       struct cfs_hash         *ls_obj_hash;
+       struct rhashtable       ls_obj_hash;
        /*
         * buckets for summary data
         */
@@ -676,7 +674,8 @@ int  lu_object_init       (struct lu_object *o,
 void lu_object_fini       (struct lu_object *o);
 void lu_object_add_top    (struct lu_object_header *h, struct lu_object *o);
 void lu_object_add        (struct lu_object *before, struct lu_object *o);
-
+struct lu_object *lu_object_get_first(struct lu_object_header *h,
+                                     struct lu_device *dev);
 void lu_dev_add_linkage(struct lu_site *s, struct lu_device *d);
 void lu_dev_del_linkage(struct lu_site *s, struct lu_device *d);
 
@@ -734,8 +733,8 @@ static inline int lu_site_purge(const struct lu_env *env, struct lu_site *s,
        return lu_site_purge_objects(env, s, nr, 1);
 }
 
-void lu_site_print(const struct lu_env *env, struct lu_site *s, void *cookie,
-                   lu_printer_t printer);
+void lu_site_print(const struct lu_env *env, struct lu_site *s, atomic_t *ref,
+                  int msg_flags, lu_printer_t printer);
 struct lu_object *lu_object_find(const struct lu_env *env,
                                  struct lu_device *dev, const struct lu_fid *f,
                                  const struct lu_object_conf *conf);
@@ -760,7 +759,7 @@ struct lu_object *lu_object_find_slice(const struct lu_env *env,
 static inline struct lu_object *lu_object_top(struct lu_object_header *h)
 {
        LASSERT(!list_empty(&h->loh_layers));
-       return container_of0(h->loh_layers.next, struct lu_object, lo_linkage);
+       return container_of(h->loh_layers.next, struct lu_object, lo_linkage);
 }
 
 /**
@@ -768,7 +767,7 @@ static inline struct lu_object *lu_object_top(struct lu_object_header *h)
  */
 static inline struct lu_object *lu_object_next(const struct lu_object *o)
 {
-        return container_of0(o->lo_linkage.next, struct lu_object, lo_linkage);
+       return container_of(o->lo_linkage.next, struct lu_object, lo_linkage);
 }
 
 /**
@@ -1608,7 +1607,7 @@ struct lu_tgt_descs {
        /* Size of the lu_tgts array, granted to be a power of 2 */
        __u32                   ltd_tgts_size;
        /* bitmap of TGTs available */
-       struct cfs_bitmap       *ltd_tgt_bitmap;
+       unsigned long           *ltd_tgt_bitmap;
        /* TGTs scheduled to be deleted */
        __u32                   ltd_death_row;
        /* Table refcount used for delayed deletion */
@@ -1647,9 +1646,9 @@ static inline struct lu_tgt_desc *ltd_first_tgt(struct lu_tgt_descs *ltd)
 {
        int index;
 
-       index = find_first_bit(ltd->ltd_tgt_bitmap->data,
-                              ltd->ltd_tgt_bitmap->size);
-       return (index < ltd->ltd_tgt_bitmap->size) ? LTD_TGT(ltd, index) : NULL;
+       index = find_first_bit(ltd->ltd_tgt_bitmap,
+                              ltd->ltd_tgts_size);
+       return (index < ltd->ltd_tgts_size) ? LTD_TGT(ltd, index) : NULL;
 }
 
 static inline struct lu_tgt_desc *ltd_next_tgt(struct lu_tgt_descs *ltd,
@@ -1661,10 +1660,10 @@ static inline struct lu_tgt_desc *ltd_next_tgt(struct lu_tgt_descs *ltd,
                return NULL;
 
        index = tgt->ltd_index;
-       LASSERT(index < ltd->ltd_tgt_bitmap->size);
-       index = find_next_bit(ltd->ltd_tgt_bitmap->data,
-                             ltd->ltd_tgt_bitmap->size, index + 1);
-       return (index < ltd->ltd_tgt_bitmap->size) ? LTD_TGT(ltd, index) : NULL;
+       LASSERT(index < ltd->ltd_tgts_size);
+       index = find_next_bit(ltd->ltd_tgt_bitmap,
+                             ltd->ltd_tgts_size, index + 1);
+       return (index < ltd->ltd_tgts_size) ? LTD_TGT(ltd, index) : NULL;
 }
 
 #define ltd_foreach_tgt(ltd, tgt) \