diff options
Diffstat (limited to 'fs/xfs/xfs_trans.c')
-rw-r--r-- | fs/xfs/xfs_trans.c | 48 |
1 files changed, 18 insertions, 30 deletions
diff --git a/fs/xfs/xfs_trans.c b/fs/xfs/xfs_trans.c index 8d056cef5d1f..ee2721e0de4d 100644 --- a/fs/xfs/xfs_trans.c +++ b/fs/xfs/xfs_trans.c | |||
@@ -24,7 +24,6 @@ | |||
24 | #include "xfs_trans.h" | 24 | #include "xfs_trans.h" |
25 | #include "xfs_sb.h" | 25 | #include "xfs_sb.h" |
26 | #include "xfs_ag.h" | 26 | #include "xfs_ag.h" |
27 | #include "xfs_dir.h" | ||
28 | #include "xfs_dir2.h" | 27 | #include "xfs_dir2.h" |
29 | #include "xfs_dmapi.h" | 28 | #include "xfs_dmapi.h" |
30 | #include "xfs_mount.h" | 29 | #include "xfs_mount.h" |
@@ -33,7 +32,6 @@ | |||
33 | #include "xfs_bmap_btree.h" | 32 | #include "xfs_bmap_btree.h" |
34 | #include "xfs_alloc_btree.h" | 33 | #include "xfs_alloc_btree.h" |
35 | #include "xfs_ialloc_btree.h" | 34 | #include "xfs_ialloc_btree.h" |
36 | #include "xfs_dir_sf.h" | ||
37 | #include "xfs_dir2_sf.h" | 35 | #include "xfs_dir2_sf.h" |
38 | #include "xfs_attr_sf.h" | 36 | #include "xfs_attr_sf.h" |
39 | #include "xfs_dinode.h" | 37 | #include "xfs_dinode.h" |
@@ -236,11 +234,8 @@ xfs_trans_alloc( | |||
236 | xfs_mount_t *mp, | 234 | xfs_mount_t *mp, |
237 | uint type) | 235 | uint type) |
238 | { | 236 | { |
239 | fs_check_frozen(XFS_MTOVFS(mp), SB_FREEZE_TRANS); | 237 | vfs_wait_for_freeze(XFS_MTOVFS(mp), SB_FREEZE_TRANS); |
240 | atomic_inc(&mp->m_active_trans); | 238 | return _xfs_trans_alloc(mp, type); |
241 | |||
242 | return (_xfs_trans_alloc(mp, type)); | ||
243 | |||
244 | } | 239 | } |
245 | 240 | ||
246 | xfs_trans_t * | 241 | xfs_trans_t * |
@@ -250,12 +245,9 @@ _xfs_trans_alloc( | |||
250 | { | 245 | { |
251 | xfs_trans_t *tp; | 246 | xfs_trans_t *tp; |
252 | 247 | ||
253 | ASSERT(xfs_trans_zone != NULL); | 248 | atomic_inc(&mp->m_active_trans); |
254 | tp = kmem_zone_zalloc(xfs_trans_zone, KM_SLEEP); | ||
255 | 249 | ||
256 | /* | 250 | tp = kmem_zone_zalloc(xfs_trans_zone, KM_SLEEP); |
257 | * Initialize the transaction structure. | ||
258 | */ | ||
259 | tp->t_magic = XFS_TRANS_MAGIC; | 251 | tp->t_magic = XFS_TRANS_MAGIC; |
260 | tp->t_type = type; | 252 | tp->t_type = type; |
261 | tp->t_mountp = mp; | 253 | tp->t_mountp = mp; |
@@ -263,8 +255,7 @@ _xfs_trans_alloc( | |||
263 | tp->t_busy_free = XFS_LBC_NUM_SLOTS; | 255 | tp->t_busy_free = XFS_LBC_NUM_SLOTS; |
264 | XFS_LIC_INIT(&(tp->t_items)); | 256 | XFS_LIC_INIT(&(tp->t_items)); |
265 | XFS_LBC_INIT(&(tp->t_busy)); | 257 | XFS_LBC_INIT(&(tp->t_busy)); |
266 | 258 | return tp; | |
267 | return (tp); | ||
268 | } | 259 | } |
269 | 260 | ||
270 | /* | 261 | /* |
@@ -303,7 +294,7 @@ xfs_trans_dup( | |||
303 | tp->t_blk_res = tp->t_blk_res_used; | 294 | tp->t_blk_res = tp->t_blk_res_used; |
304 | ntp->t_rtx_res = tp->t_rtx_res - tp->t_rtx_res_used; | 295 | ntp->t_rtx_res = tp->t_rtx_res - tp->t_rtx_res_used; |
305 | tp->t_rtx_res = tp->t_rtx_res_used; | 296 | tp->t_rtx_res = tp->t_rtx_res_used; |
306 | PFLAGS_DUP(&tp->t_pflags, &ntp->t_pflags); | 297 | ntp->t_pflags = tp->t_pflags; |
307 | 298 | ||
308 | XFS_TRANS_DUP_DQINFO(tp->t_mountp, tp, ntp); | 299 | XFS_TRANS_DUP_DQINFO(tp->t_mountp, tp, ntp); |
309 | 300 | ||
@@ -335,14 +326,11 @@ xfs_trans_reserve( | |||
335 | uint logcount) | 326 | uint logcount) |
336 | { | 327 | { |
337 | int log_flags; | 328 | int log_flags; |
338 | int error; | 329 | int error = 0; |
339 | int rsvd; | 330 | int rsvd = (tp->t_flags & XFS_TRANS_RESERVE) != 0; |
340 | |||
341 | error = 0; | ||
342 | rsvd = (tp->t_flags & XFS_TRANS_RESERVE) != 0; | ||
343 | 331 | ||
344 | /* Mark this thread as being in a transaction */ | 332 | /* Mark this thread as being in a transaction */ |
345 | PFLAGS_SET_FSTRANS(&tp->t_pflags); | 333 | current_set_flags_nested(&tp->t_pflags, PF_FSTRANS); |
346 | 334 | ||
347 | /* | 335 | /* |
348 | * Attempt to reserve the needed disk blocks by decrementing | 336 | * Attempt to reserve the needed disk blocks by decrementing |
@@ -353,7 +341,7 @@ xfs_trans_reserve( | |||
353 | error = xfs_mod_incore_sb(tp->t_mountp, XFS_SBS_FDBLOCKS, | 341 | error = xfs_mod_incore_sb(tp->t_mountp, XFS_SBS_FDBLOCKS, |
354 | -blocks, rsvd); | 342 | -blocks, rsvd); |
355 | if (error != 0) { | 343 | if (error != 0) { |
356 | PFLAGS_RESTORE_FSTRANS(&tp->t_pflags); | 344 | current_restore_flags_nested(&tp->t_pflags, PF_FSTRANS); |
357 | return (XFS_ERROR(ENOSPC)); | 345 | return (XFS_ERROR(ENOSPC)); |
358 | } | 346 | } |
359 | tp->t_blk_res += blocks; | 347 | tp->t_blk_res += blocks; |
@@ -426,9 +414,9 @@ undo_blocks: | |||
426 | tp->t_blk_res = 0; | 414 | tp->t_blk_res = 0; |
427 | } | 415 | } |
428 | 416 | ||
429 | PFLAGS_RESTORE_FSTRANS(&tp->t_pflags); | 417 | current_restore_flags_nested(&tp->t_pflags, PF_FSTRANS); |
430 | 418 | ||
431 | return (error); | 419 | return error; |
432 | } | 420 | } |
433 | 421 | ||
434 | 422 | ||
@@ -819,7 +807,7 @@ shut_us_down: | |||
819 | if (commit_lsn == -1 && !shutdown) | 807 | if (commit_lsn == -1 && !shutdown) |
820 | shutdown = XFS_ERROR(EIO); | 808 | shutdown = XFS_ERROR(EIO); |
821 | } | 809 | } |
822 | PFLAGS_RESTORE_FSTRANS(&tp->t_pflags); | 810 | current_restore_flags_nested(&tp->t_pflags, PF_FSTRANS); |
823 | xfs_trans_free_items(tp, shutdown? XFS_TRANS_ABORT : 0); | 811 | xfs_trans_free_items(tp, shutdown? XFS_TRANS_ABORT : 0); |
824 | xfs_trans_free_busy(tp); | 812 | xfs_trans_free_busy(tp); |
825 | xfs_trans_free(tp); | 813 | xfs_trans_free(tp); |
@@ -846,7 +834,7 @@ shut_us_down: | |||
846 | */ | 834 | */ |
847 | nvec = xfs_trans_count_vecs(tp); | 835 | nvec = xfs_trans_count_vecs(tp); |
848 | if (nvec == 0) { | 836 | if (nvec == 0) { |
849 | xfs_force_shutdown(mp, XFS_LOG_IO_ERROR); | 837 | xfs_force_shutdown(mp, SHUTDOWN_LOG_IO_ERROR); |
850 | goto shut_us_down; | 838 | goto shut_us_down; |
851 | } else if (nvec <= XFS_TRANS_LOGVEC_COUNT) { | 839 | } else if (nvec <= XFS_TRANS_LOGVEC_COUNT) { |
852 | log_vector = log_vector_fast; | 840 | log_vector = log_vector_fast; |
@@ -884,7 +872,7 @@ shut_us_down: | |||
884 | * had pinned, clean up, free trans structure, and return error. | 872 | * had pinned, clean up, free trans structure, and return error. |
885 | */ | 873 | */ |
886 | if (error || commit_lsn == -1) { | 874 | if (error || commit_lsn == -1) { |
887 | PFLAGS_RESTORE_FSTRANS(&tp->t_pflags); | 875 | current_restore_flags_nested(&tp->t_pflags, PF_FSTRANS); |
888 | xfs_trans_uncommit(tp, flags|XFS_TRANS_ABORT); | 876 | xfs_trans_uncommit(tp, flags|XFS_TRANS_ABORT); |
889 | return XFS_ERROR(EIO); | 877 | return XFS_ERROR(EIO); |
890 | } | 878 | } |
@@ -926,7 +914,7 @@ shut_us_down: | |||
926 | /* | 914 | /* |
927 | * Mark this thread as no longer being in a transaction | 915 | * Mark this thread as no longer being in a transaction |
928 | */ | 916 | */ |
929 | PFLAGS_RESTORE_FSTRANS(&tp->t_pflags); | 917 | current_restore_flags_nested(&tp->t_pflags, PF_FSTRANS); |
930 | 918 | ||
931 | /* | 919 | /* |
932 | * Once all the items of the transaction have been copied | 920 | * Once all the items of the transaction have been copied |
@@ -1148,7 +1136,7 @@ xfs_trans_cancel( | |||
1148 | */ | 1136 | */ |
1149 | if ((tp->t_flags & XFS_TRANS_DIRTY) && !XFS_FORCED_SHUTDOWN(mp)) { | 1137 | if ((tp->t_flags & XFS_TRANS_DIRTY) && !XFS_FORCED_SHUTDOWN(mp)) { |
1150 | XFS_ERROR_REPORT("xfs_trans_cancel", XFS_ERRLEVEL_LOW, mp); | 1138 | XFS_ERROR_REPORT("xfs_trans_cancel", XFS_ERRLEVEL_LOW, mp); |
1151 | xfs_force_shutdown(mp, XFS_CORRUPT_INCORE); | 1139 | xfs_force_shutdown(mp, SHUTDOWN_CORRUPT_INCORE); |
1152 | } | 1140 | } |
1153 | #ifdef DEBUG | 1141 | #ifdef DEBUG |
1154 | if (!(flags & XFS_TRANS_ABORT)) { | 1142 | if (!(flags & XFS_TRANS_ABORT)) { |
@@ -1182,7 +1170,7 @@ xfs_trans_cancel( | |||
1182 | } | 1170 | } |
1183 | 1171 | ||
1184 | /* mark this thread as no longer being in a transaction */ | 1172 | /* mark this thread as no longer being in a transaction */ |
1185 | PFLAGS_RESTORE_FSTRANS(&tp->t_pflags); | 1173 | current_restore_flags_nested(&tp->t_pflags, PF_FSTRANS); |
1186 | 1174 | ||
1187 | xfs_trans_free_items(tp, flags); | 1175 | xfs_trans_free_items(tp, flags); |
1188 | xfs_trans_free_busy(tp); | 1176 | xfs_trans_free_busy(tp); |