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

TOMOYO Linux Cross Reference
Linux/include/linux/netfs.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 /include/linux/netfs.h (Version linux-6.12-rc7) and /include/linux/netfs.h (Version linux-4.10.17)


  1 /* SPDX-License-Identifier: GPL-2.0-or-later *      1 
  2 /* Network filesystem support services.           
  3  *                                                
  4  * Copyright (C) 2021 Red Hat, Inc. All Rights    
  5  * Written by David Howells (dhowells@redhat.c    
  6  *                                                
  7  * See:                                           
  8  *                                                
  9  *      Documentation/filesystems/netfs_librar    
 10  *                                                
 11  * for a description of the network filesystem    
 12  */                                               
 13                                                   
 14 #ifndef _LINUX_NETFS_H                            
 15 #define _LINUX_NETFS_H                            
 16                                                   
 17 #include <linux/workqueue.h>                      
 18 #include <linux/fs.h>                             
 19 #include <linux/pagemap.h>                        
 20 #include <linux/uio.h>                            
 21                                                   
 22 enum netfs_sreq_ref_trace;                        
 23 typedef struct mempool_s mempool_t;               
 24                                                   
 25 /**                                               
 26  * folio_start_private_2 - Start an fscache wr    
 27  * @folio: The folio.                             
 28  *                                                
 29  * Call this function before writing a folio t    
 30  * second write before the first one finishes     
 31  *                                                
 32  * Note that this should no longer be used.       
 33  */                                               
 34 static inline void folio_start_private_2(struc    
 35 {                                                 
 36         VM_BUG_ON_FOLIO(folio_test_private_2(f    
 37         folio_get(folio);                         
 38         folio_set_private_2(folio);               
 39 }                                                 
 40                                                   
 41 enum netfs_io_source {                            
 42         NETFS_SOURCE_UNKNOWN,                     
 43         NETFS_FILL_WITH_ZEROES,                   
 44         NETFS_DOWNLOAD_FROM_SERVER,               
 45         NETFS_READ_FROM_CACHE,                    
 46         NETFS_INVALID_READ,                       
 47         NETFS_UPLOAD_TO_SERVER,                   
 48         NETFS_WRITE_TO_CACHE,                     
 49         NETFS_INVALID_WRITE,                      
 50 } __mode(byte);                                   
 51                                                   
 52 typedef void (*netfs_io_terminated_t)(void *pr    
 53                                       bool was    
 54                                                   
 55 /*                                                
 56  * Per-inode context.  This wraps the VFS inod    
 57  */                                               
 58 struct netfs_inode {                              
 59         struct inode            inode;            
 60         const struct netfs_request_ops *ops;      
 61 #if IS_ENABLED(CONFIG_FSCACHE)                    
 62         struct fscache_cookie   *cache;           
 63 #endif                                            
 64         struct mutex            wb_lock;          
 65         loff_t                  remote_i_size;    
 66         loff_t                  zero_point;       
 67                                                   
 68         atomic_t                io_count;         
 69         unsigned long           flags;            
 70 #define NETFS_ICTX_ODIRECT      0                 
 71 #define NETFS_ICTX_UNBUFFERED   1                 
 72 #define NETFS_ICTX_WRITETHROUGH 2                 
 73 #define NETFS_ICTX_MODIFIED_ATTR 3                
 74 };                                                
 75                                                   
 76 /*                                                
 77  * A netfs group - for instance a ceph snap.      
 78  * pages marked with a group must be flushed b    
 79  * the domain of another group.                   
 80  */                                               
 81 struct netfs_group {                              
 82         refcount_t              ref;              
 83         void (*free)(struct netfs_group *netfs    
 84 };                                                
 85                                                   
 86 /*                                                
 87  * Information about a dirty page (attached on    
 88  * folio->private                                 
 89  */                                               
 90 struct netfs_folio {                              
 91         struct netfs_group      *netfs_group;     
 92         unsigned int            dirty_offset;     
 93         unsigned int            dirty_len;        
 94 };                                                
 95 #define NETFS_FOLIO_INFO        0x1UL   /* OR'    
 96 #define NETFS_FOLIO_COPY_TO_CACHE ((struct net    
 97                                                   
 98 static inline bool netfs_is_folio_info(const v    
 99 {                                                 
100         return (unsigned long)priv & NETFS_FOL    
101 }                                                 
102                                                   
103 static inline struct netfs_folio *__netfs_foli    
104 {                                                 
105         if (netfs_is_folio_info(priv))            
106                 return (struct netfs_folio *)(    
107         return NULL;                              
108 }                                                 
109                                                   
110 static inline struct netfs_folio *netfs_folio_    
111 {                                                 
112         return __netfs_folio_info(folio_get_pr    
113 }                                                 
114                                                   
115 static inline struct netfs_group *netfs_folio_    
116 {                                                 
117         struct netfs_folio *finfo;                
118         void *priv = folio_get_private(folio);    
119                                                   
120         finfo = netfs_folio_info(folio);          
121         if (finfo)                                
122                 return finfo->netfs_group;        
123         return priv;                              
124 }                                                 
125                                                   
126 /*                                                
127  * Stream of I/O subrequests going to a partic    
128  * server or the local cache.  This is mainly     
129  * have to write to multiple destinations conc    
130  */                                               
131 struct netfs_io_stream {                          
132         /* Submission tracking */                 
133         struct netfs_io_subrequest *construct;    
134         size_t                  sreq_max_len;     
135         unsigned int            sreq_max_segs;    
136         unsigned int            submit_off;       
137         unsigned int            submit_len;       
138         unsigned int            submit_extenda    
139         void (*prepare_write)(struct netfs_io_    
140         void (*issue_write)(struct netfs_io_su    
141         /* Collection tracking */                 
142         struct list_head        subrequests;      
143         struct netfs_io_subrequest *front;        
144         unsigned long long      collected_to;     
145         size_t                  transferred;      
146         enum netfs_io_source    source;           
147         unsigned short          error;            
148         unsigned char           stream_nr;        
149         bool                    avail;            
150         bool                    active;           
151         bool                    need_retry;       
152         bool                    failed;           
153 };                                                
154                                                   
155 /*                                                
156  * Resources required to do operations on a ca    
157  */                                               
158 struct netfs_cache_resources {                    
159         const struct netfs_cache_ops    *ops;     
160         void                            *cache    
161         void                            *cache    
162         unsigned int                    debug_    
163         unsigned int                    inval_    
164 };                                                
165                                                   
166 /*                                                
167  * Descriptor for a single component subreques    
168  * individual read/write from/to a server, a c    
169  *                                                
170  * The buffer iterator is persistent for the l    
171  * the pages it points to can be relied on to     
172  */                                               
173 struct netfs_io_subrequest {                      
174         struct netfs_io_request *rreq;            
175         struct work_struct      work;             
176         struct list_head        rreq_link;        
177         struct iov_iter         io_iter;          
178         unsigned long long      start;            
179         size_t                  len;              
180         size_t                  transferred;      
181         size_t                  consumed;         
182         size_t                  prev_donated;     
183         size_t                  next_donated;     
184         refcount_t              ref;              
185         short                   error;            
186         unsigned short          debug_index;      
187         unsigned int            nr_segs;          
188         enum netfs_io_source    source;           
189         unsigned char           stream_nr;        
190         unsigned char           curr_folioq_sl    
191         unsigned char           curr_folio_ord    
192         struct folio_queue      *curr_folioq;     
193         unsigned long           flags;            
194 #define NETFS_SREQ_COPY_TO_CACHE        0         
195 #define NETFS_SREQ_CLEAR_TAIL           1         
196 #define NETFS_SREQ_SEEK_DATA_READ       3         
197 #define NETFS_SREQ_NO_PROGRESS          4         
198 #define NETFS_SREQ_ONDEMAND             5         
199 #define NETFS_SREQ_BOUNDARY             6         
200 #define NETFS_SREQ_HIT_EOF              7         
201 #define NETFS_SREQ_IN_PROGRESS          8         
202 #define NETFS_SREQ_NEED_RETRY           9         
203 #define NETFS_SREQ_RETRYING             10        
204 #define NETFS_SREQ_FAILED               11        
205 };                                                
206                                                   
207 enum netfs_io_origin {                            
208         NETFS_READAHEAD,                /* Thi    
209         NETFS_READPAGE,                 /* Thi    
210         NETFS_READ_GAPS,                /* Thi    
211         NETFS_READ_FOR_WRITE,           /* Thi    
212         NETFS_DIO_READ,                 /* Thi    
213         NETFS_WRITEBACK,                /* Thi    
214         NETFS_WRITETHROUGH,             /* Thi    
215         NETFS_UNBUFFERED_WRITE,         /* Thi    
216         NETFS_DIO_WRITE,                /* Thi    
217         NETFS_PGPRIV2_COPY_TO_CACHE,    /* [DE    
218         nr__netfs_io_origin                       
219 } __mode(byte);                                   
220                                                   
221 /*                                                
222  * Descriptor for an I/O helper request.  This    
223  * operations to a variety of data stores and     
224  */                                               
225 struct netfs_io_request {                         
226         union {                                   
227                 struct work_struct work;          
228                 struct rcu_head rcu;              
229         };                                        
230         struct inode            *inode;           
231         struct address_space    *mapping;         
232         struct kiocb            *iocb;            
233         struct netfs_cache_resources cache_res    
234         struct readahead_control *ractl;          
235         struct list_head        proc_link;        
236         struct list_head        subrequests;      
237         struct netfs_io_stream  io_streams[2];    
238 #define NR_IO_STREAMS 2 //wreq->nr_io_streams     
239         struct netfs_group      *group;           
240         struct folio_queue      *buffer;          
241         struct folio_queue      *buffer_tail;     
242         struct iov_iter         iter;             
243         struct iov_iter         io_iter;          
244         void                    *netfs_priv;      
245         void                    *netfs_priv2;     
246         struct bio_vec          *direct_bv;       
247         unsigned int            direct_bv_coun    
248         unsigned int            debug_id;         
249         unsigned int            rsize;            
250         unsigned int            wsize;            
251         atomic_t                subreq_counter    
252         unsigned int            nr_group_rel;     
253         spinlock_t              lock;             
254         atomic_t                nr_outstanding    
255         unsigned long long      submitted;        
256         unsigned long long      len;              
257         size_t                  transferred;      
258         long                    error;            
259         enum netfs_io_origin    origin;           
260         bool                    direct_bv_unpi    
261         u8                      buffer_head_sl    
262         u8                      buffer_tail_sl    
263         unsigned long long      i_size;           
264         unsigned long long      start;            
265         atomic64_t              issued_to;        
266         unsigned long long      collected_to;     
267         unsigned long long      cleaned_to;       
268         pgoff_t                 no_unlock_foli    
269         size_t                  prev_donated;     
270         refcount_t              ref;              
271         unsigned long           flags;            
272 #define NETFS_RREQ_COPY_TO_CACHE        1         
273 #define NETFS_RREQ_NO_UNLOCK_FOLIO      2         
274 #define NETFS_RREQ_DONT_UNLOCK_FOLIOS   3         
275 #define NETFS_RREQ_FAILED               4         
276 #define NETFS_RREQ_IN_PROGRESS          5         
277 #define NETFS_RREQ_UPLOAD_TO_SERVER     8         
278 #define NETFS_RREQ_NONBLOCK             9         
279 #define NETFS_RREQ_BLOCKED              10        
280 #define NETFS_RREQ_PAUSE                11        
281 #define NETFS_RREQ_USE_IO_ITER          12        
282 #define NETFS_RREQ_ALL_QUEUED           13        
283 #define NETFS_RREQ_NEED_RETRY           14        
284 #define NETFS_RREQ_USE_PGPRIV2          31        
285                                                   
286         const struct netfs_request_ops *netfs_    
287         void (*cleanup)(struct netfs_io_reques    
288 };                                                
289                                                   
290 /*                                                
291  * Operations the network filesystem can/must     
292  */                                               
293 struct netfs_request_ops {                        
294         mempool_t *request_pool;                  
295         mempool_t *subrequest_pool;               
296         int (*init_request)(struct netfs_io_re    
297         void (*free_request)(struct netfs_io_r    
298         void (*free_subrequest)(struct netfs_i    
299                                                   
300         /* Read request handling */               
301         void (*expand_readahead)(struct netfs_    
302         int (*prepare_read)(struct netfs_io_su    
303         void (*issue_read)(struct netfs_io_sub    
304         bool (*is_still_valid)(struct netfs_io    
305         int (*check_write_begin)(struct file *    
306                                  struct folio     
307         void (*done)(struct netfs_io_request *    
308                                                   
309         /* Modification handling */               
310         void (*update_i_size)(struct inode *in    
311         void (*post_modify)(struct inode *inod    
312                                                   
313         /* Write request handling */              
314         void (*begin_writeback)(struct netfs_i    
315         void (*prepare_write)(struct netfs_io_    
316         void (*issue_write)(struct netfs_io_su    
317         void (*retry_request)(struct netfs_io_    
318         void (*invalidate_cache)(struct netfs_    
319 };                                                
320                                                   
321 /*                                                
322  * How to handle reading from a hole.             
323  */                                               
324 enum netfs_read_from_hole {                       
325         NETFS_READ_HOLE_IGNORE,                   
326         NETFS_READ_HOLE_CLEAR,                    
327         NETFS_READ_HOLE_FAIL,                     
328 };                                                
329                                                   
330 /*                                                
331  * Table of operations for access to a cache.     
332  */                                               
333 struct netfs_cache_ops {                          
334         /* End an operation */                    
335         void (*end_operation)(struct netfs_cac    
336                                                   
337         /* Read data from the cache */            
338         int (*read)(struct netfs_cache_resourc    
339                     loff_t start_pos,             
340                     struct iov_iter *iter,        
341                     enum netfs_read_from_hole     
342                     netfs_io_terminated_t term    
343                     void *term_func_priv);        
344                                                   
345         /* Write data to the cache */             
346         int (*write)(struct netfs_cache_resour    
347                      loff_t start_pos,            
348                      struct iov_iter *iter,       
349                      netfs_io_terminated_t ter    
350                      void *term_func_priv);       
351                                                   
352         /* Write data to the cache from a netf    
353         void (*issue_write)(struct netfs_io_su    
354                                                   
355         /* Expand readahead request */            
356         void (*expand_readahead)(struct netfs_    
357                                  unsigned long    
358                                  unsigned long    
359                                  unsigned long    
360                                                   
361         /* Prepare a read operation, shortenin    
362          * boundary as appropriate.               
363          */                                       
364         enum netfs_io_source (*prepare_read)(s    
365                                              u    
366                                                   
367         /* Prepare a write subrequest, working    
368          * and finding out the maximum amount     
369          * attempting to submit.  If we're not    
370          * subrequest should be marked failed.    
371          */                                       
372         void (*prepare_write_subreq)(struct ne    
373                                                   
374         /* Prepare a write operation, working     
375          * actually do.                           
376          */                                       
377         int (*prepare_write)(struct netfs_cach    
378                              loff_t *_start, s    
379                              loff_t i_size, bo    
380                                                   
381         /* Prepare an on-demand read operation    
382          * boundary as appropriate.               
383          */                                       
384         enum netfs_io_source (*prepare_ondeman    
385                                                   
386                                                   
387                                                   
388                                                   
389         /* Query the occupancy of the cache in    
390          * next chunk of data starts and how l    
391          */                                       
392         int (*query_occupancy)(struct netfs_ca    
393                                loff_t start, s    
394                                loff_t *_data_s    
395 };                                                
396                                                   
397 /* High-level read API. */                        
398 ssize_t netfs_unbuffered_read_iter_locked(stru    
399 ssize_t netfs_unbuffered_read_iter(struct kioc    
400 ssize_t netfs_buffered_read_iter(struct kiocb     
401 ssize_t netfs_file_read_iter(struct kiocb *ioc    
402                                                   
403 /* High-level write API */                        
404 ssize_t netfs_perform_write(struct kiocb *iocb    
405                             struct netfs_group    
406 ssize_t netfs_buffered_write_iter_locked(struc    
407                                          struc    
408 ssize_t netfs_unbuffered_write_iter(struct kio    
409 ssize_t netfs_unbuffered_write_iter_locked(str    
410                                            str    
411 ssize_t netfs_file_write_iter(struct kiocb *io    
412                                                   
413 /* Address operations API */                      
414 struct readahead_control;                         
415 void netfs_readahead(struct readahead_control     
416 int netfs_read_folio(struct file *, struct fol    
417 int netfs_write_begin(struct netfs_inode *, st    
418                       struct address_space *,     
419                       struct folio **, void **    
420 int netfs_writepages(struct address_space *map    
421                      struct writeback_control     
422 bool netfs_dirty_folio(struct address_space *m    
423 int netfs_unpin_writeback(struct inode *inode,    
424 void netfs_clear_inode_writeback(struct inode     
425 void netfs_invalidate_folio(struct folio *foli    
426 bool netfs_release_folio(struct folio *folio,     
427                                                   
428 /* VMA operations API. */                         
429 vm_fault_t netfs_page_mkwrite(struct vm_fault     
430                                                   
431 /* (Sub)request management API. */                
432 void netfs_read_subreq_progress(struct netfs_i    
433                                 bool was_async    
434 void netfs_read_subreq_terminated(struct netfs    
435                                   int error, b    
436 void netfs_get_subrequest(struct netfs_io_subr    
437                           enum netfs_sreq_ref_    
438 void netfs_put_subrequest(struct netfs_io_subr    
439                           bool was_async, enum    
440 ssize_t netfs_extract_user_iter(struct iov_ite    
441                                 struct iov_ite    
442                                 iov_iter_extra    
443 size_t netfs_limit_iter(const struct iov_iter     
444                         size_t max_size, size_    
445 void netfs_prepare_write_failed(struct netfs_i    
446 void netfs_write_subrequest_terminated(void *_    
447                                        bool wa    
448 void netfs_queue_write_request(struct netfs_io    
449                                                   
450 int netfs_start_io_read(struct inode *inode);     
451 void netfs_end_io_read(struct inode *inode);      
452 int netfs_start_io_write(struct inode *inode);    
453 void netfs_end_io_write(struct inode *inode);     
454 int netfs_start_io_direct(struct inode *inode)    
455 void netfs_end_io_direct(struct inode *inode);    
456                                                   
457 /**                                               
458  * netfs_inode - Get the netfs inode context f    
459  * @inode: The inode to query                     
460  *                                                
461  * Get the netfs lib inode context from the ne    
462  * context struct is expected to directly foll    
463  */                                               
464 static inline struct netfs_inode *netfs_inode(    
465 {                                                 
466         return container_of(inode, struct netf    
467 }                                                 
468                                                   
469 /**                                               
470  * netfs_inode_init - Initialise a netfslib in    
471  * @ctx: The netfs inode to initialise            
472  * @ops: The netfs's operations list              
473  * @use_zero_point: True to use the zero_point    
474  *                                                
475  * Initialise the netfs library context struct    
476  * directly from the VFS inode struct.            
477  */                                               
478 static inline void netfs_inode_init(struct net    
479                                     const stru    
480                                     bool use_z    
481 {                                                 
482         ctx->ops = ops;                           
483         ctx->remote_i_size = i_size_read(&ctx-    
484         ctx->zero_point = LLONG_MAX;              
485         ctx->flags = 0;                           
486         atomic_set(&ctx->io_count, 0);            
487 #if IS_ENABLED(CONFIG_FSCACHE)                    
488         ctx->cache = NULL;                        
489 #endif                                            
490         mutex_init(&ctx->wb_lock);                
491         /* ->releasepage() drives zero_point *    
492         if (use_zero_point) {                     
493                 ctx->zero_point = ctx->remote_    
494                 mapping_set_release_always(ctx    
495         }                                         
496 }                                                 
497                                                   
498 /**                                               
499  * netfs_resize_file - Note that a file got re    
500  * @ctx: The netfs inode being resized            
501  * @new_i_size: The new file size                 
502  * @changed_on_server: The change was applied     
503  *                                                
504  * Inform the netfs lib that a file got resize    
505  */                                               
506 static inline void netfs_resize_file(struct ne    
507                                      bool chan    
508 {                                                 
509         if (changed_on_server)                    
510                 ctx->remote_i_size = new_i_siz    
511         if (new_i_size < ctx->zero_point)         
512                 ctx->zero_point = new_i_size;     
513 }                                                 
514                                                   
515 /**                                               
516  * netfs_i_cookie - Get the cache cookie from     
517  * @ctx: The netfs inode to query                 
518  *                                                
519  * Get the caching cookie (if enabled) from th    
520  */                                               
521 static inline struct fscache_cookie *netfs_i_c    
522 {                                                 
523 #if IS_ENABLED(CONFIG_FSCACHE)                    
524         return ctx->cache;                        
525 #else                                             
526         return NULL;                              
527 #endif                                            
528 }                                                 
529                                                   
530 /**                                               
531  * netfs_wait_for_outstanding_io - Wait for ou    
532  * @inode: The netfs inode to wait on             
533  *                                                
534  * Wait for outstanding I/O requests of any ty    
535  * to be called from inode eviction routines.     
536  * resources held by those requests are cleane    
537  * cleaned up.                                    
538  */                                               
539 static inline void netfs_wait_for_outstanding_    
540 {                                                 
541         struct netfs_inode *ictx = netfs_inode    
542                                                   
543         wait_var_event(&ictx->io_count, atomic    
544 }                                                 
545                                                   
546 #endif /* _LINUX_NETFS_H */                       
547                                                   

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