btrfs: switch cached fs_info::csum_size from u16 to u32
The fs_info value is 32bit, switch also the local u16 variables. This leads to a better assembly code generated due to movzwl. This simple change will shave some bytes on x86_64 and release config: text data bss dec hex filename 1090000 17980 14912 1122892 11224c pre/btrfs.ko 1089794 17980 14912 1122686 11217e post/btrfs.ko DELTA: -206 Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com> Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
parent
55fc29bed8
commit
223486c27b
@ -331,7 +331,7 @@ static inline void btrfs_print_data_csum_error(struct btrfs_inode *inode,
|
||||
u64 logical_start, u8 *csum, u8 *csum_expected, int mirror_num)
|
||||
{
|
||||
struct btrfs_root *root = inode->root;
|
||||
const u16 csum_size = root->fs_info->csum_size;
|
||||
const u32 csum_size = root->fs_info->csum_size;
|
||||
|
||||
/* Output minus objectid, which is more meaningful */
|
||||
if (root->root_key.objectid >= BTRFS_LAST_FREE_OBJECTID)
|
||||
|
@ -131,8 +131,7 @@ 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 u16 csum_size = fs_info->csum_size;
|
||||
|
||||
const u32 csum_size = fs_info->csum_size;
|
||||
return sizeof(struct compressed_bio) +
|
||||
(DIV_ROUND_UP(disk_size, fs_info->sectorsize)) * csum_size;
|
||||
}
|
||||
@ -142,7 +141,7 @@ static int check_compressed_csum(struct btrfs_inode *inode, struct bio *bio,
|
||||
{
|
||||
struct btrfs_fs_info *fs_info = inode->root->fs_info;
|
||||
SHASH_DESC_ON_STACK(shash, fs_info->csum_shash);
|
||||
const u16 csum_size = fs_info->csum_size;
|
||||
const u32 csum_size = fs_info->csum_size;
|
||||
struct page *page;
|
||||
unsigned long i;
|
||||
char *kaddr;
|
||||
@ -628,7 +627,7 @@ 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 u16 csum_size = fs_info->csum_size;
|
||||
const u32 csum_size = fs_info->csum_size;
|
||||
u8 *sums;
|
||||
|
||||
em_tree = &BTRFS_I(inode)->extent_tree;
|
||||
|
@ -454,7 +454,7 @@ 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 u16 csum_size = fs_info->csum_size;
|
||||
const u32 csum_size = fs_info->csum_size;
|
||||
struct extent_buffer *eb;
|
||||
int ret;
|
||||
|
||||
|
@ -2689,7 +2689,7 @@ blk_status_t btrfs_submit_read_repair(struct inode *inode,
|
||||
repair_bio->bi_private = failed_bio->bi_private;
|
||||
|
||||
if (failed_io_bio->csum) {
|
||||
const u16 csum_size = fs_info->csum_size;
|
||||
const u32 csum_size = fs_info->csum_size;
|
||||
|
||||
repair_io_bio->csum = repair_io_bio->csum_inline;
|
||||
memcpy(repair_io_bio->csum,
|
||||
|
@ -181,7 +181,7 @@ btrfs_lookup_csum(struct btrfs_trans_handle *trans,
|
||||
struct btrfs_csum_item *item;
|
||||
struct extent_buffer *leaf;
|
||||
u64 csum_offset = 0;
|
||||
const u16 csum_size = fs_info->csum_size;
|
||||
const u32 csum_size = fs_info->csum_size;
|
||||
int csums_in_item;
|
||||
|
||||
file_key.objectid = BTRFS_EXTENT_CSUM_OBJECTID;
|
||||
@ -270,7 +270,7 @@ blk_status_t btrfs_lookup_bio_sums(struct inode *inode, struct bio *bio,
|
||||
u32 diff;
|
||||
int nblocks;
|
||||
int count = 0;
|
||||
const u16 csum_size = fs_info->csum_size;
|
||||
const u32 csum_size = fs_info->csum_size;
|
||||
|
||||
if (!fs_info->csum_root || (BTRFS_I(inode)->flags & BTRFS_INODE_NODATASUM))
|
||||
return BLK_STS_OK;
|
||||
@ -409,7 +409,7 @@ int btrfs_lookup_csums_range(struct btrfs_root *root, u64 start, u64 end,
|
||||
int ret;
|
||||
size_t size;
|
||||
u64 csum_end;
|
||||
const u16 csum_size = fs_info->csum_size;
|
||||
const u32 csum_size = fs_info->csum_size;
|
||||
|
||||
ASSERT(IS_ALIGNED(start, fs_info->sectorsize) &&
|
||||
IS_ALIGNED(end + 1, fs_info->sectorsize));
|
||||
@ -540,7 +540,7 @@ blk_status_t btrfs_csum_one_bio(struct btrfs_inode *inode, struct bio *bio,
|
||||
int i;
|
||||
u64 offset;
|
||||
unsigned nofs_flag;
|
||||
const u16 csum_size = fs_info->csum_size;
|
||||
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),
|
||||
@ -638,7 +638,7 @@ static noinline void truncate_one_csum(struct btrfs_fs_info *fs_info,
|
||||
u64 bytenr, u64 len)
|
||||
{
|
||||
struct extent_buffer *leaf;
|
||||
const u16 csum_size = fs_info->csum_size;
|
||||
const u32 csum_size = fs_info->csum_size;
|
||||
u64 csum_end;
|
||||
u64 end_byte = bytenr + len;
|
||||
u32 blocksize_bits = fs_info->sectorsize_bits;
|
||||
@ -692,7 +692,7 @@ int btrfs_del_csums(struct btrfs_trans_handle *trans,
|
||||
u64 csum_end;
|
||||
struct extent_buffer *leaf;
|
||||
int ret;
|
||||
const u16 csum_size = fs_info->csum_size;
|
||||
const u32 csum_size = fs_info->csum_size;
|
||||
u32 blocksize_bits = fs_info->sectorsize_bits;
|
||||
|
||||
ASSERT(root == fs_info->csum_root ||
|
||||
@ -847,7 +847,7 @@ int btrfs_csum_file_blocks(struct btrfs_trans_handle *trans,
|
||||
int index = 0;
|
||||
int found_next;
|
||||
int ret;
|
||||
const u16 csum_size = fs_info->csum_size;
|
||||
const u32 csum_size = fs_info->csum_size;
|
||||
|
||||
path = btrfs_alloc_path();
|
||||
if (!path)
|
||||
|
@ -2906,7 +2906,7 @@ static int check_data_csum(struct inode *inode, struct btrfs_io_bio *io_bio,
|
||||
SHASH_DESC_ON_STACK(shash, fs_info->csum_shash);
|
||||
char *kaddr;
|
||||
u32 len = fs_info->sectorsize;
|
||||
const u16 csum_size = fs_info->csum_size;
|
||||
const u32 csum_size = fs_info->csum_size;
|
||||
u8 *csum_expected;
|
||||
u8 csum[BTRFS_CSUM_SIZE];
|
||||
|
||||
@ -7850,11 +7850,10 @@ static struct btrfs_dio_private *btrfs_create_dio_private(struct bio *dio_bio,
|
||||
dip_size = sizeof(*dip);
|
||||
if (!write && csum) {
|
||||
struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb);
|
||||
const u16 csum_size = fs_info->csum_size;
|
||||
size_t nblocks;
|
||||
|
||||
nblocks = dio_bio->bi_iter.bi_size >> fs_info->sectorsize_bits;
|
||||
dip_size += csum_size * nblocks;
|
||||
dip_size += fs_info->csum_size * nblocks;
|
||||
}
|
||||
|
||||
dip = kzalloc(dip_size, GFP_NOFS);
|
||||
|
@ -868,7 +868,7 @@ int btrfs_find_ordered_sum(struct btrfs_inode *inode, u64 offset,
|
||||
struct btrfs_ordered_inode_tree *tree = &inode->ordered_tree;
|
||||
unsigned long num_sectors;
|
||||
unsigned long i;
|
||||
const u16 csum_size = fs_info->csum_size;
|
||||
const u32 csum_size = fs_info->csum_size;
|
||||
int index = 0;
|
||||
|
||||
ordered = btrfs_lookup_ordered_extent(inode, offset);
|
||||
|
@ -137,7 +137,7 @@ 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 u16 csum_size = fs_info->csum_size;
|
||||
const u32 csum_size = fs_info->csum_size;
|
||||
|
||||
return sizeof(struct btrfs_ordered_sum) + num_sectors * csum_size;
|
||||
}
|
||||
|
@ -336,7 +336,7 @@ static int check_csum_item(struct extent_buffer *leaf, struct btrfs_key *key,
|
||||
{
|
||||
struct btrfs_fs_info *fs_info = leaf->fs_info;
|
||||
u32 sectorsize = fs_info->sectorsize;
|
||||
const u16 csumsize = fs_info->csum_size;
|
||||
const u32 csumsize = fs_info->csum_size;
|
||||
|
||||
if (key->objectid != BTRFS_EXTENT_CSUM_OBJECTID) {
|
||||
generic_err(leaf, slot,
|
||||
|
Loading…
Reference in New Issue
Block a user