ceph: fix pg_mapping leak on pg_temp updates
Free the ceph_pg_mapping structs when they are removed from the pg_temp rbtree. Also fix a leak in the __insert_pg_mapping() error path. Signed-off-by: Sage Weil <sage@newdream.net>
This commit is contained in:
parent
252af52146
commit
bc4fdca857
|
@ -831,12 +831,13 @@ struct ceph_osdmap *osdmap_apply_incremental(void **p, void *end,
|
||||||
/* remove any? */
|
/* remove any? */
|
||||||
while (rbp && pgid_cmp(rb_entry(rbp, struct ceph_pg_mapping,
|
while (rbp && pgid_cmp(rb_entry(rbp, struct ceph_pg_mapping,
|
||||||
node)->pgid, pgid) <= 0) {
|
node)->pgid, pgid) <= 0) {
|
||||||
struct rb_node *cur = rbp;
|
struct ceph_pg_mapping *cur =
|
||||||
|
rb_entry(rbp, struct ceph_pg_mapping, node);
|
||||||
|
|
||||||
rbp = rb_next(rbp);
|
rbp = rb_next(rbp);
|
||||||
dout(" removed pg_temp %llx\n",
|
dout(" removed pg_temp %llx\n", *(u64 *)&cur->pgid);
|
||||||
*(u64 *)&rb_entry(cur, struct ceph_pg_mapping,
|
rb_erase(&cur->node, &map->pg_temp);
|
||||||
node)->pgid);
|
kfree(cur);
|
||||||
rb_erase(cur, &map->pg_temp);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pglen) {
|
if (pglen) {
|
||||||
|
@ -852,19 +853,22 @@ struct ceph_osdmap *osdmap_apply_incremental(void **p, void *end,
|
||||||
for (j = 0; j < pglen; j++)
|
for (j = 0; j < pglen; j++)
|
||||||
pg->osds[j] = ceph_decode_32(p);
|
pg->osds[j] = ceph_decode_32(p);
|
||||||
err = __insert_pg_mapping(pg, &map->pg_temp);
|
err = __insert_pg_mapping(pg, &map->pg_temp);
|
||||||
if (err)
|
if (err) {
|
||||||
|
kfree(pg);
|
||||||
goto bad;
|
goto bad;
|
||||||
|
}
|
||||||
dout(" added pg_temp %llx len %d\n", *(u64 *)&pgid,
|
dout(" added pg_temp %llx len %d\n", *(u64 *)&pgid,
|
||||||
pglen);
|
pglen);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
while (rbp) {
|
while (rbp) {
|
||||||
struct rb_node *cur = rbp;
|
struct ceph_pg_mapping *cur =
|
||||||
|
rb_entry(rbp, struct ceph_pg_mapping, node);
|
||||||
|
|
||||||
rbp = rb_next(rbp);
|
rbp = rb_next(rbp);
|
||||||
dout(" removed pg_temp %llx\n",
|
dout(" removed pg_temp %llx\n", *(u64 *)&cur->pgid);
|
||||||
*(u64 *)&rb_entry(cur, struct ceph_pg_mapping,
|
rb_erase(&cur->node, &map->pg_temp);
|
||||||
node)->pgid);
|
kfree(cur);
|
||||||
rb_erase(cur, &map->pg_temp);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ignore the rest */
|
/* ignore the rest */
|
||||||
|
|
Loading…
Reference in New Issue