Revert to Fedora kernel-2.6.17-1.2187_FC5 patched with vs2.0.2.1; there are too many...
[linux-2.6.git] / fs / xfs / xfs_trans.c
index ee2721e..8d056ce 100644 (file)
@@ -24,6 +24,7 @@
 #include "xfs_trans.h"
 #include "xfs_sb.h"
 #include "xfs_ag.h"
+#include "xfs_dir.h"
 #include "xfs_dir2.h"
 #include "xfs_dmapi.h"
 #include "xfs_mount.h"
@@ -32,6 +33,7 @@
 #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"
@@ -234,8 +236,11 @@ xfs_trans_alloc(
        xfs_mount_t     *mp,
        uint            type)
 {
-       vfs_wait_for_freeze(XFS_MTOVFS(mp), SB_FREEZE_TRANS);
-       return _xfs_trans_alloc(mp, type);
+       fs_check_frozen(XFS_MTOVFS(mp), SB_FREEZE_TRANS);
+       atomic_inc(&mp->m_active_trans);
+
+       return (_xfs_trans_alloc(mp, type));
+
 }
 
 xfs_trans_t *
@@ -245,9 +250,12 @@ _xfs_trans_alloc(
 {
        xfs_trans_t     *tp;
 
-       atomic_inc(&mp->m_active_trans);
-
+       ASSERT(xfs_trans_zone != NULL);
        tp = kmem_zone_zalloc(xfs_trans_zone, KM_SLEEP);
+
+       /*
+        * Initialize the transaction structure.
+        */
        tp->t_magic = XFS_TRANS_MAGIC;
        tp->t_type = type;
        tp->t_mountp = mp;
@@ -255,7 +263,8 @@ _xfs_trans_alloc(
        tp->t_busy_free = XFS_LBC_NUM_SLOTS;
        XFS_LIC_INIT(&(tp->t_items));
        XFS_LBC_INIT(&(tp->t_busy));
-       return tp;
+
+       return (tp);
 }
 
 /*
@@ -294,7 +303,7 @@ xfs_trans_dup(
        tp->t_blk_res = tp->t_blk_res_used;
        ntp->t_rtx_res = tp->t_rtx_res - tp->t_rtx_res_used;
        tp->t_rtx_res = tp->t_rtx_res_used;
-       ntp->t_pflags = tp->t_pflags;
+       PFLAGS_DUP(&tp->t_pflags, &ntp->t_pflags);
 
        XFS_TRANS_DUP_DQINFO(tp->t_mountp, tp, ntp);
 
@@ -326,11 +335,14 @@ xfs_trans_reserve(
        uint            logcount)
 {
        int             log_flags;
-       int             error = 0;
-       int             rsvd = (tp->t_flags & XFS_TRANS_RESERVE) != 0;
+       int             error;
+       int     rsvd;
+
+       error = 0;
+       rsvd = (tp->t_flags & XFS_TRANS_RESERVE) != 0;
 
        /* Mark this thread as being in a transaction */
-       current_set_flags_nested(&tp->t_pflags, PF_FSTRANS);
+        PFLAGS_SET_FSTRANS(&tp->t_pflags);
 
        /*
         * Attempt to reserve the needed disk blocks by decrementing
@@ -341,7 +353,7 @@ xfs_trans_reserve(
                error = xfs_mod_incore_sb(tp->t_mountp, XFS_SBS_FDBLOCKS,
                                          -blocks, rsvd);
                if (error != 0) {
-                       current_restore_flags_nested(&tp->t_pflags, PF_FSTRANS);
+                        PFLAGS_RESTORE_FSTRANS(&tp->t_pflags);
                        return (XFS_ERROR(ENOSPC));
                }
                tp->t_blk_res += blocks;
@@ -414,9 +426,9 @@ undo_blocks:
                tp->t_blk_res = 0;
        }
 
-       current_restore_flags_nested(&tp->t_pflags, PF_FSTRANS);
+        PFLAGS_RESTORE_FSTRANS(&tp->t_pflags);
 
-       return error;
+       return (error);
 }
 
 
@@ -807,7 +819,7 @@ shut_us_down:
                        if (commit_lsn == -1 && !shutdown)
                                shutdown = XFS_ERROR(EIO);
                }
-               current_restore_flags_nested(&tp->t_pflags, PF_FSTRANS);
+                PFLAGS_RESTORE_FSTRANS(&tp->t_pflags);
                xfs_trans_free_items(tp, shutdown? XFS_TRANS_ABORT : 0);
                xfs_trans_free_busy(tp);
                xfs_trans_free(tp);
@@ -834,7 +846,7 @@ shut_us_down:
         */
        nvec = xfs_trans_count_vecs(tp);
        if (nvec == 0) {
-               xfs_force_shutdown(mp, SHUTDOWN_LOG_IO_ERROR);
+               xfs_force_shutdown(mp, XFS_LOG_IO_ERROR);
                goto shut_us_down;
        } else if (nvec <= XFS_TRANS_LOGVEC_COUNT) {
                log_vector = log_vector_fast;
@@ -872,7 +884,7 @@ shut_us_down:
         * had pinned, clean up, free trans structure, and return error.
         */
        if (error || commit_lsn == -1) {
-               current_restore_flags_nested(&tp->t_pflags, PF_FSTRANS);
+                PFLAGS_RESTORE_FSTRANS(&tp->t_pflags);
                xfs_trans_uncommit(tp, flags|XFS_TRANS_ABORT);
                return XFS_ERROR(EIO);
        }
@@ -914,7 +926,7 @@ shut_us_down:
        /*
         * Mark this thread as no longer being in a transaction
         */
-       current_restore_flags_nested(&tp->t_pflags, PF_FSTRANS);
+       PFLAGS_RESTORE_FSTRANS(&tp->t_pflags);
 
        /*
         * Once all the items of the transaction have been copied
@@ -1136,7 +1148,7 @@ xfs_trans_cancel(
         */
        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, SHUTDOWN_CORRUPT_INCORE);
+               xfs_force_shutdown(mp, XFS_CORRUPT_INCORE);
        }
 #ifdef DEBUG
        if (!(flags & XFS_TRANS_ABORT)) {
@@ -1170,7 +1182,7 @@ xfs_trans_cancel(
        }
 
        /* mark this thread as no longer being in a transaction */
-       current_restore_flags_nested(&tp->t_pflags, PF_FSTRANS);
+        PFLAGS_RESTORE_FSTRANS(&tp->t_pflags);
 
        xfs_trans_free_items(tp, flags);
        xfs_trans_free_busy(tp);