Btrfs: fix relocation races
[linux-2.6-block.git] / fs / btrfs / ctree.h
index 8490ee06370996b6f0d62f53d6d389a3832e7b0d..a2c91a102b72fa923b21425f0b6883d9353b2d8d 100644 (file)
@@ -967,6 +967,12 @@ struct btrfs_fs_info {
        struct srcu_struct subvol_srcu;
 
        spinlock_t trans_lock;
+       /*
+        * the reloc mutex goes with the trans lock, it is taken
+        * during commit to protect us from the relocation code
+        */
+       struct mutex reloc_mutex;
+
        struct list_head trans_list;
        struct list_head hashers;
        struct list_head dead_roots;
@@ -1172,6 +1178,14 @@ struct btrfs_root {
        u32 type;
 
        u64 highest_objectid;
+
+       /* btrfs_record_root_in_trans is a multi-step process,
+        * and it can race with the balancing code.   But the
+        * race is very small, and only the first time the root
+        * is added to each transaction.  So in_trans_setup
+        * is used to tell us when more checks are required
+        */
+       unsigned long in_trans_setup;
        int ref_cows;
        int track_dirty;
        int in_radix;