From: Dave Chinner <david@fromorbit.com>
To: xfs@oss.sgi.com
Subject: [PATCH 07/37] xfs: do not write the buffer from xfs_qm_dqflush
Date: Mon, 23 Apr 2012 15:58:37 +1000 [thread overview]
Message-ID: <1335160747-17254-8-git-send-email-david@fromorbit.com> (raw)
In-Reply-To: <1335160747-17254-1-git-send-email-david@fromorbit.com>
From: Christoph Hellwig <hch@infradead.org>
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 <hch@lst.de>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Mark Tinguely <tinguely@sgi.com>
---
fs/xfs/xfs_dquot.c | 43 +++++++++++++------------------------------
fs/xfs/xfs_dquot.h | 2 +-
fs/xfs/xfs_dquot_item.c | 21 +++++++++++++++++++--
fs/xfs/xfs_qm.c | 25 ++++++++++++++++++++-----
4 files changed, 53 insertions(+), 38 deletions(-)
diff --git a/fs/xfs/xfs_dquot.c b/fs/xfs/xfs_dquot.c
index 786a61e..53757d8 100644
--- a/fs/xfs/xfs_dquot.c
+++ b/fs/xfs/xfs_dquot.c
@@ -878,8 +878,8 @@ xfs_qm_dqflush_done(
*/
int
xfs_qm_dqflush(
- xfs_dquot_t *dqp,
- uint flags)
+ struct xfs_dquot *dqp,
+ struct xfs_buf **bpp)
{
struct xfs_mount *mp = dqp->q_mount;
struct xfs_buf *bp;
@@ -891,14 +891,8 @@ xfs_qm_dqflush(
trace_xfs_dqflush(dqp);
- /*
- * If not dirty, or it's pinned and we are not supposed to block, nada.
- */
- if (!XFS_DQ_IS_DIRTY(dqp) ||
- ((flags & SYNC_TRYLOCK) && atomic_read(&dqp->q_pincount) > 0)) {
- xfs_dqfunlock(dqp);
- return 0;
- }
+ *bpp = NULL;
+
xfs_qm_dqunpin_wait(dqp);
/*
@@ -918,9 +912,8 @@ xfs_qm_dqflush(
xfs_trans_ail_delete(mp->m_ail, lip);
else
spin_unlock(&mp->m_ail->xa_lock);
-
- xfs_dqfunlock(dqp);
- return XFS_ERROR(EIO);
+ error = XFS_ERROR(EIO);
+ goto out_unlock;
}
/*
@@ -928,11 +921,8 @@ xfs_qm_dqflush(
*/
error = xfs_trans_read_buf(mp, NULL, mp->m_ddev_targp, dqp->q_blkno,
mp->m_quotainfo->qi_dqchunklen, 0, &bp);
- if (error) {
- ASSERT(error != ENOENT);
- xfs_dqfunlock(dqp);
- return error;
- }
+ if (error)
+ goto out_unlock;
/*
* Calculate the location of the dquot inside the buffer.
@@ -978,20 +968,13 @@ xfs_qm_dqflush(
xfs_log_force(mp, 0);
}
- if (flags & SYNC_WAIT)
- error = xfs_bwrite(bp);
- else
- xfs_buf_delwri_queue(bp);
-
- xfs_buf_relse(bp);
-
trace_xfs_dqflush_done(dqp);
+ *bpp = bp;
+ return 0;
- /*
- * dqp is still locked, but caller is free to unlock it now.
- */
- return error;
-
+out_unlock:
+ xfs_dqfunlock(dqp);
+ return XFS_ERROR(EIO);
}
/*
diff --git a/fs/xfs/xfs_dquot.h b/fs/xfs/xfs_dquot.h
index ef9190b..5f2a2f2 100644
--- a/fs/xfs/xfs_dquot.h
+++ b/fs/xfs/xfs_dquot.h
@@ -141,7 +141,7 @@ static inline xfs_dquot_t *xfs_inode_dquot(struct xfs_inode *ip, int type)
extern int xfs_qm_dqread(struct xfs_mount *, xfs_dqid_t, uint,
uint, struct xfs_dquot **);
extern void xfs_qm_dqdestroy(xfs_dquot_t *);
-extern int xfs_qm_dqflush(xfs_dquot_t *, uint);
+extern int xfs_qm_dqflush(struct xfs_dquot *, struct xfs_buf **);
extern void xfs_qm_dqunpin_wait(xfs_dquot_t *);
extern void xfs_qm_adjust_dqtimers(xfs_mount_t *,
xfs_disk_dquot_t *);
diff --git a/fs/xfs/xfs_dquot_item.c b/fs/xfs/xfs_dquot_item.c
index 34baeae..8d82958 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,
diff --git a/fs/xfs/xfs_qm.c b/fs/xfs/xfs_qm.c
index 18ba438..95aecf5 100644
--- a/fs/xfs/xfs_qm.c
+++ b/fs/xfs/xfs_qm.c
@@ -175,16 +175,21 @@ xfs_qm_dqpurge(
* we're unmounting, we do care, so we flush it and wait.
*/
if (XFS_DQ_IS_DIRTY(dqp)) {
- int error;
+ struct xfs_buf *bp = NULL;
+ int error;
/*
* We don't care about getting disk errors here. We need
* to purge this dquot anyway, so we go ahead regardless.
*/
- error = xfs_qm_dqflush(dqp, SYNC_WAIT);
- if (error)
+ error = xfs_qm_dqflush(dqp, &bp);
+ if (error) {
xfs_warn(mp, "%s: dquot %p flush failed",
__func__, dqp);
+ } else {
+ error = xfs_bwrite(bp);
+ xfs_buf_relse(bp);
+ }
xfs_dqflock(dqp);
}
@@ -1200,6 +1205,7 @@ STATIC int
xfs_qm_flush_one(
struct xfs_dquot *dqp)
{
+ struct xfs_buf *bp = NULL;
int error = 0;
xfs_dqlock(dqp);
@@ -1211,8 +1217,12 @@ xfs_qm_flush_one(
if (!xfs_dqflock_nowait(dqp))
xfs_dqflock_pushbuf_wait(dqp);
- error = xfs_qm_dqflush(dqp, 0);
+ error = xfs_qm_dqflush(dqp, &bp);
+ if (error)
+ goto out_unlock;
+ xfs_buf_delwri_queue(bp);
+ xfs_buf_relse(bp);
out_unlock:
xfs_dqunlock(dqp);
return error;
@@ -1479,18 +1489,23 @@ xfs_qm_dqreclaim_one(
* dirty dquots.
*/
if (XFS_DQ_IS_DIRTY(dqp)) {
+ struct xfs_buf *bp = NULL;
+
trace_xfs_dqreclaim_dirty(dqp);
/*
* We flush it delayed write, so don't bother releasing the
* freelist lock.
*/
- error = xfs_qm_dqflush(dqp, 0);
+ error = xfs_qm_dqflush(dqp, &bp);
if (error) {
xfs_warn(mp, "%s: dquot %p flush failed",
__func__, dqp);
+ goto out_busy;
}
+ xfs_buf_delwri_queue(bp);
+ xfs_buf_relse(bp);
/*
* Give the dquot another try on the freelist, as the
* flushing will take some time.
--
1.7.9.5
_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs
next prev parent reply other threads:[~2012-04-23 5:59 UTC|newest]
Thread overview: 96+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-04-23 5:58 [PATCH 00/37] xfs: current 3.4 patch queue Dave Chinner
2012-04-23 5:58 ` [PATCH 01/37] xfs: remove log item from AIL in xfs_qm_dqflush after a shutdown Dave Chinner
2012-04-23 5:58 ` [PATCH 02/37] xfs: remove log item from AIL in xfs_iflush " Dave Chinner
2012-04-23 15:39 ` Mark Tinguely
2012-04-23 5:58 ` [PATCH 03/37] xfs: allow assigning the tail lsn with the AIL lock held Dave Chinner
2012-04-23 5:58 ` [PATCH 04/37] xfs: implement freezing by emptying the AIL Dave Chinner
2012-04-23 15:40 ` Mark Tinguely
2012-04-29 21:43 ` Christoph Hellwig
2012-04-23 5:58 ` [PATCH 05/37] xfs: don't flush inodes from background inode reclaim Dave Chinner
2012-04-23 5:58 ` [PATCH 06/37] xfs: do not write the buffer from xfs_iflush Dave Chinner
2012-04-23 5:58 ` Dave Chinner [this message]
2012-04-23 5:58 ` [PATCH 08/37] xfs: do not add buffers to the delwri queue until pushed Dave Chinner
2012-04-23 5:58 ` [PATCH 09/37] xfs: on-stack delayed write buffer lists Dave Chinner
2012-04-25 18:34 ` Mark Tinguely
2012-04-29 21:44 ` Christoph Hellwig
2012-04-23 5:58 ` [PATCH 10/37] xfs: remove some obsolete comments in xfs_trans_ail.c Dave Chinner
2012-04-23 15:41 ` Mark Tinguely
2012-04-23 5:58 ` [PATCH 11/37] xfs: pass shutdown method into xfs_trans_ail_delete_bulk Dave Chinner
2012-04-23 5:58 ` [PATCH 12/37] xfs: Do background CIL flushes via a workqueue Dave Chinner
2012-04-23 7:54 ` [PATCH 12/37 V2] " Dave Chinner
2012-04-29 21:46 ` Christoph Hellwig
2012-04-23 5:58 ` [PATCH 13/37] xfs: page type check in writeback only checks last buffer Dave Chinner
2012-04-23 5:58 ` [PATCH 14/37] xfs: Use preallocation for inodes with extsz hints Dave Chinner
2012-04-29 21:47 ` Christoph Hellwig
2012-04-23 5:58 ` [PATCH 15/37] xfs: fix buffer lookup race on allocation failure Dave Chinner
2012-04-23 5:58 ` [PATCH 16/37] xfs: check for buffer errors before waiting Dave Chinner
2012-04-23 5:58 ` [PATCH 17/37] xfs: fix incorrect b_offset initialisation Dave Chinner
2012-04-23 5:58 ` [PATCH 18/37] xfs: use kmem_zone_zalloc for buffers Dave Chinner
2012-04-23 5:58 ` [PATCH 19/37] xfs: clean up buffer get/read call API Dave Chinner
2012-04-23 5:58 ` [PATCH 20/37] xfs: kill b_file_offset Dave Chinner
2012-04-23 5:58 ` [PATCH 21/37] xfs: use blocks for counting length of buffers Dave Chinner
2012-04-23 5:58 ` [PATCH 22/37] xfs: use blocks for storing the desired IO size Dave Chinner
2012-04-23 5:58 ` [PATCH 23/37] xfs: kill xfs_buf_btoc Dave Chinner
2012-04-23 5:58 ` [PATCH 24/37] xfs: kill XBF_LOCK Dave Chinner
2012-04-23 5:58 ` [PATCH 25/37] xfs: kill xfs_read_buf() Dave Chinner
2012-04-23 5:58 ` [PATCH 26/37] xfs: kill XBF_DONTBLOCK Dave Chinner
2012-04-23 5:58 ` [PATCH 27/37] xfs: use iolock on XFS_IOC_ALLOCSP calls Dave Chinner
2012-04-23 5:58 ` [PATCH 28/37] xfs: move xfsagino_t to xfs_types.h Dave Chinner
2012-04-23 15:43 ` Mark Tinguely
2012-04-24 15:10 ` Mark Tinguely
2012-04-29 21:49 ` Christoph Hellwig
2012-04-30 0:32 ` Dave Chinner
2012-04-23 5:58 ` [PATCH 29/37] xfs: move busy extent handling to it's own file Dave Chinner
2012-04-23 17:57 ` Ben Myers
2012-04-24 0:25 ` [PATCH 29/37 V2] " Dave Chinner
2012-04-24 15:56 ` Mark Tinguely
2012-04-24 18:10 ` Mark Tinguely
2012-04-29 10:39 ` [PATCH 29/37 V3] " Dave Chinner
2012-04-29 21:50 ` Christoph Hellwig
2012-04-30 0:36 ` Dave Chinner
2012-04-30 2:17 ` Dave Chinner
2012-04-23 5:59 ` [PATCH 30/37] xfs: clean up busy extent naming Dave Chinner
2012-04-24 18:11 ` Mark Tinguely
2012-04-29 10:41 ` [PATCH 30/37 V2] " Dave Chinner
2012-04-29 21:50 ` Christoph Hellwig
2012-04-23 5:59 ` [PATCH 31/37] xfs: move xfs_fsb_to_db to xfs_bmap.h Dave Chinner
2012-04-24 19:24 ` Mark Tinguely
2012-04-29 21:53 ` Christoph Hellwig
2012-04-30 2:31 ` Dave Chinner
2012-04-23 5:59 ` [PATCH 32/37] xfs: move xfs_get_extsz_hint() and kill xfs_rw.h Dave Chinner
2012-04-24 19:30 ` Mark Tinguely
2012-04-29 21:53 ` Christoph Hellwig
2012-04-23 5:59 ` [PATCH 33/37] xfs: move xfs_do_force_shutdown() and kill xfs_rw.c Dave Chinner
2012-04-24 19:37 ` Mark Tinguely
2012-04-29 21:54 ` Christoph Hellwig
2012-04-30 2:38 ` Dave Chinner
2012-04-23 5:59 ` [PATCH 34/37] xfs: clean up xfs_bit.h includes Dave Chinner
2012-04-24 19:44 ` Mark Tinguely
2012-04-29 21:55 ` Christoph Hellwig
2012-04-30 2:40 ` Dave Chinner
2012-04-23 5:59 ` [PATCH 35/37] xfs: Properly exclude IO type flags from buffer flags Dave Chinner
2012-04-24 20:02 ` Mark Tinguely
2012-04-29 21:55 ` Christoph Hellwig
2012-04-23 5:59 ` [PATCH 36/37] xfs: flush outstanding buffers on log mount failure Dave Chinner
2012-04-23 15:47 ` Mark Tinguely
2012-04-29 21:55 ` Christoph Hellwig
2012-04-23 5:59 ` [PATCH 37/37] xfs: make XBF_MAPPED the default behaviour Dave Chinner
2012-04-25 18:35 ` Mark Tinguely
2012-04-25 20:09 ` Mark Tinguely
2012-04-25 22:33 ` Dave Chinner
2012-04-29 21:57 ` Christoph Hellwig
2012-04-30 2:45 ` Dave Chinner
2012-04-23 18:01 ` [PATCH 00/37] xfs: current 3.4 patch queue Ben Myers
2012-04-23 23:29 ` Dave Chinner
2012-04-30 14:24 ` Ben Myers
2012-04-28 2:15 ` Ben Myers
2012-04-28 21:28 ` Ben Myers
2012-04-29 0:21 ` Dave Chinner
2012-04-29 0:14 ` Dave Chinner
2012-04-30 14:44 ` Ben Myers
2012-04-30 23:04 ` Dave Chinner
2012-04-30 14:32 ` Assertion failed: RB_EMPTY_NODE(&bp->b_rbnode) Ben Myers
2012-04-30 23:12 ` Dave Chinner
2012-04-30 14:34 ` [PATCH 00/37] xfs: current 3.4 patch queue Ben Myers
2012-04-30 23:20 ` Dave Chinner
2012-04-30 19:25 ` Christoph Hellwig
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1335160747-17254-8-git-send-email-david@fromorbit.com \
--to=david@fromorbit.com \
--cc=xfs@oss.sgi.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox