Commit 3ffbd68c authored by David Sterba's avatar David Sterba

btrfs: simplify pointer chasing of local fs_info variables

Functions that get btrfs inode can simply reach the fs_info by
dereferencing the root and this looks a bit more straightforward
compared to the btrfs_sb(...) indirection.

If the transaction handle is available and not NULL it's used instead.
Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
parent 37508515
...@@ -1222,7 +1222,7 @@ int btrfs_commit_inode_delayed_items(struct btrfs_trans_handle *trans, ...@@ -1222,7 +1222,7 @@ int btrfs_commit_inode_delayed_items(struct btrfs_trans_handle *trans,
int btrfs_commit_inode_delayed_inode(struct btrfs_inode *inode) int btrfs_commit_inode_delayed_inode(struct btrfs_inode *inode)
{ {
struct btrfs_fs_info *fs_info = btrfs_sb(inode->vfs_inode.i_sb); struct btrfs_fs_info *fs_info = inode->root->fs_info;
struct btrfs_trans_handle *trans; struct btrfs_trans_handle *trans;
struct btrfs_delayed_node *delayed_node = btrfs_get_delayed_node(inode); struct btrfs_delayed_node *delayed_node = btrfs_get_delayed_node(inode);
struct btrfs_path *path; struct btrfs_path *path;
...@@ -1837,7 +1837,7 @@ int btrfs_delayed_update_inode(struct btrfs_trans_handle *trans, ...@@ -1837,7 +1837,7 @@ int btrfs_delayed_update_inode(struct btrfs_trans_handle *trans,
int btrfs_delayed_delete_inode_ref(struct btrfs_inode *inode) int btrfs_delayed_delete_inode_ref(struct btrfs_inode *inode)
{ {
struct btrfs_fs_info *fs_info = btrfs_sb(inode->vfs_inode.i_sb); struct btrfs_fs_info *fs_info = inode->root->fs_info;
struct btrfs_delayed_node *delayed_node; struct btrfs_delayed_node *delayed_node;
/* /*
......
...@@ -212,7 +212,7 @@ struct extent_map *btree_get_extent(struct btrfs_inode *inode, ...@@ -212,7 +212,7 @@ struct extent_map *btree_get_extent(struct btrfs_inode *inode,
struct page *page, size_t pg_offset, u64 start, u64 len, struct page *page, size_t pg_offset, u64 start, u64 len,
int create) int create)
{ {
struct btrfs_fs_info *fs_info = btrfs_sb(inode->vfs_inode.i_sb); struct btrfs_fs_info *fs_info = inode->root->fs_info;
struct extent_map_tree *em_tree = &inode->extent_tree; struct extent_map_tree *em_tree = &inode->extent_tree;
struct extent_map *em; struct extent_map *em;
int ret; int ret;
......
...@@ -5889,7 +5889,7 @@ static void btrfs_calculate_inode_block_rsv_size(struct btrfs_fs_info *fs_info, ...@@ -5889,7 +5889,7 @@ static void btrfs_calculate_inode_block_rsv_size(struct btrfs_fs_info *fs_info,
int btrfs_delalloc_reserve_metadata(struct btrfs_inode *inode, u64 num_bytes) int btrfs_delalloc_reserve_metadata(struct btrfs_inode *inode, u64 num_bytes)
{ {
struct btrfs_fs_info *fs_info = btrfs_sb(inode->vfs_inode.i_sb); struct btrfs_fs_info *fs_info = inode->root->fs_info;
unsigned nr_extents; unsigned nr_extents;
enum btrfs_reserve_flush_enum flush = BTRFS_RESERVE_FLUSH_ALL; enum btrfs_reserve_flush_enum flush = BTRFS_RESERVE_FLUSH_ALL;
int ret = 0; int ret = 0;
...@@ -5962,7 +5962,7 @@ int btrfs_delalloc_reserve_metadata(struct btrfs_inode *inode, u64 num_bytes) ...@@ -5962,7 +5962,7 @@ int btrfs_delalloc_reserve_metadata(struct btrfs_inode *inode, u64 num_bytes)
void btrfs_delalloc_release_metadata(struct btrfs_inode *inode, u64 num_bytes, void btrfs_delalloc_release_metadata(struct btrfs_inode *inode, u64 num_bytes,
bool qgroup_free) bool qgroup_free)
{ {
struct btrfs_fs_info *fs_info = btrfs_sb(inode->vfs_inode.i_sb); struct btrfs_fs_info *fs_info = inode->root->fs_info;
num_bytes = ALIGN(num_bytes, fs_info->sectorsize); num_bytes = ALIGN(num_bytes, fs_info->sectorsize);
spin_lock(&inode->lock); spin_lock(&inode->lock);
...@@ -5991,7 +5991,7 @@ void btrfs_delalloc_release_metadata(struct btrfs_inode *inode, u64 num_bytes, ...@@ -5991,7 +5991,7 @@ void btrfs_delalloc_release_metadata(struct btrfs_inode *inode, u64 num_bytes,
void btrfs_delalloc_release_extents(struct btrfs_inode *inode, u64 num_bytes, void btrfs_delalloc_release_extents(struct btrfs_inode *inode, u64 num_bytes,
bool qgroup_free) bool qgroup_free)
{ {
struct btrfs_fs_info *fs_info = btrfs_sb(inode->vfs_inode.i_sb); struct btrfs_fs_info *fs_info = inode->root->fs_info;
unsigned num_extents; unsigned num_extents;
spin_lock(&inode->lock); spin_lock(&inode->lock);
......
...@@ -922,7 +922,7 @@ void btrfs_extent_item_to_extent_map(struct btrfs_inode *inode, ...@@ -922,7 +922,7 @@ void btrfs_extent_item_to_extent_map(struct btrfs_inode *inode,
const bool new_inline, const bool new_inline,
struct extent_map *em) struct extent_map *em)
{ {
struct btrfs_fs_info *fs_info = btrfs_sb(inode->vfs_inode.i_sb); struct btrfs_fs_info *fs_info = inode->root->fs_info;
struct btrfs_root *root = inode->root; struct btrfs_root *root = inode->root;
struct extent_buffer *leaf = path->nodes[0]; struct extent_buffer *leaf = path->nodes[0];
const int slot = path->slots[0]; const int slot = path->slots[0];
......
...@@ -83,7 +83,7 @@ static int __compare_inode_defrag(struct inode_defrag *defrag1, ...@@ -83,7 +83,7 @@ static int __compare_inode_defrag(struct inode_defrag *defrag1,
static int __btrfs_add_inode_defrag(struct btrfs_inode *inode, static int __btrfs_add_inode_defrag(struct btrfs_inode *inode,
struct inode_defrag *defrag) struct inode_defrag *defrag)
{ {
struct btrfs_fs_info *fs_info = btrfs_sb(inode->vfs_inode.i_sb); struct btrfs_fs_info *fs_info = inode->root->fs_info;
struct inode_defrag *entry; struct inode_defrag *entry;
struct rb_node **p; struct rb_node **p;
struct rb_node *parent = NULL; struct rb_node *parent = NULL;
...@@ -135,8 +135,8 @@ static inline int __need_auto_defrag(struct btrfs_fs_info *fs_info) ...@@ -135,8 +135,8 @@ static inline int __need_auto_defrag(struct btrfs_fs_info *fs_info)
int btrfs_add_inode_defrag(struct btrfs_trans_handle *trans, int btrfs_add_inode_defrag(struct btrfs_trans_handle *trans,
struct btrfs_inode *inode) struct btrfs_inode *inode)
{ {
struct btrfs_fs_info *fs_info = btrfs_sb(inode->vfs_inode.i_sb);
struct btrfs_root *root = inode->root; struct btrfs_root *root = inode->root;
struct btrfs_fs_info *fs_info = root->fs_info;
struct inode_defrag *defrag; struct inode_defrag *defrag;
u64 transid; u64 transid;
int ret; int ret;
...@@ -185,7 +185,7 @@ int btrfs_add_inode_defrag(struct btrfs_trans_handle *trans, ...@@ -185,7 +185,7 @@ int btrfs_add_inode_defrag(struct btrfs_trans_handle *trans,
static void btrfs_requeue_inode_defrag(struct btrfs_inode *inode, static void btrfs_requeue_inode_defrag(struct btrfs_inode *inode,
struct inode_defrag *defrag) struct inode_defrag *defrag)
{ {
struct btrfs_fs_info *fs_info = btrfs_sb(inode->vfs_inode.i_sb); struct btrfs_fs_info *fs_info = inode->root->fs_info;
int ret; int ret;
if (!__need_auto_defrag(fs_info)) if (!__need_auto_defrag(fs_info))
...@@ -1132,7 +1132,7 @@ static int extent_mergeable(struct extent_buffer *leaf, int slot, ...@@ -1132,7 +1132,7 @@ static int extent_mergeable(struct extent_buffer *leaf, int slot,
int btrfs_mark_extent_written(struct btrfs_trans_handle *trans, int btrfs_mark_extent_written(struct btrfs_trans_handle *trans,
struct btrfs_inode *inode, u64 start, u64 end) struct btrfs_inode *inode, u64 start, u64 end)
{ {
struct btrfs_fs_info *fs_info = btrfs_sb(inode->vfs_inode.i_sb); struct btrfs_fs_info *fs_info = trans->fs_info;
struct btrfs_root *root = inode->root; struct btrfs_root *root = inode->root;
struct extent_buffer *leaf; struct extent_buffer *leaf;
struct btrfs_path *path; struct btrfs_path *path;
...@@ -1469,7 +1469,7 @@ lock_and_cleanup_extent_if_need(struct btrfs_inode *inode, struct page **pages, ...@@ -1469,7 +1469,7 @@ lock_and_cleanup_extent_if_need(struct btrfs_inode *inode, struct page **pages,
u64 *lockstart, u64 *lockend, u64 *lockstart, u64 *lockend,
struct extent_state **cached_state) struct extent_state **cached_state)
{ {
struct btrfs_fs_info *fs_info = btrfs_sb(inode->vfs_inode.i_sb); struct btrfs_fs_info *fs_info = inode->root->fs_info;
u64 start_pos; u64 start_pos;
u64 last_pos; u64 last_pos;
int i; int i;
...@@ -1525,7 +1525,7 @@ lock_and_cleanup_extent_if_need(struct btrfs_inode *inode, struct page **pages, ...@@ -1525,7 +1525,7 @@ lock_and_cleanup_extent_if_need(struct btrfs_inode *inode, struct page **pages,
static noinline int check_can_nocow(struct btrfs_inode *inode, loff_t pos, static noinline int check_can_nocow(struct btrfs_inode *inode, loff_t pos,
size_t *write_bytes) size_t *write_bytes)
{ {
struct btrfs_fs_info *fs_info = btrfs_sb(inode->vfs_inode.i_sb); struct btrfs_fs_info *fs_info = inode->root->fs_info;
struct btrfs_root *root = inode->root; struct btrfs_root *root = inode->root;
struct btrfs_ordered_extent *ordered; struct btrfs_ordered_extent *ordered;
u64 lockstart, lockend; u64 lockstart, lockend;
...@@ -2227,7 +2227,7 @@ static int fill_holes(struct btrfs_trans_handle *trans, ...@@ -2227,7 +2227,7 @@ static int fill_holes(struct btrfs_trans_handle *trans,
struct btrfs_inode *inode, struct btrfs_inode *inode,
struct btrfs_path *path, u64 offset, u64 end) struct btrfs_path *path, u64 offset, u64 end)
{ {
struct btrfs_fs_info *fs_info = btrfs_sb(inode->vfs_inode.i_sb); struct btrfs_fs_info *fs_info = trans->fs_info;
struct btrfs_root *root = inode->root; struct btrfs_root *root = inode->root;
struct extent_buffer *leaf; struct extent_buffer *leaf;
struct btrfs_file_extent_item *fi; struct btrfs_file_extent_item *fi;
......
...@@ -655,7 +655,7 @@ static int __load_free_space_cache(struct btrfs_root *root, struct inode *inode, ...@@ -655,7 +655,7 @@ static int __load_free_space_cache(struct btrfs_root *root, struct inode *inode,
struct btrfs_free_space_ctl *ctl, struct btrfs_free_space_ctl *ctl,
struct btrfs_path *path, u64 offset) struct btrfs_path *path, u64 offset)
{ {
struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb); struct btrfs_fs_info *fs_info = root->fs_info;
struct btrfs_free_space_header *header; struct btrfs_free_space_header *header;
struct extent_buffer *leaf; struct extent_buffer *leaf;
struct btrfs_io_ctl io_ctl; struct btrfs_io_ctl io_ctl;
...@@ -1123,13 +1123,10 @@ static int __btrfs_wait_cache_io(struct btrfs_root *root, ...@@ -1123,13 +1123,10 @@ static int __btrfs_wait_cache_io(struct btrfs_root *root,
{ {
int ret; int ret;
struct inode *inode = io_ctl->inode; struct inode *inode = io_ctl->inode;
struct btrfs_fs_info *fs_info;
if (!inode) if (!inode)
return 0; return 0;
fs_info = btrfs_sb(inode->i_sb);
/* Flush the dirty pages in the cache file. */ /* Flush the dirty pages in the cache file. */
ret = flush_dirty_cache(inode); ret = flush_dirty_cache(inode);
if (ret) if (ret)
...@@ -1145,7 +1142,7 @@ static int __btrfs_wait_cache_io(struct btrfs_root *root, ...@@ -1145,7 +1142,7 @@ static int __btrfs_wait_cache_io(struct btrfs_root *root,
BTRFS_I(inode)->generation = 0; BTRFS_I(inode)->generation = 0;
if (block_group) { if (block_group) {
#ifdef DEBUG #ifdef DEBUG
btrfs_err(fs_info, btrfs_err(root->fs_info,
"failed to write free space cache for block group %llu", "failed to write free space cache for block group %llu",
block_group->key.objectid); block_group->key.objectid);
#endif #endif
......
...@@ -1751,7 +1751,7 @@ static void btrfs_add_delalloc_inodes(struct btrfs_root *root, ...@@ -1751,7 +1751,7 @@ static void btrfs_add_delalloc_inodes(struct btrfs_root *root,
void __btrfs_del_delalloc_inode(struct btrfs_root *root, void __btrfs_del_delalloc_inode(struct btrfs_root *root,
struct btrfs_inode *inode) struct btrfs_inode *inode)
{ {
struct btrfs_fs_info *fs_info = btrfs_sb(inode->vfs_inode.i_sb); struct btrfs_fs_info *fs_info = root->fs_info;
if (!list_empty(&inode->delalloc_inodes)) { if (!list_empty(&inode->delalloc_inodes)) {
list_del_init(&inode->delalloc_inodes); list_del_init(&inode->delalloc_inodes);
...@@ -6418,7 +6418,7 @@ int btrfs_add_link(struct btrfs_trans_handle *trans, ...@@ -6418,7 +6418,7 @@ int btrfs_add_link(struct btrfs_trans_handle *trans,
struct btrfs_inode *parent_inode, struct btrfs_inode *inode, struct btrfs_inode *parent_inode, struct btrfs_inode *inode,
const char *name, int name_len, int add_backref, u64 index) const char *name, int name_len, int add_backref, u64 index)
{ {
struct btrfs_fs_info *fs_info = btrfs_sb(inode->vfs_inode.i_sb); struct btrfs_fs_info *fs_info = trans->fs_info;
int ret = 0; int ret = 0;
struct btrfs_key key; struct btrfs_key key;
struct btrfs_root *root = parent_inode->root; struct btrfs_root *root = parent_inode->root;
...@@ -6846,7 +6846,7 @@ struct extent_map *btrfs_get_extent(struct btrfs_inode *inode, ...@@ -6846,7 +6846,7 @@ struct extent_map *btrfs_get_extent(struct btrfs_inode *inode,
size_t pg_offset, u64 start, u64 len, size_t pg_offset, u64 start, u64 len,
int create) int create)
{ {
struct btrfs_fs_info *fs_info = btrfs_sb(inode->vfs_inode.i_sb); struct btrfs_fs_info *fs_info = inode->root->fs_info;
int ret; int ret;
int err = 0; int err = 0;
u64 extent_start = 0; u64 extent_start = 0;
......
...@@ -3739,7 +3739,7 @@ static noinline int copy_items(struct btrfs_trans_handle *trans, ...@@ -3739,7 +3739,7 @@ static noinline int copy_items(struct btrfs_trans_handle *trans,
int start_slot, int nr, int inode_only, int start_slot, int nr, int inode_only,
u64 logged_isize) u64 logged_isize)
{ {
struct btrfs_fs_info *fs_info = btrfs_sb(inode->vfs_inode.i_sb); struct btrfs_fs_info *fs_info = trans->fs_info;
unsigned long src_offset; unsigned long src_offset;
unsigned long dst_offset; unsigned long dst_offset;
struct btrfs_root *log = inode->root->log_root; struct btrfs_root *log = inode->root->log_root;
...@@ -5436,7 +5436,7 @@ static int btrfs_log_all_parents(struct btrfs_trans_handle *trans, ...@@ -5436,7 +5436,7 @@ static int btrfs_log_all_parents(struct btrfs_trans_handle *trans,
struct btrfs_inode *inode, struct btrfs_inode *inode,
struct btrfs_log_ctx *ctx) struct btrfs_log_ctx *ctx)
{ {
struct btrfs_fs_info *fs_info = btrfs_sb(inode->vfs_inode.i_sb); struct btrfs_fs_info *fs_info = trans->fs_info;
int ret; int ret;
struct btrfs_path *path; struct btrfs_path *path;
struct btrfs_key key; struct btrfs_key key;
...@@ -5971,7 +5971,7 @@ int btrfs_log_new_name(struct btrfs_trans_handle *trans, ...@@ -5971,7 +5971,7 @@ int btrfs_log_new_name(struct btrfs_trans_handle *trans,
struct btrfs_inode *inode, struct btrfs_inode *old_dir, struct btrfs_inode *inode, struct btrfs_inode *old_dir,
struct dentry *parent) struct dentry *parent)
{ {
struct btrfs_fs_info *fs_info = btrfs_sb(inode->vfs_inode.i_sb); struct btrfs_fs_info *fs_info = trans->fs_info;
/* /*
* this will force the logging code to walk the dentry chain * this will force the logging code to walk the dentry chain
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment