From 6038210594aa36ccb7f8405a1299d1dca0a5a50f Mon Sep 17 00:00:00 2001 From: sageweil Date: Fri, 16 Nov 2007 18:44:26 +0000 Subject: [PATCH] missing pieces git-svn-id: https://ceph.svn.sf.net/svnroot/ceph@2074 29311d96-e01e-0410-9327-a35deaab8ce9 --- trunk/ceph/kernel/Makefile | 3 ++- trunk/ceph/kernel/client.c | 2 +- trunk/ceph/kernel/mon_client.c | 16 ++++++++++++++++ trunk/ceph/kernel/monmap.c | 26 ++++++++++++++++++++++++++ trunk/ceph/kernel/osd_client.c | 15 +++++++++++++++ trunk/ceph/kernel/osd_client.h | 4 ++-- 6 files changed, 62 insertions(+), 4 deletions(-) create mode 100644 trunk/ceph/kernel/mon_client.c create mode 100644 trunk/ceph/kernel/monmap.c create mode 100644 trunk/ceph/kernel/osd_client.c diff --git a/trunk/ceph/kernel/Makefile b/trunk/ceph/kernel/Makefile index 7e87822352fd5..269f6b1da5ded 100644 --- a/trunk/ceph/kernel/Makefile +++ b/trunk/ceph/kernel/Makefile @@ -8,4 +8,5 @@ ceph-objs := super.o inode.o \ bufferlist.o ktcp.o messenger.o \ client.o \ mds_client.o mdsmap.o \ - mon_client.o monmap.o + mon_client.o monmap.o \ + osd_client.o diff --git a/trunk/ceph/kernel/client.c b/trunk/ceph/kernel/client.c index 99d338c50b13c..451ae1a804b86 100644 --- a/trunk/ceph/kernel/client.c +++ b/trunk/ceph/kernel/client.c @@ -44,7 +44,7 @@ static int mount(struct ceph_client *client, struct ceph_mount_args *args) int attempts = 10; int which; - client->mounting = 7; + client->mounting = 6; /* FIXME don't wait for osd map, for now */ /* send mount request */ mount_msg = ceph_msg_new(CEPH_MSG_CLIENT_MOUNT, 0, 0, 0); diff --git a/trunk/ceph/kernel/mon_client.c b/trunk/ceph/kernel/mon_client.c new file mode 100644 index 0000000000000..3019ba601872a --- /dev/null +++ b/trunk/ceph/kernel/mon_client.c @@ -0,0 +1,16 @@ + +#include +#include +#include "mon_client.h" + + +static int pick_mon(struct ceph_mon_client *monc, int notmon) +{ + if (notmon < 0 && monc->last_mon >= 0) + return monc->last_mon; + monc->last_mon = get_random_int() % monc->monmap.num_mon; + return monc->last_mon; +} + + + diff --git a/trunk/ceph/kernel/monmap.c b/trunk/ceph/kernel/monmap.c new file mode 100644 index 0000000000000..05765efe37b2a --- /dev/null +++ b/trunk/ceph/kernel/monmap.c @@ -0,0 +1,26 @@ +#include +#include "monmap.h" +#include "messenger.h" + +int ceph_monmap_decode(struct ceph_monmap *m, void **p, void *end) +{ + int err; + + if ((err = ceph_decode_64(p, end, &m->epoch)) < 0) + return err; + if ((err = ceph_decode_32(p, end, &m->num_mon)) < 0) + return err; + + m->mon_inst = kmalloc(m->num_mon*sizeof(*m->mon_inst), GFP_KERNEL); + if (m->mon_inst == NULL) + return -ENOMEM; + if ((err = ceph_decode_copy(p, end, m->mon_inst, m->num_mon*sizeof(m->mon_inst[0]))) < 0) + goto bad; + + return 0; + +bad: + kfree(m->mon_inst); + m->mon_inst = 0; + return err; +} diff --git a/trunk/ceph/kernel/osd_client.c b/trunk/ceph/kernel/osd_client.c new file mode 100644 index 0000000000000..2d5b493ea4988 --- /dev/null +++ b/trunk/ceph/kernel/osd_client.c @@ -0,0 +1,15 @@ + +#include "osd_client.h" +#include "messenger.h" + + +void ceph_osdc_init(struct ceph_osd_client *osdc) +{ + osdc->osdmap = NULL; +} + +void ceph_osdc_handle_map(struct ceph_osd_client *osdc, struct ceph_msg *msg) +{ + dout(1, "ceph_osdc_handle_map - implement me\n"); + ceph_msg_put(msg); +} diff --git a/trunk/ceph/kernel/osd_client.h b/trunk/ceph/kernel/osd_client.h index 6f643646b9427..a8e3d64272733 100644 --- a/trunk/ceph/kernel/osd_client.h +++ b/trunk/ceph/kernel/osd_client.h @@ -7,10 +7,10 @@ #include "osdmap.h" */ struct ceph_osdmap; - +struct ceph_msg; struct ceph_osd_client { - struct ceph_osdmap *osdmap; /* osd map */ + struct ceph_osdmap *osdmap; /* current osd map */ }; -- 2.39.5