Commit 92bb062f authored by Linus Torvalds's avatar Linus Torvalds

Merge branch 'for-linus' of git://github.com/NewDreamNetwork/ceph-client

* 'for-linus' of git://github.com/NewDreamNetwork/ceph-client:
  libceph: fix pg_temp mapping update
  libceph: fix pg_temp mapping calculation
  libceph: fix linger request requeuing
  libceph: fix parse options memory leak
  libceph: initialize ack_stamp to avoid unnecessary connection reset
parents 7409b713 8adc8b3d
...@@ -232,6 +232,7 @@ void ceph_destroy_options(struct ceph_options *opt) ...@@ -232,6 +232,7 @@ void ceph_destroy_options(struct ceph_options *opt)
ceph_crypto_key_destroy(opt->key); ceph_crypto_key_destroy(opt->key);
kfree(opt->key); kfree(opt->key);
} }
kfree(opt->mon_addr);
kfree(opt); kfree(opt);
} }
EXPORT_SYMBOL(ceph_destroy_options); EXPORT_SYMBOL(ceph_destroy_options);
......
...@@ -2307,6 +2307,7 @@ struct ceph_msg *ceph_msg_new(int type, int front_len, gfp_t flags) ...@@ -2307,6 +2307,7 @@ struct ceph_msg *ceph_msg_new(int type, int front_len, gfp_t flags)
m->front_max = front_len; m->front_max = front_len;
m->front_is_vmalloc = false; m->front_is_vmalloc = false;
m->more_to_follow = false; m->more_to_follow = false;
m->ack_stamp = 0;
m->pool = NULL; m->pool = NULL;
/* middle */ /* middle */
......
...@@ -217,6 +217,7 @@ struct ceph_osd_request *ceph_osdc_alloc_request(struct ceph_osd_client *osdc, ...@@ -217,6 +217,7 @@ struct ceph_osd_request *ceph_osdc_alloc_request(struct ceph_osd_client *osdc,
INIT_LIST_HEAD(&req->r_unsafe_item); INIT_LIST_HEAD(&req->r_unsafe_item);
INIT_LIST_HEAD(&req->r_linger_item); INIT_LIST_HEAD(&req->r_linger_item);
INIT_LIST_HEAD(&req->r_linger_osd); INIT_LIST_HEAD(&req->r_linger_osd);
INIT_LIST_HEAD(&req->r_req_lru_item);
req->r_flags = flags; req->r_flags = flags;
WARN_ON((flags & (CEPH_OSD_FLAG_READ|CEPH_OSD_FLAG_WRITE)) == 0); WARN_ON((flags & (CEPH_OSD_FLAG_READ|CEPH_OSD_FLAG_WRITE)) == 0);
...@@ -816,13 +817,10 @@ static void __register_request(struct ceph_osd_client *osdc, ...@@ -816,13 +817,10 @@ static void __register_request(struct ceph_osd_client *osdc,
{ {
req->r_tid = ++osdc->last_tid; req->r_tid = ++osdc->last_tid;
req->r_request->hdr.tid = cpu_to_le64(req->r_tid); req->r_request->hdr.tid = cpu_to_le64(req->r_tid);
INIT_LIST_HEAD(&req->r_req_lru_item);
dout("__register_request %p tid %lld\n", req, req->r_tid); dout("__register_request %p tid %lld\n", req, req->r_tid);
__insert_request(osdc, req); __insert_request(osdc, req);
ceph_osdc_get_request(req); ceph_osdc_get_request(req);
osdc->num_requests++; osdc->num_requests++;
if (osdc->num_requests == 1) { if (osdc->num_requests == 1) {
dout(" first request, scheduling timeout\n"); dout(" first request, scheduling timeout\n");
__schedule_osd_timeout(osdc); __schedule_osd_timeout(osdc);
......
...@@ -339,6 +339,7 @@ static int __insert_pg_mapping(struct ceph_pg_mapping *new, ...@@ -339,6 +339,7 @@ static int __insert_pg_mapping(struct ceph_pg_mapping *new,
struct ceph_pg_mapping *pg = NULL; struct ceph_pg_mapping *pg = NULL;
int c; int c;
dout("__insert_pg_mapping %llx %p\n", *(u64 *)&new->pgid, 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);
...@@ -366,16 +367,33 @@ static struct ceph_pg_mapping *__lookup_pg_mapping(struct rb_root *root, ...@@ -366,16 +367,33 @@ 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 = pgid_cmp(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) {
n = n->rb_right; n = n->rb_right;
else } else {
dout("__lookup_pg_mapping %llx got %p\n",
*(u64 *)&pgid, pg);
return pg; return pg;
}
} }
return NULL; return NULL;
} }
static int __remove_pg_mapping(struct rb_root *root, struct ceph_pg pgid)
{
struct ceph_pg_mapping *pg = __lookup_pg_mapping(root, pgid);
if (pg) {
dout("__remove_pg_mapping %llx %p\n", *(u64 *)&pgid, pg);
rb_erase(&pg->node, root);
kfree(pg);
return 0;
}
dout("__remove_pg_mapping %llx dne\n", *(u64 *)&pgid);
return -ENOENT;
}
/* /*
* rbtree of pg pool info * rbtree of pg pool info
*/ */
...@@ -711,7 +729,6 @@ struct ceph_osdmap *osdmap_apply_incremental(void **p, void *end, ...@@ -711,7 +729,6 @@ struct ceph_osdmap *osdmap_apply_incremental(void **p, void *end,
void *start = *p; void *start = *p;
int err = -EINVAL; int err = -EINVAL;
u16 version; u16 version;
struct rb_node *rbp;
ceph_decode_16_safe(p, end, version, bad); ceph_decode_16_safe(p, end, version, bad);
if (version > CEPH_OSDMAP_INC_VERSION) { if (version > CEPH_OSDMAP_INC_VERSION) {
...@@ -861,7 +878,6 @@ struct ceph_osdmap *osdmap_apply_incremental(void **p, void *end, ...@@ -861,7 +878,6 @@ struct ceph_osdmap *osdmap_apply_incremental(void **p, void *end,
} }
/* new_pg_temp */ /* new_pg_temp */
rbp = rb_first(&map->pg_temp);
ceph_decode_32_safe(p, end, len, bad); ceph_decode_32_safe(p, end, len, bad);
while (len--) { while (len--) {
struct ceph_pg_mapping *pg; struct ceph_pg_mapping *pg;
...@@ -872,18 +888,6 @@ struct ceph_osdmap *osdmap_apply_incremental(void **p, void *end, ...@@ -872,18 +888,6 @@ struct ceph_osdmap *osdmap_apply_incremental(void **p, void *end,
ceph_decode_copy(p, &pgid, sizeof(pgid)); ceph_decode_copy(p, &pgid, sizeof(pgid));
pglen = ceph_decode_32(p); pglen = ceph_decode_32(p);
/* remove any? */
while (rbp && pgid_cmp(rb_entry(rbp, struct ceph_pg_mapping,
node)->pgid, pgid) <= 0) {
struct ceph_pg_mapping *cur =
rb_entry(rbp, struct ceph_pg_mapping, node);
rbp = rb_next(rbp);
dout(" removed pg_temp %llx\n", *(u64 *)&cur->pgid);
rb_erase(&cur->node, &map->pg_temp);
kfree(cur);
}
if (pglen) { if (pglen) {
/* insert */ /* insert */
ceph_decode_need(p, end, pglen*sizeof(u32), bad); ceph_decode_need(p, end, pglen*sizeof(u32), bad);
...@@ -903,17 +907,11 @@ struct ceph_osdmap *osdmap_apply_incremental(void **p, void *end, ...@@ -903,17 +907,11 @@ struct ceph_osdmap *osdmap_apply_incremental(void **p, void *end,
} }
dout(" added pg_temp %llx len %d\n", *(u64 *)&pgid, dout(" added pg_temp %llx len %d\n", *(u64 *)&pgid,
pglen); pglen);
} else {
/* remove */
__remove_pg_mapping(&map->pg_temp, pgid);
} }
} }
while (rbp) {
struct ceph_pg_mapping *cur =
rb_entry(rbp, struct ceph_pg_mapping, node);
rbp = rb_next(rbp);
dout(" removed pg_temp %llx\n", *(u64 *)&cur->pgid);
rb_erase(&cur->node, &map->pg_temp);
kfree(cur);
}
/* ignore the rest */ /* ignore the rest */
*p = end; *p = end;
...@@ -1046,10 +1044,25 @@ static int *calc_pg_raw(struct ceph_osdmap *osdmap, struct ceph_pg pgid, ...@@ -1046,10 +1044,25 @@ static int *calc_pg_raw(struct ceph_osdmap *osdmap, struct ceph_pg pgid,
struct ceph_pg_mapping *pg; struct ceph_pg_mapping *pg;
struct ceph_pg_pool_info *pool; struct ceph_pg_pool_info *pool;
int ruleno; int ruleno;
unsigned poolid, ps, pps; unsigned poolid, ps, pps, t;
int preferred; int preferred;
poolid = le32_to_cpu(pgid.pool);
ps = le16_to_cpu(pgid.ps);
preferred = (s16)le16_to_cpu(pgid.preferred);
pool = __lookup_pg_pool(&osdmap->pg_pools, poolid);
if (!pool)
return NULL;
/* pg_temp? */ /* pg_temp? */
if (preferred >= 0)
t = ceph_stable_mod(ps, le32_to_cpu(pool->v.lpg_num),
pool->lpgp_num_mask);
else
t = ceph_stable_mod(ps, le32_to_cpu(pool->v.pg_num),
pool->pgp_num_mask);
pgid.ps = cpu_to_le16(t);
pg = __lookup_pg_mapping(&osdmap->pg_temp, pgid); pg = __lookup_pg_mapping(&osdmap->pg_temp, pgid);
if (pg) { if (pg) {
*num = pg->len; *num = pg->len;
...@@ -1057,18 +1070,6 @@ static int *calc_pg_raw(struct ceph_osdmap *osdmap, struct ceph_pg pgid, ...@@ -1057,18 +1070,6 @@ static int *calc_pg_raw(struct ceph_osdmap *osdmap, struct ceph_pg pgid,
} }
/* crush */ /* crush */
poolid = le32_to_cpu(pgid.pool);
ps = le16_to_cpu(pgid.ps);
preferred = (s16)le16_to_cpu(pgid.preferred);
/* don't forcefeed bad device ids to crush */
if (preferred >= osdmap->max_osd ||
preferred >= osdmap->crush->max_devices)
preferred = -1;
pool = __lookup_pg_pool(&osdmap->pg_pools, poolid);
if (!pool)
return NULL;
ruleno = crush_find_rule(osdmap->crush, pool->v.crush_ruleset, ruleno = crush_find_rule(osdmap->crush, pool->v.crush_ruleset,
pool->v.type, pool->v.size); pool->v.type, pool->v.size);
if (ruleno < 0) { if (ruleno < 0) {
...@@ -1078,6 +1079,11 @@ static int *calc_pg_raw(struct ceph_osdmap *osdmap, struct ceph_pg pgid, ...@@ -1078,6 +1079,11 @@ static int *calc_pg_raw(struct ceph_osdmap *osdmap, struct ceph_pg pgid,
return NULL; return NULL;
} }
/* don't forcefeed bad device ids to crush */
if (preferred >= osdmap->max_osd ||
preferred >= osdmap->crush->max_devices)
preferred = -1;
if (preferred >= 0) if (preferred >= 0)
pps = ceph_stable_mod(ps, pps = ceph_stable_mod(ps,
le32_to_cpu(pool->v.lpgp_num), le32_to_cpu(pool->v.lpgp_num),
......
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