diff options
author | Sage Weil <sage@newdream.net> | 2010-07-20 19:19:56 -0400 |
---|---|---|
committer | Sage Weil <sage@newdream.net> | 2010-07-23 13:02:06 -0400 |
commit | bc4fdca85734d12cd2c7a25c52323ef6e6e5adef (patch) | |
tree | 64063d3fc8e39dd22d1621c7e30b184585bfdaf2 /fs | |
parent | 252af5214682191e34e57204e1a31924fb82c207 (diff) |
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>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/ceph/osdmap.c | 26 |
1 files changed, 15 insertions, 11 deletions
diff --git a/fs/ceph/osdmap.c b/fs/ceph/osdmap.c index 277f8b339577..416d46adbf87 100644 --- a/fs/ceph/osdmap.c +++ b/fs/ceph/osdmap.c | |||
@@ -831,12 +831,13 @@ struct ceph_osdmap *osdmap_apply_incremental(void **p, void *end, | |||
831 | /* remove any? */ | 831 | /* remove any? */ |
832 | while (rbp && pgid_cmp(rb_entry(rbp, struct ceph_pg_mapping, | 832 | while (rbp && pgid_cmp(rb_entry(rbp, struct ceph_pg_mapping, |
833 | node)->pgid, pgid) <= 0) { | 833 | node)->pgid, pgid) <= 0) { |
834 | struct rb_node *cur = rbp; | 834 | struct ceph_pg_mapping *cur = |
835 | rb_entry(rbp, struct ceph_pg_mapping, node); | ||
836 | |||
835 | rbp = rb_next(rbp); | 837 | rbp = rb_next(rbp); |
836 | dout(" removed pg_temp %llx\n", | 838 | dout(" removed pg_temp %llx\n", *(u64 *)&cur->pgid); |
837 | *(u64 *)&rb_entry(cur, struct ceph_pg_mapping, | 839 | rb_erase(&cur->node, &map->pg_temp); |
838 | node)->pgid); | 840 | kfree(cur); |
839 | rb_erase(cur, &map->pg_temp); | ||
840 | } | 841 | } |
841 | 842 | ||
842 | if (pglen) { | 843 | if (pglen) { |
@@ -852,19 +853,22 @@ struct ceph_osdmap *osdmap_apply_incremental(void **p, void *end, | |||
852 | for (j = 0; j < pglen; j++) | 853 | for (j = 0; j < pglen; j++) |
853 | pg->osds[j] = ceph_decode_32(p); | 854 | pg->osds[j] = ceph_decode_32(p); |
854 | err = __insert_pg_mapping(pg, &map->pg_temp); | 855 | err = __insert_pg_mapping(pg, &map->pg_temp); |
855 | if (err) | 856 | if (err) { |
857 | kfree(pg); | ||
856 | goto bad; | 858 | goto bad; |
859 | } | ||
857 | dout(" added pg_temp %llx len %d\n", *(u64 *)&pgid, | 860 | dout(" added pg_temp %llx len %d\n", *(u64 *)&pgid, |
858 | pglen); | 861 | pglen); |
859 | } | 862 | } |
860 | } | 863 | } |
861 | while (rbp) { | 864 | while (rbp) { |
862 | struct rb_node *cur = rbp; | 865 | struct ceph_pg_mapping *cur = |
866 | rb_entry(rbp, struct ceph_pg_mapping, node); | ||
867 | |||
863 | rbp = rb_next(rbp); | 868 | rbp = rb_next(rbp); |
864 | dout(" removed pg_temp %llx\n", | 869 | dout(" removed pg_temp %llx\n", *(u64 *)&cur->pgid); |
865 | *(u64 *)&rb_entry(cur, struct ceph_pg_mapping, | 870 | rb_erase(&cur->node, &map->pg_temp); |
866 | node)->pgid); | 871 | kfree(cur); |
867 | rb_erase(cur, &map->pg_temp); | ||
868 | } | 872 | } |
869 | 873 | ||
870 | /* ignore the rest */ | 874 | /* ignore the rest */ |