diff options
author | Josef Bacik <jbacik@fb.com> | 2016-09-02 15:40:02 -0400 |
---|---|---|
committer | David Sterba <dsterba@suse.com> | 2016-09-26 11:59:49 -0400 |
commit | afcdd129e05a9210a5d19d4aa6e0afa475fc49e2 (patch) | |
tree | 76ed00c65a4156d82101d02f1de662b374a05e1d | |
parent | ba8b04c1d4adbc66f3653e3de5bd6c74a9a003bf (diff) |
Btrfs: add a flags field to btrfs_fs_info
We have a lot of random ints in btrfs_fs_info that can be put into flags. This
is mostly equivalent with the exception of how we deal with quota going on or
off, now instead we set a flag when we are turning it on or off and deal with
that appropriately, rather than just having a pending state that the current
quota_enabled gets set to. Thanks,
Signed-off-by: Josef Bacik <jbacik@fb.com>
Signed-off-by: David Sterba <dsterba@suse.com>
-rw-r--r-- | fs/btrfs/btrfs_inode.h | 11 | ||||
-rw-r--r-- | fs/btrfs/ctree.h | 43 | ||||
-rw-r--r-- | fs/btrfs/delayed-inode.c | 3 | ||||
-rw-r--r-- | fs/btrfs/delayed-ref.c | 6 | ||||
-rw-r--r-- | fs/btrfs/disk-io.c | 23 | ||||
-rw-r--r-- | fs/btrfs/extent-tree.c | 14 | ||||
-rw-r--r-- | fs/btrfs/extent_io.c | 7 | ||||
-rw-r--r-- | fs/btrfs/free-space-tree.c | 6 | ||||
-rw-r--r-- | fs/btrfs/inode.c | 4 | ||||
-rw-r--r-- | fs/btrfs/qgroup.c | 55 | ||||
-rw-r--r-- | fs/btrfs/relocation.c | 2 | ||||
-rw-r--r-- | fs/btrfs/super.c | 2 | ||||
-rw-r--r-- | fs/btrfs/tests/qgroup-tests.c | 2 | ||||
-rw-r--r-- | fs/btrfs/transaction.c | 24 | ||||
-rw-r--r-- | fs/btrfs/tree-log.c | 4 | ||||
-rw-r--r-- | fs/btrfs/volumes.c | 2 |
16 files changed, 99 insertions, 109 deletions
diff --git a/fs/btrfs/btrfs_inode.h b/fs/btrfs/btrfs_inode.h index 4919aedb5fc1..1a8fa46ff87e 100644 --- a/fs/btrfs/btrfs_inode.h +++ b/fs/btrfs/btrfs_inode.h | |||
@@ -44,17 +44,6 @@ | |||
44 | #define BTRFS_INODE_IN_DELALLOC_LIST 9 | 44 | #define BTRFS_INODE_IN_DELALLOC_LIST 9 |
45 | #define BTRFS_INODE_READDIO_NEED_LOCK 10 | 45 | #define BTRFS_INODE_READDIO_NEED_LOCK 10 |
46 | #define BTRFS_INODE_HAS_PROPS 11 | 46 | #define BTRFS_INODE_HAS_PROPS 11 |
47 | /* | ||
48 | * The following 3 bits are meant only for the btree inode. | ||
49 | * When any of them is set, it means an error happened while writing an | ||
50 | * extent buffer belonging to: | ||
51 | * 1) a non-log btree | ||
52 | * 2) a log btree and first log sub-transaction | ||
53 | * 3) a log btree and second log sub-transaction | ||
54 | */ | ||
55 | #define BTRFS_INODE_BTREE_ERR 12 | ||
56 | #define BTRFS_INODE_BTREE_LOG1_ERR 13 | ||
57 | #define BTRFS_INODE_BTREE_LOG2_ERR 14 | ||
58 | 47 | ||
59 | /* in memory btrfs inode */ | 48 | /* in memory btrfs inode */ |
60 | struct btrfs_inode { | 49 | struct btrfs_inode { |
diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h index 176a61967a8a..2b7041ed4cb8 100644 --- a/fs/btrfs/ctree.h +++ b/fs/btrfs/ctree.h | |||
@@ -677,9 +677,25 @@ struct btrfs_device; | |||
677 | struct btrfs_fs_devices; | 677 | struct btrfs_fs_devices; |
678 | struct btrfs_balance_control; | 678 | struct btrfs_balance_control; |
679 | struct btrfs_delayed_root; | 679 | struct btrfs_delayed_root; |
680 | |||
681 | #define BTRFS_FS_BARRIER 1 | ||
682 | #define BTRFS_FS_CLOSING_START 2 | ||
683 | #define BTRFS_FS_CLOSING_DONE 3 | ||
684 | #define BTRFS_FS_LOG_RECOVERING 4 | ||
685 | #define BTRFS_FS_OPEN 5 | ||
686 | #define BTRFS_FS_QUOTA_ENABLED 6 | ||
687 | #define BTRFS_FS_QUOTA_ENABLING 7 | ||
688 | #define BTRFS_FS_QUOTA_DISABLING 8 | ||
689 | #define BTRFS_FS_UPDATE_UUID_TREE_GEN 9 | ||
690 | #define BTRFS_FS_CREATING_FREE_SPACE_TREE 10 | ||
691 | #define BTRFS_FS_BTREE_ERR 11 | ||
692 | #define BTRFS_FS_LOG1_ERR 12 | ||
693 | #define BTRFS_FS_LOG2_ERR 13 | ||
694 | |||
680 | struct btrfs_fs_info { | 695 | struct btrfs_fs_info { |
681 | u8 fsid[BTRFS_FSID_SIZE]; | 696 | u8 fsid[BTRFS_FSID_SIZE]; |
682 | u8 chunk_tree_uuid[BTRFS_UUID_SIZE]; | 697 | u8 chunk_tree_uuid[BTRFS_UUID_SIZE]; |
698 | unsigned long flags; | ||
683 | struct btrfs_root *extent_root; | 699 | struct btrfs_root *extent_root; |
684 | struct btrfs_root *tree_root; | 700 | struct btrfs_root *tree_root; |
685 | struct btrfs_root *chunk_root; | 701 | struct btrfs_root *chunk_root; |
@@ -908,10 +924,6 @@ struct btrfs_fs_info { | |||
908 | int thread_pool_size; | 924 | int thread_pool_size; |
909 | 925 | ||
910 | struct kobject *space_info_kobj; | 926 | struct kobject *space_info_kobj; |
911 | int do_barriers; | ||
912 | int closing; | ||
913 | int log_root_recovering; | ||
914 | int open; | ||
915 | 927 | ||
916 | u64 total_pinned; | 928 | u64 total_pinned; |
917 | 929 | ||
@@ -988,17 +1000,6 @@ struct btrfs_fs_info { | |||
988 | #ifdef CONFIG_BTRFS_FS_CHECK_INTEGRITY | 1000 | #ifdef CONFIG_BTRFS_FS_CHECK_INTEGRITY |
989 | u32 check_integrity_print_mask; | 1001 | u32 check_integrity_print_mask; |
990 | #endif | 1002 | #endif |
991 | /* | ||
992 | * quota information | ||
993 | */ | ||
994 | unsigned int quota_enabled:1; | ||
995 | |||
996 | /* | ||
997 | * quota_enabled only changes state after a commit. This holds the | ||
998 | * next state. | ||
999 | */ | ||
1000 | unsigned int pending_quota_state:1; | ||
1001 | |||
1002 | /* is qgroup tracking in a consistent state? */ | 1003 | /* is qgroup tracking in a consistent state? */ |
1003 | u64 qgroup_flags; | 1004 | u64 qgroup_flags; |
1004 | 1005 | ||
@@ -1062,7 +1063,6 @@ struct btrfs_fs_info { | |||
1062 | wait_queue_head_t replace_wait; | 1063 | wait_queue_head_t replace_wait; |
1063 | 1064 | ||
1064 | struct semaphore uuid_tree_rescan_sem; | 1065 | struct semaphore uuid_tree_rescan_sem; |
1065 | unsigned int update_uuid_tree_gen:1; | ||
1066 | 1066 | ||
1067 | /* Used to reclaim the metadata space in the background. */ | 1067 | /* Used to reclaim the metadata space in the background. */ |
1068 | struct work_struct async_reclaim_work; | 1068 | struct work_struct async_reclaim_work; |
@@ -1081,7 +1081,6 @@ struct btrfs_fs_info { | |||
1081 | */ | 1081 | */ |
1082 | struct list_head pinned_chunks; | 1082 | struct list_head pinned_chunks; |
1083 | 1083 | ||
1084 | int creating_free_space_tree; | ||
1085 | /* Used to record internally whether fs has been frozen */ | 1084 | /* Used to record internally whether fs has been frozen */ |
1086 | int fs_frozen; | 1085 | int fs_frozen; |
1087 | }; | 1086 | }; |
@@ -2868,10 +2867,14 @@ int btrfs_drop_subtree(struct btrfs_trans_handle *trans, | |||
2868 | static inline int btrfs_fs_closing(struct btrfs_fs_info *fs_info) | 2867 | static inline int btrfs_fs_closing(struct btrfs_fs_info *fs_info) |
2869 | { | 2868 | { |
2870 | /* | 2869 | /* |
2871 | * Get synced with close_ctree() | 2870 | * Do it this way so we only ever do one test_bit in the normal case. |
2872 | */ | 2871 | */ |
2873 | smp_mb(); | 2872 | if (test_bit(BTRFS_FS_CLOSING_START, &fs_info->flags)) { |
2874 | return fs_info->closing; | 2873 | if (test_bit(BTRFS_FS_CLOSING_DONE, &fs_info->flags)) |
2874 | return 2; | ||
2875 | return 1; | ||
2876 | } | ||
2877 | return 0; | ||
2875 | } | 2878 | } |
2876 | 2879 | ||
2877 | /* | 2880 | /* |
diff --git a/fs/btrfs/delayed-inode.c b/fs/btrfs/delayed-inode.c index 3eeb9cd8cfa5..982a168af2ce 100644 --- a/fs/btrfs/delayed-inode.c +++ b/fs/btrfs/delayed-inode.c | |||
@@ -1874,7 +1874,8 @@ int btrfs_delayed_delete_inode_ref(struct inode *inode) | |||
1874 | * leads to enospc problems. This means we also can't do | 1874 | * leads to enospc problems. This means we also can't do |
1875 | * delayed inode refs | 1875 | * delayed inode refs |
1876 | */ | 1876 | */ |
1877 | if (BTRFS_I(inode)->root->fs_info->log_root_recovering) | 1877 | if (test_bit(BTRFS_FS_LOG_RECOVERING, |
1878 | &BTRFS_I(inode)->root->fs_info->flags)) | ||
1878 | return -EAGAIN; | 1879 | return -EAGAIN; |
1879 | 1880 | ||
1880 | delayed_node = btrfs_get_or_create_delayed_node(inode); | 1881 | delayed_node = btrfs_get_or_create_delayed_node(inode); |
diff --git a/fs/btrfs/delayed-ref.c b/fs/btrfs/delayed-ref.c index ac02e041464b..a5d81f361d0b 100644 --- a/fs/btrfs/delayed-ref.c +++ b/fs/btrfs/delayed-ref.c | |||
@@ -770,7 +770,8 @@ int btrfs_add_delayed_tree_ref(struct btrfs_fs_info *fs_info, | |||
770 | if (!head_ref) | 770 | if (!head_ref) |
771 | goto free_ref; | 771 | goto free_ref; |
772 | 772 | ||
773 | if (fs_info->quota_enabled && is_fstree(ref_root)) { | 773 | if (test_bit(BTRFS_FS_QUOTA_ENABLED, &fs_info->flags) && |
774 | is_fstree(ref_root)) { | ||
774 | record = kmalloc(sizeof(*record), GFP_NOFS); | 775 | record = kmalloc(sizeof(*record), GFP_NOFS); |
775 | if (!record) | 776 | if (!record) |
776 | goto free_head_ref; | 777 | goto free_head_ref; |
@@ -828,7 +829,8 @@ int btrfs_add_delayed_data_ref(struct btrfs_fs_info *fs_info, | |||
828 | return -ENOMEM; | 829 | return -ENOMEM; |
829 | } | 830 | } |
830 | 831 | ||
831 | if (fs_info->quota_enabled && is_fstree(ref_root)) { | 832 | if (test_bit(BTRFS_FS_QUOTA_ENABLED, &fs_info->flags) && |
833 | is_fstree(ref_root)) { | ||
832 | record = kmalloc(sizeof(*record), GFP_NOFS); | 834 | record = kmalloc(sizeof(*record), GFP_NOFS); |
833 | if (!record) { | 835 | if (!record) { |
834 | kmem_cache_free(btrfs_delayed_data_ref_cachep, ref); | 836 | kmem_cache_free(btrfs_delayed_data_ref_cachep, ref); |
diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c index 754de24f17af..f92bfa8ffd41 100644 --- a/fs/btrfs/disk-io.c +++ b/fs/btrfs/disk-io.c | |||
@@ -1839,7 +1839,7 @@ static int cleaner_kthread(void *arg) | |||
1839 | * Do not do anything if we might cause open_ctree() to block | 1839 | * Do not do anything if we might cause open_ctree() to block |
1840 | * before we have finished mounting the filesystem. | 1840 | * before we have finished mounting the filesystem. |
1841 | */ | 1841 | */ |
1842 | if (!root->fs_info->open) | 1842 | if (!test_bit(BTRFS_FS_OPEN, &root->fs_info->flags)) |
1843 | goto sleep; | 1843 | goto sleep; |
1844 | 1844 | ||
1845 | if (!mutex_trylock(&root->fs_info->cleaner_mutex)) | 1845 | if (!mutex_trylock(&root->fs_info->cleaner_mutex)) |
@@ -2332,8 +2332,6 @@ static void btrfs_init_qgroup(struct btrfs_fs_info *fs_info) | |||
2332 | fs_info->qgroup_op_tree = RB_ROOT; | 2332 | fs_info->qgroup_op_tree = RB_ROOT; |
2333 | INIT_LIST_HEAD(&fs_info->dirty_qgroups); | 2333 | INIT_LIST_HEAD(&fs_info->dirty_qgroups); |
2334 | fs_info->qgroup_seq = 1; | 2334 | fs_info->qgroup_seq = 1; |
2335 | fs_info->quota_enabled = 0; | ||
2336 | fs_info->pending_quota_state = 0; | ||
2337 | fs_info->qgroup_ulist = NULL; | 2335 | fs_info->qgroup_ulist = NULL; |
2338 | fs_info->qgroup_rescan_running = false; | 2336 | fs_info->qgroup_rescan_running = false; |
2339 | mutex_init(&fs_info->qgroup_rescan_lock); | 2337 | mutex_init(&fs_info->qgroup_rescan_lock); |
@@ -2518,8 +2516,7 @@ static int btrfs_read_roots(struct btrfs_fs_info *fs_info, | |||
2518 | root = btrfs_read_tree_root(tree_root, &location); | 2516 | root = btrfs_read_tree_root(tree_root, &location); |
2519 | if (!IS_ERR(root)) { | 2517 | if (!IS_ERR(root)) { |
2520 | set_bit(BTRFS_ROOT_TRACK_DIRTY, &root->state); | 2518 | set_bit(BTRFS_ROOT_TRACK_DIRTY, &root->state); |
2521 | fs_info->quota_enabled = 1; | 2519 | set_bit(BTRFS_FS_QUOTA_ENABLED, &fs_info->flags); |
2522 | fs_info->pending_quota_state = 1; | ||
2523 | fs_info->quota_root = root; | 2520 | fs_info->quota_root = root; |
2524 | } | 2521 | } |
2525 | 2522 | ||
@@ -2710,8 +2707,7 @@ int open_ctree(struct super_block *sb, | |||
2710 | extent_io_tree_init(&fs_info->freed_extents[1], | 2707 | extent_io_tree_init(&fs_info->freed_extents[1], |
2711 | fs_info->btree_inode->i_mapping); | 2708 | fs_info->btree_inode->i_mapping); |
2712 | fs_info->pinned_extents = &fs_info->freed_extents[0]; | 2709 | fs_info->pinned_extents = &fs_info->freed_extents[0]; |
2713 | fs_info->do_barriers = 1; | 2710 | set_bit(BTRFS_FS_BARRIER, &fs_info->flags); |
2714 | |||
2715 | 2711 | ||
2716 | mutex_init(&fs_info->ordered_operations_mutex); | 2712 | mutex_init(&fs_info->ordered_operations_mutex); |
2717 | mutex_init(&fs_info->tree_log_mutex); | 2713 | mutex_init(&fs_info->tree_log_mutex); |
@@ -3199,10 +3195,9 @@ retry_root_backup: | |||
3199 | return ret; | 3195 | return ret; |
3200 | } | 3196 | } |
3201 | } else { | 3197 | } else { |
3202 | fs_info->update_uuid_tree_gen = 1; | 3198 | set_bit(BTRFS_FS_UPDATE_UUID_TREE_GEN, &fs_info->flags); |
3203 | } | 3199 | } |
3204 | 3200 | set_bit(BTRFS_FS_OPEN, &fs_info->flags); | |
3205 | fs_info->open = 1; | ||
3206 | 3201 | ||
3207 | /* | 3202 | /* |
3208 | * backuproot only affect mount behavior, and if open_ctree succeeded, | 3203 | * backuproot only affect mount behavior, and if open_ctree succeeded, |
@@ -3893,8 +3888,7 @@ void close_ctree(struct btrfs_root *root) | |||
3893 | struct btrfs_fs_info *fs_info = root->fs_info; | 3888 | struct btrfs_fs_info *fs_info = root->fs_info; |
3894 | int ret; | 3889 | int ret; |
3895 | 3890 | ||
3896 | fs_info->closing = 1; | 3891 | set_bit(BTRFS_FS_CLOSING_START, &fs_info->flags); |
3897 | smp_mb(); | ||
3898 | 3892 | ||
3899 | /* wait for the qgroup rescan worker to stop */ | 3893 | /* wait for the qgroup rescan worker to stop */ |
3900 | btrfs_qgroup_wait_for_completion(fs_info, false); | 3894 | btrfs_qgroup_wait_for_completion(fs_info, false); |
@@ -3939,8 +3933,7 @@ void close_ctree(struct btrfs_root *root) | |||
3939 | kthread_stop(fs_info->transaction_kthread); | 3933 | kthread_stop(fs_info->transaction_kthread); |
3940 | kthread_stop(fs_info->cleaner_kthread); | 3934 | kthread_stop(fs_info->cleaner_kthread); |
3941 | 3935 | ||
3942 | fs_info->closing = 2; | 3936 | set_bit(BTRFS_FS_CLOSING_DONE, &fs_info->flags); |
3943 | smp_mb(); | ||
3944 | 3937 | ||
3945 | btrfs_free_qgroup_config(fs_info); | 3938 | btrfs_free_qgroup_config(fs_info); |
3946 | 3939 | ||
@@ -3965,7 +3958,7 @@ void close_ctree(struct btrfs_root *root) | |||
3965 | invalidate_inode_pages2(fs_info->btree_inode->i_mapping); | 3958 | invalidate_inode_pages2(fs_info->btree_inode->i_mapping); |
3966 | btrfs_stop_all_workers(fs_info); | 3959 | btrfs_stop_all_workers(fs_info); |
3967 | 3960 | ||
3968 | fs_info->open = 0; | 3961 | clear_bit(BTRFS_FS_OPEN, &fs_info->flags); |
3969 | free_root_pointers(fs_info, 1); | 3962 | free_root_pointers(fs_info, 1); |
3970 | 3963 | ||
3971 | iput(fs_info->btree_inode); | 3964 | iput(fs_info->btree_inode); |
diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c index e9d60607a0bd..3e360132a2b7 100644 --- a/fs/btrfs/extent-tree.c +++ b/fs/btrfs/extent-tree.c | |||
@@ -2940,7 +2940,7 @@ int btrfs_run_delayed_refs(struct btrfs_trans_handle *trans, | |||
2940 | if (trans->aborted) | 2940 | if (trans->aborted) |
2941 | return 0; | 2941 | return 0; |
2942 | 2942 | ||
2943 | if (root->fs_info->creating_free_space_tree) | 2943 | if (test_bit(BTRFS_FS_CREATING_FREE_SPACE_TREE, &root->fs_info->flags)) |
2944 | return 0; | 2944 | return 0; |
2945 | 2945 | ||
2946 | if (root == root->fs_info->extent_root) | 2946 | if (root == root->fs_info->extent_root) |
@@ -5188,7 +5188,7 @@ static int __reserve_metadata_bytes(struct btrfs_root *root, | |||
5188 | * which means we won't have fs_info->fs_root set, so don't do | 5188 | * which means we won't have fs_info->fs_root set, so don't do |
5189 | * the async reclaim as we will panic. | 5189 | * the async reclaim as we will panic. |
5190 | */ | 5190 | */ |
5191 | if (!root->fs_info->log_root_recovering && | 5191 | if (!test_bit(BTRFS_FS_LOG_RECOVERING, &root->fs_info->flags) && |
5192 | need_do_async_reclaim(space_info, root, used) && | 5192 | need_do_async_reclaim(space_info, root, used) && |
5193 | !work_busy(&root->fs_info->async_reclaim_work)) { | 5193 | !work_busy(&root->fs_info->async_reclaim_work)) { |
5194 | trace_btrfs_trigger_flush(root->fs_info, | 5194 | trace_btrfs_trigger_flush(root->fs_info, |
@@ -5794,7 +5794,7 @@ int btrfs_subvolume_reserve_metadata(struct btrfs_root *root, | |||
5794 | int ret; | 5794 | int ret; |
5795 | struct btrfs_block_rsv *global_rsv = &root->fs_info->global_block_rsv; | 5795 | struct btrfs_block_rsv *global_rsv = &root->fs_info->global_block_rsv; |
5796 | 5796 | ||
5797 | if (root->fs_info->quota_enabled) { | 5797 | if (test_bit(BTRFS_FS_QUOTA_ENABLED, &root->fs_info->flags)) { |
5798 | /* One for parent inode, two for dir entries */ | 5798 | /* One for parent inode, two for dir entries */ |
5799 | num_bytes = 3 * root->nodesize; | 5799 | num_bytes = 3 * root->nodesize; |
5800 | ret = btrfs_qgroup_reserve_meta(root, num_bytes); | 5800 | ret = btrfs_qgroup_reserve_meta(root, num_bytes); |
@@ -5972,7 +5972,7 @@ int btrfs_delalloc_reserve_metadata(struct inode *inode, u64 num_bytes) | |||
5972 | csum_bytes = BTRFS_I(inode)->csum_bytes; | 5972 | csum_bytes = BTRFS_I(inode)->csum_bytes; |
5973 | spin_unlock(&BTRFS_I(inode)->lock); | 5973 | spin_unlock(&BTRFS_I(inode)->lock); |
5974 | 5974 | ||
5975 | if (root->fs_info->quota_enabled) { | 5975 | if (test_bit(BTRFS_FS_QUOTA_ENABLED, &root->fs_info->flags)) { |
5976 | ret = btrfs_qgroup_reserve_meta(root, | 5976 | ret = btrfs_qgroup_reserve_meta(root, |
5977 | nr_extents * root->nodesize); | 5977 | nr_extents * root->nodesize); |
5978 | if (ret) | 5978 | if (ret) |
@@ -8544,7 +8544,7 @@ static int account_leaf_items(struct btrfs_trans_handle *trans, | |||
8544 | u64 bytenr, num_bytes; | 8544 | u64 bytenr, num_bytes; |
8545 | 8545 | ||
8546 | /* We can be called directly from walk_up_proc() */ | 8546 | /* We can be called directly from walk_up_proc() */ |
8547 | if (!root->fs_info->quota_enabled) | 8547 | if (!test_bit(BTRFS_FS_QUOTA_ENABLED, &root->fs_info->flags)) |
8548 | return 0; | 8548 | return 0; |
8549 | 8549 | ||
8550 | for (i = 0; i < nr; i++) { | 8550 | for (i = 0; i < nr; i++) { |
@@ -8653,7 +8653,7 @@ static int account_shared_subtree(struct btrfs_trans_handle *trans, | |||
8653 | BUG_ON(root_level < 0 || root_level > BTRFS_MAX_LEVEL); | 8653 | BUG_ON(root_level < 0 || root_level > BTRFS_MAX_LEVEL); |
8654 | BUG_ON(root_eb == NULL); | 8654 | BUG_ON(root_eb == NULL); |
8655 | 8655 | ||
8656 | if (!root->fs_info->quota_enabled) | 8656 | if (!test_bit(BTRFS_FS_QUOTA_ENABLED, &root->fs_info->flags)) |
8657 | return 0; | 8657 | return 0; |
8658 | 8658 | ||
8659 | if (!extent_buffer_uptodate(root_eb)) { | 8659 | if (!extent_buffer_uptodate(root_eb)) { |
@@ -10803,7 +10803,7 @@ void btrfs_delete_unused_bgs(struct btrfs_fs_info *fs_info) | |||
10803 | struct btrfs_trans_handle *trans; | 10803 | struct btrfs_trans_handle *trans; |
10804 | int ret = 0; | 10804 | int ret = 0; |
10805 | 10805 | ||
10806 | if (!fs_info->open) | 10806 | if (!test_bit(BTRFS_FS_OPEN, &fs_info->flags)) |
10807 | return; | 10807 | return; |
10808 | 10808 | ||
10809 | spin_lock(&fs_info->unused_bgs_lock); | 10809 | spin_lock(&fs_info->unused_bgs_lock); |
diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c index e26e3feca500..14ab8576cc93 100644 --- a/fs/btrfs/extent_io.c +++ b/fs/btrfs/extent_io.c | |||
@@ -3625,7 +3625,6 @@ static void end_extent_buffer_writeback(struct extent_buffer *eb) | |||
3625 | static void set_btree_ioerr(struct page *page) | 3625 | static void set_btree_ioerr(struct page *page) |
3626 | { | 3626 | { |
3627 | struct extent_buffer *eb = (struct extent_buffer *)page->private; | 3627 | struct extent_buffer *eb = (struct extent_buffer *)page->private; |
3628 | struct btrfs_inode *btree_ino = BTRFS_I(eb->fs_info->btree_inode); | ||
3629 | 3628 | ||
3630 | SetPageError(page); | 3629 | SetPageError(page); |
3631 | if (test_and_set_bit(EXTENT_BUFFER_WRITE_ERR, &eb->bflags)) | 3630 | if (test_and_set_bit(EXTENT_BUFFER_WRITE_ERR, &eb->bflags)) |
@@ -3671,13 +3670,13 @@ static void set_btree_ioerr(struct page *page) | |||
3671 | */ | 3670 | */ |
3672 | switch (eb->log_index) { | 3671 | switch (eb->log_index) { |
3673 | case -1: | 3672 | case -1: |
3674 | set_bit(BTRFS_INODE_BTREE_ERR, &btree_ino->runtime_flags); | 3673 | set_bit(BTRFS_FS_BTREE_ERR, &eb->fs_info->flags); |
3675 | break; | 3674 | break; |
3676 | case 0: | 3675 | case 0: |
3677 | set_bit(BTRFS_INODE_BTREE_LOG1_ERR, &btree_ino->runtime_flags); | 3676 | set_bit(BTRFS_FS_LOG1_ERR, &eb->fs_info->flags); |
3678 | break; | 3677 | break; |
3679 | case 1: | 3678 | case 1: |
3680 | set_bit(BTRFS_INODE_BTREE_LOG2_ERR, &btree_ino->runtime_flags); | 3679 | set_bit(BTRFS_FS_LOG2_ERR, &eb->fs_info->flags); |
3681 | break; | 3680 | break; |
3682 | default: | 3681 | default: |
3683 | BUG(); /* unexpected, logic error */ | 3682 | BUG(); /* unexpected, logic error */ |
diff --git a/fs/btrfs/free-space-tree.c b/fs/btrfs/free-space-tree.c index 87e7e3d3e676..83ee63bdca96 100644 --- a/fs/btrfs/free-space-tree.c +++ b/fs/btrfs/free-space-tree.c | |||
@@ -1163,7 +1163,7 @@ int btrfs_create_free_space_tree(struct btrfs_fs_info *fs_info) | |||
1163 | if (IS_ERR(trans)) | 1163 | if (IS_ERR(trans)) |
1164 | return PTR_ERR(trans); | 1164 | return PTR_ERR(trans); |
1165 | 1165 | ||
1166 | fs_info->creating_free_space_tree = 1; | 1166 | set_bit(BTRFS_FS_CREATING_FREE_SPACE_TREE, &fs_info->flags); |
1167 | free_space_root = btrfs_create_tree(trans, fs_info, | 1167 | free_space_root = btrfs_create_tree(trans, fs_info, |
1168 | BTRFS_FREE_SPACE_TREE_OBJECTID); | 1168 | BTRFS_FREE_SPACE_TREE_OBJECTID); |
1169 | if (IS_ERR(free_space_root)) { | 1169 | if (IS_ERR(free_space_root)) { |
@@ -1183,7 +1183,7 @@ int btrfs_create_free_space_tree(struct btrfs_fs_info *fs_info) | |||
1183 | } | 1183 | } |
1184 | 1184 | ||
1185 | btrfs_set_fs_compat_ro(fs_info, FREE_SPACE_TREE); | 1185 | btrfs_set_fs_compat_ro(fs_info, FREE_SPACE_TREE); |
1186 | fs_info->creating_free_space_tree = 0; | 1186 | clear_bit(BTRFS_FS_CREATING_FREE_SPACE_TREE, &fs_info->flags); |
1187 | 1187 | ||
1188 | ret = btrfs_commit_transaction(trans, tree_root); | 1188 | ret = btrfs_commit_transaction(trans, tree_root); |
1189 | if (ret) | 1189 | if (ret) |
@@ -1192,7 +1192,7 @@ int btrfs_create_free_space_tree(struct btrfs_fs_info *fs_info) | |||
1192 | return 0; | 1192 | return 0; |
1193 | 1193 | ||
1194 | abort: | 1194 | abort: |
1195 | fs_info->creating_free_space_tree = 0; | 1195 | clear_bit(BTRFS_FS_CREATING_FREE_SPACE_TREE, &fs_info->flags); |
1196 | btrfs_abort_transaction(trans, ret); | 1196 | btrfs_abort_transaction(trans, ret); |
1197 | btrfs_end_transaction(trans, tree_root); | 1197 | btrfs_end_transaction(trans, tree_root); |
1198 | return ret; | 1198 | return ret; |
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c index 8c63752b0a96..b5e08a903bb3 100644 --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c | |||
@@ -3948,7 +3948,7 @@ noinline int btrfs_update_inode(struct btrfs_trans_handle *trans, | |||
3948 | */ | 3948 | */ |
3949 | if (!btrfs_is_free_space_inode(inode) | 3949 | if (!btrfs_is_free_space_inode(inode) |
3950 | && root->root_key.objectid != BTRFS_DATA_RELOC_TREE_OBJECTID | 3950 | && root->root_key.objectid != BTRFS_DATA_RELOC_TREE_OBJECTID |
3951 | && !root->fs_info->log_root_recovering) { | 3951 | && !test_bit(BTRFS_FS_LOG_RECOVERING, &root->fs_info->flags)) { |
3952 | btrfs_update_root_times(trans, root); | 3952 | btrfs_update_root_times(trans, root); |
3953 | 3953 | ||
3954 | ret = btrfs_delayed_update_inode(trans, root, inode); | 3954 | ret = btrfs_delayed_update_inode(trans, root, inode); |
@@ -5235,7 +5235,7 @@ void btrfs_evict_inode(struct inode *inode) | |||
5235 | 5235 | ||
5236 | btrfs_free_io_failure_record(inode, 0, (u64)-1); | 5236 | btrfs_free_io_failure_record(inode, 0, (u64)-1); |
5237 | 5237 | ||
5238 | if (root->fs_info->log_root_recovering) { | 5238 | if (test_bit(BTRFS_FS_LOG_RECOVERING, &root->fs_info->flags)) { |
5239 | BUG_ON(test_bit(BTRFS_INODE_HAS_ORPHAN_ITEM, | 5239 | BUG_ON(test_bit(BTRFS_INODE_HAS_ORPHAN_ITEM, |
5240 | &BTRFS_I(inode)->runtime_flags)); | 5240 | &BTRFS_I(inode)->runtime_flags)); |
5241 | goto no_delete; | 5241 | goto no_delete; |
diff --git a/fs/btrfs/qgroup.c b/fs/btrfs/qgroup.c index 8db2e29fdcf4..13c2dc79501b 100644 --- a/fs/btrfs/qgroup.c +++ b/fs/btrfs/qgroup.c | |||
@@ -309,7 +309,7 @@ int btrfs_read_qgroup_config(struct btrfs_fs_info *fs_info) | |||
309 | u64 flags = 0; | 309 | u64 flags = 0; |
310 | u64 rescan_progress = 0; | 310 | u64 rescan_progress = 0; |
311 | 311 | ||
312 | if (!fs_info->quota_enabled) | 312 | if (!test_bit(BTRFS_FS_QUOTA_ENABLED, &fs_info->flags)) |
313 | return 0; | 313 | return 0; |
314 | 314 | ||
315 | fs_info->qgroup_ulist = ulist_alloc(GFP_NOFS); | 315 | fs_info->qgroup_ulist = ulist_alloc(GFP_NOFS); |
@@ -463,13 +463,11 @@ next2: | |||
463 | } | 463 | } |
464 | out: | 464 | out: |
465 | fs_info->qgroup_flags |= flags; | 465 | fs_info->qgroup_flags |= flags; |
466 | if (!(fs_info->qgroup_flags & BTRFS_QGROUP_STATUS_FLAG_ON)) { | 466 | if (!(fs_info->qgroup_flags & BTRFS_QGROUP_STATUS_FLAG_ON)) |
467 | fs_info->quota_enabled = 0; | 467 | clear_bit(BTRFS_FS_QUOTA_ENABLED, &fs_info->flags); |
468 | fs_info->pending_quota_state = 0; | 468 | else if (fs_info->qgroup_flags & BTRFS_QGROUP_STATUS_FLAG_RESCAN && |
469 | } else if (fs_info->qgroup_flags & BTRFS_QGROUP_STATUS_FLAG_RESCAN && | 469 | ret >= 0) |
470 | ret >= 0) { | ||
471 | ret = qgroup_rescan_init(fs_info, rescan_progress, 0); | 470 | ret = qgroup_rescan_init(fs_info, rescan_progress, 0); |
472 | } | ||
473 | btrfs_free_path(path); | 471 | btrfs_free_path(path); |
474 | 472 | ||
475 | if (ret < 0) { | 473 | if (ret < 0) { |
@@ -847,7 +845,7 @@ static int btrfs_clean_quota_tree(struct btrfs_trans_handle *trans, | |||
847 | } | 845 | } |
848 | ret = 0; | 846 | ret = 0; |
849 | out: | 847 | out: |
850 | root->fs_info->pending_quota_state = 0; | 848 | set_bit(BTRFS_FS_QUOTA_DISABLING, &root->fs_info->flags); |
851 | btrfs_free_path(path); | 849 | btrfs_free_path(path); |
852 | return ret; | 850 | return ret; |
853 | } | 851 | } |
@@ -868,7 +866,7 @@ int btrfs_quota_enable(struct btrfs_trans_handle *trans, | |||
868 | 866 | ||
869 | mutex_lock(&fs_info->qgroup_ioctl_lock); | 867 | mutex_lock(&fs_info->qgroup_ioctl_lock); |
870 | if (fs_info->quota_root) { | 868 | if (fs_info->quota_root) { |
871 | fs_info->pending_quota_state = 1; | 869 | set_bit(BTRFS_FS_QUOTA_ENABLING, &fs_info->flags); |
872 | goto out; | 870 | goto out; |
873 | } | 871 | } |
874 | 872 | ||
@@ -964,7 +962,7 @@ out_add_root: | |||
964 | } | 962 | } |
965 | spin_lock(&fs_info->qgroup_lock); | 963 | spin_lock(&fs_info->qgroup_lock); |
966 | fs_info->quota_root = quota_root; | 964 | fs_info->quota_root = quota_root; |
967 | fs_info->pending_quota_state = 1; | 965 | set_bit(BTRFS_FS_QUOTA_ENABLING, &fs_info->flags); |
968 | spin_unlock(&fs_info->qgroup_lock); | 966 | spin_unlock(&fs_info->qgroup_lock); |
969 | out_free_path: | 967 | out_free_path: |
970 | btrfs_free_path(path); | 968 | btrfs_free_path(path); |
@@ -993,8 +991,8 @@ int btrfs_quota_disable(struct btrfs_trans_handle *trans, | |||
993 | mutex_lock(&fs_info->qgroup_ioctl_lock); | 991 | mutex_lock(&fs_info->qgroup_ioctl_lock); |
994 | if (!fs_info->quota_root) | 992 | if (!fs_info->quota_root) |
995 | goto out; | 993 | goto out; |
996 | fs_info->quota_enabled = 0; | 994 | clear_bit(BTRFS_FS_QUOTA_ENABLED, &fs_info->flags); |
997 | fs_info->pending_quota_state = 0; | 995 | set_bit(BTRFS_FS_QUOTA_DISABLING, &fs_info->flags); |
998 | btrfs_qgroup_wait_for_completion(fs_info, false); | 996 | btrfs_qgroup_wait_for_completion(fs_info, false); |
999 | spin_lock(&fs_info->qgroup_lock); | 997 | spin_lock(&fs_info->qgroup_lock); |
1000 | quota_root = fs_info->quota_root; | 998 | quota_root = fs_info->quota_root; |
@@ -1490,7 +1488,8 @@ int btrfs_qgroup_insert_dirty_extent(struct btrfs_trans_handle *trans, | |||
1490 | struct btrfs_delayed_ref_root *delayed_refs; | 1488 | struct btrfs_delayed_ref_root *delayed_refs; |
1491 | int ret; | 1489 | int ret; |
1492 | 1490 | ||
1493 | if (!fs_info->quota_enabled || bytenr == 0 || num_bytes == 0) | 1491 | if (!test_bit(BTRFS_FS_QUOTA_ENABLED, &fs_info->flags) |
1492 | || bytenr == 0 || num_bytes == 0) | ||
1494 | return 0; | 1493 | return 0; |
1495 | if (WARN_ON(trans == NULL)) | 1494 | if (WARN_ON(trans == NULL)) |
1496 | return -EINVAL; | 1495 | return -EINVAL; |
@@ -1713,7 +1712,7 @@ btrfs_qgroup_account_extent(struct btrfs_trans_handle *trans, | |||
1713 | if (old_roots) | 1712 | if (old_roots) |
1714 | nr_old_roots = old_roots->nnodes; | 1713 | nr_old_roots = old_roots->nnodes; |
1715 | 1714 | ||
1716 | if (!fs_info->quota_enabled) | 1715 | if (!test_bit(BTRFS_FS_QUOTA_ENABLED, &fs_info->flags)) |
1717 | goto out_free; | 1716 | goto out_free; |
1718 | BUG_ON(!fs_info->quota_root); | 1717 | BUG_ON(!fs_info->quota_root); |
1719 | 1718 | ||
@@ -1833,10 +1832,14 @@ int btrfs_run_qgroups(struct btrfs_trans_handle *trans, | |||
1833 | if (!quota_root) | 1832 | if (!quota_root) |
1834 | goto out; | 1833 | goto out; |
1835 | 1834 | ||
1836 | if (!fs_info->quota_enabled && fs_info->pending_quota_state) | 1835 | if (!test_bit(BTRFS_FS_QUOTA_ENABLED, &fs_info->flags) && |
1836 | test_bit(BTRFS_FS_QUOTA_ENABLING, &fs_info->flags)) | ||
1837 | start_rescan_worker = 1; | 1837 | start_rescan_worker = 1; |
1838 | 1838 | ||
1839 | fs_info->quota_enabled = fs_info->pending_quota_state; | 1839 | if (test_and_clear_bit(BTRFS_FS_QUOTA_ENABLING, &fs_info->flags)) |
1840 | set_bit(BTRFS_FS_QUOTA_ENABLED, &fs_info->flags); | ||
1841 | if (test_and_clear_bit(BTRFS_FS_QUOTA_DISABLING, &fs_info->flags)) | ||
1842 | clear_bit(BTRFS_FS_QUOTA_ENABLED, &fs_info->flags); | ||
1840 | 1843 | ||
1841 | spin_lock(&fs_info->qgroup_lock); | 1844 | spin_lock(&fs_info->qgroup_lock); |
1842 | while (!list_empty(&fs_info->dirty_qgroups)) { | 1845 | while (!list_empty(&fs_info->dirty_qgroups)) { |
@@ -1855,7 +1858,7 @@ int btrfs_run_qgroups(struct btrfs_trans_handle *trans, | |||
1855 | BTRFS_QGROUP_STATUS_FLAG_INCONSISTENT; | 1858 | BTRFS_QGROUP_STATUS_FLAG_INCONSISTENT; |
1856 | spin_lock(&fs_info->qgroup_lock); | 1859 | spin_lock(&fs_info->qgroup_lock); |
1857 | } | 1860 | } |
1858 | if (fs_info->quota_enabled) | 1861 | if (test_bit(BTRFS_FS_QUOTA_ENABLED, &fs_info->flags)) |
1859 | fs_info->qgroup_flags |= BTRFS_QGROUP_STATUS_FLAG_ON; | 1862 | fs_info->qgroup_flags |= BTRFS_QGROUP_STATUS_FLAG_ON; |
1860 | else | 1863 | else |
1861 | fs_info->qgroup_flags &= ~BTRFS_QGROUP_STATUS_FLAG_ON; | 1864 | fs_info->qgroup_flags &= ~BTRFS_QGROUP_STATUS_FLAG_ON; |
@@ -1900,7 +1903,7 @@ int btrfs_qgroup_inherit(struct btrfs_trans_handle *trans, | |||
1900 | u64 nums; | 1903 | u64 nums; |
1901 | 1904 | ||
1902 | mutex_lock(&fs_info->qgroup_ioctl_lock); | 1905 | mutex_lock(&fs_info->qgroup_ioctl_lock); |
1903 | if (!fs_info->quota_enabled) | 1906 | if (!test_bit(BTRFS_FS_QUOTA_ENABLED, &fs_info->flags)) |
1904 | goto out; | 1907 | goto out; |
1905 | 1908 | ||
1906 | if (!quota_root) { | 1909 | if (!quota_root) { |
@@ -2347,7 +2350,7 @@ static void btrfs_qgroup_rescan_worker(struct btrfs_work *work) | |||
2347 | err = PTR_ERR(trans); | 2350 | err = PTR_ERR(trans); |
2348 | break; | 2351 | break; |
2349 | } | 2352 | } |
2350 | if (!fs_info->quota_enabled) { | 2353 | if (!test_bit(BTRFS_FS_QUOTA_ENABLED, &fs_info->flags)) { |
2351 | err = -EINTR; | 2354 | err = -EINTR; |
2352 | } else { | 2355 | } else { |
2353 | err = qgroup_rescan_leaf(fs_info, path, trans); | 2356 | err = qgroup_rescan_leaf(fs_info, path, trans); |
@@ -2578,8 +2581,8 @@ int btrfs_qgroup_reserve_data(struct inode *inode, u64 start, u64 len) | |||
2578 | struct ulist_iterator uiter; | 2581 | struct ulist_iterator uiter; |
2579 | int ret; | 2582 | int ret; |
2580 | 2583 | ||
2581 | if (!root->fs_info->quota_enabled || !is_fstree(root->objectid) || | 2584 | if (!test_bit(BTRFS_FS_QUOTA_ENABLED, &root->fs_info->flags) || |
2582 | len == 0) | 2585 | !is_fstree(root->objectid) || len == 0) |
2583 | return 0; | 2586 | return 0; |
2584 | 2587 | ||
2585 | changeset.bytes_changed = 0; | 2588 | changeset.bytes_changed = 0; |
@@ -2676,8 +2679,8 @@ int btrfs_qgroup_reserve_meta(struct btrfs_root *root, int num_bytes) | |||
2676 | { | 2679 | { |
2677 | int ret; | 2680 | int ret; |
2678 | 2681 | ||
2679 | if (!root->fs_info->quota_enabled || !is_fstree(root->objectid) || | 2682 | if (!test_bit(BTRFS_FS_QUOTA_ENABLED, &root->fs_info->flags) || |
2680 | num_bytes == 0) | 2683 | !is_fstree(root->objectid) || num_bytes == 0) |
2681 | return 0; | 2684 | return 0; |
2682 | 2685 | ||
2683 | BUG_ON(num_bytes != round_down(num_bytes, root->nodesize)); | 2686 | BUG_ON(num_bytes != round_down(num_bytes, root->nodesize)); |
@@ -2692,7 +2695,8 @@ void btrfs_qgroup_free_meta_all(struct btrfs_root *root) | |||
2692 | { | 2695 | { |
2693 | int reserved; | 2696 | int reserved; |
2694 | 2697 | ||
2695 | if (!root->fs_info->quota_enabled || !is_fstree(root->objectid)) | 2698 | if (!test_bit(BTRFS_FS_QUOTA_ENABLED, &root->fs_info->flags) || |
2699 | !is_fstree(root->objectid)) | ||
2696 | return; | 2700 | return; |
2697 | 2701 | ||
2698 | reserved = atomic_xchg(&root->qgroup_meta_rsv, 0); | 2702 | reserved = atomic_xchg(&root->qgroup_meta_rsv, 0); |
@@ -2703,7 +2707,8 @@ void btrfs_qgroup_free_meta_all(struct btrfs_root *root) | |||
2703 | 2707 | ||
2704 | void btrfs_qgroup_free_meta(struct btrfs_root *root, int num_bytes) | 2708 | void btrfs_qgroup_free_meta(struct btrfs_root *root, int num_bytes) |
2705 | { | 2709 | { |
2706 | if (!root->fs_info->quota_enabled || !is_fstree(root->objectid)) | 2710 | if (!test_bit(BTRFS_FS_QUOTA_ENABLED, &root->fs_info->flags) || |
2711 | !is_fstree(root->objectid)) | ||
2707 | return; | 2712 | return; |
2708 | 2713 | ||
2709 | BUG_ON(num_bytes != round_down(num_bytes, root->nodesize)); | 2714 | BUG_ON(num_bytes != round_down(num_bytes, root->nodesize)); |
diff --git a/fs/btrfs/relocation.c b/fs/btrfs/relocation.c index 7d53f2acb09e..83fc51f786ab 100644 --- a/fs/btrfs/relocation.c +++ b/fs/btrfs/relocation.c | |||
@@ -3952,7 +3952,7 @@ static int qgroup_fix_relocated_data_extents(struct btrfs_trans_handle *trans, | |||
3952 | struct btrfs_key key; | 3952 | struct btrfs_key key; |
3953 | int ret = 0; | 3953 | int ret = 0; |
3954 | 3954 | ||
3955 | if (!fs_info->quota_enabled) | 3955 | if (!test_bit(BTRFS_FS_QUOTA_ENABLED, &fs_info->flags)) |
3956 | return 0; | 3956 | return 0; |
3957 | 3957 | ||
3958 | /* | 3958 | /* |
diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c index 4071fe2bd098..21f2b2d87f37 100644 --- a/fs/btrfs/super.c +++ b/fs/btrfs/super.c | |||
@@ -1836,7 +1836,7 @@ static int btrfs_remount(struct super_block *sb, int *flags, char *data) | |||
1836 | } | 1836 | } |
1837 | sb->s_flags &= ~MS_RDONLY; | 1837 | sb->s_flags &= ~MS_RDONLY; |
1838 | 1838 | ||
1839 | fs_info->open = 1; | 1839 | set_bit(BTRFS_FS_OPEN, &fs_info->flags); |
1840 | } | 1840 | } |
1841 | out: | 1841 | out: |
1842 | wake_up_process(fs_info->transaction_kthread); | 1842 | wake_up_process(fs_info->transaction_kthread); |
diff --git a/fs/btrfs/tests/qgroup-tests.c b/fs/btrfs/tests/qgroup-tests.c index 4407fef7c16c..ca7cb5e6d385 100644 --- a/fs/btrfs/tests/qgroup-tests.c +++ b/fs/btrfs/tests/qgroup-tests.c | |||
@@ -480,7 +480,7 @@ int btrfs_test_qgroups(u32 sectorsize, u32 nodesize) | |||
480 | */ | 480 | */ |
481 | root->fs_info->tree_root = root; | 481 | root->fs_info->tree_root = root; |
482 | root->fs_info->quota_root = root; | 482 | root->fs_info->quota_root = root; |
483 | root->fs_info->quota_enabled = 1; | 483 | set_bit(BTRFS_FS_QUOTA_ENABLED, &fs_info->flags); |
484 | 484 | ||
485 | /* | 485 | /* |
486 | * Can't use bytenr 0, some things freak out | 486 | * Can't use bytenr 0, some things freak out |
diff --git a/fs/btrfs/transaction.c b/fs/btrfs/transaction.c index 95d41919d034..b53104042e95 100644 --- a/fs/btrfs/transaction.c +++ b/fs/btrfs/transaction.c | |||
@@ -441,7 +441,7 @@ static void wait_current_trans(struct btrfs_root *root) | |||
441 | 441 | ||
442 | static int may_wait_transaction(struct btrfs_root *root, int type) | 442 | static int may_wait_transaction(struct btrfs_root *root, int type) |
443 | { | 443 | { |
444 | if (root->fs_info->log_root_recovering) | 444 | if (test_bit(BTRFS_FS_LOG_RECOVERING, &root->fs_info->flags)) |
445 | return 0; | 445 | return 0; |
446 | 446 | ||
447 | if (type == TRANS_USERSPACE) | 447 | if (type == TRANS_USERSPACE) |
@@ -993,7 +993,6 @@ int btrfs_wait_marked_extents(struct btrfs_root *root, | |||
993 | struct extent_state *cached_state = NULL; | 993 | struct extent_state *cached_state = NULL; |
994 | u64 start = 0; | 994 | u64 start = 0; |
995 | u64 end; | 995 | u64 end; |
996 | struct btrfs_inode *btree_ino = BTRFS_I(root->fs_info->btree_inode); | ||
997 | bool errors = false; | 996 | bool errors = false; |
998 | 997 | ||
999 | while (!find_first_extent_bit(dirty_pages, start, &start, &end, | 998 | while (!find_first_extent_bit(dirty_pages, start, &start, &end, |
@@ -1025,17 +1024,17 @@ int btrfs_wait_marked_extents(struct btrfs_root *root, | |||
1025 | 1024 | ||
1026 | if (root->root_key.objectid == BTRFS_TREE_LOG_OBJECTID) { | 1025 | if (root->root_key.objectid == BTRFS_TREE_LOG_OBJECTID) { |
1027 | if ((mark & EXTENT_DIRTY) && | 1026 | if ((mark & EXTENT_DIRTY) && |
1028 | test_and_clear_bit(BTRFS_INODE_BTREE_LOG1_ERR, | 1027 | test_and_clear_bit(BTRFS_FS_LOG1_ERR, |
1029 | &btree_ino->runtime_flags)) | 1028 | &root->fs_info->flags)) |
1030 | errors = true; | 1029 | errors = true; |
1031 | 1030 | ||
1032 | if ((mark & EXTENT_NEW) && | 1031 | if ((mark & EXTENT_NEW) && |
1033 | test_and_clear_bit(BTRFS_INODE_BTREE_LOG2_ERR, | 1032 | test_and_clear_bit(BTRFS_FS_LOG2_ERR, |
1034 | &btree_ino->runtime_flags)) | 1033 | &root->fs_info->flags)) |
1035 | errors = true; | 1034 | errors = true; |
1036 | } else { | 1035 | } else { |
1037 | if (test_and_clear_bit(BTRFS_INODE_BTREE_ERR, | 1036 | if (test_and_clear_bit(BTRFS_FS_BTREE_ERR, |
1038 | &btree_ino->runtime_flags)) | 1037 | &root->fs_info->flags)) |
1039 | errors = true; | 1038 | errors = true; |
1040 | } | 1039 | } |
1041 | 1040 | ||
@@ -1335,7 +1334,7 @@ static int qgroup_account_snapshot(struct btrfs_trans_handle *trans, | |||
1335 | * kick in anyway. | 1334 | * kick in anyway. |
1336 | */ | 1335 | */ |
1337 | mutex_lock(&fs_info->qgroup_ioctl_lock); | 1336 | mutex_lock(&fs_info->qgroup_ioctl_lock); |
1338 | if (!fs_info->quota_enabled) { | 1337 | if (!test_bit(BTRFS_FS_QUOTA_ENABLED, &fs_info->flags)) { |
1339 | mutex_unlock(&fs_info->qgroup_ioctl_lock); | 1338 | mutex_unlock(&fs_info->qgroup_ioctl_lock); |
1340 | return 0; | 1339 | return 0; |
1341 | } | 1340 | } |
@@ -1712,7 +1711,7 @@ static void update_super_roots(struct btrfs_root *root) | |||
1712 | super->root_level = root_item->level; | 1711 | super->root_level = root_item->level; |
1713 | if (btrfs_test_opt(root->fs_info, SPACE_CACHE)) | 1712 | if (btrfs_test_opt(root->fs_info, SPACE_CACHE)) |
1714 | super->cache_generation = root_item->generation; | 1713 | super->cache_generation = root_item->generation; |
1715 | if (root->fs_info->update_uuid_tree_gen) | 1714 | if (test_bit(BTRFS_FS_UPDATE_UUID_TREE_GEN, &root->fs_info->flags)) |
1716 | super->uuid_tree_generation = root_item->generation; | 1715 | super->uuid_tree_generation = root_item->generation; |
1717 | } | 1716 | } |
1718 | 1717 | ||
@@ -1919,7 +1918,6 @@ int btrfs_commit_transaction(struct btrfs_trans_handle *trans, | |||
1919 | { | 1918 | { |
1920 | struct btrfs_transaction *cur_trans = trans->transaction; | 1919 | struct btrfs_transaction *cur_trans = trans->transaction; |
1921 | struct btrfs_transaction *prev_trans = NULL; | 1920 | struct btrfs_transaction *prev_trans = NULL; |
1922 | struct btrfs_inode *btree_ino = BTRFS_I(root->fs_info->btree_inode); | ||
1923 | int ret; | 1921 | int ret; |
1924 | 1922 | ||
1925 | /* Stop the commit early if ->aborted is set */ | 1923 | /* Stop the commit early if ->aborted is set */ |
@@ -2213,8 +2211,8 @@ int btrfs_commit_transaction(struct btrfs_trans_handle *trans, | |||
2213 | btrfs_update_commit_device_size(root->fs_info); | 2211 | btrfs_update_commit_device_size(root->fs_info); |
2214 | btrfs_update_commit_device_bytes_used(root, cur_trans); | 2212 | btrfs_update_commit_device_bytes_used(root, cur_trans); |
2215 | 2213 | ||
2216 | clear_bit(BTRFS_INODE_BTREE_LOG1_ERR, &btree_ino->runtime_flags); | 2214 | clear_bit(BTRFS_FS_LOG1_ERR, &root->fs_info->flags); |
2217 | clear_bit(BTRFS_INODE_BTREE_LOG2_ERR, &btree_ino->runtime_flags); | 2215 | clear_bit(BTRFS_FS_LOG2_ERR, &root->fs_info->flags); |
2218 | 2216 | ||
2219 | btrfs_trans_release_chunk_metadata(trans); | 2217 | btrfs_trans_release_chunk_metadata(trans); |
2220 | 2218 | ||
diff --git a/fs/btrfs/tree-log.c b/fs/btrfs/tree-log.c index ef9c55bc7907..d22adf4fea7e 100644 --- a/fs/btrfs/tree-log.c +++ b/fs/btrfs/tree-log.c | |||
@@ -5579,7 +5579,7 @@ int btrfs_recover_log_trees(struct btrfs_root *log_root_tree) | |||
5579 | if (!path) | 5579 | if (!path) |
5580 | return -ENOMEM; | 5580 | return -ENOMEM; |
5581 | 5581 | ||
5582 | fs_info->log_root_recovering = 1; | 5582 | set_bit(BTRFS_FS_LOG_RECOVERING, &fs_info->flags); |
5583 | 5583 | ||
5584 | trans = btrfs_start_transaction(fs_info->tree_root, 0); | 5584 | trans = btrfs_start_transaction(fs_info->tree_root, 0); |
5585 | if (IS_ERR(trans)) { | 5585 | if (IS_ERR(trans)) { |
@@ -5689,7 +5689,7 @@ again: | |||
5689 | 5689 | ||
5690 | free_extent_buffer(log_root_tree->node); | 5690 | free_extent_buffer(log_root_tree->node); |
5691 | log_root_tree->log_root = NULL; | 5691 | log_root_tree->log_root = NULL; |
5692 | fs_info->log_root_recovering = 0; | 5692 | clear_bit(BTRFS_FS_LOG_RECOVERING, &fs_info->flags); |
5693 | kfree(log_root_tree); | 5693 | kfree(log_root_tree); |
5694 | 5694 | ||
5695 | return 0; | 5695 | return 0; |
diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c index 4ff39952bdfc..c356ce332229 100644 --- a/fs/btrfs/volumes.c +++ b/fs/btrfs/volumes.c | |||
@@ -4217,7 +4217,7 @@ out: | |||
4217 | if (ret) | 4217 | if (ret) |
4218 | btrfs_warn(fs_info, "btrfs_uuid_scan_kthread failed %d", ret); | 4218 | btrfs_warn(fs_info, "btrfs_uuid_scan_kthread failed %d", ret); |
4219 | else | 4219 | else |
4220 | fs_info->update_uuid_tree_gen = 1; | 4220 | set_bit(BTRFS_FS_UPDATE_UUID_TREE_GEN, &fs_info->flags); |
4221 | up(&fs_info->uuid_tree_rescan_sem); | 4221 | up(&fs_info->uuid_tree_rescan_sem); |
4222 | return 0; | 4222 | return 0; |
4223 | } | 4223 | } |