Commit 59d7fab2 authored by Darrick J. Wong's avatar Darrick J. Wong
Browse files

xfs: fix quotaoff mutex usage now that we don't support disabling it



Prior to commit 40b52225 ("xfs: remove support for disabling quota
accounting on a mounted file system"), we used the quotaoff mutex to
protect dquot operations against quotaoff trying to pull down dquots as
part of disabling quota.

Now that we only support turning off quota enforcement, the quotaoff
mutex only protects changes in m_qflags/sb_qflags.  We don't need it to
protect dquots, which means we can remove it from setqlimits and the
dquot scrub code.  While we're at it, fix the function that forces
quotacheck, since it should have been taking the quotaoff mutex.

Signed-off-by: default avatarDarrick J. Wong <djwong@kernel.org>
Reviewed-by: default avatarDave Chinner <dchinner@redhat.com>
parent 47a6df7c
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -48,10 +48,10 @@ xchk_setup_quota(
	dqtype = xchk_quota_to_dqtype(sc);
	if (dqtype == 0)
		return -EINVAL;
	sc->flags |= XCHK_HAS_QUOTAOFFLOCK;
	mutex_lock(&sc->mp->m_quotainfo->qi_quotaofflock);

	if (!xfs_this_quota_on(sc->mp, dqtype))
		return -ENOENT;

	error = xchk_setup_fs(sc);
	if (error)
		return error;
+3 −0
Original line number Diff line number Diff line
@@ -25,6 +25,7 @@
#include "xfs_ag.h"
#include "xfs_ag_resv.h"
#include "xfs_quota.h"
#include "xfs_qm.h"
#include "scrub/scrub.h"
#include "scrub/common.h"
#include "scrub/trace.h"
@@ -912,11 +913,13 @@ xrep_force_quotacheck(
	if (!(flag & sc->mp->m_qflags))
		return;

	mutex_lock(&sc->mp->m_quotainfo->qi_quotaofflock);
	sc->mp->m_qflags &= ~flag;
	spin_lock(&sc->mp->m_sb_lock);
	sc->mp->m_sb.sb_qflags &= ~flag;
	spin_unlock(&sc->mp->m_sb_lock);
	xfs_log_sb(sc->tp);
	mutex_unlock(&sc->mp->m_quotainfo->qi_quotaofflock);
}

/*
+0 −4
Original line number Diff line number Diff line
@@ -173,10 +173,6 @@ xchk_teardown(
		mnt_drop_write_file(sc->file);
	if (sc->flags & XCHK_REAPING_DISABLED)
		xchk_start_reaping(sc);
	if (sc->flags & XCHK_HAS_QUOTAOFFLOCK) {
		mutex_unlock(&sc->mp->m_quotainfo->qi_quotaofflock);
		sc->flags &= ~XCHK_HAS_QUOTAOFFLOCK;
	}
	if (sc->buf) {
		kmem_free(sc->buf);
		sc->buf = NULL;
+0 −1
Original line number Diff line number Diff line
@@ -88,7 +88,6 @@ struct xfs_scrub {

/* XCHK state flags grow up from zero, XREP state flags grown down from 2^31 */
#define XCHK_TRY_HARDER		(1 << 0)  /* can't get resources, try again */
#define XCHK_HAS_QUOTAOFFLOCK	(1 << 1)  /* we hold the quotaoff lock */
#define XCHK_REAPING_DISABLED	(1 << 2)  /* background block reaping paused */
#define XREP_ALREADY_FIXED	(1 << 31) /* checking our repair work */

+1 −10
Original line number Diff line number Diff line
@@ -302,13 +302,6 @@ xfs_qm_scall_setqlim(
	if ((newlim->d_fieldmask & XFS_QC_MASK) == 0)
		return 0;

	/*
	 * We don't want to race with a quotaoff so take the quotaoff lock.
	 * We don't hold an inode lock, so there's nothing else to stop
	 * a quotaoff from happening.
	 */
	mutex_lock(&q->qi_quotaofflock);

	/*
	 * Get the dquot (locked) before we start, as we need to do a
	 * transaction to allocate it if it doesn't exist. Once we have the
@@ -319,7 +312,7 @@ xfs_qm_scall_setqlim(
	error = xfs_qm_dqget(mp, id, type, true, &dqp);
	if (error) {
		ASSERT(error != -ENOENT);
		goto out_unlock;
		return error;
	}

	defq = xfs_get_defquota(q, xfs_dquot_type(dqp));
@@ -415,8 +408,6 @@ xfs_qm_scall_setqlim(

out_rele:
	xfs_qm_dqrele(dqp);
out_unlock:
	mutex_unlock(&q->qi_quotaofflock);
	return error;
}