From dcaca3e08c138e6de35a769b752f5496f3488cf2 Mon Sep 17 00:00:00 2001 From: Yehuda Sadeh Date: Wed, 1 Apr 2009 14:22:41 -0700 Subject: [PATCH] kclient: debugfs for caps reservation system --- src/kernel/caps.c | 13 +++++++++++++ src/kernel/debugfs.c | 24 ++++++++++++++++++++++++ src/kernel/super.h | 1 + 3 files changed, 38 insertions(+) diff --git a/src/kernel/caps.c b/src/kernel/caps.c index 4301628ad02aa..66bf49235448e 100644 --- a/src/kernel/caps.c +++ b/src/kernel/caps.c @@ -2088,3 +2088,16 @@ void ceph_put_cap(struct ceph_cap *cap) list_add(&cap->caps_item, &caps_list); spin_unlock(&caps_list_lock); } + +void ceph_reservation_status(int *total, int *used, int *reserved) +{ + if (total) + *total = caps_count; + + if (used) + *used = caps_use_count; + + if (reserved) + *reserved = caps_reserve_count; +} + diff --git a/src/kernel/debugfs.c b/src/kernel/debugfs.c index de664447cc6c5..0d95dc2a93665 100644 --- a/src/kernel/debugfs.c +++ b/src/kernel/debugfs.c @@ -12,6 +12,7 @@ static struct dentry *ceph_debugfs_debug; 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 @@ -367,6 +368,19 @@ static int osdc_show(struct seq_file *s, void *p) return 0; } +static int caps_reservation_show(struct seq_file *s, void *p) +{ + int total, used, reserved; + + ceph_reservation_status(&total, &used, &reserved); + + seq_printf(s, "total\t%d\n" + "used\t%d\n" + "reserved\t%d\n", + total, used, reserved); + return 0; +} + #define DEFINE_SHOW_FUNC(name) \ static int name##_open(struct inode *inode, struct file *file) \ { \ @@ -393,6 +407,7 @@ DEFINE_SHOW_FUNC(osdmap_show) DEFINE_SHOW_FUNC(monc_show) DEFINE_SHOW_FUNC(mdsc_show) DEFINE_SHOW_FUNC(osdc_show) +DEFINE_SHOW_FUNC(caps_reservation_show) #ifdef CONFIG_CEPH_BOOKKEEPER static int debugfs_bookkeeper_set(void *data, u64 val) @@ -449,6 +464,14 @@ int ceph_debugfs_init(void) if (!ceph_debugfs_debug_mask) goto out; + ceph_debugfs_caps_reservation = debugfs_create_file("caps_reservation", + 0400, + ceph_debugfs_dir, + NULL, + &caps_reservation_show_fops); + if (!ceph_debugfs_caps_reservation) + goto out; + #ifdef CONFIG_CEPH_BOOKKEEPER ceph_debugfs_bookkeeper = debugfs_create_file("show_bookkeeper", 0600, @@ -467,6 +490,7 @@ out: void ceph_debugfs_cleanup(void) { + debugfs_remove(ceph_debugfs_caps_reservation); debugfs_remove(ceph_debugfs_debug_console); debugfs_remove(ceph_debugfs_debug_mask); debugfs_remove(ceph_debugfs_debug_msgr); diff --git a/src/kernel/super.h b/src/kernel/super.h index 97502bbdb9f85..17632e3c67d25 100644 --- a/src/kernel/super.h +++ b/src/kernel/super.h @@ -517,6 +517,7 @@ extern int ceph_unreserve_caps(struct ceph_caps_reservation *ctx); extern struct ceph_cap *ceph_get_cap(struct ceph_caps_reservation *ctx, int mode); extern struct ceph_cap *ceph_get_reserved_cap(struct ceph_caps_reservation *ctx); extern void ceph_put_cap(struct ceph_cap *cap); +extern void ceph_reservation_status(int *total, int *used, int *reserved); static inline struct ceph_client *ceph_inode_to_client(struct inode *inode) { -- 2.39.5