Merge master.kernel.org:/home/rmk/linux-2.6-arm
[pandora-kernel.git] / fs / xfs / xfs_trans.c
index 279e043..8d056ce 100644 (file)
@@ -55,9 +55,140 @@ STATIC void xfs_trans_committed(xfs_trans_t *, int);
 STATIC void    xfs_trans_chunk_committed(xfs_log_item_chunk_t *, xfs_lsn_t, int);
 STATIC void    xfs_trans_free(xfs_trans_t *);
 
-kmem_zone_t            *xfs_trans_zone;
+kmem_zone_t    *xfs_trans_zone;
 
 
+/*
+ * Reservation functions here avoid a huge stack in xfs_trans_init
+ * due to register overflow from temporaries in the calculations.
+ */
+
+STATIC uint
+xfs_calc_write_reservation(xfs_mount_t *mp)
+{
+       return XFS_CALC_WRITE_LOG_RES(mp) + XFS_DQUOT_LOGRES(mp);
+}
+
+STATIC uint
+xfs_calc_itruncate_reservation(xfs_mount_t *mp)
+{
+       return XFS_CALC_ITRUNCATE_LOG_RES(mp) + XFS_DQUOT_LOGRES(mp);
+}
+
+STATIC uint
+xfs_calc_rename_reservation(xfs_mount_t *mp)
+{
+       return XFS_CALC_RENAME_LOG_RES(mp) + XFS_DQUOT_LOGRES(mp);
+}
+
+STATIC uint
+xfs_calc_link_reservation(xfs_mount_t *mp)
+{
+       return XFS_CALC_LINK_LOG_RES(mp) + XFS_DQUOT_LOGRES(mp);
+}
+
+STATIC uint
+xfs_calc_remove_reservation(xfs_mount_t *mp)
+{
+       return XFS_CALC_REMOVE_LOG_RES(mp) + XFS_DQUOT_LOGRES(mp);
+}
+
+STATIC uint
+xfs_calc_symlink_reservation(xfs_mount_t *mp)
+{
+       return XFS_CALC_SYMLINK_LOG_RES(mp) + XFS_DQUOT_LOGRES(mp);
+}
+
+STATIC uint
+xfs_calc_create_reservation(xfs_mount_t *mp)
+{
+       return XFS_CALC_CREATE_LOG_RES(mp) + XFS_DQUOT_LOGRES(mp);
+}
+
+STATIC uint
+xfs_calc_mkdir_reservation(xfs_mount_t *mp)
+{
+       return XFS_CALC_MKDIR_LOG_RES(mp) + XFS_DQUOT_LOGRES(mp);
+}
+
+STATIC uint
+xfs_calc_ifree_reservation(xfs_mount_t *mp)
+{
+       return XFS_CALC_IFREE_LOG_RES(mp) + XFS_DQUOT_LOGRES(mp);
+}
+
+STATIC uint
+xfs_calc_ichange_reservation(xfs_mount_t *mp)
+{
+       return XFS_CALC_ICHANGE_LOG_RES(mp) + XFS_DQUOT_LOGRES(mp);
+}
+
+STATIC uint
+xfs_calc_growdata_reservation(xfs_mount_t *mp)
+{
+       return XFS_CALC_GROWDATA_LOG_RES(mp);
+}
+
+STATIC uint
+xfs_calc_growrtalloc_reservation(xfs_mount_t *mp)
+{
+       return XFS_CALC_GROWRTALLOC_LOG_RES(mp);
+}
+
+STATIC uint
+xfs_calc_growrtzero_reservation(xfs_mount_t *mp)
+{
+       return XFS_CALC_GROWRTZERO_LOG_RES(mp);
+}
+
+STATIC uint
+xfs_calc_growrtfree_reservation(xfs_mount_t *mp)
+{
+       return XFS_CALC_GROWRTFREE_LOG_RES(mp);
+}
+
+STATIC uint
+xfs_calc_swrite_reservation(xfs_mount_t *mp)
+{
+       return XFS_CALC_SWRITE_LOG_RES(mp);
+}
+
+STATIC uint
+xfs_calc_writeid_reservation(xfs_mount_t *mp)
+{
+       return XFS_CALC_WRITEID_LOG_RES(mp);
+}
+
+STATIC uint
+xfs_calc_addafork_reservation(xfs_mount_t *mp)
+{
+       return XFS_CALC_ADDAFORK_LOG_RES(mp) + XFS_DQUOT_LOGRES(mp);
+}
+
+STATIC uint
+xfs_calc_attrinval_reservation(xfs_mount_t *mp)
+{
+       return XFS_CALC_ATTRINVAL_LOG_RES(mp);
+}
+
+STATIC uint
+xfs_calc_attrset_reservation(xfs_mount_t *mp)
+{
+       return XFS_CALC_ATTRSET_LOG_RES(mp) + XFS_DQUOT_LOGRES(mp);
+}
+
+STATIC uint
+xfs_calc_attrrm_reservation(xfs_mount_t *mp)
+{
+       return XFS_CALC_ATTRRM_LOG_RES(mp) + XFS_DQUOT_LOGRES(mp);
+}
+
+STATIC uint
+xfs_calc_clear_agi_bucket_reservation(xfs_mount_t *mp)
+{
+       return XFS_CALC_CLEAR_AGI_BUCKET_LOG_RES(mp);
+}
+
 /*
  * Initialize the precomputed transaction reservation values
  * in the mount structure.
@@ -69,39 +200,27 @@ xfs_trans_init(
        xfs_trans_reservations_t        *resp;
 
        resp = &(mp->m_reservations);
-       resp->tr_write =
-               (uint)(XFS_CALC_WRITE_LOG_RES(mp) + XFS_DQUOT_LOGRES(mp));
-       resp->tr_itruncate =
-               (uint)(XFS_CALC_ITRUNCATE_LOG_RES(mp) + XFS_DQUOT_LOGRES(mp));
-       resp->tr_rename =
-               (uint)(XFS_CALC_RENAME_LOG_RES(mp) + XFS_DQUOT_LOGRES(mp));
-       resp->tr_link = (uint)XFS_CALC_LINK_LOG_RES(mp);
-       resp->tr_remove =
-               (uint)(XFS_CALC_REMOVE_LOG_RES(mp) + XFS_DQUOT_LOGRES(mp));
-       resp->tr_symlink =
-               (uint)(XFS_CALC_SYMLINK_LOG_RES(mp) + XFS_DQUOT_LOGRES(mp));
-       resp->tr_create =
-               (uint)(XFS_CALC_CREATE_LOG_RES(mp) + XFS_DQUOT_LOGRES(mp));
-       resp->tr_mkdir =
-               (uint)(XFS_CALC_MKDIR_LOG_RES(mp) + XFS_DQUOT_LOGRES(mp));
-       resp->tr_ifree =
-               (uint)(XFS_CALC_IFREE_LOG_RES(mp) + XFS_DQUOT_LOGRES(mp));
-       resp->tr_ichange =
-               (uint)(XFS_CALC_ICHANGE_LOG_RES(mp) + XFS_DQUOT_LOGRES(mp));
-       resp->tr_growdata = (uint)XFS_CALC_GROWDATA_LOG_RES(mp);
-       resp->tr_swrite = (uint)XFS_CALC_SWRITE_LOG_RES(mp);
-       resp->tr_writeid = (uint)XFS_CALC_WRITEID_LOG_RES(mp);
-       resp->tr_addafork =
-               (uint)(XFS_CALC_ADDAFORK_LOG_RES(mp) + XFS_DQUOT_LOGRES(mp));
-       resp->tr_attrinval = (uint)XFS_CALC_ATTRINVAL_LOG_RES(mp);
-       resp->tr_attrset =
-               (uint)(XFS_CALC_ATTRSET_LOG_RES(mp) + XFS_DQUOT_LOGRES(mp));
-       resp->tr_attrrm =
-               (uint)(XFS_CALC_ATTRRM_LOG_RES(mp) + XFS_DQUOT_LOGRES(mp));
-       resp->tr_clearagi = (uint)XFS_CALC_CLEAR_AGI_BUCKET_LOG_RES(mp);
-       resp->tr_growrtalloc = (uint)XFS_CALC_GROWRTALLOC_LOG_RES(mp);
-       resp->tr_growrtzero = (uint)XFS_CALC_GROWRTZERO_LOG_RES(mp);
-       resp->tr_growrtfree = (uint)XFS_CALC_GROWRTFREE_LOG_RES(mp);
+       resp->tr_write = xfs_calc_write_reservation(mp);
+       resp->tr_itruncate = xfs_calc_itruncate_reservation(mp);
+       resp->tr_rename = xfs_calc_rename_reservation(mp);
+       resp->tr_link = xfs_calc_link_reservation(mp);
+       resp->tr_remove = xfs_calc_remove_reservation(mp);
+       resp->tr_symlink = xfs_calc_symlink_reservation(mp);
+       resp->tr_create = xfs_calc_create_reservation(mp);
+       resp->tr_mkdir = xfs_calc_mkdir_reservation(mp);
+       resp->tr_ifree = xfs_calc_ifree_reservation(mp);
+       resp->tr_ichange = xfs_calc_ichange_reservation(mp);
+       resp->tr_growdata = xfs_calc_growdata_reservation(mp);
+       resp->tr_swrite = xfs_calc_swrite_reservation(mp);
+       resp->tr_writeid = xfs_calc_writeid_reservation(mp);
+       resp->tr_addafork = xfs_calc_addafork_reservation(mp);
+       resp->tr_attrinval = xfs_calc_attrinval_reservation(mp);
+       resp->tr_attrset = xfs_calc_attrset_reservation(mp);
+       resp->tr_attrrm = xfs_calc_attrrm_reservation(mp);
+       resp->tr_clearagi = xfs_calc_clear_agi_bucket_reservation(mp);
+       resp->tr_growrtalloc = xfs_calc_growrtalloc_reservation(mp);
+       resp->tr_growrtzero = xfs_calc_growrtzero_reservation(mp);
+       resp->tr_growrtfree = xfs_calc_growrtfree_reservation(mp);
 }
 
 /*
@@ -371,7 +490,7 @@ xfs_trans_mod_sb(
        case XFS_TRANS_SB_RES_FREXTENTS:
                /*
                 * The allocation has already been applied to the
-                * in-core superblocks's counter.  This should only
+                * in-core superblock's counter.  This should only
                 * be applied to the on-disk superblock.
                 */
                ASSERT(delta < 0);
