20
20
#include <linux/slab.h>
21
21
#include <linux/blkdev.h>
22
22
#include <linux/list_sort.h>
23
- #include "ctree.h"
24
- #include "transaction.h"
23
+ #include "tree-log.h"
25
24
#include "disk-io.h"
26
25
#include "locking.h"
27
26
#include "print-tree.h"
28
27
#include "backref.h"
29
- #include "tree-log.h"
30
28
#include "hash.h"
31
29
32
30
/* magic values for the inode_only field in btrfs_log_inode:
@@ -144,12 +142,10 @@ static int start_log_trans(struct btrfs_trans_handle *trans,
144
142
145
143
mutex_lock (& root -> log_mutex );
146
144
if (root -> log_root ) {
147
- if (ACCESS_ONCE (root -> fs_info -> last_trans_log_full_commit ) ==
148
- trans -> transid ) {
145
+ if (btrfs_need_log_full_commit (root -> fs_info , trans )) {
149
146
ret = - EAGAIN ;
150
147
goto out ;
151
148
}
152
-
153
149
if (!root -> log_start_pid ) {
154
150
root -> log_start_pid = current -> pid ;
155
151
clear_bit (BTRFS_ROOT_MULTI_LOG_TASKS , & root -> state );
@@ -2512,8 +2508,7 @@ int btrfs_sync_log(struct btrfs_trans_handle *trans,
2512
2508
}
2513
2509
2514
2510
/* bail out if we need to do a full commit */
2515
- if (ACCESS_ONCE (root -> fs_info -> last_trans_log_full_commit ) ==
2516
- trans -> transid ) {
2511
+ if (btrfs_need_log_full_commit (root -> fs_info , trans )) {
2517
2512
ret = - EAGAIN ;
2518
2513
btrfs_free_logged_extents (log , log_transid );
2519
2514
mutex_unlock (& root -> log_mutex );
@@ -2534,8 +2529,7 @@ int btrfs_sync_log(struct btrfs_trans_handle *trans,
2534
2529
blk_finish_plug (& plug );
2535
2530
btrfs_abort_transaction (trans , root , ret );
2536
2531
btrfs_free_logged_extents (log , log_transid );
2537
- ACCESS_ONCE (root -> fs_info -> last_trans_log_full_commit ) =
2538
- trans -> transid ;
2532
+ btrfs_set_log_full_commit (root -> fs_info , trans );
2539
2533
mutex_unlock (& root -> log_mutex );
2540
2534
goto out ;
2541
2535
}
@@ -2578,8 +2572,8 @@ int btrfs_sync_log(struct btrfs_trans_handle *trans,
2578
2572
list_del_init (& root_log_ctx .list );
2579
2573
2580
2574
blk_finish_plug (& plug );
2581
- ACCESS_ONCE (root -> fs_info -> last_trans_log_full_commit ) =
2582
- trans -> transid ;
2575
+ btrfs_set_log_full_commit (root -> fs_info , trans );
2576
+
2583
2577
if (ret != - ENOSPC ) {
2584
2578
btrfs_abort_transaction (trans , root , ret );
2585
2579
mutex_unlock (& log_root_tree -> log_mutex );
@@ -2623,8 +2617,7 @@ int btrfs_sync_log(struct btrfs_trans_handle *trans,
2623
2617
* now that we've moved on to the tree of log tree roots,
2624
2618
* check the full commit flag again
2625
2619
*/
2626
- if (ACCESS_ONCE (root -> fs_info -> last_trans_log_full_commit ) ==
2627
- trans -> transid ) {
2620
+ if (btrfs_need_log_full_commit (root -> fs_info , trans )) {
2628
2621
blk_finish_plug (& plug );
2629
2622
btrfs_wait_marked_extents (log , & log -> dirty_log_pages , mark );
2630
2623
btrfs_free_logged_extents (log , log_transid );
@@ -2638,8 +2631,7 @@ int btrfs_sync_log(struct btrfs_trans_handle *trans,
2638
2631
EXTENT_DIRTY | EXTENT_NEW );
2639
2632
blk_finish_plug (& plug );
2640
2633
if (ret ) {
2641
- ACCESS_ONCE (root -> fs_info -> last_trans_log_full_commit ) =
2642
- trans -> transid ;
2634
+ btrfs_set_log_full_commit (root -> fs_info , trans );
2643
2635
btrfs_abort_transaction (trans , root , ret );
2644
2636
btrfs_free_logged_extents (log , log_transid );
2645
2637
mutex_unlock (& log_root_tree -> log_mutex );
@@ -2668,8 +2660,7 @@ int btrfs_sync_log(struct btrfs_trans_handle *trans,
2668
2660
*/
2669
2661
ret = write_ctree_super (trans , root -> fs_info -> tree_root , 1 );
2670
2662
if (ret ) {
2671
- ACCESS_ONCE (root -> fs_info -> last_trans_log_full_commit ) =
2672
- trans -> transid ;
2663
+ btrfs_set_log_full_commit (root -> fs_info , trans );
2673
2664
btrfs_abort_transaction (trans , root , ret );
2674
2665
goto out_wake_log_root ;
2675
2666
}
@@ -2887,7 +2878,7 @@ int btrfs_del_dir_entries_in_log(struct btrfs_trans_handle *trans,
2887
2878
out_unlock :
2888
2879
mutex_unlock (& BTRFS_I (dir )-> log_mutex );
2889
2880
if (ret == - ENOSPC ) {
2890
- root -> fs_info -> last_trans_log_full_commit = trans -> transid ;
2881
+ btrfs_set_log_full_commit ( root -> fs_info , trans ) ;
2891
2882
ret = 0 ;
2892
2883
} else if (ret < 0 )
2893
2884
btrfs_abort_transaction (trans , root , ret );
@@ -2920,7 +2911,7 @@ int btrfs_del_inode_ref_in_log(struct btrfs_trans_handle *trans,
2920
2911
dirid , & index );
2921
2912
mutex_unlock (& BTRFS_I (inode )-> log_mutex );
2922
2913
if (ret == - ENOSPC ) {
2923
- root -> fs_info -> last_trans_log_full_commit = trans -> transid ;
2914
+ btrfs_set_log_full_commit ( root -> fs_info , trans ) ;
2924
2915
ret = 0 ;
2925
2916
} else if (ret < 0 && ret != - ENOENT )
2926
2917
btrfs_abort_transaction (trans , root , ret );
@@ -4131,8 +4122,7 @@ static noinline int check_parent_dirs_for_sync(struct btrfs_trans_handle *trans,
4131
4122
* make sure any commits to the log are forced
4132
4123
* to be full commits
4133
4124
*/
4134
- root -> fs_info -> last_trans_log_full_commit =
4135
- trans -> transid ;
4125
+ btrfs_set_log_full_commit (root -> fs_info , trans );
4136
4126
ret = 1 ;
4137
4127
break ;
4138
4128
}
@@ -4178,6 +4168,10 @@ static int btrfs_log_inode_parent(struct btrfs_trans_handle *trans,
4178
4168
goto end_no_trans ;
4179
4169
}
4180
4170
4171
+ /*
4172
+ * The prev transaction commit doesn't complete, we need do
4173
+ * full commit by ourselves.
4174
+ */
4181
4175
if (root -> fs_info -> last_trans_log_full_commit >
4182
4176
root -> fs_info -> last_trans_committed ) {
4183
4177
ret = 1 ;
@@ -4247,7 +4241,7 @@ static int btrfs_log_inode_parent(struct btrfs_trans_handle *trans,
4247
4241
end_trans :
4248
4242
dput (old_parent );
4249
4243
if (ret < 0 ) {
4250
- root -> fs_info -> last_trans_log_full_commit = trans -> transid ;
4244
+ btrfs_set_log_full_commit ( root -> fs_info , trans ) ;
4251
4245
ret = 1 ;
4252
4246
}
4253
4247
0 commit comments