Skip to content

Commit cf55c35

Browse files
Brian Fostergregkh
authored andcommitted
xfs: fix up quotacheck buffer list error handling
commit 20e8a063786050083fe05b4f45be338c60b49126 upstream. The quotacheck error handling of the delwri buffer list assumes the resident buffers are locked and doesn't clear the _XBF_DELWRI_Q flag on the buffers that are dequeued. This can lead to assert failures on buffer release and possibly other locking problems. Move this code to a delwri queue cancel helper function to encapsulate the logic required to properly release buffers from a delwri queue. Update the helper to clear the delwri queue flag and call it from quotacheck. Signed-off-by: Brian Foster <bfoster@redhat.com> Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com> Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent a76647a commit cf55c35

3 files changed

Lines changed: 26 additions & 6 deletions

File tree

fs/xfs/xfs_buf.c

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -979,6 +979,8 @@ void
979979
xfs_buf_unlock(
980980
struct xfs_buf *bp)
981981
{
982+
ASSERT(xfs_buf_islocked(bp));
983+
982984
XB_CLEAR_OWNER(bp);
983985
up(&bp->b_sema);
984986

@@ -1712,6 +1714,28 @@ xfs_alloc_buftarg(
17121714
return NULL;
17131715
}
17141716

1717+
/*
1718+
* Cancel a delayed write list.
1719+
*
1720+
* Remove each buffer from the list, clear the delwri queue flag and drop the
1721+
* associated buffer reference.
1722+
*/
1723+
void
1724+
xfs_buf_delwri_cancel(
1725+
struct list_head *list)
1726+
{
1727+
struct xfs_buf *bp;
1728+
1729+
while (!list_empty(list)) {
1730+
bp = list_first_entry(list, struct xfs_buf, b_list);
1731+
1732+
xfs_buf_lock(bp);
1733+
bp->b_flags &= ~_XBF_DELWRI_Q;
1734+
list_del_init(&bp->b_list);
1735+
xfs_buf_relse(bp);
1736+
}
1737+
}
1738+
17151739
/*
17161740
* Add a buffer to the delayed write list.
17171741
*

fs/xfs/xfs_buf.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -304,6 +304,7 @@ extern void xfs_buf_iomove(xfs_buf_t *, size_t, size_t, void *,
304304
extern void *xfs_buf_offset(struct xfs_buf *, size_t);
305305

306306
/* Delayed Write Buffer Routines */
307+
extern void xfs_buf_delwri_cancel(struct list_head *);
307308
extern bool xfs_buf_delwri_queue(struct xfs_buf *, struct list_head *);
308309
extern int xfs_buf_delwri_submit(struct list_head *);
309310
extern int xfs_buf_delwri_submit_nowait(struct list_head *);

fs/xfs/xfs_qm.c

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1355,12 +1355,7 @@ xfs_qm_quotacheck(
13551355
mp->m_qflags |= flags;
13561356

13571357
error_return:
1358-
while (!list_empty(&buffer_list)) {
1359-
struct xfs_buf *bp =
1360-
list_first_entry(&buffer_list, struct xfs_buf, b_list);
1361-
list_del_init(&bp->b_list);
1362-
xfs_buf_relse(bp);
1363-
}
1358+
xfs_buf_delwri_cancel(&buffer_list);
13641359

13651360
if (error) {
13661361
xfs_warn(mp,

0 commit comments

Comments
 (0)