aboutsummaryrefslogtreecommitdiffstats
path: root/net/ceph/osdmap.c
diff options
context:
space:
mode:
Diffstat (limited to 'net/ceph/osdmap.c')
-rw-r--r--net/ceph/osdmap.c31
1 files changed, 16 insertions, 15 deletions
diff --git a/net/ceph/osdmap.c b/net/ceph/osdmap.c
index 864789c5974e..64ae9f89773a 100644
--- a/net/ceph/osdmap.c
+++ b/net/ceph/osdmap.c
@@ -338,7 +338,7 @@ static void crush_finalize(struct crush_map *c)
338static struct crush_map *crush_decode(void *pbyval, void *end) 338static struct crush_map *crush_decode(void *pbyval, void *end)
339{ 339{
340 struct crush_map *c; 340 struct crush_map *c;
341 int err = -EINVAL; 341 int err;
342 int i, j; 342 int i, j;
343 void **p = &pbyval; 343 void **p = &pbyval;
344 void *start = pbyval; 344 void *start = pbyval;
@@ -407,7 +407,6 @@ static struct crush_map *crush_decode(void *pbyval, void *end)
407 size = sizeof(struct crush_bucket_straw2); 407 size = sizeof(struct crush_bucket_straw2);
408 break; 408 break;
409 default: 409 default:
410 err = -EINVAL;
411 goto bad; 410 goto bad;
412 } 411 }
413 BUG_ON(size == 0); 412 BUG_ON(size == 0);
@@ -439,31 +438,31 @@ static struct crush_map *crush_decode(void *pbyval, void *end)
439 err = crush_decode_uniform_bucket(p, end, 438 err = crush_decode_uniform_bucket(p, end,
440 (struct crush_bucket_uniform *)b); 439 (struct crush_bucket_uniform *)b);
441 if (err < 0) 440 if (err < 0)
442 goto bad; 441 goto fail;
443 break; 442 break;
444 case CRUSH_BUCKET_LIST: 443 case CRUSH_BUCKET_LIST:
445 err = crush_decode_list_bucket(p, end, 444 err = crush_decode_list_bucket(p, end,
446 (struct crush_bucket_list *)b); 445 (struct crush_bucket_list *)b);
447 if (err < 0) 446 if (err < 0)
448 goto bad; 447 goto fail;
449 break; 448 break;
450 case CRUSH_BUCKET_TREE: 449 case CRUSH_BUCKET_TREE:
451 err = crush_decode_tree_bucket(p, end, 450 err = crush_decode_tree_bucket(p, end,
452 (struct crush_bucket_tree *)b); 451 (struct crush_bucket_tree *)b);
453 if (err < 0) 452 if (err < 0)
454 goto bad; 453 goto fail;
455 break; 454 break;
456 case CRUSH_BUCKET_STRAW: 455 case CRUSH_BUCKET_STRAW:
457 err = crush_decode_straw_bucket(p, end, 456 err = crush_decode_straw_bucket(p, end,
458 (struct crush_bucket_straw *)b); 457 (struct crush_bucket_straw *)b);
459 if (err < 0) 458 if (err < 0)
460 goto bad; 459 goto fail;
461 break; 460 break;
462 case CRUSH_BUCKET_STRAW2: 461 case CRUSH_BUCKET_STRAW2:
463 err = crush_decode_straw2_bucket(p, end, 462 err = crush_decode_straw2_bucket(p, end,
464 (struct crush_bucket_straw2 *)b); 463 (struct crush_bucket_straw2 *)b);
465 if (err < 0) 464 if (err < 0)
466 goto bad; 465 goto fail;
467 break; 466 break;
468 } 467 }
469 } 468 }
@@ -474,7 +473,6 @@ static struct crush_map *crush_decode(void *pbyval, void *end)
474 u32 yes; 473 u32 yes;
475 struct crush_rule *r; 474 struct crush_rule *r;
476 475
477 err = -EINVAL;
478 ceph_decode_32_safe(p, end, yes, bad); 476 ceph_decode_32_safe(p, end, yes, bad);
479 if (!yes) { 477 if (!yes) {
480 dout("crush_decode NO rule %d off %x %p to %p\n", 478 dout("crush_decode NO rule %d off %x %p to %p\n",
@@ -489,7 +487,6 @@ static struct crush_map *crush_decode(void *pbyval, void *end)
489 /* len */ 487 /* len */
490 ceph_decode_32_safe(p, end, yes, bad); 488 ceph_decode_32_safe(p, end, yes, bad);
491#if BITS_PER_LONG == 32 489#if BITS_PER_LONG == 32
492 err = -EINVAL;
493 if (yes > (ULONG_MAX - sizeof(*r)) 490 if (yes > (ULONG_MAX - sizeof(*r))
494 / sizeof(struct crush_rule_step)) 491 / sizeof(struct crush_rule_step))
495 goto bad; 492 goto bad;
@@ -557,7 +554,7 @@ static struct crush_map *crush_decode(void *pbyval, void *end)
557 if (*p != end) { 554 if (*p != end) {
558 err = decode_choose_args(p, end, c); 555 err = decode_choose_args(p, end, c);
559 if (err) 556 if (err)
560 goto bad; 557 goto fail;
561 } 558 }
562 559
563done: 560done:
@@ -567,10 +564,14 @@ done:
567 564
568badmem: 565badmem:
569 err = -ENOMEM; 566 err = -ENOMEM;
570bad: 567fail:
571 dout("crush_decode fail %d\n", err); 568 dout("crush_decode fail %d\n", err);
572 crush_destroy(c); 569 crush_destroy(c);
573 return ERR_PTR(err); 570 return ERR_PTR(err);
571
572bad:
573 err = -EINVAL;
574 goto fail;
574} 575}
575 576
576int ceph_pg_compare(const struct ceph_pg *lhs, const struct ceph_pg *rhs) 577int ceph_pg_compare(const struct ceph_pg *lhs, const struct ceph_pg *rhs)
@@ -1399,7 +1400,7 @@ static struct ceph_pg_mapping *__decode_pg_upmap_items(void **p, void *end,
1399 return ERR_PTR(-EINVAL); 1400 return ERR_PTR(-EINVAL);
1400 1401
1401 ceph_decode_need(p, end, 2 * len * sizeof(u32), e_inval); 1402 ceph_decode_need(p, end, 2 * len * sizeof(u32), e_inval);
1402 pg = kzalloc(sizeof(*pg) + 2 * len * sizeof(u32), GFP_NOIO); 1403 pg = alloc_pg_mapping(2 * len * sizeof(u32));
1403 if (!pg) 1404 if (!pg)
1404 return ERR_PTR(-ENOMEM); 1405 return ERR_PTR(-ENOMEM);
1405 1406
@@ -1544,7 +1545,7 @@ static int osdmap_decode(void **p, void *end, struct ceph_osdmap *map)
1544 if (struct_v >= 3) { 1545 if (struct_v >= 3) {
1545 /* erasure_code_profiles */ 1546 /* erasure_code_profiles */
1546 ceph_decode_skip_map_of_map(p, end, string, string, string, 1547 ceph_decode_skip_map_of_map(p, end, string, string, string,
1547 bad); 1548 e_inval);
1548 } 1549 }
1549 1550
1550 if (struct_v >= 4) { 1551 if (struct_v >= 4) {
@@ -1825,9 +1826,9 @@ struct ceph_osdmap *osdmap_apply_incremental(void **p, void *end,
1825 if (struct_v >= 3) { 1826 if (struct_v >= 3) {
1826 /* new_erasure_code_profiles */ 1827 /* new_erasure_code_profiles */
1827 ceph_decode_skip_map_of_map(p, end, string, string, string, 1828 ceph_decode_skip_map_of_map(p, end, string, string, string,
1828 bad); 1829 e_inval);
1829 /* old_erasure_code_profiles */ 1830 /* old_erasure_code_profiles */
1830 ceph_decode_skip_set(p, end, string, bad); 1831 ceph_decode_skip_set(p, end, string, e_inval);
1831 } 1832 }
1832 1833
1833 if (struct_v >= 4) { 1834 if (struct_v >= 4) {