From 3ce16c8c50fdb735a9b78ca816d809f2db0946e5 Mon Sep 17 00:00:00 2001 From: Tomasz Gromadzki Date: Sat, 26 Oct 2024 01:01:43 +0200 Subject: [PATCH] common: skip warning: 'No bad blocks found' Skip warning: "Cannot find any matching device, no bad blocks found" when pmem2_badblock_next() is used internally. Signed-off-by: Tomasz Gromadzki --- src/common/bad_blocks.c | 5 +++-- src/libpmem2/badblocks_ndctl.c | 19 ++++++++++++++----- src/libpmem2/badblocks_none.c | 12 +++++++++--- 3 files changed, 26 insertions(+), 10 deletions(-) diff --git a/src/common/bad_blocks.c b/src/common/bad_blocks.c index 54f89d65d17..a92e32a0604 100644 --- a/src/common/bad_blocks.c +++ b/src/common/bad_blocks.c @@ -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 @@ -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 @@ -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); diff --git a/src/libpmem2/badblocks_ndctl.c b/src/libpmem2/badblocks_ndctl.c index c7a8b4dd582..d18a04b592f 100644 --- a/src/libpmem2/badblocks_ndctl.c +++ b/src/libpmem2/badblocks_ndctl.c @@ -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, @@ -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(); @@ -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; } @@ -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 diff --git a/src/libpmem2/badblocks_none.c b/src/libpmem2/badblocks_none.c index 869e94d39d0..06097635cf0 100644 --- a/src/libpmem2/badblocks_none.c +++ b/src/libpmem2/badblocks_none.c @@ -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); } /*