[XFS] Clean up quotamount error handling.
[safe/jmp/linux-2.6] / fs / xfs / quota / xfs_dquot_item.c
index e4e5f05..3dedce1 100644 (file)
@@ -23,7 +23,6 @@
 #include "xfs_trans.h"
 #include "xfs_sb.h"
 #include "xfs_ag.h"
-#include "xfs_dir.h"
 #include "xfs_dir2.h"
 #include "xfs_alloc.h"
 #include "xfs_dmapi.h"
@@ -32,7 +31,6 @@
 #include "xfs_bmap_btree.h"
 #include "xfs_alloc_btree.h"
 #include "xfs_ialloc_btree.h"
-#include "xfs_dir_sf.h"
 #include "xfs_dir2_sf.h"
 #include "xfs_attr_sf.h"
 #include "xfs_dinode.h"
@@ -45,8 +43,6 @@
 #include "xfs_itable.h"
 #include "xfs_rw.h"
 #include "xfs_acl.h"
-#include "xfs_cap.h"
-#include "xfs_mac.h"
 #include "xfs_attr.h"
 #include "xfs_buf_item.h"
 #include "xfs_trans_priv.h"
@@ -98,14 +94,13 @@ STATIC void
 xfs_qm_dquot_logitem_pin(
        xfs_dq_logitem_t *logitem)
 {
-       unsigned long   s;
        xfs_dquot_t *dqp;
 
        dqp = logitem->qli_dquot;
        ASSERT(XFS_DQ_IS_LOCKED(dqp));
-       s = XFS_DQ_PINLOCK(dqp);
+       spin_lock(&(XFS_DQ_TO_QINF(dqp)->qi_pinlock));
        dqp->q_pincount++;
-       XFS_DQ_PINUNLOCK(dqp, s);
+       spin_unlock(&(XFS_DQ_TO_QINF(dqp)->qi_pinlock));
 }
 
 /*
@@ -119,17 +114,16 @@ xfs_qm_dquot_logitem_unpin(
        xfs_dq_logitem_t *logitem,
        int               stale)
 {
-       unsigned long   s;
        xfs_dquot_t *dqp;
 
        dqp = logitem->qli_dquot;
        ASSERT(dqp->q_pincount > 0);
-       s = XFS_DQ_PINLOCK(dqp);
+       spin_lock(&(XFS_DQ_TO_QINF(dqp)->qi_pinlock));
        dqp->q_pincount--;
        if (dqp->q_pincount == 0) {
                sv_broadcast(&dqp->q_pinwait);
        }
-       XFS_DQ_PINUNLOCK(dqp, s);
+       spin_unlock(&(XFS_DQ_TO_QINF(dqp)->qi_pinlock));
 }
 
 /* ARGSUSED */
