Btrfs: fix warning of bytes_may_use
[cascardo/linux.git] / fs / btrfs / btrfs_inode.h
index de5e4f2..81220b2 100644 (file)
@@ -44,6 +44,8 @@
 #define BTRFS_INODE_IN_DELALLOC_LIST           9
 #define BTRFS_INODE_READDIO_NEED_LOCK          10
 #define BTRFS_INODE_HAS_PROPS                  11
+/* DIO is ready to submit */
+#define BTRFS_INODE_DIO_READY                  12
 /*
  * The following 3 bits are meant only for the btree inode.
  * When any of them is set, it means an error happened while writing an
@@ -66,7 +68,11 @@ struct btrfs_inode {
         */
        struct btrfs_key location;
 
-       /* Lock for counters */
+       /*
+        * Lock for counters and all fields used to determine if the inode is in
+        * the log or not (last_trans, last_sub_trans, last_log_commit,
+        * logged_trans).
+        */
        spinlock_t lock;
 
        /* the extent_tree has caches of all the extent mappings to disk */
@@ -250,6 +256,9 @@ static inline bool btrfs_is_free_space_inode(struct inode *inode)
 
 static inline int btrfs_inode_in_log(struct inode *inode, u64 generation)
 {
+       int ret = 0;
+
+       spin_lock(&BTRFS_I(inode)->lock);
        if (BTRFS_I(inode)->logged_trans == generation &&
            BTRFS_I(inode)->last_sub_trans <=
            BTRFS_I(inode)->last_log_commit &&
@@ -263,9 +272,10 @@ static inline int btrfs_inode_in_log(struct inode *inode, u64 generation)
                 */
                smp_mb();
                if (list_empty(&BTRFS_I(inode)->extent_tree.modified_extents))
-                       return 1;
+                       ret = 1;
        }
-       return 0;
+       spin_unlock(&BTRFS_I(inode)->lock);
+       return ret;
 }
 
 #define BTRFS_DIO_ORIG_BIO_SUBMITTED   0x1