Skip to content

Commit

Permalink
common: avoid badblock error msg when used internally
Browse files Browse the repository at this point in the history
Signed-off-by: Tomasz Gromadzki <[email protected]>
  • Loading branch information
grom72 committed Jan 31, 2024
1 parent 77636fa commit 76f7c92
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/common/bad_blocks.c
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ badblocks_get(const char *file, struct badblocks *bbs)
goto exit_delete_source;

bb_found = 0;
while ((pmem2_badblock_next(bbctx, &bb)) == 0) {
while ((pmem2_badblock_next_internal(bbctx, &bb)) == 0) {
bb_found++;
/*
* Form a new bad block structure with offset and length
Expand Down Expand Up @@ -210,7 +210,7 @@ badblocks_clear_all(const char *file)
goto exit_delete_source;
}

while ((pmem2_badblock_next(bbctx, &bb)) == 0) {
while ((pmem2_badblock_next_internal(bbctx, &bb)) == 0) {
ret = pmem2_badblock_clear(bbctx, &bb);
if (ret) {
CORE_LOG_ERROR("pmem2_badblock_clear -- %s", file);
Expand Down
4 changes: 4 additions & 0 deletions src/common/badblocks.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include <string.h>
#include <stdint.h>
#include <sys/types.h>
#include "libpmem2.h"

#ifdef __cplusplus
extern "C" {
Expand Down Expand Up @@ -70,6 +71,9 @@ int badblocks_clear_all(const char *file);

int badblocks_check_file(const char *path);

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

#ifdef __cplusplus
}
#endif
Expand Down
1 change: 1 addition & 0 deletions src/common/set_badblocks.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#include "os.h"
#include "out.h"
#include "set_badblocks.h"
#include "libpmem2.h"
#include "badblocks.h"

/* helper structure for badblocks_check_file_cb() */
Expand Down
1 change: 1 addition & 0 deletions src/libpmem2/badblocks.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
* badblocks.c -- implementation of common bad blocks API
*/

#include "libpmem2.h"
#include "badblocks.h"
#include "alloc.h"
#include "out.h"
Expand Down
17 changes: 15 additions & 2 deletions src/libpmem2/badblocks_ndctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -528,10 +528,10 @@ pmem2_badblock_next_region(struct pmem2_badblock_context *bbctx,
}

/*
* pmem2_badblock_next -- get the next bad block
* pmem2_badblock_next_internal -- get the next bad block
*/
int
pmem2_badblock_next(struct pmem2_badblock_context *bbctx,
pmem2_badblock_next_internal(struct pmem2_badblock_context *bbctx,
struct pmem2_badblock *bb)
{
LOG(3, "bbctx %p bb %p", bbctx, bb);
Expand Down Expand Up @@ -674,6 +674,19 @@ pmem2_badblock_next(struct pmem2_badblock_context *bbctx,
return 0;
}

int
pmem2_badblock_next(struct pmem2_badblock_context *bbctx,
struct pmem2_badblock *bb)
{
int ret = pmem2_badblock_next_internal(bbctx, bb);

if (ret == PMEM2_E_NO_BAD_BLOCK_FOUND) {
ERR_WO_ERRNO(
"Cannot find any matching device, no bad blocks found");
}
return ret;
}

/*
* pmem2_badblock_clear_fsdax -- (internal) clear one bad block
* in a FSDAX device
Expand Down

0 comments on commit 76f7c92

Please sign in to comment.