Commit 784e80f5 authored by Darrick J. Wong's avatar Darrick J. Wong
Browse files

xfs: use a per-resource struct for incore dquot data



Introduce a new struct xfs_dquot_res that we'll use to track all the
incore data for a particular resource type (block, inode, rt block).
This will help us (once we've eliminated q_core) to declutter quota
functions that currently open-code field access or pass around fields
around explicitly.

Signed-off-by: default avatarDarrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: default avatarChandan Babu R <chandanrlinux@gmail.com>
Reviewed-by: default avatarChristoph Hellwig <hch@lst.de>
Reviewed-by: default avatarAllison Collins <allison.henderson@oracle.com>
parent c51df733
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -552,9 +552,9 @@ xfs_dquot_from_disk(
	 * Reservation counters are defined as reservation plus current usage
	 * to avoid having to add every time.
	 */
	dqp->q_res_bcount = be64_to_cpu(ddqp->d_bcount);
	dqp->q_res_icount = be64_to_cpu(ddqp->d_icount);
	dqp->q_res_rtbcount = be64_to_cpu(ddqp->d_rtbcount);
	dqp->q_blk.reserved = be64_to_cpu(ddqp->d_bcount);
	dqp->q_ino.reserved = be64_to_cpu(ddqp->d_icount);
	dqp->q_rtb.reserved = be64_to_cpu(ddqp->d_rtbcount);

	/* initialize the dquot speculative prealloc thresholds */
	xfs_dquot_set_prealloc_limits(dqp);
+11 −7
Original line number Diff line number Diff line
@@ -27,6 +27,11 @@ enum {
	XFS_QLOWSP_MAX
};

struct xfs_dquot_res {
	/* Total resources allocated and reserved. */
	xfs_qcnt_t		reserved;
};

/*
 * The incore dquot structure
 */
@@ -41,14 +46,13 @@ struct xfs_dquot {
	xfs_daddr_t		q_blkno;
	xfs_fileoff_t		q_fileoffset;

	struct xfs_dquot_res	q_blk;	/* regular blocks */
	struct xfs_dquot_res	q_ino;	/* inodes */
	struct xfs_dquot_res	q_rtb;	/* realtime blocks */

	struct xfs_disk_dquot	q_core;
	struct xfs_dq_logitem	q_logitem;
	/* total regular nblks used+reserved */
	xfs_qcnt_t		q_res_bcount;
	/* total inos allocd+reserved */
	xfs_qcnt_t		q_res_icount;
	/* total realtime blks used+reserved */
	xfs_qcnt_t		q_res_rtbcount;

	xfs_qcnt_t		q_prealloc_lo_wmark;
	xfs_qcnt_t		q_prealloc_hi_wmark;
	int64_t			q_low_space[XFS_QLOWSP_MAX];
@@ -139,7 +143,7 @@ static inline bool xfs_dquot_lowsp(struct xfs_dquot *dqp)
{
	int64_t freesp;

	freesp = be64_to_cpu(dqp->q_core.d_blk_hardlimit) - dqp->q_res_bcount;
	freesp = be64_to_cpu(dqp->q_core.d_blk_hardlimit) - dqp->q_blk.reserved;
	if (freesp < dqp->q_low_space[XFS_QLOWSP_1_PCNT])
		return true;

+3 −3
Original line number Diff line number Diff line
@@ -307,7 +307,7 @@ xfs_quota_need_throttle(
		return false;

	/* under the lo watermark, no throttle */
	if (dq->q_res_bcount + alloc_blocks < dq->q_prealloc_lo_wmark)
	if (dq->q_blk.reserved + alloc_blocks < dq->q_prealloc_lo_wmark)
		return false;

	return true;
@@ -326,13 +326,13 @@ xfs_quota_calc_throttle(
	struct xfs_dquot *dq = xfs_inode_dquot(ip, type);

	/* no dq, or over hi wmark, squash the prealloc completely */
	if (!dq || dq->q_res_bcount >= dq->q_prealloc_hi_wmark) {
	if (!dq || dq->q_blk.reserved >= dq->q_prealloc_hi_wmark) {
		*qblocks = 0;
		*qfreesp = 0;
		return;
	}

	freesp = dq->q_prealloc_hi_wmark - dq->q_res_bcount;
	freesp = dq->q_prealloc_hi_wmark - dq->q_blk.reserved;
	if (freesp < dq->q_low_space[XFS_QLOWSP_5_PCNT]) {
		shift = 2;
		if (freesp < dq->q_low_space[XFS_QLOWSP_3_PCNT])
+3 −3
Original line number Diff line number Diff line
@@ -1092,14 +1092,14 @@ xfs_qm_quotacheck_dqadjust(
	 * resource usage.
	 */
	be64_add_cpu(&dqp->q_core.d_icount, 1);
	dqp->q_res_icount++;
	dqp->q_ino.reserved++;
	if (nblks) {
		be64_add_cpu(&dqp->q_core.d_bcount, nblks);
		dqp->q_res_bcount += nblks;
		dqp->q_blk.reserved += nblks;
	}
	if (rtblks) {
		be64_add_cpu(&dqp->q_core.d_rtbcount, rtblks);
		dqp->q_res_rtbcount += rtblks;
		dqp->q_rtb.reserved += rtblks;
	}

	/*
+4 −4
Original line number Diff line number Diff line
@@ -29,8 +29,8 @@ xfs_fill_statvfs_from_dquot(
	if (limit && statp->f_blocks > limit) {
		statp->f_blocks = limit;
		statp->f_bfree = statp->f_bavail =
			(statp->f_blocks > dqp->q_res_bcount) ?
			 (statp->f_blocks - dqp->q_res_bcount) : 0;
			(statp->f_blocks > dqp->q_blk.reserved) ?
			 (statp->f_blocks - dqp->q_blk.reserved) : 0;
	}

	limit = dqp->q_core.d_ino_softlimit ?
@@ -39,8 +39,8 @@ xfs_fill_statvfs_from_dquot(
	if (limit && statp->f_files > limit) {
		statp->f_files = limit;
		statp->f_ffree =
			(statp->f_files > dqp->q_res_icount) ?
			 (statp->f_files - dqp->q_res_icount) : 0;
			(statp->f_files > dqp->q_ino.reserved) ?
			 (statp->f_files - dqp->q_ino.reserved) : 0;
	}
}

Loading