xfs: simplify returns in xchk_bmap

Remove the pointless goto and return code in xchk_bmap, since it only
serves to obscure what's going on in the function.  Instead, return
whichever error code is appropriate there.  For nonexistent forks,
this should have been ENOENT.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
This commit is contained in:
Darrick J. Wong 2023-08-10 07:48:13 -07:00
parent 369c001b7a
commit 65092ca140

View File

@ -841,7 +841,7 @@ xchk_bmap(
/* Non-existent forks can be ignored. */ /* Non-existent forks can be ignored. */
if (!ifp) if (!ifp)
goto out; return -ENOENT;
info.is_rt = whichfork == XFS_DATA_FORK && XFS_IS_REALTIME_INODE(ip); info.is_rt = whichfork == XFS_DATA_FORK && XFS_IS_REALTIME_INODE(ip);
info.whichfork = whichfork; info.whichfork = whichfork;
@ -853,7 +853,7 @@ xchk_bmap(
/* No CoW forks on non-reflink inodes/filesystems. */ /* No CoW forks on non-reflink inodes/filesystems. */
if (!xfs_is_reflink_inode(ip)) { if (!xfs_is_reflink_inode(ip)) {
xchk_ino_set_corrupt(sc, sc->ip->i_ino); xchk_ino_set_corrupt(sc, sc->ip->i_ino);
goto out; return 0;
} }
break; break;
case XFS_ATTR_FORK: case XFS_ATTR_FORK:
@ -873,31 +873,31 @@ xchk_bmap(
/* No mappings to check. */ /* No mappings to check. */
if (whichfork == XFS_COW_FORK) if (whichfork == XFS_COW_FORK)
xchk_fblock_set_corrupt(sc, whichfork, 0); xchk_fblock_set_corrupt(sc, whichfork, 0);
goto out; return 0;
case XFS_DINODE_FMT_EXTENTS: case XFS_DINODE_FMT_EXTENTS:
break; break;
case XFS_DINODE_FMT_BTREE: case XFS_DINODE_FMT_BTREE:
if (whichfork == XFS_COW_FORK) { if (whichfork == XFS_COW_FORK) {
xchk_fblock_set_corrupt(sc, whichfork, 0); xchk_fblock_set_corrupt(sc, whichfork, 0);
goto out; return 0;
} }
error = xchk_bmap_btree(sc, whichfork, &info); error = xchk_bmap_btree(sc, whichfork, &info);
if (error) if (error)
goto out; return error;
break; break;
default: default:
xchk_fblock_set_corrupt(sc, whichfork, 0); xchk_fblock_set_corrupt(sc, whichfork, 0);
goto out; return 0;
} }
if (sc->sm->sm_flags & XFS_SCRUB_OFLAG_CORRUPT) if (sc->sm->sm_flags & XFS_SCRUB_OFLAG_CORRUPT)
goto out; return 0;
/* Find the offset of the last extent in the mapping. */ /* Find the offset of the last extent in the mapping. */
error = xfs_bmap_last_offset(ip, &endoff, whichfork); error = xfs_bmap_last_offset(ip, &endoff, whichfork);
if (!xchk_fblock_process_error(sc, whichfork, 0, &error)) if (!xchk_fblock_process_error(sc, whichfork, 0, &error))
goto out; return error;
/* /*
* Scrub extent records. We use a special iterator function here that * Scrub extent records. We use a special iterator function here that
@ -910,12 +910,12 @@ xchk_bmap(
while (xchk_bmap_iext_iter(&info, &irec)) { while (xchk_bmap_iext_iter(&info, &irec)) {
if (xchk_should_terminate(sc, &error) || if (xchk_should_terminate(sc, &error) ||
(sc->sm->sm_flags & XFS_SCRUB_OFLAG_CORRUPT)) (sc->sm->sm_flags & XFS_SCRUB_OFLAG_CORRUPT))
goto out; return 0;
if (irec.br_startoff >= endoff) { if (irec.br_startoff >= endoff) {
xchk_fblock_set_corrupt(sc, whichfork, xchk_fblock_set_corrupt(sc, whichfork,
irec.br_startoff); irec.br_startoff);
goto out; return 0;
} }
if (isnullstartblock(irec.br_startblock)) if (isnullstartblock(irec.br_startblock))
@ -928,10 +928,10 @@ xchk_bmap(
if (xchk_bmap_want_check_rmaps(&info)) { if (xchk_bmap_want_check_rmaps(&info)) {
error = xchk_bmap_check_rmaps(sc, whichfork); error = xchk_bmap_check_rmaps(sc, whichfork);
if (!xchk_fblock_xref_process_error(sc, whichfork, 0, &error)) if (!xchk_fblock_xref_process_error(sc, whichfork, 0, &error))
goto out; return error;
} }
out:
return error; return 0;
} }
/* Scrub an inode's data fork. */ /* Scrub an inode's data fork. */