@@ -492,7 +611,7 @@ xfs_trans_apply_sb_deltas(
 
        if (whole)
                /*
-                * Log the whole thing, the fields are discontiguous.
+                * Log the whole thing, the fields are noncontiguous.
                 */
                xfs_trans_log_buf(tp, bp, 0, sizeof(xfs_sb_t) - 1);
        else
@@ -550,7 +669,7 @@ xfs_trans_unreserve_and_mod_sb(
        /*
         * Apply any superblock modifications to the in-core version.
         * The t_res_fdblocks_delta and t_res_frextents_delta fields are
-        * explicity NOT applied to the in-core superblock.
+        * explicitly NOT applied to the in-core superblock.
         * The idea is that that has already been done.
         */
        if (tp->t_flags & XFS_TRANS_SB_DIRTY) {
@@ -1014,6 +1133,7 @@ xfs_trans_cancel(
        xfs_log_item_t          *lip;
        int                     i;
 #endif
+       xfs_mount_t             *mp = tp->t_mountp;
 
        /*
         * See if the caller is being too lazy to figure out if
@@ -1026,9 +1146,10 @@ xfs_trans_cancel(
         * filesystem.  This happens in paths where we detect
         * corruption and decide to give up.
         */
-       if ((tp->t_flags & XFS_TRANS_DIRTY) &&
-           !XFS_FORCED_SHUTDOWN(tp->t_mountp))
-               xfs_force_shutdown(tp->t_mountp, XFS_CORRUPT_INCORE);
+       if ((tp->t_flags & XFS_TRANS_DIRTY) && !XFS_FORCED_SHUTDOWN(mp)) {
+               XFS_ERROR_REPORT("xfs_trans_cancel", XFS_ERRLEVEL_LOW, mp);
+               xfs_force_shutdown(mp, XFS_CORRUPT_INCORE);
+       }
 #ifdef DEBUG
        if (!(flags & XFS_TRANS_ABORT)) {
                licp = &(tp->t_items);
@@ -1040,7 +1161,7 @@ xfs_trans_cancel(
                                }
 
                                lip = lidp->lid_item;
-                               if (!XFS_FORCED_SHUTDOWN(tp->t_mountp))
+                               if (!XFS_FORCED_SHUTDOWN(mp))
                                        ASSERT(!(lip->li_type == XFS_LI_EFD));
                        }
                        licp = licp->lic_next;
@@ -1048,7 +1169,7 @@ xfs_trans_cancel(
        }
 #endif
        xfs_trans_unreserve_and_mod_sb(tp);
-       XFS_TRANS_UNRESERVE_AND_MOD_DQUOTS(tp->t_mountp, tp);
+       XFS_TRANS_UNRESERVE_AND_MOD_DQUOTS(mp, tp);
 
        if (tp->t_ticket) {
                if (flags & XFS_TRANS_RELEASE_LOG_RES) {
@@ -1057,7 +1178,7 @@ xfs_trans_cancel(
                } else {
                        log_flags = 0;
                }
-               xfs_log_done(tp->t_mountp, tp->t_ticket, NULL, log_flags);
+               xfs_log_done(mp, tp->t_ticket, NULL, log_flags);
        }
 
        /* mark this thread as no longer being in a transaction */