From fe7257fd4b8ae9a3e354d9edb61890973e373ef0 Mon Sep 17 00:00:00 2001 From: Christoph Hellwig Date: Mon, 23 Apr 2012 15:58:37 +1000 Subject: xfs: do not write the buffer from xfs_qm_dqflush Instead of writing the buffer directly from inside xfs_qm_dqflush return it to the caller and let the caller decide what to do with the buffer. Also remove the pincount check in xfs_qm_dqflush that all non-blocking callers already implement and the now unused flags parameter and the XFS_DQ_IS_DIRTY check that all callers already perform. [ Dave Chinner: fixed build error cause by missing '{'. ] Signed-off-by: Christoph Hellwig Reviewed-by: Dave Chinner Reviewed-by: Mark Tinguely Signed-off-by: Ben Myers --- fs/xfs/xfs_dquot_item.c | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) (limited to 'fs/xfs/xfs_dquot_item.c') diff --git a/fs/xfs/xfs_dquot_item.c b/fs/xfs/xfs_dquot_item.c index 34baeae45265..8d8295814272 100644 --- a/fs/xfs/xfs_dquot_item.c +++ b/fs/xfs/xfs_dquot_item.c @@ -119,10 +119,12 @@ xfs_qm_dquot_logitem_push( struct xfs_log_item *lip) { struct xfs_dquot *dqp = DQUOT_ITEM(lip)->qli_dquot; + struct xfs_buf *bp = NULL; int error; ASSERT(XFS_DQ_IS_LOCKED(dqp)); ASSERT(!completion_done(&dqp->q_flush)); + ASSERT(atomic_read(&dqp->q_pincount) == 0); /* * Since we were able to lock the dquot's flush lock and @@ -133,10 +135,16 @@ xfs_qm_dquot_logitem_push( * lock without sleeping, then there must not have been * anyone in the process of flushing the dquot. */ - error = xfs_qm_dqflush(dqp, SYNC_TRYLOCK); - if (error) + error = xfs_qm_dqflush(dqp, &bp); + if (error) { xfs_warn(dqp->q_mount, "%s: push error %d on dqp %p", __func__, error, dqp); + goto out_unlock; + } + + xfs_buf_delwri_queue(bp); + xfs_buf_relse(bp); +out_unlock: xfs_dqunlock(dqp); } @@ -239,6 +247,15 @@ xfs_qm_dquot_logitem_trylock( if (!xfs_dqlock_nowait(dqp)) return XFS_ITEM_LOCKED; + /* + * Re-check the pincount now that we stabilized the value by + * taking the quota lock. + */ + if (atomic_read(&dqp->q_pincount) > 0) { + xfs_dqunlock(dqp); + return XFS_ITEM_PINNED; + } + if (!xfs_dqflock_nowait(dqp)) { /* * dquot has already been flushed to the backing buffer, -- cgit v1.2.3