X-Git-Url: https://git.whamcloud.com/?a=blobdiff_plain;f=lustre%2Fobdclass%2Fcl_object.c;h=ac46d074b24e3ce0c1d1f7ebb453a17b7972022f;hb=cc2ff1bfd66a5c004eb6ed61fc2dac3f1ab49d3a;hp=57bb6cd30fe4ba380d18977eb04ea44f7c1778d3;hpb=19fff6ccfbd2889bc140fb5a8ee74902f8a35cc0;p=fs%2Flustre-release.git diff --git a/lustre/obdclass/cl_object.c b/lustre/obdclass/cl_object.c index 57bb6cd..ac46d07 100644 --- a/lustre/obdclass/cl_object.c +++ b/lustre/obdclass/cl_object.c @@ -214,7 +214,7 @@ int cl_object_attr_get(const struct lu_env *env, struct cl_object *obj, struct lu_object_header *top; int result; - LASSERT(spin_is_locked(cl_object_attr_guard(obj))); + assert_spin_locked(cl_object_attr_guard(obj)); ENTRY; top = obj->co_lu.lo_header; @@ -246,7 +246,7 @@ int cl_object_attr_set(const struct lu_env *env, struct cl_object *obj, struct lu_object_header *top; int result; - LASSERT(spin_is_locked(cl_object_attr_guard(obj))); + assert_spin_locked(cl_object_attr_guard(obj)); ENTRY; top = obj->co_lu.lo_header; @@ -400,11 +400,10 @@ void cache_stats_init(struct cache_stats *cs, const char *name) atomic_set(&cs->cs_stats[i], 0); } -int cache_stats_print(const struct cache_stats *cs, - char *page, int count, int h) +int cache_stats_print(const struct cache_stats *cs, struct seq_file *m, int h) { - int nob = 0; int i; + /* * lookup hit total cached create * env: ...... ...... ...... ...... ...... @@ -412,18 +411,16 @@ int cache_stats_print(const struct cache_stats *cs, if (h) { const char *names[CS_NR] = CS_NAMES; - nob += snprintf(page + nob, count - nob, "%6s", " "); + seq_printf(m, "%6s", " "); for (i = 0; i < CS_NR; i++) - nob += snprintf(page + nob, count - nob, - "%8s", names[i]); - nob += snprintf(page + nob, count - nob, "\n"); + seq_printf(m, "%8s", names[i]); + seq_printf(m, "\n"); } - nob += snprintf(page + nob, count - nob, "%5.5s:", cs->cs_name); + seq_printf(m, "%5.5s:", cs->cs_name); for (i = 0; i < CS_NR; i++) - nob += snprintf(page + nob, count - nob, "%8u", - atomic_read(&cs->cs_stats[i])); - return nob; + seq_printf(m, "%8u", atomic_read(&cs->cs_stats[i])); + return 0; } static void cl_env_percpu_refill(void); @@ -471,50 +468,48 @@ static struct cache_stats cl_env_stats = { * Outputs client site statistical counters into a buffer. Suitable for * ll_rd_*()-style functions. */ -int cl_site_stats_print(const struct cl_site *site, char *page, int count) -{ - int nob; - int i; - static const char *pstate[] = { - [CPS_CACHED] = "c", - [CPS_OWNED] = "o", - [CPS_PAGEOUT] = "w", - [CPS_PAGEIN] = "r", - [CPS_FREEING] = "f" - }; - static const char *lstate[] = { - [CLS_NEW] = "n", - [CLS_QUEUING] = "q", - [CLS_ENQUEUED] = "e", - [CLS_HELD] = "h", - [CLS_INTRANSIT] = "t", - [CLS_CACHED] = "c", - [CLS_FREEING] = "f" - }; +int cl_site_stats_print(const struct cl_site *site, struct seq_file *m) +{ + static const char *pstate[] = { + [CPS_CACHED] = "c", + [CPS_OWNED] = "o", + [CPS_PAGEOUT] = "w", + [CPS_PAGEIN] = "r", + [CPS_FREEING] = "f" + }; + static const char *lstate[] = { + [CLS_NEW] = "n", + [CLS_QUEUING] = "q", + [CLS_ENQUEUED] = "e", + [CLS_HELD] = "h", + [CLS_INTRANSIT] = "t", + [CLS_CACHED] = "c", + [CLS_FREEING] = "f" + }; + int i; + /* lookup hit total busy create pages: ...... ...... ...... ...... ...... [...... ...... ...... ......] locks: ...... ...... ...... ...... ...... [...... ...... ...... ...... ......] env: ...... ...... ...... ...... ...... */ - nob = lu_site_stats_print(&site->cs_lu, page, count); - nob += cache_stats_print(&site->cs_pages, page + nob, count - nob, 1); - nob += snprintf(page + nob, count - nob, " ["); - for (i = 0; i < ARRAY_SIZE(site->cs_pages_state); ++i) - nob += snprintf(page + nob, count - nob, "%s: %u ", - pstate[i], - atomic_read(&site->cs_pages_state[i])); - nob += snprintf(page + nob, count - nob, "]\n"); - nob += cache_stats_print(&site->cs_locks, page + nob, count - nob, 0); - nob += snprintf(page + nob, count - nob, " ["); - for (i = 0; i < ARRAY_SIZE(site->cs_locks_state); ++i) - nob += snprintf(page + nob, count - nob, "%s: %u ", - lstate[i], - atomic_read(&site->cs_locks_state[i])); - nob += snprintf(page + nob, count - nob, "]\n"); - nob += cache_stats_print(&cl_env_stats, page + nob, count - nob, 0); - nob += snprintf(page + nob, count - nob, "\n"); - return nob; + lu_site_stats_seq_print(&site->cs_lu, m); + cache_stats_print(&site->cs_pages, m, 1); + seq_printf(m, " ["); + for (i = 0; i < ARRAY_SIZE(site->cs_pages_state); ++i) + seq_printf(m, "%s: %u ", pstate[i], + atomic_read(&site->cs_pages_state[i])); + seq_printf(m, "]\n"); + cache_stats_print(&site->cs_locks, m, 0); + seq_printf(m, " ["); + for (i = 0; i < ARRAY_SIZE(site->cs_locks_state); ++i) + seq_printf(m, "%s: %u ", lstate[i], + atomic_read(&site->cs_locks_state[i])); + seq_printf(m, "]\n"); + cache_stats_print(&cl_env_stats, m, 0); + seq_printf(m, "\n"); + return 0; } EXPORT_SYMBOL(cl_site_stats_print); @@ -761,37 +756,37 @@ static inline struct cl_env *cl_env_detach(struct cl_env *cle) static struct lu_env *cl_env_new(__u32 ctx_tags, __u32 ses_tags, void *debug) { - struct lu_env *env; - struct cl_env *cle; + struct lu_env *env; + struct cl_env *cle; - OBD_SLAB_ALLOC_PTR_GFP(cle, cl_env_kmem, __GFP_IO); - if (cle != NULL) { - int rc; + OBD_SLAB_ALLOC_PTR_GFP(cle, cl_env_kmem, GFP_NOFS); + if (cle != NULL) { + int rc; - CFS_INIT_LIST_HEAD(&cle->ce_linkage); - cle->ce_magic = &cl_env_init0; - env = &cle->ce_lu; - rc = lu_env_init(env, LCT_CL_THREAD|ctx_tags); - if (rc == 0) { - rc = lu_context_init(&cle->ce_ses, - LCT_SESSION | ses_tags); - if (rc == 0) { - lu_context_enter(&cle->ce_ses); - env->le_ses = &cle->ce_ses; - cl_env_init0(cle, debug); - } else - lu_env_fini(env); - } - if (rc != 0) { - OBD_SLAB_FREE_PTR(cle, cl_env_kmem); - env = ERR_PTR(rc); - } else { - CL_ENV_INC(create); - CL_ENV_INC(total); - } - } else - env = ERR_PTR(-ENOMEM); - return env; + CFS_INIT_LIST_HEAD(&cle->ce_linkage); + cle->ce_magic = &cl_env_init0; + env = &cle->ce_lu; + rc = lu_env_init(env, LCT_CL_THREAD|ctx_tags); + if (rc == 0) { + rc = lu_context_init(&cle->ce_ses, + LCT_SESSION | ses_tags); + if (rc == 0) { + lu_context_enter(&cle->ce_ses); + env->le_ses = &cle->ce_ses; + cl_env_init0(cle, debug); + } else + lu_env_fini(env); + } + if (rc != 0) { + OBD_SLAB_FREE_PTR(cle, cl_env_kmem); + env = ERR_PTR(rc); + } else { + CL_ENV_INC(create); + CL_ENV_INC(total); + } + } else + env = ERR_PTR(-ENOMEM); + return env; } static void cl_env_fini(struct cl_env *cle)