Skip to content

Commit 503ec91

Browse files
committed
btrfs: move read policies out of experimental
Read policies seem safe and stable enough to move it out of the experimental feature set. This allows us to add more policies without forcing users to enable the full experimental feature set. Signed-off-by: Kai Krakow <kai@kaishome.de>
1 parent 2b313b2 commit 503ec91

File tree

6 files changed

+31
-14
lines changed

6 files changed

+31
-14
lines changed

fs/btrfs/Kconfig

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,21 @@ config BTRFS_PER_DEVICE_IO_STATS
141141

142142
If unsure, say N.
143143

144+
config BTRFS_READ_POLICIES
145+
bool "Btrfs read policies"
146+
depends on BTRFS_FS
147+
default n
148+
help
149+
This enables btrfs read policies to control how btrfs selects stripes
150+
from a mirror during read operations. This was originally part of
151+
the experimental feature set but it is safe to use and can provide
152+
huge performance benefits in certain scenarios without causing any
153+
performance regressions.
154+
155+
This adds a new file /sys/fs/btrfs/BTRFS-UUID/read_policy.
156+
157+
If unsure, say N.
158+
144159
config BTRFS_EXPERIMENTAL
145160
bool "Btrfs experimental features"
146161
depends on BTRFS_FS

fs/btrfs/super.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2498,7 +2498,7 @@ static int __init btrfs_print_mod_info(void)
24982498
#endif
24992499
;
25002500

