Lines Matching refs:cookie
21 static void fscache_unhash_cookie(struct fscache_cookie *cookie);
22 static void fscache_perform_invalidation(struct fscache_cookie *cookie);
35 void fscache_print_cookie(struct fscache_cookie *cookie, char prefix) in fscache_print_cookie() argument
41 cookie->debug_id, in fscache_print_cookie()
42 cookie->flags, in fscache_print_cookie()
43 atomic_read(&cookie->n_active), in fscache_print_cookie()
44 atomic_read(&cookie->n_accesses), in fscache_print_cookie()
45 fscache_cookie_states[cookie->state]); in fscache_print_cookie()
48 cookie->volume->debug_id, in fscache_print_cookie()
49 cookie->volume->key); in fscache_print_cookie()
51 k = (cookie->key_len <= sizeof(cookie->inline_key)) ? in fscache_print_cookie()
52 cookie->inline_key : cookie->key; in fscache_print_cookie()
53 pr_err("%c-key=[%u] '%*phN'\n", prefix, cookie->key_len, cookie->key_len, k); in fscache_print_cookie()
56 static void fscache_free_cookie(struct fscache_cookie *cookie) in fscache_free_cookie() argument
58 if (WARN_ON_ONCE(!list_empty(&cookie->commit_link))) { in fscache_free_cookie()
60 list_del_init(&cookie->commit_link); in fscache_free_cookie()
66 if (WARN_ON_ONCE(test_bit(FSCACHE_COOKIE_IS_HASHED, &cookie->flags))) { in fscache_free_cookie()
67 fscache_print_cookie(cookie, 'F'); in fscache_free_cookie()
72 list_del(&cookie->proc_link); in fscache_free_cookie()
74 if (cookie->aux_len > sizeof(cookie->inline_aux)) in fscache_free_cookie()
75 kfree(cookie->aux); in fscache_free_cookie()
76 if (cookie->key_len > sizeof(cookie->inline_key)) in fscache_free_cookie()
77 kfree(cookie->key); in fscache_free_cookie()
79 kmem_cache_free(fscache_cookie_jar, cookie); in fscache_free_cookie()
82 static void __fscache_queue_cookie(struct fscache_cookie *cookie) in __fscache_queue_cookie() argument
84 if (!queue_work(fscache_wq, &cookie->work)) in __fscache_queue_cookie()
85 fscache_put_cookie(cookie, fscache_cookie_put_over_queued); in __fscache_queue_cookie()
88 static void fscache_queue_cookie(struct fscache_cookie *cookie, in fscache_queue_cookie() argument
91 fscache_get_cookie(cookie, where); in fscache_queue_cookie()
92 __fscache_queue_cookie(cookie); in fscache_queue_cookie()
101 static void fscache_init_access_gate(struct fscache_cookie *cookie) in fscache_init_access_gate() argument
105 n_accesses = atomic_read(&cookie->n_accesses); in fscache_init_access_gate()
106 trace_fscache_access(cookie->debug_id, refcount_read(&cookie->ref), in fscache_init_access_gate()
108 set_bit(FSCACHE_COOKIE_NO_ACCESS_WAKE, &cookie->flags); in fscache_init_access_gate()
121 void fscache_end_cookie_access(struct fscache_cookie *cookie, in fscache_end_cookie_access() argument
127 n_accesses = atomic_dec_return(&cookie->n_accesses); in fscache_end_cookie_access()
128 trace_fscache_access(cookie->debug_id, refcount_read(&cookie->ref), in fscache_end_cookie_access()
131 !test_bit(FSCACHE_COOKIE_NO_ACCESS_WAKE, &cookie->flags)) in fscache_end_cookie_access()
132 fscache_queue_cookie(cookie, fscache_cookie_get_end_access); in fscache_end_cookie_access()
139 static void __fscache_begin_cookie_access(struct fscache_cookie *cookie, in __fscache_begin_cookie_access() argument
144 n_accesses = atomic_inc_return(&cookie->n_accesses); in __fscache_begin_cookie_access()
148 trace_fscache_access(cookie->debug_id, refcount_read(&cookie->ref), in __fscache_begin_cookie_access()
178 bool fscache_begin_cookie_access(struct fscache_cookie *cookie, in fscache_begin_cookie_access() argument
181 if (!test_bit(FSCACHE_COOKIE_IS_CACHING, &cookie->flags)) in fscache_begin_cookie_access()
183 __fscache_begin_cookie_access(cookie, why); in fscache_begin_cookie_access()
184 if (!test_bit(FSCACHE_COOKIE_IS_CACHING, &cookie->flags) || in fscache_begin_cookie_access()
185 !fscache_cache_is_live(cookie->volume->cache)) { in fscache_begin_cookie_access()
186 fscache_end_cookie_access(cookie, fscache_access_unlive); in fscache_begin_cookie_access()
192 static inline void wake_up_cookie_state(struct fscache_cookie *cookie) in wake_up_cookie_state() argument
200 wake_up_var(&cookie->state); in wake_up_cookie_state()
208 static void __fscache_set_cookie_state(struct fscache_cookie *cookie, in __fscache_set_cookie_state() argument
211 smp_store_release(&cookie->state, state); in __fscache_set_cookie_state()
214 static void fscache_set_cookie_state(struct fscache_cookie *cookie, in fscache_set_cookie_state() argument
217 spin_lock(&cookie->lock); in fscache_set_cookie_state()
218 __fscache_set_cookie_state(cookie, state); in fscache_set_cookie_state()
219 spin_unlock(&cookie->lock); in fscache_set_cookie_state()
220 wake_up_cookie_state(cookie); in fscache_set_cookie_state()
233 void fscache_cookie_lookup_negative(struct fscache_cookie *cookie) in fscache_cookie_lookup_negative() argument
235 set_bit(FSCACHE_COOKIE_NO_DATA_TO_READ, &cookie->flags); in fscache_cookie_lookup_negative()
236 fscache_set_cookie_state(cookie, FSCACHE_COOKIE_STATE_CREATING); in fscache_cookie_lookup_negative()
247 void fscache_resume_after_invalidation(struct fscache_cookie *cookie) in fscache_resume_after_invalidation() argument
249 fscache_set_cookie_state(cookie, FSCACHE_COOKIE_STATE_ACTIVE); in fscache_resume_after_invalidation()
262 void fscache_caching_failed(struct fscache_cookie *cookie) in fscache_caching_failed() argument
264 clear_bit(FSCACHE_COOKIE_IS_CACHING, &cookie->flags); in fscache_caching_failed()
265 fscache_set_cookie_state(cookie, FSCACHE_COOKIE_STATE_FAILED); in fscache_caching_failed()
266 trace_fscache_cookie(cookie->debug_id, refcount_read(&cookie->ref), in fscache_caching_failed()
277 static int fscache_set_key(struct fscache_cookie *cookie, in fscache_set_key() argument
285 if (index_key_len > sizeof(cookie->inline_key)) { in fscache_set_key()
289 cookie->key = buf; in fscache_set_key()
291 buf = cookie->inline_key; in fscache_set_key()
295 cookie->key_hash = fscache_hash(cookie->volume->key_hash, in fscache_set_key()
332 struct fscache_cookie *cookie; in fscache_alloc_cookie() local
335 cookie = kmem_cache_zalloc(fscache_cookie_jar, GFP_KERNEL); in fscache_alloc_cookie()
336 if (!cookie) in fscache_alloc_cookie()
340 cookie->volume = volume; in fscache_alloc_cookie()
341 cookie->advice = advice; in fscache_alloc_cookie()
342 cookie->key_len = index_key_len; in fscache_alloc_cookie()
343 cookie->aux_len = aux_data_len; in fscache_alloc_cookie()
344 cookie->object_size = object_size; in fscache_alloc_cookie()
346 __set_bit(FSCACHE_COOKIE_NO_DATA_TO_READ, &cookie->flags); in fscache_alloc_cookie()
348 if (fscache_set_key(cookie, index_key, index_key_len) < 0) in fscache_alloc_cookie()
351 if (cookie->aux_len <= sizeof(cookie->inline_aux)) { in fscache_alloc_cookie()
352 memcpy(cookie->inline_aux, aux_data, cookie->aux_len); in fscache_alloc_cookie()
354 cookie->aux = kmemdup(aux_data, cookie->aux_len, GFP_KERNEL); in fscache_alloc_cookie()
355 if (!cookie->aux) in fscache_alloc_cookie()
359 refcount_set(&cookie->ref, 1); in fscache_alloc_cookie()
360 cookie->debug_id = atomic_inc_return(&fscache_cookie_debug_id); in fscache_alloc_cookie()
361 spin_lock_init(&cookie->lock); in fscache_alloc_cookie()
362 INIT_LIST_HEAD(&cookie->commit_link); in fscache_alloc_cookie()
363 INIT_WORK(&cookie->work, fscache_cookie_worker); in fscache_alloc_cookie()
364 __fscache_set_cookie_state(cookie, FSCACHE_COOKIE_STATE_QUIESCENT); in fscache_alloc_cookie()
367 list_add_tail(&cookie->proc_link, &fscache_cookies); in fscache_alloc_cookie()
369 fscache_see_cookie(cookie, fscache_cookie_new_acquire); in fscache_alloc_cookie()
370 return cookie; in fscache_alloc_cookie()
373 fscache_free_cookie(cookie); in fscache_alloc_cookie()
377 static inline bool fscache_cookie_is_dropped(struct fscache_cookie *cookie) in fscache_cookie_is_dropped() argument
379 return READ_ONCE(cookie->state) == FSCACHE_COOKIE_STATE_DROPPED; in fscache_cookie_is_dropped()
457 struct fscache_cookie *cookie; in __fscache_acquire_cookie() local
470 cookie = fscache_alloc_cookie(volume, advice, in __fscache_acquire_cookie()
474 if (!cookie) { in __fscache_acquire_cookie()
479 if (!fscache_hash_cookie(cookie)) { in __fscache_acquire_cookie()
480 fscache_see_cookie(cookie, fscache_cookie_discard); in __fscache_acquire_cookie()
481 fscache_free_cookie(cookie); in __fscache_acquire_cookie()
485 trace_fscache_acquire(cookie); in __fscache_acquire_cookie()
487 _leave(" = c=%08x", cookie->debug_id); in __fscache_acquire_cookie()
488 return cookie; in __fscache_acquire_cookie()
495 static void fscache_prepare_to_write(struct fscache_cookie *cookie) in fscache_prepare_to_write() argument
497 cookie->volume->cache->ops->prepare_to_write(cookie); in fscache_prepare_to_write()
503 static void fscache_perform_lookup(struct fscache_cookie *cookie) in fscache_perform_lookup() argument
510 if (!cookie->volume->cache_priv) { in fscache_perform_lookup()
511 fscache_create_volume(cookie->volume, true); in fscache_perform_lookup()
512 if (!cookie->volume->cache_priv) { in fscache_perform_lookup()
513 fscache_set_cookie_state(cookie, FSCACHE_COOKIE_STATE_QUIESCENT); in fscache_perform_lookup()
518 if (!cookie->volume->cache->ops->lookup_cookie(cookie)) { in fscache_perform_lookup()
519 if (cookie->state != FSCACHE_COOKIE_STATE_FAILED) in fscache_perform_lookup()
520 fscache_set_cookie_state(cookie, FSCACHE_COOKIE_STATE_QUIESCENT); in fscache_perform_lookup()
526 fscache_see_cookie(cookie, fscache_cookie_see_active); in fscache_perform_lookup()
527 spin_lock(&cookie->lock); in fscache_perform_lookup()
528 if (test_and_clear_bit(FSCACHE_COOKIE_DO_INVALIDATE, &cookie->flags)) in fscache_perform_lookup()
529 __fscache_set_cookie_state(cookie, in fscache_perform_lookup()
532 __fscache_set_cookie_state(cookie, FSCACHE_COOKIE_STATE_ACTIVE); in fscache_perform_lookup()
533 spin_unlock(&cookie->lock); in fscache_perform_lookup()
534 wake_up_cookie_state(cookie); in fscache_perform_lookup()
538 fscache_end_cookie_access(cookie, trace); in fscache_perform_lookup()
540 fscache_withdraw_cookie(cookie); in fscache_perform_lookup()
541 fscache_end_volume_access(cookie->volume, cookie, trace); in fscache_perform_lookup()
548 static bool fscache_begin_lookup(struct fscache_cookie *cookie, bool will_modify) in fscache_begin_lookup() argument
551 set_bit(FSCACHE_COOKIE_LOCAL_WRITE, &cookie->flags); in fscache_begin_lookup()
552 set_bit(FSCACHE_COOKIE_DO_PREP_TO_WRITE, &cookie->flags); in fscache_begin_lookup()
554 if (!fscache_begin_volume_access(cookie->volume, cookie, in fscache_begin_lookup()
558 __fscache_begin_cookie_access(cookie, fscache_access_lookup_cookie); in fscache_begin_lookup()
559 __fscache_set_cookie_state(cookie, FSCACHE_COOKIE_STATE_LOOKING_UP); in fscache_begin_lookup()
560 set_bit(FSCACHE_COOKIE_IS_CACHING, &cookie->flags); in fscache_begin_lookup()
561 set_bit(FSCACHE_COOKIE_HAS_BEEN_CACHED, &cookie->flags); in fscache_begin_lookup()
569 void __fscache_use_cookie(struct fscache_cookie *cookie, bool will_modify) in __fscache_use_cookie() argument
575 _enter("c=%08x", cookie->debug_id); in __fscache_use_cookie()
577 if (WARN(test_bit(FSCACHE_COOKIE_RELINQUISHED, &cookie->flags), in __fscache_use_cookie()
581 spin_lock(&cookie->lock); in __fscache_use_cookie()
583 n_active = atomic_inc_return(&cookie->n_active); in __fscache_use_cookie()
584 trace_fscache_active(cookie->debug_id, refcount_read(&cookie->ref), in __fscache_use_cookie()
585 n_active, atomic_read(&cookie->n_accesses), in __fscache_use_cookie()
590 state = fscache_cookie_state(cookie); in __fscache_use_cookie()
593 queue = fscache_begin_lookup(cookie, will_modify); in __fscache_use_cookie()
599 set_bit(FSCACHE_COOKIE_LOCAL_WRITE, &cookie->flags); in __fscache_use_cookie()
604 !test_and_set_bit(FSCACHE_COOKIE_LOCAL_WRITE, &cookie->flags)) { in __fscache_use_cookie()
605 set_bit(FSCACHE_COOKIE_DO_PREP_TO_WRITE, &cookie->flags); in __fscache_use_cookie()
614 if (test_and_clear_bit(FSCACHE_COOKIE_DO_LRU_DISCARD, &cookie->flags)) in __fscache_use_cookie()
615 fscache_see_cookie(cookie, fscache_cookie_see_lru_discard_clear); in __fscache_use_cookie()
623 spin_unlock(&cookie->lock); in __fscache_use_cookie()
624 wait_var_event(&cookie->state, in __fscache_use_cookie()
625 fscache_cookie_state(cookie) != in __fscache_use_cookie()
627 spin_lock(&cookie->lock); in __fscache_use_cookie()
636 spin_unlock(&cookie->lock); in __fscache_use_cookie()
638 fscache_queue_cookie(cookie, fscache_cookie_get_use_work); in __fscache_use_cookie()
643 static void fscache_unuse_cookie_locked(struct fscache_cookie *cookie) in fscache_unuse_cookie_locked() argument
645 clear_bit(FSCACHE_COOKIE_DISABLED, &cookie->flags); in fscache_unuse_cookie_locked()
646 if (!test_bit(FSCACHE_COOKIE_IS_CACHING, &cookie->flags)) in fscache_unuse_cookie_locked()
649 cookie->unused_at = jiffies; in fscache_unuse_cookie_locked()
651 if (list_empty(&cookie->commit_link)) { in fscache_unuse_cookie_locked()
652 fscache_get_cookie(cookie, fscache_cookie_get_lru); in fscache_unuse_cookie_locked()
655 list_move_tail(&cookie->commit_link, &fscache_cookie_lru); in fscache_unuse_cookie_locked()
665 void __fscache_unuse_cookie(struct fscache_cookie *cookie, in __fscache_unuse_cookie() argument
668 unsigned int debug_id = cookie->debug_id; in __fscache_unuse_cookie()
669 unsigned int r = refcount_read(&cookie->ref); in __fscache_unuse_cookie()
670 unsigned int a = atomic_read(&cookie->n_accesses); in __fscache_unuse_cookie()
674 __fscache_update_cookie(cookie, aux_data, object_size); in __fscache_unuse_cookie()
677 c = atomic_fetch_add_unless(&cookie->n_active, -1, 1); in __fscache_unuse_cookie()
683 spin_lock(&cookie->lock); in __fscache_unuse_cookie()
684 r = refcount_read(&cookie->ref); in __fscache_unuse_cookie()
685 a = atomic_read(&cookie->n_accesses); in __fscache_unuse_cookie()
686 c = atomic_dec_return(&cookie->n_active); in __fscache_unuse_cookie()
689 fscache_unuse_cookie_locked(cookie); in __fscache_unuse_cookie()
690 spin_unlock(&cookie->lock); in __fscache_unuse_cookie()
700 static void fscache_cookie_state_machine(struct fscache_cookie *cookie) in fscache_cookie_state_machine() argument
705 _enter("c=%x", cookie->debug_id); in fscache_cookie_state_machine()
708 spin_lock(&cookie->lock); in fscache_cookie_state_machine()
710 state = cookie->state; in fscache_cookie_state_machine()
717 if (atomic_read(&cookie->n_accesses) == 0 && in fscache_cookie_state_machine()
718 test_bit(FSCACHE_COOKIE_DO_RELINQUISH, &cookie->flags)) { in fscache_cookie_state_machine()
719 __fscache_set_cookie_state(cookie, in fscache_cookie_state_machine()
727 spin_unlock(&cookie->lock); in fscache_cookie_state_machine()
728 fscache_init_access_gate(cookie); in fscache_cookie_state_machine()
729 fscache_perform_lookup(cookie); in fscache_cookie_state_machine()
733 spin_unlock(&cookie->lock); in fscache_cookie_state_machine()
734 fscache_perform_invalidation(cookie); in fscache_cookie_state_machine()
738 if (test_and_clear_bit(FSCACHE_COOKIE_DO_PREP_TO_WRITE, &cookie->flags)) { in fscache_cookie_state_machine()
739 spin_unlock(&cookie->lock); in fscache_cookie_state_machine()
740 fscache_prepare_to_write(cookie); in fscache_cookie_state_machine()
741 spin_lock(&cookie->lock); in fscache_cookie_state_machine()
743 if (test_bit(FSCACHE_COOKIE_DO_LRU_DISCARD, &cookie->flags)) { in fscache_cookie_state_machine()
744 __fscache_set_cookie_state(cookie, in fscache_cookie_state_machine()
752 if (test_and_clear_bit(FSCACHE_COOKIE_DO_INVALIDATE, &cookie->flags)) in fscache_cookie_state_machine()
753 fscache_end_cookie_access(cookie, fscache_access_invalidate_cookie_end); in fscache_cookie_state_machine()
755 if (atomic_read(&cookie->n_accesses) != 0) in fscache_cookie_state_machine()
757 if (test_bit(FSCACHE_COOKIE_DO_RELINQUISH, &cookie->flags)) { in fscache_cookie_state_machine()
758 __fscache_set_cookie_state(cookie, in fscache_cookie_state_machine()
763 if (test_bit(FSCACHE_COOKIE_DO_WITHDRAW, &cookie->flags)) { in fscache_cookie_state_machine()
764 __fscache_set_cookie_state(cookie, in fscache_cookie_state_machine()
774 if (cookie->cache_priv) { in fscache_cookie_state_machine()
775 spin_unlock(&cookie->lock); in fscache_cookie_state_machine()
776 cookie->volume->cache->ops->withdraw_cookie(cookie); in fscache_cookie_state_machine()
777 spin_lock(&cookie->lock); in fscache_cookie_state_machine()
780 if (test_and_clear_bit(FSCACHE_COOKIE_DO_INVALIDATE, &cookie->flags)) in fscache_cookie_state_machine()
781 fscache_end_cookie_access(cookie, fscache_access_invalidate_cookie_end); in fscache_cookie_state_machine()
785 fscache_see_cookie(cookie, fscache_cookie_see_relinquish); in fscache_cookie_state_machine()
786 fscache_unhash_cookie(cookie); in fscache_cookie_state_machine()
787 __fscache_set_cookie_state(cookie, in fscache_cookie_state_machine()
792 fscache_see_cookie(cookie, fscache_cookie_see_lru_discard); in fscache_cookie_state_machine()
795 fscache_see_cookie(cookie, fscache_cookie_see_withdraw); in fscache_cookie_state_machine()
801 clear_bit(FSCACHE_COOKIE_NEEDS_UPDATE, &cookie->flags); in fscache_cookie_state_machine()
802 clear_bit(FSCACHE_COOKIE_DO_WITHDRAW, &cookie->flags); in fscache_cookie_state_machine()
803 clear_bit(FSCACHE_COOKIE_DO_LRU_DISCARD, &cookie->flags); in fscache_cookie_state_machine()
804 clear_bit(FSCACHE_COOKIE_DO_PREP_TO_WRITE, &cookie->flags); in fscache_cookie_state_machine()
805 set_bit(FSCACHE_COOKIE_NO_DATA_TO_READ, &cookie->flags); in fscache_cookie_state_machine()
806 __fscache_set_cookie_state(cookie, FSCACHE_COOKIE_STATE_QUIESCENT); in fscache_cookie_state_machine()
815 cookie->debug_id, state); in fscache_cookie_state_machine()
820 spin_unlock(&cookie->lock); in fscache_cookie_state_machine()
822 wake_up_cookie_state(cookie); in fscache_cookie_state_machine()
828 struct fscache_cookie *cookie = container_of(work, struct fscache_cookie, work); in fscache_cookie_worker() local
830 fscache_see_cookie(cookie, fscache_cookie_see_work); in fscache_cookie_worker()
831 fscache_cookie_state_machine(cookie); in fscache_cookie_worker()
832 fscache_put_cookie(cookie, fscache_cookie_put_work); in fscache_cookie_worker()
840 static void __fscache_withdraw_cookie(struct fscache_cookie *cookie) in __fscache_withdraw_cookie() argument
845 unpinned = test_and_clear_bit(FSCACHE_COOKIE_NO_ACCESS_WAKE, &cookie->flags); in __fscache_withdraw_cookie()
848 n_accesses = atomic_read(&cookie->n_accesses); in __fscache_withdraw_cookie()
850 trace_fscache_access(cookie->debug_id, refcount_read(&cookie->ref), in __fscache_withdraw_cookie()
853 fscache_queue_cookie(cookie, fscache_cookie_get_end_access); in __fscache_withdraw_cookie()
856 static void fscache_cookie_lru_do_one(struct fscache_cookie *cookie) in fscache_cookie_lru_do_one() argument
858 fscache_see_cookie(cookie, fscache_cookie_see_lru_do_one); in fscache_cookie_lru_do_one()
860 spin_lock(&cookie->lock); in fscache_cookie_lru_do_one()
861 if (cookie->state != FSCACHE_COOKIE_STATE_ACTIVE || in fscache_cookie_lru_do_one()
862 time_before(jiffies, cookie->unused_at + fscache_lru_cookie_timeout) || in fscache_cookie_lru_do_one()
863 atomic_read(&cookie->n_active) > 0) { in fscache_cookie_lru_do_one()
864 spin_unlock(&cookie->lock); in fscache_cookie_lru_do_one()
867 set_bit(FSCACHE_COOKIE_DO_LRU_DISCARD, &cookie->flags); in fscache_cookie_lru_do_one()
868 spin_unlock(&cookie->lock); in fscache_cookie_lru_do_one()
870 _debug("lru c=%x", cookie->debug_id); in fscache_cookie_lru_do_one()
871 __fscache_withdraw_cookie(cookie); in fscache_cookie_lru_do_one()
874 fscache_put_cookie(cookie, fscache_cookie_put_lru); in fscache_cookie_lru_do_one()
879 struct fscache_cookie *cookie; in fscache_cookie_lru_worker() local
885 cookie = list_first_entry(&fscache_cookie_lru, in fscache_cookie_lru_worker()
887 unused_at = cookie->unused_at + fscache_lru_cookie_timeout; in fscache_cookie_lru_worker()
893 list_del_init(&cookie->commit_link); in fscache_cookie_lru_worker()
896 fscache_cookie_lru_do_one(cookie); in fscache_cookie_lru_worker()
908 static void fscache_cookie_drop_from_lru(struct fscache_cookie *cookie) in fscache_cookie_drop_from_lru() argument
912 if (!list_empty(&cookie->commit_link)) { in fscache_cookie_drop_from_lru()
914 if (!list_empty(&cookie->commit_link)) { in fscache_cookie_drop_from_lru()
915 list_del_init(&cookie->commit_link); in fscache_cookie_drop_from_lru()
922 fscache_put_cookie(cookie, fscache_cookie_put_lru); in fscache_cookie_drop_from_lru()
929 static void fscache_unhash_cookie(struct fscache_cookie *cookie) in fscache_unhash_cookie() argument
934 bucket = cookie->key_hash & (ARRAY_SIZE(fscache_cookie_hash) - 1); in fscache_unhash_cookie()
938 hlist_bl_del(&cookie->hash_link); in fscache_unhash_cookie()
939 clear_bit(FSCACHE_COOKIE_IS_HASHED, &cookie->flags); in fscache_unhash_cookie()
944 static void fscache_drop_withdraw_cookie(struct fscache_cookie *cookie) in fscache_drop_withdraw_cookie() argument
946 fscache_cookie_drop_from_lru(cookie); in fscache_drop_withdraw_cookie()
947 __fscache_withdraw_cookie(cookie); in fscache_drop_withdraw_cookie()
957 void fscache_withdraw_cookie(struct fscache_cookie *cookie) in fscache_withdraw_cookie() argument
959 set_bit(FSCACHE_COOKIE_DO_WITHDRAW, &cookie->flags); in fscache_withdraw_cookie()
960 fscache_drop_withdraw_cookie(cookie); in fscache_withdraw_cookie()
968 void __fscache_relinquish_cookie(struct fscache_cookie *cookie, bool retire) in __fscache_relinquish_cookie() argument
975 cookie->debug_id, atomic_read(&cookie->n_active), retire); in __fscache_relinquish_cookie()
977 if (WARN(test_and_set_bit(FSCACHE_COOKIE_RELINQUISHED, &cookie->flags), in __fscache_relinquish_cookie()
978 "Cookie c=%x already relinquished\n", cookie->debug_id)) in __fscache_relinquish_cookie()
982 set_bit(FSCACHE_COOKIE_RETIRED, &cookie->flags); in __fscache_relinquish_cookie()
983 trace_fscache_relinquish(cookie, retire); in __fscache_relinquish_cookie()
985 ASSERTCMP(atomic_read(&cookie->n_active), ==, 0); in __fscache_relinquish_cookie()
986 ASSERTCMP(atomic_read(&cookie->volume->n_cookies), >, 0); in __fscache_relinquish_cookie()
987 atomic_dec(&cookie->volume->n_cookies); in __fscache_relinquish_cookie()
989 if (test_bit(FSCACHE_COOKIE_HAS_BEEN_CACHED, &cookie->flags)) { in __fscache_relinquish_cookie()
990 set_bit(FSCACHE_COOKIE_DO_RELINQUISH, &cookie->flags); in __fscache_relinquish_cookie()
991 fscache_drop_withdraw_cookie(cookie); in __fscache_relinquish_cookie()
993 fscache_set_cookie_state(cookie, FSCACHE_COOKIE_STATE_DROPPED); in __fscache_relinquish_cookie()
994 fscache_unhash_cookie(cookie); in __fscache_relinquish_cookie()
996 fscache_put_cookie(cookie, fscache_cookie_put_relinquish); in __fscache_relinquish_cookie()
1003 void fscache_put_cookie(struct fscache_cookie *cookie, in fscache_put_cookie() argument
1006 struct fscache_volume *volume = cookie->volume; in fscache_put_cookie()
1007 unsigned int cookie_debug_id = cookie->debug_id; in fscache_put_cookie()
1011 zero = __refcount_dec_and_test(&cookie->ref, &ref); in fscache_put_cookie()
1014 fscache_free_cookie(cookie); in fscache_put_cookie()
1023 struct fscache_cookie *fscache_get_cookie(struct fscache_cookie *cookie, in fscache_get_cookie() argument
1028 __refcount_inc(&cookie->ref, &ref); in fscache_get_cookie()
1029 trace_fscache_cookie(cookie->debug_id, ref + 1, where); in fscache_get_cookie()
1030 return cookie; in fscache_get_cookie()
1037 static void fscache_perform_invalidation(struct fscache_cookie *cookie) in fscache_perform_invalidation() argument
1039 if (!cookie->volume->cache->ops->invalidate_cookie(cookie)) in fscache_perform_invalidation()
1040 fscache_caching_failed(cookie); in fscache_perform_invalidation()
1041 fscache_end_cookie_access(cookie, fscache_access_invalidate_cookie_end); in fscache_perform_invalidation()
1047 void __fscache_invalidate(struct fscache_cookie *cookie, in __fscache_invalidate() argument
1053 _enter("c=%x", cookie->debug_id); in __fscache_invalidate()
1057 if (WARN(test_bit(FSCACHE_COOKIE_RELINQUISHED, &cookie->flags), in __fscache_invalidate()
1062 test_and_set_bit(FSCACHE_COOKIE_DISABLED, &cookie->flags)) in __fscache_invalidate()
1065 spin_lock(&cookie->lock); in __fscache_invalidate()
1066 set_bit(FSCACHE_COOKIE_NO_DATA_TO_READ, &cookie->flags); in __fscache_invalidate()
1067 fscache_update_aux(cookie, aux_data, &new_size); in __fscache_invalidate()
1068 cookie->inval_counter++; in __fscache_invalidate()
1069 trace_fscache_invalidate(cookie, new_size); in __fscache_invalidate()
1071 switch (cookie->state) { in __fscache_invalidate()
1074 spin_unlock(&cookie->lock); in __fscache_invalidate()
1075 _leave(" [no %u]", cookie->state); in __fscache_invalidate()
1079 if (!test_and_set_bit(FSCACHE_COOKIE_DO_INVALIDATE, &cookie->flags)) in __fscache_invalidate()
1080 __fscache_begin_cookie_access(cookie, fscache_access_invalidate_cookie); in __fscache_invalidate()
1083 spin_unlock(&cookie->lock); in __fscache_invalidate()
1084 _leave(" [look %x]", cookie->inval_counter); in __fscache_invalidate()
1089 cookie, fscache_access_invalidate_cookie); in __fscache_invalidate()
1091 __fscache_set_cookie_state(cookie, FSCACHE_COOKIE_STATE_INVALIDATING); in __fscache_invalidate()
1092 spin_unlock(&cookie->lock); in __fscache_invalidate()
1093 wake_up_cookie_state(cookie); in __fscache_invalidate()
1096 fscache_queue_cookie(cookie, fscache_cookie_get_inval_work); in __fscache_invalidate()
1109 struct fscache_cookie *cookie; in fscache_cookies_seq_show() local
1121 cookie = list_entry(v, struct fscache_cookie, proc_link); in fscache_cookies_seq_show()
1125 cookie->debug_id, in fscache_cookies_seq_show()
1126 cookie->volume->debug_id, in fscache_cookies_seq_show()
1127 refcount_read(&cookie->ref), in fscache_cookies_seq_show()
1128 atomic_read(&cookie->n_active), in fscache_cookies_seq_show()
1129 atomic_read(&cookie->n_accesses), in fscache_cookies_seq_show()
1130 fscache_cookie_states[cookie->state], in fscache_cookies_seq_show()
1131 cookie->flags); in fscache_cookies_seq_show()
1133 keylen = cookie->key_len; in fscache_cookies_seq_show()
1134 auxlen = cookie->aux_len; in fscache_cookies_seq_show()
1138 p = keylen <= sizeof(cookie->inline_key) ? in fscache_cookies_seq_show()
1139 cookie->inline_key : cookie->key; in fscache_cookies_seq_show()
1144 p = auxlen <= sizeof(cookie->inline_aux) ? in fscache_cookies_seq_show()
1145 cookie->inline_aux : cookie->aux; in fscache_cookies_seq_show()