Skip to content

Commit b84a3a9

Browse files
Christoph HellwigBen Myers
authored andcommitted
xfs: remove the per-filesystem list of dquots
Instead of keeping a separate per-filesystem list of dquots we can walk the radix tree for the two places where we need to iterate all quota structures. Reviewed-by: Dave Chinner <dchinner@redhat.com> Signed-off-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Ben Myers <bpm@sgi.com>
1 parent 9f920f1 commit b84a3a9

5 files changed

Lines changed: 226 additions & 304 deletions

File tree

‎fs/xfs/xfs_dquot.c‎

Lines changed: 3 additions & 92 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,9 @@
4444
*
4545
* ip->i_lock
4646
* qi->qi_tree_lock
47-
* qi->qi_dqlist_lock
48-
* dquot->q_qlock (xfs_dqlock() and friends)
49-
* dquot->q_flush (xfs_dqflock() and friends)
50-
* qi->qi_lru_lock
47+
* dquot->q_qlock (xfs_dqlock() and friends)
48+
* dquot->q_flush (xfs_dqflock() and friends)
49+
* qi->qi_lru_lock
5150
*
5251
* If two dquots need to be locked the order is user before group/project,
5352
* otherwise by the lowest id first, see xfs_dqlock2.
@@ -728,21 +727,13 @@ xfs_qm_dqget(
728727
goto restart;
729728
}
730729

731-
/*
732-
* Attach this dquot to this filesystem's list of all dquots,
733-
* kept inside the mount structure in m_quotainfo field
734-
*/
735-
mutex_lock(&qi->qi_dqlist_lock);
736-
737730
/*
738731
* We return a locked dquot to the caller, with a reference taken
739732
*/
740733
xfs_dqlock(dqp);
741734
dqp->q_nrefs = 1;
742735

743-
list_add(&dqp->q_mplist, &qi->qi_dqlist);
744736
qi->qi_dquots++;
745-
mutex_unlock(&qi->qi_dqlist_lock);
746737
mutex_unlock(&qi->qi_tree_lock);
747738

748739
dqret:
@@ -1017,86 +1008,6 @@ xfs_dqlock2(
10171008
}
10181009
}
10191010

1020-
/*
1021-
* Take a dquot out of the mount's dqlist as well as the hashlist. This is
1022-
* called via unmount as well as quotaoff, and the purge will always succeed.
1023-
*/
1024-
void
1025-
xfs_qm_dqpurge(
1026-
struct xfs_dquot *dqp)
1027-
{
1028-
struct xfs_mount *mp = dqp->q_mount;
1029-
struct xfs_quotainfo *qi = mp->m_quotainfo;
1030-
1031-
xfs_dqlock(dqp);
1032-
1033-
/*
1034-
* If we're turning off quotas, we have to make sure that, for
1035-
* example, we don't delete quota disk blocks while dquots are
1036-
* in the process of getting written to those disk blocks.
1037-
* This dquot might well be on AIL, and we can't leave it there
1038-
* if we're turning off quotas. Basically, we need this flush
1039-
* lock, and are willing to block on it.
1040-
*/
1041-
if (!xfs_dqflock_nowait(dqp)) {
1042-
/*
1043-
* Block on the flush lock after nudging dquot buffer,
1044-
* if it is incore.
1045-
*/
1046-
xfs_dqflock_pushbuf_wait(dqp);
1047-
}
1048-
1049-
/*
1050-
* If we are turning this type of quotas off, we don't care
1051-
* about the dirty metadata sitting in this dquot. OTOH, if
1052-
* we're unmounting, we do care, so we flush it and wait.
1053-
*/
1054-
if (XFS_DQ_IS_DIRTY(dqp)) {
1055-
int error;
1056-
1057-
/*
1058-
* We don't care about getting disk errors here. We need
1059-
* to purge this dquot anyway, so we go ahead regardless.
1060-
*/
1061-
error = xfs_qm_dqflush(dqp, SYNC_WAIT);
1062-
if (error)
1063-
xfs_warn(mp, "%s: dquot %p flush failed",
1064-
__func__, dqp);
1065-
xfs_dqflock(dqp);
1066-
}
1067-
1068-
ASSERT(atomic_read(&dqp->q_pincount) == 0);
1069-
ASSERT(XFS_FORCED_SHUTDOWN(mp) ||
1070-
!(dqp->q_logitem.qli_item.li_flags & XFS_LI_IN_AIL));
1071-
1072-
xfs_dqfunlock(dqp);
1073-
xfs_dqunlock(dqp);
1074-
1075-
mutex_lock(&qi->qi_tree_lock);
1076-
radix_tree_delete(XFS_DQUOT_TREE(qi, dqp->q_core.d_flags),
1077-
be32_to_cpu(dqp->q_core.d_id));
1078-
mutex_unlock(&qi->qi_tree_lock);
1079-
1080-
mutex_lock(&qi->qi_dqlist_lock);
1081-
list_del_init(&dqp->q_mplist);
1082-
qi->qi_dqreclaims++;
1083-
qi->qi_dquots--;
1084-
mutex_unlock(&qi->qi_dqlist_lock);
1085-
1086-
/*
1087-
* We move dquots to the freelist as soon as their reference count
1088-
* hits zero, so it really should be on the freelist here.
1089-
*/
1090-
mutex_lock(&qi->qi_lru_lock);
1091-
ASSERT(!list_empty(&dqp->q_lru));
1092-
list_del_init(&dqp->q_lru);
1093-
qi->qi_lru_count--;
1094-
XFS_STATS_DEC(xs_qm_dquot_unused);
1095-
mutex_unlock(&qi->qi_lru_lock);
1096-
1097-
xfs_qm_dqdestroy(dqp);
1098-
}
1099-
11001011
/*
11011012
* Give the buffer a little push if it is incore and
11021013
* wait on the flush lock.

‎fs/xfs/xfs_dquot.h‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ struct xfs_trans;
3838
typedef struct xfs_dquot {
3939
uint dq_flags; /* various flags (XFS_DQ_*) */
4040
struct list_head q_lru; /* global free list of dquots */
41-
struct list_head q_mplist; /* mount's list of dquots */
4241
struct xfs_mount*q_mount; /* filesystem this relates to */
4342
struct xfs_trans*q_transp; /* trans this belongs to currently */
4443
uint q_nrefs; /* # active refs from inodes */
@@ -143,7 +142,6 @@ extern int xfs_qm_dqread(struct xfs_mount *, xfs_dqid_t, uint,
143142
uint, struct xfs_dquot **);
144143
extern void xfs_qm_dqdestroy(xfs_dquot_t *);
145144
extern int xfs_qm_dqflush(xfs_dquot_t *, uint);
146-
extern void xfs_qm_dqpurge(xfs_dquot_t *);
147145
extern void xfs_qm_dqunpin_wait(xfs_dquot_t *);
148146
extern void xfs_qm_adjust_dqtimers(xfs_mount_t *,
149147
xfs_disk_dquot_t *);

0 commit comments

Comments
 (0)