Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions .github/workflows/makefile.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Makefile CI

on:
push:
branches:
- 'rebase-*/btrfs-patches'
pull_request:
branches:
- 'rebase-*/btrfs-patches'
workflow_dispatch:

jobs:
build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Configure minimal kernel
run: make tinyconfig

- name: Configure btrfs
run: |
echo "CONFIG_BLOCK=y" >>.config
echo "CONFIG_BTRFS_FS=y" >>.config
echo "CONFIG_BTRFS_FS_POSIX_ACL=y" >>.config
echo "CONFIG_BTRFS_ALLOCATOR_HINTS=y" >>.config
echo "CONFIG_BTRFS_PER_DEVICE_IO_STATS=y" >>.config
echo "CONFIG_BTRFS_READ_POLICIES=y" >>.config
make oldconfig

- name: Compile kernel
run: make -j$(nproc) all
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -183,3 +183,6 @@ sphinx_*/

# Rust analyzer configuration
/rust-project.json

# Allow Github workflows
!/.github
72 changes: 72 additions & 0 deletions fs/btrfs/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,78 @@ config BTRFS_ASSERT

If unsure, say N.

config BTRFS_ALLOCATOR_HINTS
bool "Btrfs allocator hints"
depends on BTRFS_FS
default n
help
Enable support for allocator hints. This feature allows to select
dedicated or preferred devices for meta data vs data, or prevent
allocation from a device at all. This feature does not interact
well with free space calculation because the formula expects to
allocate space always from a device with most free space which is
not true when hints are applied. It may also create issues if a
device from the pool dies resulting in a situation where there are
still enough RAID mirror members but the allocation hints don't
allow to allocate from specific devices.

You are advised to watch your free space closely with btrfs tools
instead of relying on df only.

Mounting a btrfs with this feature on or off is always possible,
there are no incompatible changes to the file system. But running
without this feature may place new chunks on unwanted devices and
you may want to clean up later by balancing the affected chunks.

Supported hint types in /sys/fs/btrfs/BTRFS-UUID/devinfo/ID/type:

- type = 0 - allocate data chunks from this ID first (recommended
for big disks with good sequential performance, e.g.
HDDs), prefers data on this device
- type = 1 - allocate meta data chunks from this ID first
(recommended for fast and small disks with good
latency, e.g. SSD/NVMe), prefers meta data on this
device
- type = 2 - allocate only meta data chunks from this ID, no data
chunks will ever be allocated from this device
- type = 3 - allocate only data chunks from this ID, no meta data
chunks will ever be allocated from this device
- type = 4 - allocate any chunks from this device last, will never
allocate any space from this device unless there isn't
enough space on other devices
- type = 5 - never allocate any new chunks, useful when putting a
device out of use and to avoid redundant chunk writes
during balance/replace

If unsure, say N.

config BTRFS_PER_DEVICE_IO_STATS
bool "Btrfs per io devices stats"
depends on BTRFS_FS
default n
help
Enable collecting io read stats per devices to evaluate the effects
of different read policies better.

This adds a new file /sys/fs/btrfs/BTRFS-UUID/devinfo/ID/read_stats.

If unsure, say N.

config BTRFS_READ_POLICIES
bool "Btrfs read policies"
depends on BTRFS_FS
default n
help
This enables btrfs read policies to control how btrfs selects stripes
from a mirror during read operations. This was originally part of
the experimental feature set but it is safe to use and can provide
huge performance benefits in certain scenarios without causing any
performance regressions.

This adds a new file /sys/fs/btrfs/BTRFS-UUID/read_policy.

If unsure, say N.

config BTRFS_EXPERIMENTAL
bool "Btrfs experimental features"
depends on BTRFS_FS
Expand Down
3 changes: 2 additions & 1 deletion fs/btrfs/backref.c
Original file line number Diff line number Diff line change
Expand Up @@ -1126,6 +1126,7 @@ static int add_inline_refs(struct btrfs_backref_walk_ctx *ctx,
if (ret)
return ret;
ptr += btrfs_extent_inline_ref_size(type);
cond_resched();
}

return 0;
Expand Down Expand Up @@ -1229,7 +1230,7 @@ static int add_keyed_refs(struct btrfs_backref_walk_ctx *ctx,
}
if (ret)
return ret;

cond_resched();
}

return ret;
Expand Down
8 changes: 4 additions & 4 deletions fs/btrfs/super.c
Original file line number Diff line number Diff line change
Expand Up @@ -2498,15 +2498,15 @@ static int __init btrfs_print_mod_info(void)
#endif
;

#ifdef CONFIG_BTRFS_EXPERIMENTAL
#ifdef CONFIG_BTRFS_READ_POLICIES
if (btrfs_get_mod_read_policy() == NULL)
pr_info("Btrfs loaded%s\n", options);
else
pr_info("Btrfs loaded%s, read_policy=%s\n",
options, btrfs_get_mod_read_policy());
#else
pr_info("Btrfs loaded%s\n", options);
#endif
#endif /* CONFIG_BTRFS_READ_POLICIES */

return 0;
}
Expand Down Expand Up @@ -2565,11 +2565,11 @@ static const struct init_sequence mod_init_seq[] = {
}, {
.init_func = btrfs_extent_map_init,
.exit_func = btrfs_extent_map_exit,
#ifdef CONFIG_BTRFS_EXPERIMENTAL
#ifdef CONFIG_BTRFS_READ_POLICIES
}, {
.init_func = btrfs_read_policy_init,
.exit_func = NULL,
#endif
#endif /* CONFIG_BTRFS_READ_POLICIES */
}, {
.init_func = ordered_data_init,
.exit_func = ordered_data_exit,
Expand Down
Loading