fs/partitions: use ADDPART_FLAG_RAID instead of magic number
[safe/jmp/linux-2.6] / fs / ceph / debugfs.c
index b90fc3e..f7048da 100644 (file)
@@ -1,5 +1,7 @@
 #include "ceph_debug.h"
 
+#include <linux/device.h>
+#include <linux/slab.h>
 #include <linux/module.h>
 #include <linux/ctype.h>
 #include <linux/debugfs.h>
@@ -24,6 +26,7 @@
  *      .../monc        - mon client state
  *      .../dentry_lru  - dump contents of dentry lru
  *      .../caps        - expose cap (reservation) stats
+ *      .../bdi         - symlink to ../../bdi/something
  */
 
 static struct dentry *ceph_debugfs_dir;
@@ -76,6 +79,7 @@ static int osdmap_show(struct seq_file *s, void *p)
 {
        int i;
        struct ceph_client *client = s->private;
+       struct rb_node *n;
 
        if (client->osdc.osdmap == NULL)
                return 0;
@@ -85,11 +89,11 @@ static int osdmap_show(struct seq_file *s, void *p)
                   " NEARFULL" : "",
                   (client->osdc.osdmap->flags & CEPH_OSDMAP_FULL) ?
                   " FULL" : "");
-       for (i = 0; i < client->osdc.osdmap->num_pools; i++) {
+       for (n = rb_first(&client->osdc.osdmap->pg_pools); n; n = rb_next(n)) {
                struct ceph_pg_pool_info *pool =
-                       &client->osdc.osdmap->pg_pool[i];
+                       rb_entry(n, struct ceph_pg_pool_info, node);
                seq_printf(s, "pg_pool %d pg_num %d / %d, lpg_num %d / %d\n",
-                          i, pool->v.pg_num, pool->pg_num_mask,
+                          pool->id, pool->v.pg_num, pool->pg_num_mask,
                           pool->v.lpg_num, pool->lpg_num_mask);
        }
        for (i = 0; i < client->osdc.osdmap->max_osd; i++) {
@@ -110,9 +114,8 @@ static int monc_show(struct seq_file *s, void *p)
 {
        struct ceph_client *client = s->private;
        struct ceph_mon_statfs_request *req;
-       u64 nexttid = 0;
-       int got;
        struct ceph_mon_client *monc = &client->monc;
+       struct rb_node *rp;
 
        mutex_lock(&monc->mutex);
 
@@ -123,38 +126,28 @@ static int monc_show(struct seq_file *s, void *p)
        if (monc->want_next_osdmap)
                seq_printf(s, "want next osdmap\n");
 
-       while (nexttid < monc->last_tid) {
-               got = radix_tree_gang_lookup(&monc->statfs_request_tree,
-                                            (void **)&req, nexttid, 1);
-               if (got == 0)
-                       break;
-               nexttid = req->tid + 1;
-
+       for (rp = rb_first(&monc->statfs_request_tree); rp; rp = rb_next(rp)) {
+               req = rb_entry(rp, struct ceph_mon_statfs_request, node);
                seq_printf(s, "%lld statfs\n", req->tid);
        }
-       mutex_unlock(&monc->mutex);
 
+       mutex_unlock(&monc->mutex);
        return 0;
 }
 
 static int mdsc_show(struct seq_file *s, void *p)
 {
        struct ceph_client *client = s->private;
-       struct ceph_mds_request *req;
-       u64 nexttid = 0;
-       int got;
        struct ceph_mds_client *mdsc = &client->mdsc;
+       struct ceph_mds_request *req;
+       struct rb_node *rp;
        int pathlen;
        u64 pathbase;
        char *path;
 
        mutex_lock(&mdsc->mutex);
-       while (nexttid < mdsc->last_tid) {
-               got = radix_tree_gang_lookup(&mdsc->request_tree,
-                                            (void **)&req, nexttid, 1);
-               if (got == 0)
-                       break;
-               nexttid = req->r_tid + 1;
+       for (rp = rb_first(&mdsc->request_tree); rp; rp = rb_next(rp)) {
+               req = rb_entry(rp, struct ceph_mds_request, r_node);
 
                if (req->r_request)
                        seq_printf(s, "%lld\tmds%d\t", req->r_tid, req->r_mds);
@@ -229,8 +222,10 @@ static int osdc_show(struct seq_file *s, void *pp)
 
                req = rb_entry(p, struct ceph_osd_request, r_node);
 
-               seq_printf(s, "%lld\tosd%d\t", req->r_tid,
-                          req->r_osd ? req->r_osd->o_osd : -1);
+               seq_printf(s, "%lld\tosd%d\t%d.%x\t", req->r_tid,
+                          req->r_osd ? req->r_osd->o_osd : -1,
+                          le32_to_cpu(req->r_pgid.pool),
+                          le16_to_cpu(req->r_pgid.ps));
 
                head = req->r_request->front.iov_base;
                op = (void *)(head + 1);
@@ -262,14 +257,15 @@ static int osdc_show(struct seq_file *s, void *pp)
 static int caps_show(struct seq_file *s, void *p)
 {
        struct ceph_client *client = p;
-       int total, avail, used, reserved;
+       int total, avail, used, reserved, min;
 
-       ceph_reservation_status(client, &total, &avail, &used, &reserved);
+       ceph_reservation_status(client, &total, &avail, &used, &reserved, &min);
        seq_printf(s, "total\t\t%d\n"
-                     "avail\t\t%d\n"
-                     "used\t\t%d\n"
-                     "reserved\t%d\n",
-                  total, avail, used, reserved);
+                  "avail\t\t%d\n"
+                  "used\t\t%d\n"
+                  "reserved\t%d\n"
+                  "min\t%d\n",
+                  total, avail, used, reserved, min);
        return 0;
 }
 
@@ -318,6 +314,30 @@ DEFINE_SHOW_FUNC(osdc_show)
 DEFINE_SHOW_FUNC(dentry_lru_show)
 DEFINE_SHOW_FUNC(caps_show)
 
+static int congestion_kb_set(void *data, u64 val)
+{
+       struct ceph_client *client = (struct ceph_client *)data;
+
+       if (client)
+               client->mount_args->congestion_kb = (int)val;
+
+       return 0;
+}
+
+static int congestion_kb_get(void *data, u64 *val)
+{
+       struct ceph_client *client = (struct ceph_client *)data;
+
+       if (client)
+               *val = (u64)client->mount_args->congestion_kb;
+
+       return 0;
+}
+
+
+DEFINE_SIMPLE_ATTRIBUTE(congestion_kb_fops, congestion_kb_get,
+                       congestion_kb_set, "%llu\n");
+
 int __init ceph_debugfs_init(void)
 {
        ceph_debugfs_dir = debugfs_create_dir("ceph", NULL);
@@ -407,6 +427,18 @@ int ceph_debugfs_client_init(struct ceph_client *client)
        if (!client->debugfs_caps)
                goto out;
 
+       client->debugfs_congestion_kb = debugfs_create_file("writeback_congestion_kb",
+                                                  0600,
+                                                  client->debugfs_dir,
+                                                  client,
+                                                  &congestion_kb_fops);
+       if (!client->debugfs_congestion_kb)
+               goto out;
+
+       sprintf(name, "../../bdi/%s", dev_name(client->sb->s_bdi->dev));
+       client->debugfs_bdi = debugfs_create_symlink("bdi", client->debugfs_dir,
+                                                    name);
+
        return 0;
 
 out:
@@ -416,6 +448,7 @@ out:
 
 void ceph_debugfs_client_cleanup(struct ceph_client *client)
 {
+       debugfs_remove(client->debugfs_bdi);
        debugfs_remove(client->debugfs_caps);
        debugfs_remove(client->debugfs_dentry_lru);
        debugfs_remove(client->debugfs_osdmap);
@@ -424,6 +457,7 @@ void ceph_debugfs_client_cleanup(struct ceph_client *client)
        debugfs_remove(client->osdc.debugfs_file);
        debugfs_remove(client->mdsc.debugfs_file);
        debugfs_remove(client->monc.debugfs_file);
+       debugfs_remove(client->debugfs_congestion_kb);
        debugfs_remove(client->debugfs_dir);
 }