Lines Matching refs:object

153 static inline void fscache_done_parent_op(struct fscache_object *object)  in fscache_done_parent_op()  argument
155 struct fscache_object *parent = object->parent; in fscache_done_parent_op()
158 object->debug_id, parent->debug_id, parent->n_ops); in fscache_done_parent_op()
171 static void fscache_object_sm_dispatcher(struct fscache_object *object) in fscache_object_sm_dispatcher() argument
179 ASSERT(object != NULL); in fscache_object_sm_dispatcher()
182 object->debug_id, object->state->name, object->events); in fscache_object_sm_dispatcher()
184 event_mask = object->event_mask; in fscache_object_sm_dispatcher()
186 object->event_mask = 0; /* Mask normal event handling */ in fscache_object_sm_dispatcher()
187 state = object->state; in fscache_object_sm_dispatcher()
189 events = object->events; in fscache_object_sm_dispatcher()
192 if (events & object->oob_event_mask) { in fscache_object_sm_dispatcher()
194 object->debug_id, events & object->oob_event_mask); in fscache_object_sm_dispatcher()
196 for (t = object->oob_table; t->events; t++) { in fscache_object_sm_dispatcher()
201 __clear_bit(event, &object->oob_event_mask); in fscache_object_sm_dispatcher()
202 clear_bit(event, &object->events); in fscache_object_sm_dispatcher()
216 trace_fscache_osm(object, state, in fscache_object_sm_dispatcher()
218 clear_bit(event, &object->events); in fscache_object_sm_dispatcher()
220 object->debug_id, event, in fscache_object_sm_dispatcher()
222 object->state = state = new_state; in fscache_object_sm_dispatcher()
235 _debug("{OBJ%x} exec %s", object->debug_id, state->name); in fscache_object_sm_dispatcher()
237 trace_fscache_osm(object, state, false, oob, event); in fscache_object_sm_dispatcher()
238 new_state = state->work(object, event); in fscache_object_sm_dispatcher()
241 _debug("{OBJ%x} %s notrans", object->debug_id, state->name); in fscache_object_sm_dispatcher()
246 fscache_enqueue_object(object); in fscache_object_sm_dispatcher()
247 event_mask = object->oob_event_mask; in fscache_object_sm_dispatcher()
252 object->debug_id, state->name, new_state->name); in fscache_object_sm_dispatcher()
253 object->state = state = new_state; in fscache_object_sm_dispatcher()
264 event_mask = object->oob_event_mask; in fscache_object_sm_dispatcher()
269 object->event_mask = event_mask; in fscache_object_sm_dispatcher()
271 events = object->events; in fscache_object_sm_dispatcher()
282 struct fscache_object *object = in fscache_object_work_func() local
286 _enter("{OBJ%x}", object->debug_id); in fscache_object_work_func()
289 fscache_object_sm_dispatcher(object); in fscache_object_work_func()
291 fscache_put_object(object, fscache_obj_put_work); in fscache_object_work_func()
305 void fscache_object_init(struct fscache_object *object, in fscache_object_init() argument
313 object->state = STATE(WAIT_FOR_INIT); in fscache_object_init()
314 object->oob_table = fscache_osm_init_oob; in fscache_object_init()
315 object->flags = 1 << FSCACHE_OBJECT_IS_LIVE; in fscache_object_init()
316 spin_lock_init(&object->lock); in fscache_object_init()
317 INIT_LIST_HEAD(&object->cache_link); in fscache_object_init()
318 INIT_HLIST_NODE(&object->cookie_link); in fscache_object_init()
319 INIT_WORK(&object->work, fscache_object_work_func); in fscache_object_init()
320 INIT_LIST_HEAD(&object->dependents); in fscache_object_init()
321 INIT_LIST_HEAD(&object->dep_link); in fscache_object_init()
322 INIT_LIST_HEAD(&object->pending_ops); in fscache_object_init()
323 object->n_children = 0; in fscache_object_init()
324 object->n_ops = object->n_in_progress = object->n_exclusive = 0; in fscache_object_init()
325 object->events = 0; in fscache_object_init()
326 object->store_limit = 0; in fscache_object_init()
327 object->store_limit_l = 0; in fscache_object_init()
328 object->cache = cache; in fscache_object_init()
329 object->cookie = cookie; in fscache_object_init()
331 object->parent = NULL; in fscache_object_init()
333 RB_CLEAR_NODE(&object->objlist_link); in fscache_object_init()
336 object->oob_event_mask = 0; in fscache_object_init()
337 for (t = object->oob_table; t->events; t++) in fscache_object_init()
338 object->oob_event_mask |= t->events; in fscache_object_init()
339 object->event_mask = object->oob_event_mask; in fscache_object_init()
340 for (t = object->state->transitions; t->events; t++) in fscache_object_init()
341 object->event_mask |= t->events; in fscache_object_init()
349 static inline void fscache_mark_object_dead(struct fscache_object *object) in fscache_mark_object_dead() argument
351 spin_lock(&object->lock); in fscache_mark_object_dead()
352 clear_bit(FSCACHE_OBJECT_IS_LIVE, &object->flags); in fscache_mark_object_dead()
353 spin_unlock(&object->lock); in fscache_mark_object_dead()
359 static const struct fscache_state *fscache_abort_initialisation(struct fscache_object *object, in fscache_abort_initialisation() argument
362 _enter("{OBJ%x},%d", object->debug_id, event); in fscache_abort_initialisation()
364 object->oob_event_mask = 0; in fscache_abort_initialisation()
365 fscache_dequeue_object(object); in fscache_abort_initialisation()
376 static const struct fscache_state *fscache_initialise_object(struct fscache_object *object, in fscache_initialise_object() argument
382 _enter("{OBJ%x},%d", object->debug_id, event); in fscache_initialise_object()
384 ASSERT(list_empty(&object->dep_link)); in fscache_initialise_object()
386 parent = object->parent; in fscache_initialise_object()
410 object->cache->ops->grab_object(object, fscache_obj_get_add_to_deps)) { in fscache_initialise_object()
411 list_add(&object->dep_link, &parent->dependents); in fscache_initialise_object()
431 static const struct fscache_state *fscache_parent_ready(struct fscache_object *object, in fscache_parent_ready() argument
434 struct fscache_object *parent = object->parent; in fscache_parent_ready()
436 _enter("{OBJ%x},%d", object->debug_id, event); in fscache_parent_ready()
443 object->lookup_jif = jiffies; in fscache_parent_ready()
455 static const struct fscache_state *fscache_look_up_object(struct fscache_object *object, in fscache_look_up_object() argument
458 struct fscache_cookie *cookie = object->cookie; in fscache_look_up_object()
459 struct fscache_object *parent = object->parent; in fscache_look_up_object()
462 _enter("{OBJ%x},%d", object->debug_id, event); in fscache_look_up_object()
464 object->oob_table = fscache_osm_lookup_oob; in fscache_look_up_object()
474 test_bit(FSCACHE_IOERROR, &object->cache->flags) || in fscache_look_up_object()
475 !fscache_use_cookie(object)) { in fscache_look_up_object()
481 cookie->def->name, object->cache->tag->name); in fscache_look_up_object()
485 ret = object->cache->ops->lookup_object(object); in fscache_look_up_object()
488 fscache_unuse_cookie(object); in fscache_look_up_object()
514 void fscache_object_lookup_negative(struct fscache_object *object) in fscache_object_lookup_negative() argument
516 struct fscache_cookie *cookie = object->cookie; in fscache_object_lookup_negative()
518 _enter("{OBJ%x,%s}", object->debug_id, object->state->name); in fscache_object_lookup_negative()
520 if (!test_and_set_bit(FSCACHE_OBJECT_IS_LOOKED_UP, &object->flags)) { in fscache_object_lookup_negative()
547 void fscache_obtained_object(struct fscache_object *object) in fscache_obtained_object() argument
549 struct fscache_cookie *cookie = object->cookie; in fscache_obtained_object()
551 _enter("{OBJ%x,%s}", object->debug_id, object->state->name); in fscache_obtained_object()
555 if (!test_and_set_bit(FSCACHE_OBJECT_IS_LOOKED_UP, &object->flags)) { in fscache_obtained_object()
571 set_bit(FSCACHE_OBJECT_IS_AVAILABLE, &object->flags); in fscache_obtained_object()
579 static const struct fscache_state *fscache_object_available(struct fscache_object *object, in fscache_object_available() argument
582 _enter("{OBJ%x},%d", object->debug_id, event); in fscache_object_available()
584 object->oob_table = fscache_osm_run_oob; in fscache_object_available()
586 spin_lock(&object->lock); in fscache_object_available()
588 fscache_done_parent_op(object); in fscache_object_available()
589 if (object->n_in_progress == 0) { in fscache_object_available()
590 if (object->n_ops > 0) { in fscache_object_available()
591 ASSERTCMP(object->n_ops, >=, object->n_obj_ops); in fscache_object_available()
592 fscache_start_operations(object); in fscache_object_available()
594 ASSERT(list_empty(&object->pending_ops)); in fscache_object_available()
597 spin_unlock(&object->lock); in fscache_object_available()
600 object->cache->ops->lookup_complete(object); in fscache_object_available()
603 fscache_hist(fscache_obj_instantiate_histogram, object->lookup_jif); in fscache_object_available()
613 static const struct fscache_state *fscache_jumpstart_dependents(struct fscache_object *object, in fscache_jumpstart_dependents() argument
616 _enter("{OBJ%x},%d", object->debug_id, event); in fscache_jumpstart_dependents()
618 if (!fscache_enqueue_dependents(object, FSCACHE_OBJECT_EV_PARENT_READY)) in fscache_jumpstart_dependents()
626 static const struct fscache_state *fscache_lookup_failure(struct fscache_object *object, in fscache_lookup_failure() argument
631 _enter("{OBJ%x},%d", object->debug_id, event); in fscache_lookup_failure()
633 object->oob_event_mask = 0; in fscache_lookup_failure()
636 object->cache->ops->lookup_complete(object); in fscache_lookup_failure()
639 set_bit(FSCACHE_OBJECT_KILLED_BY_CACHE, &object->flags); in fscache_lookup_failure()
641 cookie = object->cookie; in fscache_lookup_failure()
646 fscache_done_parent_op(object); in fscache_lookup_failure()
654 static const struct fscache_state *fscache_kill_object(struct fscache_object *object, in fscache_kill_object() argument
658 object->debug_id, object->n_ops, object->n_children, event); in fscache_kill_object()
660 fscache_mark_object_dead(object); in fscache_kill_object()
661 object->oob_event_mask = 0; in fscache_kill_object()
663 if (test_bit(FSCACHE_OBJECT_RETIRED, &object->flags)) { in fscache_kill_object()
665 clear_bit(FSCACHE_OBJECT_PENDING_WRITE, &object->flags); in fscache_kill_object()
666 fscache_cancel_all_ops(object); in fscache_kill_object()
669 if (list_empty(&object->dependents) && in fscache_kill_object()
670 object->n_ops == 0 && in fscache_kill_object()
671 object->n_children == 0) in fscache_kill_object()
674 if (object->n_in_progress == 0) { in fscache_kill_object()
675 spin_lock(&object->lock); in fscache_kill_object()
676 if (object->n_ops > 0 && object->n_in_progress == 0) in fscache_kill_object()
677 fscache_start_operations(object); in fscache_kill_object()
678 spin_unlock(&object->lock); in fscache_kill_object()
681 if (!list_empty(&object->dependents)) in fscache_kill_object()
690 static const struct fscache_state *fscache_kill_dependents(struct fscache_object *object, in fscache_kill_dependents() argument
693 _enter("{OBJ%x},%d", object->debug_id, event); in fscache_kill_dependents()
695 if (!fscache_enqueue_dependents(object, FSCACHE_OBJECT_EV_KILL)) in fscache_kill_dependents()
703 static const struct fscache_state *fscache_drop_object(struct fscache_object *object, in fscache_drop_object() argument
706 struct fscache_object *parent = object->parent; in fscache_drop_object()
707 struct fscache_cookie *cookie = object->cookie; in fscache_drop_object()
708 struct fscache_cache *cache = object->cache; in fscache_drop_object()
711 _enter("{OBJ%x,%d},%d", object->debug_id, object->n_children, event); in fscache_drop_object()
714 ASSERT(!hlist_unhashed(&object->cookie_link)); in fscache_drop_object()
718 fscache_update_aux_data(object); in fscache_drop_object()
725 hlist_del_init(&object->cookie_link); in fscache_drop_object()
737 spin_lock(&object->lock); in fscache_drop_object()
738 spin_unlock(&object->lock); in fscache_drop_object()
742 list_del_init(&object->cache_link); in fscache_drop_object()
746 cache->ops->drop_object(object); in fscache_drop_object()
759 object->parent = NULL; in fscache_drop_object()
763 fscache_put_object(object, fscache_obj_put_drop_obj); in fscache_drop_object()
773 static int fscache_get_object(struct fscache_object *object, in fscache_get_object() argument
779 ret = object->cache->ops->grab_object(object, why) ? 0 : -EAGAIN; in fscache_get_object()
787 static void fscache_put_object(struct fscache_object *object, in fscache_put_object() argument
791 object->cache->ops->put_object(object, why); in fscache_put_object()
801 void fscache_object_destroy(struct fscache_object *object) in fscache_object_destroy() argument
803 fscache_objlist_remove(object); in fscache_object_destroy()
806 fscache_cookie_put(object->cookie, fscache_cookie_put_object); in fscache_object_destroy()
807 object->cookie = NULL; in fscache_object_destroy()
814 void fscache_enqueue_object(struct fscache_object *object) in fscache_enqueue_object() argument
816 _enter("{OBJ%x}", object->debug_id); in fscache_enqueue_object()
818 if (fscache_get_object(object, fscache_obj_get_queue) >= 0) { in fscache_enqueue_object()
822 if (queue_work(fscache_object_wq, &object->work)) { in fscache_enqueue_object()
826 fscache_put_object(object, fscache_obj_put_queue); in fscache_enqueue_object()
868 static bool fscache_enqueue_dependents(struct fscache_object *object, int event) in fscache_enqueue_dependents() argument
873 _enter("{OBJ%x}", object->debug_id); in fscache_enqueue_dependents()
875 if (list_empty(&object->dependents)) in fscache_enqueue_dependents()
878 spin_lock(&object->lock); in fscache_enqueue_dependents()
880 while (!list_empty(&object->dependents)) { in fscache_enqueue_dependents()
881 dep = list_entry(object->dependents.next, in fscache_enqueue_dependents()
888 if (!list_empty(&object->dependents) && need_resched()) { in fscache_enqueue_dependents()
894 spin_unlock(&object->lock); in fscache_enqueue_dependents()
901 static void fscache_dequeue_object(struct fscache_object *object) in fscache_dequeue_object() argument
903 _enter("{OBJ%x}", object->debug_id); in fscache_dequeue_object()
905 if (!list_empty(&object->dep_link)) { in fscache_dequeue_object()
906 spin_lock(&object->parent->lock); in fscache_dequeue_object()
907 list_del_init(&object->dep_link); in fscache_dequeue_object()
908 spin_unlock(&object->parent->lock); in fscache_dequeue_object()
925 enum fscache_checkaux fscache_check_aux(struct fscache_object *object, in fscache_check_aux() argument
931 if (!object->cookie->def->check_aux) { in fscache_check_aux()
936 result = object->cookie->def->check_aux(object->cookie->netfs_data, in fscache_check_aux()
965 static const struct fscache_state *_fscache_invalidate_object(struct fscache_object *object, in _fscache_invalidate_object() argument
969 struct fscache_cookie *cookie = object->cookie; in _fscache_invalidate_object()
971 _enter("{OBJ%x},%d", object->debug_id, event); in _fscache_invalidate_object()
976 if (!fscache_use_cookie(object)) { in _fscache_invalidate_object()
977 ASSERT(radix_tree_empty(&object->cookie->stores)); in _fscache_invalidate_object()
978 set_bit(FSCACHE_OBJECT_RETIRED, &object->flags); in _fscache_invalidate_object()
985 clear_bit(FSCACHE_OBJECT_PENDING_WRITE, &object->flags); in _fscache_invalidate_object()
986 fscache_cancel_all_ops(object); in _fscache_invalidate_object()
993 fscache_operation_init(cookie, op, object->cache->ops->invalidate_object, in _fscache_invalidate_object()
1001 if (fscache_submit_exclusive_op(object, op) < 0) in _fscache_invalidate_object()
1021 fscache_mark_object_dead(object); in _fscache_invalidate_object()
1022 fscache_unuse_cookie(object); in _fscache_invalidate_object()
1027 fscache_mark_object_dead(object); in _fscache_invalidate_object()
1029 fscache_unuse_cookie(object); in _fscache_invalidate_object()
1035 static const struct fscache_state *fscache_invalidate_object(struct fscache_object *object, in fscache_invalidate_object() argument
1042 s = _fscache_invalidate_object(object, event); in fscache_invalidate_object()
1050 static void fscache_update_aux_data(struct fscache_object *object) in fscache_update_aux_data() argument
1054 object->cache->ops->update_object(object); in fscache_update_aux_data()
1061 static const struct fscache_state *fscache_update_object(struct fscache_object *object, in fscache_update_object() argument
1064 _enter("{OBJ%x},%d", object->debug_id, event); in fscache_update_object()
1066 fscache_update_aux_data(object); in fscache_update_object()
1079 void fscache_object_retrying_stale(struct fscache_object *object) in fscache_object_retrying_stale() argument
1093 void fscache_object_mark_killed(struct fscache_object *object, in fscache_object_mark_killed() argument
1096 if (test_and_set_bit(FSCACHE_OBJECT_KILLED_BY_CACHE, &object->flags)) { in fscache_object_mark_killed()
1098 object->cache->identifier); in fscache_object_mark_killed()
1125 static const struct fscache_state *fscache_object_dead(struct fscache_object *object, in fscache_object_dead() argument
1129 &object->flags)) in fscache_object_dead()