Lines Matching refs:volume

20 struct fscache_volume *fscache_get_volume(struct fscache_volume *volume,  in fscache_get_volume()  argument
25 __refcount_inc(&volume->ref, &ref); in fscache_get_volume()
26 trace_fscache_volume(volume->debug_id, ref + 1, where); in fscache_get_volume()
27 return volume; in fscache_get_volume()
30 struct fscache_volume *fscache_try_get_volume(struct fscache_volume *volume, in fscache_try_get_volume() argument
35 if (!__refcount_inc_not_zero(&volume->ref, &ref)) in fscache_try_get_volume()
38 trace_fscache_volume(volume->debug_id, ref + 1, where); in fscache_try_get_volume()
39 return volume; in fscache_try_get_volume()
43 static void fscache_see_volume(struct fscache_volume *volume, in fscache_see_volume() argument
46 int ref = refcount_read(&volume->ref); in fscache_see_volume()
48 trace_fscache_volume(volume->debug_id, ref, where); in fscache_see_volume()
54 static void __fscache_begin_volume_access(struct fscache_volume *volume, in __fscache_begin_volume_access() argument
60 n_accesses = atomic_inc_return(&volume->n_accesses); in __fscache_begin_volume_access()
62 trace_fscache_access_volume(volume->debug_id, cookie ? cookie->debug_id : 0, in __fscache_begin_volume_access()
63 refcount_read(&volume->ref), in __fscache_begin_volume_access()
96 bool fscache_begin_volume_access(struct fscache_volume *volume, in fscache_begin_volume_access() argument
100 if (!fscache_cache_is_live(volume->cache)) in fscache_begin_volume_access()
102 __fscache_begin_volume_access(volume, cookie, why); in fscache_begin_volume_access()
103 if (!fscache_cache_is_live(volume->cache)) { in fscache_begin_volume_access()
104 fscache_end_volume_access(volume, cookie, fscache_access_unlive); in fscache_begin_volume_access()
119 void fscache_end_volume_access(struct fscache_volume *volume, in fscache_end_volume_access() argument
126 n_accesses = atomic_dec_return(&volume->n_accesses); in fscache_end_volume_access()
127 trace_fscache_access_volume(volume->debug_id, cookie ? cookie->debug_id : 0, in fscache_end_volume_access()
128 refcount_read(&volume->ref), in fscache_end_volume_access()
131 wake_up_var(&volume->n_accesses); in fscache_end_volume_access()
149 static bool fscache_is_acquire_pending(struct fscache_volume *volume) in fscache_is_acquire_pending() argument
151 return test_bit(FSCACHE_VOLUME_ACQUIRE_PENDING, &volume->flags); in fscache_is_acquire_pending()
217 struct fscache_volume *volume; in fscache_alloc_volume() local
233 volume = kzalloc(struct_size(volume, coherency, coherency_len), in fscache_alloc_volume()
235 if (!volume) in fscache_alloc_volume()
238 volume->cache = cache; in fscache_alloc_volume()
239 volume->coherency_len = coherency_len; in fscache_alloc_volume()
241 memcpy(volume->coherency, coherency_data, coherency_len); in fscache_alloc_volume()
242 INIT_LIST_HEAD(&volume->proc_link); in fscache_alloc_volume()
243 INIT_WORK(&volume->work, fscache_create_volume_work); in fscache_alloc_volume()
244 refcount_set(&volume->ref, 1); in fscache_alloc_volume()
245 spin_lock_init(&volume->lock); in fscache_alloc_volume()
257 volume->key = key; in fscache_alloc_volume()
258 volume->key_hash = fscache_hash(0, key, hlen); in fscache_alloc_volume()
260 volume->debug_id = atomic_inc_return(&fscache_volume_debug_id); in fscache_alloc_volume()
263 list_add_tail(&volume->proc_link, &fscache_volumes); in fscache_alloc_volume()
264 fscache_see_volume(volume, fscache_volume_new_acquire); in fscache_alloc_volume()
267 _leave(" = v=%x", volume->debug_id); in fscache_alloc_volume()
268 return volume; in fscache_alloc_volume()
271 kfree(volume); in fscache_alloc_volume()
285 struct fscache_volume *volume = in fscache_create_volume_work() local
288 fscache_see_volume(volume, fscache_volume_see_create_work); in fscache_create_volume_work()
290 ops = volume->cache->ops; in fscache_create_volume_work()
292 ops->acquire_volume(volume); in fscache_create_volume_work()
293 fscache_end_cache_access(volume->cache, in fscache_create_volume_work()
296 clear_and_wake_up_bit(FSCACHE_VOLUME_CREATING, &volume->flags); in fscache_create_volume_work()
297 fscache_put_volume(volume, fscache_volume_put_create_work); in fscache_create_volume_work()
303 void fscache_create_volume(struct fscache_volume *volume, bool wait) in fscache_create_volume() argument
305 if (test_and_set_bit(FSCACHE_VOLUME_CREATING, &volume->flags)) in fscache_create_volume()
307 if (volume->cache_priv) in fscache_create_volume()
309 if (!fscache_begin_cache_access(volume->cache, in fscache_create_volume()
313 fscache_get_volume(volume, fscache_volume_get_create_work); in fscache_create_volume()
314 if (!schedule_work(&volume->work)) in fscache_create_volume()
315 fscache_put_volume(volume, fscache_volume_put_create_work); in fscache_create_volume()
319 fscache_see_volume(volume, fscache_volume_wait_create_work); in fscache_create_volume()
320 wait_on_bit(&volume->flags, FSCACHE_VOLUME_CREATING, in fscache_create_volume()
325 clear_bit_unlock(FSCACHE_VOLUME_CREATING, &volume->flags); in fscache_create_volume()
326 wake_up_bit(&volume->flags, FSCACHE_VOLUME_CREATING); in fscache_create_volume()
337 struct fscache_volume *volume; in __fscache_acquire_volume() local
339 volume = fscache_alloc_volume(volume_key, cache_name, in __fscache_acquire_volume()
341 if (!volume) in __fscache_acquire_volume()
344 if (!fscache_hash_volume(volume)) { in __fscache_acquire_volume()
345 fscache_put_volume(volume, fscache_volume_put_hash_collision); in __fscache_acquire_volume()
349 fscache_create_volume(volume, false); in __fscache_acquire_volume()
350 return volume; in __fscache_acquire_volume()
354 static void fscache_wake_pending_volume(struct fscache_volume *volume, in fscache_wake_pending_volume() argument
361 if (fscache_volume_same(cursor, volume)) { in fscache_wake_pending_volume()
373 static void fscache_unhash_volume(struct fscache_volume *volume) in fscache_unhash_volume() argument
378 bucket = volume->key_hash & (ARRAY_SIZE(fscache_volume_hash) - 1); in fscache_unhash_volume()
382 hlist_bl_del(&volume->hash_link); in fscache_unhash_volume()
383 if (test_bit(FSCACHE_VOLUME_COLLIDED_WITH, &volume->flags)) in fscache_unhash_volume()
384 fscache_wake_pending_volume(volume, h); in fscache_unhash_volume()
391 static void fscache_free_volume(struct fscache_volume *volume) in fscache_free_volume() argument
393 struct fscache_cache *cache = volume->cache; in fscache_free_volume()
395 if (volume->cache_priv) { in fscache_free_volume()
396 __fscache_begin_volume_access(volume, NULL, in fscache_free_volume()
398 if (volume->cache_priv) in fscache_free_volume()
399 cache->ops->free_volume(volume); in fscache_free_volume()
400 fscache_end_volume_access(volume, NULL, in fscache_free_volume()
405 list_del_init(&volume->proc_link); in fscache_free_volume()
406 atomic_dec(&volume->cache->n_volumes); in fscache_free_volume()
409 if (!hlist_bl_unhashed(&volume->hash_link)) in fscache_free_volume()
410 fscache_unhash_volume(volume); in fscache_free_volume()
412 trace_fscache_volume(volume->debug_id, 0, fscache_volume_free); in fscache_free_volume()
413 kfree(volume->key); in fscache_free_volume()
414 kfree(volume); in fscache_free_volume()
422 void fscache_put_volume(struct fscache_volume *volume, in fscache_put_volume() argument
425 if (volume) { in fscache_put_volume()
426 unsigned int debug_id = volume->debug_id; in fscache_put_volume()
430 zero = __refcount_dec_and_test(&volume->ref, &ref); in fscache_put_volume()
433 fscache_free_volume(volume); in fscache_put_volume()
441 void __fscache_relinquish_volume(struct fscache_volume *volume, in __fscache_relinquish_volume() argument
445 if (WARN_ON(test_and_set_bit(FSCACHE_VOLUME_RELINQUISHED, &volume->flags))) in __fscache_relinquish_volume()
449 set_bit(FSCACHE_VOLUME_INVALIDATE, &volume->flags); in __fscache_relinquish_volume()
451 memcpy(volume->coherency, coherency_data, volume->coherency_len); in __fscache_relinquish_volume()
454 fscache_put_volume(volume, fscache_volume_put_relinquish); in __fscache_relinquish_volume()
465 void fscache_withdraw_volume(struct fscache_volume *volume) in fscache_withdraw_volume() argument
469 _debug("withdraw V=%x", volume->debug_id); in fscache_withdraw_volume()
472 n_accesses = atomic_dec_return(&volume->n_accesses); in fscache_withdraw_volume()
473 trace_fscache_access_volume(volume->debug_id, 0, in fscache_withdraw_volume()
474 refcount_read(&volume->ref), in fscache_withdraw_volume()
477 wait_var_event(&volume->n_accesses, in fscache_withdraw_volume()
478 atomic_read(&volume->n_accesses) == 0); in fscache_withdraw_volume()
488 struct fscache_volume *volume; in fscache_volumes_seq_show() local
497 volume = list_entry(v, struct fscache_volume, proc_link); in fscache_volumes_seq_show()
500 volume->debug_id, in fscache_volumes_seq_show()
501 refcount_read(&volume->ref), in fscache_volumes_seq_show()
502 atomic_read(&volume->n_cookies), in fscache_volumes_seq_show()
503 atomic_read(&volume->n_accesses), in fscache_volumes_seq_show()
504 volume->flags, in fscache_volumes_seq_show()
505 volume->cache->name ?: "-", in fscache_volumes_seq_show()
506 volume->key + 1); in fscache_volumes_seq_show()