]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
kclient: parse updated mdsmap
authorSage Weil <sage@newdream.net>
Tue, 29 Sep 2009 21:53:07 +0000 (14:53 -0700)
committerSage Weil <sage@newdream.net>
Tue, 29 Sep 2009 21:53:15 +0000 (14:53 -0700)
src/kernel/debugfs.c
src/kernel/mdsmap.c
src/kernel/mdsmap.h

index 8db43924cb9ce915bcafc9b78baf377ee6cdca44..15d2a4bc40fe0736decf06c229ddee236dd464c1 100644 (file)
@@ -58,8 +58,9 @@ static int mdsmap_show(struct seq_file *s, void *p)
        seq_printf(s, "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];
+               struct ceph_entity_addr *addr =
+                       &client->mdsc.mdsmap->m_info[i].addr;
+               int state = client->mdsc.mdsmap->m_info[i].state;
 
                seq_printf(s, "\tmds%d\t%u.%u.%u.%u:%u\t(%s)\n",
                               i,
index 8292ec2081b14fd53adcb983abf963532730c0c1..bd4e3900ffad8e9fb526701d6957286afbdb454b 100644 (file)
@@ -24,7 +24,7 @@ int ceph_mdsmap_get_random_mds(struct ceph_mdsmap *m)
 
        /* count */
        for (i = 0; i < m->m_max_mds; i++)
-               if (m->m_state[i] > 0)
+               if (m->m_info[i].state > 0)
                        n++;
        if (n == 0)
                return -1;
@@ -34,7 +34,7 @@ int ceph_mdsmap_get_random_mds(struct ceph_mdsmap *m)
        n = r % n;
        i = 0;
        for (i = 0; n > 0; i++, n--)
-               while (m->m_state[i] <= 0)
+               while (m->m_info[i].state <= 0)
                        i++;
 
        return i;
@@ -49,7 +49,7 @@ int ceph_mdsmap_get_random_mds(struct ceph_mdsmap *m)
 struct ceph_mdsmap *ceph_mdsmap_decode(void **p, void *end)
 {
        struct ceph_mdsmap *m;
-       int i, n;
+       int i, j, n;
        int err = -EINVAL;
        u16 version;
 
@@ -69,9 +69,8 @@ struct ceph_mdsmap *ceph_mdsmap_decode(void **p, void *end)
        ceph_decode_64(p, m->m_max_file_size);
        ceph_decode_32(p, m->m_max_mds);
 
-       m->m_addr = kcalloc(m->m_max_mds, sizeof(*m->m_addr), GFP_NOFS);
-       m->m_state = kcalloc(m->m_max_mds, sizeof(*m->m_state), GFP_NOFS);
-       if (m->m_addr == NULL || m->m_state == NULL)
+       m->m_info = kcalloc(m->m_max_mds, sizeof(*m->m_info), GFP_NOFS);
+       if (m->m_info == NULL)
                goto badmem;
 
        /* pick out active nodes from mds_info (state > 0) */
@@ -82,6 +81,8 @@ struct ceph_mdsmap *ceph_mdsmap_decode(void **p, void *end)
                u64 state_seq;
                u8 infoversion;
                struct ceph_entity_addr addr;
+               u32 num_export_targets;
+               void *pexport_targets = NULL;
 
                ceph_decode_need(p, end, sizeof(addr) + 1 + sizeof(u32), bad);
                *p += sizeof(addr);          /* skip addr key */
@@ -98,13 +99,35 @@ struct ceph_mdsmap *ceph_mdsmap_decode(void **p, void *end)
                ceph_decode_32(p, state);
                ceph_decode_64(p, state_seq);
                ceph_decode_copy(p, &addr, sizeof(addr));
-               *p += sizeof(struct ceph_timespec) + 2*sizeof(u32);
+               *p += sizeof(struct ceph_timespec);
+               *p += sizeof(u32);
+               ceph_decode_32_safe(p, end, namelen, bad);
+               *p += sizeof(namelen);
+               if (infoversion >= 2) {
+                       ceph_decode_32_safe(p, end, num_export_targets, bad);
+                       pexport_targets = *p;
+                       *p += sizeof(num_export_targets * sizeof(u32));
+               } else {
+                       num_export_targets = 0;
+               }
+
                dout("mdsmap_decode %d/%d mds%d.%d %u.%u.%u.%u:%u %s\n",
                     i+1, n, mds, inc, IPQUADPORT(addr.ipaddr),
                     ceph_mds_state_name(state));
                if (mds >= 0 && mds < m->m_max_mds && state > 0) {
-                       m->m_state[mds] = state;
-                       m->m_addr[mds] = addr;
+                       m->m_info[mds].state = state;
+                       m->m_info[mds].addr = addr;
+                       m->m_info[mds].num_export_targets = num_export_targets;
+                       if (num_export_targets) {
+                               m->m_info[mds].export_targets =
+                                       kcalloc(num_export_targets, sizeof(u32),
+                                               GFP_NOFS);
+                               for (j = 0; j < num_export_targets; j++)
+                                       ceph_decode_32(&pexport_targets,
+                                             m->m_info[mds].export_targets[j]);
+                       } else {
+                               m->m_info[mds].export_targets = NULL;
+                       }
                }
        }
 
@@ -133,8 +156,11 @@ bad:
 
 void ceph_mdsmap_destroy(struct ceph_mdsmap *m)
 {
-       kfree(m->m_addr);
-       kfree(m->m_state);
+       int i;
+
+       for (i = 0; i < m->m_max_mds; i++)
+               kfree(m->m_info[i].export_targets);
+       kfree(m->m_info);
        kfree(m->m_data_pg_pools);
        kfree(m);
 }
index ea8a0f5275879dd61b282cfe37f40e39e1a7b4c1..d317308648fb6dcc0d1360c5453b38911f00ebde 100644 (file)
@@ -8,6 +8,13 @@
  *
  * we limit fields to those the client actually xcares about
  */
+struct ceph_mds_info {
+       struct ceph_entity_addr addr;
+       s32 state;
+       int num_export_targets;
+       u32 *export_targets;
+};
+
 struct ceph_mdsmap {
        u32 m_epoch, m_client_epoch, m_last_failure;
        u32 m_root;
@@ -15,8 +22,7 @@ struct ceph_mdsmap {
        u32 m_session_autoclose;        /* seconds */
        u64 m_max_file_size;
        u32 m_max_mds;                  /* size of m_addr, m_state arrays */
-       struct ceph_entity_addr *m_addr;  /* mds addrs */
-       s32 *m_state;                   /* states */
+       struct ceph_mds_info *m_info;
 
        /* which object pools file data can be stored in */
        int m_num_data_pg_pools;
@@ -29,7 +35,7 @@ ceph_mdsmap_get_addr(struct ceph_mdsmap *m, int w)
 {
        if (w >= m->m_max_mds)
                return NULL;
-       return &m->m_addr[w];
+       return &m->m_info[w].addr;
 }
 
 static inline int ceph_mdsmap_get_state(struct ceph_mdsmap *m, int w)
@@ -37,7 +43,7 @@ static inline int ceph_mdsmap_get_state(struct ceph_mdsmap *m, int w)
        BUG_ON(w < 0);
        if (w >= m->m_max_mds)
                return CEPH_MDS_STATE_DNE;
-       return m->m_state[w];
+       return m->m_info[w].state;
 }
 
 extern int ceph_mdsmap_get_random_mds(struct ceph_mdsmap *m);