Commit 405ee87c authored by Christoph Hellwig's avatar Christoph Hellwig Committed by Carlos Maiolino

xfs: call xfs_bmap_exact_minlen_extent_alloc from xfs_bmap_btalloc

xfs_bmap_exact_minlen_extent_alloc duplicates the args setup in
xfs_bmap_btalloc.  Switch to call it from xfs_bmap_btalloc after
doing the basic setup.
Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
Reviewed-by: default avatarDarrick J. Wong <djwong@kernel.org>
Signed-off-by: default avatarCarlos Maiolino <cem@kernel.org>
parent b611fddc
...@@ -3479,28 +3479,17 @@ xfs_bmap_process_allocated_extent( ...@@ -3479,28 +3479,17 @@ xfs_bmap_process_allocated_extent(
static int static int
xfs_bmap_exact_minlen_extent_alloc( xfs_bmap_exact_minlen_extent_alloc(
struct xfs_bmalloca *ap) struct xfs_bmalloca *ap,
struct xfs_alloc_arg *args)
{ {
struct xfs_mount *mp = ap->ip->i_mount;
struct xfs_alloc_arg args = { .tp = ap->tp, .mp = mp };
xfs_fileoff_t orig_offset;
xfs_extlen_t orig_length;
int error;
ASSERT(ap->length);
if (ap->minlen != 1) { if (ap->minlen != 1) {
ap->blkno = NULLFSBLOCK; args->fsbno = NULLFSBLOCK;
ap->length = 0;
return 0; return 0;
} }
orig_offset = ap->offset; args->alloc_minlen_only = 1;
orig_length = ap->length; args->minlen = args->maxlen = ap->minlen;
args->total = ap->total;
args.alloc_minlen_only = 1;
xfs_bmap_compute_alignments(ap, &args);
/* /*
* Unlike the longest extent available in an AG, we don't track * Unlike the longest extent available in an AG, we don't track
...@@ -3510,33 +3499,9 @@ xfs_bmap_exact_minlen_extent_alloc( ...@@ -3510,33 +3499,9 @@ xfs_bmap_exact_minlen_extent_alloc(
* we need not be concerned about a drop in performance in * we need not be concerned about a drop in performance in
* "debug only" code paths. * "debug only" code paths.
*/ */
ap->blkno = XFS_AGB_TO_FSB(mp, 0, 0); ap->blkno = XFS_AGB_TO_FSB(ap->ip->i_mount, 0, 0);
args.oinfo = XFS_RMAP_OINFO_SKIP_UPDATE; return xfs_alloc_vextent_first_ag(args, ap->blkno);
args.minlen = args.maxlen = ap->minlen;
args.total = ap->total;
args.alignment = 1;
args.minalignslop = 0;
args.minleft = ap->minleft;
args.wasdel = ap->wasdel;
args.resv = XFS_AG_RESV_NONE;
args.datatype = ap->datatype;
error = xfs_alloc_vextent_first_ag(&args, ap->blkno);
if (error)
return error;
if (args.fsbno != NULLFSBLOCK) {
xfs_bmap_process_allocated_extent(ap, &args, orig_offset,
orig_length);
} else {
ap->blkno = NULLFSBLOCK;
ap->length = 0;
}
return 0;
} }
/* /*
...@@ -3795,8 +3760,11 @@ xfs_bmap_btalloc( ...@@ -3795,8 +3760,11 @@ xfs_bmap_btalloc(
/* Trim the allocation back to the maximum an AG can fit. */ /* Trim the allocation back to the maximum an AG can fit. */
args.maxlen = min(ap->length, mp->m_ag_max_usable); args.maxlen = min(ap->length, mp->m_ag_max_usable);
if ((ap->datatype & XFS_ALLOC_USERDATA) && if (unlikely(XFS_TEST_ERROR(false, mp,
xfs_inode_is_filestream(ap->ip)) XFS_ERRTAG_BMAP_ALLOC_MINLEN_EXTENT)))
error = xfs_bmap_exact_minlen_extent_alloc(ap, &args);
else if ((ap->datatype & XFS_ALLOC_USERDATA) &&
xfs_inode_is_filestream(ap->ip))
error = xfs_bmap_btalloc_filestreams(ap, &args, stripe_align); error = xfs_bmap_btalloc_filestreams(ap, &args, stripe_align);
else else
error = xfs_bmap_btalloc_best_length(ap, &args, stripe_align); error = xfs_bmap_btalloc_best_length(ap, &args, stripe_align);
...@@ -4211,9 +4179,6 @@ xfs_bmapi_allocate( ...@@ -4211,9 +4179,6 @@ xfs_bmapi_allocate(
if ((bma->datatype & XFS_ALLOC_USERDATA) && if ((bma->datatype & XFS_ALLOC_USERDATA) &&
XFS_IS_REALTIME_INODE(bma->ip)) XFS_IS_REALTIME_INODE(bma->ip))
error = xfs_bmap_rtalloc(bma); error = xfs_bmap_rtalloc(bma);
else if (unlikely(XFS_TEST_ERROR(false, mp,
XFS_ERRTAG_BMAP_ALLOC_MINLEN_EXTENT)))
error = xfs_bmap_exact_minlen_extent_alloc(bma);
else else
error = xfs_bmap_btalloc(bma); error = xfs_bmap_btalloc(bma);
if (error) if (error)
......
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