libceph: fix pg_temp updates
authorSage Weil <sage@inktank.com>
Mon, 21 May 2012 16:45:23 +0000 (09:45 -0700)
committerSage Weil <sage@inktank.com>
Tue, 22 May 2012 03:40:42 +0000 (20:40 -0700)
Usually, we are adding pg_temp entries or removing them.  Occasionally they
update.  In that case, osdmap_apply_incremental() was failing because the
rbtree entry already exists.

Fix by removing the existing entry before inserting a new one.

Fixes http://tracker.newdream.net/issues/2446

Signed-off-by: Sage Weil <sage@inktank.com>
Reviewed-by: Alex Elder <elder@inktank.com>
net/ceph/osdmap.c

index 2592f3cca9878bf51b4e6cbdd3276cd0e975ee8b..1892c523c43c5308dd75fa17901a6c3de6cf70cf 100644 (file)
@@ -883,8 +883,12 @@ struct ceph_osdmap *osdmap_apply_incremental(void **p, void *end,
                pglen = ceph_decode_32(p);
 
                if (pglen) {
-                       /* insert */
                        ceph_decode_need(p, end, pglen*sizeof(u32), bad);
+
+                       /* removing existing (if any) */
+                       (void) __remove_pg_mapping(&map->pg_temp, pgid);
+
+                       /* insert */
                        pg = kmalloc(sizeof(*pg) + sizeof(u32)*pglen, GFP_NOFS);
                        if (!pg) {
                                err = -ENOMEM;