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

TOMOYO Linux Cross Reference
Linux/fs/cachefiles/internal.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/cachefiles/internal.h (Version linux-6.12-rc7) and /fs/cachefiles/internal.h (Version linux-6.8.12)


  1 /* SPDX-License-Identifier: GPL-2.0-or-later *      1 /* SPDX-License-Identifier: GPL-2.0-or-later */
  2 /* General netfs cache on cache files internal      2 /* General netfs cache on cache files internal defs
  3  *                                                  3  *
  4  * Copyright (C) 2021 Red Hat, Inc. All Rights      4  * Copyright (C) 2021 Red Hat, Inc. All Rights Reserved.
  5  * Written by David Howells (dhowells@redhat.c      5  * Written by David Howells (dhowells@redhat.com)
  6  */                                                 6  */
  7                                                     7 
  8 #ifdef pr_fmt                                       8 #ifdef pr_fmt
  9 #undef pr_fmt                                       9 #undef pr_fmt
 10 #endif                                             10 #endif
 11                                                    11 
 12 #define pr_fmt(fmt) "CacheFiles: " fmt             12 #define pr_fmt(fmt) "CacheFiles: " fmt
 13                                                    13 
 14                                                    14 
 15 #include <linux/fscache-cache.h>                   15 #include <linux/fscache-cache.h>
 16 #include <linux/cred.h>                            16 #include <linux/cred.h>
 17 #include <linux/security.h>                        17 #include <linux/security.h>
 18 #include <linux/xarray.h>                          18 #include <linux/xarray.h>
 19 #include <linux/cachefiles.h>                      19 #include <linux/cachefiles.h>
 20                                                    20 
 21 #define CACHEFILES_DIO_BLOCK_SIZE 4096             21 #define CACHEFILES_DIO_BLOCK_SIZE 4096
 22                                                    22 
 23 struct cachefiles_cache;                           23 struct cachefiles_cache;
 24 struct cachefiles_object;                          24 struct cachefiles_object;
 25                                                    25 
 26 enum cachefiles_content {                          26 enum cachefiles_content {
 27         /* These values are saved on disk */       27         /* These values are saved on disk */
 28         CACHEFILES_CONTENT_NO_DATA      = 0, /     28         CACHEFILES_CONTENT_NO_DATA      = 0, /* No content stored */
 29         CACHEFILES_CONTENT_SINGLE       = 1, /     29         CACHEFILES_CONTENT_SINGLE       = 1, /* Content is monolithic, all is present */
 30         CACHEFILES_CONTENT_ALL          = 2, /     30         CACHEFILES_CONTENT_ALL          = 2, /* Content is all present, no map */
 31         CACHEFILES_CONTENT_BACKFS_MAP   = 3, /     31         CACHEFILES_CONTENT_BACKFS_MAP   = 3, /* Content is piecemeal, mapped through backing fs */
 32         CACHEFILES_CONTENT_DIRTY        = 4, /     32         CACHEFILES_CONTENT_DIRTY        = 4, /* Content is dirty (only seen on disk) */
 33         nr__cachefiles_content                     33         nr__cachefiles_content
 34 };                                                 34 };
 35                                                    35 
 36 /*                                                 36 /*
 37  * Cached volume representation.                   37  * Cached volume representation.
 38  */                                                38  */
 39 struct cachefiles_volume {                         39 struct cachefiles_volume {
 40         struct cachefiles_cache         *cache     40         struct cachefiles_cache         *cache;
 41         struct list_head                cache_     41         struct list_head                cache_link;     /* Link in cache->volumes */
 42         struct fscache_volume           *vcook     42         struct fscache_volume           *vcookie;       /* The netfs's representation */
 43         struct dentry                   *dentr     43         struct dentry                   *dentry;        /* The volume dentry */
 44         struct dentry                   *fanou     44         struct dentry                   *fanout[256];   /* Fanout subdirs */
 45 };                                                 45 };
 46                                                    46 
 47 enum cachefiles_object_state {                     47 enum cachefiles_object_state {
 48         CACHEFILES_ONDEMAND_OBJSTATE_CLOSE, /*     48         CACHEFILES_ONDEMAND_OBJSTATE_CLOSE, /* Anonymous fd closed by daemon or initial state */
 49         CACHEFILES_ONDEMAND_OBJSTATE_OPEN, /*      49         CACHEFILES_ONDEMAND_OBJSTATE_OPEN, /* Anonymous fd associated with object is available */
 50         CACHEFILES_ONDEMAND_OBJSTATE_REOPENING     50         CACHEFILES_ONDEMAND_OBJSTATE_REOPENING, /* Object that was closed and is being reopened. */
 51         CACHEFILES_ONDEMAND_OBJSTATE_DROPPING, << 
 52 };                                                 51 };
 53                                                    52 
 54 struct cachefiles_ondemand_info {                  53 struct cachefiles_ondemand_info {
 55         struct work_struct              ondema     54         struct work_struct              ondemand_work;
 56         int                             ondema     55         int                             ondemand_id;
 57         enum cachefiles_object_state    state;     56         enum cachefiles_object_state    state;
 58         struct cachefiles_object        *objec     57         struct cachefiles_object        *object;
 59         spinlock_t                      lock;  << 
 60 };                                                 58 };
 61                                                    59 
 62 /*                                                 60 /*
 63  * Backing file state.                             61  * Backing file state.
 64  */                                                62  */
 65 struct cachefiles_object {                         63 struct cachefiles_object {
 66         struct fscache_cookie           *cooki     64         struct fscache_cookie           *cookie;        /* Netfs data storage object cookie */
 67         struct cachefiles_volume        *volum     65         struct cachefiles_volume        *volume;        /* Cache volume that holds this object */
 68         struct list_head                cache_     66         struct list_head                cache_link;     /* Link in cache->*_list */
 69         struct file                     *file;     67         struct file                     *file;          /* The file representing this object */
 70         char                            *d_nam     68         char                            *d_name;        /* Backing file name */
 71         int                             debug_     69         int                             debug_id;
 72         spinlock_t                      lock;      70         spinlock_t                      lock;
 73         refcount_t                      ref;       71         refcount_t                      ref;
 74         u8                              d_name     72         u8                              d_name_len;     /* Length of filename */
 75         enum cachefiles_content         conten     73         enum cachefiles_content         content_info:8; /* Info about content presence */
 76         unsigned long                   flags;     74         unsigned long                   flags;
 77 #define CACHEFILES_OBJECT_USING_TMPFILE 0          75 #define CACHEFILES_OBJECT_USING_TMPFILE 0               /* Have an unlinked tmpfile */
 78 #ifdef CONFIG_CACHEFILES_ONDEMAND                  76 #ifdef CONFIG_CACHEFILES_ONDEMAND
 79         struct cachefiles_ondemand_info *ondem     77         struct cachefiles_ondemand_info *ondemand;
 80 #endif                                             78 #endif
 81 };                                                 79 };
 82                                                    80 
 83 #define CACHEFILES_ONDEMAND_ID_CLOSED   -1         81 #define CACHEFILES_ONDEMAND_ID_CLOSED   -1
 84                                                    82 
 85 /*                                                 83 /*
 86  * Cache files cache definition                    84  * Cache files cache definition
 87  */                                                85  */
 88 struct cachefiles_cache {                          86 struct cachefiles_cache {
 89         struct fscache_cache            *cache     87         struct fscache_cache            *cache;         /* Cache cookie */
 90         struct vfsmount                 *mnt;      88         struct vfsmount                 *mnt;           /* mountpoint holding the cache */
 91         struct dentry                   *store     89         struct dentry                   *store;         /* Directory into which live objects go */
 92         struct dentry                   *grave     90         struct dentry                   *graveyard;     /* directory into which dead objects go */
 93         struct file                     *cache     91         struct file                     *cachefilesd;   /* manager daemon handle */
 94         struct list_head                volume     92         struct list_head                volumes;        /* List of volume objects */
 95         struct list_head                object     93         struct list_head                object_list;    /* List of active objects */
 96         spinlock_t                      object     94         spinlock_t                      object_list_lock; /* Lock for volumes and object_list */
 97         const struct cred               *cache     95         const struct cred               *cache_cred;    /* security override for accessing cache */
 98         struct mutex                    daemon     96         struct mutex                    daemon_mutex;   /* command serialisation mutex */
 99         wait_queue_head_t               daemon     97         wait_queue_head_t               daemon_pollwq;  /* poll waitqueue for daemon */
100         atomic_t                        gravec     98         atomic_t                        gravecounter;   /* graveyard uniquifier */
101         atomic_t                        f_rele     99         atomic_t                        f_released;     /* number of objects released lately */
102         atomic_long_t                   b_rele    100         atomic_long_t                   b_released;     /* number of blocks released lately */
103         atomic_long_t                   b_writ    101         atomic_long_t                   b_writing;      /* Number of blocks being written */
104         unsigned                        frun_p    102         unsigned                        frun_percent;   /* when to stop culling (% files) */
105         unsigned                        fcull_    103         unsigned                        fcull_percent;  /* when to start culling (% files) */
106         unsigned                        fstop_    104         unsigned                        fstop_percent;  /* when to stop allocating (% files) */
107         unsigned                        brun_p    105         unsigned                        brun_percent;   /* when to stop culling (% blocks) */
108         unsigned                        bcull_    106         unsigned                        bcull_percent;  /* when to start culling (% blocks) */
109         unsigned                        bstop_    107         unsigned                        bstop_percent;  /* when to stop allocating (% blocks) */
110         unsigned                        bsize;    108         unsigned                        bsize;          /* cache's block size */
111         unsigned                        bshift    109         unsigned                        bshift;         /* ilog2(bsize) */
112         uint64_t                        frun;     110         uint64_t                        frun;           /* when to stop culling */
113         uint64_t                        fcull;    111         uint64_t                        fcull;          /* when to start culling */
114         uint64_t                        fstop;    112         uint64_t                        fstop;          /* when to stop allocating */
115         sector_t                        brun;     113         sector_t                        brun;           /* when to stop culling */
116         sector_t                        bcull;    114         sector_t                        bcull;          /* when to start culling */
117         sector_t                        bstop;    115         sector_t                        bstop;          /* when to stop allocating */
118         unsigned long                   flags;    116         unsigned long                   flags;
119 #define CACHEFILES_READY                0         117 #define CACHEFILES_READY                0       /* T if cache prepared */
120 #define CACHEFILES_DEAD                 1         118 #define CACHEFILES_DEAD                 1       /* T if cache dead */
121 #define CACHEFILES_CULLING              2         119 #define CACHEFILES_CULLING              2       /* T if cull engaged */
122 #define CACHEFILES_STATE_CHANGED        3         120 #define CACHEFILES_STATE_CHANGED        3       /* T if state changed (poll trigger) */
123 #define CACHEFILES_ONDEMAND_MODE        4         121 #define CACHEFILES_ONDEMAND_MODE        4       /* T if in on-demand read mode */
124         char                            *rootd    122         char                            *rootdirname;   /* name of cache root directory */
125         char                            *secct    123         char                            *secctx;        /* LSM security context */
126         char                            *tag;     124         char                            *tag;           /* cache binding tag */
127         refcount_t                      unbind    125         refcount_t                      unbind_pincount;/* refcount to do daemon unbind */
128         struct xarray                   reqs;     126         struct xarray                   reqs;           /* xarray of pending on-demand requests */
129         unsigned long                   req_id    127         unsigned long                   req_id_next;
130         struct xarray                   ondema    128         struct xarray                   ondemand_ids;   /* xarray for ondemand_id allocation */
131         u32                             ondema    129         u32                             ondemand_id_next;
132         u32                             msg_id << 
133 };                                                130 };
134                                                   131 
135 static inline bool cachefiles_in_ondemand_mode    132 static inline bool cachefiles_in_ondemand_mode(struct cachefiles_cache *cache)
136 {                                                 133 {
137         return IS_ENABLED(CONFIG_CACHEFILES_ON    134         return IS_ENABLED(CONFIG_CACHEFILES_ONDEMAND) &&
138                 test_bit(CACHEFILES_ONDEMAND_M    135                 test_bit(CACHEFILES_ONDEMAND_MODE, &cache->flags);
139 }                                                 136 }
140                                                   137 
141 struct cachefiles_req {                           138 struct cachefiles_req {
142         struct cachefiles_object *object;         139         struct cachefiles_object *object;
143         struct completion done;                   140         struct completion done;
144         refcount_t ref;                        << 
145         int error;                                141         int error;
146         struct cachefiles_msg msg;                142         struct cachefiles_msg msg;
147 };                                                143 };
148                                                   144 
149 #define CACHEFILES_REQ_NEW      XA_MARK_1         145 #define CACHEFILES_REQ_NEW      XA_MARK_1
150                                                   146 
151 #include <trace/events/cachefiles.h>              147 #include <trace/events/cachefiles.h>
152                                                   148 
153 static inline                                     149 static inline
154 struct file *cachefiles_cres_file(struct netfs    150 struct file *cachefiles_cres_file(struct netfs_cache_resources *cres)
155 {                                                 151 {
156         return cres->cache_priv2;                 152         return cres->cache_priv2;
157 }                                                 153 }
158                                                   154 
159 static inline                                     155 static inline
160 struct cachefiles_object *cachefiles_cres_obje    156 struct cachefiles_object *cachefiles_cres_object(struct netfs_cache_resources *cres)
161 {                                                 157 {
162         return fscache_cres_cookie(cres)->cach    158         return fscache_cres_cookie(cres)->cache_priv;
163 }                                                 159 }
164                                                   160 
165 /*                                                161 /*
166  * note change of state for daemon                162  * note change of state for daemon
167  */                                               163  */
168 static inline void cachefiles_state_changed(st    164 static inline void cachefiles_state_changed(struct cachefiles_cache *cache)
169 {                                                 165 {
170         set_bit(CACHEFILES_STATE_CHANGED, &cac    166         set_bit(CACHEFILES_STATE_CHANGED, &cache->flags);
171         wake_up_all(&cache->daemon_pollwq);       167         wake_up_all(&cache->daemon_pollwq);
172 }                                                 168 }
173                                                   169 
174 /*                                                170 /*
175  * cache.c                                        171  * cache.c
176  */                                               172  */
177 extern int cachefiles_add_cache(struct cachefi    173 extern int cachefiles_add_cache(struct cachefiles_cache *cache);
178 extern void cachefiles_withdraw_cache(struct c    174 extern void cachefiles_withdraw_cache(struct cachefiles_cache *cache);
179                                                   175 
180 enum cachefiles_has_space_for {                   176 enum cachefiles_has_space_for {
181         cachefiles_has_space_check,               177         cachefiles_has_space_check,
182         cachefiles_has_space_for_write,           178         cachefiles_has_space_for_write,
183         cachefiles_has_space_for_create,          179         cachefiles_has_space_for_create,
184 };                                                180 };
185 extern int cachefiles_has_space(struct cachefi    181 extern int cachefiles_has_space(struct cachefiles_cache *cache,
186                                 unsigned fnr,     182                                 unsigned fnr, unsigned bnr,
187                                 enum cachefile    183                                 enum cachefiles_has_space_for reason);
188                                                   184 
189 /*                                                185 /*
190  * daemon.c                                       186  * daemon.c
191  */                                               187  */
192 extern const struct file_operations cachefiles    188 extern const struct file_operations cachefiles_daemon_fops;
193 extern void cachefiles_flush_reqs(struct cache << 
194 extern void cachefiles_get_unbind_pincount(str    189 extern void cachefiles_get_unbind_pincount(struct cachefiles_cache *cache);
195 extern void cachefiles_put_unbind_pincount(str    190 extern void cachefiles_put_unbind_pincount(struct cachefiles_cache *cache);
196                                                   191 
197 /*                                                192 /*
198  * error_inject.c                                 193  * error_inject.c
199  */                                               194  */
200 #ifdef CONFIG_CACHEFILES_ERROR_INJECTION          195 #ifdef CONFIG_CACHEFILES_ERROR_INJECTION
201 extern unsigned int cachefiles_error_injection    196 extern unsigned int cachefiles_error_injection_state;
202 extern int cachefiles_register_error_injection    197 extern int cachefiles_register_error_injection(void);
203 extern void cachefiles_unregister_error_inject    198 extern void cachefiles_unregister_error_injection(void);
204                                                   199 
205 #else                                             200 #else
206 #define cachefiles_error_injection_state 0        201 #define cachefiles_error_injection_state 0
207                                                   202 
208 static inline int cachefiles_register_error_in    203 static inline int cachefiles_register_error_injection(void)
209 {                                                 204 {
210         return 0;                                 205         return 0;
211 }                                                 206 }
212                                                   207 
213 static inline void cachefiles_unregister_error    208 static inline void cachefiles_unregister_error_injection(void)
214 {                                                 209 {
215 }                                                 210 }
216 #endif                                            211 #endif
217                                                   212 
218                                                   213 
219 static inline int cachefiles_inject_read_error    214 static inline int cachefiles_inject_read_error(void)
220 {                                                 215 {
221         return cachefiles_error_injection_stat    216         return cachefiles_error_injection_state & 2 ? -EIO : 0;
222 }                                                 217 }
223                                                   218 
224 static inline int cachefiles_inject_write_erro    219 static inline int cachefiles_inject_write_error(void)
225 {                                                 220 {
226         return cachefiles_error_injection_stat    221         return cachefiles_error_injection_state & 2 ? -EIO :
227                 cachefiles_error_injection_sta    222                 cachefiles_error_injection_state & 1 ? -ENOSPC :
228                 0;                                223                 0;
229 }                                                 224 }
230                                                   225 
231 static inline int cachefiles_inject_remove_err    226 static inline int cachefiles_inject_remove_error(void)
232 {                                                 227 {
233         return cachefiles_error_injection_stat    228         return cachefiles_error_injection_state & 2 ? -EIO : 0;
234 }                                                 229 }
235                                                   230 
236 /*                                                231 /*
237  * interface.c                                    232  * interface.c
238  */                                               233  */
239 extern const struct fscache_cache_ops cachefil    234 extern const struct fscache_cache_ops cachefiles_cache_ops;
240 extern void cachefiles_see_object(struct cache    235 extern void cachefiles_see_object(struct cachefiles_object *object,
241                                   enum cachefi    236                                   enum cachefiles_obj_ref_trace why);
242 extern struct cachefiles_object *cachefiles_gr    237 extern struct cachefiles_object *cachefiles_grab_object(struct cachefiles_object *object,
243                                                   238                                                         enum cachefiles_obj_ref_trace why);
244 extern void cachefiles_put_object(struct cache    239 extern void cachefiles_put_object(struct cachefiles_object *object,
245                                   enum cachefi    240                                   enum cachefiles_obj_ref_trace why);
246                                                   241 
247 /*                                                242 /*
248  * io.c                                           243  * io.c
249  */                                               244  */
250 extern bool cachefiles_begin_operation(struct     245 extern bool cachefiles_begin_operation(struct netfs_cache_resources *cres,
251                                        enum fs    246                                        enum fscache_want_state want_state);
252 extern int __cachefiles_prepare_write(struct c    247 extern int __cachefiles_prepare_write(struct cachefiles_object *object,
253                                       struct f    248                                       struct file *file,
254                                       loff_t *    249                                       loff_t *_start, size_t *_len, size_t upper_len,
255                                       bool no_    250                                       bool no_space_allocated_yet);
256 extern int __cachefiles_write(struct cachefile    251 extern int __cachefiles_write(struct cachefiles_object *object,
257                               struct file *fil    252                               struct file *file,
258                               loff_t start_pos    253                               loff_t start_pos,
259                               struct iov_iter     254                               struct iov_iter *iter,
260                               netfs_io_termina    255                               netfs_io_terminated_t term_func,
261                               void *term_func_    256                               void *term_func_priv);
262                                                   257 
263 /*                                                258 /*
264  * key.c                                          259  * key.c
265  */                                               260  */
266 extern bool cachefiles_cook_key(struct cachefi    261 extern bool cachefiles_cook_key(struct cachefiles_object *object);
267                                                   262 
268 /*                                                263 /*
269  * main.c                                         264  * main.c
270  */                                               265  */
271 extern struct kmem_cache *cachefiles_object_ja    266 extern struct kmem_cache *cachefiles_object_jar;
272                                                   267 
273 /*                                                268 /*
274  * namei.c                                        269  * namei.c
275  */                                               270  */
276 extern void cachefiles_unmark_inode_in_use(str    271 extern void cachefiles_unmark_inode_in_use(struct cachefiles_object *object,
277                                            str    272                                            struct file *file);
278 extern int cachefiles_bury_object(struct cache    273 extern int cachefiles_bury_object(struct cachefiles_cache *cache,
279                                   struct cache    274                                   struct cachefiles_object *object,
280                                   struct dentr    275                                   struct dentry *dir,
281                                   struct dentr    276                                   struct dentry *rep,
282                                   enum fscache    277                                   enum fscache_why_object_killed why);
283 extern int cachefiles_delete_object(struct cac    278 extern int cachefiles_delete_object(struct cachefiles_object *object,
284                                     enum fscac    279                                     enum fscache_why_object_killed why);
285 extern bool cachefiles_look_up_object(struct c    280 extern bool cachefiles_look_up_object(struct cachefiles_object *object);
286 extern struct dentry *cachefiles_get_directory    281 extern struct dentry *cachefiles_get_directory(struct cachefiles_cache *cache,
287                                                   282                                                struct dentry *dir,
288                                                   283                                                const char *name,
289                                                   284                                                bool *_is_new);
290 extern void cachefiles_put_directory(struct de    285 extern void cachefiles_put_directory(struct dentry *dir);
291                                                   286 
292 extern int cachefiles_cull(struct cachefiles_c    287 extern int cachefiles_cull(struct cachefiles_cache *cache, struct dentry *dir,
293                            char *filename);       288                            char *filename);
294                                                   289 
295 extern int cachefiles_check_in_use(struct cach    290 extern int cachefiles_check_in_use(struct cachefiles_cache *cache,
296                                    struct dent    291                                    struct dentry *dir, char *filename);
297 extern struct file *cachefiles_create_tmpfile(    292 extern struct file *cachefiles_create_tmpfile(struct cachefiles_object *object);
298 extern bool cachefiles_commit_tmpfile(struct c    293 extern bool cachefiles_commit_tmpfile(struct cachefiles_cache *cache,
299                                       struct c    294                                       struct cachefiles_object *object);
300                                                   295 
301 /*                                                296 /*
302  * ondemand.c                                     297  * ondemand.c
303  */                                               298  */
304 #ifdef CONFIG_CACHEFILES_ONDEMAND                 299 #ifdef CONFIG_CACHEFILES_ONDEMAND
305 extern ssize_t cachefiles_ondemand_daemon_read    300 extern ssize_t cachefiles_ondemand_daemon_read(struct cachefiles_cache *cache,
306                                         char _    301                                         char __user *_buffer, size_t buflen);
307                                                   302 
308 extern int cachefiles_ondemand_copen(struct ca    303 extern int cachefiles_ondemand_copen(struct cachefiles_cache *cache,
309                                      char *arg    304                                      char *args);
310                                                   305 
311 extern int cachefiles_ondemand_restore(struct     306 extern int cachefiles_ondemand_restore(struct cachefiles_cache *cache,
312                                         char *    307                                         char *args);
313                                                   308 
314 extern int cachefiles_ondemand_init_object(str    309 extern int cachefiles_ondemand_init_object(struct cachefiles_object *object);
315 extern void cachefiles_ondemand_clean_object(s    310 extern void cachefiles_ondemand_clean_object(struct cachefiles_object *object);
316                                                   311 
317 extern int cachefiles_ondemand_read(struct cac    312 extern int cachefiles_ondemand_read(struct cachefiles_object *object,
318                                     loff_t pos    313                                     loff_t pos, size_t len);
319                                                   314 
320 extern int cachefiles_ondemand_init_obj_info(s    315 extern int cachefiles_ondemand_init_obj_info(struct cachefiles_object *obj,
321                                         struct    316                                         struct cachefiles_volume *volume);
322 extern void cachefiles_ondemand_deinit_obj_inf    317 extern void cachefiles_ondemand_deinit_obj_info(struct cachefiles_object *obj);
323                                                   318 
324 #define CACHEFILES_OBJECT_STATE_FUNCS(_state,     319 #define CACHEFILES_OBJECT_STATE_FUNCS(_state, _STATE)   \
325 static inline bool                                320 static inline bool                                                              \
326 cachefiles_ondemand_object_is_##_state(const s    321 cachefiles_ondemand_object_is_##_state(const struct cachefiles_object *object) \
327 {                                                 322 {                                                                                               \
328         return object->ondemand->state == CACH    323         return object->ondemand->state == CACHEFILES_ONDEMAND_OBJSTATE_##_STATE; \
329 }                                                 324 }                                                                                               \
330                                                   325                                                                                                 \
331 static inline void                                326 static inline void                                                              \
332 cachefiles_ondemand_set_object_##_state(struct    327 cachefiles_ondemand_set_object_##_state(struct cachefiles_object *object) \
333 {                                                 328 {                                                                                               \
334         object->ondemand->state = CACHEFILES_O    329         object->ondemand->state = CACHEFILES_ONDEMAND_OBJSTATE_##_STATE; \
335 }                                                 330 }
336                                                   331 
337 CACHEFILES_OBJECT_STATE_FUNCS(open, OPEN);        332 CACHEFILES_OBJECT_STATE_FUNCS(open, OPEN);
338 CACHEFILES_OBJECT_STATE_FUNCS(close, CLOSE);      333 CACHEFILES_OBJECT_STATE_FUNCS(close, CLOSE);
339 CACHEFILES_OBJECT_STATE_FUNCS(reopening, REOPE    334 CACHEFILES_OBJECT_STATE_FUNCS(reopening, REOPENING);
340 CACHEFILES_OBJECT_STATE_FUNCS(dropping, DROPPI << 
341                                                   335 
342 static inline bool cachefiles_ondemand_is_reop    336 static inline bool cachefiles_ondemand_is_reopening_read(struct cachefiles_req *req)
343 {                                                 337 {
344         return cachefiles_ondemand_object_is_r    338         return cachefiles_ondemand_object_is_reopening(req->object) &&
345                         req->msg.opcode == CAC    339                         req->msg.opcode == CACHEFILES_OP_READ;
346 }                                                 340 }
347                                                   341 
348 #else                                             342 #else
349 static inline ssize_t cachefiles_ondemand_daem    343 static inline ssize_t cachefiles_ondemand_daemon_read(struct cachefiles_cache *cache,
350                                         char _    344                                         char __user *_buffer, size_t buflen)
351 {                                                 345 {
352         return -EOPNOTSUPP;                       346         return -EOPNOTSUPP;
353 }                                                 347 }
354                                                   348 
355 static inline int cachefiles_ondemand_init_obj    349 static inline int cachefiles_ondemand_init_object(struct cachefiles_object *object)
356 {                                                 350 {
357         return 0;                                 351         return 0;
358 }                                                 352 }
359                                                   353 
360 static inline void cachefiles_ondemand_clean_o    354 static inline void cachefiles_ondemand_clean_object(struct cachefiles_object *object)
361 {                                                 355 {
362 }                                                 356 }
363                                                   357 
364 static inline int cachefiles_ondemand_read(str    358 static inline int cachefiles_ondemand_read(struct cachefiles_object *object,
365                                            lof    359                                            loff_t pos, size_t len)
366 {                                                 360 {
367         return -EOPNOTSUPP;                       361         return -EOPNOTSUPP;
368 }                                                 362 }
369                                                   363 
370 static inline int cachefiles_ondemand_init_obj    364 static inline int cachefiles_ondemand_init_obj_info(struct cachefiles_object *obj,
371                                                   365                                                 struct cachefiles_volume *volume)
372 {                                                 366 {
373         return 0;                                 367         return 0;
374 }                                                 368 }
375 static inline void cachefiles_ondemand_deinit_    369 static inline void cachefiles_ondemand_deinit_obj_info(struct cachefiles_object *obj)
376 {                                                 370 {
377 }                                                 371 }
378                                                   372 
379 static inline bool cachefiles_ondemand_is_reop    373 static inline bool cachefiles_ondemand_is_reopening_read(struct cachefiles_req *req)
380 {                                                 374 {
381         return false;                             375         return false;
382 }                                                 376 }
383 #endif                                            377 #endif
384                                                   378 
385 /*                                                379 /*
386  * security.c                                     380  * security.c
387  */                                               381  */
388 extern int cachefiles_get_security_ID(struct c    382 extern int cachefiles_get_security_ID(struct cachefiles_cache *cache);
389 extern int cachefiles_determine_cache_security    383 extern int cachefiles_determine_cache_security(struct cachefiles_cache *cache,
390                                                   384                                                struct dentry *root,
391                                                   385                                                const struct cred **_saved_cred);
392                                                   386 
393 static inline void cachefiles_begin_secure(str    387 static inline void cachefiles_begin_secure(struct cachefiles_cache *cache,
394                                            con    388                                            const struct cred **_saved_cred)
395 {                                                 389 {
396         *_saved_cred = override_creds(cache->c    390         *_saved_cred = override_creds(cache->cache_cred);
397 }                                                 391 }
398                                                   392 
399 static inline void cachefiles_end_secure(struc    393 static inline void cachefiles_end_secure(struct cachefiles_cache *cache,
400                                          const    394                                          const struct cred *saved_cred)
401 {                                                 395 {
402         revert_creds(saved_cred);                 396         revert_creds(saved_cred);
403 }                                                 397 }
404                                                   398 
405 /*                                                399 /*
406  * volume.c                                       400  * volume.c
407  */                                               401  */
408 void cachefiles_acquire_volume(struct fscache_    402 void cachefiles_acquire_volume(struct fscache_volume *volume);
409 void cachefiles_free_volume(struct fscache_vol    403 void cachefiles_free_volume(struct fscache_volume *volume);
410 void cachefiles_withdraw_volume(struct cachefi    404 void cachefiles_withdraw_volume(struct cachefiles_volume *volume);
411                                                   405 
412 /*                                                406 /*
413  * xattr.c                                        407  * xattr.c
414  */                                               408  */
415 extern int cachefiles_set_object_xattr(struct     409 extern int cachefiles_set_object_xattr(struct cachefiles_object *object);
416 extern int cachefiles_check_auxdata(struct cac    410 extern int cachefiles_check_auxdata(struct cachefiles_object *object,
417                                     struct fil    411                                     struct file *file);
418 extern int cachefiles_remove_object_xattr(stru    412 extern int cachefiles_remove_object_xattr(struct cachefiles_cache *cache,
419                                           stru    413                                           struct cachefiles_object *object,
420                                           stru    414                                           struct dentry *dentry);
421 extern void cachefiles_prepare_to_write(struct    415 extern void cachefiles_prepare_to_write(struct fscache_cookie *cookie);
422 extern bool cachefiles_set_volume_xattr(struct    416 extern bool cachefiles_set_volume_xattr(struct cachefiles_volume *volume);
423 extern int cachefiles_check_volume_xattr(struc    417 extern int cachefiles_check_volume_xattr(struct cachefiles_volume *volume);
424                                                   418 
425 /*                                                419 /*
426  * Error handling                                 420  * Error handling
427  */                                               421  */
428 #define cachefiles_io_error(___cache, FMT, ...    422 #define cachefiles_io_error(___cache, FMT, ...)         \
429 do {                                              423 do {                                                    \
430         pr_err("I/O Error: " FMT"\n", ##__VA_A    424         pr_err("I/O Error: " FMT"\n", ##__VA_ARGS__);   \
431         fscache_io_error((___cache)->cache);      425         fscache_io_error((___cache)->cache);            \
432         set_bit(CACHEFILES_DEAD, &(___cache)->    426         set_bit(CACHEFILES_DEAD, &(___cache)->flags);   \
433         if (cachefiles_in_ondemand_mode(___cac << 
434                 cachefiles_flush_reqs(___cache << 
435 } while (0)                                       427 } while (0)
436                                                   428 
437 #define cachefiles_io_error_obj(object, FMT, .    429 #define cachefiles_io_error_obj(object, FMT, ...)                       \
438 do {                                              430 do {                                                                    \
439         struct cachefiles_cache *___cache;        431         struct cachefiles_cache *___cache;                              \
440                                                   432                                                                         \
441         ___cache = (object)->volume->cache;       433         ___cache = (object)->volume->cache;                             \
442         cachefiles_io_error(___cache, FMT " [o    434         cachefiles_io_error(___cache, FMT " [o=%08x]", ##__VA_ARGS__,   \
443                             (object)->debug_id    435                             (object)->debug_id);                        \
444 } while (0)                                       436 } while (0)
445                                                   437 
446                                                   438 
447 /*                                                439 /*
448  * Debug tracing                                  440  * Debug tracing
449  */                                               441  */
450 extern unsigned cachefiles_debug;                 442 extern unsigned cachefiles_debug;
451 #define CACHEFILES_DEBUG_KENTER 1                 443 #define CACHEFILES_DEBUG_KENTER 1
452 #define CACHEFILES_DEBUG_KLEAVE 2                 444 #define CACHEFILES_DEBUG_KLEAVE 2
453 #define CACHEFILES_DEBUG_KDEBUG 4                 445 #define CACHEFILES_DEBUG_KDEBUG 4
454                                                   446 
455 #define dbgprintk(FMT, ...) \                     447 #define dbgprintk(FMT, ...) \
456         printk(KERN_DEBUG "[%-6.6s] "FMT"\n",     448         printk(KERN_DEBUG "[%-6.6s] "FMT"\n", current->comm, ##__VA_ARGS__)
457                                                   449 
458 #define kenter(FMT, ...) dbgprintk("==> %s("FM    450 #define kenter(FMT, ...) dbgprintk("==> %s("FMT")", __func__, ##__VA_ARGS__)
459 #define kleave(FMT, ...) dbgprintk("<== %s()"F    451 #define kleave(FMT, ...) dbgprintk("<== %s()"FMT"", __func__, ##__VA_ARGS__)
460 #define kdebug(FMT, ...) dbgprintk(FMT, ##__VA    452 #define kdebug(FMT, ...) dbgprintk(FMT, ##__VA_ARGS__)
461                                                   453 
462                                                   454 
463 #if defined(__KDEBUG)                             455 #if defined(__KDEBUG)
464 #define _enter(FMT, ...) kenter(FMT, ##__VA_AR    456 #define _enter(FMT, ...) kenter(FMT, ##__VA_ARGS__)
465 #define _leave(FMT, ...) kleave(FMT, ##__VA_AR    457 #define _leave(FMT, ...) kleave(FMT, ##__VA_ARGS__)
466 #define _debug(FMT, ...) kdebug(FMT, ##__VA_AR    458 #define _debug(FMT, ...) kdebug(FMT, ##__VA_ARGS__)
467                                                   459 
468 #elif defined(CONFIG_CACHEFILES_DEBUG)            460 #elif defined(CONFIG_CACHEFILES_DEBUG)
469 #define _enter(FMT, ...)                          461 #define _enter(FMT, ...)                                \
470 do {                                              462 do {                                                    \
471         if (cachefiles_debug & CACHEFILES_DEBU    463         if (cachefiles_debug & CACHEFILES_DEBUG_KENTER) \
472                 kenter(FMT, ##__VA_ARGS__);       464                 kenter(FMT, ##__VA_ARGS__);             \
473 } while (0)                                       465 } while (0)
474                                                   466 
475 #define _leave(FMT, ...)                          467 #define _leave(FMT, ...)                                \
476 do {                                              468 do {                                                    \
477         if (cachefiles_debug & CACHEFILES_DEBU    469         if (cachefiles_debug & CACHEFILES_DEBUG_KLEAVE) \
478                 kleave(FMT, ##__VA_ARGS__);       470                 kleave(FMT, ##__VA_ARGS__);             \
479 } while (0)                                       471 } while (0)
480                                                   472 
481 #define _debug(FMT, ...)                          473 #define _debug(FMT, ...)                                \
482 do {                                              474 do {                                                    \
483         if (cachefiles_debug & CACHEFILES_DEBU    475         if (cachefiles_debug & CACHEFILES_DEBUG_KDEBUG) \
484                 kdebug(FMT, ##__VA_ARGS__);       476                 kdebug(FMT, ##__VA_ARGS__);             \
485 } while (0)                                       477 } while (0)
486                                                   478 
487 #else                                             479 #else
488 #define _enter(FMT, ...) no_printk("==> %s("FM    480 #define _enter(FMT, ...) no_printk("==> %s("FMT")", __func__, ##__VA_ARGS__)
489 #define _leave(FMT, ...) no_printk("<== %s()"F    481 #define _leave(FMT, ...) no_printk("<== %s()"FMT"", __func__, ##__VA_ARGS__)
490 #define _debug(FMT, ...) no_printk(FMT, ##__VA    482 #define _debug(FMT, ...) no_printk(FMT, ##__VA_ARGS__)
491 #endif                                            483 #endif
492                                                   484 
493 #if 1 /* defined(__KDEBUGALL) */                  485 #if 1 /* defined(__KDEBUGALL) */
494                                                   486 
495 #define ASSERT(X)                                 487 #define ASSERT(X)                                                       \
496 do {                                              488 do {                                                                    \
497         if (unlikely(!(X))) {                     489         if (unlikely(!(X))) {                                           \
498                 pr_err("\n");                     490                 pr_err("\n");                                           \
499                 pr_err("Assertion failed\n");     491                 pr_err("Assertion failed\n");           \
500                 BUG();                            492                 BUG();                                                  \
501         }                                         493         }                                                               \
502 } while (0)                                       494 } while (0)
503                                                   495 
504 #define ASSERTCMP(X, OP, Y)                       496 #define ASSERTCMP(X, OP, Y)                                             \
505 do {                                              497 do {                                                                    \
506         if (unlikely(!((X) OP (Y)))) {            498         if (unlikely(!((X) OP (Y)))) {                                  \
507                 pr_err("\n");                     499                 pr_err("\n");                                           \
508                 pr_err("Assertion failed\n");     500                 pr_err("Assertion failed\n");           \
509                 pr_err("%lx " #OP " %lx is fal    501                 pr_err("%lx " #OP " %lx is false\n",                    \
510                        (unsigned long)(X), (un    502                        (unsigned long)(X), (unsigned long)(Y));         \
511                 BUG();                            503                 BUG();                                                  \
512         }                                         504         }                                                               \
513 } while (0)                                       505 } while (0)
514                                                   506 
515 #define ASSERTIF(C, X)                            507 #define ASSERTIF(C, X)                                                  \
516 do {                                              508 do {                                                                    \
517         if (unlikely((C) && !(X))) {              509         if (unlikely((C) && !(X))) {                                    \
518                 pr_err("\n");                     510                 pr_err("\n");                                           \
519                 pr_err("Assertion failed\n");     511                 pr_err("Assertion failed\n");           \
520                 BUG();                            512                 BUG();                                                  \
521         }                                         513         }                                                               \
522 } while (0)                                       514 } while (0)
523                                                   515 
524 #define ASSERTIFCMP(C, X, OP, Y)                  516 #define ASSERTIFCMP(C, X, OP, Y)                                        \
525 do {                                              517 do {                                                                    \
526         if (unlikely((C) && !((X) OP (Y)))) {     518         if (unlikely((C) && !((X) OP (Y)))) {                           \
527                 pr_err("\n");                     519                 pr_err("\n");                                           \
528                 pr_err("Assertion failed\n");     520                 pr_err("Assertion failed\n");           \
529                 pr_err("%lx " #OP " %lx is fal    521                 pr_err("%lx " #OP " %lx is false\n",                    \
530                        (unsigned long)(X), (un    522                        (unsigned long)(X), (unsigned long)(Y));         \
531                 BUG();                            523                 BUG();                                                  \
532         }                                         524         }                                                               \
533 } while (0)                                       525 } while (0)
534                                                   526 
535 #else                                             527 #else
536                                                   528 
537 #define ASSERT(X)                       do {}     529 #define ASSERT(X)                       do {} while (0)
538 #define ASSERTCMP(X, OP, Y)             do {}     530 #define ASSERTCMP(X, OP, Y)             do {} while (0)
539 #define ASSERTIF(C, X)                  do {}     531 #define ASSERTIF(C, X)                  do {} while (0)
540 #define ASSERTIFCMP(C, X, OP, Y)        do {}     532 #define ASSERTIFCMP(C, X, OP, Y)        do {} while (0)
541                                                   533 
542 #endif                                            534 #endif
543                                                   535 

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