opts.h (991ba0211290884df42f9506499aba7e933a2bb8) | opts.h (8244f3209b5b49a6bde9921d7825af9f57161b23) |
---|---|
1/* SPDX-License-Identifier: GPL-2.0 */ 2#ifndef _BCACHEFS_OPTS_H 3#define _BCACHEFS_OPTS_H 4 5#include <linux/bug.h> 6#include <linux/log2.h> 7#include <linux/string.h> 8#include <linux/sysfs.h> --- 30 unchanged lines hidden (view full) --- 39 * can pass the mount options to bch2_fs_alloc() as a whole struct, and then only 40 * apply the options from that struct that are defined. 41 */ 42 43/* dummy option, for options that aren't stored in the superblock */ 44LE64_BITMASK(NO_SB_OPT, struct bch_sb, flags[0], 0, 0); 45 46/* When can be set: */ | 1/* SPDX-License-Identifier: GPL-2.0 */ 2#ifndef _BCACHEFS_OPTS_H 3#define _BCACHEFS_OPTS_H 4 5#include <linux/bug.h> 6#include <linux/log2.h> 7#include <linux/string.h> 8#include <linux/sysfs.h> --- 30 unchanged lines hidden (view full) --- 39 * can pass the mount options to bch2_fs_alloc() as a whole struct, and then only 40 * apply the options from that struct that are defined. 41 */ 42 43/* dummy option, for options that aren't stored in the superblock */ 44LE64_BITMASK(NO_SB_OPT, struct bch_sb, flags[0], 0, 0); 45 46/* When can be set: */ |
47enum opt_mode { | 47enum opt_flags { |
48 OPT_FS = (1 << 0), /* Filesystem option */ 49 OPT_DEVICE = (1 << 1), /* Device option */ 50 OPT_INODE = (1 << 2), /* Inode option */ 51 OPT_FORMAT = (1 << 3), /* May be specified at format time */ 52 OPT_MOUNT = (1 << 4), /* May be specified at mount time */ 53 OPT_RUNTIME = (1 << 5), /* May be specified at runtime */ | 48 OPT_FS = (1 << 0), /* Filesystem option */ 49 OPT_DEVICE = (1 << 1), /* Device option */ 50 OPT_INODE = (1 << 2), /* Inode option */ 51 OPT_FORMAT = (1 << 3), /* May be specified at format time */ 52 OPT_MOUNT = (1 << 4), /* May be specified at mount time */ 53 OPT_RUNTIME = (1 << 5), /* May be specified at runtime */ |
54 OPT_HUMAN_READABLE = (1 << 6), 55 OPT_MUST_BE_POW_2 = (1 << 7), /* Must be power of 2 */ 56 OPT_SB_FIELD_SECTORS = (1 << 8),/* Superblock field is >> 9 of actual value */ 57 OPT_SB_FIELD_ILOG2 = (1 << 9), /* Superblock field is ilog2 of actual value */ |
|
54}; 55 56enum opt_type { 57 BCH_OPT_BOOL, 58 BCH_OPT_UINT, | 58}; 59 60enum opt_type { 61 BCH_OPT_BOOL, 62 BCH_OPT_UINT, |
59 BCH_OPT_SECTORS, | |
60 BCH_OPT_STR, 61 BCH_OPT_FN, 62}; 63 64/** 65 * x(name, shortopt, type, in mem type, mode, sb_opt) 66 * 67 * @name - name of mount option, sysfs attribute, and struct bch_opts --- 15 unchanged lines hidden (view full) --- 83#ifdef __KERNEL__ 84#define RATELIMIT_ERRORS_DEFAULT true 85#else 86#define RATELIMIT_ERRORS_DEFAULT false 87#endif 88 89#define BCH_OPTS() \ 90 x(block_size, u16, \ | 63 BCH_OPT_STR, 64 BCH_OPT_FN, 65}; 66 67/** 68 * x(name, shortopt, type, in mem type, mode, sb_opt) 69 * 70 * @name - name of mount option, sysfs attribute, and struct bch_opts --- 15 unchanged lines hidden (view full) --- 86#ifdef __KERNEL__ 87#define RATELIMIT_ERRORS_DEFAULT true 88#else 89#define RATELIMIT_ERRORS_DEFAULT false 90#endif 91 92#define BCH_OPTS() \ 93 x(block_size, u16, \ |
91 OPT_FS|OPT_FORMAT, \ 92 OPT_SECTORS(1, 128), \ | 94 OPT_FS|OPT_FORMAT| \ 95 OPT_HUMAN_READABLE|OPT_MUST_BE_POW_2|OPT_SB_FIELD_SECTORS, \ 96 OPT_UINT(512, 1U << 16), \ |
93 BCH_SB_BLOCK_SIZE, 8, \ 94 "size", NULL) \ | 97 BCH_SB_BLOCK_SIZE, 8, \ 98 "size", NULL) \ |
95 x(btree_node_size, u16, \ 96 OPT_FS|OPT_FORMAT, \ 97 OPT_SECTORS(1, 512), \ | 99 x(btree_node_size, u32, \ 100 OPT_FS|OPT_FORMAT| \ 101 OPT_HUMAN_READABLE|OPT_MUST_BE_POW_2|OPT_SB_FIELD_SECTORS, \ 102 OPT_UINT(512, 1U << 20), \ |
98 BCH_SB_BTREE_NODE_SIZE, 512, \ 99 "size", "Btree node size, default 256k") \ 100 x(errors, u8, \ 101 OPT_FS|OPT_FORMAT|OPT_MOUNT|OPT_RUNTIME, \ 102 OPT_STR(bch2_error_actions), \ 103 BCH_SB_ERROR_ACTION, BCH_ON_ERROR_ro, \ 104 NULL, "Action to take on filesystem error") \ 105 x(metadata_replicas, u8, \ --- 87 unchanged lines hidden (view full) --- 193 NO_SB_OPT, true, \ 194 NULL, "Stash pointer to in memory btree node in btree ptr")\ 195 x(gc_reserve_percent, u8, \ 196 OPT_FS|OPT_FORMAT|OPT_MOUNT|OPT_RUNTIME, \ 197 OPT_UINT(5, 21), \ 198 BCH_SB_GC_RESERVE, 8, \ 199 "%", "Percentage of disk space to reserve for copygc")\ 200 x(gc_reserve_bytes, u64, \ | 103 BCH_SB_BTREE_NODE_SIZE, 512, \ 104 "size", "Btree node size, default 256k") \ 105 x(errors, u8, \ 106 OPT_FS|OPT_FORMAT|OPT_MOUNT|OPT_RUNTIME, \ 107 OPT_STR(bch2_error_actions), \ 108 BCH_SB_ERROR_ACTION, BCH_ON_ERROR_ro, \ 109 NULL, "Action to take on filesystem error") \ 110 x(metadata_replicas, u8, \ --- 87 unchanged lines hidden (view full) --- 198 NO_SB_OPT, true, \ 199 NULL, "Stash pointer to in memory btree node in btree ptr")\ 200 x(gc_reserve_percent, u8, \ 201 OPT_FS|OPT_FORMAT|OPT_MOUNT|OPT_RUNTIME, \ 202 OPT_UINT(5, 21), \ 203 BCH_SB_GC_RESERVE, 8, \ 204 "%", "Percentage of disk space to reserve for copygc")\ 205 x(gc_reserve_bytes, u64, \ |
201 OPT_FS|OPT_FORMAT|OPT_MOUNT|OPT_RUNTIME, \ 202 OPT_SECTORS(0, U64_MAX), \ | 206 OPT_FS|OPT_FORMAT|OPT_MOUNT|OPT_RUNTIME| \ 207 OPT_HUMAN_READABLE|OPT_SB_FIELD_SECTORS, \ 208 OPT_UINT(0, U64_MAX), \ |
203 BCH_SB_GC_RESERVE_BYTES, 0, \ 204 "%", "Amount of disk space to reserve for copygc\n" \ 205 "Takes precedence over gc_reserve_percent if set")\ 206 x(root_reserve_percent, u8, \ 207 OPT_FS|OPT_FORMAT|OPT_MOUNT, \ 208 OPT_UINT(0, 100), \ 209 BCH_SB_ROOT_RESERVE, 0, \ 210 "%", "Percentage of disk space to reserve for superuser")\ --- 144 unchanged lines hidden (view full) --- 355 x(no_data_io, u8, \ 356 OPT_MOUNT, \ 357 OPT_BOOL(), \ 358 NO_SB_OPT, false, \ 359 NULL, "Skip submit_bio() for data reads and writes, " \ 360 "for performance testing purposes") \ 361 x(fs_size, u64, \ 362 OPT_DEVICE, \ | 209 BCH_SB_GC_RESERVE_BYTES, 0, \ 210 "%", "Amount of disk space to reserve for copygc\n" \ 211 "Takes precedence over gc_reserve_percent if set")\ 212 x(root_reserve_percent, u8, \ 213 OPT_FS|OPT_FORMAT|OPT_MOUNT, \ 214 OPT_UINT(0, 100), \ 215 BCH_SB_ROOT_RESERVE, 0, \ 216 "%", "Percentage of disk space to reserve for superuser")\ --- 144 unchanged lines hidden (view full) --- 361 x(no_data_io, u8, \ 362 OPT_MOUNT, \ 363 OPT_BOOL(), \ 364 NO_SB_OPT, false, \ 365 NULL, "Skip submit_bio() for data reads and writes, " \ 366 "for performance testing purposes") \ 367 x(fs_size, u64, \ 368 OPT_DEVICE, \ |
363 OPT_SECTORS(0, S64_MAX), \ | 369 OPT_UINT(0, S64_MAX), \ |
364 NO_SB_OPT, 0, \ 365 "size", "Size of filesystem on device") \ 366 x(bucket, u32, \ 367 OPT_DEVICE, \ | 370 NO_SB_OPT, 0, \ 371 "size", "Size of filesystem on device") \ 372 x(bucket, u32, \ 373 OPT_DEVICE, \ |
368 OPT_SECTORS(0, S64_MAX), \ | 374 OPT_UINT(0, S64_MAX), \ |
369 NO_SB_OPT, 0, \ 370 "size", "Size of filesystem on device") \ 371 x(durability, u8, \ 372 OPT_DEVICE, \ 373 OPT_UINT(0, BCH_REPLICAS_MAX), \ 374 NO_SB_OPT, 1, \ 375 "n", "Data written to this device will be considered\n"\ 376 "to have already been replicated n times") --- 42 unchanged lines hidden (view full) --- 419 bch2_opts_nr 420}; 421 422struct bch_fs; 423struct printbuf; 424 425struct bch_option { 426 struct attribute attr; | 375 NO_SB_OPT, 0, \ 376 "size", "Size of filesystem on device") \ 377 x(durability, u8, \ 378 OPT_DEVICE, \ 379 OPT_UINT(0, BCH_REPLICAS_MAX), \ 380 NO_SB_OPT, 1, \ 381 "n", "Data written to this device will be considered\n"\ 382 "to have already been replicated n times") --- 42 unchanged lines hidden (view full) --- 425 bch2_opts_nr 426}; 427 428struct bch_fs; 429struct printbuf; 430 431struct bch_option { 432 struct attribute attr; |
433 u64 (*get_sb)(const struct bch_sb *); |
|
427 void (*set_sb)(struct bch_sb *, u64); | 434 void (*set_sb)(struct bch_sb *, u64); |
428 enum opt_mode mode; | |
429 enum opt_type type; | 435 enum opt_type type; |
436 enum opt_flags flags; 437 u64 min, max; |
|
430 431 union { 432 struct { | 438 439 union { 440 struct { |
433 u64 min, max; | |
434 }; 435 struct { 436 const char * const *choices; 437 }; 438 struct { 439 int (*parse)(struct bch_fs *, const char *, u64 *); 440 void (*to_text)(struct printbuf *, struct bch_fs *, u64); 441 }; --- 5 unchanged lines hidden (view full) --- 447}; 448 449extern const struct bch_option bch2_opt_table[]; 450 451bool bch2_opt_defined_by_id(const struct bch_opts *, enum bch_opt_id); 452u64 bch2_opt_get_by_id(const struct bch_opts *, enum bch_opt_id); 453void bch2_opt_set_by_id(struct bch_opts *, enum bch_opt_id, u64); 454 | 441 }; 442 struct { 443 const char * const *choices; 444 }; 445 struct { 446 int (*parse)(struct bch_fs *, const char *, u64 *); 447 void (*to_text)(struct printbuf *, struct bch_fs *, u64); 448 }; --- 5 unchanged lines hidden (view full) --- 454}; 455 456extern const struct bch_option bch2_opt_table[]; 457 458bool bch2_opt_defined_by_id(const struct bch_opts *, enum bch_opt_id); 459u64 bch2_opt_get_by_id(const struct bch_opts *, enum bch_opt_id); 460void bch2_opt_set_by_id(struct bch_opts *, enum bch_opt_id, u64); 461 |
455struct bch_opts bch2_opts_from_sb(struct bch_sb *); | 462int bch2_opts_from_sb(struct bch_opts *, struct bch_sb *); 463void __bch2_opt_set_sb(struct bch_sb *, const struct bch_option *, u64); 464void bch2_opt_set_sb(struct bch_fs *, const struct bch_option *, u64); |
456 457int bch2_opt_lookup(const char *); | 465 466int bch2_opt_lookup(const char *); |
458int bch2_opt_parse(struct bch_fs *, const struct bch_option *, const char *, u64 *); | 467int bch2_opt_parse(struct bch_fs *, const char *, const struct bch_option *, 468 const char *, u64 *); |
459 460#define OPT_SHOW_FULL_LIST (1 << 0) 461#define OPT_SHOW_MOUNT_STYLE (1 << 1) 462 463void bch2_opt_to_text(struct printbuf *, struct bch_fs *, 464 const struct bch_option *, u64, unsigned); 465 466int bch2_opt_check_may_set(struct bch_fs *, int, u64); --- 21 unchanged lines hidden --- | 469 470#define OPT_SHOW_FULL_LIST (1 << 0) 471#define OPT_SHOW_MOUNT_STYLE (1 << 1) 472 473void bch2_opt_to_text(struct printbuf *, struct bch_fs *, 474 const struct bch_option *, u64, unsigned); 475 476int bch2_opt_check_may_set(struct bch_fs *, int, u64); --- 21 unchanged lines hidden --- |