try_recover_peb(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… try_recover_peb(9) β€” like, the rescue mission for your flash

okay so first things first: this page lives in the Kernel API Manual, section 9, and it's called try_recover_peb(9). say it with me β€” try recover PEB 🫢 it's the little function that shows up when a write goes wrong and somebody has to go save the data. no cap, it's giving first-responder energy.


✨ NAME ✨

try_recover_peb β€” bestie, it literally tries to recover from a write failure πŸ’–


🌸 SYNOPSIS 🌸

int try_recover_peb (struct ubi_volume *vol , int pnum , int lnum ,
const void *buf , int offset , int len , struct ubi_vid_io_buf *vidb ,
bool *retry );

yeah she's a long one 😭 eight parameters, we're built different. here's the tea on each of them πŸ‘‡


πŸŽ€ ARGUMENTS πŸŽ€

  • vol β€” the volume description object. like, the volume's whole personality file.
  • pnum β€” the physical eraseblock we're trying to recover. the main character of this episode ✨
  • lnum β€” the logical eraseblock number, for when you need the logical side of the story.
  • buf β€” the data that didn't get written because the write failed 😭 poor thing never made it out.
  • offset β€” offset of the failed write. like, exactly where things went sideways.
  • len β€” how many bytes should have been written. the count that got robbed πŸ™ˆ
  • vidb β€” the VID buffer. yes that's its whole description, don't come for me πŸ’€
  • retry β€” a bool * that tells the caller whether they should retry in case of failure. very much a "should we run it back?" situation.

πŸ”₯ DESCRIPTION πŸ”₯

so picture this: a write just failed 😬 and try_recover_peb gets called. what it does is move all the good data off the potentially-bad physical eraseblock and onto a good physical eraseblock. queen behavior, honestly πŸ‘‘ rescuing data from a cursed block.

and she doesn't stop there β€” this function also writes the data which was not written due to the failure. so the leftover buf situation gets handled too. iconic.

returns 0 in case of success πŸ’– and a negative error code in case of failure πŸ’€.

now the important bit, listen up bestie: in case of failure, the retry parameter is set to false if this is a fatal error (like, retrying won't help, it's over, no point), and true otherwise (still hope ✨). do not mix those up, i'm begging 🫢

⚠️ ok real talk β€” retry only gets meaningfully set when the function fails. don't go reading it after a 0 return and expecting wisdom, that's not what the manpage says and i'm not gonna make stuff up for you πŸŽ€

🌈 SEE ALSO 🌈

buckle up, this list is long β€” but every single one is here, mwah πŸ’…


kisses, this page ships from ./drivers/mtd/ubi and it's dated October 2026 β€” that's the vibe check, we're done here, slay πŸ’…βœ¨πŸ¦‹

πŸ“¦ where this page comes from