aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ceph/osdmap.c
diff options
context:
space:
mode:
authorSage Weil <sage@newdream.net>2009-10-09 01:22:37 -0400
committerSage Weil <sage@newdream.net>2009-10-09 14:58:11 -0400
commit991abb6ecfc8edf9863aa6a3f43249e63f9d4d4e (patch)
tree19484fb1965b1ee2cc61a5e7256d3a5aaba4c5fe /fs/ceph/osdmap.c
parent0ba6478df7c6bef0f4b2625554545f941f89fb97 (diff)
ceph: fail gracefully on corrupt osdmap (bad pg_temp mapping)
Return an error and report a corrupt map instead of crying BUG(). Signed-off-by: Sage Weil <sage@newdream.net>
Diffstat (limited to 'fs/ceph/osdmap.c')
-rw-r--r--fs/ceph/osdmap.c15
1 files changed, 10 insertions, 5 deletions
diff --git a/fs/ceph/osdmap.c b/fs/ceph/osdmap.c
index e38fe6309b1c..342e5f80996b 100644
--- a/fs/ceph/osdmap.c
+++ b/fs/ceph/osdmap.c
@@ -366,8 +366,8 @@ static int osdmap_set_max_osd(struct ceph_osdmap *map, int max)
366/* 366/*
367 * Insert a new pg_temp mapping 367 * Insert a new pg_temp mapping
368 */ 368 */
369static void __insert_pg_mapping(struct ceph_pg_mapping *new, 369static int __insert_pg_mapping(struct ceph_pg_mapping *new,
370 struct rb_root *root) 370 struct rb_root *root)
371{ 371{
372 struct rb_node **p = &root->rb_node; 372 struct rb_node **p = &root->rb_node;
373 struct rb_node *parent = NULL; 373 struct rb_node *parent = NULL;
@@ -381,11 +381,12 @@ static void __insert_pg_mapping(struct ceph_pg_mapping *new,
381 else if (new->pgid > pg->pgid) 381 else if (new->pgid > pg->pgid)
382 p = &(*p)->rb_right; 382 p = &(*p)->rb_right;
383 else 383 else
384 BUG(); 384 return -EEXIST;
385 } 385 }
386 386
387 rb_link_node(&new->node, parent, p); 387 rb_link_node(&new->node, parent, p);
388 rb_insert_color(&new->node, root); 388 rb_insert_color(&new->node, root);
389 return 0;
389} 390}
390 391
391/* 392/*
@@ -481,7 +482,9 @@ struct ceph_osdmap *osdmap_decode(void **p, void *end)
481 for (j = 0; j < n; j++) 482 for (j = 0; j < n; j++)
482 ceph_decode_32(p, pg->osds[j]); 483 ceph_decode_32(p, pg->osds[j]);
483 484
484 __insert_pg_mapping(pg, &map->pg_temp); 485 err = __insert_pg_mapping(pg, &map->pg_temp);
486 if (err)
487 goto bad;
485 dout(" added pg_temp %llx len %d\n", pgid, len); 488 dout(" added pg_temp %llx len %d\n", pgid, len);
486 } 489 }
487 490
@@ -681,7 +684,9 @@ struct ceph_osdmap *osdmap_apply_incremental(void **p, void *end,
681 pg->len = pglen; 684 pg->len = pglen;
682 for (j = 0; j < len; j++) 685 for (j = 0; j < len; j++)
683 ceph_decode_32(p, pg->osds[j]); 686 ceph_decode_32(p, pg->osds[j]);
684 __insert_pg_mapping(pg, &map->pg_temp); 687 err = __insert_pg_mapping(pg, &map->pg_temp);
688 if (err)
689 goto bad;
685 dout(" added pg_temp %llx len %d\n", pgid, pglen); 690 dout(" added pg_temp %llx len %d\n", pgid, pglen);
686 } 691 }
687 } 692 }