]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commitdiff
xfs_scrub: report bad file ranges correctly
authorDarrick J. Wong <djwong@kernel.org>
Wed, 24 Jun 2026 18:15:02 +0000 (11:15 -0700)
committerAndrey Albershteyn <aalbersh@kernel.org>
Thu, 25 Jun 2026 13:42:53 +0000 (15:42 +0200)
Codex complains that the "media error at data offset..." message prints
the wrong information -- err_off is the offset into @map, not the file
offset; and the length should be constrained by the end of @map.  Fix
both of these issues.

Cc: linux-xfs@vger.kernel.org # v4.15.0
Fixes: b364a9c008fc04 ("xfs_scrub: scrub file data blocks")
Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
scrub/phase6.c

index cd9bb26bf88628065a46308136e70c403aff8e41..2278ae5ad3dfd7fba8a0e1f2be7a39f0eb4e0486 100644 (file)
@@ -408,6 +408,7 @@ report_ioerr_fsmap(
        char                    buf[DESCR_BUFSZ];
        struct ioerr_filerange  *fr = arg;
        uint64_t                err_off;
+       uint64_t                err_len;
        int                     ret;
 
        /* Don't care about unwritten extents. */
@@ -476,9 +477,12 @@ report_ioerr_fsmap(
                return 0;
        }
 
+       err_len = min(fr->physical + fr->length,
+                     map->fmr_physical + map->fmr_length) -
+                 max(fr->physical, map->fmr_physical);
        str_unfixable_error(ctx, buf,
  _("media error at data offset %llu length %llu."),
-                       err_off, fr->length);
+                       map->fmr_offset + err_off, err_len);
        return 0;
 }