xfs: pass a struct xfs_bmbt_irec to xfs_bmbt_lookup_eq
Now that we've massaged the callers into the right form we can always pass the actual extent record instead of the individual fields. As an additional benefit the btree cursor will now be prepoulated with the correct extent state instead of having to fix it up later. Signed-off-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Brian Foster <bfoster@redhat.com> Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com> Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
This commit is contained in:
parent
a67d00a555
commit
e16cf9b03c
|
@ -112,14 +112,10 @@ xfs_bmap_compute_maxlevels(
|
|||
STATIC int /* error */
|
||||
xfs_bmbt_lookup_eq(
|
||||
struct xfs_btree_cur *cur,
|
||||
xfs_fileoff_t off,
|
||||
xfs_fsblock_t bno,
|
||||
xfs_filblks_t len,
|
||||
struct xfs_bmbt_irec *irec,
|
||||
int *stat) /* success/failure */
|
||||
{
|
||||
cur->bc_rec.b.br_startoff = off;
|
||||
cur->bc_rec.b.br_startblock = bno;
|
||||
cur->bc_rec.b.br_blockcount = len;
|
||||
cur->bc_rec.b = *irec;
|
||||
return xfs_btree_lookup(cur, XFS_LOOKUP_EQ, stat);
|
||||
}
|
||||
|
||||
|
@ -1697,9 +1693,7 @@ xfs_bmap_add_extent_delay_real(
|
|||
rval = XFS_ILOG_CORE | XFS_ILOG_DEXT;
|
||||
else {
|
||||
rval = XFS_ILOG_CORE;
|
||||
error = xfs_bmbt_lookup_eq(bma->cur, RIGHT.br_startoff,
|
||||
RIGHT.br_startblock,
|
||||
RIGHT.br_blockcount, &i);
|
||||
error = xfs_bmbt_lookup_eq(bma->cur, &RIGHT, &i);
|
||||
if (error)
|
||||
goto done;
|
||||
XFS_WANT_CORRUPTED_GOTO(mp, i == 1, done);
|
||||
|
@ -1735,9 +1729,7 @@ xfs_bmap_add_extent_delay_real(
|
|||
rval = XFS_ILOG_DEXT;
|
||||
else {
|
||||
rval = 0;
|
||||
error = xfs_bmbt_lookup_eq(bma->cur, old.br_startoff,
|
||||
old.br_startblock, old.br_blockcount,
|
||||
&i);
|
||||
error = xfs_bmbt_lookup_eq(bma->cur, &old, &i);
|
||||
if (error)
|
||||
goto done;
|
||||
XFS_WANT_CORRUPTED_GOTO(mp, i == 1, done);
|
||||
|
@ -1763,9 +1755,7 @@ xfs_bmap_add_extent_delay_real(
|
|||
rval = XFS_ILOG_DEXT;
|
||||
else {
|
||||
rval = 0;
|
||||
error = xfs_bmbt_lookup_eq(bma->cur, RIGHT.br_startoff,
|
||||
RIGHT.br_startblock,
|
||||
RIGHT.br_blockcount, &i);
|
||||
error = xfs_bmbt_lookup_eq(bma->cur, &RIGHT, &i);
|
||||
if (error)
|
||||
goto done;
|
||||
XFS_WANT_CORRUPTED_GOTO(mp, i == 1, done);
|
||||
|
@ -1792,13 +1782,10 @@ xfs_bmap_add_extent_delay_real(
|
|||
rval = XFS_ILOG_CORE | XFS_ILOG_DEXT;
|
||||
else {
|
||||
rval = XFS_ILOG_CORE;
|
||||
error = xfs_bmbt_lookup_eq(bma->cur, new->br_startoff,
|
||||
new->br_startblock, new->br_blockcount,
|
||||
&i);
|
||||
error = xfs_bmbt_lookup_eq(bma->cur, new, &i);
|
||||
if (error)
|
||||
goto done;
|
||||
XFS_WANT_CORRUPTED_GOTO(mp, i == 0, done);
|
||||
bma->cur->bc_rec.b.br_state = XFS_EXT_NORM;
|
||||
error = xfs_btree_insert(bma->cur, &i);
|
||||
if (error)
|
||||
goto done;
|
||||
|
@ -1832,9 +1819,7 @@ xfs_bmap_add_extent_delay_real(
|
|||
rval = XFS_ILOG_DEXT;
|
||||
else {
|
||||
rval = 0;
|
||||
error = xfs_bmbt_lookup_eq(bma->cur, old.br_startoff,
|
||||
old.br_startblock, old.br_blockcount,
|
||||
&i);
|
||||
error = xfs_bmbt_lookup_eq(bma->cur, &old, &i);
|
||||
if (error)
|
||||
goto done;
|
||||
XFS_WANT_CORRUPTED_GOTO(mp, i == 1, done);
|
||||
|
@ -1857,13 +1842,10 @@ xfs_bmap_add_extent_delay_real(
|
|||
rval = XFS_ILOG_CORE | XFS_ILOG_DEXT;
|
||||
else {
|
||||
rval = XFS_ILOG_CORE;
|
||||
error = xfs_bmbt_lookup_eq(bma->cur, new->br_startoff,
|
||||
new->br_startblock, new->br_blockcount,
|
||||
&i);
|
||||
error = xfs_bmbt_lookup_eq(bma->cur, new, &i);
|
||||
if (error)
|
||||
goto done;
|
||||
XFS_WANT_CORRUPTED_GOTO(mp, i == 0, done);
|
||||
bma->cur->bc_rec.b.br_state = XFS_EXT_NORM;
|
||||
error = xfs_btree_insert(bma->cur, &i);
|
||||
if (error)
|
||||
goto done;
|
||||
|
@ -1910,9 +1892,7 @@ xfs_bmap_add_extent_delay_real(
|
|||
rval = XFS_ILOG_DEXT;
|
||||
else {
|
||||
rval = 0;
|
||||
error = xfs_bmbt_lookup_eq(bma->cur, old.br_startoff,
|
||||
old.br_startblock,
|
||||
old.br_blockcount, &i);
|
||||
error = xfs_bmbt_lookup_eq(bma->cur, &old, &i);
|
||||
if (error)
|
||||
goto done;
|
||||
XFS_WANT_CORRUPTED_GOTO(mp, i == 1, done);
|
||||
|
@ -1945,13 +1925,10 @@ xfs_bmap_add_extent_delay_real(
|
|||
rval = XFS_ILOG_CORE | XFS_ILOG_DEXT;
|
||||
else {
|
||||
rval = XFS_ILOG_CORE;
|
||||
error = xfs_bmbt_lookup_eq(bma->cur, new->br_startoff,
|
||||
new->br_startblock, new->br_blockcount,
|
||||
&i);
|
||||
error = xfs_bmbt_lookup_eq(bma->cur, new, &i);
|
||||
if (error)
|
||||
goto done;
|
||||
XFS_WANT_CORRUPTED_GOTO(mp, i == 0, done);
|
||||
bma->cur->bc_rec.b.br_state = XFS_EXT_NORM;
|
||||
error = xfs_btree_insert(bma->cur, &i);
|
||||
if (error)
|
||||
goto done;
|
||||
|
@ -2033,13 +2010,10 @@ xfs_bmap_add_extent_delay_real(
|
|||
rval = XFS_ILOG_CORE | XFS_ILOG_DEXT;
|
||||
else {
|
||||
rval = XFS_ILOG_CORE;
|
||||
error = xfs_bmbt_lookup_eq(bma->cur, new->br_startoff,
|
||||
new->br_startblock, new->br_blockcount,
|
||||
&i);
|
||||
error = xfs_bmbt_lookup_eq(bma->cur, new, &i);
|
||||
if (error)
|
||||
goto done;
|
||||
XFS_WANT_CORRUPTED_GOTO(mp, i == 0, done);
|
||||
bma->cur->bc_rec.b.br_state = XFS_EXT_NORM;
|
||||
error = xfs_btree_insert(bma->cur, &i);
|
||||
if (error)
|
||||
goto done;
|
||||
|
@ -2245,9 +2219,8 @@ xfs_bmap_add_extent_unwritten_real(
|
|||
rval = XFS_ILOG_CORE | XFS_ILOG_DEXT;
|
||||
else {
|
||||
rval = XFS_ILOG_CORE;
|
||||
if ((error = xfs_bmbt_lookup_eq(cur, RIGHT.br_startoff,
|
||||
RIGHT.br_startblock,
|
||||
RIGHT.br_blockcount, &i)))
|
||||
error = xfs_bmbt_lookup_eq(cur, &RIGHT, &i);
|
||||
if (error)
|
||||
goto done;
|
||||
XFS_WANT_CORRUPTED_GOTO(mp, i == 1, done);
|
||||
if ((error = xfs_btree_delete(cur, &i)))
|
||||
|
@ -2287,9 +2260,8 @@ xfs_bmap_add_extent_unwritten_real(
|
|||
rval = XFS_ILOG_CORE | XFS_ILOG_DEXT;
|
||||
else {
|
||||
rval = XFS_ILOG_CORE;
|
||||
if ((error = xfs_bmbt_lookup_eq(cur, PREV.br_startoff,
|
||||
PREV.br_startblock, PREV.br_blockcount,
|
||||
&i)))
|
||||
error = xfs_bmbt_lookup_eq(cur, &PREV, &i);
|
||||
if (error)
|
||||
goto done;
|
||||
XFS_WANT_CORRUPTED_GOTO(mp, i == 1, done);
|
||||
if ((error = xfs_btree_delete(cur, &i)))
|
||||
|
@ -2322,9 +2294,8 @@ xfs_bmap_add_extent_unwritten_real(
|
|||
rval = XFS_ILOG_CORE | XFS_ILOG_DEXT;
|
||||
else {
|
||||
rval = XFS_ILOG_CORE;
|
||||
if ((error = xfs_bmbt_lookup_eq(cur, RIGHT.br_startoff,
|
||||
RIGHT.br_startblock,
|
||||
RIGHT.br_blockcount, &i)))
|
||||
error = xfs_bmbt_lookup_eq(cur, &RIGHT, &i);
|
||||
if (error)
|
||||
goto done;
|
||||
XFS_WANT_CORRUPTED_GOTO(mp, i == 1, done);
|
||||
if ((error = xfs_btree_delete(cur, &i)))
|
||||
|
@ -2354,9 +2325,8 @@ xfs_bmap_add_extent_unwritten_real(
|
|||
rval = XFS_ILOG_DEXT;
|
||||
else {
|
||||
rval = 0;
|
||||
if ((error = xfs_bmbt_lookup_eq(cur, new->br_startoff,
|
||||
new->br_startblock, new->br_blockcount,
|
||||
&i)))
|
||||
error = xfs_bmbt_lookup_eq(cur, new, &i);
|
||||
if (error)
|
||||
goto done;
|
||||
XFS_WANT_CORRUPTED_GOTO(mp, i == 1, done);
|
||||
error = xfs_bmbt_update(cur, &PREV);
|
||||
|
@ -2389,9 +2359,7 @@ xfs_bmap_add_extent_unwritten_real(
|
|||
rval = XFS_ILOG_DEXT;
|
||||
else {
|
||||
rval = 0;
|
||||
error = xfs_bmbt_lookup_eq(cur, old.br_startoff,
|
||||
old.br_startblock, old.br_blockcount,
|
||||
&i);
|
||||
error = xfs_bmbt_lookup_eq(cur, &old, &i);
|
||||
if (error)
|
||||
goto done;
|
||||
XFS_WANT_CORRUPTED_GOTO(mp, i == 1, done);
|
||||
|
@ -2427,9 +2395,7 @@ xfs_bmap_add_extent_unwritten_real(
|
|||
rval = XFS_ILOG_CORE | XFS_ILOG_DEXT;
|
||||
else {
|
||||
rval = XFS_ILOG_CORE;
|
||||
error = xfs_bmbt_lookup_eq(cur, old.br_startoff,
|
||||
old.br_startblock, old.br_blockcount,
|
||||
&i);
|
||||
error = xfs_bmbt_lookup_eq(cur, &old, &i);
|
||||
if (error)
|
||||
goto done;
|
||||
XFS_WANT_CORRUPTED_GOTO(mp, i == 1, done);
|
||||
|
@ -2467,9 +2433,7 @@ xfs_bmap_add_extent_unwritten_real(
|
|||
rval = XFS_ILOG_DEXT;
|
||||
else {
|
||||
rval = 0;
|
||||
error = xfs_bmbt_lookup_eq(cur, old.br_startoff,
|
||||
old.br_startblock, old.br_blockcount,
|
||||
&i);
|
||||
error = xfs_bmbt_lookup_eq(cur, &old, &i);
|
||||
if (error)
|
||||
goto done;
|
||||
XFS_WANT_CORRUPTED_GOTO(mp, i == 1, done);
|
||||
|
@ -2505,21 +2469,17 @@ xfs_bmap_add_extent_unwritten_real(
|
|||
rval = XFS_ILOG_CORE | XFS_ILOG_DEXT;
|
||||
else {
|
||||
rval = XFS_ILOG_CORE;
|
||||
error = xfs_bmbt_lookup_eq(cur, old.br_startoff,
|
||||
old.br_startblock, old.br_blockcount,
|
||||
&i);
|
||||
error = xfs_bmbt_lookup_eq(cur, &old, &i);
|
||||
if (error)
|
||||
goto done;
|
||||
XFS_WANT_CORRUPTED_GOTO(mp, i == 1, done);
|
||||
error = xfs_bmbt_update(cur, &PREV);
|
||||
if (error)
|
||||
goto done;
|
||||
if ((error = xfs_bmbt_lookup_eq(cur, new->br_startoff,
|
||||
new->br_startblock, new->br_blockcount,
|
||||
&i)))
|
||||
error = xfs_bmbt_lookup_eq(cur, new, &i);
|
||||
if (error)
|
||||
goto done;
|
||||
XFS_WANT_CORRUPTED_GOTO(mp, i == 0, done);
|
||||
cur->bc_rec.b.br_state = new->br_state;
|
||||
if ((error = xfs_btree_insert(cur, &i)))
|
||||
goto done;
|
||||
XFS_WANT_CORRUPTED_GOTO(mp, i == 1, done);
|
||||
|
@ -2554,9 +2514,7 @@ xfs_bmap_add_extent_unwritten_real(
|
|||
rval = XFS_ILOG_CORE | XFS_ILOG_DEXT;
|
||||
else {
|
||||
rval = XFS_ILOG_CORE;
|
||||
error = xfs_bmbt_lookup_eq(cur, old.br_startoff,
|
||||
old.br_startblock, old.br_blockcount,
|
||||
&i);
|
||||
error = xfs_bmbt_lookup_eq(cur, &old, &i);
|
||||
if (error)
|
||||
goto done;
|
||||
XFS_WANT_CORRUPTED_GOTO(mp, i == 1, done);
|
||||
|
@ -2574,13 +2532,11 @@ xfs_bmap_add_extent_unwritten_real(
|
|||
* we are about to insert as we can't trust it after
|
||||
* the previous insert.
|
||||
*/
|
||||
if ((error = xfs_bmbt_lookup_eq(cur, new->br_startoff,
|
||||
new->br_startblock, new->br_blockcount,
|
||||
&i)))
|
||||
error = xfs_bmbt_lookup_eq(cur, new, &i);
|
||||
if (error)
|
||||
goto done;
|
||||
XFS_WANT_CORRUPTED_GOTO(mp, i == 0, done);
|
||||
/* new middle extent - newext */
|
||||
cur->bc_rec.b.br_state = new->br_state;
|
||||
if ((error = xfs_btree_insert(cur, &i)))
|
||||
goto done;
|
||||
XFS_WANT_CORRUPTED_GOTO(mp, i == 1, done);
|
||||
|
@ -2889,9 +2845,7 @@ xfs_bmap_add_extent_hole_real(
|
|||
rval = XFS_ILOG_CORE | xfs_ilog_fext(whichfork);
|
||||
} else {
|
||||
rval = XFS_ILOG_CORE;
|
||||
error = xfs_bmbt_lookup_eq(cur, right.br_startoff,
|
||||
right.br_startblock, right.br_blockcount,
|
||||
&i);
|
||||
error = xfs_bmbt_lookup_eq(cur, &right, &i);
|
||||
if (error)
|
||||
goto done;
|
||||
XFS_WANT_CORRUPTED_GOTO(mp, i == 1, done);
|
||||
|
@ -2926,9 +2880,7 @@ xfs_bmap_add_extent_hole_real(
|
|||
rval = xfs_ilog_fext(whichfork);
|
||||
} else {
|
||||
rval = 0;
|
||||
error = xfs_bmbt_lookup_eq(cur, old.br_startoff,
|
||||
old.br_startblock, old.br_blockcount,
|
||||
&i);
|
||||
error = xfs_bmbt_lookup_eq(cur, &old, &i);
|
||||
if (error)
|
||||
goto done;
|
||||
XFS_WANT_CORRUPTED_GOTO(mp, i == 1, done);
|
||||
|
@ -2956,9 +2908,7 @@ xfs_bmap_add_extent_hole_real(
|
|||
rval = xfs_ilog_fext(whichfork);
|
||||
} else {
|
||||
rval = 0;
|
||||
error = xfs_bmbt_lookup_eq(cur, old.br_startoff,
|
||||
old.br_startblock, old.br_blockcount,
|
||||
&i);
|
||||
error = xfs_bmbt_lookup_eq(cur, &old, &i);
|
||||
if (error)
|
||||
goto done;
|
||||
XFS_WANT_CORRUPTED_GOTO(mp, i == 1, done);
|
||||
|
@ -2981,14 +2931,10 @@ xfs_bmap_add_extent_hole_real(
|
|||
rval = XFS_ILOG_CORE | xfs_ilog_fext(whichfork);
|
||||
} else {
|
||||
rval = XFS_ILOG_CORE;
|
||||
error = xfs_bmbt_lookup_eq(cur,
|
||||
new->br_startoff,
|
||||
new->br_startblock,
|
||||
new->br_blockcount, &i);
|
||||
error = xfs_bmbt_lookup_eq(cur, new, &i);
|
||||
if (error)
|
||||
goto done;
|
||||
XFS_WANT_CORRUPTED_GOTO(mp, i == 0, done);
|
||||
cur->bc_rec.b.br_state = new->br_state;
|
||||
error = xfs_btree_insert(cur, &i);
|
||||
if (error)
|
||||
goto done;
|
||||
|
@ -5099,8 +5045,7 @@ xfs_bmap_del_extent_real(
|
|||
|
||||
del_endblock = del->br_startblock + del->br_blockcount;
|
||||
if (cur) {
|
||||
error = xfs_bmbt_lookup_eq(cur, got.br_startoff,
|
||||
got.br_startblock, got.br_blockcount, &i);
|
||||
error = xfs_bmbt_lookup_eq(cur, &got, &i);
|
||||
if (error)
|
||||
goto done;
|
||||
XFS_WANT_CORRUPTED_GOTO(mp, i == 1, done);
|
||||
|
@ -5203,9 +5148,7 @@ xfs_bmap_del_extent_real(
|
|||
* Reset the cursor, don't trust it after any
|
||||
* insert operation.
|
||||
*/
|
||||
error = xfs_bmbt_lookup_eq(cur, got.br_startoff,
|
||||
got.br_startblock,
|
||||
got.br_blockcount, &i);
|
||||
error = xfs_bmbt_lookup_eq(cur, &got, &i);
|
||||
if (error)
|
||||
goto done;
|
||||
XFS_WANT_CORRUPTED_GOTO(mp, i == 1, done);
|
||||
|
@ -5733,8 +5676,7 @@ xfs_bmse_merge(
|
|||
}
|
||||
|
||||
/* lookup and remove the extent to merge */
|
||||
error = xfs_bmbt_lookup_eq(cur, got->br_startoff, got->br_startblock,
|
||||
got->br_blockcount, &i);
|
||||
error = xfs_bmbt_lookup_eq(cur, got, &i);
|
||||
if (error)
|
||||
return error;
|
||||
XFS_WANT_CORRUPTED_RETURN(mp, i == 1);
|
||||
|
@ -5745,8 +5687,7 @@ xfs_bmse_merge(
|
|||
XFS_WANT_CORRUPTED_RETURN(mp, i == 1);
|
||||
|
||||
/* lookup and update size of the previous extent */
|
||||
error = xfs_bmbt_lookup_eq(cur, left->br_startoff, left->br_startblock,
|
||||
left->br_blockcount, &i);
|
||||
error = xfs_bmbt_lookup_eq(cur, left, &i);
|
||||
if (error)
|
||||
return error;
|
||||
XFS_WANT_CORRUPTED_RETURN(mp, i == 1);
|
||||
|
@ -5862,8 +5803,7 @@ xfs_bmse_shift_one(
|
|||
new.br_startoff = startoff;
|
||||
|
||||
if (cur) {
|
||||
error = xfs_bmbt_lookup_eq(cur, got->br_startoff,
|
||||
got->br_startblock, got->br_blockcount, &i);
|
||||
error = xfs_bmbt_lookup_eq(cur, got, &i);
|
||||
if (error)
|
||||
return error;
|
||||
XFS_WANT_CORRUPTED_RETURN(mp, i == 1);
|
||||
|
@ -6115,10 +6055,7 @@ xfs_bmap_split_extent_at(
|
|||
cur->bc_private.b.firstblock = *firstfsb;
|
||||
cur->bc_private.b.dfops = dfops;
|
||||
cur->bc_private.b.flags = 0;
|
||||
error = xfs_bmbt_lookup_eq(cur, got.br_startoff,
|
||||
got.br_startblock,
|
||||
got.br_blockcount,
|
||||
&i);
|
||||
error = xfs_bmbt_lookup_eq(cur, &got, &i);
|
||||
if (error)
|
||||
goto del_cursor;
|
||||
XFS_WANT_CORRUPTED_GOTO(mp, i == 1, del_cursor);
|
||||
|
@ -6142,14 +6079,10 @@ xfs_bmap_split_extent_at(
|
|||
XFS_IFORK_NEXTENTS(ip, whichfork) + 1);
|
||||
|
||||
if (cur) {
|
||||
error = xfs_bmbt_lookup_eq(cur, new.br_startoff,
|
||||
new.br_startblock, new.br_blockcount,
|
||||
&i);
|
||||
error = xfs_bmbt_lookup_eq(cur, &new, &i);
|
||||
if (error)
|
||||
goto del_cursor;
|
||||
XFS_WANT_CORRUPTED_GOTO(mp, i == 0, del_cursor);
|
||||
cur->bc_rec.b.br_state = new.br_state;
|
||||
|
||||
error = xfs_btree_insert(cur, &i);
|
||||
if (error)
|
||||
goto del_cursor;
|
||||
|
|
Loading…
Reference in New Issue