Lines Matching refs:object
26 struct cachefiles_object *object; in cachefiles_alloc_object() local
30 object = kmem_cache_zalloc(cachefiles_object_jar, GFP_KERNEL); in cachefiles_alloc_object()
31 if (!object) in cachefiles_alloc_object()
34 refcount_set(&object->ref, 1); in cachefiles_alloc_object()
36 spin_lock_init(&object->lock); in cachefiles_alloc_object()
37 INIT_LIST_HEAD(&object->cache_link); in cachefiles_alloc_object()
38 object->volume = volume; in cachefiles_alloc_object()
39 object->debug_id = atomic_inc_return(&cachefiles_object_debug_id); in cachefiles_alloc_object()
40 object->cookie = fscache_get_cookie(cookie, fscache_cookie_get_attach_object); in cachefiles_alloc_object()
43 trace_cachefiles_ref(object->debug_id, cookie->debug_id, 1, in cachefiles_alloc_object()
45 return object; in cachefiles_alloc_object()
51 void cachefiles_see_object(struct cachefiles_object *object, in cachefiles_see_object() argument
54 trace_cachefiles_ref(object->debug_id, object->cookie->debug_id, in cachefiles_see_object()
55 refcount_read(&object->ref), why); in cachefiles_see_object()
61 struct cachefiles_object *cachefiles_grab_object(struct cachefiles_object *object, in cachefiles_grab_object() argument
66 __refcount_inc(&object->ref, &r); in cachefiles_grab_object()
67 trace_cachefiles_ref(object->debug_id, object->cookie->debug_id, r, why); in cachefiles_grab_object()
68 return object; in cachefiles_grab_object()
74 void cachefiles_put_object(struct cachefiles_object *object, in cachefiles_put_object() argument
77 unsigned int object_debug_id = object->debug_id; in cachefiles_put_object()
78 unsigned int cookie_debug_id = object->cookie->debug_id; in cachefiles_put_object()
83 done = __refcount_dec_and_test(&object->ref, &r); in cachefiles_put_object()
88 ASSERTCMP(object->file, ==, NULL); in cachefiles_put_object()
90 kfree(object->d_name); in cachefiles_put_object()
92 cache = object->volume->cache->cache; in cachefiles_put_object()
93 fscache_put_cookie(object->cookie, fscache_cookie_put_object); in cachefiles_put_object()
94 object->cookie = NULL; in cachefiles_put_object()
95 kmem_cache_free(cachefiles_object_jar, object); in cachefiles_put_object()
109 static int cachefiles_adjust_size(struct cachefiles_object *object) in cachefiles_adjust_size() argument
112 struct file *file = object->file; in cachefiles_adjust_size()
117 ni_size = object->cookie->object_size; in cachefiles_adjust_size()
121 object->debug_id, (unsigned long long) ni_size); in cachefiles_adjust_size()
161 cachefiles_io_error_obj(object, "Size set failed"); in cachefiles_adjust_size()
174 struct cachefiles_object *object; in cachefiles_lookup_cookie() local
179 object = cachefiles_alloc_object(cookie); in cachefiles_lookup_cookie()
180 if (!object) in cachefiles_lookup_cookie()
183 _enter("{OBJ%x}", object->debug_id); in cachefiles_lookup_cookie()
185 if (!cachefiles_cook_key(object)) in cachefiles_lookup_cookie()
188 cookie->cache_priv = object; in cachefiles_lookup_cookie()
192 success = cachefiles_look_up_object(object); in cachefiles_lookup_cookie()
196 cachefiles_see_object(object, cachefiles_obj_see_lookup_cookie); in cachefiles_lookup_cookie()
199 list_add(&object->cache_link, &cache->object_list); in cachefiles_lookup_cookie()
201 cachefiles_adjust_size(object); in cachefiles_lookup_cookie()
209 cachefiles_see_object(object, cachefiles_obj_see_lookup_failed); in cachefiles_lookup_cookie()
211 _debug("failed c=%08x o=%08x", cookie->debug_id, object->debug_id); in cachefiles_lookup_cookie()
218 cachefiles_put_object(object, cachefiles_obj_put_alloc_fail); in cachefiles_lookup_cookie()
227 static bool cachefiles_shorten_object(struct cachefiles_object *object, in cachefiles_shorten_object() argument
230 struct cachefiles_cache *cache = object->volume->cache; in cachefiles_shorten_object()
238 trace_cachefiles_trunc(object, inode, i_size, dio_size, in cachefiles_shorten_object()
244 trace_cachefiles_io_error(object, file_inode(file), ret, in cachefiles_shorten_object()
246 cachefiles_io_error_obj(object, "Trunc-to-size failed %d", ret); in cachefiles_shorten_object()
247 cachefiles_remove_object_xattr(cache, object, file->f_path.dentry); in cachefiles_shorten_object()
252 trace_cachefiles_trunc(object, inode, dio_size, new_size, in cachefiles_shorten_object()
259 trace_cachefiles_io_error(object, file_inode(file), ret, in cachefiles_shorten_object()
261 cachefiles_io_error_obj(object, "Trunc-to-dio-size failed %d", ret); in cachefiles_shorten_object()
262 cachefiles_remove_object_xattr(cache, object, file->f_path.dentry); in cachefiles_shorten_object()
276 struct cachefiles_object *object = cachefiles_cres_object(cres); in cachefiles_resize_cookie() local
277 struct cachefiles_cache *cache = object->volume->cache; in cachefiles_resize_cookie()
278 struct fscache_cookie *cookie = object->cookie; in cachefiles_resize_cookie()
287 cachefiles_shorten_object(object, file, new_size); in cachefiles_resize_cookie()
289 object->cookie->object_size = new_size; in cachefiles_resize_cookie()
303 static void cachefiles_commit_object(struct cachefiles_object *object, in cachefiles_commit_object() argument
308 if (test_and_clear_bit(FSCACHE_COOKIE_LOCAL_WRITE, &object->cookie->flags)) in cachefiles_commit_object()
310 if (test_and_clear_bit(FSCACHE_COOKIE_NEEDS_UPDATE, &object->cookie->flags)) in cachefiles_commit_object()
313 cachefiles_set_object_xattr(object); in cachefiles_commit_object()
315 if (test_bit(CACHEFILES_OBJECT_USING_TMPFILE, &object->flags)) in cachefiles_commit_object()
316 cachefiles_commit_tmpfile(cache, object); in cachefiles_commit_object()
322 static void cachefiles_clean_up_object(struct cachefiles_object *object, in cachefiles_clean_up_object() argument
325 if (test_bit(FSCACHE_COOKIE_RETIRED, &object->cookie->flags)) { in cachefiles_clean_up_object()
326 if (!test_bit(CACHEFILES_OBJECT_USING_TMPFILE, &object->flags)) { in cachefiles_clean_up_object()
327 cachefiles_see_object(object, cachefiles_obj_see_clean_delete); in cachefiles_clean_up_object()
328 _debug("- inval object OBJ%x", object->debug_id); in cachefiles_clean_up_object()
329 cachefiles_delete_object(object, FSCACHE_OBJECT_WAS_RETIRED); in cachefiles_clean_up_object()
331 cachefiles_see_object(object, cachefiles_obj_see_clean_drop_tmp); in cachefiles_clean_up_object()
332 _debug("- inval object OBJ%x tmpfile", object->debug_id); in cachefiles_clean_up_object()
335 cachefiles_see_object(object, cachefiles_obj_see_clean_commit); in cachefiles_clean_up_object()
336 cachefiles_commit_object(object, cache); in cachefiles_clean_up_object()
339 cachefiles_unmark_inode_in_use(object, object->file); in cachefiles_clean_up_object()
340 if (object->file) { in cachefiles_clean_up_object()
341 fput(object->file); in cachefiles_clean_up_object()
342 object->file = NULL; in cachefiles_clean_up_object()
351 struct cachefiles_object *object = cookie->cache_priv; in cachefiles_withdraw_cookie() local
352 struct cachefiles_cache *cache = object->volume->cache; in cachefiles_withdraw_cookie()
355 _enter("o=%x", object->debug_id); in cachefiles_withdraw_cookie()
356 cachefiles_see_object(object, cachefiles_obj_see_withdraw_cookie); in cachefiles_withdraw_cookie()
358 if (!list_empty(&object->cache_link)) { in cachefiles_withdraw_cookie()
360 cachefiles_see_object(object, cachefiles_obj_see_withdrawal); in cachefiles_withdraw_cookie()
361 list_del_init(&object->cache_link); in cachefiles_withdraw_cookie()
365 cachefiles_ondemand_clean_object(object); in cachefiles_withdraw_cookie()
367 if (object->file) { in cachefiles_withdraw_cookie()
369 cachefiles_clean_up_object(object, cache); in cachefiles_withdraw_cookie()
374 cachefiles_put_object(object, cachefiles_obj_put_detach); in cachefiles_withdraw_cookie()
382 struct cachefiles_object *object = cookie->cache_priv; in cachefiles_invalidate_cookie() local
386 _enter("o=%x,[%llu]", object->debug_id, object->cookie->object_size); in cachefiles_invalidate_cookie()
388 old_tmpfile = test_bit(CACHEFILES_OBJECT_USING_TMPFILE, &object->flags); in cachefiles_invalidate_cookie()
390 if (!object->file) { in cachefiles_invalidate_cookie()
396 new_file = cachefiles_create_tmpfile(object); in cachefiles_invalidate_cookie()
402 spin_lock(&object->lock); in cachefiles_invalidate_cookie()
404 old_file = object->file; in cachefiles_invalidate_cookie()
405 object->file = new_file; in cachefiles_invalidate_cookie()
406 object->content_info = CACHEFILES_CONTENT_NO_DATA; in cachefiles_invalidate_cookie()
407 set_bit(CACHEFILES_OBJECT_USING_TMPFILE, &object->flags); in cachefiles_invalidate_cookie()
408 set_bit(FSCACHE_COOKIE_NEEDS_UPDATE, &object->cookie->flags); in cachefiles_invalidate_cookie()
410 spin_unlock(&object->lock); in cachefiles_invalidate_cookie()
418 struct cachefiles_volume *volume = object->volume; in cachefiles_invalidate_cookie()
422 cachefiles_bury_object(volume->cache, object, fan, in cachefiles_invalidate_cookie()