Whamcloud - gitweb
LU-11814 obdcalss: ensure LCT_QUIESCENT take sync
[fs/lustre-release.git] / lustre / include / lu_object.h
index 781b9b4..e86f8b9 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>
 
@@ -171,7 +172,6 @@ struct lu_device_operations {
         * \param[in] parent    parent object
         * \param[in] name      lu_name
         *
-        * \retval 0            on success
         * \retval 0            0 FID allocated successfully.
         * \retval 1            1 FID allocated successfully and new sequence
         *                      requested from seq meta server
@@ -500,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 {
@@ -528,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 {
        /**
@@ -549,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.
         */
@@ -597,7 +594,7 @@ struct lu_site {
         /**
          * objects hash table
          */
-       struct cfs_hash         *ls_obj_hash;
+       struct rhashtable       ls_obj_hash;
        /*
         * buckets for summary data
         */
@@ -677,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);
 
@@ -735,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);
@@ -761,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);
 }
 
 /**
@@ -769,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);
 }
 
 /**
@@ -1202,8 +1200,9 @@ int   lu_context_key_register(struct lu_context_key *key);
 void  lu_context_key_degister(struct lu_context_key *key);
 void *lu_context_key_get     (const struct lu_context *ctx,
                                const struct lu_context_key *key);
-void  lu_context_key_quiesce (struct lu_context_key *key);
-void  lu_context_key_revive  (struct lu_context_key *key);
+void  lu_context_key_quiesce(struct lu_device_type *t,
+                            struct lu_context_key *key);
+void  lu_context_key_revive(struct lu_context_key *key);
 
 
 /*
@@ -1248,12 +1247,12 @@ void  lu_context_key_revive  (struct lu_context_key *key);
         }                                                       \
         struct __##mod##_dummy_type_start {;}
 
-#define LU_TYPE_STOP(mod, ...)                                  \
-        static void mod##_type_stop(struct lu_device_type *t)   \
-        {                                                       \
-                lu_context_key_quiesce_many(__VA_ARGS__, NULL); \
-        }                                                       \
-        struct __##mod##_dummy_type_stop {;}
+#define LU_TYPE_STOP(mod, ...)                                     \
+       static void mod##_type_stop(struct lu_device_type *t)      \
+       {                                                          \
+               lu_context_key_quiesce_many(t, __VA_ARGS__, NULL); \
+       }                                                          \
+       struct __##mod##_dummy_type_stop { }
 
 
 
@@ -1277,7 +1276,8 @@ int   lu_context_refill(struct lu_context *ctx);
 int  lu_context_key_register_many(struct lu_context_key *k, ...);
 void lu_context_key_degister_many(struct lu_context_key *k, ...);
 void lu_context_key_revive_many  (struct lu_context_key *k, ...);
-void lu_context_key_quiesce_many (struct lu_context_key *k, ...);
+void lu_context_key_quiesce_many(struct lu_device_type *t,
+                                struct lu_context_key *k, ...);
 
 /*
  * update/clear ctx/ses tags.
@@ -1609,7 +1609,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 */
@@ -1648,9 +1648,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,
@@ -1662,10 +1662,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) \