Linux Btrfs filesystem development
 help / color / mirror / Atom feed
From: David Sterba <dsterba@suse.com>
To: linux-btrfs@vger.kernel.org
Cc: David Sterba <dsterba@suse.com>
Subject: [PATCH 08/10] btrfs: remove unnecessary local variables for checksum size
Date: Thu, 29 Oct 2020 15:27:54 +0100	[thread overview]
Message-ID: <da71002084c80344ea01f56b0554ed9c88dfbe10.1603981453.git.dsterba@suse.com> (raw)
In-Reply-To: <cover.1603981452.git.dsterba@suse.com>

Remove local variable that is then used just once and replace it with
fs_info::csum_tree.

Signed-off-by: David Sterba <dsterba@suse.com>
---
 fs/btrfs/compression.c  | 6 ++----
 fs/btrfs/disk-io.c      | 3 +--
 fs/btrfs/file-item.c    | 3 +--
 fs/btrfs/ordered-data.h | 3 +--
 4 files changed, 5 insertions(+), 10 deletions(-)

diff --git a/fs/btrfs/compression.c b/fs/btrfs/compression.c
index b2bb4681975e..4e022ed72d2f 100644
--- a/fs/btrfs/compression.c
+++ b/fs/btrfs/compression.c
@@ -131,9 +131,8 @@ static int btrfs_decompress_bio(struct compressed_bio *cb);
 static inline int compressed_bio_size(struct btrfs_fs_info *fs_info,
 				      unsigned long disk_size)
 {
-	const u32 csum_size = fs_info->csum_size;
 	return sizeof(struct compressed_bio) +
-		(DIV_ROUND_UP(disk_size, fs_info->sectorsize)) * csum_size;
+		(DIV_ROUND_UP(disk_size, fs_info->sectorsize)) * fs_info->csum_size;
 }
 
 static int check_compressed_csum(struct btrfs_inode *inode, struct bio *bio,
@@ -627,7 +626,6 @@ blk_status_t btrfs_submit_compressed_read(struct inode *inode, struct bio *bio,
 	struct extent_map *em;
 	blk_status_t ret = BLK_STS_RESOURCE;
 	int faili = 0;
-	const u32 csum_size = fs_info->csum_size;
 	u8 *sums;
 
 	em_tree = &BTRFS_I(inode)->extent_tree;
@@ -727,7 +725,7 @@ blk_status_t btrfs_submit_compressed_read(struct inode *inode, struct bio *bio,
 
 			nr_sectors = DIV_ROUND_UP(comp_bio->bi_iter.bi_size,
 						  fs_info->sectorsize);
-			sums += csum_size * nr_sectors;
+			sums += fs_info->csum_size * nr_sectors;
 
 			ret = btrfs_map_bio(fs_info, comp_bio, mirror_num);
 			if (ret) {
diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c
index aa89d5c15f6e..128eb2d56862 100644
--- a/fs/btrfs/disk-io.c
+++ b/fs/btrfs/disk-io.c
@@ -452,7 +452,6 @@ static int csum_dirty_buffer(struct btrfs_fs_info *fs_info, struct page *page)
 	u64 start = page_offset(page);
 	u64 found_start;
 	u8 result[BTRFS_CSUM_SIZE];
-	const u32 csum_size = fs_info->csum_size;
 	struct extent_buffer *eb;
 	int ret;
 
@@ -489,7 +488,7 @@ static int csum_dirty_buffer(struct btrfs_fs_info *fs_info, struct page *page)
 		WARN_ON(IS_ENABLED(CONFIG_BTRFS_DEBUG));
 		return ret;
 	}
-	write_extent_buffer(eb, result, 0, csum_size);
+	write_extent_buffer(eb, result, 0, fs_info->csum_size);
 
 	return 0;
 }
diff --git a/fs/btrfs/file-item.c b/fs/btrfs/file-item.c
index d7fdfd6ea6f4..3356bd3ae0e0 100644
--- a/fs/btrfs/file-item.c
+++ b/fs/btrfs/file-item.c
@@ -541,7 +541,6 @@ blk_status_t btrfs_csum_one_bio(struct btrfs_inode *inode, struct bio *bio,
 	int i;
 	u64 offset;
 	unsigned nofs_flag;
-	const u32 csum_size = fs_info->csum_size;
 
 	nofs_flag = memalloc_nofs_save();
 	sums = kvzalloc(btrfs_ordered_sum_size(fs_info, bio->bi_iter.bi_size),
@@ -609,7 +608,7 @@ blk_status_t btrfs_csum_one_bio(struct btrfs_inode *inode, struct bio *bio,
 					    fs_info->sectorsize,
 					    sums->sums + index);
 			kunmap_atomic(data);
-			index += csum_size;
+			index += fs_info->csum_size;
 			offset += fs_info->sectorsize;
 			this_sum_bytes += fs_info->sectorsize;
 			total_bytes += fs_info->sectorsize;
diff --git a/fs/btrfs/ordered-data.h b/fs/btrfs/ordered-data.h
index e48810104e4a..367269effd6a 100644
--- a/fs/btrfs/ordered-data.h
+++ b/fs/btrfs/ordered-data.h
@@ -137,9 +137,8 @@ static inline int btrfs_ordered_sum_size(struct btrfs_fs_info *fs_info,
 					 unsigned long bytes)
 {
 	int num_sectors = (int)DIV_ROUND_UP(bytes, fs_info->sectorsize);
-	const u32 csum_size = fs_info->csum_size;
 
-	return sizeof(struct btrfs_ordered_sum) + num_sectors * csum_size;
+	return sizeof(struct btrfs_ordered_sum) + num_sectors * fs_info->csum_size;
 }
 
 static inline void
-- 
2.25.0


  parent reply	other threads:[~2020-10-29 14:29 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-29 14:27 [PATCH 00/10] Sectorsize, csum_size lifted to fs_info David Sterba
2020-10-29 14:27 ` [PATCH 01/10] btrfs: use precalculated sectorsize_bits from fs_info David Sterba
2020-11-02 14:05   ` Qu Wenruo
2020-11-02 14:18     ` Qu Wenruo
2020-11-02 14:31       ` Johannes Thumshirn
2020-11-02 15:08         ` David Sterba
2020-11-02 15:12           ` Johannes Thumshirn
2020-11-02 15:15     ` David Sterba
2020-11-03  9:31   ` David Sterba
2020-10-29 14:27 ` [PATCH 02/10] btrfs: replace div_u64 by shift in free_space_bitmap_size David Sterba
2020-11-02 14:07   ` Qu Wenruo
2020-10-29 14:27 ` [PATCH 03/10] btrfs: replace s_blocksize_bits with fs_info::sectorsize_bits David Sterba
2020-11-02 14:23   ` Qu Wenruo
2020-11-02 15:18     ` David Sterba
2020-10-29 14:27 ` [PATCH 04/10] btrfs: store precalculated csum_size in fs_info David Sterba
2020-10-29 14:27 ` [PATCH 05/10] btrfs: precalculate checksums per leaf once David Sterba
2020-11-02 14:27   ` Qu Wenruo
2020-11-02 15:24     ` David Sterba
2020-11-02 16:00       ` David Sterba
2020-10-29 14:27 ` [PATCH 06/10] btrfs: use cached value of fs_info::csum_size everywhere David Sterba
2020-11-02 14:28   ` Qu Wenruo
2020-10-29 14:27 ` [PATCH 07/10] btrfs: switch cached fs_info::csum_size from u16 to u32 David Sterba
2020-10-29 14:27 ` David Sterba [this message]
2020-10-29 14:43   ` [PATCH 08/10] btrfs: remove unnecessary local variables for checksum size Johannes Thumshirn
2020-10-29 14:27 ` [PATCH 09/10] btrfs: check integrity: remove local copy of csum_size David Sterba
2020-10-29 14:44   ` Johannes Thumshirn
2020-10-29 14:27 ` [PATCH 10/10] btrfs: scrub: remove local copy of csum_size from context David Sterba
2020-10-29 14:45   ` Johannes Thumshirn
2020-10-29 14:54     ` David Sterba
2020-10-29 15:01       ` Johannes Thumshirn
2020-10-29 14:50 ` [PATCH 00/10] Sectorsize, csum_size lifted to fs_info Johannes Thumshirn
2020-10-29 16:25   ` 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=da71002084c80344ea01f56b0554ed9c88dfbe10.1603981453.git.dsterba@suse.com \
    --to=dsterba@suse.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