2501-
#ifdef CONFIG_BTRFS_EXPERIMENTAL
2501+
#ifdef CONFIG_BTRFS_READ_POLICIES
25022502
if (btrfs_get_mod_read_policy() == NULL)
25032503
pr_info("Btrfs loaded%s\n", options);
25042504
else
@@ -2565,7 +2565,7 @@ static const struct init_sequence mod_init_seq[] = {
25652565
}, {
25662566
.init_func = btrfs_extent_map_init,
25672567
.exit_func = btrfs_extent_map_exit,
2568-
#ifdef CONFIG_BTRFS_EXPERIMENTAL
2568+
#ifdef CONFIG_BTRFS_READ_POLICIES
25692569
}, {
25702570
.init_func = btrfs_read_policy_init,
25712571
.exit_func = NULL,

fs/btrfs/sysfs.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1323,13 +1323,13 @@ BTRFS_ATTR(, temp_fsid, btrfs_temp_fsid_show);
13231323

13241324
static const char *btrfs_read_policy_name[] = {
13251325
"pid",
1326-
#ifdef CONFIG_BTRFS_EXPERIMENTAL
1326+
#ifdef CONFIG_BTRFS_READ_POLICIES
13271327
"round-robin",
13281328
"devid",
13291329
#endif
13301330
};
13311331

1332-
#ifdef CONFIG_BTRFS_EXPERIMENTAL
1332+
#ifdef CONFIG_BTRFS_READ_POLICIES
13331333

13341334
/* Global module configuration parameters. */
13351335
static char *read_policy;
@@ -1354,7 +1354,7 @@ int btrfs_read_policy_to_enum(const char *str, s64 *value_ret)
13541354

13551355
strscpy(param, str);
13561356

1357-
#ifdef CONFIG_BTRFS_EXPERIMENTAL
1357+
#ifdef CONFIG_BTRFS_READ_POLICIES
13581358
/* Separate value from input in policy:value format. */
13591359
value_str = strchr(param, ':');
13601360
if (value_str) {
@@ -1376,7 +1376,7 @@ int btrfs_read_policy_to_enum(const char *str, s64 *value_ret)
13761376
return sysfs_match_string(btrfs_read_policy_name, param);
13771377
}
13781378

1379-
#ifdef CONFIG_BTRFS_EXPERIMENTAL
1379+
#ifdef CONFIG_BTRFS_READ_POLICIES
13801380
int __init btrfs_read_policy_init(void)
13811381
{
13821382
s64 value;
@@ -1407,7 +1407,7 @@ static ssize_t btrfs_read_policy_show(struct kobject *kobj,
14071407

14081408
ret += sysfs_emit_at(buf, ret, "%s", btrfs_read_policy_name[i]);
14091409

1410-
#ifdef CONFIG_BTRFS_EXPERIMENTAL
1410+
#ifdef CONFIG_BTRFS_READ_POLICIES
14111411
if (i == BTRFS_READ_POLICY_RR)
14121412
ret += sysfs_emit_at(buf, ret, ":%u",
14131413
READ_ONCE(fs_devices->rr_min_contig_read));
@@ -1437,7 +1437,7 @@ static ssize_t btrfs_read_policy_store(struct kobject *kobj,
14371437
if (index < 0)
14381438
return -EINVAL;
14391439

1440-
#ifdef CONFIG_BTRFS_EXPERIMENTAL
1440+
#ifdef CONFIG_BTRFS_READ_POLICIES
14411441
/* If moving from RR then disable collecting fs stats. */
14421442
if (fs_devices->read_policy == BTRFS_READ_POLICY_RR && index != BTRFS_READ_POLICY_RR)
14431443
fs_devices->collect_fs_stats = false;

fs/btrfs/sysfs.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ void btrfs_sysfs_del_one_qgroup(struct btrfs_fs_info *fs_info,
5050
struct btrfs_qgroup *qgroup);
5151
int btrfs_read_policy_to_enum(const char *str, s64 *value);
5252

53-
#ifdef CONFIG_BTRFS_EXPERIMENTAL
53+
#ifdef CONFIG_BTRFS_READ_POLICIES
5454
int __init btrfs_read_policy_init(void);
5555
char *btrfs_get_mod_read_policy(void);
5656
#endif

fs/btrfs/volumes.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1282,7 +1282,7 @@ static int open_fs_devices(struct btrfs_fs_devices *fs_devices,
12821282
fs_devices->latest_dev = latest_dev;
12831283
fs_devices->total_rw_bytes = 0;
12841284
fs_devices->chunk_alloc_policy = BTRFS_CHUNK_ALLOC_REGULAR;
1285-
#ifdef CONFIG_BTRFS_EXPERIMENTAL
1285+
#ifdef CONFIG_BTRFS_READ_POLICIES
12861286
fs_devices->rr_min_contig_read = BTRFS_DEFAULT_RR_MIN_CONTIG_READ;
12871287
fs_devices->read_devid = latest_dev->devid;
12881288
fs_devices->read_policy = btrfs_read_policy_to_enum(btrfs_get_mod_read_policy(),
@@ -6050,7 +6050,7 @@ unsigned long btrfs_full_stripe_len(struct btrfs_fs_info *fs_info,
60506050
return len;
60516051
}
60526052

6053-
#ifdef CONFIG_BTRFS_EXPERIMENTAL
6053+
#ifdef CONFIG_BTRFS_READ_POLICIES
60546054
static int btrfs_read_preferred(struct btrfs_chunk_map *map, int first, int num_stripes)
60556055
{
60566056
for (int index = first; index < first + num_stripes; index++) {
@@ -6158,7 +6158,7 @@ static int find_live_mirror(struct btrfs_fs_info *fs_info,
61586158
case BTRFS_READ_POLICY_PID:
61596159
preferred_mirror = first + (current->pid % num_stripes);
61606160
break;
6161-
#ifdef CONFIG_BTRFS_EXPERIMENTAL
6161+
#ifdef CONFIG_BTRFS_READ_POLICIES
61626162
case BTRFS_READ_POLICY_RR:
61636163
preferred_mirror = btrfs_read_rr(map, first, num_stripes);
61646164
break;

fs/btrfs/volumes.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,7 @@ enum btrfs_chunk_allocation_policy {
318318
enum btrfs_read_policy {
319319
/* Use process PID to choose the stripe */
320320
BTRFS_READ_POLICY_PID,
321-
#ifdef CONFIG_BTRFS_EXPERIMENTAL
321+
#ifdef CONFIG_BTRFS_READ_POLICIES
322322
/* Balancing RAID1 reads across all striped devices (round-robin). */
323323
BTRFS_READ_POLICY_RR,
324324
/* Read from a specific device. */
@@ -463,7 +463,7 @@ struct btrfs_fs_devices {
463463
/* Policy used to read the mirrored stripes. */
464464
enum btrfs_read_policy read_policy;
465465

466-
#ifdef CONFIG_BTRFS_EXPERIMENTAL
466+
#ifdef CONFIG_BTRFS_READ_POLICIES
467467
/*
468468
* Minimum contiguous reads before switching to next device, the unit
469469
* is one block/sectorsize.
@@ -472,7 +472,9 @@ struct btrfs_fs_devices {
472472

473473
/* Device to be used for reading in case of RAID1. */
474474
u64 read_devid;
475+
#endif
475476

477+
#ifdef CONFIG_BTRFS_EXPERIMENTAL
476478
/* Checksum mode - offload it or do it synchronously. */
477479
enum btrfs_offload_csum_mode offload_csum_mode;
478480
#endif

0 commit comments

Comments
 (0)