@@ -152,6 +146,7 @@ xfs_qm_dquot_logitem_push(
        xfs_dq_logitem_t        *logitem)
 {
        xfs_dquot_t     *dqp;
+       int             error;
 
        dqp = logitem->qli_dquot;
 
@@ -167,7 +162,11 @@ xfs_qm_dquot_logitem_push(
         * lock without sleeping, then there must not have been
         * anyone in the process of flushing the dquot.
         */
-       xfs_qm_dqflush(dqp, XFS_B_DELWRI);
+       error = xfs_qm_dqflush(dqp, XFS_QMOPT_DELWRI);
+       if (error)
+               xfs_fs_cmn_err(CE_WARN, dqp->q_mount,
+                       "xfs_qm_dquot_logitem_push: push error %d on dqp %p",
+                       error, dqp);
        xfs_dqunlock(dqp);
 }
 
@@ -193,8 +192,6 @@ void
 xfs_qm_dqunpin_wait(
        xfs_dquot_t     *dqp)
 {
-       SPLDECL(s);
-
        ASSERT(XFS_DQ_IS_LOCKED(dqp));
        if (dqp->q_pincount == 0) {
                return;
@@ -204,9 +201,9 @@ xfs_qm_dqunpin_wait(
         * Give the log a push so we don't wait here too long.
         */
        xfs_log_force(dqp->q_mount, (xfs_lsn_t)0, XFS_LOG_FORCE);
-       s = XFS_DQ_PINLOCK(dqp);
+       spin_lock(&(XFS_DQ_TO_QINF(dqp)->qi_pinlock));
        if (dqp->q_pincount == 0) {
-               XFS_DQ_PINUNLOCK(dqp, s);
+               spin_unlock(&(XFS_DQ_TO_QINF(dqp)->qi_pinlock));
                return;
        }
        sv_wait(&(dqp->q_pinwait), PINOD,
@@ -220,8 +217,8 @@ xfs_qm_dqunpin_wait(
  * If so, we want to push it out to help us take this item off the AIL as soon
  * as possible.
  *
- * We must not be holding the AIL_LOCK at this point. Calling incore() to
- * search the buffercache can be a time consuming thing, and AIL_LOCK is a
+ * We must not be holding the AIL lock at this point. Calling incore() to
+ * search the buffer cache can be a time consuming thing, and AIL lock is a
  * spinlock.
  */
 STATIC void
@@ -248,7 +245,7 @@ xfs_qm_dquot_logitem_pushbuf(
         * inode flush completed and the inode was taken off the AIL.
         * So, just get out.
         */
-       if ((valusema(&(dqp->q_flock)) > 0)  ||
+       if (!issemalocked(&(dqp->q_flock))  ||
            ((qip->qli_item.li_flags & XFS_LI_IN_AIL) == 0)) {
                qip->qli_pushbuf_flag = 0;
                xfs_dqunlock(dqp);
@@ -261,7 +258,7 @@ xfs_qm_dquot_logitem_pushbuf(
        if (bp != NULL) {
                if (XFS_BUF_ISDELAYWRITE(bp)) {
                        dopush = ((qip->qli_item.li_flags & XFS_LI_IN_AIL) &&
-                                 (valusema(&(dqp->q_flock)) <= 0));
+                                 issemalocked(&(dqp->q_flock)));
                        qip->qli_pushbuf_flag = 0;
                        xfs_dqunlock(dqp);
 
@@ -326,7 +323,7 @@ xfs_qm_dquot_logitem_trylock(
                 * want to do that now since we might sleep in the device
                 * strategy routine.  We also don't want to grab the buffer lock
                 * here because we'd like not to call into the buffer cache
-                * while holding the AIL_LOCK.
+                * while holding the AIL lock.
                 * Make sure to only return PUSHBUF if we set pushbuf_flag
                 * ourselves.  If someone else is doing it then we don't
                 * want to go to the push routine and duplicate their efforts.
@@ -384,18 +381,6 @@ xfs_qm_dquot_logitem_unlock(
 
 
 /*
- * The transaction with the dquot locked has aborted.  The dquot
- * must not be dirty within the transaction.  We simply unlock just
- * as if the transaction had been cancelled.
- */
-STATIC void
-xfs_qm_dquot_logitem_abort(
-       xfs_dq_logitem_t    *ql)
-{
-       xfs_qm_dquot_logitem_unlock(ql);
-}
-
-/*
  * this needs to stamp an lsn into the dquot, I think.
  * rpc's that look at user dquot's would then have to
  * push on the dependency recorded in the dquot
@@ -413,7 +398,7 @@ xfs_qm_dquot_logitem_committing(
 /*
  * This is the ops vector for dquots
  */
-STATIC struct xfs_item_ops xfs_dquot_item_ops = {
+static struct xfs_item_ops xfs_dquot_item_ops = {
        .iop_size       = (uint(*)(xfs_log_item_t*))xfs_qm_dquot_logitem_size,
        .iop_format     = (void(*)(xfs_log_item_t*, xfs_log_iovec_t*))
                                        xfs_qm_dquot_logitem_format,
@@ -428,7 +413,6 @@ STATIC struct xfs_item_ops xfs_dquot_item_ops = {
        .iop_committed  = (xfs_lsn_t(*)(xfs_log_item_t*, xfs_lsn_t))
                                        xfs_qm_dquot_logitem_committed,
        .iop_push       = (void(*)(xfs_log_item_t*))xfs_qm_dquot_logitem_push,
-       .iop_abort      = (void(*)(xfs_log_item_t*))xfs_qm_dquot_logitem_abort,
        .iop_pushbuf    = (void(*)(xfs_log_item_t*))
                                        xfs_qm_dquot_logitem_pushbuf,
        .iop_committing = (void(*)(xfs_log_item_t*, xfs_lsn_t))
@@ -561,17 +545,6 @@ xfs_qm_qoff_logitem_committed(xfs_qoff_logitem_t *qf, xfs_lsn_t lsn)
 }
 
 /*
- * The transaction of which this QUOTAOFF is a part has been aborted.
- * Just clean up after ourselves.
- * Shouldn't this never happen in the case of qoffend logitems? XXX
- */
-STATIC void
-xfs_qm_qoff_logitem_abort(xfs_qoff_logitem_t *qf)
-{
-       kmem_free(qf, sizeof(xfs_qoff_logitem_t));
-}
-
-/*
  * There isn't much you can do to push on an quotaoff item.  It is simply
  * stuck waiting for the log to be flushed to disk.
  */
@@ -590,15 +563,14 @@ xfs_qm_qoffend_logitem_committed(
        xfs_lsn_t lsn)
 {
        xfs_qoff_logitem_t      *qfs;
-       SPLDECL(s);
 
        qfs = qfe->qql_start_lip;
-       AIL_LOCK(qfs->qql_item.li_mountp,s);
+       spin_lock(&qfs->qql_item.li_mountp->m_ail_lock);
        /*
         * Delete the qoff-start logitem from the AIL.
         * xfs_trans_delete_ail() drops the AIL lock.
         */
-       xfs_trans_delete_ail(qfs->qql_item.li_mountp, (xfs_log_item_t *)qfs, s);
+       xfs_trans_delete_ail(qfs->qql_item.li_mountp, (xfs_log_item_t *)qfs);
        kmem_free(qfs, sizeof(xfs_qoff_logitem_t));
        kmem_free(qfe, sizeof(xfs_qoff_logitem_t));
        return (xfs_lsn_t)-1;
@@ -632,7 +604,7 @@ xfs_qm_qoffend_logitem_committing(xfs_qoff_logitem_t *qip, xfs_lsn_t commit_lsn)
        return;
 }
 
-STATIC struct xfs_item_ops xfs_qm_qoffend_logitem_ops = {
+static struct xfs_item_ops xfs_qm_qoffend_logitem_ops = {
        .iop_size       = (uint(*)(xfs_log_item_t*))xfs_qm_qoff_logitem_size,
        .iop_format     = (void(*)(xfs_log_item_t*, xfs_log_iovec_t*))
                                        xfs_qm_qoff_logitem_format,
@@ -646,7 +618,6 @@ STATIC struct xfs_item_ops xfs_qm_qoffend_logitem_ops = {
        .iop_committed  = (xfs_lsn_t(*)(xfs_log_item_t*, xfs_lsn_t))
                                        xfs_qm_qoffend_logitem_committed,
        .iop_push       = (void(*)(xfs_log_item_t*))xfs_qm_qoff_logitem_push,
-       .iop_abort      = (void(*)(xfs_log_item_t*))xfs_qm_qoff_logitem_abort,
        .iop_pushbuf    = NULL,
        .iop_committing = (void(*)(xfs_log_item_t*, xfs_lsn_t))
                                        xfs_qm_qoffend_logitem_committing
@@ -655,7 +626,7 @@ STATIC struct xfs_item_ops xfs_qm_qoffend_logitem_ops = {
 /*
  * This is the ops vector shared by all quotaoff-start log items.
  */
-STATIC struct xfs_item_ops xfs_qm_qoff_logitem_ops = {
+static struct xfs_item_ops xfs_qm_qoff_logitem_ops = {
        .iop_size       = (uint(*)(xfs_log_item_t*))xfs_qm_qoff_logitem_size,
        .iop_format     = (void(*)(xfs_log_item_t*, xfs_log_iovec_t*))
                                        xfs_qm_qoff_logitem_format,
@@ -669,7 +640,6 @@ STATIC struct xfs_item_ops xfs_qm_qoff_logitem_ops = {
        .iop_committed  = (xfs_lsn_t(*)(xfs_log_item_t*, xfs_lsn_t))
                                        xfs_qm_qoff_logitem_committed,
        .iop_push       = (void(*)(xfs_log_item_t*))xfs_qm_qoff_logitem_push,
-       .iop_abort      = (void(*)(xfs_log_item_t*))xfs_qm_qoff_logitem_abort,
        .iop_pushbuf    = NULL,
        .iop_committing = (void(*)(xfs_log_item_t*, xfs_lsn_t))
                                        xfs_qm_qoff_logitem_committing