crush_do_rule(9)
β¨ crush_do_rule(9) β¨
okay so bestie, you've wandered into the Kernel API Manual π
and this page is genuinely iconic β it's crush_do_rule(9), the actual kernel-side baddie that does the math. sit down, hydrate, let's get into it π«Ά
πΈ NAME πΈ
crush_do_rule β calculate a mapping with the given input and rule
like, that's the whole vibe: you hand it an input and a rule, and it goes and computes you a mapping. no cap, that's the job. π
π¦ SYNOPSIS π¦
int crush_do_rule (const struct crush_map *map , int ruleno , int x ,
int *result , int result_max , const __u32 *weight , int weight_max ,
void *cwin , const struct crush_choose_arg *choose_args );
yes she takes nine arguments and yes she's highkey living her main character era. type it exactly like that, ok? π₯
π ARGUMENTS π
okay so here's the cast of characters, going one by one, no skipping, periodt:
mapβ thecrush_map. literally the map. it's giving "the whole world, in struct form." πrulenoβ the rule id. which rule are we running? that's the number, bestie, you pick it. πxβ hash input. this is the thing getting hashed. it's the seed of the whole situation. β¨resultβ pointer to result vector. this is where the output lands. the Cinderella slipper of the function, if you will. πresult_maxβ maximum result size. the capacity, the limit, the "know your lane" of the result vector. π¦weightβ weight vector (for map leaves). leaves only, iykyk. πweight_maxβ size ofweightvector. because a vector without a size is just chaos, and not the fun kind. πcwinβ pointer to at leastcrush_work_sizebytes of memory. at least, bestie β don't be out here handing it 12 bytes and hoping for the best. πchoose_argsβ weights and ids for each known bucket. buckets get their own little weights-and-ids moment, and this is it. π§
ngl, thatcwinone is the classic "must be big enough" situation β the page says at leastcrush_work_sizebytes, so take that literally, fr fr. π
π SEE ALSO π
if you're nosy (we love a curious queen), go look at:
- Kernel file
./net/ceph/crush/mapper.c crush_find_rule(9)crush_choose_firstn(9)
the whole friend group, together at last π«Ά
okay that's the whole page, you ate that π also for the record this one's from ./net/ceph/crush, dated October 2026 β so mark your calendar and stan responsibly, bestie. slay! π
π¦ where this page comes from
- nixpkgs unstable: linux-manual 7.3.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms