inode->disk_i_size = size;
 }
 
-static inline bool btrfs_is_free_space_inode(struct btrfs_inode *inode)
+static inline bool btrfs_is_free_space_inode(const struct btrfs_inode *inode)
 {
        return test_bit(BTRFS_INODE_FREE_SPACE_INODE, &inode->runtime_flags);
 }
 
-static inline bool is_data_inode(struct inode *inode)
+static inline bool is_data_inode(const struct inode *inode)
 {
        return btrfs_ino(BTRFS_I(inode)) != BTRFS_BTREE_INODE_OBJECTID;
 }
 
  *  making error handling and cleanup easier.
  */
 
-int btrfs_alloc_data_chunk_ondemand(struct btrfs_inode *inode, u64 bytes)
+int btrfs_alloc_data_chunk_ondemand(const struct btrfs_inode *inode, u64 bytes)
 {
        struct btrfs_root *root = inode->root;
        struct btrfs_fs_info *fs_info = root->fs_info;
 
 struct btrfs_inode;
 struct btrfs_fs_info;
 
-int btrfs_alloc_data_chunk_ondemand(struct btrfs_inode *inode, u64 bytes);
+int btrfs_alloc_data_chunk_ondemand(const struct btrfs_inode *inode, u64 bytes);
 int btrfs_check_data_free_space(struct btrfs_inode *inode,
                        struct extent_changeset **reserved, u64 start, u64 len,
                        bool noflush);
 
 int btrfs_insert_delayed_dir_index(struct btrfs_trans_handle *trans,
                                   const char *name, int name_len,
                                   struct btrfs_inode *dir,
-                                  struct btrfs_disk_key *disk_key, u8 flags,
+                                  const struct btrfs_disk_key *disk_key, u8 flags,
                                   u64 index)
 {
        struct btrfs_fs_info *fs_info = trans->fs_info;
        downgrade_write(&inode->i_rwsem);
 }
 
-int btrfs_should_delete_dir_index(struct list_head *del_list,
+int btrfs_should_delete_dir_index(const struct list_head *del_list,
                                  u64 index)
 {
        struct btrfs_delayed_item *curr;
  * Read dir info stored in the delayed tree.
  */
 int btrfs_readdir_delayed_dir_index(struct dir_context *ctx,
-                                   struct list_head *ins_list)
+                                   const struct list_head *ins_list)
 {
        struct btrfs_dir_item *di;
        struct btrfs_delayed_item *curr, *next;
 
 int btrfs_insert_delayed_dir_index(struct btrfs_trans_handle *trans,
                                   const char *name, int name_len,
                                   struct btrfs_inode *dir,
-                                  struct btrfs_disk_key *disk_key, u8 flags,
+                                  const struct btrfs_disk_key *disk_key, u8 flags,
                                   u64 index);
 
 int btrfs_delete_delayed_dir_index(struct btrfs_trans_handle *trans,
 void btrfs_readdir_put_delayed_items(struct inode *inode,
                                     struct list_head *ins_list,
                                     struct list_head *del_list);
-int btrfs_should_delete_dir_index(struct list_head *del_list,
+int btrfs_should_delete_dir_index(const struct list_head *del_list,
                                  u64 index);
 int btrfs_readdir_delayed_dir_index(struct dir_context *ctx,
-                                   struct list_head *ins_list);
+                                   const struct list_head *ins_list);
 
 /* Used during directory logging. */
 void btrfs_log_get_delayed_items(struct btrfs_inode *inode,
 
                                                   *trans,
                                                   struct btrfs_root *root,
                                                   struct btrfs_path *path,
-                                                  struct btrfs_key *cpu_key,
+                                                  const struct btrfs_key *cpu_key,
                                                   u32 data_size,
                                                   const char *name,
                                                   int name_len)
  */
 int btrfs_insert_dir_item(struct btrfs_trans_handle *trans,
                          const struct fscrypt_str *name, struct btrfs_inode *dir,
-                         struct btrfs_key *location, u8 type, u64 index)
+                         const struct btrfs_key *location, u8 type, u64 index)
 {
        int ret = 0;
        int ret2 = 0;
  * for a specific name.
  */
 struct btrfs_dir_item *btrfs_match_dir_item_name(struct btrfs_fs_info *fs_info,
-                                                struct btrfs_path *path,
+                                                const struct btrfs_path *path,
                                                 const char *name, int name_len)
 {
        struct btrfs_dir_item *dir_item;
 int btrfs_delete_one_dir_name(struct btrfs_trans_handle *trans,
                              struct btrfs_root *root,
                              struct btrfs_path *path,
-                             struct btrfs_dir_item *di)
+                             const struct btrfs_dir_item *di)
 {
 
        struct extent_buffer *leaf;
 
                          const struct fscrypt_str *name);
 int btrfs_insert_dir_item(struct btrfs_trans_handle *trans,
                          const struct fscrypt_str *name, struct btrfs_inode *dir,
-                         struct btrfs_key *location, u8 type, u64 index);
+                         const struct btrfs_key *location, u8 type, u64 index);
 struct btrfs_dir_item *btrfs_lookup_dir_item(struct btrfs_trans_handle *trans,
                                             struct btrfs_root *root,
                                             struct btrfs_path *path, u64 dir,
 int btrfs_delete_one_dir_name(struct btrfs_trans_handle *trans,
                              struct btrfs_root *root,
                              struct btrfs_path *path,
-                             struct btrfs_dir_item *di);
+                             const struct btrfs_dir_item *di);
 int btrfs_insert_xattr_item(struct btrfs_trans_handle *trans,
                            struct btrfs_root *root,
                            struct btrfs_path *path, u64 objectid,
                                          const char *name, u16 name_len,
                                          int mod);
 struct btrfs_dir_item *btrfs_match_dir_item_name(struct btrfs_fs_info *fs_info,
-                                                struct btrfs_path *path,
+                                                const struct btrfs_path *path,
                                                 const char *name,
                                                 int name_len);
 
 
  *                     structure for details.
  */
 int btrfs_read_extent_buffer(struct extent_buffer *eb,
-                            struct btrfs_tree_parent_check *check)
+                            const struct btrfs_tree_parent_check *check)
 {
        struct btrfs_fs_info *fs_info = eb->fs_info;
        int failed = 0;
 
 /* Do basic extent buffer checks at read time */
 int btrfs_validate_extent_buffer(struct extent_buffer *eb,
-                                struct btrfs_tree_parent_check *check)
+                                const struct btrfs_tree_parent_check *check)
 {
        struct btrfs_fs_info *fs_info = eb->fs_info;
        u64 found_start;
                goto out;
        }
        if (check->has_first_key) {
-               struct btrfs_key *expect_key = &check->first_key;
+               const struct btrfs_key *expect_key = &check->first_key;
                struct btrfs_key found_key;
 
                if (found_level)
 
 static struct btrfs_root *read_tree_root_path(struct btrfs_root *tree_root,
                                              struct btrfs_path *path,
-                                             struct btrfs_key *key)
+                                             const struct btrfs_key *key)
 {
        struct btrfs_root *root;
        struct btrfs_tree_parent_check check = { 0 };
 }
 
 struct btrfs_root *btrfs_read_tree_root(struct btrfs_root *tree_root,
-                                       struct btrfs_key *key)
+                                       const struct btrfs_key *key)
 {
        struct btrfs_root *root;
        struct btrfs_path *path;
        return ret;
 }
 
-void btrfs_check_leaked_roots(struct btrfs_fs_info *fs_info)
+void btrfs_check_leaked_roots(const struct btrfs_fs_info *fs_info)
 {
 #ifdef CONFIG_BTRFS_DEBUG
        struct btrfs_root *root;
  *             1, 2    2nd and 3rd backup copy
  *            -1       skip bytenr check
  */
-int btrfs_validate_super(struct btrfs_fs_info *fs_info,
-                        struct btrfs_super_block *sb, int mirror_num)
+int btrfs_validate_super(const struct btrfs_fs_info *fs_info,
+                        const struct btrfs_super_block *sb, int mirror_num)
 {
        u64 nodesize = btrfs_super_nodesize(sb);
        u64 sectorsize = btrfs_super_sectorsize(sb);
 }
 
 int __cold open_ctree(struct super_block *sb, struct btrfs_fs_devices *fs_devices,
-                     char *options)
+                     const char *options)
 {
        u32 sectorsize;
        u32 nodesize;
 
        return BTRFS_SUPER_INFO_OFFSET;
 }
 
-void btrfs_check_leaked_roots(struct btrfs_fs_info *fs_info);
+void btrfs_check_leaked_roots(const struct btrfs_fs_info *fs_info);
 void btrfs_init_fs_info(struct btrfs_fs_info *fs_info);
 struct extent_buffer *read_tree_block(struct btrfs_fs_info *fs_info, u64 bytenr,
                                      struct btrfs_tree_parent_check *check);
 int btrfs_start_pre_rw_mount(struct btrfs_fs_info *fs_info);
 int btrfs_check_super_csum(struct btrfs_fs_info *fs_info,
                           const struct btrfs_super_block *disk_sb);
-int __cold open_ctree(struct super_block *sb,
-              struct btrfs_fs_devices *fs_devices,
-              char *options);
+int __cold open_ctree(struct super_block *sb, struct btrfs_fs_devices *fs_devices,
+                     const char *options);
 void __cold close_ctree(struct btrfs_fs_info *fs_info);
-int btrfs_validate_super(struct btrfs_fs_info *fs_info,
-                        struct btrfs_super_block *sb, int mirror_num);
+int btrfs_validate_super(const struct btrfs_fs_info *fs_info,
+                        const struct btrfs_super_block *sb, int mirror_num);
 int btrfs_check_features(struct btrfs_fs_info *fs_info, bool is_rw_mount);
 int write_all_supers(struct btrfs_fs_info *fs_info, int max_mirrors);
 struct btrfs_super_block *btrfs_read_dev_super(struct block_device *bdev);
                                                   int copy_num, bool drop_cache);
 int btrfs_commit_super(struct btrfs_fs_info *fs_info);
 struct btrfs_root *btrfs_read_tree_root(struct btrfs_root *tree_root,
-                                       struct btrfs_key *key);
+                                       const struct btrfs_key *key);
 int btrfs_insert_fs_root(struct btrfs_fs_info *fs_info,
                         struct btrfs_root *root);
 void btrfs_free_fs_roots(struct btrfs_fs_info *fs_info);
 void btrfs_drop_and_free_fs_root(struct btrfs_fs_info *fs_info,
                                 struct btrfs_root *root);
 int btrfs_validate_extent_buffer(struct extent_buffer *eb,
-                                struct btrfs_tree_parent_check *check);
+                                const struct btrfs_tree_parent_check *check);
 #ifdef CONFIG_BTRFS_FS_RUN_SANITY_TESTS
 struct btrfs_root *btrfs_alloc_dummy_root(struct btrfs_fs_info *fs_info);
 #endif
 int btrfs_buffer_uptodate(struct extent_buffer *buf, u64 parent_transid,
                          int atomic);
 int btrfs_read_extent_buffer(struct extent_buffer *buf,
-                            struct btrfs_tree_parent_check *check);
+                            const struct btrfs_tree_parent_check *check);
 
 blk_status_t btree_csum_one_bio(struct btrfs_bio *bbio);
 int btrfs_alloc_log_tree_node(struct btrfs_trans_handle *trans,
 
 }
 
 static void process_one_page(struct btrfs_fs_info *fs_info,
-                            struct page *page, struct page *locked_page,
+                            struct page *page, const struct page *locked_page,
                             unsigned long page_ops, u64 start, u64 end)
 {
        struct folio *folio = page_folio(page);
 }
 
 static void __process_pages_contig(struct address_space *mapping,
-                                  struct page *locked_page, u64 start, u64 end,
+                                  const struct page *locked_page, u64 start, u64 end,
                                   unsigned long page_ops)
 {
        struct btrfs_fs_info *fs_info = inode_to_fs_info(mapping->host);
        }
 }
 
