aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--net/ceph/crush/mapper.c88
1 files changed, 33 insertions, 55 deletions
diff --git a/net/ceph/crush/mapper.c b/net/ceph/crush/mapper.c
index 77b7a73e65cf..a71f8c4c78ec 100644
--- a/net/ceph/crush/mapper.c
+++ b/net/ceph/crush/mapper.c
@@ -282,7 +282,7 @@ static int is_out(const struct crush_map *map,
282} 282}
283 283
284/** 284/**
285 * crush_choose - choose numrep distinct items of given type 285 * crush_choose_firstn - choose numrep distinct items of given type
286 * @map: the crush_map 286 * @map: the crush_map
287 * @bucket: the bucket we are choose an item from 287 * @bucket: the bucket we are choose an item from
288 * @x: crush input value 288 * @x: crush input value
@@ -290,18 +290,17 @@ static int is_out(const struct crush_map *map,
290 * @type: the type of item to choose 290 * @type: the type of item to choose
291 * @out: pointer to output vector 291 * @out: pointer to output vector
292 * @outpos: our position in that vector 292 * @outpos: our position in that vector
293 * @firstn: true if choosing "first n" items, false if choosing "indep"
294 * @recurse_to_leaf: true if we want one device under each item of given type 293 * @recurse_to_leaf: true if we want one device under each item of given type
295 * @descend_once: true if we should only try one descent before giving up 294 * @descend_once: true if we should only try one descent before giving up
296 * @out2: second output vector for leaf items (if @recurse_to_leaf) 295 * @out2: second output vector for leaf items (if @recurse_to_leaf)
297 */ 296 */
298static int crush_choose(const struct crush_map *map, 297static int crush_choose_firstn(const struct crush_map *map,
299 struct crush_bucket *bucket, 298 struct crush_bucket *bucket,
300 const __u32 *weight, int weight_max, 299 const __u32 *weight, int weight_max,
301 int x, int numrep, int type, 300 int x, int numrep, int type,
302 int *out, int outpos, 301 int *out, int outpos,
303 int firstn, int recurse_to_leaf, 302 int recurse_to_leaf,
304 int descend_once, int *out2) 303 int descend_once, int *out2)
305{ 304{
306 int rep; 305 int rep;
307 unsigned int ftotal, flocal; 306 unsigned int ftotal, flocal;
@@ -330,26 +329,8 @@ static int crush_choose(const struct crush_map *map,
330 collide = 0; 329 collide = 0;
331 retry_bucket = 0; 330 retry_bucket = 0;
332 r = rep; 331 r = rep;
333 if (in->alg == CRUSH_BUCKET_UNIFORM) { 332 /* r' = r + f_total */
334 /* be careful */ 333 r += ftotal;
335 if (firstn || (__u32)numrep >= in->size)
336 /* r' = r + f_total */
337 r += ftotal;
338 else if (in->size % numrep == 0)
339 /* r'=r+(n+1)*f_local */
340 r += (numrep+1) *
341 (flocal+ftotal);
342 else
343 /* r' = r + n*f_local */
344 r += numrep * (flocal+ftotal);
345 } else {
346 if (firstn)
347 /* r' = r + f_total */
348 r += ftotal;
349 else
350 /* r' = r + n*f_local */
351 r += numrep * (flocal+ftotal);
352 }
353 334
354 /* bucket choose */ 335 /* bucket choose */
355 if (in->size == 0) { 336 if (in->size == 0) {
@@ -399,12 +380,12 @@ static int crush_choose(const struct crush_map *map,
399 reject = 0; 380 reject = 0;
400 if (!collide && recurse_to_leaf) { 381 if (!collide && recurse_to_leaf) {
401 if (item < 0) { 382 if (item < 0) {
402 if (crush_choose(map, 383 if (crush_choose_firstn(map,
403 map->buckets[-1-item], 384 map->buckets[-1-item],
404 weight, weight_max, 385 weight, weight_max,
405 x, outpos+1, 0, 386 x, outpos+1, 0,
406 out2, outpos, 387 out2, outpos,
407 firstn, 0, 388 0,
408 map->chooseleaf_descend_once, 389 map->chooseleaf_descend_once,
409 NULL) <= outpos) 390 NULL) <= outpos)
410 /* didn't get leaf */ 391 /* didn't get leaf */
@@ -455,12 +436,8 @@ reject:
455 } while (retry_descent); 436 } while (retry_descent);
456 437
457 if (skip_rep) { 438 if (skip_rep) {
458 if (firstn) { 439 dprintk("skip rep\n");
459 dprintk("skip rep\n"); 440 continue;
460 continue;
461 }
462 dprintk("undef rep, continuing\n");
463 item = CRUSH_ITEM_UNDEF;
464 } 441 }
465 442
466 dprintk("CHOOSE got %d\n", item); 443 dprintk("CHOOSE got %d\n", item);
@@ -474,7 +451,7 @@ reject:
474 451
475 452
476/** 453/**
477 * choose indep: alternative breadth-first positionally stable mapping 454 * crush_choose_indep: alternative breadth-first positionally stable mapping
478 * 455 *
479 */ 456 */
480static void crush_choose_indep(const struct crush_map *map, 457static void crush_choose_indep(const struct crush_map *map,
@@ -707,24 +684,25 @@ int crush_do_rule(const struct crush_map *map,
707 } 684 }
708 j = 0; 685 j = 0;
709 if (firstn) { 686 if (firstn) {
710 osize += crush_choose(map, 687 osize += crush_choose_firstn(
711 map->buckets[-1-w[i]], 688 map,
712 weight, weight_max, 689 map->buckets[-1-w[i]],
713 x, numrep, 690 weight, weight_max,
714 curstep->arg2, 691 x, numrep,
715 o+osize, j, 692 curstep->arg2,
716 firstn, 693 o+osize, j,
717 recurse_to_leaf, 694 recurse_to_leaf,
718 descend_once, c+osize); 695 descend_once, c+osize);
719 } else { 696 } else {
720 crush_choose_indep(map, 697 crush_choose_indep(
721 map->buckets[-1-w[i]], 698 map,
722 weight, weight_max, 699 map->buckets[-1-w[i]],
723 x, numrep, 700 weight, weight_max,
724 curstep->arg2, 701 x, numrep,
725 o+osize, j, 702 curstep->arg2,
726 recurse_to_leaf, 703 o+osize, j,
727 c+osize); 704 recurse_to_leaf,
705 c+osize);
728 osize += numrep; 706 osize += numrep;
729 } 707 }
730 } 708 }