Whamcloud - gitweb
Separate lu_site stats printing code into a separate function that can be
authornikita <nikita>
Sat, 18 Oct 2008 17:25:19 +0000 (17:25 +0000)
committernikita <nikita>
Sat, 18 Oct 2008 17:25:19 +0000 (17:25 +0000)
reused on a client.
b=16450

lustre/ChangeLog
lustre/mdt/mdt_lproc.c
lustre/obdclass/lu_object.c

index a65dbba..8af96c9 100644 (file)
@@ -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>
index 9e45313..171c77a 100644 (file)
@@ -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,
index 8ecd85c..4c999b4 100644 (file)
@@ -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,