try_recover_peb(9)
π 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β abool *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 βretryonly gets meaningfully set when the function fails. don't go reading it after a0return 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 π
Kernel file ./drivers/mtd/ubi/eba.cstruct ubi_eba_entry(9)struct ubi_eba_table(9)ubi_next_sqnum(9)ubi_get_compat(9)ubi_eba_get_ldesc(9)ubi_eba_create_table(9)ubi_eba_destroy_table(9)ubi_eba_copy_table(9)ubi_eba_replace_table(9)ltree_lookup(9)ltree_add_entry(9)leb_read_lock(9)leb_read_unlock(9)leb_write_lock(9)leb_write_trylock(9)leb_write_unlock(9)ubi_eba_is_mapped(9)ubi_eba_unmap_leb(9)check_mapping(9)ubi_eba_read_leb(9)ubi_eba_read_leb_sg(9)recover_peb(9)try_write_vid_and_data(9)ubi_eba_write_leb(9)ubi_eba_write_leb_st(9)is_error_sane(9)ubi_eba_copy_leb(9)print_rsvd_warning(9)self_check_eba(9)ubi_eba_init(9)
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
- 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