Add comments to clarify that in the various ndctl_*_babdlock_foreach
loops where we compose the json output, the additional check for
UTIL_JSON_MEDIA_ERRORS is valid because even if we're not printing
media errors, we still want the badblock_count to be updated, which
requires a full badblocks traversal.

Cc: Dan Williams <[email protected]>
Suggested-by: Dan Williams <[email protected]>
Signed-off-by: Vishal Verma <[email protected]>
---
 util/json.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/util/json.c b/util/json.c
index 30b56c3..702ccf4 100644
--- a/util/json.c
+++ b/util/json.c
@@ -465,6 +465,7 @@ struct json_object *util_region_badblocks_to_json(struct 
ndctl_region *region,
 
                bbs += bb->len;
 
+               /* recheck so we can still get the badblocks_count from above */
                if (!(flags & UTIL_JSON_MEDIA_ERRORS))
                        continue;
 
@@ -554,6 +555,7 @@ static struct json_object *dev_badblocks_to_json(struct 
ndctl_region *region,
 
                bbs += len;
 
+               /* recheck so we can still get the badblocks_count from above */
                if (!(flags & UTIL_JSON_MEDIA_ERRORS))
                        continue;
 
-- 
2.17.1

_______________________________________________
Linux-nvdimm mailing list
[email protected]
https://lists.01.org/mailman/listinfo/linux-nvdimm

Reply via email to