History

fscache: Implement cookie user counting and resource pinning

Provide a pair of functions to count the number of users of a cookie (open files, writeback, invalidation, resizing, reads, writes), to obtain and pin resources for the cookie and to prevent culling for the whilst there are users. The first function marks a cookie as being in use: void fscache_use_cookie(struct fscache_cookie *cookie, bool will_modify); The caller should indicate the cookie to use and whether or not the caller is in a context that may modify the cookie (e.g. a file open O_RDWR). If the cookie is not already resourced, fscache will ask the cache backend in the background to do whatever it needs to look up, create or otherwise obtain the resources necessary to access data. This is pinned to the cookie and may not be culled, though it may be withdrawn if the cache as a whole is withdrawn. The second function removes the in-use mark from a cookie and, optionally, updates the coherency data: void fscache_unuse_cookie(struct fscache_cookie *cookie, const void *aux_data, const loff_t *object_size); If non-NULL, the aux_data buffer and/or the object_size will be saved into the cookie and will be set on the backing store when the object is committed. If this removes the last usage on a cookie, the cookie is placed onto an LRU list from which it will be removed and closed after a couple of seconds if it doesn't get reused. This prevents resource overload in the cache - in particular it prevents it from holding too many files open. Changes ======= ver #2: - Fix fscache_unuse_cookie() to use atomic_dec_and_lock() to avoid a potential race if the cookie gets reused before it completes the unusement. - Added missing transition to LRU_DISCARDING state.

David Howells committed 5 years ago

Commit 12bb21a1 parent 5d00e425 files · +327 −2Browse files

Unified · Split

5 files
  1. fs/fscache/cookie.c +217 −1
  2. fs/fscache/internal.h +5 −0
  3. fs/fscache/stats.c +12 −0
  4. include/linux/fscache.h +81 −1
  5. include/trace/events/fscache.h +12 −0
