Skip to content

Commit 8d3d7e2

Browse files
Brian Fosterdjwong
authored andcommitted
xfs: trylock underlying buffer on dquot flush
A dquot flush currently blocks on the buffer lock for the underlying dquot buffer. In turn, this causes xfsaild to block rather than continue processing other items in the meantime. Update xfs_qm_dqflush() to trylock the buffer, similar to how inode buffers are handled, and return -EAGAIN if the lock fails. Fix up any callers that don't currently handle the error properly. Signed-off-by: Brian Foster <[email protected]> Reviewed-by: Christoph Hellwig <[email protected]> Reviewed-by: Darrick J. Wong <[email protected]> Signed-off-by: Darrick J. Wong <[email protected]>
1 parent 63337b6 commit 8d3d7e2

File tree

3 files changed

+14
-9
lines changed

3 files changed

+14
-9
lines changed

fs/xfs/xfs_dquot.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1105,8 +1105,8 @@ xfs_qm_dqflush(
11051105
* Get the buffer containing the on-disk dquot
11061106
*/
11071107
error = xfs_trans_read_buf(mp, NULL, mp->m_ddev_targp, dqp->q_blkno,
1108-
mp->m_quotainfo->qi_dqchunklen, 0, &bp,
1109-
&xfs_dquot_buf_ops);
1108+
mp->m_quotainfo->qi_dqchunklen, XBF_TRYLOCK,
1109+
&bp, &xfs_dquot_buf_ops);
11101110
if (error)
11111111
goto out_unlock;
11121112

@@ -1177,7 +1177,7 @@ xfs_qm_dqflush(
11771177

11781178
out_unlock:
11791179
xfs_dqfunlock(dqp);
1180-
return -EIO;
1180+
return error;
11811181
}
11821182

11831183
/*

fs/xfs/xfs_dquot_item.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,8 @@ xfs_qm_dquot_logitem_push(
189189
if (!xfs_buf_delwri_queue(bp, buffer_list))
190190
rval = XFS_ITEM_FLUSHING;
191191
xfs_buf_relse(bp);
192-
}
192+
} else if (error == -EAGAIN)
193+
rval = XFS_ITEM_LOCKED;
193194

194195
spin_lock(&lip->li_ailp->ail_lock);
195196
out_unlock:

fs/xfs/xfs_qm.c

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -121,12 +121,11 @@ xfs_qm_dqpurge(
121121
{
122122
struct xfs_mount *mp = dqp->q_mount;
123123
struct xfs_quotainfo *qi = mp->m_quotainfo;
124+
int error = -EAGAIN;
124125

125126
xfs_dqlock(dqp);
126-
if ((dqp->dq_flags & XFS_DQ_FREEING) || dqp->q_nrefs != 0) {
127-
xfs_dqunlock(dqp);
128-
return -EAGAIN;
129-
}
127+
if ((dqp->dq_flags & XFS_DQ_FREEING) || dqp->q_nrefs != 0)
128+
goto out_unlock;
130129

131130
dqp->dq_flags |= XFS_DQ_FREEING;
132131

@@ -139,7 +138,6 @@ xfs_qm_dqpurge(
139138
*/
140139
if (XFS_DQ_IS_DIRTY(dqp)) {
141140
struct xfs_buf *bp = NULL;
142-
int error;
143141

144142
/*
145143
* We don't care about getting disk errors here. We need
@@ -149,6 +147,8 @@ xfs_qm_dqpurge(
149147
if (!error) {
150148
error = xfs_bwrite(bp);
151149
xfs_buf_relse(bp);
150+
} else if (error == -EAGAIN) {
151+
goto out_unlock;
152152
}
153153
xfs_dqflock(dqp);
154154
}
@@ -174,6 +174,10 @@ xfs_qm_dqpurge(
174174

175175
xfs_qm_dqdestroy(dqp);
176176
return 0;
177+
178+
out_unlock:
179+
xfs_dqunlock(dqp);
180+
return error;
177181
}
178182

179183
/*

0 commit comments

Comments
 (0)