btrfs: switch BTRFS_ROOT_* to enums
[sfrench/cifs-2.6.git] / fs / btrfs / ctree.h
index f8429cd8afb68ff97fa5fbee8d7a461f22956764..41d056010d9ee7af413a0ede78eb4078349ce4bd 100644 (file)
@@ -109,13 +109,26 @@ static inline unsigned long btrfs_chunk_item_size(int num_stripes)
 }
 
 /*
- * File system states
+ * Runtime (in-memory) states of filesystem
  */
-#define BTRFS_FS_STATE_ERROR           0
-#define BTRFS_FS_STATE_REMOUNTING      1
-#define BTRFS_FS_STATE_TRANS_ABORTED   2
-#define BTRFS_FS_STATE_DEV_REPLACING   3
-#define BTRFS_FS_STATE_DUMMY_FS_INFO   4
+enum {
+       /* Global indicator of serious filesystem errors */
+       BTRFS_FS_STATE_ERROR,
+       /*
+        * Filesystem is being remounted, allow to skip some operations, like
+        * defrag
+        */
+       BTRFS_FS_STATE_REMOUNTING,
+       /* Track if a transaction abort has been reported on this filesystem */
+       BTRFS_FS_STATE_TRANS_ABORTED,
+       /*
+        * Bio operations should be blocked on this filesystem because a source
+        * or target device is being destroyed as part of a device replace
+        */
+       BTRFS_FS_STATE_DEV_REPLACING,
+       /* The btrfs_fs_info created for self-tests */
+       BTRFS_FS_STATE_DUMMY_FS_INFO,
+};
 
 #define BTRFS_BACKREF_REV_MAX          256
 #define BTRFS_BACKREF_REV_SHIFT                56
@@ -448,13 +461,18 @@ struct btrfs_space_info {
        struct kobject *block_group_kobjs[BTRFS_NR_RAID_TYPES];
 };
 
-#define        BTRFS_BLOCK_RSV_GLOBAL          1
-#define        BTRFS_BLOCK_RSV_DELALLOC        2
-#define        BTRFS_BLOCK_RSV_TRANS           3
-#define        BTRFS_BLOCK_RSV_CHUNK           4
-#define        BTRFS_BLOCK_RSV_DELOPS          5
-#define        BTRFS_BLOCK_RSV_EMPTY           6
-#define        BTRFS_BLOCK_RSV_TEMP            7
+/*
+ * Types of block reserves
+ */
+enum {
+       BTRFS_BLOCK_RSV_GLOBAL,
+       BTRFS_BLOCK_RSV_DELALLOC,
+       BTRFS_BLOCK_RSV_TRANS,
+       BTRFS_BLOCK_RSV_CHUNK,
+       BTRFS_BLOCK_RSV_DELOPS,
+       BTRFS_BLOCK_RSV_EMPTY,
+       BTRFS_BLOCK_RSV_TEMP,
+};
 
 struct btrfs_block_rsv {
        u64 size;
@@ -739,44 +757,39 @@ struct btrfs_swapfile_pin {
 
 bool btrfs_pinned_by_swapfile(struct btrfs_fs_info *fs_info, void *ptr);
 
-#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_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
-#define BTRFS_FS_QUOTA_OVERRIDE                        14
-/* Used to record internally whether fs has been frozen */
-#define BTRFS_FS_FROZEN                                15
-
-/*
- * Indicate that a whole-filesystem exclusive operation is running
- * (device replace, resize, device add/delete, balance)
- */
-#define BTRFS_FS_EXCL_OP                       16
-
-/*
- * To info transaction_kthread we need an immediate commit so it doesn't
- * need to wait for commit_interval
- */
-#define BTRFS_FS_NEED_ASYNC_COMMIT             17
-
-/*
- * Indicate that balance has been set up from the ioctl and is in the main
- * phase. The fs_info::balance_ctl is initialized.
- */
-#define BTRFS_FS_BALANCE_RUNNING               18
+enum {
+       BTRFS_FS_BARRIER,
+       BTRFS_FS_CLOSING_START,
+       BTRFS_FS_CLOSING_DONE,
+       BTRFS_FS_LOG_RECOVERING,
+       BTRFS_FS_OPEN,
+       BTRFS_FS_QUOTA_ENABLED,
+       BTRFS_FS_UPDATE_UUID_TREE_GEN,
+       BTRFS_FS_CREATING_FREE_SPACE_TREE,
+       BTRFS_FS_BTREE_ERR,
+       BTRFS_FS_LOG1_ERR,
+       BTRFS_FS_LOG2_ERR,
+       BTRFS_FS_QUOTA_OVERRIDE,
+       /* Used to record internally whether fs has been frozen */
+       BTRFS_FS_FROZEN,
+       /*
+        * Indicate that a whole-filesystem exclusive operation is running
+        * (device replace, resize, device add/delete, balance)
+        */
+       BTRFS_FS_EXCL_OP,
+       /*
+        * To info transaction_kthread we need an immediate commit so it
+        * doesn't need to wait for commit_interval
+        */
+       BTRFS_FS_NEED_ASYNC_COMMIT,
+       /*
+        * Indicate that balance has been set up from the ioctl and is in the
+        * main phase. The fs_info::balance_ctl is initialized.
+        */
+       BTRFS_FS_BALANCE_RUNNING,
+};
 
 struct btrfs_fs_info {
-       /* User-visible fs UUID */
-       u8 fsid[BTRFS_FSID_SIZE];
-       /* UUID written to btree blocks */
-       u8 metadata_fsid[BTRFS_FSID_SIZE];
        u8 chunk_tree_uuid[BTRFS_UUID_SIZE];
        unsigned long flags;
        struct btrfs_root *extent_root;
@@ -1167,22 +1180,23 @@ struct btrfs_subvolume_writers {
 /*
  * The state of btrfs root
  */
-/*
- * 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
- */
-#define BTRFS_ROOT_IN_TRANS_SETUP      0
-#define BTRFS_ROOT_REF_COWS            1
-#define BTRFS_ROOT_TRACK_DIRTY         2
-#define BTRFS_ROOT_IN_RADIX            3
-#define BTRFS_ROOT_ORPHAN_ITEM_INSERTED        4
-#define BTRFS_ROOT_DEFRAG_RUNNING      5
-#define BTRFS_ROOT_FORCE_COW           6
-#define BTRFS_ROOT_MULTI_LOG_TASKS     7
-#define BTRFS_ROOT_DIRTY               8
+enum {
+       /*
+        * 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
+        */
+       BTRFS_ROOT_IN_TRANS_SETUP,
+       BTRFS_ROOT_REF_COWS,
+       BTRFS_ROOT_TRACK_DIRTY,
+       BTRFS_ROOT_IN_RADIX,
+       BTRFS_ROOT_ORPHAN_ITEM_INSERTED,
+       BTRFS_ROOT_DEFRAG_RUNNING,
+       BTRFS_ROOT_FORCE_COW,
+       BTRFS_ROOT_MULTI_LOG_TASKS,
+       BTRFS_ROOT_DIRTY,
+};
 
 /*
  * in ram representation of the tree.  extent_root is used for all allocations
@@ -3195,9 +3209,8 @@ void btrfs_merge_delalloc_extent(struct inode *inode, struct extent_state *new,
                                 struct extent_state *other);
 void btrfs_split_delalloc_extent(struct inode *inode,
                                 struct extent_state *orig, u64 split);
-int btrfs_merge_bio_hook(struct page *page, unsigned long offset,
-                        size_t size, struct bio *bio,
-                        unsigned long bio_flags);
+int btrfs_bio_fits_in_stripe(struct page *page, size_t size, struct bio *bio,
+                            unsigned long bio_flags);
 void btrfs_set_range_writeback(struct extent_io_tree *tree, u64 start, u64 end);
 vm_fault_t btrfs_page_mkwrite(struct vm_fault *vmf);
 int btrfs_readpage(struct file *file, struct page *page);