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


  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) 2007 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/timer.h>
                                                   >>  17 #include <linux/wait_bit.h>
 16 #include <linux/cred.h>                            18 #include <linux/cred.h>
                                                   >>  19 #include <linux/workqueue.h>
 17 #include <linux/security.h>                        20 #include <linux/security.h>
 18 #include <linux/xarray.h>                      << 
 19 #include <linux/cachefiles.h>                  << 
 20                                                << 
 21 #define CACHEFILES_DIO_BLOCK_SIZE 4096         << 
 22                                                    21 
 23 struct cachefiles_cache;                           22 struct cachefiles_cache;
 24 struct cachefiles_object;                          23 struct cachefiles_object;
 25                                                    24 
 26 enum cachefiles_content {                      !!  25 extern unsigned cachefiles_debug;
 27         /* These values are saved on disk */   !!  26 #define CACHEFILES_DEBUG_KENTER 1
 28         CACHEFILES_CONTENT_NO_DATA      = 0, / !!  27 #define CACHEFILES_DEBUG_KLEAVE 2
 29         CACHEFILES_CONTENT_SINGLE       = 1, / !!  28 #define CACHEFILES_DEBUG_KDEBUG 4
 30         CACHEFILES_CONTENT_ALL          = 2, / << 
 31         CACHEFILES_CONTENT_BACKFS_MAP   = 3, / << 
 32         CACHEFILES_CONTENT_DIRTY        = 4, / << 
 33         nr__cachefiles_content                 << 
 34 };                                             << 
 35                                                << 
 36 /*                                             << 
 37  * Cached volume representation.               << 
 38  */                                            << 
 39 struct cachefiles_volume {                     << 
 40         struct cachefiles_cache         *cache << 
 41         struct list_head                cache_ << 
 42         struct fscache_volume           *vcook << 
 43         struct dentry                   *dentr << 
 44         struct dentry                   *fanou << 
 45 };                                             << 
 46                                                    29 
 47 enum cachefiles_object_state {                 !!  30 #define cachefiles_gfp (__GFP_RECLAIM | __GFP_NORETRY | __GFP_NOMEMALLOC)
 48         CACHEFILES_ONDEMAND_OBJSTATE_CLOSE, /* << 
 49         CACHEFILES_ONDEMAND_OBJSTATE_OPEN, /*  << 
 50         CACHEFILES_ONDEMAND_OBJSTATE_REOPENING << 
 51         CACHEFILES_ONDEMAND_OBJSTATE_DROPPING, << 
 52 };                                             << 
 53                                                << 
 54 struct cachefiles_ondemand_info {              << 
 55         struct work_struct              ondema << 
 56         int                             ondema << 
 57         enum cachefiles_object_state    state; << 
 58         struct cachefiles_object        *objec << 
 59         spinlock_t                      lock;  << 
 60 };                                             << 
 61                                                    31 
 62 /*                                                 32 /*
 63  * Backing file state.                         !!  33  * node records
 64  */                                                34  */
 65 struct cachefiles_object {                         35 struct cachefiles_object {
 66         struct fscache_cookie           *cooki !!  36         struct fscache_object           fscache;        /* fscache handle */
 67         struct cachefiles_volume        *volum !!  37         struct cachefiles_lookup_data   *lookup_data;   /* cached lookup data */
 68         struct list_head                cache_ !!  38         struct dentry                   *dentry;        /* the file/dir representing this object */
 69         struct file                     *file; !!  39         struct dentry                   *backer;        /* backing file */
 70         char                            *d_nam !!  40         loff_t                          i_size;         /* object size */
 71         int                             debug_ << 
 72         spinlock_t                      lock;  << 
 73         refcount_t                      ref;   << 
 74         u8                              d_name << 
 75         enum cachefiles_content         conten << 
 76         unsigned long                   flags;     41         unsigned long                   flags;
 77 #define CACHEFILES_OBJECT_USING_TMPFILE 0      !!  42 #define CACHEFILES_OBJECT_ACTIVE        0               /* T if marked active */
 78 #ifdef CONFIG_CACHEFILES_ONDEMAND              !!  43         atomic_t                        usage;          /* object usage count */
 79         struct cachefiles_ondemand_info *ondem !!  44         uint8_t                         type;           /* object type */
 80 #endif                                         !!  45         uint8_t                         new;            /* T if object new */
                                                   >>  46         spinlock_t                      work_lock;
                                                   >>  47         struct rb_node                  active_node;    /* link in active tree (dentry is key) */
 81 };                                                 48 };
 82                                                    49 
 83 #define CACHEFILES_ONDEMAND_ID_CLOSED   -1     !!  50 extern struct kmem_cache *cachefiles_object_jar;
 84                                                    51 
 85 /*                                                 52 /*
 86  * Cache files cache definition                    53  * Cache files cache definition
 87  */                                                54  */
 88 struct cachefiles_cache {                          55 struct cachefiles_cache {
 89         struct fscache_cache            *cache !!  56         struct fscache_cache            cache;          /* FS-Cache record */
 90         struct vfsmount                 *mnt;      57         struct vfsmount                 *mnt;           /* mountpoint holding the cache */
 91         struct dentry                   *store << 
 92         struct dentry                   *grave     58         struct dentry                   *graveyard;     /* directory into which dead objects go */
 93         struct file                     *cache     59         struct file                     *cachefilesd;   /* manager daemon handle */
 94         struct list_head                volume << 
 95         struct list_head                object << 
 96         spinlock_t                      object << 
 97         const struct cred               *cache     60         const struct cred               *cache_cred;    /* security override for accessing cache */
 98         struct mutex                    daemon     61         struct mutex                    daemon_mutex;   /* command serialisation mutex */
 99         wait_queue_head_t               daemon     62         wait_queue_head_t               daemon_pollwq;  /* poll waitqueue for daemon */
                                                   >>  63         struct rb_root                  active_nodes;   /* active nodes (can't be culled) */
                                                   >>  64         rwlock_t                        active_lock;    /* lock for active_nodes */
100         atomic_t                        gravec     65         atomic_t                        gravecounter;   /* graveyard uniquifier */
101         atomic_t                        f_rele     66         atomic_t                        f_released;     /* number of objects released lately */
102         atomic_long_t                   b_rele     67         atomic_long_t                   b_released;     /* number of blocks released lately */
103         atomic_long_t                   b_writ << 
104         unsigned                        frun_p     68         unsigned                        frun_percent;   /* when to stop culling (% files) */
105         unsigned                        fcull_     69         unsigned                        fcull_percent;  /* when to start culling (% files) */
106         unsigned                        fstop_     70         unsigned                        fstop_percent;  /* when to stop allocating (% files) */
107         unsigned                        brun_p     71         unsigned                        brun_percent;   /* when to stop culling (% blocks) */
108         unsigned                        bcull_     72         unsigned                        bcull_percent;  /* when to start culling (% blocks) */
109         unsigned                        bstop_     73         unsigned                        bstop_percent;  /* when to stop allocating (% blocks) */
110         unsigned                        bsize;     74         unsigned                        bsize;          /* cache's block size */
111         unsigned                        bshift !!  75         unsigned                        bshift;         /* min(ilog2(PAGE_SIZE / bsize), 0) */
112         uint64_t                        frun;      76         uint64_t                        frun;           /* when to stop culling */
113         uint64_t                        fcull;     77         uint64_t                        fcull;          /* when to start culling */
114         uint64_t                        fstop;     78         uint64_t                        fstop;          /* when to stop allocating */
115         sector_t                        brun;      79         sector_t                        brun;           /* when to stop culling */
116         sector_t                        bcull;     80         sector_t                        bcull;          /* when to start culling */
117         sector_t                        bstop;     81         sector_t                        bstop;          /* when to stop allocating */
118         unsigned long                   flags;     82         unsigned long                   flags;
119 #define CACHEFILES_READY                0          83 #define CACHEFILES_READY                0       /* T if cache prepared */
120 #define CACHEFILES_DEAD                 1          84 #define CACHEFILES_DEAD                 1       /* T if cache dead */
121 #define CACHEFILES_CULLING              2          85 #define CACHEFILES_CULLING              2       /* T if cull engaged */
122 #define CACHEFILES_STATE_CHANGED        3          86 #define CACHEFILES_STATE_CHANGED        3       /* T if state changed (poll trigger) */
123 #define CACHEFILES_ONDEMAND_MODE        4      << 
124         char                            *rootd     87         char                            *rootdirname;   /* name of cache root directory */
125         char                            *secct     88         char                            *secctx;        /* LSM security context */
126         char                            *tag;      89         char                            *tag;           /* cache binding tag */
127         refcount_t                      unbind << 
128         struct xarray                   reqs;  << 
129         unsigned long                   req_id << 
130         struct xarray                   ondema << 
131         u32                             ondema << 
132         u32                             msg_id << 
133 };                                                 90 };
134                                                    91 
135 static inline bool cachefiles_in_ondemand_mode !!  92 /*
136 {                                              !!  93  * backing file read tracking
137         return IS_ENABLED(CONFIG_CACHEFILES_ON !!  94  */
138                 test_bit(CACHEFILES_ONDEMAND_M !!  95 struct cachefiles_one_read {
139 }                                              !!  96         wait_queue_entry_t                      monitor;        /* link into monitored waitqueue */
                                                   >>  97         struct page                     *back_page;     /* backing file page we're waiting for */
                                                   >>  98         struct page                     *netfs_page;    /* netfs page we're going to fill */
                                                   >>  99         struct fscache_retrieval        *op;            /* retrieval op covering this */
                                                   >> 100         struct list_head                op_link;        /* link in op's todo list */
                                                   >> 101 };
140                                                   102 
141 struct cachefiles_req {                        !! 103 /*
142         struct cachefiles_object *object;      !! 104  * backing file write tracking
143         struct completion done;                !! 105  */
144         refcount_t ref;                        !! 106 struct cachefiles_one_write {
145         int error;                             !! 107         struct page                     *netfs_page;    /* netfs page to copy */
146         struct cachefiles_msg msg;             !! 108         struct cachefiles_object        *object;
                                                   >> 109         struct list_head                obj_link;       /* link in object's lists */
                                                   >> 110         fscache_rw_complete_t           end_io_func;
                                                   >> 111         void                            *context;
147 };                                                112 };
148                                                   113 
149 #define CACHEFILES_REQ_NEW      XA_MARK_1      !! 114 /*
                                                   >> 115  * auxiliary data xattr buffer
                                                   >> 116  */
                                                   >> 117 struct cachefiles_xattr {
                                                   >> 118         uint16_t                        len;
                                                   >> 119         uint8_t                         type;
                                                   >> 120         uint8_t                         data[];
                                                   >> 121 };
150                                                   122 
151 #include <trace/events/cachefiles.h>              123 #include <trace/events/cachefiles.h>
152                                                   124 
153 static inline                                  << 
154 struct file *cachefiles_cres_file(struct netfs << 
155 {                                              << 
156         return cres->cache_priv2;              << 
157 }                                              << 
158                                                << 
159 static inline                                  << 
160 struct cachefiles_object *cachefiles_cres_obje << 
161 {                                              << 
162         return fscache_cres_cookie(cres)->cach << 
163 }                                              << 
164                                                << 
165 /*                                                125 /*
166  * note change of state for daemon                126  * note change of state for daemon
167  */                                               127  */
168 static inline void cachefiles_state_changed(st    128 static inline void cachefiles_state_changed(struct cachefiles_cache *cache)
169 {                                                 129 {
170         set_bit(CACHEFILES_STATE_CHANGED, &cac    130         set_bit(CACHEFILES_STATE_CHANGED, &cache->flags);
171         wake_up_all(&cache->daemon_pollwq);       131         wake_up_all(&cache->daemon_pollwq);
172 }                                                 132 }
173                                                   133 
174 /*                                                134 /*
175  * cache.c                                     !! 135  * bind.c
176  */                                               136  */
177 extern int cachefiles_add_cache(struct cachefi !! 137 extern int cachefiles_daemon_bind(struct cachefiles_cache *cache, char *args);
178 extern void cachefiles_withdraw_cache(struct c !! 138 extern void cachefiles_daemon_unbind(struct cachefiles_cache *cache);
179                                                << 
180 enum cachefiles_has_space_for {                << 
181         cachefiles_has_space_check,            << 
182         cachefiles_has_space_for_write,        << 
183         cachefiles_has_space_for_create,       << 
184 };                                             << 
185 extern int cachefiles_has_space(struct cachefi << 
186                                 unsigned fnr,  << 
187                                 enum cachefile << 
188                                                   139 
189 /*                                                140 /*
190  * daemon.c                                       141  * daemon.c
191  */                                               142  */
192 extern const struct file_operations cachefiles    143 extern const struct file_operations cachefiles_daemon_fops;
193 extern void cachefiles_flush_reqs(struct cache << 
194 extern void cachefiles_get_unbind_pincount(str << 
195 extern void cachefiles_put_unbind_pincount(str << 
196                                                << 
197 /*                                             << 
198  * error_inject.c                              << 
199  */                                            << 
200 #ifdef CONFIG_CACHEFILES_ERROR_INJECTION       << 
201 extern unsigned int cachefiles_error_injection << 
202 extern int cachefiles_register_error_injection << 
203 extern void cachefiles_unregister_error_inject << 
204                                                << 
205 #else                                          << 
206 #define cachefiles_error_injection_state 0     << 
207                                                << 
208 static inline int cachefiles_register_error_in << 
209 {                                              << 
210         return 0;                              << 
211 }                                              << 
212                                                << 
213 static inline void cachefiles_unregister_error << 
214 {                                              << 
215 }                                              << 
216 #endif                                         << 
217                                                   144 
218                                                !! 145 extern int cachefiles_has_space(struct cachefiles_cache *cache,
219 static inline int cachefiles_inject_read_error !! 146                                 unsigned fnr, unsigned bnr);
220 {                                              << 
221         return cachefiles_error_injection_stat << 
222 }                                              << 
223                                                << 
224 static inline int cachefiles_inject_write_erro << 
225 {                                              << 
226         return cachefiles_error_injection_stat << 
227                 cachefiles_error_injection_sta << 
228                 0;                             << 
229 }                                              << 
230                                                << 
231 static inline int cachefiles_inject_remove_err << 
232 {                                              << 
233         return cachefiles_error_injection_stat << 
234 }                                              << 
235                                                   147 
236 /*                                                148 /*
237  * interface.c                                    149  * interface.c
238  */                                               150  */
239 extern const struct fscache_cache_ops cachefil    151 extern const struct fscache_cache_ops cachefiles_cache_ops;
240 extern void cachefiles_see_object(struct cache << 
241                                   enum cachefi << 
242 extern struct cachefiles_object *cachefiles_gr << 
243                                                << 
244 extern void cachefiles_put_object(struct cache << 
245                                   enum cachefi << 
246                                                << 
247 /*                                             << 
248  * io.c                                        << 
249  */                                            << 
250 extern bool cachefiles_begin_operation(struct  << 
251                                        enum fs << 
252 extern int __cachefiles_prepare_write(struct c << 
253                                       struct f << 
254                                       loff_t * << 
255                                       bool no_ << 
256 extern int __cachefiles_write(struct cachefile << 
257                               struct file *fil << 
258                               loff_t start_pos << 
259                               struct iov_iter  << 
260                               netfs_io_termina << 
261                               void *term_func_ << 
262                                                   152 
263 /*                                                153 /*
264  * key.c                                          154  * key.c
265  */                                               155  */
266 extern bool cachefiles_cook_key(struct cachefi !! 156 extern char *cachefiles_cook_key(const u8 *raw, int keylen, uint8_t type);
267                                                << 
268 /*                                             << 
269  * main.c                                      << 
270  */                                            << 
271 extern struct kmem_cache *cachefiles_object_ja << 
272                                                   157 
273 /*                                                158 /*
274  * namei.c                                        159  * namei.c
275  */                                               160  */
276 extern void cachefiles_unmark_inode_in_use(str !! 161 extern void cachefiles_mark_object_inactive(struct cachefiles_cache *cache,
277                                            str !! 162                                             struct cachefiles_object *object,
278 extern int cachefiles_bury_object(struct cache !! 163                                             blkcnt_t i_blocks);
279                                   struct cache !! 164 extern int cachefiles_delete_object(struct cachefiles_cache *cache,
280                                   struct dentr !! 165                                     struct cachefiles_object *object);
281                                   struct dentr !! 166 extern int cachefiles_walk_to_object(struct cachefiles_object *parent,
282                                   enum fscache !! 167                                      struct cachefiles_object *object,
283 extern int cachefiles_delete_object(struct cac !! 168                                      const char *key,
284                                     enum fscac !! 169                                      struct cachefiles_xattr *auxdata);
285 extern bool cachefiles_look_up_object(struct c << 
286 extern struct dentry *cachefiles_get_directory    170 extern struct dentry *cachefiles_get_directory(struct cachefiles_cache *cache,
287                                                   171                                                struct dentry *dir,
288                                                !! 172                                                const char *name);
289                                                << 
290 extern void cachefiles_put_directory(struct de << 
291                                                   173 
292 extern int cachefiles_cull(struct cachefiles_c    174 extern int cachefiles_cull(struct cachefiles_cache *cache, struct dentry *dir,
293                            char *filename);       175                            char *filename);
294                                                   176 
295 extern int cachefiles_check_in_use(struct cach    177 extern int cachefiles_check_in_use(struct cachefiles_cache *cache,
296                                    struct dent    178                                    struct dentry *dir, char *filename);
297 extern struct file *cachefiles_create_tmpfile( << 
298 extern bool cachefiles_commit_tmpfile(struct c << 
299                                       struct c << 
300                                                << 
301 /*                                             << 
302  * ondemand.c                                  << 
303  */                                            << 
304 #ifdef CONFIG_CACHEFILES_ONDEMAND              << 
305 extern ssize_t cachefiles_ondemand_daemon_read << 
306                                         char _ << 
307                                                << 
308 extern int cachefiles_ondemand_copen(struct ca << 
309                                      char *arg << 
310                                                << 
311 extern int cachefiles_ondemand_restore(struct  << 
312                                         char * << 
313                                                << 
314 extern int cachefiles_ondemand_init_object(str << 
315 extern void cachefiles_ondemand_clean_object(s << 
316                                                << 
317 extern int cachefiles_ondemand_read(struct cac << 
318                                     loff_t pos << 
319                                                << 
320 extern int cachefiles_ondemand_init_obj_info(s << 
321                                         struct << 
322 extern void cachefiles_ondemand_deinit_obj_inf << 
323                                                << 
324 #define CACHEFILES_OBJECT_STATE_FUNCS(_state,  << 
325 static inline bool                             << 
326 cachefiles_ondemand_object_is_##_state(const s << 
327 {                                              << 
328         return object->ondemand->state == CACH << 
329 }                                              << 
330                                                << 
331 static inline void                             << 
332 cachefiles_ondemand_set_object_##_state(struct << 
333 {                                              << 
334         object->ondemand->state = CACHEFILES_O << 
335 }                                              << 
336                                                   179 
337 CACHEFILES_OBJECT_STATE_FUNCS(open, OPEN);     !! 180 /*
338 CACHEFILES_OBJECT_STATE_FUNCS(close, CLOSE);   !! 181  * proc.c
339 CACHEFILES_OBJECT_STATE_FUNCS(reopening, REOPE !! 182  */
340 CACHEFILES_OBJECT_STATE_FUNCS(dropping, DROPPI !! 183 #ifdef CONFIG_CACHEFILES_HISTOGRAM
                                                   >> 184 extern atomic_t cachefiles_lookup_histogram[HZ];
                                                   >> 185 extern atomic_t cachefiles_mkdir_histogram[HZ];
                                                   >> 186 extern atomic_t cachefiles_create_histogram[HZ];
341                                                   187 
342 static inline bool cachefiles_ondemand_is_reop !! 188 extern int __init cachefiles_proc_init(void);
                                                   >> 189 extern void cachefiles_proc_cleanup(void);
                                                   >> 190 static inline
                                                   >> 191 void cachefiles_hist(atomic_t histogram[], unsigned long start_jif)
343 {                                                 192 {
344         return cachefiles_ondemand_object_is_r !! 193         unsigned long jif = jiffies - start_jif;
345                         req->msg.opcode == CAC !! 194         if (jif >= HZ)
                                                   >> 195                 jif = HZ - 1;
                                                   >> 196         atomic_inc(&histogram[jif]);
346 }                                                 197 }
347                                                   198 
348 #else                                             199 #else
349 static inline ssize_t cachefiles_ondemand_daem !! 200 #define cachefiles_proc_init()          (0)
350                                         char _ !! 201 #define cachefiles_proc_cleanup()       do {} while (0)
351 {                                              !! 202 #define cachefiles_hist(hist, start_jif) do {} while (0)
352         return -EOPNOTSUPP;                    << 
353 }                                              << 
354                                                << 
355 static inline int cachefiles_ondemand_init_obj << 
356 {                                              << 
357         return 0;                              << 
358 }                                              << 
359                                                << 
360 static inline void cachefiles_ondemand_clean_o << 
361 {                                              << 
362 }                                              << 
363                                                << 
364 static inline int cachefiles_ondemand_read(str << 
365                                            lof << 
366 {                                              << 
367         return -EOPNOTSUPP;                    << 
368 }                                              << 
369                                                << 
370 static inline int cachefiles_ondemand_init_obj << 
371                                                << 
372 {                                              << 
373         return 0;                              << 
374 }                                              << 
375 static inline void cachefiles_ondemand_deinit_ << 
376 {                                              << 
377 }                                              << 
378                                                << 
379 static inline bool cachefiles_ondemand_is_reop << 
380 {                                              << 
381         return false;                          << 
382 }                                              << 
383 #endif                                            203 #endif
384                                                   204 
385 /*                                                205 /*
                                                   >> 206  * rdwr.c
                                                   >> 207  */
                                                   >> 208 extern int cachefiles_read_or_alloc_page(struct fscache_retrieval *,
                                                   >> 209                                          struct page *, gfp_t);
                                                   >> 210 extern int cachefiles_read_or_alloc_pages(struct fscache_retrieval *,
                                                   >> 211                                           struct list_head *, unsigned *,
                                                   >> 212                                           gfp_t);
                                                   >> 213 extern int cachefiles_allocate_page(struct fscache_retrieval *, struct page *,
                                                   >> 214                                     gfp_t);
                                                   >> 215 extern int cachefiles_allocate_pages(struct fscache_retrieval *,
                                                   >> 216                                      struct list_head *, unsigned *, gfp_t);
                                                   >> 217 extern int cachefiles_write_page(struct fscache_storage *, struct page *);
                                                   >> 218 extern void cachefiles_uncache_page(struct fscache_object *, struct page *);
                                                   >> 219 
                                                   >> 220 /*
386  * security.c                                     221  * security.c
387  */                                               222  */
388 extern int cachefiles_get_security_ID(struct c    223 extern int cachefiles_get_security_ID(struct cachefiles_cache *cache);
389 extern int cachefiles_determine_cache_security    224 extern int cachefiles_determine_cache_security(struct cachefiles_cache *cache,
390                                                   225                                                struct dentry *root,
391                                                   226                                                const struct cred **_saved_cred);
392                                                   227 
393 static inline void cachefiles_begin_secure(str    228 static inline void cachefiles_begin_secure(struct cachefiles_cache *cache,
394                                            con    229                                            const struct cred **_saved_cred)
395 {                                                 230 {
396         *_saved_cred = override_creds(cache->c    231         *_saved_cred = override_creds(cache->cache_cred);
397 }                                                 232 }
398                                                   233 
399 static inline void cachefiles_end_secure(struc    234 static inline void cachefiles_end_secure(struct cachefiles_cache *cache,
400                                          const    235                                          const struct cred *saved_cred)
401 {                                                 236 {
402         revert_creds(saved_cred);                 237         revert_creds(saved_cred);
403 }                                                 238 }
404                                                   239 
405 /*                                                240 /*
406  * volume.c                                    << 
407  */                                            << 
408 void cachefiles_acquire_volume(struct fscache_ << 
409 void cachefiles_free_volume(struct fscache_vol << 
410 void cachefiles_withdraw_volume(struct cachefi << 
411                                                << 
412 /*                                             << 
413  * xattr.c                                        241  * xattr.c
414  */                                               242  */
415 extern int cachefiles_set_object_xattr(struct  !! 243 extern int cachefiles_check_object_type(struct cachefiles_object *object);
416 extern int cachefiles_check_auxdata(struct cac !! 244 extern int cachefiles_set_object_xattr(struct cachefiles_object *object,
417                                     struct fil !! 245                                        struct cachefiles_xattr *auxdata);
                                                   >> 246 extern int cachefiles_update_object_xattr(struct cachefiles_object *object,
                                                   >> 247                                           struct cachefiles_xattr *auxdata);
                                                   >> 248 extern int cachefiles_check_auxdata(struct cachefiles_object *object);
                                                   >> 249 extern int cachefiles_check_object_xattr(struct cachefiles_object *object,
                                                   >> 250                                          struct cachefiles_xattr *auxdata);
418 extern int cachefiles_remove_object_xattr(stru    251 extern int cachefiles_remove_object_xattr(struct cachefiles_cache *cache,
419                                           stru << 
420                                           stru    252                                           struct dentry *dentry);
421 extern void cachefiles_prepare_to_write(struct !! 253 
422 extern bool cachefiles_set_volume_xattr(struct << 
423 extern int cachefiles_check_volume_xattr(struc << 
424                                                   254 
425 /*                                                255 /*
426  * Error handling                              !! 256  * error handling
427  */                                               257  */
                                                   >> 258 
428 #define cachefiles_io_error(___cache, FMT, ...    259 #define cachefiles_io_error(___cache, FMT, ...)         \
429 do {                                              260 do {                                                    \
430         pr_err("I/O Error: " FMT"\n", ##__VA_A    261         pr_err("I/O Error: " FMT"\n", ##__VA_ARGS__);   \
431         fscache_io_error((___cache)->cache);   !! 262         fscache_io_error(&(___cache)->cache);           \
432         set_bit(CACHEFILES_DEAD, &(___cache)->    263         set_bit(CACHEFILES_DEAD, &(___cache)->flags);   \
433         if (cachefiles_in_ondemand_mode(___cac << 
434                 cachefiles_flush_reqs(___cache << 
435 } while (0)                                       264 } while (0)
436                                                   265 
437 #define cachefiles_io_error_obj(object, FMT, .    266 #define cachefiles_io_error_obj(object, FMT, ...)                       \
438 do {                                              267 do {                                                                    \
439         struct cachefiles_cache *___cache;        268         struct cachefiles_cache *___cache;                              \
440                                                   269                                                                         \
441         ___cache = (object)->volume->cache;    !! 270         ___cache = container_of((object)->fscache.cache,                \
442         cachefiles_io_error(___cache, FMT " [o !! 271                                 struct cachefiles_cache, cache);        \
443                             (object)->debug_id !! 272         cachefiles_io_error(___cache, FMT, ##__VA_ARGS__);              \
444 } while (0)                                       273 } while (0)
445                                                   274 
446                                                   275 
447 /*                                                276 /*
448  * Debug tracing                               !! 277  * debug tracing
449  */                                               278  */
450 extern unsigned cachefiles_debug;              << 
451 #define CACHEFILES_DEBUG_KENTER 1              << 
452 #define CACHEFILES_DEBUG_KLEAVE 2              << 
453 #define CACHEFILES_DEBUG_KDEBUG 4              << 
454                                                << 
455 #define dbgprintk(FMT, ...) \                     279 #define dbgprintk(FMT, ...) \
456         printk(KERN_DEBUG "[%-6.6s] "FMT"\n",     280         printk(KERN_DEBUG "[%-6.6s] "FMT"\n", current->comm, ##__VA_ARGS__)
457                                                   281 
458 #define kenter(FMT, ...) dbgprintk("==> %s("FM    282 #define kenter(FMT, ...) dbgprintk("==> %s("FMT")", __func__, ##__VA_ARGS__)
459 #define kleave(FMT, ...) dbgprintk("<== %s()"F    283 #define kleave(FMT, ...) dbgprintk("<== %s()"FMT"", __func__, ##__VA_ARGS__)
460 #define kdebug(FMT, ...) dbgprintk(FMT, ##__VA    284 #define kdebug(FMT, ...) dbgprintk(FMT, ##__VA_ARGS__)
461                                                   285 
462                                                   286 
463 #if defined(__KDEBUG)                             287 #if defined(__KDEBUG)
464 #define _enter(FMT, ...) kenter(FMT, ##__VA_AR    288 #define _enter(FMT, ...) kenter(FMT, ##__VA_ARGS__)
465 #define _leave(FMT, ...) kleave(FMT, ##__VA_AR    289 #define _leave(FMT, ...) kleave(FMT, ##__VA_ARGS__)
466 #define _debug(FMT, ...) kdebug(FMT, ##__VA_AR    290 #define _debug(FMT, ...) kdebug(FMT, ##__VA_ARGS__)
467                                                   291 
468 #elif defined(CONFIG_CACHEFILES_DEBUG)            292 #elif defined(CONFIG_CACHEFILES_DEBUG)
469 #define _enter(FMT, ...)                          293 #define _enter(FMT, ...)                                \
470 do {                                              294 do {                                                    \
471         if (cachefiles_debug & CACHEFILES_DEBU    295         if (cachefiles_debug & CACHEFILES_DEBUG_KENTER) \
472                 kenter(FMT, ##__VA_ARGS__);       296                 kenter(FMT, ##__VA_ARGS__);             \
473 } while (0)                                       297 } while (0)
474                                                   298 
475 #define _leave(FMT, ...)                          299 #define _leave(FMT, ...)                                \
476 do {                                              300 do {                                                    \
477         if (cachefiles_debug & CACHEFILES_DEBU    301         if (cachefiles_debug & CACHEFILES_DEBUG_KLEAVE) \
478                 kleave(FMT, ##__VA_ARGS__);       302                 kleave(FMT, ##__VA_ARGS__);             \
479 } while (0)                                       303 } while (0)
480                                                   304 
481 #define _debug(FMT, ...)                          305 #define _debug(FMT, ...)                                \
482 do {                                              306 do {                                                    \
483         if (cachefiles_debug & CACHEFILES_DEBU    307         if (cachefiles_debug & CACHEFILES_DEBUG_KDEBUG) \
484                 kdebug(FMT, ##__VA_ARGS__);       308                 kdebug(FMT, ##__VA_ARGS__);             \
485 } while (0)                                       309 } while (0)
486                                                   310 
487 #else                                             311 #else
488 #define _enter(FMT, ...) no_printk("==> %s("FM    312 #define _enter(FMT, ...) no_printk("==> %s("FMT")", __func__, ##__VA_ARGS__)
489 #define _leave(FMT, ...) no_printk("<== %s()"F    313 #define _leave(FMT, ...) no_printk("<== %s()"FMT"", __func__, ##__VA_ARGS__)
490 #define _debug(FMT, ...) no_printk(FMT, ##__VA    314 #define _debug(FMT, ...) no_printk(FMT, ##__VA_ARGS__)
491 #endif                                            315 #endif
492                                                   316 
493 #if 1 /* defined(__KDEBUGALL) */                  317 #if 1 /* defined(__KDEBUGALL) */
494                                                   318 
495 #define ASSERT(X)                                 319 #define ASSERT(X)                                                       \
496 do {                                              320 do {                                                                    \
497         if (unlikely(!(X))) {                     321         if (unlikely(!(X))) {                                           \
498                 pr_err("\n");                     322                 pr_err("\n");                                           \
499                 pr_err("Assertion failed\n");     323                 pr_err("Assertion failed\n");           \
500                 BUG();                            324                 BUG();                                                  \
501         }                                         325         }                                                               \
502 } while (0)                                       326 } while (0)
503                                                   327 
504 #define ASSERTCMP(X, OP, Y)                       328 #define ASSERTCMP(X, OP, Y)                                             \
505 do {                                              329 do {                                                                    \
506         if (unlikely(!((X) OP (Y)))) {            330         if (unlikely(!((X) OP (Y)))) {                                  \
507                 pr_err("\n");                     331                 pr_err("\n");                                           \
508                 pr_err("Assertion failed\n");     332                 pr_err("Assertion failed\n");           \
509                 pr_err("%lx " #OP " %lx is fal    333                 pr_err("%lx " #OP " %lx is false\n",                    \
510                        (unsigned long)(X), (un    334                        (unsigned long)(X), (unsigned long)(Y));         \
511                 BUG();                            335                 BUG();                                                  \
512         }                                         336         }                                                               \
513 } while (0)                                       337 } while (0)
514                                                   338 
515 #define ASSERTIF(C, X)                            339 #define ASSERTIF(C, X)                                                  \
516 do {                                              340 do {                                                                    \
517         if (unlikely((C) && !(X))) {              341         if (unlikely((C) && !(X))) {                                    \
518                 pr_err("\n");                     342                 pr_err("\n");                                           \
519                 pr_err("Assertion failed\n");     343                 pr_err("Assertion failed\n");           \
520                 BUG();                            344                 BUG();                                                  \
521         }                                         345         }                                                               \
522 } while (0)                                       346 } while (0)
523                                                   347 
524 #define ASSERTIFCMP(C, X, OP, Y)                  348 #define ASSERTIFCMP(C, X, OP, Y)                                        \
525 do {                                              349 do {                                                                    \
526         if (unlikely((C) && !((X) OP (Y)))) {     350         if (unlikely((C) && !((X) OP (Y)))) {                           \
527                 pr_err("\n");                     351                 pr_err("\n");                                           \
528                 pr_err("Assertion failed\n");     352                 pr_err("Assertion failed\n");           \
529                 pr_err("%lx " #OP " %lx is fal    353                 pr_err("%lx " #OP " %lx is false\n",                    \
530                        (unsigned long)(X), (un    354                        (unsigned long)(X), (unsigned long)(Y));         \
531                 BUG();                            355                 BUG();                                                  \
532         }                                         356         }                                                               \
533 } while (0)                                       357 } while (0)
534                                                   358 
535 #else                                             359 #else
536                                                   360 
537 #define ASSERT(X)                       do {}     361 #define ASSERT(X)                       do {} while (0)
538 #define ASSERTCMP(X, OP, Y)             do {}     362 #define ASSERTCMP(X, OP, Y)             do {} while (0)
539 #define ASSERTIF(C, X)                  do {}     363 #define ASSERTIF(C, X)                  do {} while (0)
540 #define ASSERTIFCMP(C, X, OP, Y)        do {}     364 #define ASSERTIFCMP(C, X, OP, Y)        do {} while (0)
541                                                   365 
542 #endif                                            366 #endif
543                                                   367 

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