Skip to content

Commit

Permalink
common: skip warning: 'No bad blocks found'
Browse files Browse the repository at this point in the history
Skip warning: "Cannot find any matching device, no bad blocks found"
when pmem2_badblock_next() is used internally.

Signed-off-by: Tomasz Gromadzki <[email protected]>
  • Loading branch information
grom72 committed Oct 25, 2024
1 parent 5903626 commit 3ce16c8
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 10 deletions.
5 changes: 3 additions & 2 deletions src/common/bad_blocks.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#include "core_assert.h"
#include "vec.h"
#include "os.h"
#include "../libpmem2/badblock.h"

/*
* badblocks_count -- returns number of bad blocks in the file
Expand Down Expand Up @@ -73,7 +74,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_int(bbctx, &bb, 0)) == 0) {
bb_found++;
/*
* Form a new bad block structure with offset and length
Expand Down Expand Up @@ -211,7 +212,7 @@ badblocks_clear_all(const char *file)
goto exit_delete_source;
}

while ((pmem2_badblock_next(bbctx, &bb)) == 0) {
while ((pmem2_badblock_next_int(bbctx, &bb, 0)) == 0) {
ret = pmem2_badblock_clear(bbctx, &bb);
if (ret) {
CORE_LOG_ERROR("pmem2_badblock_clear -- %s", file);
Expand Down
19 changes: 14 additions & 5 deletions src/libpmem2/badblocks_ndctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#include "badblocks.h"
#include "set_badblocks.h"
#include "extent.h"
#include "badblock.h"

typedef int pmem2_badblock_next_type(
struct pmem2_badblock_context *bbctx,
Expand Down Expand Up @@ -530,8 +531,8 @@ pmem2_badblock_next_region(struct pmem2_badblock_context *bbctx,
* pmem2_badblock_next -- get the next bad block
*/
int
pmem2_badblock_next(struct pmem2_badblock_context *bbctx,
struct pmem2_badblock *bb)
pmem2_badblock_next_int(struct pmem2_badblock_context *bbctx,
struct pmem2_badblock *bb, int warning)
{
LOG(3, "bbctx %p bb %p", bbctx, bb);
PMEM2_ERR_CLR();
Expand All @@ -550,8 +551,9 @@ pmem2_badblock_next(struct pmem2_badblock_context *bbctx,
int ret;

if (bbctx->rgn.region == NULL && bbctx->ndns == NULL) {
ERR_WO_ERRNO(
"Cannot find any matching device, no bad blocks found");
if (warning)
ERR_WO_ERRNO(
"Cannot find any matching device, no bad blocks found");
return PMEM2_E_NO_BAD_BLOCK_FOUND;
}

Expand Down Expand Up @@ -672,7 +674,14 @@ pmem2_badblock_next(struct pmem2_badblock_context *bbctx,

return 0;
}

int
pmem2_badblock_next(struct pmem2_badblock_context *bbctx,
struct pmem2_badblock *bb)
{
LOG(3, "bbctx %p bb %p", bbctx, bb);
PMEM2_ERR_CLR();
return pmem2_badblock_next_int(bbctx, bb, 1);
}
/*
* pmem2_badblock_clear_fsdax -- (internal) clear one bad block
* in a FSDAX device
Expand Down
12 changes: 9 additions & 3 deletions src/libpmem2/badblocks_none.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,18 @@ pmem2_badblock_context_delete(
* pmem2_badblock_next -- get the next bad block
*/
int
pmem2_badblock_next(struct pmem2_badblock_context *bbctx,
struct pmem2_badblock *bb)
pmem2_badblock_next_int(struct pmem2_badblock_context *bbctx,
struct pmem2_badblock *bb, int warning)
{
SUPPRESS_UNUSED(bbctx, bb);
SUPPRESS_UNUSED(bbctx, bb, warning);

return PMEM2_E_NOSUPP;
}int

pmem2_badblock_next(struct pmem2_badblock_context *bbctx,
struct pmem2_badblock *bb)
{
return pmem2_badblock_next_int(bbctx, bb, 1);
}

/*
Expand Down

0 comments on commit 3ce16c8

Please sign in to comment.