From 143845dbe536c96406c64129508256c071a9e92f Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Thu, 16 Oct 2008 15:33:10 -0700 Subject: [PATCH] kclient: mdsmap cleanups --- src/kernel/mdsmap.c | 26 +++++++++----------------- src/kernel/mdsmap.h | 35 ++++++++++++++++++++++------------- 2 files changed, 31 insertions(+), 30 deletions(-) diff --git a/src/kernel/mdsmap.c b/src/kernel/mdsmap.c index 911297ee03635..55b5e8010e2d6 100644 --- a/src/kernel/mdsmap.c +++ b/src/kernel/mdsmap.c @@ -16,14 +16,10 @@ int ceph_debug_mdsmap = -1; #define DOUT_PREFIX "mdsmap: " #include "super.h" -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]; -} +/* + * choose a random mds that is "up" (i.e. has a state > 0), or -1. + */ int ceph_mdsmap_get_random_mds(struct ceph_mdsmap *m) { int n = 0; @@ -48,13 +44,10 @@ int ceph_mdsmap_get_random_mds(struct ceph_mdsmap *m) return i; } -struct ceph_entity_addr *ceph_mdsmap_get_addr(struct ceph_mdsmap *m, int w) -{ - if (w >= m->m_max_mds) - return NULL; - return &m->m_addr[w]; -} - +/* + * Ignore any fields we don't care about in the MDS map (there are quite + * a few of them). + */ struct ceph_mdsmap *ceph_mdsmap_decode(void **p, void *end) { struct ceph_mdsmap *m; @@ -70,9 +63,8 @@ struct ceph_mdsmap *ceph_mdsmap_decode(void **p, void *end) ceph_decode_32(p, m->m_epoch); ceph_decode_32(p, m->m_client_epoch); ceph_decode_32(p, m->m_last_failure); - ceph_decode_32_le(p, m->m_created.tv_sec); - ceph_decode_32_le(p, m->m_created.tv_nsec); - ceph_decode_32(p, m->m_anchortable); + *p += sizeof(struct ceph_timespec); /* ignore map timestamp */ + *p += sizeof(__u32); /* skip anchortable */ ceph_decode_32(p, m->m_root); ceph_decode_32(p, m->m_session_timeout); ceph_decode_32(p, m->m_session_autoclose); diff --git a/src/kernel/mdsmap.h b/src/kernel/mdsmap.h index b90dc5c042c05..6ac39a4526177 100644 --- a/src/kernel/mdsmap.h +++ b/src/kernel/mdsmap.h @@ -9,23 +9,32 @@ * fields limited to those the client cares about */ struct ceph_mdsmap { - __u32 m_epoch, m_client_epoch, m_last_failure; - struct ceph_timespec m_created; - __u32 m_anchortable; - __u32 m_root; - __u32 m_session_timeout; - __u32 m_session_autoclose; - __u32 m_max_mds; /* size of m_addr, m_state arrays */ - struct ceph_entity_addr *m_addr; /* array of addresses */ - __s32 *m_state; /* array of states */ + u32 m_epoch, m_client_epoch, m_last_failure; + u32 m_root; + u32 m_session_timeout; /* seconds */ + u32 m_session_autoclose; /* seconds */ + u32 m_max_mds; /* size of m_addr, m_state arrays */ + struct ceph_entity_addr *m_addr; /* mds addrs */ + s32 *m_state; /* states */ }; -extern int ceph_mdsmap_get_random_mds(struct ceph_mdsmap *m); -extern int ceph_mdsmap_get_state(struct ceph_mdsmap *m, int w); -extern struct ceph_entity_addr *ceph_mdsmap_get_addr(struct ceph_mdsmap *m, int w); +static inline struct ceph_entity_addr *ceph_mdsmap_get_addr(struct ceph_mdsmap *m, int w) +{ + if (w >= m->m_max_mds) + return NULL; + return &m->m_addr[w]; +} + +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]; +} +extern int ceph_mdsmap_get_random_mds(struct ceph_mdsmap *m); extern struct ceph_mdsmap * ceph_mdsmap_decode(void **p, void *end); extern void ceph_mdsmap_destroy(struct ceph_mdsmap *m); - #endif -- 2.39.5