]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
kclient: add other maps to sysfs
authorSage Weil <sage@newdream.net>
Wed, 25 Feb 2009 18:06:03 +0000 (10:06 -0800)
committerSage Weil <sage@newdream.net>
Wed, 25 Feb 2009 18:12:05 +0000 (10:12 -0800)
src/TODO
src/kernel/osdmap.h
src/kernel/super.h
src/kernel/sysfs.c

index bab6bb10de762702727d3aa8f7dbac6e163678d4..b7b5295c68b415d63d1c0771412089fdf7d24409 100644 (file)
--- a/src/TODO
+++ b/src/TODO
@@ -4,7 +4,7 @@ v0.7
 /- fast truncate
 /- updated debian package
 - improved start/stop scripts
-- proc/sysfs cleanup
+/- proc/sysfs cleanup
 
 v0.8
 - fully async file creation
@@ -60,16 +60,6 @@ kernel client
 - set mapping bits for ENOSPC, EIO?
 - flush caps on sync, fsync, etc.
   - do we need to block?  how do we track that?
-- procfs/debugfs
-  - adjust granular debug levels too
-    - should we be using debugfs?
-  - a dir for each client instance (client###)?
-  - hooks to get mds, osd, monmap epoch #s
-- populate sysfs?
-  - things that would be useful to see
-    - fsid
-    - map versions on client
-    - outstanding mds, osd, mon requests?
 - fix readdir vs fragment race by keeping a separate frag pos, and ignoring dentries below it
 - reconnect after being disconnected from the mds
 
index 22eca126358a41216b6ab7afd0c11f01a820c336..f3b2964fa65165e8975e7c3062a330ea720a1f52 100644 (file)
@@ -35,8 +35,7 @@ struct ceph_osdmap {
 
        u32 max_osd;       /* size of osd_state, _offload, _addr arrays */
        u8 *osd_state;     /* CEPH_OSD_* */
-       u32 *osd_offload;  /* 0 = normal, 0x10000 = 100% offload (failed) */
-       u32 *osd_weight;
+       u32 *osd_weight;   /* 0 = failed, 0x10000 = 100% normal */
        struct ceph_entity_addr *osd_addr;
 
        /* the CRUSH map specifies the mapping of placement groups to
index 67aecd26782a2aed1615b0def1260b1d450c8dd6..eca2b23ff64a9ae2c9503205e247b6a342262a2c 100644 (file)
@@ -93,7 +93,7 @@ extern spinlock_t ceph_clients_list_lock;
 struct ceph_client {
        u32 whoami;                   /* my client number */
        struct kobject kobj;
-       struct kobj_attribute k_fsid;
+       struct kobj_attribute k_fsid, k_monmap, k_mdsmap, k_osdmap;
 
        struct mutex mount_mutex;       /* serialize mount attempts */
        struct ceph_mount_args mount_args;
index 4d270e83e4de308a41642bc22e4ec2df6cdaa411..667385e69c18902734ffde7da07267f4b26a442c 100644 (file)
@@ -5,6 +5,9 @@
 
 struct kobject ceph_kobj;
 
+/*
+ * per-client attributes
+ */
 struct kobj_type client_type = {
        .sysfs_ops = &kobj_sysfs_ops,
 };
@@ -21,7 +24,95 @@ ssize_t fsid_show(struct kobject *k_client, struct kobj_attribute *attr,
               le64_to_cpu(__ceph_fsid_minor(&client->monc.monmap->fsid)));
 }
 
-#define ADD_ATTR(a, n, m, sh, st) \
+ssize_t monmap_show(struct kobject *k_client, struct kobj_attribute *attr,
+                   char *buf)
+{
+       struct ceph_client *client = to_client(k_client);
+       int i, pos;
+
+       if (client->monc.monmap == NULL)
+               return 0;
+
+       pos = sprintf(buf, "epoch %d\n", client->monc.monmap->epoch);
+       for (i = 0; i < client->monc.monmap->num_mon; i++) {
+               struct ceph_entity_inst *inst =
+                       &client->monc.monmap->mon_inst[i];
+
+               if (pos > PAGE_SIZE - 128)
+                       break; /* be conservative */
+               pos += sprintf(buf + pos, "\t%s%d\t%u.%u.%u.%u:%u\n",
+                              ENTITY_NAME(inst->name),
+                              IPQUADPORT(inst->addr.ipaddr));
+       }
+       return pos;
+}
+
+ssize_t mdsmap_show(struct kobject *k_client, struct kobj_attribute *attr,
+                   char *buf)
+{
+       struct ceph_client *client = to_client(k_client);
+       int i, pos;
+
+       if (client->mdsc.mdsmap == NULL)
+               return 0;
+       pos = sprintf(buf, "epoch %d\n", client->mdsc.mdsmap->m_epoch);
+       pos += sprintf(buf + pos, "root %d\n", client->mdsc.mdsmap->m_root);
+       pos += sprintf(buf + pos, "session_timeout %d\n",
+                      client->mdsc.mdsmap->m_session_timeout);
+       pos += sprintf(buf + pos, "session_autoclose %d\n",
+                      client->mdsc.mdsmap->m_session_autoclose);
+       for (i = 0; i < client->mdsc.mdsmap->m_max_mds; i++) {
+               struct ceph_entity_addr *addr = &client->mdsc.mdsmap->m_addr[i];
+               int state = client->mdsc.mdsmap->m_state[i];
+
+               if (pos > PAGE_SIZE - 128)
+                       break; /* be conservative */
+               pos += sprintf(buf+pos, "\tmds%d\t%u.%u.%u.%u:%u\t(%s)\n",
+                              i,
+                              IPQUADPORT(addr->ipaddr),
+                              ceph_mdsmap_state_str(state));
+       }
+       return pos;
+}
+
+ssize_t osdmap_show(struct kobject *k_client, struct kobj_attribute *attr,
+                   char *buf)
+{
+       struct ceph_client *client = to_client(k_client);
+       int i, pos;
+
+       if (client->osdc.osdmap == NULL)
+               return 0;
+       pos = sprintf(buf, "epoch %d\n", client->osdc.osdmap->epoch);
+       pos += sprintf(buf + pos, "pg_num %d / %d\n",
+                      client->osdc.osdmap->pg_num,
+                      client->osdc.osdmap->pg_num_mask);
+       pos += sprintf(buf + pos, "lpg_num %d / %d\n",
+                      client->osdc.osdmap->lpg_num,
+                      client->osdc.osdmap->lpg_num_mask);
+       pos += sprintf(buf + pos, "flags%s%s\n",
+                      (client->osdc.osdmap->flags & CEPH_OSDMAP_NEARFULL) ?
+                      " NEARFULL":"",
+                      (client->osdc.osdmap->flags & CEPH_OSDMAP_FULL) ?
+                      " FULL":"");
+       for (i = 0; i < client->osdc.osdmap->max_osd; i++) {
+               struct ceph_entity_addr *addr =
+                       &client->osdc.osdmap->osd_addr[i];
+               int state = client->osdc.osdmap->osd_state[i];
+               char sb[64];
+
+               if (pos > PAGE_SIZE - 128)
+                       break; /* be conservative */
+               pos += sprintf(buf + pos,
+                      "\tosd%d\t%u.%u.%u.%u:%u\t%3d%%\t(%s)\n",
+                      i, IPQUADPORT(addr->ipaddr),
+                      ((client->osdc.osdmap->osd_weight[i]*100) >> 16),
+                      ceph_osdmap_state_str(sb, sizeof(sb), state));
+       }
+       return pos;
+}
+
+#define ADD_CLIENT_ATTR(a, n, m, sh, st) \
        client->a.attr.name = n; \
        client->a.attr.mode = m; \
        client->a.show = sh; \
@@ -38,7 +129,10 @@ int ceph_sysfs_client_init(struct ceph_client *client)
        if (ret)
                goto out;
 
-       ADD_ATTR(k_fsid, "fsid", 0400, fsid_show, NULL);
+       ADD_CLIENT_ATTR(k_fsid, "fsid", 0400, fsid_show, NULL);
+       ADD_CLIENT_ATTR(k_monmap, "monmap", 0400, monmap_show, NULL);
+       ADD_CLIENT_ATTR(k_mdsmap, "mdsmap", 0400, mdsmap_show, NULL);
+       ADD_CLIENT_ATTR(k_mdsmap, "osdmap", 0400, osdmap_show, NULL);
        return 0;
 
 out:
@@ -54,7 +148,7 @@ void ceph_sysfs_client_cleanup(struct ceph_client *client)
 }
 
 /*
- * /sys/fs/ceph attrs
+ * ceph attrs
  */
 struct ceph_attr {
        struct attribute attr;
@@ -84,7 +178,7 @@ struct kobj_type ceph_type = {
 };
 
 /*
- * simple int attrs
+ * simple int attrs (debug levels)
  */
 static ssize_t attr_show(struct kobject *ko, struct attribute *a, char *buf)
 {