linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Josef Bacik <josef@toxicpanda.com>
To: linux-btrfs@vger.kernel.org, kernel-team@fb.com
Subject: [PATCH 12/15] btrfs: delete btrfs_inode_sectorsize helper
Date: Wed, 14 Sep 2022 19:04:48 -0400	[thread overview]
Message-ID: <030e2b0b061a8ae57037f810ae3bfb2b4c9b0f4d.1663196541.git.josef@toxicpanda.com> (raw)
In-Reply-To: <cover.1663196541.git.josef@toxicpanda.com>

This is defined in btrfs_inode.h, and dereferences btrfs_root and
btrfs_fs_info, both of which aren't defined in btrfs_inode.h.
Additionally, in many places we already have root or fs_info, so this
helper often makes the code harder to read.  So delete the helper and
simply open code it in the few places that we use it.

Signed-off-by: Josef Bacik <josef@toxicpanda.com>
---
 fs/btrfs/btrfs_inode.h |  5 -----
 fs/btrfs/extent_io.c   |  4 ++--
 fs/btrfs/file.c        | 11 +++++------
 3 files changed, 7 insertions(+), 13 deletions(-)

diff --git a/fs/btrfs/btrfs_inode.h b/fs/btrfs/btrfs_inode.h
index 890c9f979a3d..b24f78145fa6 100644
--- a/fs/btrfs/btrfs_inode.h
+++ b/fs/btrfs/btrfs_inode.h
@@ -251,11 +251,6 @@ struct btrfs_inode {
 	struct inode vfs_inode;
 };
 
