Commit 05cf492a authored by Dave Chinner's avatar Dave Chinner

xfs: use xfs_bmap_longest_free_extent() in filestreams

The code in xfs_bmap_longest_free_extent() is open coded in
xfs_filestream_pick_ag(). Export xfs_bmap_longest_free_extent and
call it from the filestreams code instead.
Signed-off-by: default avatarDave Chinner <dchinner@redhat.com>
Reviewed-by: default avatarDarrick J. Wong <djwong@kernel.org>
parent 6b637ad0
...@@ -3135,7 +3135,7 @@ xfs_bmap_adjacent( ...@@ -3135,7 +3135,7 @@ xfs_bmap_adjacent(
#undef ISVALID #undef ISVALID
} }
static int int
xfs_bmap_longest_free_extent( xfs_bmap_longest_free_extent(
struct xfs_perag *pag, struct xfs_perag *pag,
struct xfs_trans *tp, struct xfs_trans *tp,
......
...@@ -168,6 +168,8 @@ static inline bool xfs_bmap_is_written_extent(struct xfs_bmbt_irec *irec) ...@@ -168,6 +168,8 @@ static inline bool xfs_bmap_is_written_extent(struct xfs_bmbt_irec *irec)
#define xfs_valid_startblock(ip, startblock) \ #define xfs_valid_startblock(ip, startblock) \
((startblock) != 0 || XFS_IS_REALTIME_INODE(ip)) ((startblock) != 0 || XFS_IS_REALTIME_INODE(ip))
int xfs_bmap_longest_free_extent(struct xfs_perag *pag,
struct xfs_trans *tp, xfs_extlen_t *blen);
void xfs_trim_extent(struct xfs_bmbt_irec *irec, xfs_fileoff_t bno, void xfs_trim_extent(struct xfs_bmbt_irec *irec, xfs_fileoff_t bno,
xfs_filblks_t len); xfs_filblks_t len);
unsigned int xfs_bmap_compute_attr_offset(struct xfs_mount *mp); unsigned int xfs_bmap_compute_attr_offset(struct xfs_mount *mp);
......
...@@ -124,17 +124,14 @@ xfs_filestream_pick_ag( ...@@ -124,17 +124,14 @@ xfs_filestream_pick_ag(
trace_xfs_filestream_scan(mp, ip->i_ino, ag); trace_xfs_filestream_scan(mp, ip->i_ino, ag);
pag = xfs_perag_get(mp, ag); pag = xfs_perag_get(mp, ag);
longest = 0;
if (!xfs_perag_initialised_agf(pag)) { err = xfs_bmap_longest_free_extent(pag, NULL, &longest);
err = xfs_alloc_read_agf(pag, NULL, trylock, NULL); if (err) {
if (err) { xfs_perag_put(pag);
if (err != -EAGAIN) { if (err != -EAGAIN)
xfs_perag_put(pag); return err;
return err; /* Couldn't lock the AGF, skip this AG. */
} goto next_ag;
/* Couldn't lock the AGF, skip this AG. */
goto next_ag;
}
} }
/* Keep track of the AG with the most free blocks. */ /* Keep track of the AG with the most free blocks. */
...@@ -154,9 +151,6 @@ xfs_filestream_pick_ag( ...@@ -154,9 +151,6 @@ xfs_filestream_pick_ag(
goto next_ag; goto next_ag;
} }
longest = xfs_alloc_longest_free_extent(pag,
xfs_alloc_min_freelist(mp, pag),
xfs_ag_resv_needed(pag, XFS_AG_RESV_NONE));
if (((minlen && longest >= minlen) || if (((minlen && longest >= minlen) ||
(!minlen && pag->pagf_freeblks >= minfree)) && (!minlen && pag->pagf_freeblks >= minfree)) &&
(!xfs_perag_prefers_metadata(pag) || (!xfs_perag_prefers_metadata(pag) ||
......
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