aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/fscache-cache.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/linux/fscache-cache.h')
-rw-r--r--include/linux/fscache-cache.h50
1 files changed, 18 insertions, 32 deletions
diff --git a/include/linux/fscache-cache.h b/include/linux/fscache-cache.h
index 7823e9ef995e..771484993ca7 100644
--- a/include/linux/fscache-cache.h
+++ b/include/linux/fscache-cache.h
@@ -308,36 +308,6 @@ struct fscache_cache_ops {
308 void (*dissociate_pages)(struct fscache_cache *cache); 308 void (*dissociate_pages)(struct fscache_cache *cache);
309}; 309};
310 310
311/*
312 * data file or index object cookie
313 * - a file will only appear in one cache
314 * - a request to cache a file may or may not be honoured, subject to
315 * constraints such as disk space
316 * - indices are created on disk just-in-time
317 */
318struct fscache_cookie {
319 atomic_t usage; /* number of users of this cookie */
320 atomic_t n_children; /* number of children of this cookie */
321 atomic_t n_active; /* number of active users of netfs ptrs */
322 spinlock_t lock;
323 spinlock_t stores_lock; /* lock on page store tree */
324 struct hlist_head backing_objects; /* object(s) backing this file/index */
325 const struct fscache_cookie_def *def; /* definition */
326 struct fscache_cookie *parent; /* parent of this entry */
327 void *netfs_data; /* back pointer to netfs */
328 struct radix_tree_root stores; /* pages to be stored on this cookie */
329#define FSCACHE_COOKIE_PENDING_TAG 0 /* pages tag: pending write to cache */
330#define FSCACHE_COOKIE_STORING_TAG 1 /* pages tag: writing to cache */
331
332 unsigned long flags;
333#define FSCACHE_COOKIE_LOOKING_UP 0 /* T if non-index cookie being looked up still */
334#define FSCACHE_COOKIE_NO_DATA_YET 1 /* T if new object with no cached data yet */
335#define FSCACHE_COOKIE_UNAVAILABLE 2 /* T if cookie is unavailable (error, etc) */
336#define FSCACHE_COOKIE_INVALIDATING 3 /* T if cookie is being invalidated */
337#define FSCACHE_COOKIE_RELINQUISHED 4 /* T if cookie has been relinquished */
338#define FSCACHE_COOKIE_RETIRED 5 /* T if cookie was retired */
339};
340
341extern struct fscache_cookie fscache_fsdef_index; 311extern struct fscache_cookie fscache_fsdef_index;
342 312
343/* 313/*
@@ -400,6 +370,7 @@ struct fscache_object {
400#define FSCACHE_OBJECT_IS_LIVE 3 /* T if object is not withdrawn or relinquished */ 370#define FSCACHE_OBJECT_IS_LIVE 3 /* T if object is not withdrawn or relinquished */
401#define FSCACHE_OBJECT_IS_LOOKED_UP 4 /* T if object has been looked up */ 371#define FSCACHE_OBJECT_IS_LOOKED_UP 4 /* T if object has been looked up */
402#define FSCACHE_OBJECT_IS_AVAILABLE 5 /* T if object has become active */ 372#define FSCACHE_OBJECT_IS_AVAILABLE 5 /* T if object has become active */
373#define FSCACHE_OBJECT_RETIRED 6 /* T if object was retired on relinquishment */
403 374
404 struct list_head cache_link; /* link in cache->object_list */ 375 struct list_head cache_link; /* link in cache->object_list */
405 struct hlist_node cookie_link; /* link in cookie->backing_objects */ 376 struct hlist_node cookie_link; /* link in cookie->backing_objects */
@@ -511,6 +482,11 @@ static inline void fscache_end_io(struct fscache_retrieval *op,
511 op->end_io_func(page, op->context, error); 482 op->end_io_func(page, op->context, error);
512} 483}
513 484
485static inline void __fscache_use_cookie(struct fscache_cookie *cookie)
486{
487 atomic_inc(&cookie->n_active);
488}
489
514/** 490/**
515 * fscache_use_cookie - Request usage of cookie attached to an object 491 * fscache_use_cookie - Request usage of cookie attached to an object
516 * @object: Object description 492 * @object: Object description
@@ -524,6 +500,16 @@ static inline bool fscache_use_cookie(struct fscache_object *object)
524 return atomic_inc_not_zero(&cookie->n_active) != 0; 500 return atomic_inc_not_zero(&cookie->n_active) != 0;
525} 501}
526 502
503static inline bool __fscache_unuse_cookie(struct fscache_cookie *cookie)
504{
505 return atomic_dec_and_test(&cookie->n_active);
506}
507
508static inline void __fscache_wake_unused_cookie(struct fscache_cookie *cookie)
509{
510 wake_up_atomic_t(&cookie->n_active);
511}
512
527/** 513/**
528 * fscache_unuse_cookie - Cease usage of cookie attached to an object 514 * fscache_unuse_cookie - Cease usage of cookie attached to an object
529 * @object: Object description 515 * @object: Object description
@@ -534,8 +520,8 @@ static inline bool fscache_use_cookie(struct fscache_object *object)
534static inline void fscache_unuse_cookie(struct fscache_object *object) 520static inline void fscache_unuse_cookie(struct fscache_object *object)
535{ 521{
536 struct fscache_cookie *cookie = object->cookie; 522 struct fscache_cookie *cookie = object->cookie;
537 if (atomic_dec_and_test(&cookie->n_active)) 523 if (__fscache_unuse_cookie(cookie))
538 wake_up_atomic_t(&cookie->n_active); 524 __fscache_wake_unused_cookie(cookie);
539} 525}
540 526
541/* 527/*