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

TOMOYO Linux Cross Reference
Linux/Documentation/filesystems/journalling.rst

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 /Documentation/filesystems/journalling.rst (Version linux-6.12-rc7) and /Documentation/filesystems/journalling.rst (Version linux-2.6.0)


  1 The Linux Journalling API                         
  2 =========================                         
  3                                                   
  4 Overview                                          
  5 --------                                          
  6                                                   
  7 Details                                           
  8 ~~~~~~~                                           
  9                                                   
 10 The journalling layer is easy to use. You need    
 11 journal_t data structure. There are two calls     
 12 how you decide to allocate the physical media     
 13 resides. The jbd2_journal_init_inode() call is    
 14 filesystem inodes, or the jbd2_journal_init_de    
 15 for journal stored on a raw device (in a conti    
 16 journal_t is a typedef for a struct pointer, s    
 17 finished make sure you call jbd2_journal_destr    
 18 any used kernel memory.                           
 19                                                   
 20 Once you have got your journal_t object you ne    
 21 journal file. The journalling layer expects th    
 22 was already allocated and initialized properly    
 23 When loading the journal you must call jbd2_jo    
 24 journal contents. If the client file system de    
 25 does not need to be processed (or even need no    
 26 may call jbd2_journal_wipe() to clear the jour    
 27 calling jbd2_journal_load().                      
 28                                                   
 29 Note that jbd2_journal_wipe(..,0) calls           
 30 jbd2_journal_skip_recovery() for you if it det    
 31 transactions in the journal and similarly jbd2    
 32 call jbd2_journal_recover() if necessary. I wo    
 33 ext4_load_journal() in fs/ext4/super.c for exa    
 34                                                   
 35 Now you can go ahead and start modifying the u    
 36 Almost.                                           
 37                                                   
 38 You still need to actually journal your filesy    
 39 by wrapping them into transactions. Additional    
 40 the modification of each of the buffers with c    
 41 so it knows what the modifications you are act    
 42 this use jbd2_journal_start() which returns a     
 43                                                   
 44 jbd2_journal_start() and its counterpart jbd2_    
 45 which indicates the end of a transaction are n    
 46 reenter a transaction if necessary, but rememb    
 47 jbd2_journal_stop() the same number of times a    
 48 jbd2_journal_start() before the transaction is    
 49 accurately leaves the update phase). Ext4/VFS     
 50 simplify handling of inode dirtying, quota sup    
 51                                                   
 52 Inside each transaction you need to wrap the m    
 53 individual buffers (blocks). Before you start     
 54 need to call jbd2_journal_get_create_access()     
 55 jbd2_journal_get_write_access() /                 
 56 jbd2_journal_get_undo_access() as appropriate,    
 57 journalling layer to copy the unmodified          
 58 data if it needs to. After all the buffer may     
 59 uncommitted transaction. At this point you are    
 60 buffer, and once you are have done so you need    
 61 jbd2_journal_dirty_metadata(). Or if you've as    
 62 buffer you now know is now longer required to     
 63 device you can call jbd2_journal_forget() in m    
 64 might have used bforget() in the past.            
 65                                                   
 66 A jbd2_journal_flush() may be called at any ti    
 67 checkpoint all your transactions.                 
 68                                                   
 69 Then at umount time , in your put_super() you     
 70 jbd2_journal_destroy() to clean up your in-cor    
 71                                                   
 72 Unfortunately there a couple of ways the journ    
 73 deadlock. The first thing to note is that each    
 74 single outstanding transaction at any one time    
 75 until the outermost jbd2_journal_stop(). This     
 76 the transaction at the end of each file/inode/    
 77 perform, so that the journalling system isn't     
 78 journal. Since transactions can't be nested/ba    
 79 journals, and another filesystem other than yo    
 80 modified in a later syscall.                      
 81                                                   
 82 The second case to bear in mind is that jbd2_j    
 83 if there isn't enough space in the journal for    
 84 on the passed nblocks param) - when it blocks     
 85 for transactions to complete and be committed     
 86 essentially we are waiting for jbd2_journal_st    
 87 deadlocks you must treat jbd2_journal_start()     
 88 jbd2_journal_stop() as if they were semaphores    
 89 your semaphore ordering rules to prevent          
 90 deadlocks. Note that jbd2_journal_extend() has    
 91 behaviour to jbd2_journal_start() so you can d    
 92 easily as on jbd2_journal_start().                
 93                                                   
 94 Try to reserve the right number of blocks the     
 95 be the maximum number of blocks you are going     
 96 transaction. I advise having a look at at leas    
 97 basis on which ext4 uses to make these decisio    
 98                                                   
 99 Another wriggle to watch out for is your on-di    
