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

Commit 1214f1cf authored by Brian Foster's avatar Brian Foster Committed by Darrick J. Wong
Browse files

xfs: replace dop_low with transaction flag



The dop_low field enables the low free space allocation mode when a
previous allocation has detected difficulty allocating blocks. It
has historically been part of the xfs_defer_ops structure, which
means if enabled, it remains enabled across a set of transactions
until the deferred operations have completed and the dfops is reset.

Now that the dfops is embedded in the transaction, we can save a bit
more space by using a transaction flag rather than a standalone
boolean. Drop the ->dop_low field and replace it with a transaction
flag that is set at the same points, carried across rolling
transactions and cleared on completion of deferred operations. This
essentially emulates the behavior of ->dop_low and so should not
change behavior.

Signed-off-by: default avatarBrian Foster <bfoster@redhat.com>
Reviewed-by: default avatarDarrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: default avatarChristoph Hellwig <hch@lst.de>
Signed-off-by: default avatarDarrick J. Wong <darrick.wong@oracle.com>
parent ce356d64
Loading
Loading
Loading
Loading
+4 −4
Original line number Original line Diff line number Diff line
@@ -700,7 +700,7 @@ xfs_bmap_extents_to_btree(
	if (tp->t_firstblock == NULLFSBLOCK) {
	if (tp->t_firstblock == NULLFSBLOCK) {
		args.type = XFS_ALLOCTYPE_START_BNO;
		args.type = XFS_ALLOCTYPE_START_BNO;
		args.fsbno = XFS_INO_TO_FSB(mp, ip->i_ino);
		args.fsbno = XFS_INO_TO_FSB(mp, ip->i_ino);
	} else if (tp->t_dfops->dop_low) {
	} else if (tp->t_flags & XFS_TRANS_LOWMODE) {
		args.type = XFS_ALLOCTYPE_START_BNO;
		args.type = XFS_ALLOCTYPE_START_BNO;
		args.fsbno = tp->t_firstblock;
		args.fsbno = tp->t_firstblock;
	} else {
	} else {
@@ -3449,7 +3449,7 @@ xfs_bmap_btalloc(
			error = xfs_bmap_btalloc_nullfb(ap, &args, &blen);
			error = xfs_bmap_btalloc_nullfb(ap, &args, &blen);
		if (error)
		if (error)
			return error;
			return error;
	} else if (ap->tp->t_dfops->dop_low) {
	} else if (ap->tp->t_flags & XFS_TRANS_LOWMODE) {
		if (xfs_inode_is_filestream(ap->ip))
		if (xfs_inode_is_filestream(ap->ip))
			args.type = XFS_ALLOCTYPE_FIRST_AG;
			args.type = XFS_ALLOCTYPE_FIRST_AG;
		else
		else
@@ -3484,7 +3484,7 @@ xfs_bmap_btalloc(
	 * is >= the stripe unit and the allocation offset is
	 * is >= the stripe unit and the allocation offset is
	 * at the end of file.
	 * at the end of file.
	 */
	 */
	if (!ap->tp->t_dfops->dop_low && ap->aeof) {
	if (!(ap->tp->t_flags & XFS_TRANS_LOWMODE) && ap->aeof) {
		if (!ap->offset) {
		if (!ap->offset) {
			args.alignment = stripe_align;
			args.alignment = stripe_align;
			atype = args.type;
			atype = args.type;
@@ -3576,7 +3576,7 @@ xfs_bmap_btalloc(
		args.total = ap->minlen;
		args.total = ap->minlen;
		if ((error = xfs_alloc_vextent(&args)))
		if ((error = xfs_alloc_vextent(&args)))
			return error;
			return error;
		ap->tp->t_dfops->dop_low = true;
		ap->tp->t_flags |= XFS_TRANS_LOWMODE;
	}
	}
	if (args.fsbno != NULLFSBLOCK) {
	if (args.fsbno != NULLFSBLOCK) {
		/*
		/*
+2 −2
Original line number Original line Diff line number Diff line
@@ -226,7 +226,7 @@ xfs_bmbt_alloc_block(
		 * block allocation here and corrupt the filesystem.
		 * block allocation here and corrupt the filesystem.
		 */
		 */
		args.minleft = args.tp->t_blk_res;
		args.minleft = args.tp->t_blk_res;
	} else if (cur->bc_tp->t_dfops->dop_low) {
	} else if (cur->bc_tp->t_flags & XFS_TRANS_LOWMODE) {
		args.type = XFS_ALLOCTYPE_START_BNO;
		args.type = XFS_ALLOCTYPE_START_BNO;
	} else {
	} else {
		args.type = XFS_ALLOCTYPE_NEAR_BNO;
		args.type = XFS_ALLOCTYPE_NEAR_BNO;
@@ -253,7 +253,7 @@ xfs_bmbt_alloc_block(
		error = xfs_alloc_vextent(&args);
		error = xfs_alloc_vextent(&args);
		if (error)
		if (error)
			goto error0;
			goto error0;
		cur->bc_tp->t_dfops->dop_low = true;
		cur->bc_tp->t_flags |= XFS_TRANS_LOWMODE;
	}
	}
	if (WARN_ON_ONCE(args.fsbno == NULLFSBLOCK)) {
	if (WARN_ON_ONCE(args.fsbno == NULLFSBLOCK)) {
		*stat = 0;
		*stat = 0;
+14 −2
Original line number Original line Diff line number Diff line
@@ -330,9 +330,14 @@ xfs_defer_reset(


	ASSERT(!xfs_defer_has_unfinished_work(dop));
	ASSERT(!xfs_defer_has_unfinished_work(dop));


	dop->dop_low = false;
	memset(dop->dop_inodes, 0, sizeof(dop->dop_inodes));
	memset(dop->dop_inodes, 0, sizeof(dop->dop_inodes));
	memset(dop->dop_bufs, 0, sizeof(dop->dop_bufs));
	memset(dop->dop_bufs, 0, sizeof(dop->dop_bufs));

	/*
	 * Low mode state transfers across transaction rolls to mirror dfops
	 * lifetime. Clear it now that dfops is reset.
	 */
	tp->t_flags &= ~XFS_TRANS_LOWMODE;
}
}


/*
/*
@@ -590,7 +595,14 @@ xfs_defer_move(


	memcpy(dst->dop_inodes, src->dop_inodes, sizeof(dst->dop_inodes));
	memcpy(dst->dop_inodes, src->dop_inodes, sizeof(dst->dop_inodes));
	memcpy(dst->dop_bufs, src->dop_bufs, sizeof(dst->dop_bufs));
	memcpy(dst->dop_bufs, src->dop_bufs, sizeof(dst->dop_bufs));
	dst->dop_low = src->dop_low;

	/*
	 * Low free space mode was historically controlled by a dfops field.
	 * This meant that low mode state potentially carried across multiple
	 * transaction rolls. Transfer low mode on a dfops move to preserve
	 * that behavior.
	 */
	dtp->t_flags |= (stp->t_flags & XFS_TRANS_LOWMODE);


	xfs_defer_reset(stp);
	xfs_defer_reset(stp);
}
}
+0 −11
Original line number Original line Diff line number Diff line
@@ -25,17 +25,6 @@ struct xfs_defer_pending {


/*
/*
 * Header for deferred operation list.
 * Header for deferred operation list.
 *
 * dop_low is used by the allocator to activate the lowspace algorithm -
 * when free space is running low the extent allocator may choose to
 * allocate an extent from an AG without leaving sufficient space for
 * a btree split when inserting the new extent.  In this case the allocator
 * will enable the lowspace algorithm which is supposed to allow further
 * allocations (such as btree splits and newroots) to allocate from
 * sequential AGs.  In order to avoid locking AGs out of order the lowspace
 * algorithm will start searching for free space from AG 0.  If the correct
 * transaction reservations have been made then this algorithm will eventually
 * find all the space it needs.
 */
 */
enum xfs_defer_ops_type {
enum xfs_defer_ops_type {
	XFS_DEFER_OPS_TYPE_BMAP,
	XFS_DEFER_OPS_TYPE_BMAP,
+12 −0
Original line number Original line Diff line number Diff line
@@ -64,6 +64,18 @@ void xfs_log_get_max_trans_res(struct xfs_mount *mp,
#define XFS_TRANS_RESERVE	0x20    /* OK to use reserved data blocks */
#define XFS_TRANS_RESERVE	0x20    /* OK to use reserved data blocks */
#define XFS_TRANS_NO_WRITECOUNT 0x40	/* do not elevate SB writecount */
#define XFS_TRANS_NO_WRITECOUNT 0x40	/* do not elevate SB writecount */
#define XFS_TRANS_NOFS		0x80	/* pass KM_NOFS to kmem_alloc */
#define XFS_TRANS_NOFS		0x80	/* pass KM_NOFS to kmem_alloc */
/*
 * LOWMODE is used by the allocator to activate the lowspace algorithm - when
 * free space is running low the extent allocator may choose to allocate an
 * extent from an AG without leaving sufficient space for a btree split when
 * inserting the new extent. In this case the allocator will enable the
 * lowspace algorithm which is supposed to allow further allocations (such as
 * btree splits and newroots) to allocate from sequential AGs. In order to
 * avoid locking AGs out of order the lowspace algorithm will start searching
 * for free space from AG 0. If the correct transaction reservations have been
 * made then this algorithm will eventually find all the space it needs.
 */
#define XFS_TRANS_LOWMODE	0x100	/* allocate in low space mode */


/*
/*
 * Field values for xfs_trans_mod_sb.
 * Field values for xfs_trans_mod_sb.
Loading