Skip to content

Commit 676544c

Browse files
Christoph HellwigChandan Babu R
authored andcommitted
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: Christoph Hellwig <[email protected]> Reviewed-by: "Darrick J. Wong" <[email protected]> Signed-off-by: Chandan Babu R <[email protected]>
1 parent db8616e commit 676544c

File tree

2 files changed

+15
-6
lines changed

2 files changed

+15
-6
lines changed

fs/xfs/libxfs/xfs_bmap.c

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3044,7 +3044,8 @@ xfs_bmap_extsize_align(
30443044

30453045
#define XFS_ALLOC_GAP_UNITS 4
30463046

3047-
void
3047+
/* returns true if ap->blkno was modified */
3048+
bool
30483049
xfs_bmap_adjacent(
30493050
struct xfs_bmalloca *ap) /* bmap alloc argument struct */
30503051
{
@@ -3079,13 +3080,14 @@ xfs_bmap_adjacent(
30793080
if (adjust &&
30803081
ISVALID(ap->blkno + adjust, ap->prev.br_startblock))
30813082
ap->blkno += adjust;
3083+
return true;
30823084
}
30833085
/*
30843086
* If not at eof, then compare the two neighbor blocks.
30853087
* Figure out whether either one gives us a good starting point,
30863088
* and pick the better one.
30873089
*/
3088-
else if (!ap->eof) {
3090+
if (!ap->eof) {
30893091
xfs_fsblock_t gotbno; /* right side block number */
30903092
xfs_fsblock_t gotdiff=0; /* right side difference */
30913093
xfs_fsblock_t prevbno; /* left side block number */
@@ -3165,14 +3167,21 @@ xfs_bmap_adjacent(
31653167
* If both valid, pick the better one, else the only good
31663168
* one, else ap->blkno is already set (to 0 or the inode block).
31673169
*/
3168-
if (prevbno != NULLFSBLOCK && gotbno != NULLFSBLOCK)
3170+
if (prevbno != NULLFSBLOCK && gotbno != NULLFSBLOCK) {
31693171
ap->blkno = prevdiff <= gotdiff ? prevbno : gotbno;
3170-
else if (prevbno != NULLFSBLOCK)
3172+
return true;
3173+
}
3174+
if (prevbno != NULLFSBLOCK) {
31713175
ap->blkno = prevbno;
3172-
else if (gotbno != NULLFSBLOCK)
3176+
return true;
3177+
}
3178+
if (gotbno != NULLFSBLOCK) {
31733179
ap->blkno = gotbno;
3180+
return true;
3181+
}
31743182
}
31753183
#undef ISVALID
3184+
return false;
31763185
}
31773186

31783187
int

fs/xfs/xfs_bmap_util.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ int xfs_bmap_extsize_align(struct xfs_mount *mp, struct xfs_bmbt_irec *gotp,
4747
struct xfs_bmbt_irec *prevp, xfs_extlen_t extsz,
4848
int rt, int eof, int delay, int convert,
4949
xfs_fileoff_t *offp, xfs_extlen_t *lenp);
50-
void xfs_bmap_adjacent(struct xfs_bmalloca *ap);
50+
bool xfs_bmap_adjacent(struct xfs_bmalloca *ap);
5151
int xfs_bmap_last_extent(struct xfs_trans *tp, struct xfs_inode *ip,
5252
int whichfork, struct xfs_bmbt_irec *rec,
5353
int *is_empty);

0 commit comments

Comments
 (0)