crush_choose_firstn(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… 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 β€” the crush_map. the map. the whole entire blueprint, bestie.
  • work β€” working space initialized by crush_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 long weight is.
  • 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 the out vector. 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: chooseleaf mode instead of plain choose mode. πŸ“
  • vary_r β€” pass r to recursive calls. literally just: forward the r down into recursion.
  • stable β€” stable mode starts rep=0 in the recursive call for all replicas. that's the whole behavior, no notes.
  • out2 β€” second output vector for leaf items (if recurse_to_leaf). the second vector. only relevant when you're doing the recurse-to-leaf thing.
  • parent_r β€” r value 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 πŸ¦‹

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