~ [ 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.1.21)


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

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