From ba73ac8cd29550f3102dba0453ca56afd464c90e Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Tue, 19 May 2009 12:26:12 -0700 Subject: [PATCH] kclient: remove bookkeeper --- src/Makefile.am | 2 - src/crush/crush.c | 1 - src/kernel/Kconfig | 6 - src/kernel/Makefile | 2 +- src/kernel/bookkeeper.c | 122 ------------------ src/kernel/bookkeeper.h | 31 ----- src/kernel/ceph_debug.h | 2 - src/kernel/debugfs.c | 34 ----- src/kernel/import_patch_set_into_linux_git.sh | 5 +- src/kernel/super.c | 7 - src/kernel/super.h | 7 - 11 files changed, 2 insertions(+), 217 deletions(-) delete mode 100644 src/kernel/bookkeeper.c delete mode 100644 src/kernel/bookkeeper.h diff --git a/src/Makefile.am b/src/Makefile.am index aeaa3b51ca2be..10632e321de74 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -381,8 +381,6 @@ noinst_HEADERS = \ kernel/Kconfig\ kernel/Makefile\ kernel/addr.c\ - kernel/bookkeeper.c\ - kernel/bookkeeper.h\ kernel/caps.c\ kernel/ceph_debug.h\ kernel/ceph_fs.h\ diff --git a/src/crush/crush.c b/src/crush/crush.c index 705d6acf5964a..d0f11287c3e02 100644 --- a/src/crush/crush.c +++ b/src/crush/crush.c @@ -1,7 +1,6 @@ #ifdef __KERNEL__ # include -# include "../bookkeeper.h" #else # include # include diff --git a/src/kernel/Kconfig b/src/kernel/Kconfig index 874657549909a..32090d3f54739 100644 --- a/src/kernel/Kconfig +++ b/src/kernel/Kconfig @@ -12,9 +12,3 @@ config CEPH_FS If unsure, say N. -config CEPH_BOOKKEEPER - bool "Ceph leaks detection tool" - depends on CEPH_FS - help - Leaks detection tool for the Ceph fs. - diff --git a/src/kernel/Makefile b/src/kernel/Makefile index 483e556416040..ba1e6a59f651a 100644 --- a/src/kernel/Makefile +++ b/src/kernel/Makefile @@ -12,7 +12,7 @@ ceph-objs := super.o inode.o dir.o file.o addr.o ioctl.o \ mds_client.o mdsmap.o \ mon_client.o \ osd_client.o osdmap.o crush/crush.o crush/mapper.o \ - debugfs.o bookkeeper.o + debugfs.o else #Otherwise we were called directly from the command diff --git a/src/kernel/bookkeeper.c b/src/kernel/bookkeeper.c deleted file mode 100644 index 5e281ca1d4f73..0000000000000 --- a/src/kernel/bookkeeper.c +++ /dev/null @@ -1,122 +0,0 @@ -#include -#include -#include - -#define CEPH_OVERRIDE_BOOKKEEPER /* avoid kmalloc/kfree recursion */ - -#define CEPH_BK_MAGIC 0x140985AC - -#include "ceph_debug.h" - -int ceph_debug_tools __read_mostly = -1; -#define DOUT_VAR ceph_debug_tools -#define DOUT_MASK DOUT_MASK_TOOLS -#include "super.h" - -static struct list_head _bk_allocs; - -static DEFINE_SPINLOCK(_bk_lock); - -static size_t _total_alloc; -static size_t _total_free; - -struct alloc_data { - u32 prefix_magic; - struct list_head node; - size_t size; - char *fname; - int line; - u32 suffix_magic; -}; - -void *ceph_kmalloc(char *fname, int line, size_t size, gfp_t flags) -{ - struct alloc_data *p = kmalloc(size+sizeof(struct alloc_data), flags); - - if (!p) - return NULL; - - p->prefix_magic = CEPH_BK_MAGIC; - p->size = size; - p->fname = fname; - p->line = line; - p->suffix_magic = CEPH_BK_MAGIC; - - spin_lock(&_bk_lock); - _total_alloc += size; - - list_add_tail(&p->node, &_bk_allocs); - spin_unlock(&_bk_lock); - - return ((void *)p)+sizeof(struct alloc_data); -} - -void ceph_kfree(const void *ptr) -{ - struct alloc_data *p = (struct alloc_data *)(ptr - - sizeof(struct alloc_data)); - int overrun = 0; - - if (!ptr) - return; - - if (p->prefix_magic != CEPH_BK_MAGIC) { - derr(0, "ERROR: memory overrun (under)!\n"); - overrun = 1; - } - - if (p->suffix_magic != CEPH_BK_MAGIC) { - derr(0, "ERROR: Memory overrun (over)!\n"); - overrun = 1; - } - - if (overrun) { - derr(0, "Memory allocated at %s(%d): p=%p (%zu bytes)\n", - p->fname, p->line, ((void *)p)+sizeof(struct alloc_data), - p->size); - } - - BUG_ON(overrun); - - spin_lock(&_bk_lock); - _total_free += p->size; - list_del(&p->node); - spin_unlock(&_bk_lock); - - kfree(p); - - return; -} - - -void ceph_bookkeeper_dump(void) -{ - struct list_head *p; - struct alloc_data *entry; - - dout(1, "bookkeeper: total bytes alloc: %zu\n", _total_alloc); - dout(1, "bookkeeper: total bytes free: %zu\n", _total_free); - - if (_total_alloc != _total_free) { - list_for_each(p, &_bk_allocs) { - entry = list_entry(p, struct alloc_data, node); - dout(1, "%s(%d): p=%p (%zu bytes)\n", entry->fname, - entry->line, - ((void *)entry)+sizeof(struct alloc_data), - entry->size); - } - } else { - dout(1, "No leaks found! Yay!\n"); - } -} - -void ceph_bookkeeper_init(void) -{ - dout(10, "bookkeeper: start\n"); - INIT_LIST_HEAD(&_bk_allocs); -} - -void ceph_bookkeeper_finalize(void) -{ - ceph_bookkeeper_dump(); -} diff --git a/src/kernel/bookkeeper.h b/src/kernel/bookkeeper.h deleted file mode 100644 index 7b73dbfb53fc2..0000000000000 --- a/src/kernel/bookkeeper.h +++ /dev/null @@ -1,31 +0,0 @@ -#ifdef CONFIG_CEPH_BOOKKEEPER - -#ifndef _FS_CEPH_BOOKKEEPER_H -#define _FS_CEPH_BOOKKEEPER_H - -extern void ceph_bookkeeper_dump(void); -extern void ceph_bookkeeper_init(void); -extern void ceph_bookkeeper_finalize(void); -extern void *ceph_kmalloc(char *fname, int line, size_t size, gfp_t flags); -extern void ceph_kfree(const void *ptr); - -#endif - - -#ifndef CEPH_OVERRIDE_BOOKKEEPER -#define CEPH_BOOKKEEPER_DEFINED -#define kmalloc(size, flags) ceph_kmalloc(__FILE__, __LINE__, size, flags) -#define kzalloc(size, flags) ceph_kmalloc(__FILE__, __LINE__, size, \ - flags | __GFP_ZERO) -#define kfree ceph_kfree -#endif - -#ifdef CEPH_DISABLE_BOOKKEEPER -#ifdef CEPH_BOOKKEEPER_DEFINED -#undef kmalloc -#undef kzalloc -#undef kfree -#endif -#endif - -#endif diff --git a/src/kernel/ceph_debug.h b/src/kernel/ceph_debug.h index c8f3f406b98c3..c5cfaece18d45 100644 --- a/src/kernel/ceph_debug.h +++ b/src/kernel/ceph_debug.h @@ -3,8 +3,6 @@ #include -#include "bookkeeper.h" - extern int ceph_debug __read_mostly; /* debug level. */ extern int ceph_debug_console __read_mostly; /* send debug output to console? */ extern int ceph_debug_mask __read_mostly; diff --git a/src/kernel/debugfs.c b/src/kernel/debugfs.c index 1d4a9c4d95cd4..45468d744d50a 100644 --- a/src/kernel/debugfs.c +++ b/src/kernel/debugfs.c @@ -5,7 +5,6 @@ #include "super.h" #include "mds_client.h" -#include "bookkeeper.h" static struct dentry *ceph_debugfs_dir; static struct dentry *ceph_debugfs_debug; @@ -13,9 +12,6 @@ static struct dentry *ceph_debugfs_debug_msgr; static struct dentry *ceph_debugfs_debug_console; static struct dentry *ceph_debugfs_debug_mask; static struct dentry *ceph_debugfs_caps_reservation; -#ifdef CONFIG_CEPH_BOOKKEEPER -static struct dentry *ceph_debugfs_bookkeeper; -#endif /* * ceph_debug_mask @@ -431,24 +427,6 @@ DEFINE_SHOW_FUNC(osdc_show) DEFINE_SHOW_FUNC(caps_reservation_show) DEFINE_SHOW_FUNC(dentry_lru_show) -#ifdef CONFIG_CEPH_BOOKKEEPER -static int debugfs_bookkeeper_set(void *data, u64 val) -{ - if (val) - ceph_bookkeeper_dump(); - return 0; -} - -static int debugfs_bookkeeper_get(void *data, u64 *val) -{ - *val = 0; - return 0; -} - -DEFINE_SIMPLE_ATTRIBUTE(bookkeeper_fops, debugfs_bookkeeper_get, - debugfs_bookkeeper_set, "%llu\n"); -#endif - int ceph_debugfs_init(void) { int ret = -ENOMEM; @@ -495,15 +473,6 @@ int ceph_debugfs_init(void) if (!ceph_debugfs_caps_reservation) goto out; -#ifdef CONFIG_CEPH_BOOKKEEPER - ceph_debugfs_bookkeeper = debugfs_create_file("show_bookkeeper", - 0600, - ceph_debugfs_dir, - NULL, - &bookkeeper_fops); - if (!ceph_debugfs_bookkeeper) - goto out; -#endif return 0; out: @@ -518,9 +487,6 @@ void ceph_debugfs_cleanup(void) debugfs_remove(ceph_debugfs_debug_mask); debugfs_remove(ceph_debugfs_debug_msgr); debugfs_remove(ceph_debugfs_debug); -#ifdef CONFIG_CEPH_BOOKKEEPER - debugfs_remove(ceph_debugfs_bookkeeper); -#endif debugfs_remove(ceph_debugfs_dir); } diff --git a/src/kernel/import_patch_set_into_linux_git.sh b/src/kernel/import_patch_set_into_linux_git.sh index 7ee2210cbc576..cbc9d05e5f78f 100755 --- a/src/kernel/import_patch_set_into_linux_git.sh +++ b/src/kernel/import_patch_set_into_linux_git.sh @@ -288,14 +288,11 @@ parameters. EOF git add fs/ceph/ceph_debug.h -git add fs/ceph/bookkeeper.h -git add fs/ceph/bookkeeper.c git commit -F - < #include #include @@ -11,9 +8,6 @@ #include #include -#undef CEPH_DISABLE_BOOKKEEPER -#include "bookkeeper.h" - #include "types.h" #include "ceph_debug.h" #include "messenger.h" @@ -21,7 +15,6 @@ #include "mds_client.h" #include "osd_client.h" #include "ceph_fs.h" -#include "bookkeeper.h" /* f_type in struct statfs */ #define CEPH_SUPER_MAGIC 0x00c36400 -- 2.39.5