~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/fs/zonefs/zonefs.h

Version: ~ [ linux-6.11-rc3 ] ~ [ linux-6.10.4 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.45 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.104 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.164 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.223 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.281 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.319 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.9 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

Diff markup

Differences between /fs/zonefs/zonefs.h (Version linux-6.11-rc3) and /fs/zonefs/zonefs.h (Version linux-5.12.19)


  1 /* SPDX-License-Identifier: GPL-2.0 */              1 /* SPDX-License-Identifier: GPL-2.0 */
  2 /*                                                  2 /*
  3  * Simple zone file system for zoned block dev      3  * Simple zone file system for zoned block devices.
  4  *                                                  4  *
  5  * Copyright (C) 2019 Western Digital Corporat      5  * Copyright (C) 2019 Western Digital Corporation or its affiliates.
  6  */                                                 6  */
  7 #ifndef __ZONEFS_H__                                7 #ifndef __ZONEFS_H__
  8 #define __ZONEFS_H__                                8 #define __ZONEFS_H__
  9                                                     9 
 10 #include <linux/fs.h>                              10 #include <linux/fs.h>
 11 #include <linux/magic.h>                           11 #include <linux/magic.h>
 12 #include <linux/uuid.h>                            12 #include <linux/uuid.h>
 13 #include <linux/mutex.h>                           13 #include <linux/mutex.h>
 14 #include <linux/rwsem.h>                           14 #include <linux/rwsem.h>
 15 #include <linux/kobject.h>                     << 
 16                                                    15 
 17 /*                                                 16 /*
 18  * Maximum length of file names: this only nee     17  * Maximum length of file names: this only needs to be large enough to fit
 19  * the zone group directory names and a decima     18  * the zone group directory names and a decimal zone number for file names.
 20  * 16 characters is plenty.                        19  * 16 characters is plenty.
 21  */                                                20  */
 22 #define ZONEFS_NAME_MAX         16                 21 #define ZONEFS_NAME_MAX         16
 23                                                    22 
 24 /*                                                 23 /*
 25  * Zone types: ZONEFS_ZTYPE_SEQ is used for al     24  * Zone types: ZONEFS_ZTYPE_SEQ is used for all sequential zone types
 26  * defined in linux/blkzoned.h, that is, BLK_Z     25  * defined in linux/blkzoned.h, that is, BLK_ZONE_TYPE_SEQWRITE_REQ and
 27  * BLK_ZONE_TYPE_SEQWRITE_PREF.                    26  * BLK_ZONE_TYPE_SEQWRITE_PREF.
 28  */                                                27  */
 29 enum zonefs_ztype {                                28 enum zonefs_ztype {
 30         ZONEFS_ZTYPE_CNV,                          29         ZONEFS_ZTYPE_CNV,
 31         ZONEFS_ZTYPE_SEQ,                          30         ZONEFS_ZTYPE_SEQ,
 32         ZONEFS_ZTYPE_MAX,                          31         ZONEFS_ZTYPE_MAX,
 33 };                                                 32 };
 34                                                    33 
 35 static inline enum zonefs_ztype zonefs_zone_ty     34 static inline enum zonefs_ztype zonefs_zone_type(struct blk_zone *zone)
 36 {                                                  35 {
 37         if (zone->type == BLK_ZONE_TYPE_CONVEN     36         if (zone->type == BLK_ZONE_TYPE_CONVENTIONAL)
 38                 return ZONEFS_ZTYPE_CNV;           37                 return ZONEFS_ZTYPE_CNV;
 39         return ZONEFS_ZTYPE_SEQ;                   38         return ZONEFS_ZTYPE_SEQ;
 40 }                                                  39 }
 41                                                    40 
 42 #define ZONEFS_ZONE_INIT_MODE   (1U << 0)      !!  41 #define ZONEFS_ZONE_OPEN        (1 << 0)
 43 #define ZONEFS_ZONE_OPEN        (1U << 1)      << 
 44 #define ZONEFS_ZONE_ACTIVE      (1U << 2)      << 
 45 #define ZONEFS_ZONE_OFFLINE     (1U << 3)      << 
 46 #define ZONEFS_ZONE_READONLY    (1U << 4)      << 
 47 #define ZONEFS_ZONE_CNV         (1U << 31)     << 
 48                                                << 
 49 /*                                             << 
 50  * In-memory per-file inode zone data.         << 
 51  */                                            << 
 52 struct zonefs_zone {                           << 
 53         /* Zone state flags */                 << 
 54         unsigned int            z_flags;       << 
 55                                                << 
 56         /* Zone start sector (512B unit) */    << 
 57         sector_t                z_sector;      << 
 58                                                << 
 59         /* Zone size (bytes) */                << 
 60         loff_t                  z_size;        << 
 61                                                << 
 62         /* Zone capacity (file maximum size, b << 
 63         loff_t                  z_capacity;    << 
 64                                                << 
 65         /* Write pointer offset in the zone (s << 
 66         loff_t                  z_wpoffset;    << 
 67                                                << 
 68         /* Saved inode uid, gid and access rig << 
 69         umode_t                 z_mode;        << 
 70         kuid_t                  z_uid;         << 
 71         kgid_t                  z_gid;         << 
 72 };                                             << 
 73                                                << 
 74 /*                                             << 
 75  * In memory zone group information: all zones << 
 76  * as files, one file per zone.                << 
 77  */                                            << 
 78 struct zonefs_zone_group {                     << 
 79         struct inode            *g_inode;      << 
 80         unsigned int            g_nr_zones;    << 
 81         struct zonefs_zone      *g_zones;      << 
 82 };                                             << 
 83                                                    42 
 84 /*                                                 43 /*
 85  * In-memory inode data.                           44  * In-memory inode data.
 86  */                                                45  */
 87 struct zonefs_inode_info {                         46 struct zonefs_inode_info {
 88         struct inode            i_vnode;           47         struct inode            i_vnode;
 89                                                    48 
                                                   >>  49         /* File zone type */
                                                   >>  50         enum zonefs_ztype       i_ztype;
                                                   >>  51 
                                                   >>  52         /* File zone start sector (512B unit) */
                                                   >>  53         sector_t                i_zsector;
                                                   >>  54 
                                                   >>  55         /* File zone write pointer position (sequential zones only) */
                                                   >>  56         loff_t                  i_wpoffset;
                                                   >>  57 
                                                   >>  58         /* File maximum size */
                                                   >>  59         loff_t                  i_max_size;
                                                   >>  60 
                                                   >>  61         /* File zone size */
                                                   >>  62         loff_t                  i_zone_size;
                                                   >>  63 
 90         /*                                         64         /*
 91          * To serialise fully against both sys     65          * To serialise fully against both syscall and mmap based IO and
 92          * sequential file truncation, two loc     66          * sequential file truncation, two locks are used. For serializing
 93          * zonefs_seq_file_truncate() against      67          * zonefs_seq_file_truncate() against zonefs_iomap_begin(), that is,
 94          * file truncate operations against bl     68          * file truncate operations against block mapping, i_truncate_mutex is
 95          * used. i_truncate_mutex also protect     69          * used. i_truncate_mutex also protects against concurrent accesses
 96          * and changes to the inode private da     70          * and changes to the inode private data, and in particular changes to
 97          * a sequential file size on completio     71          * a sequential file size on completion of direct IO writes.
 98          * Serialization of mmap read IOs with     72          * Serialization of mmap read IOs with truncate and syscall IO
 99          * operations is done with invalidate_ !!  73          * operations is done with i_mmap_sem in addition to i_truncate_mutex.
100          * i_truncate_mutex.  Only zonefs_seq_ !!  74          * Only zonefs_seq_file_truncate() takes both lock (i_mmap_sem first,
101          * (invalidate_lock first, i_truncate_ !!  75          * i_truncate_mutex second).
102          */                                        76          */
103         struct mutex            i_truncate_mut     77         struct mutex            i_truncate_mutex;
                                                   >>  78         struct rw_semaphore     i_mmap_sem;
104                                                    79 
105         /* guarded by i_truncate_mutex */          80         /* guarded by i_truncate_mutex */
106         unsigned int            i_wr_refcnt;       81         unsigned int            i_wr_refcnt;
                                                   >>  82         unsigned int            i_flags;
107 };                                                 83 };
108                                                    84 
109 static inline struct zonefs_inode_info *ZONEFS     85 static inline struct zonefs_inode_info *ZONEFS_I(struct inode *inode)
110 {                                                  86 {
111         return container_of(inode, struct zone     87         return container_of(inode, struct zonefs_inode_info, i_vnode);
112 }                                                  88 }
113                                                    89 
114 static inline bool zonefs_zone_is_cnv(struct z << 
115 {                                              << 
116         return z->z_flags & ZONEFS_ZONE_CNV;   << 
117 }                                              << 
118                                                << 
119 static inline bool zonefs_zone_is_seq(struct z << 
120 {                                              << 
121         return !zonefs_zone_is_cnv(z);         << 
122 }                                              << 
123                                                << 
124 static inline struct zonefs_zone *zonefs_inode << 
125 {                                              << 
126         return inode->i_private;               << 
127 }                                              << 
128                                                << 
129 static inline bool zonefs_inode_is_cnv(struct  << 
130 {                                              << 
131         return zonefs_zone_is_cnv(zonefs_inode << 
132 }                                              << 
133                                                << 
134 static inline bool zonefs_inode_is_seq(struct  << 
135 {                                              << 
136         return zonefs_zone_is_seq(zonefs_inode << 
137 }                                              << 
138                                                << 
139 /*                                                 90 /*
140  * On-disk super block (block 0).                  91  * On-disk super block (block 0).
141  */                                                92  */
142 #define ZONEFS_LABEL_LEN        64                 93 #define ZONEFS_LABEL_LEN        64
143 #define ZONEFS_UUID_SIZE        16                 94 #define ZONEFS_UUID_SIZE        16
144 #define ZONEFS_SUPER_SIZE       4096               95 #define ZONEFS_SUPER_SIZE       4096
145                                                    96 
146 struct zonefs_super {                              97 struct zonefs_super {
147                                                    98 
148         /* Magic number */                         99         /* Magic number */
149         __le32          s_magic;                  100         __le32          s_magic;
150                                                   101 
151         /* Checksum */                            102         /* Checksum */
152         __le32          s_crc;                    103         __le32          s_crc;
153                                                   104 
154         /* Volume label */                        105         /* Volume label */
155         char            s_label[ZONEFS_LABEL_L    106         char            s_label[ZONEFS_LABEL_LEN];
156                                                   107 
157         /* 128-bit uuid */                        108         /* 128-bit uuid */
158         __u8            s_uuid[ZONEFS_UUID_SIZ    109         __u8            s_uuid[ZONEFS_UUID_SIZE];
159                                                   110 
160         /* Features */                            111         /* Features */
161         __le64          s_features;               112         __le64          s_features;
162                                                   113 
163         /* UID/GID to use for files */            114         /* UID/GID to use for files */
164         __le32          s_uid;                    115         __le32          s_uid;
165         __le32          s_gid;                    116         __le32          s_gid;
166                                                   117 
167         /* File permissions */                    118         /* File permissions */
168         __le32          s_perm;                   119         __le32          s_perm;
169                                                   120 
170         /* Padding to ZONEFS_SUPER_SIZE bytes     121         /* Padding to ZONEFS_SUPER_SIZE bytes */
171         __u8            s_reserved[3988];         122         __u8            s_reserved[3988];
172                                                   123 
173 } __packed;                                       124 } __packed;
174                                                   125 
175 /*                                                126 /*
176  * Feature flags: specified in the s_features     127  * Feature flags: specified in the s_features field of the on-disk super
177  * block struct zonefs_super and in-memory in     128  * block struct zonefs_super and in-memory in the s_feartures field of
178  * struct zonefs_sb_info.                         129  * struct zonefs_sb_info.
179  */                                               130  */
180 enum zonefs_features {                            131 enum zonefs_features {
181         /*                                        132         /*
182          * Aggregate contiguous conventional z    133          * Aggregate contiguous conventional zones into a single file.
183          */                                       134          */
184         ZONEFS_F_AGGRCNV = 1ULL << 0,             135         ZONEFS_F_AGGRCNV = 1ULL << 0,
185         /*                                        136         /*
186          * Use super block specified UID for f    137          * Use super block specified UID for files instead of default 0.
187          */                                       138          */
188         ZONEFS_F_UID = 1ULL << 1,                 139         ZONEFS_F_UID = 1ULL << 1,
189         /*                                        140         /*
190          * Use super block specified GID for f    141          * Use super block specified GID for files instead of default 0.
191          */                                       142          */
192         ZONEFS_F_GID = 1ULL << 2,                 143         ZONEFS_F_GID = 1ULL << 2,
193         /*                                        144         /*
194          * Use super block specified file perm    145          * Use super block specified file permissions instead of default 640.
195          */                                       146          */
196         ZONEFS_F_PERM = 1ULL << 3,                147         ZONEFS_F_PERM = 1ULL << 3,
197 };                                                148 };
198                                                   149 
199 #define ZONEFS_F_DEFINED_FEATURES \               150 #define ZONEFS_F_DEFINED_FEATURES \
200         (ZONEFS_F_AGGRCNV | ZONEFS_F_UID | ZON    151         (ZONEFS_F_AGGRCNV | ZONEFS_F_UID | ZONEFS_F_GID | ZONEFS_F_PERM)
201                                                   152 
202 /*                                                153 /*
203  * Mount options for zone write pointer error     154  * Mount options for zone write pointer error handling.
204  */                                               155  */
205 #define ZONEFS_MNTOPT_ERRORS_RO         (1 <<     156 #define ZONEFS_MNTOPT_ERRORS_RO         (1 << 0) /* Make zone file readonly */
206 #define ZONEFS_MNTOPT_ERRORS_ZRO        (1 <<     157 #define ZONEFS_MNTOPT_ERRORS_ZRO        (1 << 1) /* Make zone file offline */
207 #define ZONEFS_MNTOPT_ERRORS_ZOL        (1 <<     158 #define ZONEFS_MNTOPT_ERRORS_ZOL        (1 << 2) /* Make zone file offline */
208 #define ZONEFS_MNTOPT_ERRORS_REPAIR     (1 <<     159 #define ZONEFS_MNTOPT_ERRORS_REPAIR     (1 << 3) /* Remount read-only */
209 #define ZONEFS_MNTOPT_ERRORS_MASK       \         160 #define ZONEFS_MNTOPT_ERRORS_MASK       \
210         (ZONEFS_MNTOPT_ERRORS_RO | ZONEFS_MNTO    161         (ZONEFS_MNTOPT_ERRORS_RO | ZONEFS_MNTOPT_ERRORS_ZRO | \
211          ZONEFS_MNTOPT_ERRORS_ZOL | ZONEFS_MNT    162          ZONEFS_MNTOPT_ERRORS_ZOL | ZONEFS_MNTOPT_ERRORS_REPAIR)
212 #define ZONEFS_MNTOPT_EXPLICIT_OPEN     (1 <<     163 #define ZONEFS_MNTOPT_EXPLICIT_OPEN     (1 << 4) /* Explicit open/close of zones on open/close */
213                                                   164 
214 /*                                                165 /*
215  * In-memory Super block information.             166  * In-memory Super block information.
216  */                                               167  */
217 struct zonefs_sb_info {                           168 struct zonefs_sb_info {
218                                                   169 
219         unsigned long           s_mount_opts;     170         unsigned long           s_mount_opts;
220                                                   171 
221         spinlock_t              s_lock;           172         spinlock_t              s_lock;
222                                                   173 
223         unsigned long long      s_features;       174         unsigned long long      s_features;
224         kuid_t                  s_uid;            175         kuid_t                  s_uid;
225         kgid_t                  s_gid;            176         kgid_t                  s_gid;
226         umode_t                 s_perm;           177         umode_t                 s_perm;
227         uuid_t                  s_uuid;           178         uuid_t                  s_uuid;
228         unsigned int            s_zone_sectors    179         unsigned int            s_zone_sectors_shift;
229                                                   180 
230         struct zonefs_zone_group s_zgroup[ZONE !! 181         unsigned int            s_nr_files[ZONEFS_ZTYPE_MAX];
231                                                   182 
232         loff_t                  s_blocks;         183         loff_t                  s_blocks;
233         loff_t                  s_used_blocks;    184         loff_t                  s_used_blocks;
234                                                   185 
235         unsigned int            s_max_wro_seq_ !! 186         unsigned int            s_max_open_zones;
236         atomic_t                s_wro_seq_file !! 187         atomic_t                s_open_zones;
237                                                << 
238         unsigned int            s_max_active_s << 
239         atomic_t                s_active_seq_f << 
240                                                << 
241         bool                    s_sysfs_regist << 
242         struct kobject          s_kobj;        << 
243         struct completion       s_kobj_unregis << 
244 };                                                188 };
245                                                   189 
246 static inline struct zonefs_sb_info *ZONEFS_SB    190 static inline struct zonefs_sb_info *ZONEFS_SB(struct super_block *sb)
247 {                                                 191 {
248         return sb->s_fs_info;                     192         return sb->s_fs_info;
249 }                                                 193 }
250                                                   194 
251 #define zonefs_info(sb, format, args...)          195 #define zonefs_info(sb, format, args...)        \
252         pr_info("zonefs (%s): " format, sb->s_    196         pr_info("zonefs (%s): " format, sb->s_id, ## args)
253 #define zonefs_err(sb, format, args...)           197 #define zonefs_err(sb, format, args...)         \
254         pr_err("zonefs (%s) ERROR: " format, s    198         pr_err("zonefs (%s) ERROR: " format, sb->s_id, ## args)
255 #define zonefs_warn(sb, format, args...)          199 #define zonefs_warn(sb, format, args...)        \
256         pr_warn("zonefs (%s) WARNING: " format    200         pr_warn("zonefs (%s) WARNING: " format, sb->s_id, ## args)
257                                                << 
258 /* In super.c */                               << 
259 void zonefs_inode_account_active(struct inode  << 
260 int zonefs_inode_zone_mgmt(struct inode *inode << 
261 void zonefs_i_size_write(struct inode *inode,  << 
262 void zonefs_update_stats(struct inode *inode,  << 
263 void __zonefs_io_error(struct inode *inode, bo << 
264                                                << 
265 static inline void zonefs_io_error(struct inod << 
266 {                                              << 
267         struct zonefs_inode_info *zi = ZONEFS_ << 
268                                                << 
269         mutex_lock(&zi->i_truncate_mutex);     << 
270         __zonefs_io_error(inode, write);       << 
271         mutex_unlock(&zi->i_truncate_mutex);   << 
272 }                                              << 
273                                                << 
274 /* In super.c */                               << 
275 extern const struct inode_operations zonefs_di << 
276 extern const struct file_operations zonefs_dir << 
277                                                << 
278 /* In file.c */                                << 
279 extern const struct address_space_operations z << 
280 extern const struct file_operations zonefs_fil << 
281 int zonefs_file_truncate(struct inode *inode,  << 
282                                                << 
283 /* In sysfs.c */                               << 
284 int zonefs_sysfs_register(struct super_block * << 
285 void zonefs_sysfs_unregister(struct super_bloc << 
286 int zonefs_sysfs_init(void);                   << 
287 void zonefs_sysfs_exit(void);                  << 
288                                                   201 
289 #endif                                            202 #endif
290                                                   203 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php