-static inline u32 btrfs_inode_sectorsize(const struct btrfs_inode *inode)
-{
-	return inode->root->fs_info->sectorsize;
-}
-
 static inline struct btrfs_inode *BTRFS_I(const struct inode *inode)
 {
 	return container_of(inode, struct btrfs_inode, vfs_inode);
diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c
index b1d57727be02..f5eb6c66911c 100644
--- a/fs/btrfs/extent_io.c
+++ b/fs/btrfs/extent_io.c
@@ -3925,8 +3925,8 @@ int extent_fiemap(struct btrfs_inode *inode, struct fiemap_extent_info *fieinfo,
 		goto out;
 	}
 
-	lockstart = round_down(start, btrfs_inode_sectorsize(inode));
-	lockend = round_up(start + len, btrfs_inode_sectorsize(inode));
+	lockstart = round_down(start, root->fs_info->sectorsize);
+	lockend = round_up(start + len, root->fs_info->sectorsize);
 	prev_extent_end = lockstart;
 
 	lock_extent(&inode->io_tree, lockstart, lockend, &cached_state);
diff --git a/fs/btrfs/file.c b/fs/btrfs/file.c
index c395bf8e7522..c418468428ad 100644
--- a/fs/btrfs/file.c
+++ b/fs/btrfs/file.c
@@ -3010,9 +3010,8 @@ static int btrfs_punch_hole(struct file *file, loff_t offset, loff_t len)
 	if (ret)
 		goto out_only_mutex;
 
-	lockstart = round_up(offset, btrfs_inode_sectorsize(BTRFS_I(inode)));
-	lockend = round_down(offset + len,
-			     btrfs_inode_sectorsize(BTRFS_I(inode))) - 1;
+	lockstart = round_up(offset, fs_info->sectorsize);
+	lockend = round_down(offset + len, fs_info->sectorsize) - 1;
 	same_block = (BTRFS_BYTES_TO_BLKS(fs_info, offset))
 		== (BTRFS_BYTES_TO_BLKS(fs_info, offset + len - 1));
 	/*
@@ -3214,7 +3213,7 @@ enum {
 static int btrfs_zero_range_check_range_boundary(struct btrfs_inode *inode,
 						 u64 offset)
 {
-	const u64 sectorsize = btrfs_inode_sectorsize(inode);
+	const u64 sectorsize = inode->root->fs_info->sectorsize;
 	struct extent_map *em;
 	int ret;
 
@@ -3244,7 +3243,7 @@ static int btrfs_zero_range(struct inode *inode,
 	struct extent_changeset *data_reserved = NULL;
 	int ret;
 	u64 alloc_hint = 0;
-	const u64 sectorsize = btrfs_inode_sectorsize(BTRFS_I(inode));
+	const u64 sectorsize = fs_info->sectorsize;
 	u64 alloc_start = round_down(offset, sectorsize);
 	u64 alloc_end = round_up(offset + len, sectorsize);
 	u64 bytes_to_reserve = 0;
@@ -3430,7 +3429,7 @@ static long btrfs_fallocate(struct file *file, int mode,
 	u64 data_space_reserved = 0;
 	u64 qgroup_reserved = 0;
 	struct extent_map *em;
-	int blocksize = btrfs_inode_sectorsize(BTRFS_I(inode));
+	int blocksize = BTRFS_I(inode)->root->fs_info->sectorsize;
 	int ret;
 
 	/* Do not allow fallocate in ZONED mode */
-- 
2.26.3


  parent reply	other threads:[~2022-09-14 23:05 UTC|newest]

Thread overview: 49+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-14 23:04 [PATCH 00/15] btrfs: strip out btrfs_fs_info dependencies Josef Bacik
2022-09-14 23:04 ` [PATCH 01/15] btrfs: move btrfs_caching_type to block-group.h Josef Bacik
2022-09-15  6:09   ` Anand Jain
2022-09-15 14:34   ` Johannes Thumshirn
2022-09-14 23:04 ` [PATCH 02/15] btrfs: move btrfs_full_stripe_locks_tree into block-group.h Josef Bacik
2022-09-15  6:10   ` Anand Jain
2022-09-15 14:38   ` Johannes Thumshirn
2022-09-14 23:04 ` [PATCH 03/15] btrfs: move btrfs_init_async_reclaim_work prototype to space-info.h Josef Bacik
2022-09-15  6:11   ` Anand Jain
2022-09-15 14:42   ` Johannes Thumshirn
2022-09-14 23:04 ` [PATCH 04/15] btrfs: move btrfs_pinned_by_swapfile prototype into volumes.h Josef Bacik
2022-09-15 10:37   ` Anand Jain
2022-09-15 14:43   ` Johannes Thumshirn
2022-09-14 23:04 ` [PATCH 05/15] btrfs: remove temporary btrfs_map_token declaration in ctree.h Josef Bacik
2022-09-15 10:38   ` Anand Jain
2022-09-15 14:44   ` Johannes Thumshirn
2022-09-20 12:21   ` David Sterba
2022-09-14 23:04 ` [PATCH 06/15] btrfs: move static_assert() for btrfs_super_block into fs.c Josef Bacik
2022-09-15 10:42   ` Anand Jain
2022-09-15 14:45   ` Johannes Thumshirn
2022-09-19 20:54   ` David Sterba
2022-09-14 23:04 ` [PATCH 07/15] btrfs: move btrfs_swapfile_pin into volumes.h Josef Bacik
2022-09-15 10:44   ` Anand Jain
2022-09-19 21:22   ` David Sterba
2022-09-14 23:04 ` [PATCH 08/15] btrfs: move fs_info struct declarations to the top of ctree.h Josef Bacik
2022-09-15 10:45   ` Anand Jain
2022-09-15 14:47   ` Johannes Thumshirn
2022-09-14 23:04 ` [PATCH 09/15] btrfs: move btrfs_csum_ptr to inode.c Josef Bacik
2022-09-15 10:47   ` Anand Jain
2022-09-15 14:47   ` Johannes Thumshirn
2022-09-14 23:04 ` [PATCH 10/15] btrfs: move the fs_info related helpers closer to fs_info in ctree.h Josef Bacik
2022-09-15 11:28   ` Anand Jain
2022-09-15 14:50   ` Johannes Thumshirn
2022-09-14 23:04 ` [PATCH 11/15] btrfs: move btrfs_ordered_sum_size into file-item.c Josef Bacik
2022-09-15 11:29   ` Anand Jain
2022-09-15 14:50   ` Johannes Thumshirn
2022-09-14 23:04 ` Josef Bacik [this message]
2022-09-15 11:39   ` [PATCH 12/15] btrfs: delete btrfs_inode_sectorsize helper Anand Jain
2022-09-15 14:51   ` Johannes Thumshirn
2022-09-14 23:04 ` [PATCH 13/15] btrfs: delete btrfs_insert_inode_hash helper Josef Bacik
2022-09-15 12:43   ` Anand Jain
2022-09-15 14:52   ` Johannes Thumshirn
2022-09-14 23:04 ` [PATCH 14/15] btrfs: use a runtime flag to indicate an inode is a free space inode Josef Bacik
2022-09-15 13:01   ` Anand Jain
2022-09-15 14:53   ` Johannes Thumshirn
2022-09-14 23:04 ` [PATCH 15/15] btrfs: add struct declarations in dev-replace.h Josef Bacik
2022-09-15 13:06   ` Anand Jain
2022-09-15 14:54   ` Johannes Thumshirn
2022-09-20 11:44 ` [PATCH 00/15] btrfs: strip out btrfs_fs_info dependencies David Sterba

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=030e2b0b061a8ae57037f810ae3bfb2b4c9b0f4d.1663196541.git.josef@toxicpanda.com \
    --to=josef@toxicpanda.com \
    --cc=kernel-team@fb.com \
    --cc=linux-btrfs@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).