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
8 changes: 4 additions & 4 deletions Documentation/Status.rst
Original file line number Diff line number Diff line change
Expand Up @@ -298,9 +298,9 @@ Subpage block size
------------------

Most commonly used page sizes are 4KiB, 16KiB and 64KiB. All combinations with
a 4KiB sector size filesystems are supported. Some features are not compatible
a 4KiB block size filesystems are supported. Some features are not compatible
with subpage or require another feature to work. Since btrfs-progs 6.7 the default
sector size is 4KiB as this allows cross-architecture compatibility.
block size is 4KiB as this allows cross-architecture compatibility.

.. list-table::
:header-rows: 1
Expand All @@ -317,9 +317,9 @@ sector size is 4KiB as this allows cross-architecture compatibility.
* - Compression
- :statusok:`partial support`
- Only page-aligned ranges can be compressed
* - Sectorsize
* - Blocksize
- :statusok:`supported`
- The list of supported sector sizes on a given version can be found
- The list of supported block sizes on a given version can be found
in file :file:`/sys/fs/btrfs/features/supported_sectorsizes`

.. _status-zoned:
Expand Down
11 changes: 6 additions & 5 deletions Documentation/Subpage.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,17 @@ Subpage support
===============

Subpage block size support, or just *subpage* for short, is a feature to allow
using a filesystem that has different size of data block size (*sectorsize*)
using a filesystem that has different size of data block size
(*blocksize*, previously called *sectorsize*)
and the host CPU page size. For easier implementation the support was limited
to the exactly same size of the block and page. On x86_64 this is typically
4KiB, but there are other architectures commonly used that make use of larger
pages, like 64KiB on 64bit ARM or PowerPC or 16KiB on Apple Silicon. This means
filesystems created with 64KiB sector size cannot be mounted on a system with
filesystems created with 64KiB block size cannot be mounted on a system with
4KiB page size.

Since btrfs-progs 6.7, filesystems are created with a 4KiB sector size by
default, though it remains possible to create filesystems with other sector sizes
Since btrfs-progs 6.7, filesystems are created with a 4KiB block size by
default, though it remains possible to create filesystems with other block sizes
(such as 64KiB with the "-s 64k" option for :command:`mkfs.btrfs`). This
ensures that new filesystems are compatible across other architecture variants
using larger page sizes.
Expand All @@ -21,7 +22,7 @@ Requirements, limitations

The initial subpage support has been added in kernel 5.15. Most features are
already working without problems. On a 64KiB page system, a filesystem with
4KiB sectorsize can be mounted and used as long as the initial mount succeeds.
4KiB blocksize can be mounted and used as long as the initial mount succeeds.
Subpage support is used by default for systems with a non-4KiB page size since
btrfs-progs 6.7.

