Commit 7099bd0f authored by Christoph Hellwig's avatar Christoph Hellwig Committed by Chandan Babu R
Browse files

xfs: support RT inodes in xfs_mod_delalloc



To prepare for re-enabling delalloc on RT devices, track the data blocks
(which use the RT device when the inode sits on it) and the indirect
blocks (which don't) separately to xfs_mod_delalloc, and add a new
percpu counter to also track the RT delalloc blocks.

Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
Reviewed-by: default avatarDave Chinner <dchinner@redhat.com>
Reviewed-by: default avatar"Darrick J. Wong" <djwong@kernel.org>
Signed-off-by: default avatarChandan Babu R <chandanbabu@kernel.org>
parent 7e77d57a
Loading
Loading
Loading
Loading
+6 −6
Original line number Diff line number Diff line
@@ -1977,7 +1977,7 @@ xfs_bmap_add_extent_delay_real(
	}

	if (da_new != da_old)
		xfs_mod_delalloc(mp, (int64_t)da_new - da_old);
		xfs_mod_delalloc(bma->ip, 0, (int64_t)da_new - da_old);

	if (bma->cur) {
		da_new += bma->cur->bc_bmap.allocated;
@@ -2696,7 +2696,7 @@ xfs_bmap_add_extent_hole_delay(
		/*
		 * Nothing to do for disk quota accounting here.
		 */
		xfs_mod_delalloc(ip->i_mount, (int64_t)newlen - oldlen);
		xfs_mod_delalloc(ip, 0, (int64_t)newlen - oldlen);
	}
}

@@ -3373,7 +3373,7 @@ xfs_bmap_alloc_account(
		 * yet.
		 */
		if (ap->wasdel) {
			xfs_mod_delalloc(ap->ip->i_mount, -(int64_t)ap->length);
			xfs_mod_delalloc(ap->ip, -(int64_t)ap->length, 0);
			return;
		}

@@ -3397,7 +3397,7 @@ xfs_bmap_alloc_account(
	xfs_trans_log_inode(ap->tp, ap->ip, XFS_ILOG_CORE);
	if (ap->wasdel) {
		ap->ip->i_delayed_blks -= ap->length;
		xfs_mod_delalloc(ap->ip->i_mount, -(int64_t)ap->length);
		xfs_mod_delalloc(ap->ip, -(int64_t)ap->length, 0);
		fld = isrt ? XFS_TRANS_DQ_DELRTBCOUNT : XFS_TRANS_DQ_DELBCOUNT;
	} else {
		fld = isrt ? XFS_TRANS_DQ_RTBCOUNT : XFS_TRANS_DQ_BCOUNT;
@@ -4126,7 +4126,7 @@ xfs_bmapi_reserve_delalloc(
		goto out_unreserve_frextents;

	ip->i_delayed_blks += alen;
	xfs_mod_delalloc(ip->i_mount, alen + indlen);
	xfs_mod_delalloc(ip, alen, indlen);

	got->br_startoff = aoff;
	got->br_startblock = nullstartblock(indlen);
@@ -5024,7 +5024,7 @@ xfs_bmap_del_extent_delay(
		fdblocks += del->br_blockcount;

	xfs_add_fdblocks(mp, fdblocks);
	xfs_mod_delalloc(mp, -(int64_t)fdblocks);
	xfs_mod_delalloc(ip, -(int64_t)del->br_blockcount, -da_diff);
	return error;
}

+5 −1
Original line number Diff line number Diff line
@@ -412,6 +412,7 @@ xchk_fscount_count_frextents(
	int			error;

	fsc->frextents = 0;
	fsc->frextents_delayed = 0;
	if (!xfs_has_realtime(mp))
		return 0;

@@ -423,6 +424,8 @@ xchk_fscount_count_frextents(
		goto out_unlock;
	}

	fsc->frextents_delayed = percpu_counter_sum(&mp->m_delalloc_rtextents);

out_unlock:
	xfs_rtbitmap_unlock_shared(sc->mp, XFS_RBMLOCK_BITMAP);
	return error;
@@ -434,6 +437,7 @@ xchk_fscount_count_frextents(
	struct xchk_fscounters	*fsc)
{
	fsc->frextents = 0;
	fsc->frextents_delayed = 0;
	return 0;
}
#endif /* CONFIG_XFS_RT */
@@ -593,7 +597,7 @@ xchk_fscounters(
	}

	if (!xchk_fscount_within_range(sc, frextents, &mp->m_frextents,
			fsc->frextents)) {
			fsc->frextents - fsc->frextents_delayed)) {
		if (fsc->frozen)
			xchk_set_corrupt(sc);
		else
+1 −0
Original line number Diff line number Diff line
@@ -12,6 +12,7 @@ struct xchk_fscounters {
	uint64_t		ifree;
	uint64_t		fdblocks;
	uint64_t		frextents;
	uint64_t		frextents_delayed;
	unsigned long long	icount_min;
	unsigned long long	icount_max;
	bool			frozen;
+11 −1
Original line number Diff line number Diff line
@@ -65,7 +65,17 @@ xrep_fscounters(
	percpu_counter_set(&mp->m_icount, fsc->icount);
	percpu_counter_set(&mp->m_ifree, fsc->ifree);
	percpu_counter_set(&mp->m_fdblocks, fsc->fdblocks);
	percpu_counter_set(&mp->m_frextents, fsc->frextents);

	/*
	 * Online repair is only supported on v5 file systems, which require
	 * lazy sb counters and thus no update of sb_fdblocks here.  But as of
	 * now we don't support lazy counting sb_frextents yet, and thus need
	 * to also update it directly here.  And for that we need to keep
	 * track of the delalloc reservations separately, as they are are
	 * subtracted from m_frextents, but not included in sb_frextents.
	 */
	percpu_counter_set(&mp->m_frextents,
		fsc->frextents - fsc->frextents_delayed);
	mp->m_sb.sb_frextents = fsc->frextents;

	return 0;
+15 −3
Original line number Diff line number Diff line
@@ -34,6 +34,7 @@
#include "xfs_health.h"
#include "xfs_trace.h"
#include "xfs_ag.h"
#include "xfs_rtbitmap.h"
#include "scrub/stats.h"

static DEFINE_MUTEX(xfs_uuid_table_mutex);
@@ -1408,9 +1409,20 @@ xfs_clear_incompat_log_features(
#define XFS_DELALLOC_BATCH	(4096)
void
xfs_mod_delalloc(
	struct xfs_mount	*mp,
	int64_t			delta)
	struct xfs_inode	*ip,
	int64_t			data_delta,
	int64_t			ind_delta)
{
	percpu_counter_add_batch(&mp->m_delalloc_blks, delta,
	struct xfs_mount	*mp = ip->i_mount;

	if (XFS_IS_REALTIME_INODE(ip)) {
		percpu_counter_add_batch(&mp->m_delalloc_rtextents,
				xfs_rtb_to_rtx(mp, data_delta),
				XFS_DELALLOC_BATCH);
		if (!ind_delta)
			return;
		data_delta = 0;
	}
	percpu_counter_add_batch(&mp->m_delalloc_blks, data_delta + ind_delta,
			XFS_DELALLOC_BATCH);
}
Loading