btrfs: convert pr_* to btrfs_* where possible
[cascardo/linux.git] / fs / btrfs / ctree.h
index eff3993..9e8fd5e 100644 (file)
@@ -37,6 +37,7 @@
 #include <linux/workqueue.h>
 #include <linux/security.h>
 #include <linux/sizes.h>
+#include <linux/dynamic_debug.h>
 #include "extent_io.h"
 #include "extent_map.h"
 #include "async-thread.h"
@@ -427,6 +428,7 @@ struct btrfs_space_info {
        struct list_head ro_bgs;
        struct list_head priority_tickets;
        struct list_head tickets;
+       u64 tickets_id;
 
        struct rw_semaphore groups_sem;
        /* for block groups in our same type */
@@ -675,9 +677,25 @@ struct btrfs_device;
 struct btrfs_fs_devices;
 struct btrfs_balance_control;
 struct btrfs_delayed_root;
+
+#define BTRFS_FS_BARRIER                       1
+#define BTRFS_FS_CLOSING_START                 2
+#define BTRFS_FS_CLOSING_DONE                  3
+#define BTRFS_FS_LOG_RECOVERING                        4
+#define BTRFS_FS_OPEN                          5
+#define BTRFS_FS_QUOTA_ENABLED                 6
+#define BTRFS_FS_QUOTA_ENABLING                        7
+#define BTRFS_FS_QUOTA_DISABLING               8
+#define BTRFS_FS_UPDATE_UUID_TREE_GEN          9
+#define BTRFS_FS_CREATING_FREE_SPACE_TREE      10
+#define BTRFS_FS_BTREE_ERR                     11
+#define BTRFS_FS_LOG1_ERR                      12
+#define BTRFS_FS_LOG2_ERR                      13
+
 struct btrfs_fs_info {
        u8 fsid[BTRFS_FSID_SIZE];
        u8 chunk_tree_uuid[BTRFS_UUID_SIZE];
+       unsigned long flags;
        struct btrfs_root *extent_root;
        struct btrfs_root *tree_root;
        struct btrfs_root *chunk_root;
@@ -906,10 +924,6 @@ struct btrfs_fs_info {
        int thread_pool_size;
 
        struct kobject *space_info_kobj;
-       int do_barriers;
-       int closing;
-       int log_root_recovering;
-       int open;
 
        u64 total_pinned;
 
@@ -986,17 +1000,6 @@ struct btrfs_fs_info {
 #ifdef CONFIG_BTRFS_FS_CHECK_INTEGRITY
        u32 check_integrity_print_mask;
 #endif
-       /*
-        * quota information
-        */
-       unsigned int quota_enabled:1;
-
-       /*
-        * quota_enabled only changes state after a commit. This holds the
-        * next state.
-        */
-       unsigned int pending_quota_state:1;
-
        /* is qgroup tracking in a consistent state? */
        u64 qgroup_flags;
 
@@ -1060,7 +1063,6 @@ struct btrfs_fs_info {
        wait_queue_head_t replace_wait;
 
        struct semaphore uuid_tree_rescan_sem;
-       unsigned int update_uuid_tree_gen:1;
 
        /* Used to reclaim the metadata space in the background. */
        struct work_struct async_reclaim_work;
@@ -1079,7 +1081,6 @@ struct btrfs_fs_info {
         */
        struct list_head pinned_chunks;
 
-       int creating_free_space_tree;
        /* Used to record internally whether fs has been frozen */
        int fs_frozen;
 };
@@ -1434,13 +1435,13 @@ static inline void btrfs_init_map_token (struct btrfs_map_token *token)
 #define cpu_to_le8(v) (v)
 #define __le8 u8
 
-#define read_eb_member(eb, ptr, type, member, result) (                        \
+#define read_eb_member(eb, ptr, type, member, result) (\
        read_extent_buffer(eb, (char *)(result),                        \
                           ((unsigned long)(ptr)) +                     \
                            offsetof(type, member),                     \
                           sizeof(((type *)0)->member)))
 
-#define write_eb_member(eb, ptr, type, member, result) (               \
+#define write_eb_member(eb, ptr, type, member, result) (\
        write_extent_buffer(eb, (char *)(result),                       \
                           ((unsigned long)(ptr)) +                     \
                            offsetof(type, member),                     \
@@ -2866,10 +2867,14 @@ int btrfs_drop_subtree(struct btrfs_trans_handle *trans,
 static inline int btrfs_fs_closing(struct btrfs_fs_info *fs_info)
 {
        /*
-        * Get synced with close_ctree()
+        * Do it this way so we only ever do one test_bit in the normal case.
         */
-       smp_mb();
-       return fs_info->closing;
+       if (test_bit(BTRFS_FS_CLOSING_START, &fs_info->flags)) {
+               if (test_bit(BTRFS_FS_CLOSING_DONE, &fs_info->flags))
+                       return 2;
+               return 1;
+       }
+       return 0;
 }
 
 /*
@@ -3117,7 +3122,7 @@ int btrfs_start_delalloc_inodes(struct btrfs_root *root, int delay_iput);
 int btrfs_start_delalloc_roots(struct btrfs_fs_info *fs_info, int delay_iput,
                               int nr);
 int btrfs_set_extent_delalloc(struct inode *inode, u64 start, u64 end,
-                             struct extent_state **cached_state);
+                             struct extent_state **cached_state, int dedupe);
 int btrfs_create_subvol_root(struct btrfs_trans_handle *trans,
                             struct btrfs_root *new_root,
                             struct btrfs_root *parent_root,
@@ -3314,7 +3319,35 @@ void btrfs_printk(const struct btrfs_fs_info *fs_info, const char *fmt, ...)
        btrfs_printk_ratelimited(fs_info, KERN_NOTICE fmt, ##args)
 #define btrfs_info_rl(fs_info, fmt, args...) \
        btrfs_printk_ratelimited(fs_info, KERN_INFO fmt, ##args)
-#ifdef DEBUG
+
+#if defined(CONFIG_DYNAMIC_DEBUG)
+#define btrfs_debug(fs_info, fmt, args...)                             \
+do {                                                                   \
+        DEFINE_DYNAMIC_DEBUG_METADATA(descriptor, fmt);                \
+        if (unlikely(descriptor.flags & _DPRINTK_FLAGS_PRINT))         \
+               btrfs_printk(fs_info, KERN_DEBUG fmt, ##args);          \
+} while (0)
+#define btrfs_debug_in_rcu(fs_info, fmt, args...)                      \
+do {                                                                   \
+        DEFINE_DYNAMIC_DEBUG_METADATA(descriptor, fmt);                \
+        if (unlikely(descriptor.flags & _DPRINTK_FLAGS_PRINT))                 \
+               btrfs_printk_in_rcu(fs_info, KERN_DEBUG fmt, ##args);   \
+} while (0)
+#define btrfs_debug_rl_in_rcu(fs_info, fmt, args...)                   \
+do {                                                                   \
+        DEFINE_DYNAMIC_DEBUG_METADATA(descriptor, fmt);                \
+        if (unlikely(descriptor.flags & _DPRINTK_FLAGS_PRINT))         \
+               btrfs_printk_rl_in_rcu(fs_info, KERN_DEBUG fmt,         \
+                                      ##args);\
+} while (0)
+#define btrfs_debug_rl(fs_info, fmt, args...)                          \
+do {                                                                   \
+        DEFINE_DYNAMIC_DEBUG_METADATA(descriptor, fmt);                \
+        if (unlikely(descriptor.flags & _DPRINTK_FLAGS_PRINT))         \
+               btrfs_printk_ratelimited(fs_info, KERN_DEBUG fmt,       \
+                                        ##args);                       \
+} while (0)
+#elif defined(DEBUG)
 #define btrfs_debug(fs_info, fmt, args...) \
        btrfs_printk(fs_info, KERN_DEBUG fmt, ##args)
 #define btrfs_debug_in_rcu(fs_info, fmt, args...) \
@@ -3325,7 +3358,7 @@ void btrfs_printk(const struct btrfs_fs_info *fs_info, const char *fmt, ...)
        btrfs_printk_ratelimited(fs_info, KERN_DEBUG fmt, ##args)
 #else
 #define btrfs_debug(fs_info, fmt, args...) \
-    no_printk(KERN_DEBUG fmt, ##args)
+       no_printk(KERN_DEBUG fmt, ##args)
 #define btrfs_debug_in_rcu(fs_info, fmt, args...) \
        no_printk(KERN_DEBUG fmt, ##args)
 #define btrfs_debug_rl_in_rcu(fs_info, fmt, args...) \
@@ -3362,7 +3395,7 @@ do {                                                              \
 __cold
 static inline void assfail(char *expr, char *file, int line)
 {
-       pr_err("BTRFS: assertion failed: %s, file: %s, line: %d",
+       pr_err("assertion failed: %s, file: %s, line: %d\n",
               expr, file, line);
        BUG();
 }