File: fsfeatures.h

package info (click to toggle)
btrfs-progs 6.2-1%2Bdeb12u1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 17,244 kB
  • sloc: ansic: 114,376; sh: 9,576; python: 1,242; makefile: 820
file content (97 lines) | stat: -rw-r--r-- 3,762 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
/*
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public
 * License v2 as published by the Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * General Public License for more details.
 *
 * You should have received a copy of the GNU General Public
 * License along with this program; if not, write to the
 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 * Boston, MA 021110-1307, USA.
 */

#ifndef __BTRFS_FSFEATURES_H__
#define __BTRFS_FSFEATURES_H__

#include "kerncompat.h"
#include <stdio.h>
#include "kernel-lib/sizes.h"

#define BTRFS_MKFS_DEFAULT_NODE_SIZE SZ_16K

/*
 * Since one feature can set at least one bit in either
 * incompat/compat_or/runtime flags, all mkfs features users should
 * use this structure to parse the features.
 */
struct btrfs_mkfs_features {
	u64 incompat_flags;
	u64 compat_ro_flags;
	u64 runtime_flags;
};

#define BTRFS_FEATURE_RUNTIME_QUOTA		(1ULL << 0)
#define BTRFS_FEATURE_RUNTIME_LIST_ALL		(1ULL << 1)

/*
 * Such buffer size should be able to contain all feature string, with extra
 * ", " for each feature.
 */
#define BTRFS_FEATURE_STRING_BUF_SIZE		(160)

static const struct btrfs_mkfs_features btrfs_mkfs_default_features = {
	.compat_ro_flags = BTRFS_FEATURE_COMPAT_RO_FREE_SPACE_TREE |
			   BTRFS_FEATURE_COMPAT_RO_FREE_SPACE_TREE_VALID,
	.incompat_flags	 = BTRFS_FEATURE_INCOMPAT_EXTENDED_IREF |
			   BTRFS_FEATURE_INCOMPAT_NO_HOLES |
			   BTRFS_FEATURE_INCOMPAT_SKINNY_METADATA,
};

/*
 * Avoid multi-device features (RAID56 and RAID1C34), mixed bgs, and zoned
 * mode for btrfs-convert, as all supported fses are single device fses.
 *
 * Features like compression is disabled in btrfs-convert by default, as
 * data is reusing the old data from the source fs.
 * Corresponding flag will be set when the first compression write happens.
 */
static const struct btrfs_mkfs_features btrfs_convert_allowed_features = {
	.compat_ro_flags = BTRFS_FEATURE_COMPAT_RO_FREE_SPACE_TREE |
			   BTRFS_FEATURE_COMPAT_RO_FREE_SPACE_TREE_VALID |
			   BTRFS_FEATURE_COMPAT_RO_BLOCK_GROUP_TREE,
	.incompat_flags  = BTRFS_FEATURE_INCOMPAT_MIXED_BACKREF |
			   BTRFS_FEATURE_INCOMPAT_DEFAULT_SUBVOL |
			   BTRFS_FEATURE_INCOMPAT_BIG_METADATA |
			   BTRFS_FEATURE_INCOMPAT_EXTENDED_IREF |
			   BTRFS_FEATURE_INCOMPAT_SKINNY_METADATA |
			   BTRFS_FEATURE_INCOMPAT_NO_HOLES,
	.runtime_flags   = BTRFS_FEATURE_RUNTIME_QUOTA,
};

void btrfs_list_all_fs_features(const struct btrfs_mkfs_features *allowed);
void btrfs_list_all_runtime_features(const struct btrfs_mkfs_features *allowed);
char *btrfs_parse_fs_features(char *namelist,
		struct btrfs_mkfs_features *features);
char *btrfs_parse_runtime_features(char *namelist,
		struct btrfs_mkfs_features *features);
void btrfs_process_fs_features(struct btrfs_mkfs_features *features);
void btrfs_process_runtime_features(struct btrfs_mkfs_features *features);
void btrfs_parse_fs_features_to_string(char *buf,
		const struct btrfs_mkfs_features *features);
void btrfs_parse_runtime_features_to_string(char *buf,
		const struct btrfs_mkfs_features *features);
void print_kernel_version(FILE *stream, u32 version);
u32 get_running_kernel_version(void);
int btrfs_check_nodesize(u32 nodesize, u32 sectorsize,
			 struct btrfs_mkfs_features *features);
int btrfs_check_sectorsize(u32 sectorsize);
int btrfs_check_features(const struct btrfs_mkfs_features *features,
			 const struct btrfs_mkfs_features *allowed);
int btrfs_tree_search2_ioctl_supported(int fd);
void btrfs_assert_feature_buf_size(void);

#endif