Skip to content

Commit 15ddcdd

Browse files
josefbacikkdave
authored andcommitted
btrfs: add fs_parameter definitions
In order to convert to the new mount API we have to change how we do the mount option parsing. For now we're going to duplicate these helpers to make it easier to follow, and then remove the old code once everything is in place. This patch contains the re-definition of all of our mount options into the new fs_parameter_spec format. Reviewed-by: Johannes Thumshirn <[email protected]> Reviewed-by: Anand Jain <[email protected]> Acked-by: Christian Brauner <[email protected]> Signed-off-by: Josef Bacik <[email protected]> Reviewed-by: David Sterba <[email protected]> Signed-off-by: David Sterba <[email protected]>
1 parent 2496bff commit 15ddcdd

File tree

1 file changed

+125
-1
lines changed

1 file changed

+125
-1
lines changed

fs/btrfs/super.c

Lines changed: 125 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
#include <linux/crc32c.h>
2828
#include <linux/btrfs.h>
2929
#include <linux/security.h>
30+
#include <linux/fs_parser.h>
3031
#include "messages.h"
3132
#include "delayed-inode.h"
3233
#include "ctree.h"
@@ -135,7 +136,7 @@ enum {
135136
/* Debugging options */
136137
Opt_enospc_debug, Opt_noenospc_debug,
137138
#ifdef CONFIG_BTRFS_DEBUG
138-
Opt_fragment_data, Opt_fragment_metadata, Opt_fragment_all,
139+
Opt_fragment, Opt_fragment_data, Opt_fragment_metadata, Opt_fragment_all,
139140
#endif
140141
#ifdef CONFIG_BTRFS_FS_REF_VERIFY
141142
Opt_ref_verify,
@@ -225,6 +226,129 @@ static const match_table_t rescue_tokens = {
225226
{Opt_err, NULL},
226227
};
227228

229+
enum {
230+
Opt_fatal_errors_panic,
231+
Opt_fatal_errors_bug,
232+
};
233+
234+
static const struct constant_table btrfs_parameter_fatal_errors[] = {
235+
{ "panic", Opt_fatal_errors_panic },
236+
{ "bug", Opt_fatal_errors_bug },
237+
{}
238+
};
239+
240+
enum {
241+
Opt_discard_sync,
242+
Opt_discard_async,
243+
};
244+
245+
static const struct constant_table btrfs_parameter_discard[] = {
246+
{ "sync", Opt_discard_sync },
247+
{ "async", Opt_discard_async },
248+
{}
249+
};
250+
251+
enum {
252+
Opt_space_cache_v1,
253+
Opt_space_cache_v2,
254+
};
255+
256+
static const struct constant_table btrfs_parameter_space_cache[] = {
257+
{ "v1", Opt_space_cache_v1 },
258+
{ "v2", Opt_space_cache_v2 },
259+
{}
260+
};
261+
262+
enum {
263+
Opt_rescue_usebackuproot,
264+
Opt_rescue_nologreplay,
265+
Opt_rescue_ignorebadroots,
266+
Opt_rescue_ignoredatacsums,
267+
Opt_rescue_parameter_all,
268+
};
269+
270+
static const struct constant_table btrfs_parameter_rescue[] = {
271+
{ "usebackuproot", Opt_rescue_usebackuproot },
272+
{ "nologreplay", Opt_rescue_nologreplay },
273+
{ "ignorebadroots", Opt_rescue_ignorebadroots },
274+
{ "ibadroots", Opt_rescue_ignorebadroots },
275+
{ "ignoredatacsums", Opt_rescue_ignoredatacsums },
276+
{ "idatacsums", Opt_rescue_ignoredatacsums },
277+
{ "all", Opt_rescue_parameter_all },
278+
{}
279+
};
280+
281+
#ifdef CONFIG_BTRFS_DEBUG
282+
enum {
283+
Opt_fragment_parameter_data,
284+
Opt_fragment_parameter_metadata,
285+
Opt_fragment_parameter_all,
286+
};
287+
288+
static const struct constant_table btrfs_parameter_fragment[] = {
289+
{ "data", Opt_fragment_parameter_data },
290+
{ "metadata", Opt_fragment_parameter_metadata },
291+
{ "all", Opt_fragment_parameter_all },
292+
{}
293+
};
294+
#endif
295+
296+
static const struct fs_parameter_spec btrfs_fs_parameters[] __maybe_unused = {
297+
fsparam_flag_no("acl", Opt_acl),
298+
fsparam_flag_no("autodefrag", Opt_defrag),
299+
fsparam_flag_no("barrier", Opt_barrier),
300+
fsparam_flag("clear_cache", Opt_clear_cache),
301+
fsparam_u32("commit", Opt_commit_interval),
302+
fsparam_flag("compress", Opt_compress),
303+
fsparam_string("compress", Opt_compress_type),
304+
fsparam_flag("compress-force", Opt_compress_force),
305+
fsparam_string("compress-force", Opt_compress_force_type),
306+
fsparam_flag_no("datacow", Opt_datacow),
307+
fsparam_flag_no("datasum", Opt_datasum),
308+
fsparam_flag("degraded", Opt_degraded),
309+
fsparam_string("device", Opt_device),
310+
fsparam_flag_no("discard", Opt_discard),
311+
fsparam_enum("discard", Opt_discard_mode, btrfs_parameter_discard),
312+
fsparam_enum("fatal_errors", Opt_fatal_errors, btrfs_parameter_fatal_errors),
313+
fsparam_flag_no("flushoncommit", Opt_flushoncommit),
314+
fsparam_flag_no("inode_cache", Opt_inode_cache),
315+
fsparam_string("max_inline", Opt_max_inline),
316+
fsparam_u32("metadata_ratio", Opt_ratio),
317+
fsparam_flag("rescan_uuid_tree", Opt_rescan_uuid_tree),
318+
fsparam_flag("skip_balance", Opt_skip_balance),
319+
fsparam_flag_no("space_cache", Opt_space_cache),
320+
fsparam_enum("space_cache", Opt_space_cache_version, btrfs_parameter_space_cache),
321+
fsparam_flag_no("ssd", Opt_ssd),
322+
fsparam_flag_no("ssd_spread", Opt_ssd_spread),
323+
fsparam_string("subvol", Opt_subvol),
324+
fsparam_flag("subvol=", Opt_subvol_empty),
325+
fsparam_u64("subvolid", Opt_subvolid),
326+
fsparam_u32("thread_pool", Opt_thread_pool),
327+
fsparam_flag_no("treelog", Opt_treelog),
328+
fsparam_flag("user_subvol_rm_allowed", Opt_user_subvol_rm_allowed),
329+
330+
/* Rescue options. */
331+
fsparam_enum("rescue", Opt_rescue, btrfs_parameter_rescue),
332+
/* Deprecated, with alias rescue=nologreplay */
333+
__fsparam(NULL, "nologreplay", Opt_nologreplay, fs_param_deprecated, NULL),
334+
/* Deprecated, with alias rescue=usebackuproot */
335+
__fsparam(NULL, "usebackuproot", Opt_usebackuproot, fs_param_deprecated, NULL),
336+
337+
/* Deprecated options. */
338+
__fsparam(NULL, "recovery", Opt_recovery,
339+
fs_param_neg_with_no | fs_param_deprecated, NULL),
340+
341+
/* Debugging options. */
342+
fsparam_flag_no("enospc_debug", Opt_enospc_debug),
343+
#ifdef CONFIG_BTRFS_DEBUG
344+
fsparam_enum("fragment", Opt_fragment, btrfs_parameter_fragment),
345+
#endif
346+
#ifdef CONFIG_BTRFS_FS_REF_VERIFY
347+
fsparam_flag("ref_verify", Opt_ref_verify),
348+
#endif
349+
{}
350+
};
351+
228352
static bool check_ro_option(struct btrfs_fs_info *fs_info, unsigned long opt,
229353
const char *opt_name)
230354
{

0 commit comments

Comments
 (0)