Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

btrfs-progs: rename "sector size" to "block size" #930

Open
wants to merge 10 commits into
base: devel
Choose a base branch
from

Conversation

adam900710
Copy link
Collaborator

Since day 1 of btrfs, we use the name "sector size" to indicate the
minimum data unit size (from btrfs_super_block::sectorsize).

But all other file systems use "block size" to indicate the minimum data
unit size, and inside kernel, a sector is used to describe the minimal
IO block size for a block device.
Furthermore kernel sector size is fixed to 512, and different block
devices have different sector sizes, from the older 512 sector sized
HDDs, to modern day flash devices that are even pushing for 16K sector
size.

This has brought quite some confusiong when we need to co-operate with
other fs/mm people.

I believe it's time to do the migration for btrfs-progs first, then do
it inside the kernel, before we're pushing for iomap support.

adam900710 and others added 10 commits December 13, 2024 15:16
The function btrfs_record_file_extent() has extra handling that's
specific to convert, like allowing the range to be split by block group
boundary and image file extent boundary.

All of these split can only lead to corruption for non-converted fs.
As the only caller out of btrfs-convert is rootdir, which expects the
file extent item insert to respect the reserved data extent, and never
to be split.

Thankfully this is not going to cause huge problem, as
btrfs_record_file_extent() has extra checks if the data extent overlaps
with any existing one, and if it doesn't the handling will be the same
as the kernel.

But to avoid abuse, change btrfs_record_file_extent() by:

- Rename it to btrfs_convert_file_extent()
  And add extra comments on that it is specific to btrfs-convert.

- Move it to convert/common.[ch]

- Introduce a helper insert_reserved_file_extent() for rootdir.c

Signed-off-by: Qu Wenruo <[email protected]>
…extent item

Just like insert_reserved_file_extent() from the kernel, we can make
btrfs_insert_file_extent() accept an on-stack file extent item
directly.

This makes btrfs_insert_file_extent() more flex, and it can now handle
the converted file extent where it has an non-zero offset.

And this makes it much easier to expand for future compressed file
extent generation.

Signed-off-by: Qu Wenruo <[email protected]>
There were two major problems with add_file_items(): it was
writing all files sector-by-sector, making compression impossible, and
it was assuming that pread would never do a short read.

Fix these problems, and create a new helper add_file_item_extent().

Signed-off-by: Mark Harmstone <[email protected]>
Add an option --compress to mkfs.btrfs, to allow creating files
using zlib when using --rootdir.

Signed-off-by: Mark Harmstone <[email protected]>
Allow --compress to work with zstd, when compiled in.

Signed-off-by: Mark Harmstone <[email protected]>
Allow --compress to work with lzo.

Signed-off-by: Mark Harmstone <[email protected]>
[ Add extra handling when LZO support is not compiled in ]
Signed-off-by: Qu Wenruo <[email protected]>
This will change all usage of btrfs_fs_info::sectorsize to
btrfs_fs_info::blocksize.

There are some extra changes involved:

- Rename csum_tree_block_size()'s @csum_sectorsize to @csum_size
  In fact @csum_sectorsize is only used in the declaration, and the
  implementation is already using @csum_size instead.

- Involved comments and simple function/variable names

- btrfs_free_space_ctrl::sectorsize to blocksize

- btrfs_mkfs_config::sectorsize to blocksize

The following one is not changed yet, as it is part of on-disk format,
thus will be changed in a dedicate patch.

- btrfs_super_block::sectorsize

The following one will not be changed:

- btrfs_chunk::sector_size
- btrfs_device_item::sector_size

As "sector size" is correct terminology for minimum block IO size for a
device.

Signed-off-by: Qu Wenruo <[email protected]>
"--sectorsize"

Btrfs uses the terminology "sectorsize" for the minimum data allocation
size, which is very different from other filesystems, and can be a
little confusing with the kernel block io sector size (which is the
minimum block io size, and is fixed to 512 bytes).

Let's start migrating mkfs.btrfs and its documentation to use the more
common terminology instead.

Signed-off-by: Qu Wenruo <[email protected]>
"blocksize"

To align with other filesystems, with extra mentioning of the older
"sectorsize" terminology to reduce confusion.

Signed-off-by: Qu Wenruo <[email protected]>
This on-disk format rename is to keep the terminology aligned to other
filesystems.

Signed-off-by: Qu Wenruo <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants