@@ -570,6 +570,15 @@ enum btrfs_exclusive_operation {
BTRFS_EXCLOP_SWAP_ACTIVATE,
};
+/*
+ * allocation_hint mode
+ */
+
+enum btrfs_allocation_hint_modes {
+ BTRFS_ALLOCATION_HINT_DISABLED,
+ BTRFS_ALLOCATION_HINT_ENABLED
+};
+
struct btrfs_fs_info {
u8 chunk_tree_uuid[BTRFS_UUID_SIZE];
unsigned long flags;
@@ -961,6 +970,9 @@ struct btrfs_fs_info {
u64 zoned;
};
+ /* allocation_hint mode */
+ int allocation_hint_mode;
+
/* Max size to emit ZONE_APPEND write command */
u64 max_zone_append_size;
@@ -2794,6 +2794,8 @@ void btrfs_init_fs_info(struct btrfs_fs_info *fs_info)
fs_info->swapfile_pins = RB_ROOT;
fs_info->send_in_progress = 0;
+
+ fs_info->allocation_hint_mode = BTRFS_ALLOCATION_HINT_DISABLED;
}
static int init_mount_fs_info(struct btrfs_fs_info *fs_info, struct super_block *sb)
@@ -359,6 +359,7 @@ enum {
Opt_thread_pool,
Opt_treelog, Opt_notreelog,
Opt_user_subvol_rm_allowed,
+ Opt_allocation_hint,
/* Rescue options */
Opt_rescue,
@@ -432,6 +433,7 @@ static const match_table_t tokens = {
{Opt_treelog, "treelog"},
{Opt_notreelog, "notreelog"},
{Opt_user_subvol_rm_allowed, "user_subvol_rm_allowed"},
+ {Opt_allocation_hint, "allocation_hint=%d"},
/* Rescue options */
{Opt_rescue, "rescue=%s"},
@@ -889,6 +891,19 @@ int btrfs_parse_options(struct btrfs_fs_info *info, char *options,
case Opt_user_subvol_rm_allowed:
btrfs_set_opt(info->mount_opt, USER_SUBVOL_RM_ALLOWED);
break;
+ case Opt_allocation_hint:
+ ret = match_int(&args[0], &intarg);
+ if (ret || (intarg != 1 && intarg != 0)) {
+ btrfs_err(info, "invalid allocation_hint= parameter\n");
+ ret = -EINVAL;
+ goto out;
+ }
+ if (intarg)
+ btrfs_info(info, "allocation_hint enabled");
+ else
+ btrfs_info(info, "allocation_hint disabled");
+ info->allocation_hint_mode = intarg;
+ break;
case Opt_enospc_debug:
btrfs_set_opt(info->mount_opt, ENOSPC_DEBUG);
break;
@@ -1495,6 +1510,8 @@ static int btrfs_show_options(struct seq_file *seq, struct dentry *dentry)
seq_puts(seq, ",clear_cache");
if (btrfs_test_opt(info, USER_SUBVOL_RM_ALLOWED))
seq_puts(seq, ",user_subvol_rm_allowed");
+ if (info->allocation_hint_mode)
+ seq_puts(seq, ",allocation_hint=1");
if (btrfs_test_opt(info, ENOSPC_DEBUG))
seq_puts(seq, ",enospc_debug");
if (btrfs_test_opt(info, AUTO_DEFRAG))