xfs: merge xfs_buf_allocate_memory

It only has one caller and is now a simple function, so merge it
into the caller.

Signed-off-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
This commit is contained in:
Dave Chinner 2021-06-07 11:50:48 +10:00 committed by Dave Chinner
parent 170041f715
commit 8bcac7448a

View File

@ -313,11 +313,11 @@ xfs_buf_free(
static int
xfs_buf_alloc_kmem(
struct xfs_buf *bp,
size_t size,
xfs_buf_flags_t flags)
{
int align_mask = xfs_buftarg_dma_alignment(bp->b_target);
xfs_km_flags_t kmflag_mask = KM_NOFS;
size_t size = BBTOB(bp->b_length);
/* Assure zeroed buffer for non-read cases. */
if (!(flags & XBF_READ))
@ -400,33 +400,6 @@ xfs_buf_alloc_pages(
return 0;
}
/*
* Allocates all the pages for buffer in question and builds it's page list.
*/
static int
xfs_buf_allocate_memory(
struct xfs_buf *bp,
uint flags)
{
size_t size;
int error;
/*
* For buffers that fit entirely within a single page, first attempt to
* allocate the memory from the heap to minimise memory usage. If we
* can't get heap memory for these small buffers, we fall back to using
* the page allocator.
*/
size = BBTOB(bp->b_length);
if (size < PAGE_SIZE) {
error = xfs_buf_alloc_kmem(bp, size, flags);
if (!error)
return 0;
}
return xfs_buf_alloc_pages(bp, flags);
}
/*
* Map buffer into kernel address-space if necessary.
*/
@ -688,9 +661,18 @@ xfs_buf_get_map(
if (error)
return error;
error = xfs_buf_allocate_memory(new_bp, flags);
if (error)
goto out_free_buf;
/*
* For buffers that fit entirely within a single page, first attempt to
* allocate the memory from the heap to minimise memory usage. If we
* can't get heap memory for these small buffers, we fall back to using
* the page allocator.
*/
if (BBTOB(new_bp->b_length) >= PAGE_SIZE ||
xfs_buf_alloc_kmem(new_bp, flags) < 0) {
error = xfs_buf_alloc_pages(new_bp, flags);
if (error)
goto out_free_buf;
}
error = xfs_buf_find(target, map, nmaps, flags, new_bp, &bp);
if (error)