1
2
3
4
5
6
7#ifndef __ZONEFS_H__
8#define __ZONEFS_H__
9
10#include <linux/fs.h>
11#include <linux/magic.h>
12#include <linux/uuid.h>
13#include <linux/mutex.h>
14#include <linux/rwsem.h>
15
16
17
18
19
20
21#define ZONEFS_NAME_MAX 16
22
23
24
25
26
27
28enum zonefs_ztype {
29 ZONEFS_ZTYPE_CNV,
30 ZONEFS_ZTYPE_SEQ,
31 ZONEFS_ZTYPE_MAX,
32};
33
34static inline enum zonefs_ztype zonefs_zone_type(struct blk_zone *zone)
35{
36 if (zone->type == BLK_ZONE_TYPE_CONVENTIONAL)
37 return ZONEFS_ZTYPE_CNV;
38 return ZONEFS_ZTYPE_SEQ;
39}
40
41#define ZONEFS_ZONE_OPEN (1 << 0)
42
43
44
45
46struct zonefs_inode_info {
47 struct inode i_vnode;
48
49
50 enum zonefs_ztype i_ztype;
51
52
53 sector_t i_zsector;
54
55
56 loff_t i_wpoffset;
57
58
59 loff_t i_max_size;
60
61
62 loff_t i_zone_size;
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77 struct mutex i_truncate_mutex;
78 struct rw_semaphore i_mmap_sem;
79
80
81 unsigned int i_wr_refcnt;
82 unsigned int i_flags;
83};
84
85static inline struct zonefs_inode_info *ZONEFS_I(struct inode *inode)
86{
87 return container_of(inode, struct zonefs_inode_info, i_vnode);
88}
89
90
91
92
93#define ZONEFS_LABEL_LEN 64
94#define ZONEFS_UUID_SIZE 16
95#define ZONEFS_SUPER_SIZE 4096
96
97struct zonefs_super {
98
99
100 __le32 s_magic;
101
102
103 __le32 s_crc;
104
105
106 char s_label[ZONEFS_LABEL_LEN];
107
108
109 __u8 s_uuid[ZONEFS_UUID_SIZE];
110
111
112 __le64 s_features;
113
114
115 __le32 s_uid;
116 __le32 s_gid;
117
118
119 __le32 s_perm;
120
121
122 __u8 s_reserved[3988];
123
124} __packed;
125
126
127
128
129
130
131enum zonefs_features {
132
133
134
135 ZONEFS_F_AGGRCNV = 1ULL << 0,
136
137
138
139 ZONEFS_F_UID = 1ULL << 1,
140
141
142
143 ZONEFS_F_GID = 1ULL << 2,
144
145
146
147 ZONEFS_F_PERM = 1ULL << 3,
148};
149
150#define ZONEFS_F_DEFINED_FEATURES \
151 (ZONEFS_F_AGGRCNV | ZONEFS_F_UID | ZONEFS_F_GID | ZONEFS_F_PERM)
152
153
154
155
156#define ZONEFS_MNTOPT_ERRORS_RO (1 << 0)
157#define ZONEFS_MNTOPT_ERRORS_ZRO (1 << 1)
158#define ZONEFS_MNTOPT_ERRORS_ZOL (1 << 2)
159#define ZONEFS_MNTOPT_ERRORS_REPAIR (1 << 3)
160#define ZONEFS_MNTOPT_ERRORS_MASK \
161 (ZONEFS_MNTOPT_ERRORS_RO | ZONEFS_MNTOPT_ERRORS_ZRO | \
162 ZONEFS_MNTOPT_ERRORS_ZOL | ZONEFS_MNTOPT_ERRORS_REPAIR)
163#define ZONEFS_MNTOPT_EXPLICIT_OPEN (1 << 4)
164
165
166
167
168struct zonefs_sb_info {
169
170 unsigned long s_mount_opts;
171
172 spinlock_t s_lock;
173
174 unsigned long long s_features;
175 kuid_t s_uid;
176 kgid_t s_gid;
177 umode_t s_perm;
178 uuid_t s_uuid;
179 unsigned int s_zone_sectors_shift;
180
181 unsigned int s_nr_files[ZONEFS_ZTYPE_MAX];
182
183 loff_t s_blocks;
184 loff_t s_used_blocks;
185
186 unsigned int s_max_open_zones;
187 atomic_t s_open_zones;
188};
189
190static inline struct zonefs_sb_info *ZONEFS_SB(struct super_block *sb)
191{
192 return sb->s_fs_info;
193}
194
195#define zonefs_info(sb, format, args...) \
196 pr_info("zonefs (%s): " format, sb->s_id, ## args)
197#define zonefs_err(sb, format, args...) \
198 pr_err("zonefs (%s) ERROR: " format, sb->s_id, ## args)
199#define zonefs_warn(sb, format, args...) \
200 pr_warn("zonefs (%s) WARNING: " format, sb->s_id, ## args)
201
202#endif
203