This is an automated email from the git hooks/post-receive script.
agruenba pushed a commit to branch agruenba-extents
in repository gfs2-utils.
commit 6bea2bb0b483ce27328bbcf088ed8875502ac925
Author: Andreas Gruenbacher <agruenba(a)redhat.com>
AuthorDate: Thu Apr 22 00:11:03 2021 +0200
fsck.gfs2: Factor out error handling in metawalk_check_data
Move the error reporting in metawalk_check_data into a separate function
(report_data_error). Likewise, move the debug logging in undo_check_data into
a separate function (report_undo_data_error).
Fix the messages to report the actual offset instead of offset / 8.
Signed-off-by: Andreas Gruenbacher <agruenba(a)redhat.com>
---
gfs2/fsck/metawalk.c | 133 +++++++++++++++++++++++++++++----------------------
1 file changed, 75 insertions(+), 58 deletions(-)
diff --git a/gfs2/fsck/metawalk.c b/gfs2/fsck/metawalk.c
index 1b5272ff..0e53b693 100644
--- a/gfs2/fsck/metawalk.c
+++ b/gfs2/fsck/metawalk.c
@@ -1388,6 +1388,47 @@ struct error_block {
uint64_t errblk; /* error block */
};
+static void report_data_error(uint64_t metablock, int offset, uint64_t block,
+ struct error_block *error_blk,
+ int rc, int error)
+{
+ log_info("\n");
+ if (rc < 0) {
+ /* A fatal error trumps a non-fatal one. */
+ if ((error_blk->errblk == 0) ||
+ (rc < error)) {
+ log_debug(_("Fatal error on metadata "
+ "block 0x%"PRIx64", "
+ "offset 0x%x, referencing data "
+ "block 0x%"PRIx64" "
+ "preempts non-fatal error on "
+ "block 0x%"PRIx64"\n"),
+ metablock,
+ offset,
+ block,
+ error_blk->errblk);
+ error_blk->metablk = metablock;
+ error_blk->metaoff = offset;
+ error_blk->errblk = block;
+ }
+ log_info(_("Unrecoverable "));
+ } else { /* nonfatal error */
+ if (error_blk->errblk == 0) {
+ error_blk->metablk = metablock;
+ error_blk->metaoff = offset;
+ error_blk->errblk = block;
+ }
+ }
+ log_info(_("data block error %d on metadata "
+ "block %"PRId64" (0x%"PRIx64"), "
+ "offset %d (0x%x), referencing "
+ "data block %"PRId64" (0x%"PRIx64").\n"),
+ rc,
+ metablock, metablock,
+ offset, offset,
+ block, block);
+}
+
/**
* check_data - check all data pointers for a given buffer
* This does not include "data" blocks that are really
@@ -1414,7 +1455,7 @@ static int metawalk_check_data(struct gfs2_inode *ip, struct
metawalk_fxns *pass
/* If there isn't much pointer corruption check the pointers */
log_debug("Processing data blocks for inode 0x%llx, metadata block
0x%llx.\n",
(unsigned long long)ip->i_di.di_num.no_addr,
- (unsigned long long)bh->b_blocknr);
+ (unsigned long long)metablock);
for (ptr = ptr_start ; ptr < ptr_end && !fsck_abort; ptr++) {
if (!*ptr)
continue;
@@ -1430,41 +1471,7 @@ static int metawalk_check_data(struct gfs2_inode *ip, struct
metawalk_fxns *pass
rc = pass->check_data(ip, metablock, block, pass->private,
bh, ptr);
if (rc && (!error || (rc < error))) {
- log_info("\n");
- if (rc < 0) {
- /* A fatal error trumps a non-fatal one. */
- if ((error_blk->errblk == 0) ||
- (rc < error)) {
- log_debug(_("Fatal error on metadata "
- "block 0x%llx, offset "
- "0x%x, referencing block "
- "0x%llx preempts non-fatal"
- " error on block 0x%llx\n"),
- (unsigned long long)metablock,
- (int)(ptr - ptr_start),
- (unsigned long long)block,
- (unsigned long long)error_blk->errblk);
- error_blk->metablk = metablock;
- error_blk->metaoff = ptr - ptr_start;
- error_blk->errblk = block;
- }
- log_info(_("Unrecoverable "));
- } else { /* nonfatal error */
- if (error_blk->errblk == 0) {
- error_blk->metablk = metablock;
- error_blk->metaoff = ptr - ptr_start;
- error_blk->errblk = block;
- }
- }
- log_info(_("data block error %d on metadata block "
- "%lld (0x%llx), offset %d (0x%x), "
- "referencing data block %lld (0x%llx).\n"),
- rc, (unsigned long long)metablock,
- (unsigned long long)metablock,
- (int)(ptr - ptr_start),
- (int)(ptr - ptr_start),
- (unsigned long long)block,
- (unsigned long long)block);
+ report_data_error(metablock, (char *)ptr - bh->b_data, block, error_blk, rc,
error);
error = rc;
}
if (rc < 0)
@@ -1474,6 +1481,35 @@ static int metawalk_check_data(struct gfs2_inode *ip, struct
metawalk_fxns *pass
return error;
}
+static int report_undo_data_error(uint64_t metablock, int offset, uint64_t block,
+ struct error_block *error_blk,
+ int *found_error_blk, int error)
+{
+ if (metablock == error_blk->metablk &&
+ offset == error_blk->metaoff &&
+ block == error_blk->errblk) {
+ if (error < 0) { /* A fatal error that stopped it? */
+ log_debug(_("Stopping the undo process: "
+ "fatal error block 0x%"PRIx64" was "
+ "found at metadata block 0x%"PRIx64","
+ "offset 0x%x.\n"),
+ error_blk->errblk,
+ error_blk->metablk,
+ error_blk->metaoff);
+ return 1;
+ }
+ *found_error_blk = 1;
+ log_debug(_("The non-fatal error block 0x%"PRIx64" was "
+ "found at metadata block 0x%"PRIx64", offset "
+ "0x%d, but undo processing will continue "
+ "until the end of this metadata block.\n"),
+ error_blk->errblk,
+ error_blk->metablk,
+ error_blk->metaoff);
+ }
+ return 0;
+}
+
static int undo_check_data(struct gfs2_inode *ip, struct metawalk_fxns *pass,
struct gfs2_buffer_head *bh, unsigned int height,
struct error_block *error_blk, int error)
@@ -1493,28 +1529,9 @@ static int undo_check_data(struct gfs2_inode *ip, struct
metawalk_fxns *pass,
if (skip_this_pass || fsck_abort)
return 1;
block = be64_to_cpu(*ptr);
- if (metablock == error_blk->metablk &&
- (ptr - ptr_start == error_blk->metaoff) &&
- block == error_blk->errblk) {
- if (error < 0) { /* A fatal error that stopped it? */
- log_debug(_("Stopping the undo process: "
- "fatal error block 0x%llx was "
- "found at metadata block 0x%llx,"
- "offset 0x%x.\n"),
- (unsigned long long)error_blk->errblk,
- (unsigned long long)error_blk->metablk,
- error_blk->metaoff);
- return 1;
- }
- found_error_blk = 1;
- log_debug(_("The non-fatal error block 0x%llx was "
- "found at metadata block 0x%llx, offset "
- "0x%d, but undo processing will continue "
- "until the end of this metadata block.\n"),
- (unsigned long long)error_blk->errblk,
- (unsigned long long)error_blk->metablk,
- error_blk->metaoff);
- }
+ if (report_undo_data_error(metablock, (char *)ptr - bh->b_data,
+ block, error_blk, &found_error_blk, error))
+ return 1;
rc = pass->undo_check_data(ip, block, pass->private);
if (rc < 0)
return rc;
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.