summaryrefslogtreecommitdiffstats
path: root/fs/btrfs/defrag.c
diff options
context:
space:
mode:
authorDavid Sterba <dsterba@suse.com>2023-09-14 16:45:41 +0200
committerDavid Sterba <dsterba@suse.com>2024-03-04 16:24:49 +0100
commit41044b41ad2c8c8165a42ec6e9a4096826dcf153 (patch)
tree9c99810f8a8fe29a29410a0b4170c708763e00e4 /fs/btrfs/defrag.c
parentb33d2e535f9b2a1c4210cfc4843ac0dbacbeebcc (diff)
downloadlinux-stable-41044b41ad2c8c8165a42ec6e9a4096826dcf153.tar.gz
linux-stable-41044b41ad2c8c8165a42ec6e9a4096826dcf153.tar.bz2
linux-stable-41044b41ad2c8c8165a42ec6e9a4096826dcf153.zip
btrfs: add helper to get fs_info from struct inode pointer
Add a convenience helper to get a fs_info from a VFS inode pointer instead of open coding the chain or using btrfs_sb() that in some cases does one more pointer hop. This is implemented as a macro (still with type checking) so we don't need full definitions of struct btrfs_inode, btrfs_root or btrfs_fs_info. Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com> Reviewed-by: Anand Jain <anand.jain@oracle.com> Signed-off-by: David Sterba <dsterba@suse.com>
Diffstat (limited to 'fs/btrfs/defrag.c')
-rw-r--r--fs/btrfs/defrag.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/fs/btrfs/defrag.c b/fs/btrfs/defrag.c
index 6f49de3ec92f..f17833a67af8 100644
--- a/fs/btrfs/defrag.c
+++ b/fs/btrfs/defrag.c
@@ -809,7 +809,7 @@ static u32 get_extent_max_capacity(const struct btrfs_fs_info *fs_info,
static bool defrag_check_next_extent(struct inode *inode, struct extent_map *em,
u32 extent_thresh, u64 newer_than, bool locked)
{
- struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb);
+ struct btrfs_fs_info *fs_info = inode_to_fs_info(inode);
struct extent_map *next;
bool ret = false;
@@ -1364,7 +1364,7 @@ int btrfs_defrag_file(struct inode *inode, struct file_ra_state *ra,
struct btrfs_ioctl_defrag_range_args *range,
u64 newer_than, unsigned long max_to_defrag)
{
- struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb);
+ struct btrfs_fs_info *fs_info = inode_to_fs_info(inode);
unsigned long sectors_defragged = 0;
u64 isize = i_size_read(inode);
u64 cur;