]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
kernel osd_client bits
authorsageweil <sageweil@29311d96-e01e-0410-9327-a35deaab8ce9>
Tue, 20 Nov 2007 17:13:34 +0000 (17:13 +0000)
committersageweil <sageweil@29311d96-e01e-0410-9327-a35deaab8ce9>
Tue, 20 Nov 2007 17:13:34 +0000 (17:13 +0000)
git-svn-id: https://ceph.svn.sf.net/svnroot/ceph@2094 29311d96-e01e-0410-9327-a35deaab8ce9

trunk/ceph/kernel/client.c
trunk/ceph/kernel/osd_client.c
trunk/ceph/kernel/osd_client.h

index 31f8363a65ff122919fb57d96896aa88dbe464ad..b1919f9677f964ec51fce73f0907d86927b58ff2 100644 (file)
@@ -90,7 +90,7 @@ trymount:
        }
 
        /* get handle for mount path */
-       /*err = ceph_open_dir(CEPH_INO_ROOT, args->path);
+       /*err = ceph_mdsc_open_dir(&client->mdsc, CEPH_INO_ROOT, args->path);
        if (err)
                return err;
        */
@@ -121,7 +121,7 @@ static void handle_mon_map(struct ceph_client *client, struct ceph_msg *msg)
 
        clear_bit(4, &client->mounting);
        if (client->mounting == 0)
-               wake_up_all(&client->mount_wq);
+               wake_up(&client->mount_wq);
 }
 
 
index 2d5b493ea4988f5c7c8047bd104cab4b3c2b1171..53ec45273bf7a04ac9fe70f9da3a92b6847e8f11 100644 (file)
@@ -1,7 +1,121 @@
 
+#include <linux/slab.h>
+#include <linux/err.h>
+
+#include "../crush/crush.h"
 #include "osd_client.h"
 #include "messenger.h"
 
+/* maps */
+
+static int calc_bits_of(int t) 
+{
+       int b = 0;
+       while (t) {
+               t = t >> 1;
+               b++;
+       }
+       return b;
+}
+
+static void calc_pg_masks(struct ceph_osdmap *map)
+{
+       map->pg_num_mask = (1 << calc_bits_of(map->pg_num-1)) - 1;
+       map->localized_pg_num_mask = (1 << calc_bits_of(map->localized_pg_num-1)) - 1;
+}
+
+static struct crush_map *crush_decode(void **p, void *end)
+{
+       struct crush_map *c;
+       int err = -EINVAL;
+       
+       c = kmalloc(sizeof(*c), GFP_KERNEL);
+       if (c == NULL)
+               return ERR_PTR(-ENOMEM);
+
+       /* ... */
+
+       return c;
+
+bad:
+       return ERR_PTR(err);
+}
+
+void osdmap_destroy(struct ceph_osdmap *map)
+{
+       if (map->osd_state) kfree(map->osd_state);
+       if (map->crush) kfree(map->crush);
+       kfree(map);
+}
+
+static struct ceph_osdmap *osdmap_decode(void **p, void *end)
+{
+       struct ceph_osdmap *map;
+       __u32 crushlen;
+       int err;
+
+       map = kmalloc(sizeof(*map), GFP_KERNEL);
+       if (map == NULL) 
+               return ERR_PTR(-ENOMEM);
+
+       if ((err = ceph_decode_64(p, end, &map->fsid.major)) < 0)
+               goto bad;
+       if ((err = ceph_decode_64(p, end, &map->fsid.minor)) < 0)
+               goto bad;
+       if ((err = ceph_decode_64(p, end, &map->epoch)) < 0)
+               goto bad;
+       if ((err = ceph_decode_64(p, end, &map->mon_epoch)) < 0)
+               goto bad;
+       if ((err = ceph_decode_32(p, end, &map->ctime.tv_sec)) < 0)
+               goto bad;
+       if ((err = ceph_decode_32(p, end, &map->ctime.tv_usec)) < 0)
+               goto bad;
+
+       if ((err = ceph_decode_32(p, end, &map->pg_num)) < 0)
+               goto bad;
+       if ((err = ceph_decode_32(p, end, &map->localized_pg_num)) < 0)
+               goto bad;
+       calc_pg_masks(map);
+
+       if ((err = ceph_decode_32(p, end, &map->max_osd)) < 0)
+               goto bad;
+
+       /* alloc */
+       map->osd_state = kmalloc(map->max_osd * (sizeof(__u32)*2 + 
+                                                sizeof(struct ceph_entity_addr)),
+                                GFP_KERNEL);
+       if (map->osd_state == NULL) 
+               goto bad;
+       map->osd_offload = (void*)((__u32*)map->osd_state + map->max_osd);
+       map->osd_addr = (void*)(map->osd_offload + map->max_osd);
+       
+       /* osds */
+       if ((err = ceph_decode_copy(p, end, &map->osd_state, map->max_osd)) < 0)
+               goto bad;
+       if ((err = ceph_decode_copy(p, end, &map->osd_offload, map->max_osd*sizeof(*map->osd_offload))) < 0)
+               goto bad;
+       if ((err = ceph_decode_copy(p, end, &map->osd_addr, map->max_osd*sizeof(*map->osd_addr))) < 0)
+               goto bad;
+
+       /* crush */
+       if ((err = ceph_decode_32(p, end, &crushlen)) < 0)
+               goto bad;
+       map->crush = crush_decode(p, end);
+       if (IS_ERR(map->crush)) {
+               err = PTR_ERR(map->crush);
+               map->crush = 0;
+               goto bad;
+       }
+
+       return map;
+
+bad:
+       osdmap_destroy(map);
+       return ERR_PTR(err);
+}
+
+
+
 
 void ceph_osdc_init(struct ceph_osd_client *osdc)
 {
@@ -13,3 +127,5 @@ 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);
 }
+
+
index a8e3d64272733b04386e366bcfe5589adc660272..11b56f90cf4bc2d461e9c0bf4f02848948e45a95 100644 (file)
@@ -3,12 +3,26 @@
 
 /* this will be equivalent to osdc/Objecter.h */
 
-/* do these later
-#include "osdmap.h"
-*/
-struct ceph_osdmap;
+#include <linux/ceph_fs.h>
+
 struct ceph_msg;
 
+struct ceph_osdmap {
+       struct ceph_fsid fsid;
+       __u64 epoch;
+       __u64 mon_epoch;
+       struct ceph_timeval ctime, mtime;
+       
+       __u32 pg_num, pg_num_mask;
+       __u32 localized_pg_num, localized_pg_num_mask;
+       
+       __u32 max_osd;
+       __u8 *osd_state;
+       __u32 *osd_offload;  /* 0 = normal, 0x10000 = 100% offload (failed) */
+       struct ceph_entity_addr *osd_addr;
+       struct crush_map *crush;
+};
+
 struct ceph_osd_client {
        struct ceph_osdmap *osdmap;  /* current osd map */