Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 963c30cf authored by Dave Chinner's avatar Dave Chinner Committed by Alex Elder
Browse files

xfs: do not keep local copies of allocation ranges in xfs_bmapi_allocate



Signed-off-by: default avatarDave Chinner <dchinner@redhat.com>
Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
Signed-off-by: default avatarAlex Elder <aelder@sgi.com>
parent 3a75667e
Loading
Loading
Loading
Loading
+14 −29
Original line number Original line Diff line number Diff line
@@ -4617,9 +4617,6 @@ xfs_bmapi_allocate(
	int			whichfork = (flags & XFS_BMAPI_ATTRFORK) ?
	int			whichfork = (flags & XFS_BMAPI_ATTRFORK) ?
						XFS_ATTR_FORK : XFS_DATA_FORK;
						XFS_ATTR_FORK : XFS_DATA_FORK;
	struct xfs_ifork	*ifp = XFS_IFORK_PTR(bma->ip, whichfork);
	struct xfs_ifork	*ifp = XFS_IFORK_PTR(bma->ip, whichfork);
	xfs_fsblock_t		abno;
	xfs_extlen_t		alen;
	xfs_fileoff_t		aoff;
	int			error;
	int			error;
	int			rt;
	int			rt;


@@ -4630,18 +4627,17 @@ xfs_bmapi_allocate(
	 * for in this bmap call but that wouldn't be as good.
	 * for in this bmap call but that wouldn't be as good.
	 */
	 */
	if (bma->wasdel) {
	if (bma->wasdel) {
		alen = (xfs_extlen_t)bma->got.br_blockcount;
		bma->length = (xfs_extlen_t)bma->got.br_blockcount;
		aoff = bma->got.br_startoff;
		bma->offset = bma->got.br_startoff;
		if (*lastx != NULLEXTNUM && *lastx) {
		if (*lastx != NULLEXTNUM && *lastx) {
			xfs_bmbt_get_all(xfs_iext_get_ext(ifp, *lastx - 1),
			xfs_bmbt_get_all(xfs_iext_get_ext(ifp, *lastx - 1),
					 &bma->prev);
					 &bma->prev);
		}
		}
	} else {
	} else {
		alen = (xfs_extlen_t)XFS_FILBLKS_MIN(bma->length, MAXEXTLEN);
		bma->length = XFS_FILBLKS_MIN(bma->length, MAXEXTLEN);
		if (!bma->eof)
		if (!bma->eof)
			alen = (xfs_extlen_t)XFS_FILBLKS_MIN(alen,
			bma->length = XFS_FILBLKS_MIN(bma->length,
					bma->got.br_startoff - bma->offset);
					bma->got.br_startoff - bma->offset);
		aoff = bma->offset;
	}
	}


	/*
	/*
@@ -4649,23 +4645,17 @@ xfs_bmapi_allocate(
	 * user data.
	 * user data.
	 */
	 */
	if (!(flags & XFS_BMAPI_METADATA)) {
	if (!(flags & XFS_BMAPI_METADATA)) {
		bma->userdata = (aoff == 0) ?
		bma->userdata = (bma->offset == 0) ?
			XFS_ALLOC_INITIAL_USER_DATA : XFS_ALLOC_USERDATA;
			XFS_ALLOC_INITIAL_USER_DATA : XFS_ALLOC_USERDATA;
	}
	}


	/*
	bma->minlen = (flags & XFS_BMAPI_CONTIG) ? bma->length : 1;
	 * Fill in changeable bma fields.
	 */
	bma->length = alen;
	bma->offset = aoff;
	bma->minlen = (flags & XFS_BMAPI_CONTIG) ? alen : 1;
	bma->aeof = 0;


	/*
	/*
	 * Only want to do the alignment at the eof if it is userdata and
	 * Only want to do the alignment at the eof if it is userdata and
	 * allocation length is larger than a stripe unit.
	 * allocation length is larger than a stripe unit.
	 */
	 */
	if (mp->m_dalign && alen >= mp->m_dalign &&
	if (mp->m_dalign && bma->length >= mp->m_dalign &&
	    !(flags & XFS_BMAPI_METADATA) && whichfork == XFS_DATA_FORK) {
	    !(flags & XFS_BMAPI_METADATA) && whichfork == XFS_DATA_FORK) {
		error = xfs_bmap_isaeof(bma, whichfork);
		error = xfs_bmap_isaeof(bma, whichfork);
		if (error)
		if (error)
@@ -4676,17 +4666,11 @@ xfs_bmapi_allocate(
	if (error)
	if (error)
		return error;
		return error;


	/*
	 * Copy out result fields.
	 */
	abno = bma->blkno;
	alen = bma->length;
	aoff = bma->offset;
	if (bma->flist->xbf_low)
	if (bma->flist->xbf_low)
		bma->minleft = 0;
		bma->minleft = 0;
	if (*cur)
	if (*cur)
		(*cur)->bc_private.b.firstblock = *bma->firstblock;
		(*cur)->bc_private.b.firstblock = *bma->firstblock;
	if (abno == NULLFSBLOCK)
	if (bma->blkno == NULLFSBLOCK)
		return 0;
		return 0;
	if ((ifp->if_flags & XFS_IFBROOT) && !*cur) {
	if ((ifp->if_flags & XFS_IFBROOT) && !*cur) {
		(*cur) = xfs_bmbt_init_cursor(mp, bma->tp, bma->ip, whichfork);
		(*cur) = xfs_bmbt_init_cursor(mp, bma->tp, bma->ip, whichfork);
@@ -4703,9 +4687,9 @@ xfs_bmapi_allocate(
		(*cur)->bc_private.b.flags =
		(*cur)->bc_private.b.flags =
			bma->wasdel ? XFS_BTCUR_BPRV_WASDEL : 0;
			bma->wasdel ? XFS_BTCUR_BPRV_WASDEL : 0;


	bma->got.br_startoff = aoff;
	bma->got.br_startoff = bma->offset;
	bma->got.br_startblock = abno;
	bma->got.br_startblock = bma->blkno;
	bma->got.br_blockcount = alen;
	bma->got.br_blockcount = bma->length;
	bma->got.br_state = XFS_EXT_NORM;
	bma->got.br_state = XFS_EXT_NORM;


	/*
	/*
@@ -4736,8 +4720,9 @@ xfs_bmapi_allocate(
	 */
	 */
	xfs_bmbt_get_all(xfs_iext_get_ext(ifp, *lastx), &bma->got);
	xfs_bmbt_get_all(xfs_iext_get_ext(ifp, *lastx), &bma->got);


	ASSERT(bma->got.br_startoff <= aoff);
	ASSERT(bma->got.br_startoff <= bma->offset);
	ASSERT(bma->got.br_startoff + bma->got.br_blockcount >= aoff + alen);
	ASSERT(bma->got.br_startoff + bma->got.br_blockcount >=
	       bma->offset + bma->length);
	ASSERT(bma->got.br_state == XFS_EXT_NORM ||
	ASSERT(bma->got.br_state == XFS_EXT_NORM ||
	       bma->got.br_state == XFS_EXT_UNWRITTEN);
	       bma->got.br_state == XFS_EXT_UNWRITTEN);
	return 0;
	return 0;