fs/fscache/cookie.c+217−1
@@ -15,6 +15,8 @@ · 14 unmodified lines
15 15
16struct kmem_cache *fscache_cookie_jar;16struct kmem_cache *fscache_cookie_jar;
17 17
18static void fscache_cookie_lru_timed_out(struct timer_list *timer);
19static void fscache_cookie_lru_worker(struct work_struct *work);
18static void fscache_cookie_worker(struct work_struct *work);20static void fscache_cookie_worker(struct work_struct *work);
19static void fscache_unhash_cookie(struct fscache_cookie *cookie);21static void fscache_unhash_cookie(struct fscache_cookie *cookie);
20 22
@@ -22,7 +24,12 @@ static void fscache_unhash_cookie(struct fscache_cookie *cookie); · 1 unmodified line
22static struct hlist_bl_head fscache_cookie_hash[1 << fscache_cookie_hash_shift];24static struct hlist_bl_head fscache_cookie_hash[1 << fscache_cookie_hash_shift];
23static LIST_HEAD(fscache_cookies);25static LIST_HEAD(fscache_cookies);
24static DEFINE_RWLOCK(fscache_cookies_lock);26static DEFINE_RWLOCK(fscache_cookies_lock);
25static const char fscache_cookie_states[FSCACHE_COOKIE_STATE__NR] = "-LCAFWRD";27static LIST_HEAD(fscache_cookie_lru);
28static DEFINE_SPINLOCK(fscache_cookie_lru_lock);
29DEFINE_TIMER(fscache_cookie_lru_timer, fscache_cookie_lru_timed_out);
30static DECLARE_WORK(fscache_cookie_lru_work, fscache_cookie_lru_worker);
31static const char fscache_cookie_states[FSCACHE_COOKIE_STATE__NR] = "-LCAFUWRD";
32unsigned int fscache_lru_cookie_timeout = 10 * HZ;
26 33
27void fscache_print_cookie(struct fscache_cookie *cookie, char prefix)34void fscache_print_cookie(struct fscache_cookie *cookie, char prefix)
28{35{
@@ -47,6 +54,14 @@ void fscache_print_cookie(struct fscache_cookie *cookie, char prefix) · 18 unmodified lines
47 54
48static void fscache_free_cookie(struct fscache_cookie *cookie)55static void fscache_free_cookie(struct fscache_cookie *cookie)
49{56{
57 if (WARN_ON_ONCE(!list_empty(&cookie->commit_link))) {
58 spin_lock(&fscache_cookie_lru_lock);
59 list_del_init(&cookie->commit_link);
60 spin_unlock(&fscache_cookie_lru_lock);
61 fscache_stat_d(&fscache_n_cookies_lru);
62 fscache_stat(&fscache_n_cookies_lru_removed);
63 }
64
50 if (WARN_ON_ONCE(test_bit(FSCACHE_COOKIE_IS_HASHED, &cookie->flags))) {65 if (WARN_ON_ONCE(test_bit(FSCACHE_COOKIE_IS_HASHED, &cookie->flags))) {
51 fscache_print_cookie(cookie, 'F');66 fscache_print_cookie(cookie, 'F');
52 return;67 return;
@@ -498,6 +513,126 @@ out: · 445 unmodified lines
498 fscache_end_volume_access(cookie->volume, cookie, trace);513 fscache_end_volume_access(cookie->volume, cookie, trace);
499}514}
500 515
516/*
517 * Begin the process of looking up a cookie. We offload the actual process to
518 * a worker thread.
519 */
520static bool fscache_begin_lookup(struct fscache_cookie *cookie, bool will_modify)
521{
522 if (will_modify) {
523 set_bit(FSCACHE_COOKIE_LOCAL_WRITE, &cookie->flags);
524 set_bit(FSCACHE_COOKIE_DO_PREP_TO_WRITE, &cookie->flags);
525 }
526 if (!fscache_begin_volume_access(cookie->volume, cookie,
527 fscache_access_lookup_cookie))
528 return false;
529
530 __fscache_begin_cookie_access(cookie, fscache_access_lookup_cookie);
531 __fscache_set_cookie_state(cookie, FSCACHE_COOKIE_STATE_LOOKING_UP);
532 set_bit(FSCACHE_COOKIE_IS_CACHING, &cookie->flags);
533 set_bit(FSCACHE_COOKIE_HAS_BEEN_CACHED, &cookie->flags);
534 return true;
535}
536
537/*
538 * Start using the cookie for I/O. This prevents the backing object from being
539 * reaped by VM pressure.
540 */
541void __fscache_use_cookie(struct fscache_cookie *cookie, bool will_modify)
542{
543 enum fscache_cookie_state state;
544 bool queue = false;
545
546 _enter("c=%08x", cookie->debug_id);
547
548 if (WARN(test_bit(FSCACHE_COOKIE_RELINQUISHED, &cookie->flags),
549 "Trying to use relinquished cookie\n"))
550 return;
551
552 spin_lock(&cookie->lock);
553
554 atomic_inc(&cookie->n_active);
555
556again:
557 state = fscache_cookie_state(cookie);
558 switch (state) {
559 case FSCACHE_COOKIE_STATE_QUIESCENT:
560 queue = fscache_begin_lookup(cookie, will_modify);
561 break;
562
563 case FSCACHE_COOKIE_STATE_LOOKING_UP:
564 case FSCACHE_COOKIE_STATE_CREATING:
565 if (will_modify)
566 set_bit(FSCACHE_COOKIE_LOCAL_WRITE, &cookie->flags);
567 break;
568 case FSCACHE_COOKIE_STATE_ACTIVE:
569 if (will_modify &&
570 !test_and_set_bit(FSCACHE_COOKIE_LOCAL_WRITE, &cookie->flags)) {
571 set_bit(FSCACHE_COOKIE_DO_PREP_TO_WRITE, &cookie->flags);
572 queue = true;
573 }
574 break;
575
576 case FSCACHE_COOKIE_STATE_FAILED:
577 case FSCACHE_COOKIE_STATE_WITHDRAWING:
578 break;
579
580 case FSCACHE_COOKIE_STATE_LRU_DISCARDING:
581 spin_unlock(&cookie->lock);
582 wait_var_event(&cookie->state,
583 fscache_cookie_state(cookie) !=
584 FSCACHE_COOKIE_STATE_LRU_DISCARDING);
585 spin_lock(&cookie->lock);
586 goto again;
587
588 case FSCACHE_COOKIE_STATE_DROPPED:
589 case FSCACHE_COOKIE_STATE_RELINQUISHING:
590 WARN(1, "Can't use cookie in state %u\n", state);
591 break;
592 }
593
594 spin_unlock(&cookie->lock);
595 if (queue)
596 fscache_queue_cookie(cookie, fscache_cookie_get_use_work);
597 _leave("");
598}
599EXPORT_SYMBOL(__fscache_use_cookie);
600
601static void fscache_unuse_cookie_locked(struct fscache_cookie *cookie)
602{
603 clear_bit(FSCACHE_COOKIE_DISABLED, &cookie->flags);
604 if (!test_bit(FSCACHE_COOKIE_IS_CACHING, &cookie->flags))
605 return;
606
607 cookie->unused_at = jiffies;
608 spin_lock(&fscache_cookie_lru_lock);
609 if (list_empty(&cookie->commit_link)) {
610 fscache_get_cookie(cookie, fscache_cookie_get_lru);
611 fscache_stat(&fscache_n_cookies_lru);
612 }
613 list_move_tail(&cookie->commit_link, &fscache_cookie_lru);
614
615 spin_unlock(&fscache_cookie_lru_lock);
616 timer_reduce(&fscache_cookie_lru_timer,
617 jiffies + fscache_lru_cookie_timeout);
618}
619
620/*
621 * Stop using the cookie for I/O.
622 */
623void __fscache_unuse_cookie(struct fscache_cookie *cookie,
624 const void *aux_data, const loff_t *object_size)
625{
626 if (aux_data || object_size)
627 __fscache_update_cookie(cookie, aux_data, object_size);
628
629 if (atomic_dec_and_lock(&cookie->n_active, &cookie->lock)) {
630 fscache_unuse_cookie_locked(cookie);
631 spin_unlock(&cookie->lock);
632 }
633}
634EXPORT_SYMBOL(__fscache_unuse_cookie);
635
501/*636/*
502 * Perform work upon the cookie, such as committing its cache state,637 * Perform work upon the cookie, such as committing its cache state,
503 * relinquishing it or withdrawing the backing cache. We're protected from the638 * relinquishing it or withdrawing the backing cache. We're protected from the
@@ -542,6 +677,12 @@ again_locked: · 38 unmodified lines
542 fscache_prepare_to_write(cookie);677 fscache_prepare_to_write(cookie);
543 spin_lock(&cookie->lock);678 spin_lock(&cookie->lock);
544 }679 }
680 if (test_bit(FSCACHE_COOKIE_DO_LRU_DISCARD, &cookie->flags)) {
681 __fscache_set_cookie_state(cookie,
682 FSCACHE_COOKIE_STATE_LRU_DISCARDING);
683 wake = true;
684 goto again_locked;
685 }
545 fallthrough;686 fallthrough;
546 687
547 case FSCACHE_COOKIE_STATE_FAILED:688 case FSCACHE_COOKIE_STATE_FAILED:
@@ -561,6 +702,7 @@ again_locked: · 13 unmodified lines
561 }702 }
562 break;703 break;
563 704
705 case FSCACHE_COOKIE_STATE_LRU_DISCARDING:
564 case FSCACHE_COOKIE_STATE_RELINQUISHING:706 case FSCACHE_COOKIE_STATE_RELINQUISHING:
565 case FSCACHE_COOKIE_STATE_WITHDRAWING:707 case FSCACHE_COOKIE_STATE_WITHDRAWING:
566 if (cookie->cache_priv) {708 if (cookie->cache_priv) {
@@ -577,6 +719,9 @@ again_locked: · 10 unmodified lines
577 FSCACHE_COOKIE_STATE_DROPPED);719 FSCACHE_COOKIE_STATE_DROPPED);
578 wake = true;720 wake = true;
579 goto out;721 goto out;
722 case FSCACHE_COOKIE_STATE_LRU_DISCARDING:
723 fscache_see_cookie(cookie, fscache_cookie_see_lru_discard);
724 break;
580 case FSCACHE_COOKIE_STATE_WITHDRAWING:725 case FSCACHE_COOKIE_STATE_WITHDRAWING:
581 fscache_see_cookie(cookie, fscache_cookie_see_withdraw);726 fscache_see_cookie(cookie, fscache_cookie_see_withdraw);
582 break;727 break;
@@ -639,6 +784,76 @@ static void __fscache_withdraw_cookie(struct fscache_cookie *cookie) · 56 unmodified lines
639 fscache_queue_cookie(cookie, fscache_cookie_get_end_access);784 fscache_queue_cookie(cookie, fscache_cookie_get_end_access);
640}785}
641 786
787static void fscache_cookie_lru_do_one(struct fscache_cookie *cookie)
788{
789 fscache_see_cookie(cookie, fscache_cookie_see_lru_do_one);
790
791 spin_lock(&cookie->lock);
792 if (cookie->state != FSCACHE_COOKIE_STATE_ACTIVE ||
793 time_before(jiffies, cookie->unused_at + fscache_lru_cookie_timeout) ||
794 atomic_read(&cookie->n_active) > 0) {
795 spin_unlock(&cookie->lock);
796 fscache_stat(&fscache_n_cookies_lru_removed);
797 } else {
798 set_bit(FSCACHE_COOKIE_DO_LRU_DISCARD, &cookie->flags);
799 spin_unlock(&cookie->lock);
800 fscache_stat(&fscache_n_cookies_lru_expired);
801 _debug("lru c=%x", cookie->debug_id);
802 __fscache_withdraw_cookie(cookie);
803 }
804
805 fscache_put_cookie(cookie, fscache_cookie_put_lru);
806}
807
808static void fscache_cookie_lru_worker(struct work_struct *work)
809{
810 struct fscache_cookie *cookie;
811 unsigned long unused_at;
812
813 spin_lock(&fscache_cookie_lru_lock);
814
815 while (!list_empty(&fscache_cookie_lru)) {
816 cookie = list_first_entry(&fscache_cookie_lru,
817 struct fscache_cookie, commit_link);
818 unused_at = cookie->unused_at + fscache_lru_cookie_timeout;
819 if (time_before(jiffies, unused_at)) {
820 timer_reduce(&fscache_cookie_lru_timer, unused_at);
821 break;
822 }
823
824 list_del_init(&cookie->commit_link);
825 fscache_stat_d(&fscache_n_cookies_lru);
826 spin_unlock(&fscache_cookie_lru_lock);
827 fscache_cookie_lru_do_one(cookie);
828 spin_lock(&fscache_cookie_lru_lock);
829 }
830
831 spin_unlock(&fscache_cookie_lru_lock);
832}
833
834static void fscache_cookie_lru_timed_out(struct timer_list *timer)
835{
836 queue_work(fscache_wq, &fscache_cookie_lru_work);
837}
838
839static void fscache_cookie_drop_from_lru(struct fscache_cookie *cookie)
840{
841 bool need_put = false;
842
843 if (!list_empty(&cookie->commit_link)) {
844 spin_lock(&fscache_cookie_lru_lock);
845 if (!list_empty(&cookie->commit_link)) {
846 list_del_init(&cookie->commit_link);
847 fscache_stat_d(&fscache_n_cookies_lru);
848 fscache_stat(&fscache_n_cookies_lru_dropped);
849 need_put = true;
850 }
851 spin_unlock(&fscache_cookie_lru_lock);
852 if (need_put)
853 fscache_put_cookie(cookie, fscache_cookie_put_lru);
854 }
855}
856
642/*857/*
643 * Remove a cookie from the hash table.858 * Remove a cookie from the hash table.
644 */859 */
@@ -659,6 +874,7 @@ static void fscache_unhash_cookie(struct fscache_cookie *cookie) · 14 unmodified lines
659 874
660static void fscache_drop_withdraw_cookie(struct fscache_cookie *cookie)875static void fscache_drop_withdraw_cookie(struct fscache_cookie *cookie)
661{876{
877 fscache_cookie_drop_from_lru(cookie);
662 __fscache_withdraw_cookie(cookie);878 __fscache_withdraw_cookie(cookie);
663}879}
664 880
fs/fscache/internal.h+5−0
@@ -57,6 +57,7 @@ static inline bool fscache_set_cache_state_maybe(struct fscache_cache *cache, · 56 unmodified lines
57 */57 */
58extern struct kmem_cache *fscache_cookie_jar;58extern struct kmem_cache *fscache_cookie_jar;
59extern const struct seq_operations fscache_cookies_seq_ops;59extern const struct seq_operations fscache_cookies_seq_ops;
60extern struct timer_list fscache_cookie_lru_timer;
60 61
61extern void fscache_print_cookie(struct fscache_cookie *cookie, char prefix);62extern void fscache_print_cookie(struct fscache_cookie *cookie, char prefix);
62extern bool fscache_begin_cookie_access(struct fscache_cookie *cookie,63extern bool fscache_begin_cookie_access(struct fscache_cookie *cookie,
@@ -95,6 +96,10 @@ extern atomic_t fscache_n_volumes; · 32 unmodified lines
95extern atomic_t fscache_n_volumes_collision;96extern atomic_t fscache_n_volumes_collision;
96extern atomic_t fscache_n_volumes_nomem;97extern atomic_t fscache_n_volumes_nomem;
97extern atomic_t fscache_n_cookies;98extern atomic_t fscache_n_cookies;
99extern atomic_t fscache_n_cookies_lru;
100extern atomic_t fscache_n_cookies_lru_expired;
101extern atomic_t fscache_n_cookies_lru_removed;
102extern atomic_t fscache_n_cookies_lru_dropped;
98 103
99extern atomic_t fscache_n_acquires;104extern atomic_t fscache_n_acquires;
100extern atomic_t fscache_n_acquires_ok;105extern atomic_t fscache_n_acquires_ok;
fs/fscache/stats.c+12−0
@@ -17,6 +17,10 @@ atomic_t fscache_n_volumes; · 16 unmodified lines
17atomic_t fscache_n_volumes_collision;17atomic_t fscache_n_volumes_collision;
18atomic_t fscache_n_volumes_nomem;18atomic_t fscache_n_volumes_nomem;
19atomic_t fscache_n_cookies;19atomic_t fscache_n_cookies;
20atomic_t fscache_n_cookies_lru;
21atomic_t fscache_n_cookies_lru_expired;
22atomic_t fscache_n_cookies_lru_removed;
23atomic_t fscache_n_cookies_lru_dropped;
20 24
21atomic_t fscache_n_acquires;25atomic_t fscache_n_acquires;
22atomic_t fscache_n_acquires_ok;26atomic_t fscache_n_acquires_ok;
@@ -47,6 +51,14 @@ int fscache_stats_show(struct seq_file *m, void *v) · 24 unmodified lines
47 atomic_read(&fscache_n_acquires_ok),51 atomic_read(&fscache_n_acquires_ok),
48 atomic_read(&fscache_n_acquires_oom));52 atomic_read(&fscache_n_acquires_oom));
49 53
54 seq_printf(m, "LRU : n=%u exp=%u rmv=%u drp=%u at=%ld\n",
55 atomic_read(&fscache_n_cookies_lru),
56 atomic_read(&fscache_n_cookies_lru_expired),
57 atomic_read(&fscache_n_cookies_lru_removed),
58 atomic_read(&fscache_n_cookies_lru_dropped),
59 timer_pending(&fscache_cookie_lru_timer) ?
60 fscache_cookie_lru_timer.expires - jiffies : 0);
61
50 seq_printf(m, "Updates: n=%u\n",62 seq_printf(m, "Updates: n=%u\n",
51 atomic_read(&fscache_n_updates));63 atomic_read(&fscache_n_updates));
52 64
include/linux/fscache.h+81−1
@@ -22,12 +22,14 @@ · 21 unmodified lines
22#define fscache_available() (1)22#define fscache_available() (1)
23#define fscache_volume_valid(volume) (volume)23#define fscache_volume_valid(volume) (volume)
24#define fscache_cookie_valid(cookie) (cookie)24#define fscache_cookie_valid(cookie) (cookie)
25#define fscache_cookie_enabled(cookie) (cookie)25#define fscache_resources_valid(cres) ((cres)->cache_priv)
26#define fscache_cookie_enabled(cookie) (cookie && !test_bit(FSCACHE_COOKIE_DISABLED, &cookie->flags))
26#else27#else
27#define __fscache_available (0)28#define __fscache_available (0)
28#define fscache_available() (0)29#define fscache_available() (0)
29#define fscache_volume_valid(volume) (0)30#define fscache_volume_valid(volume) (0)
30#define fscache_cookie_valid(cookie) (0)31#define fscache_cookie_valid(cookie) (0)
32#define fscache_resources_valid(cres) (false)
31#define fscache_cookie_enabled(cookie) (0)33#define fscache_cookie_enabled(cookie) (0)
32#endif34#endif
33 35
@@ -46,6 +48,7 @@ enum fscache_cookie_state { · 12 unmodified lines
46 FSCACHE_COOKIE_STATE_CREATING, /* The cache object is being created */48 FSCACHE_COOKIE_STATE_CREATING, /* The cache object is being created */
47 FSCACHE_COOKIE_STATE_ACTIVE, /* The cache is active, readable and writable */49 FSCACHE_COOKIE_STATE_ACTIVE, /* The cache is active, readable and writable */
48 FSCACHE_COOKIE_STATE_FAILED, /* The cache failed, withdraw to clear */50 FSCACHE_COOKIE_STATE_FAILED, /* The cache failed, withdraw to clear */
51 FSCACHE_COOKIE_STATE_LRU_DISCARDING, /* The cookie is being discarded by the LRU */
49 FSCACHE_COOKIE_STATE_WITHDRAWING, /* The cookie is being withdrawn */52 FSCACHE_COOKIE_STATE_WITHDRAWING, /* The cookie is being withdrawn */
50 FSCACHE_COOKIE_STATE_RELINQUISHING, /* The cookie is being relinquished */53 FSCACHE_COOKIE_STATE_RELINQUISHING, /* The cookie is being relinquished */
51 FSCACHE_COOKIE_STATE_DROPPED, /* The cookie has been dropped */54 FSCACHE_COOKIE_STATE_DROPPED, /* The cookie has been dropped */
@@ -147,6 +150,8 @@ extern struct fscache_cookie *__fscache_acquire_cookie( · 95 unmodified lines
147 const void *, size_t,150 const void *, size_t,
148 const void *, size_t,151 const void *, size_t,
149 loff_t);152 loff_t);
153extern void __fscache_use_cookie(struct fscache_cookie *, bool);
154extern void __fscache_unuse_cookie(struct fscache_cookie *, const void *, const loff_t *);
150extern void __fscache_relinquish_cookie(struct fscache_cookie *, bool);155extern void __fscache_relinquish_cookie(struct fscache_cookie *, bool);
151 156
152/**157/**
@@ -228,6 +233,39 @@ struct fscache_cookie *fscache_acquire_cookie(struct fscache_volume *volume, · 75 unmodified lines
228 object_size);233 object_size);
229}234}
230 235
236/**
237 * fscache_use_cookie - Request usage of cookie attached to an object
238 * @object: Object description
239 * @will_modify: If cache is expected to be modified locally
240 *
241 * Request usage of the cookie attached to an object. The caller should tell
242 * the cache if the object's contents are about to be modified locally and then
243 * the cache can apply the policy that has been set to handle this case.
244 */
245static inline void fscache_use_cookie(struct fscache_cookie *cookie,
246 bool will_modify)
247{
248 if (fscache_cookie_valid(cookie))
249 __fscache_use_cookie(cookie, will_modify);
250}
251
252/**
253 * fscache_unuse_cookie - Cease usage of cookie attached to an object
254 * @object: Object description
255 * @aux_data: Updated auxiliary data (or NULL)
256 * @object_size: Revised size of the object (or NULL)
257 *
258 * Cease usage of the cookie attached to an object. When the users count
259 * reaches zero then the cookie relinquishment will be permitted to proceed.
260 */
261static inline void fscache_unuse_cookie(struct fscache_cookie *cookie,
262 const void *aux_data,
263 const loff_t *object_size)
264{
265 if (fscache_cookie_valid(cookie))
266 __fscache_unuse_cookie(cookie, aux_data, object_size);
267}
268
231/**269/**
232 * fscache_relinquish_cookie - Return the cookie to the cache, maybe discarding270 * fscache_relinquish_cookie - Return the cookie to the cache, maybe discarding
233 * it271 * it
@@ -247,4 +285,46 @@ void fscache_relinquish_cookie(struct fscache_cookie *cookie, bool retire) · 13 unmodified lines
247 __fscache_relinquish_cookie(cookie, retire);285 __fscache_relinquish_cookie(cookie, retire);
248}286}
249 287
288/*
289 * Find the auxiliary data on a cookie.
290 */
291static inline void *fscache_get_aux(struct fscache_cookie *cookie)
292{
293 if (cookie->aux_len <= sizeof(cookie->inline_aux))
294 return cookie->inline_aux;
295 else
296 return cookie->aux;
297}
298
299/*
300 * Update the auxiliary data on a cookie.
301 */
302static inline
303void fscache_update_aux(struct fscache_cookie *cookie,
304 const void *aux_data, const loff_t *object_size)
305{
306 void *p = fscache_get_aux(cookie);
307
308 if (aux_data && p)
309 memcpy(p, aux_data, cookie->aux_len);
310 if (object_size)
311 cookie->object_size = *object_size;
312}
313
314#ifdef CONFIG_FSCACHE_STATS
315extern atomic_t fscache_n_updates;
316#endif
317
318static inline
319void __fscache_update_cookie(struct fscache_cookie *cookie, const void *aux_data,
320 const loff_t *object_size)
321{
322#ifdef CONFIG_FSCACHE_STATS
323 atomic_inc(&fscache_n_updates);
324#endif
325 fscache_update_aux(cookie, aux_data, object_size);
326 smp_wmb();
327 set_bit(FSCACHE_COOKIE_NEEDS_UPDATE, &cookie->flags);
328}
329
250#endif /* _LINUX_FSCACHE_H */330#endif /* _LINUX_FSCACHE_H */
include/trace/events/fscache.h+12−0
@@ -51,13 +51,18 @@ enum fscache_cookie_trace { · 50 unmodified lines
51 fscache_cookie_discard,51 fscache_cookie_discard,
52 fscache_cookie_get_end_access,52 fscache_cookie_get_end_access,
53 fscache_cookie_get_hash_collision,53 fscache_cookie_get_hash_collision,
54 fscache_cookie_get_lru,
55 fscache_cookie_get_use_work,
54 fscache_cookie_new_acquire,56 fscache_cookie_new_acquire,
55 fscache_cookie_put_hash_collision,57 fscache_cookie_put_hash_collision,
58 fscache_cookie_put_lru,
56 fscache_cookie_put_over_queued,59 fscache_cookie_put_over_queued,
57 fscache_cookie_put_relinquish,60 fscache_cookie_put_relinquish,
58 fscache_cookie_put_withdrawn,61 fscache_cookie_put_withdrawn,
59 fscache_cookie_put_work,62 fscache_cookie_put_work,
60 fscache_cookie_see_active,63 fscache_cookie_see_active,
64 fscache_cookie_see_lru_discard,
65 fscache_cookie_see_lru_do_one,
61 fscache_cookie_see_relinquish,66 fscache_cookie_see_relinquish,
62 fscache_cookie_see_withdraw,67 fscache_cookie_see_withdraw,
63 fscache_cookie_see_work,68 fscache_cookie_see_work,
@@ -68,6 +73,7 @@ enum fscache_access_trace { · 4 unmodified lines
68 fscache_access_acquire_volume_end,73 fscache_access_acquire_volume_end,
69 fscache_access_cache_pin,74 fscache_access_cache_pin,
70 fscache_access_cache_unpin,75 fscache_access_cache_unpin,
76 fscache_access_lookup_cookie,
71 fscache_access_lookup_cookie_end,77 fscache_access_lookup_cookie_end,
72 fscache_access_lookup_cookie_end_failed,78 fscache_access_lookup_cookie_end_failed,
73 fscache_access_relinquish_volume,79 fscache_access_relinquish_volume,
@@ -110,13 +116,18 @@ enum fscache_access_trace { · 36 unmodified lines
110 EM(fscache_cookie_discard, "DISCARD ") \116 EM(fscache_cookie_discard, "DISCARD ") \
111 EM(fscache_cookie_get_hash_collision, "GET hcoll") \117 EM(fscache_cookie_get_hash_collision, "GET hcoll") \
112 EM(fscache_cookie_get_end_access, "GQ endac") \118 EM(fscache_cookie_get_end_access, "GQ endac") \
119 EM(fscache_cookie_get_lru, "GET lru ") \
120 EM(fscache_cookie_get_use_work, "GQ use ") \
113 EM(fscache_cookie_new_acquire, "NEW acq ") \121 EM(fscache_cookie_new_acquire, "NEW acq ") \
114 EM(fscache_cookie_put_hash_collision, "PUT hcoll") \122 EM(fscache_cookie_put_hash_collision, "PUT hcoll") \
123 EM(fscache_cookie_put_lru, "PUT lru ") \
115 EM(fscache_cookie_put_over_queued, "PQ overq") \124 EM(fscache_cookie_put_over_queued, "PQ overq") \
116 EM(fscache_cookie_put_relinquish, "PUT relnq") \125 EM(fscache_cookie_put_relinquish, "PUT relnq") \
117 EM(fscache_cookie_put_withdrawn, "PUT wthdn") \126 EM(fscache_cookie_put_withdrawn, "PUT wthdn") \
118 EM(fscache_cookie_put_work, "PQ work ") \127 EM(fscache_cookie_put_work, "PQ work ") \
119 EM(fscache_cookie_see_active, "- activ") \128 EM(fscache_cookie_see_active, "- activ") \
129 EM(fscache_cookie_see_lru_discard, "- x-lru") \
130 EM(fscache_cookie_see_lru_do_one, "- lrudo") \
120 EM(fscache_cookie_see_relinquish, "- x-rlq") \131 EM(fscache_cookie_see_relinquish, "- x-rlq") \
121 EM(fscache_cookie_see_withdraw, "- x-wth") \132 EM(fscache_cookie_see_withdraw, "- x-wth") \
122 E_(fscache_cookie_see_work, "- work ")133 E_(fscache_cookie_see_work, "- work ")
@@ -126,6 +137,7 @@ enum fscache_access_trace { · 3 unmodified lines
126 EM(fscache_access_acquire_volume_end, "END acq_vol") \137 EM(fscache_access_acquire_volume_end, "END acq_vol") \
127 EM(fscache_access_cache_pin, "PIN cache ") \138 EM(fscache_access_cache_pin, "PIN cache ") \
128 EM(fscache_access_cache_unpin, "UNPIN cache ") \139 EM(fscache_access_cache_unpin, "UNPIN cache ") \
140 EM(fscache_access_lookup_cookie, "BEGIN lookup ") \
129 EM(fscache_access_lookup_cookie_end, "END lookup ") \141 EM(fscache_access_lookup_cookie_end, "END lookup ") \
130 EM(fscache_access_lookup_cookie_end_failed,"END lookupf") \142 EM(fscache_access_lookup_cookie_end_failed,"END lookupf") \
131 EM(fscache_access_relinquish_volume, "BEGIN rlq_vol") \143 EM(fscache_access_relinquish_volume, "BEGIN rlq_vol") \

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t