Skip to content

Commit 59d7fab

Browse files
author
Darrick J. Wong
committed
xfs: fix quotaoff mutex usage now that we don't support disabling it
Prior to commit 40b5222 ("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: Darrick J. Wong <[email protected]> Reviewed-by: Dave Chinner <[email protected]>
1 parent 47a6df7 commit 59d7fab

File tree

5 files changed

+6
-17
lines changed

5 files changed

+6
-17
lines changed

fs/xfs/scrub/quota.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,10 @@ xchk_setup_quota(
4848
dqtype = xchk_quota_to_dqtype(sc);
4949
if (dqtype == 0)
5050
return -EINVAL;
51-
sc->flags |= XCHK_HAS_QUOTAOFFLOCK;
52-
mutex_lock(&sc->mp->m_quotainfo->qi_quotaofflock);
51+
5352
if (!xfs_this_quota_on(sc->mp, dqtype))
5453
return -ENOENT;
54+
5555
error = xchk_setup_fs(sc);
5656
if (error)
5757
return error;

fs/xfs/scrub/repair.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
#include "xfs_ag.h"
2626
#include "xfs_ag_resv.h"
2727
#include "xfs_quota.h"
28+
#include "xfs_qm.h"
2829
#include "scrub/scrub.h"
2930
#include "scrub/common.h"
3031
#include "scrub/trace.h"
@@ -912,11 +913,13 @@ xrep_force_quotacheck(
912913
if (!(flag & sc->mp->m_qflags))
913914
return;
914915

916+
mutex_lock(&sc->mp->m_quotainfo->qi_quotaofflock);
915917
sc->mp->m_qflags &= ~flag;
916918
spin_lock(&sc->mp->m_sb_lock);
917919
sc->mp->m_sb.sb_qflags &= ~flag;
918920
spin_unlock(&sc->mp->m_sb_lock);
919921
xfs_log_sb(sc->tp);
922+
mutex_unlock(&sc->mp->m_quotainfo->qi_quotaofflock);
920923
}
921924

922925
/*

fs/xfs/scrub/scrub.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -173,10 +173,6 @@ xchk_teardown(
173173
mnt_drop_write_file(sc->file);
174174
if (sc->flags & XCHK_REAPING_DISABLED)
175175
xchk_start_reaping(sc);
176-
if (sc->flags & XCHK_HAS_QUOTAOFFLOCK) {
177-
mutex_unlock(&sc->mp->m_quotainfo->qi_quotaofflock);
178-
sc->flags &= ~XCHK_HAS_QUOTAOFFLOCK;
179-
}
180176
if (sc->buf) {
181177
kmem_free(sc->buf);
182178
sc->buf = NULL;

fs/xfs/scrub/scrub.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,6 @@ struct xfs_scrub {
8888

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

fs/xfs/xfs_qm_syscalls.c

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -302,13 +302,6 @@ xfs_qm_scall_setqlim(
302302
if ((newlim->d_fieldmask & XFS_QC_MASK) == 0)
303303
return 0;
304304

305-
/*
306-
* We don't want to race with a quotaoff so take the quotaoff lock.
307-
* We don't hold an inode lock, so there's nothing else to stop
308-
* a quotaoff from happening.
309-
*/
310-
mutex_lock(&q->qi_quotaofflock);
311-
312305
/*
313306
* Get the dquot (locked) before we start, as we need to do a
314307
* transaction to allocate it if it doesn't exist. Once we have the
@@ -319,7 +312,7 @@ xfs_qm_scall_setqlim(
319312
error = xfs_qm_dqget(mp, id, type, true, &dqp);
320313
if (error) {
321314
ASSERT(error != -ENOENT);
322-
goto out_unlock;
315+
return error;
323316
}
324317

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

416409
out_rele:
417410
xfs_qm_dqrele(dqp);
418-
out_unlock:
419-
mutex_unlock(&q->qi_quotaofflock);
420411
return error;
421412
}
422413

0 commit comments

Comments
 (0)