Skip to content

Commit f1932fc

Browse files
committed
crush: fix mapping calculation when force argument doesn't exist
If the force argument isn't valid, we should continue calculating a mapping as if it weren't specified. Signed-off-by: Sage Weil <sage@newdream.net>
1 parent be65559 commit f1932fc

1 file changed

Lines changed: 13 additions & 22 deletions

File tree

‎net/ceph/crush/mapper.c‎

Lines changed: 13 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -477,7 +477,6 @@ int crush_do_rule(struct crush_map *map,
477477
int i, j;
478478
int numrep;
479479
int firstn;
480-
int rc = -1;
481480

482481
BUG_ON(ruleno >= map->max_rules);
483482

@@ -491,23 +490,18 @@ int crush_do_rule(struct crush_map *map,
491490
* that this may or may not correspond to the specific types
492491
* referenced by the crush rule.
493492
*/
494-
if (force >= 0) {
495-
if (force >= map->max_devices ||
496-
map->device_parents[force] == 0) {
497-
/*dprintk("CRUSH: forcefed device dne\n");*/
498-
rc = -1; /* force fed device dne */
499-
goto out;
500-
}
501-
if (!is_out(map, weight, force, x)) {
502-
while (1) {
503-
force_context[++force_pos] = force;
504-
if (force >= 0)
505-
force = map->device_parents[force];
506-
else
507-
force = map->bucket_parents[-1-force];
508-
if (force == 0)
509-
break;
510-
}
493+
if (force >= 0 &&
494+
force < map->max_devices &&
495+
map->device_parents[force] != 0 &&
496+
!is_out(map, weight, force, x)) {
497+
while (1) {
498+
force_context[++force_pos] = force;
499+
if (force >= 0)
500+
force = map->device_parents[force];
501+
else
502+
force = map->bucket_parents[-1-force];
503+
if (force == 0)
504+
break;
511505
}
512506
}
513507

@@ -600,10 +594,7 @@ int crush_do_rule(struct crush_map *map,
600594
BUG_ON(1);
601595
}
602596
}
603-
rc = result_len;
604-
605-
out:
606-
return rc;
597+
return result_len;
607598
}
608599

609600

0 commit comments

Comments
 (0)