From 43ba93659c0d1934316b51ede12c9b3f4b7cc3ba Mon Sep 17 00:00:00 2001 From: nikita <nikita> Date: Sat, 18 Oct 2008 17:25:19 +0000 Subject: [PATCH] Separate lu_site stats printing code into a separate function that can be reused on a client. b=16450 --- lustre/ChangeLog | 6 ++++++ lustre/mdt/mdt_lproc.c | 24 ++---------------------- lustre/obdclass/lu_object.c | 35 +++++++++++++++++++++++++++++++++-- 3 files changed, 41 insertions(+), 24 deletions(-) diff --git a/lustre/ChangeLog b/lustre/ChangeLog index a65dbba2bd..8af96c97a1 100644 --- a/lustre/ChangeLog +++ b/lustre/ChangeLog @@ -1642,6 +1642,12 @@ Details : lu_ref is a debugging module allowing to track references to explicitly enabled with --enable-lu_ref. See usage description within the patch. +Severity : minor +Bugzilla : 16450 +Description: Factor lu_site procfs stats into a separate function. +Details : Separate lu_site stats printing code into a separate function + that can be reused on a client. + -------------------------------------------------------------------------------- 2007-08-10 Cluster File Systems, Inc. <info@clusterfs.com> diff --git a/lustre/mdt/mdt_lproc.c b/lustre/mdt/mdt_lproc.c index 9e453133d4..171c77ada1 100644 --- a/lustre/mdt/mdt_lproc.c +++ b/lustre/mdt/mdt_lproc.c @@ -356,28 +356,8 @@ static int lprocfs_rd_site_stats(char *page, char **start, off_t off, { struct obd_device *obd = data; struct mdt_device *mdt = mdt_dev(obd->obd_lu_dev); - struct lu_site *s = mdt->mdt_md_dev.md_lu_dev.ld_site; - int i; - int populated; - - /* - * How many hash buckets are not-empty? Don't bother with locks: it's - * an estimation anyway. - */ - for (i = 0, populated = 0; i < s->ls_hash_size; i++) - populated += !hlist_empty(&s->ls_hash[i]); - - return snprintf(page, count, "%d %d %d/%d %d %d %d %d %d %d\n", - s->ls_total, - s->ls_busy, - populated, - s->ls_hash_size, - s->ls_stats.s_created, - s->ls_stats.s_cache_hit, - s->ls_stats.s_cache_miss, - s->ls_stats.s_cache_check, - s->ls_stats.s_cache_race, - s->ls_stats.s_lru_purged); + + return lu_site_stats_print(mdt_lu_site(mdt), page, count); } static int lprocfs_rd_capa_timeout(char *page, char **start, off_t off, diff --git a/lustre/obdclass/lu_object.c b/lustre/obdclass/lu_object.c index 8ecd85c849..4c999b46fb 100644 --- a/lustre/obdclass/lu_object.c +++ b/lustre/obdclass/lu_object.c @@ -1530,9 +1530,40 @@ struct lu_buf LU_BUF_NULL = { }; EXPORT_SYMBOL(LU_BUF_NULL); +/** + * Output site statistical counters into a buffer. Suitable for + * lprocfs_rd_*()-style functions. + */ +int lu_site_stats_print(const struct lu_site *s, char *page, int count) +{ + int i; + int populated; + + /* + * How many hash buckets are not-empty? Don't bother with locks: it's + * an estimation anyway. + */ + for (i = 0, populated = 0; i < s->ls_hash_size; i++) + populated += !hlist_empty(&s->ls_hash[i]); + + return snprintf(page, count, "%d %d %d/%d %d %d %d %d %d %d %d\n", + s->ls_total, + s->ls_busy, + populated, + s->ls_hash_size, + s->ls_stats.s_created, + s->ls_stats.s_cache_hit, + s->ls_stats.s_cache_miss, + s->ls_stats.s_cache_check, + s->ls_stats.s_cache_race, + s->ls_stats.s_cache_death_race, + s->ls_stats.s_lru_purged); +} +EXPORT_SYMBOL(lu_site_stats_print); + /* - * XXX: Functions below logically belong to fid module, but they are used by - * dt_store_open(). Put them here until better place is found. + * XXX: Functions below logically belong to the fid module, but they are used + * by dt_store_open(). Put them here until better place is found. */ void fid_pack(struct lu_fid_pack *pack, const struct lu_fid *fid, -- GitLab