From: Darrick J. Wong Date: Fri, 5 Oct 2018 02:36:09 +0000 (-0500) Subject: xfs: don't assume a left rmap when allocating a new rmap X-Git-Tag: v4.19.0-rc0~52 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=a6ad7ea889f83e499876b5f08bd92bff206c0f2d;p=thirdparty%2Fxfsprogs-dev.git xfs: don't assume a left rmap when allocating a new rmap Source kernel commit: fa248de98a6beb9ceaec5059041d65f87ac438b4 The original rmap code assumed that there would always be at least one rmap in the rmapbt (the AG sb/agf/agi) and so errored out if it didn't find one. This assumption isn't true for the rmapbt repair function (and it won't be true for realtime rmap either), so remove the check and just deal with the situation. Signed-off-by: Darrick J. Wong Reviewed-by: Allison Henderson Signed-off-by: Eric Sandeen --- diff --git a/libxfs/xfs_rmap.c b/libxfs/xfs_rmap.c index 3cbba4ba7..8e5f86d57 100644 --- a/libxfs/xfs_rmap.c +++ b/libxfs/xfs_rmap.c @@ -751,19 +751,19 @@ xfs_rmap_map( &have_lt); if (error) goto out_error; - XFS_WANT_CORRUPTED_GOTO(mp, have_lt == 1, out_error); - - error = xfs_rmap_get_rec(cur, <rec, &have_lt); - if (error) - goto out_error; - XFS_WANT_CORRUPTED_GOTO(mp, have_lt == 1, out_error); - trace_xfs_rmap_lookup_le_range_result(cur->bc_mp, - cur->bc_private.a.agno, ltrec.rm_startblock, - ltrec.rm_blockcount, ltrec.rm_owner, - ltrec.rm_offset, ltrec.rm_flags); + if (have_lt) { + error = xfs_rmap_get_rec(cur, <rec, &have_lt); + if (error) + goto out_error; + XFS_WANT_CORRUPTED_GOTO(mp, have_lt == 1, out_error); + trace_xfs_rmap_lookup_le_range_result(cur->bc_mp, + cur->bc_private.a.agno, ltrec.rm_startblock, + ltrec.rm_blockcount, ltrec.rm_owner, + ltrec.rm_offset, ltrec.rm_flags); - if (!xfs_rmap_is_mergeable(<rec, owner, flags)) - have_lt = 0; + if (!xfs_rmap_is_mergeable(<rec, owner, flags)) + have_lt = 0; + } XFS_WANT_CORRUPTED_GOTO(mp, have_lt == 0 ||