crush_choose_firstn(9)
π crush_choose_firstn β choose numrep distinct items of given type β¨
okay so bestie, this is a page from the Kernel API Manual (section 9 of the manual, iykyk) and honestly? it's giving "the function that actually picks your OSDs" energy. the whole vibe is: give me a bucket, give me a number, and I'll hand you back that many distinct items of a given type. no dupes, no cap. π
πΈ SYNOPSIS πΈ
int crush_choose_firstn (const struct crush_map *map , struct crush_work
*work , const struct crush_bucket *bucket , const __u32 *weight , int
weight_max , int x , int numrep , int type , int *out , int outpos , int
out_size , unsigned int tries , unsigned int recurse_tries , unsigned
int local_retries , unsigned int local_fallback_retries , int
recurse_to_leaf , unsigned int vary_r , unsigned int stable , int *out2
, int parent_r , const struct crush_choose_arg *choose_args );
yes she takes twenty-two arguments. twenty-two. she's high-maintenance and we love her for it π
π ARGUMENTS π
mapβ thecrush_map. the map. the whole entire blueprint, bestie.workβ working space initialized bycrush_init_workspace. it's the scratch pad, pre-chewed for her convenience β¨bucketβ the bucket we are choose an item from. (their words, not mine, but yes: this is the bucket we're picking out of.)weightβ weight vector (for map leaves). the actual weights, laid out for the leaves of the map.weight_maxβ size of weight vector. how longweightis.xβ crush input value. the input. the seed of the whole situation.numrepβ the number of items to choose. how many you want back, periodt.typeβ the type of item to choose. like, what kind of thing you're shopping for.outβ pointer to output vector. where the chosen ones land π«Άoutposβ our position in that vector. where we start writing. our little spot.out_sizeβ size of theoutvector. don't overflow it, bestie, I'm begging.triesβ number of attempts to make. how many shots we take.recurse_triesβ number of attempts to have recursive chooseleaf make. the retry budget for the recursive chooseleaf situation.local_retriesβ localized retries.local_fallback_retriesβ localized fallback retries. yes, that's a second kind of local retry. she's thorough πrecurse_to_leafβ true if we want one device under each item of given type (chooseleaf instead of choose). so like:chooseleafmode instead of plainchoosemode. πvary_rβ passrto recursive calls. literally just: forward therdown into recursion.stableβ stable mode startsrep=0in the recursive call for all replicas. that's the whole behavior, no notes.out2β second output vector for leaf items (ifrecurse_to_leaf). the second vector. only relevant when you're doing the recurse-to-leaf thing.parent_rβrvalue passed from the parent. inherited from mom-and-dad call site.choose_argsβ weights and ids for each known bucket. the per-bucket weights + ids lookup situation.
π¦ SEE ALSO π¦
- Kernel file
./net/ceph/crush/mapper.c crush_find_rule(9)crush_do_rule(9)
go read those next, bestie, they're literally the rest of the lore π
β οΈ real talk: this is kernel API territory β every parameter, every unsigned int, every pointer matters exactly as written. I didn't invent a single one and neither should you. π
sign-off time β¨ this iconic little page lives in ./net/ceph/crush, dated October 2026, and it's filed as crush_choose_firstn(9) β go off, section 9 ππ
π¦ 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