Expand Down
4 changes: 2 additions & 2 deletions Documentation/btrfs-convert.rst
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ OPTIONS
-N|--nodesize <SIZE>
set filesystem nodesize, the tree block size in which btrfs stores its metadata.
The default value is 16KiB (16384) or the page size, whichever is bigger.
Must be a multiple of the sectorsize, but not larger than 65536. See
:doc:`mkfs.btrfs` for more details.
Must be a multiple of the block size (previously called "sector size),
but not larger than 65536. See :doc:`mkfs.btrfs` for more details.
-r|--rollback
rollback to the original ext2/3/4 filesystem if possible
-l|--label <LABEL>
Expand Down
4 changes: 2 additions & 2 deletions Documentation/btrfs-man5.rst
Original file line number Diff line number Diff line change
Expand Up @@ -182,8 +182,8 @@ supported_checksums
supported_sectorsizes
(since: 5.13)

list of values that are accepted as sector sizes (:command:`mkfs.btrfs --sectorsize`) by
the running kernel
list of values that are accepted as block sizes (previously known as
"sector size", :command:`mkfs.btrfs --sectorsize|--blocksize`) by the running kernel

supported_rescue_options
(since: 5.11)
Expand Down
4 changes: 2 additions & 2 deletions Documentation/ch-balance-filters.rst
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ multiple device.

The main reason why you want to have different profiles for data and metadata
is to provide additional protection of the filesystem's metadata when devices fail,
since a single sector of unrecoverable metadata will break the filesystem,
while a single sector of lost data can be trivially recovered by deleting the broken file.
since a single block of unrecoverable metadata will break the filesystem,
while a single block of lost data can be trivially recovered by deleting the broken file.

Before changing profiles, make sure there is enough unallocated space on
existing drives to create new metadata block groups (for filesystems
Expand Down
6 changes: 3 additions & 3 deletions Documentation/ch-mount-options.rst
Original file line number Diff line number Diff line change
Expand Up @@ -289,10 +289,10 @@ max_inline=<bytes>
Specify the maximum amount of space, that can be inlined in
a metadata b-tree leaf. The value is specified in bytes, optionally
with a K suffix (case insensitive). In practice, this value
is limited by the filesystem block size (named *sectorsize* at mkfs time),
and memory page size of the system. In case of sectorsize limit, there's
is limited by the filesystem block size (named *blocksize* at mkfs time),
and memory page size of the system. In case of blocksize limit, there's
some space unavailable due to b-tree leaf headers. For example, a 4KiB
sectorsize, maximum size of inline data is about 3900 bytes.
blocksize, maximum size of inline data is about 3900 bytes.

Inlining can be completely turned off by specifying 0. This will increase data
block slack if file sizes are much smaller than block size but will reduce
Expand Down
2 changes: 1 addition & 1 deletion Documentation/ch-sysfs.rst
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ read_policy
sectorsize
(RO, since: 3.14)

Shows the sectorsize of the mounted filesystem.
Shows the block size (previously called "sector size") of the mounted filesystem.


temp_fsid
Expand Down
29 changes: 22 additions & 7 deletions Documentation/mkfs.btrfs.rst
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ OPTIONS
mode may lead to degraded performance on larger filesystems, but is otherwise
usable, even on multiple devices.

The *nodesize* and *sectorsize* must be equal, and the block group types must
The *nodesize* and *blocksize* must be equal, and the block group types must
match.

.. note::
Expand All @@ -108,7 +108,7 @@ OPTIONS
-n|--nodesize <size>
Specify the nodesize, the tree block size in which btrfs stores metadata. The
default value is 16KiB (16384) or the page size, whichever is bigger. Must be a
multiple of the sectorsize and a power of 2, but not larger than 64KiB (65536).
multiple of the blocksize and a power of 2, but not larger than 64KiB (65536).
Leafsize always equals nodesize and the options are aliases.

Smaller node size increases fragmentation but leads to taller b-trees which in
Expand All @@ -119,11 +119,17 @@ OPTIONS
.. note::
Versions up to 3.11 set the nodesize to 4KiB.

-s|--sectorsize <size>
Specify the sectorsize, the minimum data block allocation unit.
-s|--sectorsize|--blocksize <size>
Specify the block size, the minimum data block allocation unit.

.. note::
Versions prior to 6.7 set the sectorsize matching the host CPU
.. note::
Btrfs-progs versions prior to 6.14 uses the name "sectorsize" to
describe the minimum data block allocation unit, which is not
following other filesystems' terminology.
From version 6.14, documentation and source code will convert
to use the name "blocksize" instead.

Versions prior to 6.7 set the blocksize matching the host CPU
page size, starting in 6.7 this is 4KiB for cross-architecture
compatibility. Please read more about the :doc:`subpage block size support<Subpage>`
and :ref:`its status<status-subpage-block-size>`.
Expand Down Expand Up @@ -212,6 +218,15 @@ OPTIONS

$ mkfs.btrfs -O list-all

--compress <algo>[:<level>]
Try to compress files when using *--rootdir*. Supported values for *algo* are
*no* (the default), *zlib*, *lzo*, and *zstd*. The optional value *level* is a
compression level, from 1 to 9 for ZLIB and from 1 to 15 for ZSTD.

As with the kernel, :command:`mkfs.btrfs` won't write compressed extents when
they would be larger than the uncompressed versions, and will mark a file as
`nocompress` if its beginning is found to be incompressible.

-f|--force
Forcibly overwrite the block devices when an existing filesystem is detected.
By default, :command:`mkfs.btrfs` will utilize *libblkid* to check for any known
Expand Down Expand Up @@ -609,7 +624,7 @@ The combination of small filesystem size and large nodesize is not recommended
in general and can lead to various ENOSPC-related issues during mount time or runtime.

Since mixed block group creation is optional, we allow small
filesystem instances with differing values for *sectorsize* and *nodesize*
filesystem instances with differing values for *blocksize* and *nodesize*
to be created and could end up in the following situation:

.. code-block:: none
Expand Down
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -740,11 +740,11 @@ btrfsck.static: btrfs.static

mkfs.btrfs: $(mkfs_objects) $(objects) libbtrfsutil.a
@echo " [LD] $@"
$(Q)$(CC) -o $@ $^ $(LDFLAGS) $(LIBS)
$(Q)$(CC) -o $@ $^ $(LDFLAGS) $(LIBS) $(LIBS_COMP)

mkfs.btrfs.static: $(static_mkfs_objects) $(static_objects) $(static_libbtrfs_objects)
@echo " [LD] $@"
$(Q)$(CC) -o $@ $^ $(STATIC_LDFLAGS) $(STATIC_LIBS)
$(Q)$(CC) -o $@ $^ $(STATIC_LDFLAGS) $(STATIC_LIBS) $(STATIC_LIBS_COMP)

btrfstune: $(tune_objects) $(objects) libbtrfsutil.a
@echo " [LD] $@"
Expand Down
24 changes: 12 additions & 12 deletions btrfs-corrupt-block.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,14 @@

static int debug_corrupt_sector(struct btrfs_root *root, u64 logical, int mirror)
{
const u32 sectorsize = root->fs_info->sectorsize;
const u32 blocksize = root->fs_info->blocksize;
struct btrfs_fs_info *fs_info = root->fs_info;
int ret;
int num_copies;
int mirror_num = 1;
void *buf;

buf = malloc(root->fs_info->sectorsize);
buf = malloc(root->fs_info->blocksize);
if (!buf) {
error_msg(ERROR_MSG_MEMORY, "allocating memory for bytenr %llu",
logical);
Expand All @@ -61,28 +61,28 @@ static int debug_corrupt_sector(struct btrfs_root *root, u64 logical, int mirror

while (1) {
if (!mirror || mirror_num == mirror) {
u64 read_len = sectorsize;
u64 read_len = blocksize;

ret = read_data_from_disk(fs_info, buf, logical,
&read_len, mirror_num);
if (read_len < sectorsize)
if (read_len < blocksize)
ret = -EIO;
if (ret < 0) {
errno = -ret;
error("cannot read bytenr %llu: %m", logical);
goto out;
}
printf("corrupting %llu copy %d\n", logical, mirror_num);
memset(buf, 0, sectorsize);
ret = write_data_to_disk(fs_info, buf, logical, sectorsize);
memset(buf, 0, blocksize);
ret = write_data_to_disk(fs_info, buf, logical, blocksize);
if (ret < 0) {
errno = -ret;
error("cannot write bytenr %llu: %m", logical);
goto out;
}
}

num_copies = btrfs_num_copies(root->fs_info, logical, sectorsize);
num_copies = btrfs_num_copies(root->fs_info, logical, blocksize);
if (num_copies == 1)
break;

Expand Down Expand Up @@ -122,7 +122,7 @@ static const char * const corrupt_block_usage[] = {
OPTLINE("-d|--delete", "delete item corresponding to passed key triplet"),
OPTLINE("-r|--root", "operate on this root"),
OPTLINE("-C|--csum BYTENR", "delete a csum for the specified bytenr. When used "
"with -b it'll delete that many bytes, otherwise it's just sectorsize"),
"with -b it'll delete that many bytes, otherwise it's just blocksize"),
OPTLINE("--block-group OFFSET", "corrupt the given block group"),
OPTLINE("--value VALUE", "value to use for corrupting item data"),
OPTLINE("--offset OFFSET", "offset to use for corrupting item data"),
Expand Down Expand Up @@ -1604,9 +1604,9 @@ int main(int argc, char **argv)
usage(&corrupt_block_cmd, 1);

if (bytes == 0)
bytes = root->fs_info->sectorsize;
bytes = root->fs_info->blocksize;

bytes = round_up(bytes, root->fs_info->sectorsize);
bytes = round_up(bytes, root->fs_info->blocksize);

while (bytes > 0) {
if (corrupt_block_keys) {
Expand All @@ -1631,8 +1631,8 @@ int main(int argc, char **argv)
}
free_extent_buffer(eb);
}
logical += root->fs_info->sectorsize;
bytes -= root->fs_info->sectorsize;
logical += root->fs_info->blocksize;
bytes -= root->fs_info->blocksize;
}
return ret;
out_close:
Expand Down
Loading