Skip to content

Commit

Permalink
xfs: simplify returns in xchk_bmap
Browse files Browse the repository at this point in the history
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 <[email protected]>
Reviewed-by: Dave Chinner <[email protected]>
  • Loading branch information
Darrick J. Wong committed Aug 10, 2023
1 parent 369c001 commit 65092ca
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions fs/xfs/scrub/bmap.c
Original file line number Diff line number Diff line change
Expand Up @@ -841,7 +841,7 @@ xchk_bmap(

/* Non-existent forks can be ignored. */
if (!ifp)
goto out;
return -ENOENT;

info.is_rt = whichfork == XFS_DATA_FORK && XFS_IS_REALTIME_INODE(ip);
info.whichfork = whichfork;
Expand All @@ -853,7 +853,7 @@ xchk_bmap(
/* No CoW forks on non-reflink inodes/filesystems. */
if (!xfs_is_reflink_inode(ip)) {
xchk_ino_set_corrupt(sc, sc->ip->i_ino);
goto out;
return 0;
}
break;
case XFS_ATTR_FORK:
Expand All @@ -873,31 +873,31 @@ xchk_bmap(
/* No mappings to check. */
if (whichfork == XFS_COW_FORK)
xchk_fblock_set_corrupt(sc, whichfork, 0);
goto out;
return 0;
case XFS_DINODE_FMT_EXTENTS:
break;
case XFS_DINODE_FMT_BTREE:
if (whichfork == XFS_COW_FORK) {
xchk_fblock_set_corrupt(sc, whichfork, 0);
goto out;
return 0;
}

error = xchk_bmap_btree(sc, whichfork, &info);
if (error)
goto out;
return error;
break;
default:
xchk_fblock_set_corrupt(sc, whichfork, 0);
goto out;
return 0;
}

if (sc->sm->sm_flags & XFS_SCRUB_OFLAG_CORRUPT)
goto out;
return 0;

/* Find the offset of the last extent in the mapping. */
error = xfs_bmap_last_offset(ip, &endoff, whichfork);
if (!xchk_fblock_process_error(sc, whichfork, 0, &error))
goto out;
return error;

/*
* Scrub extent records. We use a special iterator function here that
Expand All @@ -910,12 +910,12 @@ xchk_bmap(
while (xchk_bmap_iext_iter(&info, &irec)) {
if (xchk_should_terminate(sc, &error) ||
(sc->sm->sm_flags & XFS_SCRUB_OFLAG_CORRUPT))
goto out;
return 0;

if (irec.br_startoff >= endoff) {
xchk_fblock_set_corrupt(sc, whichfork,
irec.br_startoff);
goto out;
return 0;
}

if (isnullstartblock(irec.br_startblock))
Expand All @@ -928,10 +928,10 @@ xchk_bmap(
if (xchk_bmap_want_check_rmaps(&info)) {
error = xchk_bmap_check_rmaps(sc, whichfork);
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. */
Expand Down

0 comments on commit 65092ca

Please sign in to comment.