Commit 676544c2 authored by Christoph Hellwig's avatar Christoph Hellwig Committed by Chandan Babu R

xfs: indicate if xfs_bmap_adjacent changed ap->blkno

Add a return value to xfs_bmap_adjacent to indicate if it did change
ap->blkno or not.
Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
Reviewed-by: default avatar"Darrick J. Wong" <djwong@kernel.org>
Signed-off-by: default avatarChandan Babu R <chandanbabu@kernel.org>
parent db8616e2
...@@ -3044,7 +3044,8 @@ xfs_bmap_extsize_align( ...@@ -3044,7 +3044,8 @@ xfs_bmap_extsize_align(
#define XFS_ALLOC_GAP_UNITS 4 #define XFS_ALLOC_GAP_UNITS 4
void /* returns true if ap->blkno was modified */
bool
xfs_bmap_adjacent( xfs_bmap_adjacent(
struct xfs_bmalloca *ap) /* bmap alloc argument struct */ struct xfs_bmalloca *ap) /* bmap alloc argument struct */
{ {
...@@ -3079,13 +3080,14 @@ xfs_bmap_adjacent( ...@@ -3079,13 +3080,14 @@ xfs_bmap_adjacent(
if (adjust && if (adjust &&
ISVALID(ap->blkno + adjust, ap->prev.br_startblock)) ISVALID(ap->blkno + adjust, ap->prev.br_startblock))
ap->blkno += adjust; ap->blkno += adjust;
return true;
} }
/* /*
* If not at eof, then compare the two neighbor blocks. * If not at eof, then compare the two neighbor blocks.
* Figure out whether either one gives us a good starting point, * Figure out whether either one gives us a good starting point,
* and pick the better one. * and pick the better one.
*/ */
else if (!ap->eof) { if (!ap->eof) {
xfs_fsblock_t gotbno; /* right side block number */ xfs_fsblock_t gotbno; /* right side block number */
xfs_fsblock_t gotdiff=0; /* right side difference */ xfs_fsblock_t gotdiff=0; /* right side difference */
xfs_fsblock_t prevbno; /* left side block number */ xfs_fsblock_t prevbno; /* left side block number */
...@@ -3165,14 +3167,21 @@ xfs_bmap_adjacent( ...@@ -3165,14 +3167,21 @@ xfs_bmap_adjacent(
* If both valid, pick the better one, else the only good * If both valid, pick the better one, else the only good
* one, else ap->blkno is already set (to 0 or the inode block). * one, else ap->blkno is already set (to 0 or the inode block).
*/ */
if (prevbno != NULLFSBLOCK && gotbno != NULLFSBLOCK) if (prevbno != NULLFSBLOCK && gotbno != NULLFSBLOCK) {
ap->blkno = prevdiff <= gotdiff ? prevbno : gotbno; ap->blkno = prevdiff <= gotdiff ? prevbno : gotbno;
else if (prevbno != NULLFSBLOCK) return true;
}
if (prevbno != NULLFSBLOCK) {
ap->blkno = prevbno; ap->blkno = prevbno;
else if (gotbno != NULLFSBLOCK) return true;
}
if (gotbno != NULLFSBLOCK) {
ap->blkno = gotbno; ap->blkno = gotbno;
return true;
}
} }
#undef ISVALID #undef ISVALID
return false;
} }
int int
......
...@@ -47,7 +47,7 @@ int xfs_bmap_extsize_align(struct xfs_mount *mp, struct xfs_bmbt_irec *gotp, ...@@ -47,7 +47,7 @@ int xfs_bmap_extsize_align(struct xfs_mount *mp, struct xfs_bmbt_irec *gotp,
struct xfs_bmbt_irec *prevp, xfs_extlen_t extsz, struct xfs_bmbt_irec *prevp, xfs_extlen_t extsz,
int rt, int eof, int delay, int convert, int rt, int eof, int delay, int convert,
xfs_fileoff_t *offp, xfs_extlen_t *lenp); xfs_fileoff_t *offp, xfs_extlen_t *lenp);
void xfs_bmap_adjacent(struct xfs_bmalloca *ap); bool xfs_bmap_adjacent(struct xfs_bmalloca *ap);
int xfs_bmap_last_extent(struct xfs_trans *tp, struct xfs_inode *ip, int xfs_bmap_last_extent(struct xfs_trans *tp, struct xfs_inode *ip,
int whichfork, struct xfs_bmbt_irec *rec, int whichfork, struct xfs_bmbt_irec *rec,
int *is_empty); int *is_empty);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment