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 thanINT64_MAX. Too much. Overflowing. Not the moment.PMEM2_E_LENGTH_OUT_OF_RANGEβ the bad block's length is greater thanINT64_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 failingfallocate(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_rangeorndctl_bus_cmd_new_clear_errorwhile trying to clear a bad block in a DAX device.-ENXIOβndctl_bus_cmd_new_clear_errordid not manage to clear all bad blocks. Partial clear. Incomplete slay. π
π SEE ALSO π
Go read these next, for the full lore:
pmem2_badblock_context_new(3)pmem2_badblock_next(3)libpmem2(7)- and obviously https://pmem.io π
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
- fedora 43: libpmem2-devel 2.1.0-4.fc43 Β· BSD-3-Clause
- π the page's license: BSD-3-Clause
- Copyright 2020-2023, Intel Corporation
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms