nvme_flush(2)

πŸ’Ύ nvme_flush β€” bestie edition

okay so this is nvme_flush(2), and it lives in the libnvme API manual. it's a whole little guy whose entire job is "Send an nvme flush command" πŸ’… and honestly? iconic of it.


✨ NAME ✨

nvme_flush β€” sends an nvme flush command. that's it. that's the whole personality. no cap. πŸŽ€


🌸 SYNOPSIS 🌸

int nvme_flush (int fd , __u32 nsid );

yep that's the whole signature, she's compact, she's efficient, she's serving πŸ¦‹


🫢 ARGUMENTS 🫢

  • fd β€” the file descriptor of your nvme device. like, the actual handle to the thing. you gotta have this, bestie, there's no flushing without it πŸ’–
  • nsid β€” the namespace identifier. it's a __u32, it tells the command which namespace we're talking to 🌈

πŸ’… DESCRIPTION πŸ’…

so here's the vibe: the Flush command requests that the contents of volatile write cache be made non-volatile. πŸ’«

and like… what does that MEAN. okay so imagine your device has a lil scratchpad of write cache that is, unfortunately, volatile β€” as in, if the power goes poof, that data goes poof too 😭. this command is you walking up and being like "hey bestie, please make that stuff non-volatile, i need it to actually survive." it's giving commit energy. it's the syncing moment. periodt 🧚


πŸ‘‘ RETURN πŸ‘‘

so what do you get back:

  • the nvme command status, if a response was received (peep enum nvme_status_field for the deets πŸ”)
  • or -1 with errno set otherwise. so like, if things went sideways, check your errno, that's your clue πŸ’€

lowkey important: those two outcomes are the whole story. status if you got a response, -1 + errno if you didn't. no extra lore, that's canon πŸŽ€

written by the libnvme girlies, dropped in July 2026, filed under nvme_flush in section nvme_flush(2) β€” mwah, go flush something, stay non-volatile πŸ’–βœ¨πŸ‘‘

πŸ“¦ where this page comes from