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

TOMOYO Linux Cross Reference
Linux/fs/ceph/io.c

Version: ~ [ linux-6.11.5 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.58 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.114 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.169 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.228 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.284 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.322 ] ~ [ 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/ceph/io.c (Version linux-6.11.5) and /fs/ceph/io.c (Version linux-4.19.322)


  1 // SPDX-License-Identifier: GPL-2.0                 1 
  2 /*                                                
  3  * Copyright (c) 2016 Trond Myklebust             
  4  * Copyright (c) 2019 Jeff Layton                 
  5  *                                                
  6  * I/O and data path helper functionality.        
  7  *                                                
  8  * Heavily borrowed from equivalent code in fs    
  9  */                                               
 10                                                   
 11 #include <linux/ceph/ceph_debug.h>                
 12                                                   
 13 #include <linux/types.h>                          
 14 #include <linux/kernel.h>                         
 15 #include <linux/rwsem.h>                          
 16 #include <linux/fs.h>                             
 17                                                   
 18 #include "super.h"                                
 19 #include "io.h"                                   
 20                                                   
 21 /* Call with exclusively locked inode->i_rwsem    
 22 static void ceph_block_o_direct(struct ceph_in    
 23 {                                                 
 24         lockdep_assert_held_write(&inode->i_rw    
 25                                                   
 26         if (READ_ONCE(ci->i_ceph_flags) & CEPH    
 27                 spin_lock(&ci->i_ceph_lock);      
 28                 ci->i_ceph_flags &= ~CEPH_I_OD    
 29                 spin_unlock(&ci->i_ceph_lock);    
 30                 inode_dio_wait(inode);            
 31         }                                         
 32 }                                                 
 33                                                   
 34 /**                                               
 35  * ceph_start_io_read - declare the file is be    
 36  * @inode: file inode                             
 37  *                                                
 38  * Declare that a buffered read operation is a    
 39  * that we block all direct I/O.                  
 40  * On exit, the function ensures that the CEPH    
 41  * and holds a shared lock on inode->i_rwsem t    
 42  * cannot be changed.                             
 43  * In practice, this means that buffered read     
 44  * execute in parallel, thanks to the shared l    
 45  * operations need to wait to grab an exclusiv    
 46  * CEPH_I_ODIRECT.                                
 47  * Note that buffered writes and truncates bot    
 48  * inode->i_rwsem, meaning that those are seri    
 49  */                                               
 50 void                                              
 51 ceph_start_io_read(struct inode *inode)           
 52 {                                                 
 53         struct ceph_inode_info *ci = ceph_inod    
 54                                                   
 55         /* Be an optimist! */                     
 56         down_read(&inode->i_rwsem);               
 57         if (!(READ_ONCE(ci->i_ceph_flags) & CE    
 58                 return;                           
 59         up_read(&inode->i_rwsem);                 
 60         /* Slow path.... */                       
 61         down_write(&inode->i_rwsem);              
 62         ceph_block_o_direct(ci, inode);           
 63         downgrade_write(&inode->i_rwsem);         
 64 }                                                 
 65                                                   
 66 /**                                               
 67  * ceph_end_io_read - declare that the buffere    
 68  * @inode: file inode                             
 69  *                                                
 70  * Declare that a buffered read operation is d    
 71  * lock on inode->i_rwsem.                        
 72  */                                               
 73 void                                              
 74 ceph_end_io_read(struct inode *inode)             
 75 {                                                 
 76         up_read(&inode->i_rwsem);                 
 77 }                                                 
 78                                                   
 79 /**                                               
 80  * ceph_start_io_write - declare the file is b    
 81  * @inode: file inode                             
 82  *                                                
 83  * Declare that a buffered write operation is     
 84  * that we block all direct I/O.                  
 85  */                                               
 86 void                                              
 87 ceph_start_io_write(struct inode *inode)          
 88 {                                                 
 89         down_write(&inode->i_rwsem);              
 90         ceph_block_o_direct(ceph_inode(inode),    
 91 }                                                 
 92                                                   
 93 /**                                               
 94  * ceph_end_io_write - declare that the buffer    
 95  * @inode: file inode                             
 96  *                                                
 97  * Declare that a buffered write operation is     
 98  * lock on inode->i_rwsem.                        
 99  */                                               
100 void                                              
101 ceph_end_io_write(struct inode *inode)            
102 {                                                 
103         up_write(&inode->i_rwsem);                
104 }                                                 
105                                                   
106 /* Call with exclusively locked inode->i_rwsem    
107 static void ceph_block_buffered(struct ceph_in    
108 {                                                 
109         lockdep_assert_held_write(&inode->i_rw    
110                                                   
111         if (!(READ_ONCE(ci->i_ceph_flags) & CE    
112                 spin_lock(&ci->i_ceph_lock);      
113                 ci->i_ceph_flags |= CEPH_I_ODI    
114                 spin_unlock(&ci->i_ceph_lock);    
115                 /* FIXME: unmap_mapping_range?    
116                 filemap_write_and_wait(inode->    
117         }                                         
118 }                                                 
119                                                   
120 /**                                               
121  * ceph_start_io_direct - declare the file is     
122  * @inode: file inode                             
123  *                                                
124  * Declare that a direct I/O operation is abou    
125  * that we block all buffered I/O.                
126  * On exit, the function ensures that the CEPH    
127  * and holds a shared lock on inode->i_rwsem t    
128  * cannot be changed.                             
129  * In practice, this means that direct I/O ope    
130  * execute in parallel, thanks to the shared l    
131  * operations need to wait to grab an exclusiv    
132  * CEPH_I_ODIRECT.                                
133  * Note that buffered writes and truncates bot    
134  * inode->i_rwsem, meaning that those are seri    
135  */                                               
136 void                                              
137 ceph_start_io_direct(struct inode *inode)         
138 {                                                 
139         struct ceph_inode_info *ci = ceph_inod    
140                                                   
141         /* Be an optimist! */                     
142         down_read(&inode->i_rwsem);               
143         if (READ_ONCE(ci->i_ceph_flags) & CEPH    
144                 return;                           
145         up_read(&inode->i_rwsem);                 
146         /* Slow path.... */                       
147         down_write(&inode->i_rwsem);              
148         ceph_block_buffered(ci, inode);           
149         downgrade_write(&inode->i_rwsem);         
150 }                                                 
151                                                   
152 /**                                               
153  * ceph_end_io_direct - declare that the direc    
154  * @inode: file inode                             
155  *                                                
156  * Declare that a direct I/O operation is done    
157  * lock on inode->i_rwsem.                        
158  */                                               
159 void                                              
160 ceph_end_io_direct(struct inode *inode)           
161 {                                                 
162         up_read(&inode->i_rwsem);                 
163 }                                                 
164                                                   

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