Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

btrfs: replace sb::s_blocksize by fs_info::sectorsize

The block size stored in the super block is used by subsystems outside
of btrfs and it's a copy of fs_info::sectorsize. Unify that to always
use our sectorsize, with the exception of mount where we first need to
use fixed values (4K) until we read the super block and can set the
sectorsize.

Replace all uses, in most cases it's fewer pointer indirections.

Reviewed-by: Josef Bacik <josef@toxicpanda.com>
Reviewed-by: Anand Jain <anand.jain@oracle.com>
Signed-off-by: David Sterba <dsterba@suse.com>

+11 -9
+2
fs/btrfs/disk-io.c
··· 2840 2840 int ret; 2841 2841 2842 2842 fs_info->sb = sb; 2843 + /* Temporary fixed values for block size until we read the superblock. */ 2843 2844 sb->s_blocksize = BTRFS_BDEV_BLOCKSIZE; 2844 2845 sb->s_blocksize_bits = blksize_bits(BTRFS_BDEV_BLOCKSIZE); 2845 2846 ··· 3358 3357 sb->s_bdi->ra_pages *= btrfs_super_num_devices(disk_super); 3359 3358 sb->s_bdi->ra_pages = max(sb->s_bdi->ra_pages, SZ_4M / PAGE_SIZE); 3360 3359 3360 + /* Update the values for the current filesystem. */ 3361 3361 sb->s_blocksize = sectorsize; 3362 3362 sb->s_blocksize_bits = blksize_bits(sectorsize); 3363 3363 memcpy(&sb->s_uuid, fs_info->fs_devices->fsid, BTRFS_FSID_SIZE);
+2 -2
fs/btrfs/extent_io.c
··· 1015 1015 int ret = 0; 1016 1016 size_t pg_offset = 0; 1017 1017 size_t iosize; 1018 - size_t blocksize = inode->i_sb->s_blocksize; 1018 + size_t blocksize = fs_info->sectorsize; 1019 1019 struct extent_io_tree *tree = &BTRFS_I(inode)->io_tree; 1020 1020 1021 1021 ret = set_page_extent_mapped(page); ··· 2305 2305 struct extent_state *cached_state = NULL; 2306 2306 u64 start = folio_pos(folio); 2307 2307 u64 end = start + folio_size(folio) - 1; 2308 - size_t blocksize = folio->mapping->host->i_sb->s_blocksize; 2308 + size_t blocksize = btrfs_sb(folio->mapping->host->i_sb)->sectorsize; 2309 2309 2310 2310 /* This function is only called for the btree inode */ 2311 2311 ASSERT(tree->owner == IO_TREE_BTREE_INODE_IO);
+1 -1
fs/btrfs/inode.c
··· 8721 8721 u64 delalloc_bytes; 8722 8722 u64 inode_bytes; 8723 8723 struct inode *inode = d_inode(path->dentry); 8724 - u32 blocksize = inode->i_sb->s_blocksize; 8724 + u32 blocksize = btrfs_sb(inode->i_sb)->sectorsize; 8725 8725 u32 bi_flags = BTRFS_I(inode)->flags; 8726 8726 u32 bi_ro_flags = BTRFS_I(inode)->ro_flags; 8727 8727
+1 -1
fs/btrfs/ioctl.c
··· 528 528 * block group is in the logical address space, which can be any 529 529 * sectorsize aligned bytenr in the range [0, U64_MAX]. 530 530 */ 531 - if (range.len < fs_info->sb->s_blocksize) 531 + if (range.len < fs_info->sectorsize) 532 532 return -EINVAL; 533 533 534 534 range.minlen = max(range.minlen, minlen);
+3 -3
fs/btrfs/reflink.c
··· 663 663 struct inode *dst, u64 dst_loff) 664 664 { 665 665 struct btrfs_fs_info *fs_info = BTRFS_I(src)->root->fs_info; 666 - const u64 bs = fs_info->sb->s_blocksize; 666 + const u64 bs = fs_info->sectorsize; 667 667 int ret; 668 668 669 669 /* ··· 730 730 int ret; 731 731 int wb_ret; 732 732 u64 len = olen; 733 - u64 bs = fs_info->sb->s_blocksize; 733 + u64 bs = fs_info->sectorsize; 734 734 735 735 /* 736 736 * VFS's generic_remap_file_range_prep() protects us from cloning the ··· 796 796 { 797 797 struct inode *inode_in = file_inode(file_in); 798 798 struct inode *inode_out = file_inode(file_out); 799 - u64 bs = BTRFS_I(inode_out)->root->fs_info->sb->s_blocksize; 799 + u64 bs = BTRFS_I(inode_out)->root->fs_info->sectorsize; 800 800 u64 wb_len; 801 801 int ret; 802 802
+1 -1
fs/btrfs/send.c
··· 6140 6140 int ret = 0; 6141 6141 u64 offset = key->offset; 6142 6142 u64 end; 6143 - u64 bs = sctx->send_root->fs_info->sb->s_blocksize; 6143 + u64 bs = sctx->send_root->fs_info->sectorsize; 6144 6144 6145 6145 end = min_t(u64, btrfs_file_extent_end(path), sctx->cur_inode_size); 6146 6146 if (offset >= end)
+1 -1
fs/btrfs/super.c
··· 1767 1767 buf->f_bavail = 0; 1768 1768 1769 1769 buf->f_type = BTRFS_SUPER_MAGIC; 1770 - buf->f_bsize = dentry->d_sb->s_blocksize; 1770 + buf->f_bsize = fs_info->sectorsize; 1771 1771 buf->f_namelen = BTRFS_NAME_LEN; 1772 1772 1773 1773 /* We treat it as constant endianness (it doesn't matter _which_)