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>
This commit is contained in:
parent
0ba6478df7
commit
991abb6ecf
@ -366,8 +366,8 @@ static int osdmap_set_max_osd(struct ceph_osdmap *map, int max)
|
|||||||
/*
|
/*
|
||||||
* Insert a new pg_temp mapping
|
* Insert a new pg_temp mapping
|
||||||
*/
|
*/
|
||||||
static void __insert_pg_mapping(struct ceph_pg_mapping *new,
|
static int __insert_pg_mapping(struct ceph_pg_mapping *new,
|
||||||
struct rb_root *root)
|
struct rb_root *root)
|
||||||
{
|
{
|
||||||
struct rb_node **p = &root->rb_node;
|
struct rb_node **p = &root->rb_node;
|
||||||
struct rb_node *parent = NULL;
|
struct rb_node *parent = NULL;
|
||||||
@ -381,11 +381,12 @@ static void __insert_pg_mapping(struct ceph_pg_mapping *new,
|
|||||||
else if (new->pgid > pg->pgid)
|
else if (new->pgid > pg->pgid)
|
||||||
p = &(*p)->rb_right;
|
p = &(*p)->rb_right;
|
||||||
else
|
else
|
||||||
BUG();
|
return -EEXIST;
|
||||||
}
|
}
|
||||||
|
|
||||||
rb_link_node(&new->node, parent, p);
|
rb_link_node(&new->node, parent, p);
|
||||||
rb_insert_color(&new->node, root);
|
rb_insert_color(&new->node, root);
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -481,7 +482,9 @@ struct ceph_osdmap *osdmap_decode(void **p, void *end)
|
|||||||
for (j = 0; j < n; j++)
|
for (j = 0; j < n; j++)
|
||||||
ceph_decode_32(p, pg->osds[j]);
|
ceph_decode_32(p, pg->osds[j]);
|
||||||
|
|
||||||
__insert_pg_mapping(pg, &map->pg_temp);
|
err = __insert_pg_mapping(pg, &map->pg_temp);
|
||||||
|
if (err)
|
||||||
|
goto bad;
|
||||||
dout(" added pg_temp %llx len %d\n", pgid, len);
|
dout(" added pg_temp %llx len %d\n", pgid, len);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -681,7 +684,9 @@ struct ceph_osdmap *osdmap_apply_incremental(void **p, void *end,
|
|||||||
pg->len = pglen;
|
pg->len = pglen;
|
||||||
for (j = 0; j < len; j++)
|
for (j = 0; j < len; j++)
|
||||||
ceph_decode_32(p, pg->osds[j]);
|
ceph_decode_32(p, pg->osds[j]);
|
||||||
__insert_pg_mapping(pg, &map->pg_temp);
|
err = __insert_pg_mapping(pg, &map->pg_temp);
|
||||||
|
if (err)
|
||||||
|
goto bad;
|
||||||
dout(" added pg_temp %llx len %d\n", pgid, pglen);
|
dout(" added pg_temp %llx len %d\n", pgid, pglen);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user