Whamcloud - gitweb
lu: add lu_site_print().
authornikita <nikita>
Mon, 16 Oct 2006 13:31:39 +0000 (13:31 +0000)
committernikita <nikita>
Mon, 16 Oct 2006 13:31:39 +0000 (13:31 +0000)
lustre/include/lu_object.h
lustre/obdclass/lu_object.c

index 83c2223..f69552c 100644 (file)
@@ -685,6 +685,11 @@ void lu_object_put(const struct lu_env *env,
 int lu_site_purge(const struct lu_env *env, struct lu_site *s, int nr);
 
 /*
+ * Print all objects in @s.
+ */
+void lu_site_print(const struct lu_env *env, struct lu_site *s, void *cookie,
+                   lu_printer_t printer);
+/*
  * Search cache for an object with the fid @f. If such object is found, return
  * it. Otherwise, create new object, insert it into cache and return it. In
  * any case, additional reference is acquired on the returned object.
@@ -751,18 +756,22 @@ struct lu_cdebug_print_info {
 int lu_cdebug_printer(const struct lu_env *env,
                       void *cookie, const char *format, ...);
 
+#define DECLARE_LU_CDEBUG_PRINT_INFO(var, mask) \
+        struct lu_cdebug_print_info var = {     \
+                .lpi_subsys = DEBUG_SUBSYSTEM,  \
+                .lpi_mask   = (mask),           \
+                .lpi_file   = __FILE__,         \
+                .lpi_fn     = __FUNCTION__,     \
+                .lpi_line   = __LINE__          \
+        };
+
 /*
  * Print object description followed by user-supplied message.
  */
 #define LU_OBJECT_DEBUG(mask, env, object, format, ...)                 \
 ({                                                                      \
-        static struct lu_cdebug_print_info __info = {                   \
-                .lpi_subsys = DEBUG_SUBSYSTEM,                          \
-                .lpi_mask   = (mask),                                   \
-                .lpi_file   = __FILE__,                                 \
-                .lpi_fn     = __FUNCTION__,                             \
-                .lpi_line   = __LINE__                                  \
-        };                                                              \
+        static DECLARE_LU_CDEBUG_PRINT_INFO(__info, mask);              \
+                                                                        \
         lu_object_print(env, &__info, lu_cdebug_printer, object);       \
         CDEBUG(mask, format , ## __VA_ARGS__);                          \
 })
index cfc4204..25bfe45 100644 (file)
@@ -510,6 +510,34 @@ static int lu_site_htable_size;
 static int lu_site_htable_mask;
 
 /*
+ * Print all objects in @s.
+ */
+void lu_site_print(const struct lu_env *env, struct lu_site *s, void *cookie,
+                   lu_printer_t printer)
+{
+        int i;
+
+        for (i = 0; i < lu_site_htable_size; ++i) {
+                struct lu_object_header *h;
+                struct hlist_node       *scan;
+
+                spin_lock(&s->ls_guard);
+                hlist_for_each_entry(h, scan, &s->ls_hash[i], loh_hash) {
+
+                        if (!list_empty(&h->loh_layers)) {
+                                const struct lu_object *obj;
+
+                                obj = lu_object_top(h);
+                                lu_object_print(env, cookie, printer, obj);
+                        } else
+                                lu_object_header_print(env, cookie, printer, h);
+                }
+                spin_unlock(&s->ls_guard);
+        }
+}
+EXPORT_SYMBOL(lu_site_print);
+
+/*
  * Initialize site @s, with @d as the top level device.
  */
 int lu_site_init(struct lu_site *s, struct lu_device *top)