Commit 2a9b99d4 authored by Christoph Hellwig's avatar Christoph Hellwig Committed by Chandan Babu R

xfs: pass the actual offset and len to allocate to xfs_bmapi_allocate

xfs_bmapi_allocate currently overwrites offset and len when converting
delayed allocations, and duplicates the length cap done for non-delalloc
allocations.  Move all that logic into the callers to avoid duplication
and to make the calling conventions more obvious.
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 9d069603
......@@ -4185,21 +4185,11 @@ xfs_bmapi_allocate(
int error;
ASSERT(bma->length > 0);
ASSERT(bma->length <= XFS_MAX_BMBT_EXTLEN);
/*
* For the wasdelay case, we could also just allocate the stuff asked
* for in this bmap call but that wouldn't be as good.
*/
if (bma->wasdel) {
bma->length = (xfs_extlen_t)bma->got.br_blockcount;
bma->offset = bma->got.br_startoff;
if (!xfs_iext_peek_prev_extent(ifp, &bma->icur, &bma->prev))
bma->prev.br_startoff = NULLFILEOFF;
} else {
bma->length = XFS_FILBLKS_MIN(bma->length, XFS_MAX_BMBT_EXTLEN);
if (!bma->eof)
bma->length = XFS_FILBLKS_MIN(bma->length,
bma->got.br_startoff - bma->offset);
}
if (bma->flags & XFS_BMAPI_CONTIG)
......@@ -4533,6 +4523,15 @@ xfs_bmapi_write(
*/
bma.length = XFS_FILBLKS_MIN(len, XFS_MAX_BMBT_EXTLEN);
if (wasdelay) {
bma.offset = bma.got.br_startoff;
bma.length = bma.got.br_blockcount;
} else {
if (!eof)
bma.length = XFS_FILBLKS_MIN(bma.length,
bma.got.br_startoff - bno);
}
ASSERT(bma.length > 0);
error = xfs_bmapi_allocate(&bma);
if (error) {
......@@ -4686,11 +4685,16 @@ xfs_bmapi_convert_one_delalloc(
bma.tp = tp;
bma.ip = ip;
bma.wasdel = true;
bma.offset = bma.got.br_startoff;
bma.length = max_t(xfs_filblks_t, bma.got.br_blockcount,
XFS_MAX_BMBT_EXTLEN);
bma.minleft = xfs_bmapi_minleft(tp, ip, whichfork);
/*
* Always allocate convert from the start of the delalloc extent even if
* that is outside the passed in range to create large contiguous
* extents on disk.
*/
bma.offset = bma.got.br_startoff;
bma.length = bma.got.br_blockcount;
/*
* When we're converting the delalloc reservations backing dirty pages
* in the page cache, we must be careful about how we create the new
......
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