Commit f984cb76 authored by Ilya Dryomov's avatar Ilya Dryomov

libceph: make pgid_cmp() global

calc_target() code is going to need to know how to compare PGs.  Take
lhs and rhs pgid by const * while at it.
Signed-off-by: default avatarIlya Dryomov <idryomov@gmail.com>
parent f81f1633
...@@ -24,6 +24,8 @@ struct ceph_pg { ...@@ -24,6 +24,8 @@ struct ceph_pg {
uint32_t seed; uint32_t seed;
}; };
int ceph_pg_compare(const struct ceph_pg *lhs, const struct ceph_pg *rhs);
#define CEPH_POOL_FLAG_HASHPSPOOL 1 #define CEPH_POOL_FLAG_HASHPSPOOL 1
struct ceph_pg_pool_info { struct ceph_pg_pool_info {
......
...@@ -380,23 +380,24 @@ static struct crush_map *crush_decode(void *pbyval, void *end) ...@@ -380,23 +380,24 @@ static struct crush_map *crush_decode(void *pbyval, void *end)
return ERR_PTR(err); return ERR_PTR(err);
} }
/* int ceph_pg_compare(const struct ceph_pg *lhs, const struct ceph_pg *rhs)
* rbtree of pg_mapping for handling pg_temp (explicit mapping of pgid
* to a set of osds) and primary_temp (explicit primary setting)
*/
static int pgid_cmp(struct ceph_pg l, struct ceph_pg r)
{ {
if (l.pool < r.pool) if (lhs->pool < rhs->pool)
return -1; return -1;
if (l.pool > r.pool) if (lhs->pool > rhs->pool)
return 1; return 1;
if (l.seed < r.seed) if (lhs->seed < rhs->seed)
return -1; return -1;
if (l.seed > r.seed) if (lhs->seed > rhs->seed)
return 1; return 1;
return 0; return 0;
} }
/*
* rbtree of pg_mapping for handling pg_temp (explicit mapping of pgid
* to a set of osds) and primary_temp (explicit primary setting)
*/
static int __insert_pg_mapping(struct ceph_pg_mapping *new, static int __insert_pg_mapping(struct ceph_pg_mapping *new,
struct rb_root *root) struct rb_root *root)
{ {
...@@ -409,7 +410,7 @@ static int __insert_pg_mapping(struct ceph_pg_mapping *new, ...@@ -409,7 +410,7 @@ static int __insert_pg_mapping(struct ceph_pg_mapping *new,
while (*p) { while (*p) {
parent = *p; parent = *p;
pg = rb_entry(parent, struct ceph_pg_mapping, node); pg = rb_entry(parent, struct ceph_pg_mapping, node);
c = pgid_cmp(new->pgid, pg->pgid); c = ceph_pg_compare(&new->pgid, &pg->pgid);
if (c < 0) if (c < 0)
p = &(*p)->rb_left; p = &(*p)->rb_left;
else if (c > 0) else if (c > 0)
...@@ -432,7 +433,7 @@ static struct ceph_pg_mapping *__lookup_pg_mapping(struct rb_root *root, ...@@ -432,7 +433,7 @@ static struct ceph_pg_mapping *__lookup_pg_mapping(struct rb_root *root,
while (n) { while (n) {
pg = rb_entry(n, struct ceph_pg_mapping, node); pg = rb_entry(n, struct ceph_pg_mapping, node);
c = pgid_cmp(pgid, pg->pgid); c = ceph_pg_compare(&pgid, &pg->pgid);
if (c < 0) { if (c < 0) {
n = n->rb_left; n = n->rb_left;
} else if (c > 0) { } else if (c > 0) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment