Lines Matching refs:object

148 static inline void fscache_done_parent_op(struct fscache_object *object)  in fscache_done_parent_op()  argument
150 struct fscache_object *parent = object->parent; in fscache_done_parent_op()
153 object->debug_id, parent->debug_id, parent->n_ops); in fscache_done_parent_op()
166 static void fscache_object_sm_dispatcher(struct fscache_object *object) in fscache_object_sm_dispatcher() argument
174 ASSERT(object != NULL); in fscache_object_sm_dispatcher()
177 object->debug_id, object->state->name, object->events); in fscache_object_sm_dispatcher()
179 event_mask = object->event_mask; in fscache_object_sm_dispatcher()
181 object->event_mask = 0; /* Mask normal event handling */ in fscache_object_sm_dispatcher()
182 state = object->state; in fscache_object_sm_dispatcher()
184 events = object->events; in fscache_object_sm_dispatcher()
187 if (events & object->oob_event_mask) { in fscache_object_sm_dispatcher()
189 object->debug_id, events & object->oob_event_mask); in fscache_object_sm_dispatcher()
191 for (t = object->oob_table; t->events; t++) { in fscache_object_sm_dispatcher()
196 __clear_bit(event, &object->oob_event_mask); in fscache_object_sm_dispatcher()
197 clear_bit(event, &object->events); in fscache_object_sm_dispatcher()
211 trace_fscache_osm(object, state, in fscache_object_sm_dispatcher()
213 clear_bit(event, &object->events); in fscache_object_sm_dispatcher()
215 object->debug_id, event, in fscache_object_sm_dispatcher()
217 object->state = state = new_state; in fscache_object_sm_dispatcher()
230 _debug("{OBJ%x} exec %s", object->debug_id, state->name); in fscache_object_sm_dispatcher()
232 trace_fscache_osm(object, state, false, oob, event); in fscache_object_sm_dispatcher()
233 new_state = state->work(object, event); in fscache_object_sm_dispatcher()
236 _debug("{OBJ%x} %s notrans", object->debug_id, state->name); in fscache_object_sm_dispatcher()
241 fscache_enqueue_object(object); in fscache_object_sm_dispatcher()
242 event_mask = object->oob_event_mask; in fscache_object_sm_dispatcher()
247 object->debug_id, state->name, new_state->name); in fscache_object_sm_dispatcher()
248 object->state = state = new_state; in fscache_object_sm_dispatcher()
259 event_mask = object->oob_event_mask; in fscache_object_sm_dispatcher()
264 object->event_mask = event_mask; in fscache_object_sm_dispatcher()
266 events = object->events; in fscache_object_sm_dispatcher()
277 struct fscache_object *object = in fscache_object_work_func() local
280 _enter("{OBJ%x}", object->debug_id); in fscache_object_work_func()
282 fscache_object_sm_dispatcher(object); in fscache_object_work_func()
283 fscache_put_object(object, fscache_obj_put_work); in fscache_object_work_func()
297 void fscache_object_init(struct fscache_object *object, in fscache_object_init() argument
305 object->state = STATE(WAIT_FOR_INIT); in fscache_object_init()
306 object->oob_table = fscache_osm_init_oob; in fscache_object_init()
307 object->flags = 1 << FSCACHE_OBJECT_IS_LIVE; in fscache_object_init()
308 spin_lock_init(&object->lock); in fscache_object_init()
309 INIT_LIST_HEAD(&object->cache_link); in fscache_object_init()
310 INIT_HLIST_NODE(&object->cookie_link); in fscache_object_init()
311 INIT_WORK(&object->work, fscache_object_work_func); in fscache_object_init()
312 INIT_LIST_HEAD(&object->dependents); in fscache_object_init()
313 INIT_LIST_HEAD(&object->dep_link); in fscache_object_init()
314 INIT_LIST_HEAD(&object->pending_ops); in fscache_object_init()
315 object->n_children = 0; in fscache_object_init()
316 object->n_ops = object->n_in_progress = object->n_exclusive = 0; in fscache_object_init()
317 object->events = 0; in fscache_object_init()
318 object->store_limit = 0; in fscache_object_init()
319 object->store_limit_l = 0; in fscache_object_init()
320 object->cache = cache; in fscache_object_init()
321 object->cookie = cookie; in fscache_object_init()
323 object->parent = NULL; in fscache_object_init()
325 RB_CLEAR_NODE(&object->objlist_link); in fscache_object_init()
328 object->oob_event_mask = 0; in fscache_object_init()
329 for (t = object->oob_table; t->events; t++) in fscache_object_init()
330 object->oob_event_mask |= t->events; in fscache_object_init()
331 object->event_mask = object->oob_event_mask; in fscache_object_init()
332 for (t = object->state->transitions; t->events; t++) in fscache_object_init()
333 object->event_mask |= t->events; in fscache_object_init()
341 static inline void fscache_mark_object_dead(struct fscache_object *object) in fscache_mark_object_dead() argument
343 spin_lock(&object->lock); in fscache_mark_object_dead()
344 clear_bit(FSCACHE_OBJECT_IS_LIVE, &object->flags); in fscache_mark_object_dead()
345 spin_unlock(&object->lock); in fscache_mark_object_dead()
351 static const struct fscache_state *fscache_abort_initialisation(struct fscache_object *object, in fscache_abort_initialisation() argument
354 _enter("{OBJ%x},%d", object->debug_id, event); in fscache_abort_initialisation()
356 object->oob_event_mask = 0; in fscache_abort_initialisation()
357 fscache_dequeue_object(object); in fscache_abort_initialisation()
368 static const struct fscache_state *fscache_initialise_object(struct fscache_object *object, in fscache_initialise_object() argument
374 _enter("{OBJ%x},%d", object->debug_id, event); in fscache_initialise_object()
376 ASSERT(list_empty(&object->dep_link)); in fscache_initialise_object()
378 parent = object->parent; in fscache_initialise_object()
402 object->cache->ops->grab_object(object, fscache_obj_get_add_to_deps)) { in fscache_initialise_object()
403 list_add(&object->dep_link, &parent->dependents); in fscache_initialise_object()
423 static const struct fscache_state *fscache_parent_ready(struct fscache_object *object, in fscache_parent_ready() argument
426 struct fscache_object *parent = object->parent; in fscache_parent_ready()
428 _enter("{OBJ%x},%d", object->debug_id, event); in fscache_parent_ready()
446 static const struct fscache_state *fscache_look_up_object(struct fscache_object *object, in fscache_look_up_object() argument
449 struct fscache_cookie *cookie = object->cookie; in fscache_look_up_object()
450 struct fscache_object *parent = object->parent; in fscache_look_up_object()
453 _enter("{OBJ%x},%d", object->debug_id, event); in fscache_look_up_object()
455 object->oob_table = fscache_osm_lookup_oob; in fscache_look_up_object()
465 test_bit(FSCACHE_IOERROR, &object->cache->flags) || in fscache_look_up_object()
466 !fscache_use_cookie(object)) { in fscache_look_up_object()
472 cookie->def->name, object->cache->tag->name); in fscache_look_up_object()
476 ret = object->cache->ops->lookup_object(object); in fscache_look_up_object()
479 fscache_unuse_cookie(object); in fscache_look_up_object()
505 void fscache_object_lookup_negative(struct fscache_object *object) in fscache_object_lookup_negative() argument
507 struct fscache_cookie *cookie = object->cookie; in fscache_object_lookup_negative()
509 _enter("{OBJ%x,%s}", object->debug_id, object->state->name); in fscache_object_lookup_negative()
511 if (!test_and_set_bit(FSCACHE_OBJECT_IS_LOOKED_UP, &object->flags)) { in fscache_object_lookup_negative()
537 void fscache_obtained_object(struct fscache_object *object) in fscache_obtained_object() argument
539 struct fscache_cookie *cookie = object->cookie; in fscache_obtained_object()
541 _enter("{OBJ%x,%s}", object->debug_id, object->state->name); in fscache_obtained_object()
545 if (!test_and_set_bit(FSCACHE_OBJECT_IS_LOOKED_UP, &object->flags)) { in fscache_obtained_object()
561 set_bit(FSCACHE_OBJECT_IS_AVAILABLE, &object->flags); in fscache_obtained_object()
569 static const struct fscache_state *fscache_object_available(struct fscache_object *object, in fscache_object_available() argument
572 _enter("{OBJ%x},%d", object->debug_id, event); in fscache_object_available()
574 object->oob_table = fscache_osm_run_oob; in fscache_object_available()
576 spin_lock(&object->lock); in fscache_object_available()
578 fscache_done_parent_op(object); in fscache_object_available()
579 if (object->n_in_progress == 0) { in fscache_object_available()
580 if (object->n_ops > 0) { in fscache_object_available()
581 ASSERTCMP(object->n_ops, >=, object->n_obj_ops); in fscache_object_available()
582 fscache_start_operations(object); in fscache_object_available()
584 ASSERT(list_empty(&object->pending_ops)); in fscache_object_available()
587 spin_unlock(&object->lock); in fscache_object_available()
590 object->cache->ops->lookup_complete(object); in fscache_object_available()
602 static const struct fscache_state *fscache_jumpstart_dependents(struct fscache_object *object, in fscache_jumpstart_dependents() argument
605 _enter("{OBJ%x},%d", object->debug_id, event); in fscache_jumpstart_dependents()
607 if (!fscache_enqueue_dependents(object, FSCACHE_OBJECT_EV_PARENT_READY)) in fscache_jumpstart_dependents()
615 static const struct fscache_state *fscache_lookup_failure(struct fscache_object *object, in fscache_lookup_failure() argument
620 _enter("{OBJ%x},%d", object->debug_id, event); in fscache_lookup_failure()
622 object->oob_event_mask = 0; in fscache_lookup_failure()
625 object->cache->ops->lookup_complete(object); in fscache_lookup_failure()
628 set_bit(FSCACHE_OBJECT_KILLED_BY_CACHE, &object->flags); in fscache_lookup_failure()
630 cookie = object->cookie; in fscache_lookup_failure()
635 fscache_done_parent_op(object); in fscache_lookup_failure()
643 static const struct fscache_state *fscache_kill_object(struct fscache_object *object, in fscache_kill_object() argument
647 object->debug_id, object->n_ops, object->n_children, event); in fscache_kill_object()
649 fscache_mark_object_dead(object); in fscache_kill_object()
650 object->oob_event_mask = 0; in fscache_kill_object()
652 if (test_bit(FSCACHE_OBJECT_RETIRED, &object->flags)) { in fscache_kill_object()
654 clear_bit(FSCACHE_OBJECT_PENDING_WRITE, &object->flags); in fscache_kill_object()
655 fscache_cancel_all_ops(object); in fscache_kill_object()
658 if (list_empty(&object->dependents) && in fscache_kill_object()
659 object->n_ops == 0 && in fscache_kill_object()
660 object->n_children == 0) in fscache_kill_object()
663 if (object->n_in_progress == 0) { in fscache_kill_object()
664 spin_lock(&object->lock); in fscache_kill_object()
665 if (object->n_ops > 0 && object->n_in_progress == 0) in fscache_kill_object()
666 fscache_start_operations(object); in fscache_kill_object()
667 spin_unlock(&object->lock); in fscache_kill_object()
670 if (!list_empty(&object->dependents)) in fscache_kill_object()
679 static const struct fscache_state *fscache_kill_dependents(struct fscache_object *object, in fscache_kill_dependents() argument
682 _enter("{OBJ%x},%d", object->debug_id, event); in fscache_kill_dependents()
684 if (!fscache_enqueue_dependents(object, FSCACHE_OBJECT_EV_KILL)) in fscache_kill_dependents()
692 static const struct fscache_state *fscache_drop_object(struct fscache_object *object, in fscache_drop_object() argument
695 struct fscache_object *parent = object->parent; in fscache_drop_object()
696 struct fscache_cookie *cookie = object->cookie; in fscache_drop_object()
697 struct fscache_cache *cache = object->cache; in fscache_drop_object()
700 _enter("{OBJ%x,%d},%d", object->debug_id, object->n_children, event); in fscache_drop_object()
703 ASSERT(!hlist_unhashed(&object->cookie_link)); in fscache_drop_object()
707 fscache_update_aux_data(object); in fscache_drop_object()
714 hlist_del_init(&object->cookie_link); in fscache_drop_object()
729 spin_lock(&object->lock); in fscache_drop_object()
730 spin_unlock(&object->lock); in fscache_drop_object()
734 list_del_init(&object->cache_link); in fscache_drop_object()
738 cache->ops->drop_object(object); in fscache_drop_object()
751 object->parent = NULL; in fscache_drop_object()
755 fscache_put_object(object, fscache_obj_put_drop_obj); in fscache_drop_object()
765 static int fscache_get_object(struct fscache_object *object, in fscache_get_object() argument
771 ret = object->cache->ops->grab_object(object, why) ? 0 : -EAGAIN; in fscache_get_object()
779 static void fscache_put_object(struct fscache_object *object, in fscache_put_object() argument
783 object->cache->ops->put_object(object, why); in fscache_put_object()
793 void fscache_object_destroy(struct fscache_object *object) in fscache_object_destroy() argument
796 fscache_cookie_put(object->cookie, fscache_cookie_put_object); in fscache_object_destroy()
797 object->cookie = NULL; in fscache_object_destroy()
804 void fscache_enqueue_object(struct fscache_object *object) in fscache_enqueue_object() argument
806 _enter("{OBJ%x}", object->debug_id); in fscache_enqueue_object()
808 if (fscache_get_object(object, fscache_obj_get_queue) >= 0) { in fscache_enqueue_object()
812 if (queue_work(fscache_object_wq, &object->work)) { in fscache_enqueue_object()
816 fscache_put_object(object, fscache_obj_put_queue); in fscache_enqueue_object()
858 static bool fscache_enqueue_dependents(struct fscache_object *object, int event) in fscache_enqueue_dependents() argument
863 _enter("{OBJ%x}", object->debug_id); in fscache_enqueue_dependents()
865 if (list_empty(&object->dependents)) in fscache_enqueue_dependents()
868 spin_lock(&object->lock); in fscache_enqueue_dependents()
870 while (!list_empty(&object->dependents)) { in fscache_enqueue_dependents()
871 dep = list_entry(object->dependents.next, in fscache_enqueue_dependents()
878 if (!list_empty(&object->dependents) && need_resched()) { in fscache_enqueue_dependents()
884 spin_unlock(&object->lock); in fscache_enqueue_dependents()
891 static void fscache_dequeue_object(struct fscache_object *object) in fscache_dequeue_object() argument
893 _enter("{OBJ%x}", object->debug_id); in fscache_dequeue_object()
895 if (!list_empty(&object->dep_link)) { in fscache_dequeue_object()
896 spin_lock(&object->parent->lock); in fscache_dequeue_object()
897 list_del_init(&object->dep_link); in fscache_dequeue_object()
898 spin_unlock(&object->parent->lock); in fscache_dequeue_object()
916 enum fscache_checkaux fscache_check_aux(struct fscache_object *object, in fscache_check_aux() argument
922 if (!object->cookie->def->check_aux) { in fscache_check_aux()
927 result = object->cookie->def->check_aux(object->cookie->netfs_data, in fscache_check_aux()
956 static const struct fscache_state *_fscache_invalidate_object(struct fscache_object *object, in _fscache_invalidate_object() argument
960 struct fscache_cookie *cookie = object->cookie; in _fscache_invalidate_object()
962 _enter("{OBJ%x},%d", object->debug_id, event); in _fscache_invalidate_object()
967 if (!fscache_use_cookie(object)) { in _fscache_invalidate_object()
968 ASSERT(radix_tree_empty(&object->cookie->stores)); in _fscache_invalidate_object()
969 set_bit(FSCACHE_OBJECT_RETIRED, &object->flags); in _fscache_invalidate_object()
976 clear_bit(FSCACHE_OBJECT_PENDING_WRITE, &object->flags); in _fscache_invalidate_object()
977 fscache_cancel_all_ops(object); in _fscache_invalidate_object()
984 fscache_operation_init(cookie, op, object->cache->ops->invalidate_object, in _fscache_invalidate_object()
992 if (fscache_submit_exclusive_op(object, op) < 0) in _fscache_invalidate_object()
1012 fscache_mark_object_dead(object); in _fscache_invalidate_object()
1013 fscache_unuse_cookie(object); in _fscache_invalidate_object()
1018 fscache_mark_object_dead(object); in _fscache_invalidate_object()
1020 fscache_unuse_cookie(object); in _fscache_invalidate_object()
1026 static const struct fscache_state *fscache_invalidate_object(struct fscache_object *object, in fscache_invalidate_object() argument
1033 s = _fscache_invalidate_object(object, event); in fscache_invalidate_object()
1041 static void fscache_update_aux_data(struct fscache_object *object) in fscache_update_aux_data() argument
1045 object->cache->ops->update_object(object); in fscache_update_aux_data()
1052 static const struct fscache_state *fscache_update_object(struct fscache_object *object, in fscache_update_object() argument
1055 _enter("{OBJ%x},%d", object->debug_id, event); in fscache_update_object()
1057 fscache_update_aux_data(object); in fscache_update_object()
1070 void fscache_object_retrying_stale(struct fscache_object *object) in fscache_object_retrying_stale() argument
1084 void fscache_object_mark_killed(struct fscache_object *object, in fscache_object_mark_killed() argument
1087 if (test_and_set_bit(FSCACHE_OBJECT_KILLED_BY_CACHE, &object->flags)) { in fscache_object_mark_killed()
1089 object->cache->identifier); in fscache_object_mark_killed()
1116 static const struct fscache_state *fscache_object_dead(struct fscache_object *object, in fscache_object_dead() argument
1120 &object->flags)) in fscache_object_dead()