zonefs.h (34422914dc00b291d1c47dbdabe93b154c2f2b25) | zonefs.h (aa7f243f32e1d18036ee00d71d3ccfad70ae2121) |
---|---|
1/* SPDX-License-Identifier: GPL-2.0 */ 2/* 3 * Simple zone file system for zoned block devices. 4 * 5 * Copyright (C) 2019 Western Digital Corporation or its affiliates. 6 */ 7#ifndef __ZONEFS_H__ 8#define __ZONEFS_H__ --- 33 unchanged lines hidden (view full) --- 42#define ZONEFS_ZONE_INIT_MODE (1U << 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/* | 1/* SPDX-License-Identifier: GPL-2.0 */ 2/* 3 * Simple zone file system for zoned block devices. 4 * 5 * Copyright (C) 2019 Western Digital Corporation or its affiliates. 6 */ 7#ifndef __ZONEFS_H__ 8#define __ZONEFS_H__ --- 33 unchanged lines hidden (view full) --- 42#define ZONEFS_ZONE_INIT_MODE (1U << 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 inode data. | 50 * In-memory per-file inode zone data. |
51 */ | 51 */ |
52struct zonefs_inode_info { 53 struct inode i_vnode; | 52struct zonefs_zone { 53 /* Zone state flags */ 54 unsigned int z_flags; |
54 | 55 |
55 /* File zone start sector (512B unit) */ 56 sector_t i_zsector; | 56 /* Zone start sector (512B unit) */ 57 sector_t z_sector; |
57 | 58 |
58 /* File zone write pointer position (sequential zones only) */ 59 loff_t i_wpoffset; | 59 /* Zone size (bytes) */ 60 loff_t z_size; |
60 | 61 |
61 /* File maximum size */ 62 loff_t i_max_size; | 62 /* Zone capacity (file maximum size, bytes) */ 63 loff_t z_capacity; |
63 | 64 |
64 /* File zone size */ 65 loff_t i_zone_size; | 65 /* Write pointer offset in the zone (sequential zones only, bytes) */ 66 loff_t z_wpoffset; 67}; |
66 | 68 |
69/* 70 * In memory zone group information: all zones of a group are exposed 71 * as files, one file per zone. 72 */ 73struct zonefs_zone_group { 74 unsigned int g_nr_zones; 75 struct zonefs_zone *g_zones; 76}; 77 78/* 79 * In-memory inode data. 80 */ 81struct zonefs_inode_info { 82 struct inode i_vnode; 83 |
|
67 /* 68 * To serialise fully against both syscall and mmap based IO and 69 * sequential file truncation, two locks are used. For serializing 70 * zonefs_seq_file_truncate() against zonefs_iomap_begin(), that is, 71 * file truncate operations against block mapping, i_truncate_mutex is 72 * used. i_truncate_mutex also protects against concurrent accesses 73 * and changes to the inode private data, and in particular changes to 74 * a sequential file size on completion of direct IO writes. 75 * Serialization of mmap read IOs with truncate and syscall IO 76 * operations is done with invalidate_lock in addition to 77 * i_truncate_mutex. Only zonefs_seq_file_truncate() takes both lock 78 * (invalidate_lock first, i_truncate_mutex second). 79 */ 80 struct mutex i_truncate_mutex; 81 82 /* guarded by i_truncate_mutex */ 83 unsigned int i_wr_refcnt; | 84 /* 85 * To serialise fully against both syscall and mmap based IO and 86 * sequential file truncation, two locks are used. For serializing 87 * zonefs_seq_file_truncate() against zonefs_iomap_begin(), that is, 88 * file truncate operations against block mapping, i_truncate_mutex is 89 * used. i_truncate_mutex also protects against concurrent accesses 90 * and changes to the inode private data, and in particular changes to 91 * a sequential file size on completion of direct IO writes. 92 * Serialization of mmap read IOs with truncate and syscall IO 93 * operations is done with invalidate_lock in addition to 94 * i_truncate_mutex. Only zonefs_seq_file_truncate() takes both lock 95 * (invalidate_lock first, i_truncate_mutex second). 96 */ 97 struct mutex i_truncate_mutex; 98 99 /* guarded by i_truncate_mutex */ 100 unsigned int i_wr_refcnt; |
84 unsigned int i_flags; | |
85}; 86 87static inline struct zonefs_inode_info *ZONEFS_I(struct inode *inode) 88{ 89 return container_of(inode, struct zonefs_inode_info, i_vnode); 90} 91 | 101}; 102 103static inline struct zonefs_inode_info *ZONEFS_I(struct inode *inode) 104{ 105 return container_of(inode, struct zonefs_inode_info, i_vnode); 106} 107 |
92static inline bool zonefs_zone_is_cnv(struct zonefs_inode_info *zi) | 108static inline bool zonefs_zone_is_cnv(struct zonefs_zone *z) |
93{ | 109{ |
94 return zi->i_flags & ZONEFS_ZONE_CNV; | 110 return z->z_flags & ZONEFS_ZONE_CNV; |
95} 96 | 111} 112 |
97static inline bool zonefs_zone_is_seq(struct zonefs_inode_info *zi) | 113static inline bool zonefs_zone_is_seq(struct zonefs_zone *z) |
98{ | 114{ |
99 return !zonefs_zone_is_cnv(zi); | 115 return !zonefs_zone_is_cnv(z); |
100} 101 | 116} 117 |
118static inline struct zonefs_zone *zonefs_inode_zone(struct inode *inode) 119{ 120 return inode->i_private; 121} 122 |
|
102static inline bool zonefs_inode_is_cnv(struct inode *inode) 103{ | 123static inline bool zonefs_inode_is_cnv(struct inode *inode) 124{ |
104 return zonefs_zone_is_cnv(ZONEFS_I(inode)); | 125 return zonefs_zone_is_cnv(zonefs_inode_zone(inode)); |
105} 106 107static inline bool zonefs_inode_is_seq(struct inode *inode) 108{ | 126} 127 128static inline bool zonefs_inode_is_seq(struct inode *inode) 129{ |
109 return zonefs_zone_is_seq(ZONEFS_I(inode)); | 130 return zonefs_zone_is_seq(zonefs_inode_zone(inode)); |
110} 111 112/* 113 * On-disk super block (block 0). 114 */ 115#define ZONEFS_LABEL_LEN 64 116#define ZONEFS_UUID_SIZE 16 117#define ZONEFS_SUPER_SIZE 4096 --- 77 unchanged lines hidden (view full) --- 195 196 unsigned long long s_features; 197 kuid_t s_uid; 198 kgid_t s_gid; 199 umode_t s_perm; 200 uuid_t s_uuid; 201 unsigned int s_zone_sectors_shift; 202 | 131} 132 133/* 134 * On-disk super block (block 0). 135 */ 136#define ZONEFS_LABEL_LEN 64 137#define ZONEFS_UUID_SIZE 16 138#define ZONEFS_SUPER_SIZE 4096 --- 77 unchanged lines hidden (view full) --- 216 217 unsigned long long s_features; 218 kuid_t s_uid; 219 kgid_t s_gid; 220 umode_t s_perm; 221 uuid_t s_uuid; 222 unsigned int s_zone_sectors_shift; 223 |
203 unsigned int s_nr_files[ZONEFS_ZTYPE_MAX]; | 224 struct zonefs_zone_group s_zgroup[ZONEFS_ZTYPE_MAX]; |
204 205 loff_t s_blocks; 206 loff_t s_used_blocks; 207 208 unsigned int s_max_wro_seq_files; 209 atomic_t s_wro_seq_files; 210 211 unsigned int s_max_active_seq_files; --- 12 unchanged lines hidden (view full) --- 224#define zonefs_info(sb, format, args...) \ 225 pr_info("zonefs (%s): " format, sb->s_id, ## args) 226#define zonefs_err(sb, format, args...) \ 227 pr_err("zonefs (%s) ERROR: " format, sb->s_id, ## args) 228#define zonefs_warn(sb, format, args...) \ 229 pr_warn("zonefs (%s) WARNING: " format, sb->s_id, ## args) 230 231/* In super.c */ | 225 226 loff_t s_blocks; 227 loff_t s_used_blocks; 228 229 unsigned int s_max_wro_seq_files; 230 atomic_t s_wro_seq_files; 231 232 unsigned int s_max_active_seq_files; --- 12 unchanged lines hidden (view full) --- 245#define zonefs_info(sb, format, args...) \ 246 pr_info("zonefs (%s): " format, sb->s_id, ## args) 247#define zonefs_err(sb, format, args...) \ 248 pr_err("zonefs (%s) ERROR: " format, sb->s_id, ## args) 249#define zonefs_warn(sb, format, args...) \ 250 pr_warn("zonefs (%s) WARNING: " format, sb->s_id, ## args) 251 252/* In super.c */ |
232void zonefs_account_active(struct inode *inode); 233int zonefs_zone_mgmt(struct inode *inode, enum req_op op); | 253void zonefs_inode_account_active(struct inode *inode); 254int zonefs_inode_zone_mgmt(struct inode *inode, enum req_op op); |
234void zonefs_i_size_write(struct inode *inode, loff_t isize); 235void zonefs_update_stats(struct inode *inode, loff_t new_isize); 236void __zonefs_io_error(struct inode *inode, bool write); 237 238static inline void zonefs_io_error(struct inode *inode, bool write) 239{ 240 struct zonefs_inode_info *zi = ZONEFS_I(inode); 241 --- 17 unchanged lines hidden --- | 255void zonefs_i_size_write(struct inode *inode, loff_t isize); 256void zonefs_update_stats(struct inode *inode, loff_t new_isize); 257void __zonefs_io_error(struct inode *inode, bool write); 258 259static inline void zonefs_io_error(struct inode *inode, bool write) 260{ 261 struct zonefs_inode_info *zi = ZONEFS_I(inode); 262 --- 17 unchanged lines hidden --- |