]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph-client.git/commitdiff
ceph bookkeeper: show memory footprint historic/bookkeeper
authorYehuda Sadeh <yehuda@hq.newdream.net>
Tue, 15 Dec 2009 01:01:13 +0000 (17:01 -0800)
committerYehuda Sadeh <yehuda@hq.newdream.net>
Tue, 15 Dec 2009 01:01:13 +0000 (17:01 -0800)
fs/ceph/bookkeeper.c
fs/ceph/bookkeeper.h
fs/ceph/debugfs.c

index 8edfac9dc662556322ab62f4fc302398ab18323d..98051b7cc38c2072903c20caf074be671be36ffa 100644 (file)
@@ -257,6 +257,15 @@ char *ceph_kstrndup(char *fname, int line, const char *src, int n, gfp_t flags)
        return dst;
 }
 
+size_t ceph_bookkeeper_get_footprint(void)
+{
+       size_t footprint;
+       spin_lock(&_bk_lock);
+       footprint = _total_alloc - _total_free;
+       spin_unlock(&_bk_lock);
+       return footprint;
+}
+
 void ceph_bookkeeper_init(void)
 {
        printk(KERN_ERR "bookkeeper: start\n");
@@ -273,3 +282,4 @@ void ceph_bookkeeper_finalize(void)
 {
        ceph_bookkeeper_dump();
 }
+
index db7f9738d97a5e13a96d914fa242ed122f68d355..70bd32926121889b94bf50c300ae296d56aea168 100644 (file)
@@ -24,6 +24,7 @@ extern void *ceph_kmem_cache_alloc(char *fname, int line, struct kmem_cache *cac
                           gfp_t flags);
 
 extern void ceph_kmem_cache_free(struct kmem_cache *cachep, void *objp);
+extern size_t ceph_bookkeeper_get_footprint(void);
 
 #endif
 
index 21a8b42121050b230212ae06e45f1fe9162a8f94..5ddea948c89edacfe3bb0e63132174f1ffb352d3 100644 (file)
@@ -29,6 +29,7 @@
 static struct dentry *ceph_debugfs_dir;
 #ifdef CONFIG_CEPH_BOOKKEEPER
 static struct dentry *ceph_debugfs_bookkeeper;
+static struct dentry *ceph_debugfs_footprint;
 #endif
 
 static int monmap_show(struct seq_file *s, void *p)
@@ -335,8 +336,16 @@ static int debugfs_bookkeeper_get(void *data, u64 *val)
        return 0;
 }
 
+static int debugfs_footprint_get(void *data, u64 *val)
+{
+       *val = (u64)ceph_bookkeeper_get_footprint();
+       return 0;
+}
+
 DEFINE_SIMPLE_ATTRIBUTE(bookkeeper_fops, debugfs_bookkeeper_get,
                        debugfs_bookkeeper_set, "%llu\n");
+DEFINE_SIMPLE_ATTRIBUTE(footprint_fops, debugfs_footprint_get,
+                       NULL, "%llu\n");
 #endif
 
 int __init ceph_debugfs_init(void)
@@ -436,6 +445,14 @@ int ceph_debugfs_client_init(struct ceph_client *client)
                                        &bookkeeper_fops);
        if (!ceph_debugfs_bookkeeper)
                goto out;
+
+       ceph_debugfs_footprint = debugfs_create_file("ceph_footprint",
+                                       0600,
+                                       ceph_debugfs_dir,
+                                       NULL,
+                                       &footprint_fops);
+       if (!ceph_debugfs_footprint)
+               goto out;
 #endif
        return 0;