PMEM2_BADBLOCK_CLEAR(3)

✨ NAME ✨

pmem2_badblock_clear β€” bestie, this is the one that clears the given bad block. Like, actually fixes it. Not just looking at it. Clearing it. πŸ’…

(It's a libpmem2 thing, from the PMDK Programmer's Manual, so you know it's the real deal.)


🌸 SYNOPSIS 🌸

okay so first you gotta pull in the header, no cap:

#include <libpmem2.h>

struct pmem2_badblock;
struct pmem2_badblock_context;

int pmem2_badblock_clear(
        struct pmem2_badblock_context *bbctx,
        struct pmem2_badblock *bb);

Look at those structs. struct pmem2_badblock and struct pmem2_badblock_context. Iconic. πŸŽ€


πŸ¦‹ DESCRIPTION πŸ¦‹

The pmem2_badblock_clear() function clears the given *bb bad block. That's it, that's the job. πŸ’–

So what does "clear" actually mean here? It means pmem2_badblock_clear() unmaps the bad blocks and then maps new, healthy, blocks in place of the bad ones. Glow-up arc, honestly. 🧚

The new blocks are zeroed. Fresh start energy.

⚠️ But listen β€” the content of the bad blocks is lost. Gone. Not recoverable. It's giving "we don't talk about that data anymore." 😭

⭐ RETURN VALUE ⭐

pmem2_badblock_clear() clears the given *bb bad block and returns 0 on success, or a negative error code on failure. That's the vibe check: zero good, negative not good. πŸ’€


πŸ”₯ ERRORS πŸ”₯

pmem2_badblock_clear() can fail with the following errors, and bestie, let's go through all of them, no skipping:

  • PMEM2_E_OFFSET_OUT_OF_RANGE β€” the bad block's offset is greater than INT64_MAX. Too much. Overflowing. Not the moment.
  • PMEM2_E_LENGTH_OUT_OF_RANGE β€” the bad block's length is greater than INT64_MAX. Same energy, different field.
  • PMEM2_E_NOSUPP β€” when the OS does not support this functionality. Your operating system said "not today," and honestly? We have to respect it. πŸ™ˆ
  • -errno β€” set by failing fallocate(2), while deallocating bad blocks or allocating new blocks.
  • -errno β€” set by failing ndctl functions: ndctl_bus_cmd_new_ars_cap, ndctl_cmd_submit, ndctl_cmd_ars_cap_get_range or ndctl_bus_cmd_new_clear_error while trying to clear a bad block in a DAX device.
  • -ENXIO β€” ndctl_bus_cmd_new_clear_error did not manage to clear all bad blocks. Partial clear. Incomplete slay. πŸ˜”

πŸ’œ SEE ALSO πŸ’œ

Go read these next, for the full lore:


okay and that's the whole page, periodt. this one came from the PMDK Programmer's Manual, dated 2025-07-24 β€” so like, current, relevant, on your feed. go clear those bad blocks, bestie, you got this 🫢✨

πŸ“¦ where this page comes from