-static noinline void __unlock_for_delalloc(struct inode *inode,
-                                          struct page *locked_page,
+static noinline void __unlock_for_delalloc(const struct inode *inode,
+                                          const struct page *locked_page,
                                           u64 start, u64 end)
 {
        unsigned long index = start >> PAGE_SHIFT;
 }
 
 static noinline int lock_delalloc_pages(struct inode *inode,
-                                       struct page *locked_page,
+                                       const struct page *locked_page,
                                        u64 start,
                                        u64 end)
 {
 }
 
 void extent_clear_unlock_delalloc(struct btrfs_inode *inode, u64 start, u64 end,
-                                 struct page *locked_page,
+                                 const struct page *locked_page,
                                  struct extent_state **cached,
                                  u32 clear_bits, unsigned long page_ops)
 {
  * Return the next dirty range in [@start, @end).
  * If no dirty range is found, @start will be page_offset(page) + PAGE_SIZE.
  */
-static void find_next_dirty_byte(struct btrfs_fs_info *fs_info,
+static void find_next_dirty_byte(const struct btrfs_fs_info *fs_info,
                                 struct page *page, u64 *start, u64 *end)
 {
        struct folio *folio = page_folio(page);
  * context.
  */
 static struct extent_buffer *find_extent_buffer_nolock(
-               struct btrfs_fs_info *fs_info, u64 start)
+               const struct btrfs_fs_info *fs_info, u64 start)
 {
        struct extent_buffer *eb;
 
  * already been ran (aka, ordered extent inserted) and all pages are still
  * locked.
  */
-void extent_write_locked_range(struct inode *inode, struct page *locked_page,
+void extent_write_locked_range(struct inode *inode, const struct page *locked_page,
                               u64 start, u64 end, struct writeback_control *wbc,
                               bool pages_dirty)
 {
        return false;
 }
 
-static void detach_extent_buffer_folio(struct extent_buffer *eb, struct folio *folio)
+static void detach_extent_buffer_folio(const struct extent_buffer *eb, struct folio *folio)
 {
        struct btrfs_fs_info *fs_info = eb->fs_info;
        const bool mapped = !test_bit(EXTENT_BUFFER_UNMAPPED, &eb->bflags);
 }
 
 /* Release all pages attached to the extent buffer */
-static void btrfs_release_extent_buffer_pages(struct extent_buffer *eb)
+static void btrfs_release_extent_buffer_pages(const struct extent_buffer *eb)
 {
        ASSERT(!extent_buffer_under_io(eb));
 
 }
 
 int read_extent_buffer_pages(struct extent_buffer *eb, int wait, int mirror_num,
-                            struct btrfs_tree_parent_check *check)
+                            const struct btrfs_tree_parent_check *check)
 {
        struct btrfs_bio *bbio;
        bool ret;
 
 #define GANG_LOOKUP_SIZE       16
 static struct extent_buffer *get_next_extent_buffer(
-               struct btrfs_fs_info *fs_info, struct page *page, u64 bytenr)
+               const struct btrfs_fs_info *fs_info, struct page *page, u64 bytenr)
 {
        struct extent_buffer *gang[GANG_LOOKUP_SIZE];
        struct extent_buffer *found = NULL;
 
 int try_release_extent_buffer(struct page *page);
 
 int btrfs_read_folio(struct file *file, struct folio *folio);
-void extent_write_locked_range(struct inode *inode, struct page *locked_page,
+void extent_write_locked_range(struct inode *inode, const struct page *locked_page,
                               u64 start, u64 end, struct writeback_control *wbc,
                               bool pages_dirty);
 int btrfs_writepages(struct address_space *mapping, struct writeback_control *wbc);
 #define WAIT_COMPLETE  1
 #define WAIT_PAGE_LOCK 2
 int read_extent_buffer_pages(struct extent_buffer *eb, int wait, int mirror_num,
-                            struct btrfs_tree_parent_check *parent_check);
+                            const struct btrfs_tree_parent_check *parent_check);
 void wait_on_extent_buffer_writeback(struct extent_buffer *eb);
 void btrfs_readahead_tree_block(struct btrfs_fs_info *fs_info,
                                u64 bytenr, u64 owner_root, u64 gen, int level);
 void clear_extent_buffer_uptodate(struct extent_buffer *eb);
 void extent_range_clear_dirty_for_io(struct inode *inode, u64 start, u64 end);
 void extent_clear_unlock_delalloc(struct btrfs_inode *inode, u64 start, u64 end,
-                                 struct page *locked_page,
+                                 const struct page *locked_page,
                                  struct extent_state **cached,
                                  u32 bits_to_clear, unsigned long page_ops);
 int extent_invalidate_folio(struct extent_io_tree *tree,
 
 /*
  * Count how many fs_info->max_extent_size cover the @size
  */
-static inline u32 count_max_extents(struct btrfs_fs_info *fs_info, u64 size)
+static inline u32 count_max_extents(const struct btrfs_fs_info *fs_info, u64 size)
 {
 #ifdef CONFIG_BTRFS_FS_RUN_SANITY_TESTS
        if (!fs_info)
 #define btrfs_test_opt(fs_info, opt)   ((fs_info)->mount_opt & \
                                         BTRFS_MOUNT_##opt)
 
-static inline int btrfs_fs_closing(struct btrfs_fs_info *fs_info)
+static inline int btrfs_fs_closing(const struct btrfs_fs_info *fs_info)
 {
        /* Do it this way so we only ever do one test_bit in the normal case. */
        if (test_bit(BTRFS_FS_CLOSING_START, &fs_info->flags)) {
  * since setting and checking for SB_RDONLY in the superblock's flags is not
  * atomic.
  */
-static inline int btrfs_need_cleaner_sleep(struct btrfs_fs_info *fs_info)
+static inline int btrfs_need_cleaner_sleep(const struct btrfs_fs_info *fs_info)
 {
        return test_bit(BTRFS_FS_STATE_RO, &fs_info->fs_state) ||
                btrfs_fs_closing(fs_info);
 
 #define EXPORT_FOR_TESTS
 
-static inline int btrfs_is_testing(struct btrfs_fs_info *fs_info)
+static inline int btrfs_is_testing(const struct btrfs_fs_info *fs_info)
 {
        return test_bit(BTRFS_FS_STATE_DUMMY_FS_INFO, &fs_info->fs_state);
 }
 
 #define EXPORT_FOR_TESTS static
 
-static inline int btrfs_is_testing(struct btrfs_fs_info *fs_info)
+static inline int btrfs_is_testing(const struct btrfs_fs_info *fs_info)
 {
        return 0;
 }
 
        return 0;
 }
 
-int __pure btrfs_is_empty_uuid(u8 *uuid)
+int __pure btrfs_is_empty_uuid(const u8 *uuid)
 {
        int i;
 
 
                       struct dentry *dentry, struct fileattr *fa);
 int btrfs_ioctl_get_supported_features(void __user *arg);
 void btrfs_sync_inode_flags_to_i_flags(struct inode *inode);
-int __pure btrfs_is_empty_uuid(u8 *uuid);
+int __pure btrfs_is_empty_uuid(const u8 *uuid);
 void btrfs_update_ioctl_balance_args(struct btrfs_fs_info *fs_info,
                                     struct btrfs_ioctl_balance_args *bargs);
 
 
        u64 bytenr;
 };
 
-static inline struct rb_node *rb_simple_search(struct rb_root *root, u64 bytenr)
+static inline struct rb_node *rb_simple_search(const struct rb_root *root, u64 bytenr)
 {
        struct rb_node *node = root->rb_node;
        struct rb_simple_node *entry;
  * Return the rb_node that start at or after @bytenr.  If there is no entry at
  * or after @bytner return NULL.
  */
-static inline struct rb_node *rb_simple_search_first(struct rb_root *root,
+static inline struct rb_node *rb_simple_search_first(const struct rb_root *root,
                                                     u64 bytenr)
 {
        struct rb_node *node = root->rb_node, *ret = NULL;
 
        int (*validate)(const struct btrfs_inode *inode, const char *value,
                        size_t len);
        int (*apply)(struct inode *inode, const char *value, size_t len);
-       const char *(*extract)(struct inode *inode);
+       const char *(*extract)(const struct inode *inode);
        bool (*ignore)(const struct btrfs_inode *inode);
        int inheritable;
 };
        return false;
 }
 
-static const char *prop_compression_extract(struct inode *inode)
+static const char *prop_compression_extract(const struct inode *inode)
 {
        switch (BTRFS_I(inode)->prop_compress) {
        case BTRFS_COMPRESS_ZLIB:
 };
 
 int btrfs_inode_inherit_props(struct btrfs_trans_handle *trans,
-                             struct inode *inode, struct inode *parent)
+                             struct inode *inode, const struct inode *parent)
 {
        struct btrfs_root *root = BTRFS_I(inode)->root;
        struct btrfs_fs_info *fs_info = root->fs_info;
 
 
 int btrfs_inode_inherit_props(struct btrfs_trans_handle *trans,
                              struct inode *inode,
-                             struct inode *dir);
+                             const struct inode *dir);
 
 #endif
 
 #include "root-tree.h"
 #include "tree-checker.h"
 
-enum btrfs_qgroup_mode btrfs_qgroup_mode(struct btrfs_fs_info *fs_info)
+enum btrfs_qgroup_mode btrfs_qgroup_mode(const struct btrfs_fs_info *fs_info)
 {
        if (!test_bit(BTRFS_FS_QUOTA_ENABLED, &fs_info->flags))
                return BTRFS_QGROUP_MODE_DISABLED;
        return BTRFS_QGROUP_MODE_FULL;
 }
 
-bool btrfs_qgroup_enabled(struct btrfs_fs_info *fs_info)
+bool btrfs_qgroup_enabled(const struct btrfs_fs_info *fs_info)
 {
        return btrfs_qgroup_mode(fs_info) != BTRFS_QGROUP_MODE_DISABLED;
 }
 
-bool btrfs_qgroup_full_accounting(struct btrfs_fs_info *fs_info)
+bool btrfs_qgroup_full_accounting(const struct btrfs_fs_info *fs_info)
 {
        return btrfs_qgroup_mode(fs_info) == BTRFS_QGROUP_MODE_FULL;
 }
 
 static void qgroup_rsv_add_by_qgroup(struct btrfs_fs_info *fs_info,
                                     struct btrfs_qgroup *dest,
-                                    struct btrfs_qgroup *src)
+                                    const struct btrfs_qgroup *src)
 {
        int i;
 
 
 static void qgroup_rsv_release_by_qgroup(struct btrfs_fs_info *fs_info,
                                         struct btrfs_qgroup *dest,
-                                         struct btrfs_qgroup *src)
+                                        const struct btrfs_qgroup *src)
 {
        int i;
 
        qg->new_refcnt += mod;
 }
 
-static inline u64 btrfs_qgroup_get_old_refcnt(struct btrfs_qgroup *qg, u64 seq)
+static inline u64 btrfs_qgroup_get_old_refcnt(const struct btrfs_qgroup *qg, u64 seq)
 {
        if (qg->old_refcnt < seq)
                return 0;
        return qg->old_refcnt - seq;
 }
 
-static inline u64 btrfs_qgroup_get_new_refcnt(struct btrfs_qgroup *qg, u64 seq)
+static inline u64 btrfs_qgroup_get_new_refcnt(const struct btrfs_qgroup *qg, u64 seq)
 {
        if (qg->new_refcnt < seq)
                return 0;
 static void qgroup_rescan_zero_tracking(struct btrfs_fs_info *fs_info);
 
 /* must be called with qgroup_ioctl_lock held */
-static struct btrfs_qgroup *find_qgroup_rb(struct btrfs_fs_info *fs_info,
+static struct btrfs_qgroup *find_qgroup_rb(const struct btrfs_fs_info *fs_info,
                                           u64 qgroupid)
 {
        struct rb_node *n = fs_info->qgroup_tree.rb_node;
 }
 
 #ifdef CONFIG_BTRFS_FS_RUN_SANITY_TESTS
-int btrfs_verify_qgroup_counts(struct btrfs_fs_info *fs_info, u64 qgroupid,
+int btrfs_verify_qgroup_counts(const struct btrfs_fs_info *fs_info, u64 qgroupid,
                               u64 rfer, u64 excl)
 {
        struct btrfs_qgroup *qgroup;
  * Return false if no reserved space is left.
  * Return true if some reserved space is leaked.
  */
-bool btrfs_check_quota_leak(struct btrfs_fs_info *fs_info)
+bool btrfs_check_quota_leak(const struct btrfs_fs_info *fs_info)
 {
        struct rb_node *node;
        bool ret = false;
 }
 
 int btrfs_record_squota_delta(struct btrfs_fs_info *fs_info,
-                             struct btrfs_squota_delta *delta)
+                             const struct btrfs_squota_delta *delta)
 {
        int ret;
        struct btrfs_qgroup *qgroup;
 
        BTRFS_QGROUP_MODE_SIMPLE
 };
 
-enum btrfs_qgroup_mode btrfs_qgroup_mode(struct btrfs_fs_info *fs_info);
-bool btrfs_qgroup_enabled(struct btrfs_fs_info *fs_info);
-bool btrfs_qgroup_full_accounting(struct btrfs_fs_info *fs_info);
+enum btrfs_qgroup_mode btrfs_qgroup_mode(const struct btrfs_fs_info *fs_info);
+bool btrfs_qgroup_enabled(const struct btrfs_fs_info *fs_info);
+bool btrfs_qgroup_full_accounting(const struct btrfs_fs_info *fs_info);
 int btrfs_quota_enable(struct btrfs_fs_info *fs_info,
                       struct btrfs_ioctl_quota_ctl_args *quota_ctl_args);
 int btrfs_quota_disable(struct btrfs_fs_info *fs_info);
                               enum btrfs_qgroup_rsv_type type);
 
 #ifdef CONFIG_BTRFS_FS_RUN_SANITY_TESTS
-int btrfs_verify_qgroup_counts(struct btrfs_fs_info *fs_info, u64 qgroupid,
+int btrfs_verify_qgroup_counts(const struct btrfs_fs_info *fs_info, u64 qgroupid,
                               u64 rfer, u64 excl);
 #endif
 
 int btrfs_qgroup_trace_subtree_after_cow(struct btrfs_trans_handle *trans,
                struct btrfs_root *root, struct extent_buffer *eb);
 void btrfs_qgroup_destroy_extent_records(struct btrfs_transaction *trans);
-bool btrfs_check_quota_leak(struct btrfs_fs_info *fs_info);
+bool btrfs_check_quota_leak(const struct btrfs_fs_info *fs_info);
 void btrfs_free_squota_rsv(struct btrfs_fs_info *fs_info, u64 root, u64 rsv_bytes);
 int btrfs_record_squota_delta(struct btrfs_fs_info *fs_info,
-                             struct btrfs_squota_delta *delta);
+                             const struct btrfs_squota_delta *delta);
 
 #endif
 
                      btrfs_root_id(root), root->dedupe_in_progress);
 }
 
-long btrfs_ioctl_send(struct inode *inode, struct btrfs_ioctl_send_args *arg)
+long btrfs_ioctl_send(struct inode *inode, const struct btrfs_ioctl_send_args *arg)
 {
        int ret = 0;
        struct btrfs_root *send_root = BTRFS_I(inode)->root;
 
        __BTRFS_SEND_A_MAX              = 35,
 };
 
-long btrfs_ioctl_send(struct inode *inode, struct btrfs_ioctl_send_args *arg);
+long btrfs_ioctl_send(struct inode *inode, const struct btrfs_ioctl_send_args *arg);
 
 #endif
 
        btrfs_clear_opt(fs_info->mount_opt, NOSPACECACHE);
 }
 
-static bool check_ro_option(struct btrfs_fs_info *fs_info,
+static bool check_ro_option(const struct btrfs_fs_info *fs_info,
                            unsigned long mount_opt, unsigned long opt,
                            const char *opt_name)
 {
        return false;
 }
 
-bool btrfs_check_options(struct btrfs_fs_info *info, unsigned long *mount_opt,
+bool btrfs_check_options(const struct btrfs_fs_info *info, unsigned long *mount_opt,
                         unsigned long flags)
 {
        bool ret = true;
 
 struct super_block;
 struct btrfs_fs_info;
 
-bool btrfs_check_options(struct btrfs_fs_info *info, unsigned long *mount_opt,
+bool btrfs_check_options(const struct btrfs_fs_info *info, unsigned long *mount_opt,
                         unsigned long flags);
 int btrfs_sync_fs(struct super_block *sb, int wait);
 char *btrfs_get_subvol_name_from_objectid(struct btrfs_fs_info *fs_info,
 
 #include "accessors.h"
 #include "uuid-tree.h"
 
-static void btrfs_uuid_to_key(u8 *uuid, u8 type, struct btrfs_key *key)
+static void btrfs_uuid_to_key(const u8 *uuid, u8 type, struct btrfs_key *key)
 {
        key->type = type;
        key->objectid = get_unaligned_le64(uuid);
 }
 
 /* return -ENOENT for !found, < 0 for errors, or 0 if an item was found */
-static int btrfs_uuid_tree_lookup(struct btrfs_root *uuid_root, u8 *uuid,
+static int btrfs_uuid_tree_lookup(struct btrfs_root *uuid_root, const u8 *uuid,
                                  u8 type, u64 subid)
 {
        int ret;
        return ret;
 }
 
-int btrfs_uuid_tree_add(struct btrfs_trans_handle *trans, u8 *uuid, u8 type,
+int btrfs_uuid_tree_add(struct btrfs_trans_handle *trans, const u8 *uuid, u8 type,
                        u64 subid_cpu)
 {
        struct btrfs_fs_info *fs_info = trans->fs_info;
        return ret;
 }
 
-int btrfs_uuid_tree_remove(struct btrfs_trans_handle *trans, u8 *uuid, u8 type,
+int btrfs_uuid_tree_remove(struct btrfs_trans_handle *trans, const u8 *uuid, u8 type,
                        u64 subid)
 {
        struct btrfs_fs_info *fs_info = trans->fs_info;
  * < 0 if an error occurred
  */
 static int btrfs_check_uuid_tree_entry(struct btrfs_fs_info *fs_info,
-                                      u8 *uuid, u8 type, u64 subvolid)
+                                      const u8 *uuid, u8 type, u64 subvolid)
 {
        int ret = 0;
        struct btrfs_root *subvol_root;
 
 struct btrfs_trans_handle;
 struct btrfs_fs_info;
 
-int btrfs_uuid_tree_add(struct btrfs_trans_handle *trans, u8 *uuid, u8 type,
+int btrfs_uuid_tree_add(struct btrfs_trans_handle *trans, const u8 *uuid, u8 type,
                        u64 subid);
-int btrfs_uuid_tree_remove(struct btrfs_trans_handle *trans, u8 *uuid, u8 type,
+int btrfs_uuid_tree_remove(struct btrfs_trans_handle *trans, const u8 *uuid, u8 type,
                        u64 subid);
 int btrfs_uuid_tree_iterate(struct btrfs_fs_info *fs_info);
 
 
        return -EINVAL;
 }
 
-u8 *btrfs_sb_fsid_ptr(struct btrfs_super_block *sb)
+const u8 *btrfs_sb_fsid_ptr(const struct btrfs_super_block *sb)
 {
        bool has_metadata_uuid = (btrfs_super_incompat_flags(sb) &
                                  BTRFS_FEATURE_INCOMPAT_METADATA_UUID);
 
 bool btrfs_repair_one_zone(struct btrfs_fs_info *fs_info, u64 logical);
 
 bool btrfs_pinned_by_swapfile(struct btrfs_fs_info *fs_info, void *ptr);
-u8 *btrfs_sb_fsid_ptr(struct btrfs_super_block *sb);
+const u8 *btrfs_sb_fsid_ptr(const struct btrfs_super_block *sb);
 
 #endif
 
 #include "accessors.h"
 #include "dir-item.h"
 
-int btrfs_getxattr(struct inode *inode, const char *name,
+int btrfs_getxattr(const struct inode *inode, const char *name,
                                void *buffer, size_t size)
 {
        struct btrfs_dir_item *di;
 
 
 extern const struct xattr_handler * const btrfs_xattr_handlers[];
 
-int btrfs_getxattr(struct inode *inode, const char *name,
+int btrfs_getxattr(const struct inode *inode, const char *name,
                void *buffer, size_t size);
 int btrfs_setxattr(struct btrfs_trans_handle *trans, struct inode *inode,
                   const char *name, const void *value, size_t size, int flags);
 
        return 0;
 }
 
-int btrfs_check_mountopts_zoned(struct btrfs_fs_info *info, unsigned long *mount_opt)
+int btrfs_check_mountopts_zoned(const struct btrfs_fs_info *info, unsigned long *mount_opt)
 {
        if (!btrfs_is_zoned(info))
                return 0;
 
 void btrfs_destroy_dev_zone_info(struct btrfs_device *device);
 struct btrfs_zoned_device_info *btrfs_clone_dev_zone_info(struct btrfs_device *orig_dev);
 int btrfs_check_zoned_mode(struct btrfs_fs_info *fs_info);
-int btrfs_check_mountopts_zoned(struct btrfs_fs_info *info, unsigned long *mount_opt);
+int btrfs_check_mountopts_zoned(const struct btrfs_fs_info *info, unsigned long *mount_opt);
 int btrfs_sb_log_location_bdev(struct block_device *bdev, int mirror, int rw,
                               u64 *bytenr_ret);
 int btrfs_sb_log_location(struct btrfs_device *device, int mirror, int rw,
        return -EOPNOTSUPP;
 }
 
-static inline int btrfs_check_mountopts_zoned(struct btrfs_fs_info *info,
+static inline int btrfs_check_mountopts_zoned(const struct btrfs_fs_info *info,
                                              unsigned long *mount_opt)
 {
        return 0;