Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 373402
b: refs/heads/master
c: ef4859d
h: refs/heads/master
v: v3
  • Loading branch information
Alex Elder authored and Sage Weil committed May 2, 2013
1 parent 8f3d1c8 commit a3e0585
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 42 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 8058fd45039724695d5b67a574544452635d64a9
refs/heads/master: ef4859d6479d19bcc65c3156cf3b7dd747355c29
24 changes: 24 additions & 0 deletions trunk/include/linux/ceph/osdmap.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

#include <linux/rbtree.h>
#include <linux/ceph/types.h>
#include <linux/ceph/decode.h>
#include <linux/ceph/ceph_fs.h>
#include <linux/crush/crush.h>

Expand Down Expand Up @@ -119,6 +120,29 @@ static inline struct ceph_entity_addr *ceph_osd_addr(struct ceph_osdmap *map,
return &map->osd_addr[osd];
}

static inline int ceph_decode_pgid(void **p, void *end, struct ceph_pg *pgid)
{
__u8 version;

if (!ceph_has_room(p, end, 1 + 8 + 4 + 4)) {
pr_warning("incomplete pg encoding");

return -EINVAL;
}
version = ceph_decode_8(p);
if (version > 1) {
pr_warning("do not understand pg encoding %d > 1",
(int)version);
return -EINVAL;
}

pgid->pool = ceph_decode_64(p);
pgid->seed = ceph_decode_32(p);
*p += 4; /* skip deprecated preferred value */

return 0;
}

extern struct ceph_osdmap *osdmap_decode(void **p, void *end);
extern struct ceph_osdmap *osdmap_apply_incremental(void **p, void *end,
struct ceph_osdmap *map,
Expand Down
22 changes: 1 addition & 21 deletions trunk/net/ceph/osd_client.c
Original file line number Diff line number Diff line change
Expand Up @@ -1268,26 +1268,6 @@ static void complete_request(struct ceph_osd_request *req)
complete_all(&req->r_safe_completion); /* fsync waiter */
}

static int __decode_pgid(void **p, void *end, struct ceph_pg *pgid)
{
__u8 v;

ceph_decode_need(p, end, 1 + 8 + 4 + 4, bad);
v = ceph_decode_8(p);
if (v > 1) {
pr_warning("do not understand pg encoding %d > 1", v);
return -EINVAL;
}
pgid->pool = ceph_decode_64(p);
pgid->seed = ceph_decode_32(p);
*p += 4;
return 0;

bad:
pr_warning("incomplete pg encoding");
return -EINVAL;
}

/*
* handle osd op reply. either call the callback if it is specified,
* or do the completion to wake up the waiting thread.
Expand Down Expand Up @@ -1321,7 +1301,7 @@ static void handle_reply(struct ceph_osd_client *osdc, struct ceph_msg *msg,
ceph_decode_need(&p, end, object_len, bad);
p += object_len;

err = __decode_pgid(&p, end, &pg);
err = ceph_decode_pgid(&p, end, &pg);
if (err)
goto bad;

Expand Down
22 changes: 2 additions & 20 deletions trunk/net/ceph/osdmap.c
Original file line number Diff line number Diff line change
Expand Up @@ -654,24 +654,6 @@ static int osdmap_set_max_osd(struct ceph_osdmap *map, int max)
return 0;
}

static int __decode_pgid(void **p, void *end, struct ceph_pg *pg)
{
u8 v;

ceph_decode_need(p, end, 1+8+4+4, bad);
v = ceph_decode_8(p);
if (v != 1)
goto bad;
pg->pool = ceph_decode_64(p);
pg->seed = ceph_decode_32(p);
*p += 4; /* skip preferred */
return 0;

bad:
dout("error decoding pgid\n");
return -EINVAL;
}

/*
* decode a full map.
*/
Expand Down Expand Up @@ -765,7 +747,7 @@ struct ceph_osdmap *osdmap_decode(void **p, void *end)
struct ceph_pg pgid;
struct ceph_pg_mapping *pg;

err = __decode_pgid(p, end, &pgid);
err = ceph_decode_pgid(p, end, &pgid);
if (err)
goto bad;
ceph_decode_need(p, end, sizeof(u32), bad);
Expand Down Expand Up @@ -983,7 +965,7 @@ struct ceph_osdmap *osdmap_apply_incremental(void **p, void *end,
struct ceph_pg pgid;
u32 pglen;

err = __decode_pgid(p, end, &pgid);
err = ceph_decode_pgid(p, end, &pgid);
if (err)
goto bad;
ceph_decode_need(p, end, sizeof(u32), bad);
Expand Down

0 comments on commit a3e0585

Please sign in to comment.