Skip to content
Snippets Groups Projects
Commit a1f824ea authored by Nikita Danilov's avatar Nikita Danilov
Browse files

Use cdebug_show() in CDEBUG-style macros defined outside of libcfs.

b=16450
parent 4b236904
No related branches found
No related tags found
No related merge requests found
...@@ -1708,6 +1708,11 @@ Description: Ratelimit a message that can be very frequent. ...@@ -1708,6 +1708,11 @@ Description: Ratelimit a message that can be very frequent.
Details : Ratelimit a memory allocation failure message that can Details : Ratelimit a memory allocation failure message that can
be too chatty. be too chatty.
Severity : minor
Bugzilla : 16450
Description: Use cdebug_show() in CDEBUG-style macros defined outside of libcfs.
Details : Use cdebug_show() in CDEBUG-style macros defined outside of libcfs.
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
......
...@@ -782,7 +782,7 @@ struct lu_cdebug_print_info { ...@@ -782,7 +782,7 @@ struct lu_cdebug_print_info {
int lpi_line; int lpi_line;
}; };
/* /**
* Printer function emitting messages through libcfs_debug_msg(). * Printer function emitting messages through libcfs_debug_msg().
*/ */
int lu_cdebug_printer(const struct lu_env *env, int lu_cdebug_printer(const struct lu_env *env,
...@@ -795,36 +795,50 @@ int lu_cdebug_printer(const struct lu_env *env, ...@@ -795,36 +795,50 @@ int lu_cdebug_printer(const struct lu_env *env,
.lpi_file = __FILE__, \ .lpi_file = __FILE__, \
.lpi_fn = __FUNCTION__, \ .lpi_fn = __FUNCTION__, \
.lpi_line = __LINE__ \ .lpi_line = __LINE__ \
}; }
/* /**
* Print object description followed by user-supplied message. * Print object description followed by a user-supplied message.
*/ */
#define LU_OBJECT_DEBUG(mask, env, object, format, ...) \ #define LU_OBJECT_DEBUG(mask, env, object, format, ...) \
({ \ ({ \
static DECLARE_LU_CDEBUG_PRINT_INFO(__info, mask); \ static DECLARE_LU_CDEBUG_PRINT_INFO(__info, mask); \
\ \
if (cdebug_show(mask, DEBUG_SUBSYSTEM)) { \
lu_object_print(env, &__info, lu_cdebug_printer, object); \ lu_object_print(env, &__info, lu_cdebug_printer, object); \
CDEBUG(mask, format , ## __VA_ARGS__); \ CDEBUG(mask, format , ## __VA_ARGS__); \
} \
}) })
/* /**
* Print human readable representation of the @o to the @f. * Print short object description followed by a user-supplied message.
*/ */
void lu_object_print(const struct lu_env *env, void *cookie, #define LU_OBJECT_HEADER(mask, env, object, format, ...) \
({ \
static DECLARE_LU_CDEBUG_PRINT_INFO(__info, mask); \
\
if (cdebug_show(mask, DEBUG_SUBSYSTEM)) { \
lu_object_header_print(env, &__info, lu_cdebug_printer, \
(object)->lo_header); \
lu_cdebug_printer(env, &__info, "\n"); \
CDEBUG(mask, format , ## __VA_ARGS__); \
} \
})
void lu_object_print (const struct lu_env *env, void *cookie,
lu_printer_t printer, const struct lu_object *o); lu_printer_t printer, const struct lu_object *o);
void lu_object_header_print(const struct lu_env *env, void *cookie,
lu_printer_t printer,
const struct lu_object_header *hdr);
/* /**
* Check object consistency. * Check object consistency.
*/ */
int lu_object_invariant(const struct lu_object *o); int lu_object_invariant(const struct lu_object *o);
/*
* Finalize and free devices in the device stack.
*/
void lu_stack_fini(const struct lu_env *env, struct lu_device *top); void lu_stack_fini(const struct lu_env *env, struct lu_device *top);
/* /**
* Returns 1 iff object @o exists on the stable storage, * Returns 1 iff object @o exists on the stable storage,
* returns -1 iff object @o is on remote server. * returns -1 iff object @o is on remote server.
*/ */
......
...@@ -351,6 +351,7 @@ int lu_cdebug_printer(const struct lu_env *env, ...@@ -351,6 +351,7 @@ int lu_cdebug_printer(const struct lu_env *env,
vsnprintf(key->lck_area + used, vsnprintf(key->lck_area + used,
ARRAY_SIZE(key->lck_area) - used, format, args); ARRAY_SIZE(key->lck_area) - used, format, args);
if (complete) { if (complete) {
if (cdebug_show(info->lpi_mask, info->lpi_subsys))
libcfs_debug_msg(NULL, info->lpi_subsys, info->lpi_mask, libcfs_debug_msg(NULL, info->lpi_subsys, info->lpi_mask,
(char *)info->lpi_file, info->lpi_fn, (char *)info->lpi_file, info->lpi_fn,
info->lpi_line, "%s", key->lck_area); info->lpi_line, "%s", key->lck_area);
...@@ -361,23 +362,24 @@ int lu_cdebug_printer(const struct lu_env *env, ...@@ -361,23 +362,24 @@ int lu_cdebug_printer(const struct lu_env *env,
} }
EXPORT_SYMBOL(lu_cdebug_printer); EXPORT_SYMBOL(lu_cdebug_printer);
/* /**
* Print object header. * Print object header.
*/ */
static void lu_object_header_print(const struct lu_env *env, void lu_object_header_print(const struct lu_env *env, void *cookie,
void *cookie, lu_printer_t printer, lu_printer_t printer,
const struct lu_object_header *hdr) const struct lu_object_header *hdr)
{ {
(*printer)(env, cookie, "header@%p[%#lx, %d, "DFID"%s%s%s]", (*printer)(env, cookie, "header@%p[%#lx, %d, "DFID"%s%s%s]",
hdr, hdr->loh_flags, atomic_read(&hdr->loh_ref), hdr, hdr->loh_flags, atomic_read(&hdr->loh_ref),
PFID(&hdr->loh_fid), PFID(&hdr->loh_fid),
hlist_unhashed(&hdr->loh_hash) ? "" : " hash", hlist_unhashed(&hdr->loh_hash) ? "" : " hash",
list_empty(&hdr->loh_lru) ? "" : " lru", list_empty((struct list_head *)&hdr->loh_lru) ? "" : " lru",
hdr->loh_attr & LOHA_EXISTS ? " exist":""); hdr->loh_attr & LOHA_EXISTS ? " exist":"");
} }
EXPORT_SYMBOL(lu_object_header_print);
/* /**
* Print human readable representation of the @o to the @printer. * Print human readable representation of the \a o to the \a printer.
*/ */
void lu_object_print(const struct lu_env *env, void *cookie, void lu_object_print(const struct lu_env *env, void *cookie,
lu_printer_t printer, const struct lu_object *o) lu_printer_t printer, const struct lu_object *o)
...@@ -388,21 +390,24 @@ void lu_object_print(const struct lu_env *env, void *cookie, ...@@ -388,21 +390,24 @@ void lu_object_print(const struct lu_env *env, void *cookie,
top = o->lo_header; top = o->lo_header;
lu_object_header_print(env, cookie, printer, top); lu_object_header_print(env, cookie, printer, top);
(*printer)(env, cookie, "\n"); (*printer)(env, cookie, "{ \n");
list_for_each_entry(o, &top->loh_layers, lo_linkage) { list_for_each_entry(o, &top->loh_layers, lo_linkage) {
depth = o->lo_depth + 4; depth = o->lo_depth + 4;
LASSERT(o->lo_ops->loo_object_print != NULL);
/* /*
* print `.' @depth times. * print `.' \a depth times followed by type name and address
*/ */
(*printer)(env, cookie, "%*.*s", depth, depth, ruler); (*printer)(env, cookie, "%*.*s%s@%p", depth, depth, ruler,
o->lo_dev->ld_type->ldt_name, o);
if (o->lo_ops->loo_object_print != NULL)
o->lo_ops->loo_object_print(env, cookie, printer, o); o->lo_ops->loo_object_print(env, cookie, printer, o);
(*printer)(env, cookie, "\n"); (*printer)(env, cookie, "\n");
} }
(*printer)(env, cookie, "} header@%p\n", top);
} }
EXPORT_SYMBOL(lu_object_print); EXPORT_SYMBOL(lu_object_print);
/* /**
* Check object consistency. * Check object consistency.
*/ */
int lu_object_invariant(const struct lu_object *o) int lu_object_invariant(const struct lu_object *o)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment