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

TOMOYO Linux Cross Reference
Linux/fs/ext4/ext4_extents.h

Version: ~ [ linux-6.12-rc7 ] ~ [ linux-6.11.7 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.60 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.116 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.171 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.229 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.285 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.323 ] ~ [ 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.12 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

Diff markup

Differences between /fs/ext4/ext4_extents.h (Version linux-6.12-rc7) and /fs/ext4/ext4_extents.h (Version policy-sample)


  1 // SPDX-License-Identifier: GPL-2.0                 1 
  2 /*                                                
  3  * Copyright (c) 2003-2006, Cluster File Syste    
  4  * Written by Alex Tomas <alex@clusterfs.com>     
  5  */                                               
  6                                                   
  7 #ifndef _EXT4_EXTENTS                             
  8 #define _EXT4_EXTENTS                             
  9                                                   
 10 #include "ext4.h"                                 
 11                                                   
 12 /*                                                
 13  * With AGGRESSIVE_TEST defined, the capacity     
 14  * becomes very small, so index split, in-dept    
 15  * other hard changes happen much more often.     
 16  * This is for debug purposes only.               
 17  */                                               
 18 #define AGGRESSIVE_TEST_                          
 19                                                   
 20 /*                                                
 21  * With EXTENTS_STATS defined, the number of b    
 22  * are collected in the truncate path. They'll    
 23  * umount time.                                   
 24  */                                               
 25 #define EXTENTS_STATS__                           
 26                                                   
 27 /*                                                
 28  * If CHECK_BINSEARCH is defined, then the res    
 29  * will also be checked by linear search.         
 30  */                                               
 31 #define CHECK_BINSEARCH__                         
 32                                                   
 33 /*                                                
 34  * If EXT_STATS is defined then stats numbers     
 35  * These number will be displayed at umount ti    
 36  */                                               
 37 #define EXT_STATS_                                
 38                                                   
 39                                                   
 40 /*                                                
 41  * ext4_inode has i_block array (60 bytes tota    
 42  * The first 12 bytes store ext4_extent_header    
 43  * the remainder stores an array of ext4_exten    
 44  * For non-inode extent blocks, ext4_extent_ta    
 45  * follows the array.                             
 46  */                                               
 47                                                   
 48 /*                                                
 49  * This is the extent tail on-disk structure.     
 50  * All other extent structures are 12 bytes lo    
 51  * block_size % 12 >= 4 for at least all power    
 52  * covers all valid ext4 block sizes.  Therefo    
 53  * crammed into the end of the block without h    
 54  */                                               
 55 struct ext4_extent_tail {                         
 56         __le32  et_checksum;    /* crc32c(uuid    
 57 };                                                
 58                                                   
 59 /*                                                
 60  * This is the extent on-disk structure.          
 61  * It's used at the bottom of the tree.           
 62  */                                               
 63 struct ext4_extent {                              
 64         __le32  ee_block;       /* first logic    
 65         __le16  ee_len;         /* number of b    
 66         __le16  ee_start_hi;    /* high 16 bit    
 67         __le32  ee_start_lo;    /* low 32 bits    
 68 };                                                
 69                                                   
 70 /*                                                
 71  * This is index on-disk structure.               
 72  * It's used at all the levels except the bott    
 73  */                                               
 74 struct ext4_extent_idx {                          
 75         __le32  ei_block;       /* index cover    
 76         __le32  ei_leaf_lo;     /* pointer to     
 77                                  * level. leaf    
 78         __le16  ei_leaf_hi;     /* high 16 bit    
 79         __u16   ei_unused;                        
 80 };                                                
 81                                                   
 82 /*                                                
 83  * Each block (leaves and indexes), even inode    
 84  */                                               
 85 struct ext4_extent_header {                       
 86         __le16  eh_magic;       /* probably wi    
 87         __le16  eh_entries;     /* number of v    
 88         __le16  eh_max;         /* capacity of    
 89         __le16  eh_depth;       /* has tree re    
 90         __le32  eh_generation;  /* generation     
 91 };                                                
 92                                                   
 93 #define EXT4_EXT_MAGIC          cpu_to_le16(0x    
 94 #define EXT4_MAX_EXTENT_DEPTH 5                   
 95                                                   
 96 #define EXT4_EXTENT_TAIL_OFFSET(hdr) \            
 97         (sizeof(struct ext4_extent_header) + \    
 98          (sizeof(struct ext4_extent) * le16_to    
 99                                                   
100 static inline struct ext4_extent_tail *           
101 find_ext4_extent_tail(struct ext4_extent_heade    
102 {                                                 
103         return (struct ext4_extent_tail *)(((v    
104                                            EXT    
105 }                                                 
106                                                   
107 /*                                                
108  * Array of ext4_ext_path contains path to som    
109  * Creation/lookup routines use it for travers    
110  * Truncate uses it to simulate recursive walk    
111  */                                               
112 struct ext4_ext_path {                            
113         ext4_fsblk_t                    p_bloc    
114         __u16                           p_dept    
115         __u16                           p_maxd    
116         struct ext4_extent              *p_ext    
117         struct ext4_extent_idx          *p_idx    
118         struct ext4_extent_header       *p_hdr    
119         struct buffer_head              *p_bh;    
120 };                                                
121                                                   
122 /*                                                
123  * Used to record a portion of a cluster found    
124  * of an extent while traversing the extent tr    
125  * A partial cluster may be removed if it does    
126  * with extents that aren't being deleted (tof    
127  * it cannot be removed (nofree state).           
128  */                                               
129 struct partial_cluster {                          
130         ext4_fsblk_t pclu;  /* physical cluste    
131         ext4_lblk_t lblk;   /* logical block n    
132         enum {initial, tofree, nofree} state;     
133 };                                                
134                                                   
135 /*                                                
136  * structure for external API                     
137  */                                               
138                                                   
139 /*                                                
140  * EXT_INIT_MAX_LEN is the maximum number of b    
141  * initialized extent. This is 2^15 and not (2    
142  * MSB of ee_len field in the extent datastruc    
143  * particular extent is an initialized extent     
144  * preallocated).                                 
145  * EXT_UNWRITTEN_MAX_LEN is the maximum number    
146  * unwritten extent.                              
147  * If ee_len is <= 0x8000, it is an initialize    
148  * unwritten one. In other words, if MSB of ee    
149  * unwritten extent with only one special scen    
150  * In this case we can not have an unwritten e    
151  * thus we make it as a special case of initia    
152  * This way we get better extent-to-group alig    
153  * Hence, the maximum number of blocks we can     
154  * extent is 2^15 (32768) and in an *unwritten    
155  */                                               
156 #define EXT_INIT_MAX_LEN        (1UL << 15)       
157 #define EXT_UNWRITTEN_MAX_LEN   (EXT_INIT_MAX_    
158                                                   
159                                                   
160 #define EXT_FIRST_EXTENT(__hdr__) \               
161         ((struct ext4_extent *) (((char *) (__    
162                                  sizeof(struct    
163 #define EXT_FIRST_INDEX(__hdr__) \                
164         ((struct ext4_extent_idx *) (((char *)    
165                                      sizeof(st    
166 #define EXT_HAS_FREE_INDEX(__path__) \            
167         (le16_to_cpu((__path__)->p_hdr->eh_ent    
168                                      < le16_to    
169 #define EXT_LAST_EXTENT(__hdr__) \                
170         (EXT_FIRST_EXTENT((__hdr__)) + le16_to    
171 #define EXT_LAST_INDEX(__hdr__) \                 
172         (EXT_FIRST_INDEX((__hdr__)) + le16_to_    
173 #define EXT_MAX_EXTENT(__hdr__) \                 
174         ((le16_to_cpu((__hdr__)->eh_max)) ? \     
175         ((EXT_FIRST_EXTENT((__hdr__)) + le16_t    
176                                         : NULL    
177 #define EXT_MAX_INDEX(__hdr__) \                  
178         ((le16_to_cpu((__hdr__)->eh_max)) ? \     
179         ((EXT_FIRST_INDEX((__hdr__)) + le16_to    
180                                         : NULL    
181                                                   
182 static inline struct ext4_extent_header *ext_i    
183 {                                                 
184         return (struct ext4_extent_header *) E    
185 }                                                 
186                                                   
187 static inline struct ext4_extent_header *ext_b    
188 {                                                 
189         return (struct ext4_extent_header *) b    
190 }                                                 
191                                                   
192 static inline unsigned short ext_depth(struct     
193 {                                                 
194         return le16_to_cpu(ext_inode_hdr(inode    
195 }                                                 
196                                                   
197 static inline void ext4_ext_mark_unwritten(str    
198 {                                                 
199         /* We can not have an unwritten extent    
200         BUG_ON((le16_to_cpu(ext->ee_len) & ~EX    
201         ext->ee_len |= cpu_to_le16(EXT_INIT_MA    
202 }                                                 
203                                                   
204 static inline int ext4_ext_is_unwritten(struct    
205 {                                                 
206         /* Extent with ee_len of 0x8000 is tre    
207         return (le16_to_cpu(ext->ee_len) > EXT    
208 }                                                 
209                                                   
210 static inline int ext4_ext_get_actual_len(stru    
211 {                                                 
212         return (le16_to_cpu(ext->ee_len) <= EX    
213                 le16_to_cpu(ext->ee_len) :        
214                 (le16_to_cpu(ext->ee_len) - EX    
215 }                                                 
216                                                   
217 static inline void ext4_ext_mark_initialized(s    
218 {                                                 
219         ext->ee_len = cpu_to_le16(ext4_ext_get    
220 }                                                 
221                                                   
222 /*                                                
223  * ext4_ext_pblock:                               
224  * combine low and high parts of physical bloc    
225  */                                               
226 static inline ext4_fsblk_t ext4_ext_pblock(str    
227 {                                                 
228         ext4_fsblk_t block;                       
229                                                   
230         block = le32_to_cpu(ex->ee_start_lo);     
231         block |= ((ext4_fsblk_t) le16_to_cpu(e    
232         return block;                             
233 }                                                 
234                                                   
235 /*                                                
236  * ext4_idx_pblock:                               
237  * combine low and high parts of a leaf physic    
238  */                                               
239 static inline ext4_fsblk_t ext4_idx_pblock(str    
240 {                                                 
241         ext4_fsblk_t block;                       
242                                                   
243         block = le32_to_cpu(ix->ei_leaf_lo);      
244         block |= ((ext4_fsblk_t) le16_to_cpu(i    
245         return block;                             
246 }                                                 
247                                                   
248 /*                                                
249  * ext4_ext_store_pblock:                         
250  * stores a large physical block number into a    
251  * breaking it into parts                         
252  */                                               
253 static inline void ext4_ext_store_pblock(struc    
254                                          ext4_    
255 {                                                 
256         ex->ee_start_lo = cpu_to_le32((unsigne    
257         ex->ee_start_hi = cpu_to_le16((unsigne    
258                                       0xffff);    
259 }                                                 
260                                                   
261 /*                                                
262  * ext4_idx_store_pblock:                         
263  * stores a large physical block number into a    
264  * breaking it into parts                         
265  */                                               
266 static inline void ext4_idx_store_pblock(struc    
267                                          ext4_    
268 {                                                 
269         ix->ei_leaf_lo = cpu_to_le32((unsigned    
270         ix->ei_leaf_hi = cpu_to_le16((unsigned    
271                                      0xffff);     
272 }                                                 
273                                                   
274 #endif /* _EXT4_EXTENTS */                        
275                                                   
276                                                   

~ [ 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