100 strategy. Why? Because, if you do a delete, yo    
101 haven't reused any of the freed blocks until t    
102 these blocks commits. If you reused these bloc    
103 there is no way to restore the contents of the    
104 end of the last fully committed transaction. O    
105 this is to mark blocks as free in internal in-    
106 structures only after the transaction freeing     
107 journal commit callback for this purpose.         
108                                                   
109 With journal commit callbacks you can ask the     
110 a callback function when the transaction is fi    
111 so that you can do some of your own management    
112 layer for calling the callback by simply setti    
113 ``journal->j_commit_callback`` function pointe    
114 called after each transaction commit. You can     
115 ``transaction->t_private_list`` for attaching     
116 that need processing when the transaction comm    
117                                                   
118 JBD2 also provides a way to block all transact    
119 jbd2_journal_lock_updates() /                     
120 jbd2_journal_unlock_updates(). Ext4 uses this     
121 window with a clean and stable fs for a moment    
122                                                   
123 ::                                                
124                                                   
125                                                   
126         jbd2_journal_lock_updates() //stop new    
127         jbd2_journal_flush()        // checkpo    
128         ..do stuff on stable fs                   
129         jbd2_journal_unlock_updates() // carry    
130                                                   
131 The opportunities for abuse and DOS attacks wi    
132 if you allow unprivileged userspace to trigger    
133 these calls.                                      
134                                                   
135 Fast commits                                      
136 ~~~~~~~~~~~~                                      
137                                                   
138 JBD2 to also allows you to perform file-system    
139 fast commits. In order to use fast commits, yo    
140 callbacks that perform corresponding work:        
141                                                   
142 `journal->j_fc_cleanup_cb`: Cleanup function c    
143 fast commit.                                      
144                                                   
145 `journal->j_fc_replay_cb`: Replay function cal    
146 blocks.                                           
147                                                   
148 File system is free to perform fast commits as    
149 gets permission from JBD2 to do so by calling     
150 :c:func:`jbd2_fc_begin_commit()`. Once a fast     
151 file  system should tell JBD2 about it by call    
152 :c:func:`jbd2_fc_end_commit()`. If the file sy    
153 commit immediately after stopping the fast com    
154 :c:func:`jbd2_fc_end_commit_fallback()`. This     
155 fails for some reason and the only way to guar    
156 perform the full traditional commit.              
157                                                   
158 JBD2 helper functions to manage fast commit bu    
159 :c:func:`jbd2_fc_get_buf()` and :c:func:`jbd2_    
160 and wait on IO completion of fast commit buffe    
161                                                   
162 Currently, only Ext4 implements fast commits.     
163 of fast commits, please refer to the top level    
164 fs/ext4/fast_commit.c.                            
165                                                   
166 Summary                                           
167 ~~~~~~~                                           
168                                                   
169 Using the journal is a matter of wrapping the     
170 being each mount, each modification (transacti    
171 buffer to tell the journalling layer about the    
172                                                   
173 Data Types                                        
174 ----------                                        
175                                                   
176 The journalling layer uses typedefs to 'hide'     
177 of the structures used. As a client of the JBD    
178 on the using the pointer as a magic cookie of     
179 hiding is not enforced as this is 'C'.            
180                                                   
181 Structures                                        
182 ~~~~~~~~~~                                        
183                                                   
184 .. kernel-doc:: include/linux/jbd2.h              
185    :internal:                                     
186                                                   
187 Functions                                         
188 ---------                                         
189                                                   
190 The functions here are split into two groups t    
191 as a whole, and those which are used to manage    
192                                                   
193 Journal Level                                     
194 ~~~~~~~~~~~~~                                     
195                                                   
196 .. kernel-doc:: fs/jbd2/journal.c                 
197    :export:                                       
198                                                   
199 .. kernel-doc:: fs/jbd2/recovery.c                
200    :internal:                                     
201                                                   
202 Transaction Level                                 
203 ~~~~~~~~~~~~~~~~~~                                
204                                                   
205 .. kernel-doc:: fs/jbd2/transaction.c             
206                                                   
207 See also                                          
208 --------                                          
209                                                   
210 `Journaling the Linux ext2fs Filesystem, Linux    
211 Tweedie <http://kernel.org/pub/linux/kernel/pe    
212                                                   
213 `Ext3 Journalling FileSystem, OLS 2000, Dr. St    
214 Tweedie <http://olstrans.sourceforge.net/relea    
215                                                   
                                                      

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