blob: 8f17debd7979fbe13e41acd69bc64b06834b0987 [file] [log] [blame]
David Howells36c95592009-04-03 16:42:38 +01001/* FS-Cache object state machine handler
2 *
3 * Copyright (C) 2007 Red Hat, Inc. All Rights Reserved.
4 * Written by David Howells (dhowells@redhat.com)
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version
9 * 2 of the License, or (at your option) any later version.
10 *
11 * See Documentation/filesystems/caching/object.txt for a description of the
12 * object state machine and the in-kernel representations.
13 */
14
15#define FSCACHE_DEBUG_LEVEL COOKIE
16#include <linux/module.h>
David Howellsef778e72012-12-20 21:52:36 +000017#include <linux/slab.h>
David Howellscaaef692013-05-10 19:50:26 +010018#include <linux/prefetch.h>
David Howells36c95592009-04-03 16:42:38 +010019#include "internal.h"
20
David Howellscaaef692013-05-10 19:50:26 +010021static const struct fscache_state *fscache_abort_initialisation(struct fscache_object *, int);
22static const struct fscache_state *fscache_kill_dependents(struct fscache_object *, int);
23static const struct fscache_state *fscache_drop_object(struct fscache_object *, int);
24static const struct fscache_state *fscache_initialise_object(struct fscache_object *, int);
25static const struct fscache_state *fscache_invalidate_object(struct fscache_object *, int);
26static const struct fscache_state *fscache_jumpstart_dependents(struct fscache_object *, int);
27static const struct fscache_state *fscache_kill_object(struct fscache_object *, int);
28static const struct fscache_state *fscache_lookup_failure(struct fscache_object *, int);
29static const struct fscache_state *fscache_look_up_object(struct fscache_object *, int);
30static const struct fscache_state *fscache_object_available(struct fscache_object *, int);
31static const struct fscache_state *fscache_parent_ready(struct fscache_object *, int);
32static const struct fscache_state *fscache_update_object(struct fscache_object *, int);
33static const struct fscache_state *fscache_detach_from_cookie(struct fscache_object *, int);
David Howells36c95592009-04-03 16:42:38 +010034
David Howellscaaef692013-05-10 19:50:26 +010035#define __STATE_NAME(n) fscache_osm_##n
36#define STATE(n) (&__STATE_NAME(n))
37
38/*
39 * Define a work state. Work states are execution states. No event processing
40 * is performed by them. The function attached to a work state returns a
41 * pointer indicating the next state to which the state machine should
42 * transition. Returning NO_TRANSIT repeats the current state, but goes back
43 * to the scheduler first.
44 */
45#define WORK_STATE(n, sn, f) \
46 const struct fscache_state __STATE_NAME(n) = { \
47 .name = #n, \
48 .short_name = sn, \
49 .work = f \
50 }
51
52/*
53 * Returns from work states.
54 */
55#define transit_to(state) ({ prefetch(&STATE(state)->work); STATE(state); })
56
57#define NO_TRANSIT ((struct fscache_state *)NULL)
58
59/*
60 * Define a wait state. Wait states are event processing states. No execution
61 * is performed by them. Wait states are just tables of "if event X occurs,
62 * clear it and transition to state Y". The dispatcher returns to the
63 * scheduler if none of the events in which the wait state has an interest are
64 * currently pending.
65 */
66#define WAIT_STATE(n, sn, ...) \
67 const struct fscache_state __STATE_NAME(n) = { \
68 .name = #n, \
69 .short_name = sn, \
70 .work = NULL, \
71 .transitions = { __VA_ARGS__, { 0, NULL } } \
72 }
73
74#define TRANSIT_TO(state, emask) \
75 { .events = (emask), .transit_to = STATE(state) }
76
77/*
78 * The object state machine.
79 */
80static WORK_STATE(INIT_OBJECT, "INIT", fscache_initialise_object);
81static WORK_STATE(PARENT_READY, "PRDY", fscache_parent_ready);
82static WORK_STATE(ABORT_INIT, "ABRT", fscache_abort_initialisation);
83static WORK_STATE(LOOK_UP_OBJECT, "LOOK", fscache_look_up_object);
84static WORK_STATE(CREATE_OBJECT, "CRTO", fscache_look_up_object);
85static WORK_STATE(OBJECT_AVAILABLE, "AVBL", fscache_object_available);
86static WORK_STATE(JUMPSTART_DEPS, "JUMP", fscache_jumpstart_dependents);
87
88static WORK_STATE(INVALIDATE_OBJECT, "INVL", fscache_invalidate_object);
89static WORK_STATE(UPDATE_OBJECT, "UPDT", fscache_update_object);
90
91static WORK_STATE(LOOKUP_FAILURE, "LCFL", fscache_lookup_failure);
92static WORK_STATE(KILL_OBJECT, "KILL", fscache_kill_object);
93static WORK_STATE(KILL_DEPENDENTS, "KDEP", fscache_kill_dependents);
94static WORK_STATE(DROP_OBJECT, "DROP", fscache_drop_object);
95static WORK_STATE(DETACH_FROM_COOKIE, "DTCH", fscache_detach_from_cookie);
96static WORK_STATE(OBJECT_DEAD, "DEAD", (void*)2UL);
97
98static WAIT_STATE(WAIT_FOR_INIT, "?INI",
99 TRANSIT_TO(INIT_OBJECT, 1 << FSCACHE_OBJECT_EV_NEW_CHILD));
100
101static WAIT_STATE(WAIT_FOR_PARENT, "?PRN",
102 TRANSIT_TO(PARENT_READY, 1 << FSCACHE_OBJECT_EV_PARENT_READY));
103
104static WAIT_STATE(WAIT_FOR_CMD, "?CMD",
105 TRANSIT_TO(INVALIDATE_OBJECT, 1 << FSCACHE_OBJECT_EV_INVALIDATE),
106 TRANSIT_TO(UPDATE_OBJECT, 1 << FSCACHE_OBJECT_EV_UPDATE),
107 TRANSIT_TO(JUMPSTART_DEPS, 1 << FSCACHE_OBJECT_EV_NEW_CHILD));
108
109static WAIT_STATE(WAIT_FOR_CLEARANCE, "?CLR",
110 TRANSIT_TO(KILL_OBJECT, 1 << FSCACHE_OBJECT_EV_CLEARED));
111
112/*
113 * Out-of-band event transition tables. These are for handling unexpected
114 * events, such as an I/O error. If an OOB event occurs, the state machine
115 * clears and disables the event and forces a transition to the nominated work
116 * state (acurrently executing work states will complete first).
117 *
118 * In such a situation, object->state remembers the state the machine should
119 * have been in/gone to and returning NO_TRANSIT returns to that.
120 */
121static const struct fscache_transition fscache_osm_init_oob[] = {
122 TRANSIT_TO(ABORT_INIT,
123 (1 << FSCACHE_OBJECT_EV_ERROR) |
124 (1 << FSCACHE_OBJECT_EV_KILL)),
125 { 0, NULL }
126};
127
128static const struct fscache_transition fscache_osm_lookup_oob[] = {
129 TRANSIT_TO(LOOKUP_FAILURE,
130 (1 << FSCACHE_OBJECT_EV_ERROR) |
131 (1 << FSCACHE_OBJECT_EV_KILL)),
132 { 0, NULL }
133};
134
135static const struct fscache_transition fscache_osm_run_oob[] = {
136 TRANSIT_TO(KILL_OBJECT,
137 (1 << FSCACHE_OBJECT_EV_ERROR) |
138 (1 << FSCACHE_OBJECT_EV_KILL)),
139 { 0, NULL }
David Howells440f0af2009-11-19 18:11:01 +0000140};
141
Tejun Heo8b8edef2010-07-20 22:09:01 +0200142static int fscache_get_object(struct fscache_object *);
143static void fscache_put_object(struct fscache_object *);
David Howellscaaef692013-05-10 19:50:26 +0100144static bool fscache_enqueue_dependents(struct fscache_object *, int);
David Howells36c95592009-04-03 16:42:38 +0100145static void fscache_dequeue_object(struct fscache_object *);
146
David Howells36c95592009-04-03 16:42:38 +0100147/*
148 * we need to notify the parent when an op completes that we had outstanding
149 * upon it
150 */
151static inline void fscache_done_parent_op(struct fscache_object *object)
152{
153 struct fscache_object *parent = object->parent;
154
155 _enter("OBJ%x {OBJ%x,%x}",
156 object->debug_id, parent->debug_id, parent->n_ops);
157
158 spin_lock_nested(&parent->lock, 1);
159 parent->n_ops--;
160 parent->n_obj_ops--;
161 if (parent->n_ops == 0)
162 fscache_raise_event(parent, FSCACHE_OBJECT_EV_CLEARED);
163 spin_unlock(&parent->lock);
164}
165
166/*
David Howellscaaef692013-05-10 19:50:26 +0100167 * Object state machine dispatcher.
David Howellsef778e72012-12-20 21:52:36 +0000168 */
David Howellscaaef692013-05-10 19:50:26 +0100169static void fscache_object_sm_dispatcher(struct fscache_object *object)
David Howellsef778e72012-12-20 21:52:36 +0000170{
David Howellscaaef692013-05-10 19:50:26 +0100171 const struct fscache_transition *t;
172 const struct fscache_state *state, *new_state;
173 unsigned long events, event_mask;
174 int event = -1;
David Howells36c95592009-04-03 16:42:38 +0100175
176 ASSERT(object != NULL);
177
178 _enter("{OBJ%x,%s,%lx}",
David Howellscaaef692013-05-10 19:50:26 +0100179 object->debug_id, object->state->name, object->events);
David Howells36c95592009-04-03 16:42:38 +0100180
David Howellscaaef692013-05-10 19:50:26 +0100181 event_mask = object->event_mask;
182restart:
183 object->event_mask = 0; /* Mask normal event handling */
184 state = object->state;
185restart_masked:
186 events = object->events;
David Howells36c95592009-04-03 16:42:38 +0100187
David Howellscaaef692013-05-10 19:50:26 +0100188 /* Handle any out-of-band events (typically an error) */
189 if (events & object->oob_event_mask) {
190 _debug("{OBJ%x} oob %lx",
191 object->debug_id, events & object->oob_event_mask);
192 for (t = object->oob_table; t->events; t++) {
193 if (events & t->events) {
194 state = t->transit_to;
195 ASSERT(state->work != NULL);
196 event = fls(events & t->events) - 1;
197 __clear_bit(event, &object->oob_event_mask);
198 clear_bit(event, &object->events);
199 goto execute_work_state;
200 }
David Howellsd461d262009-11-19 18:11:41 +0000201 }
David Howellscaaef692013-05-10 19:50:26 +0100202 }
David Howells36c95592009-04-03 16:42:38 +0100203
David Howellscaaef692013-05-10 19:50:26 +0100204 /* Wait states are just transition tables */
205 if (!state->work) {
206 if (events & event_mask) {
207 for (t = state->transitions; t->events; t++) {
208 if (events & t->events) {
209 new_state = t->transit_to;
210 event = fls(events & t->events) - 1;
211 clear_bit(event, &object->events);
212 _debug("{OBJ%x} ev %d: %s -> %s",
213 object->debug_id, event,
214 state->name, new_state->name);
215 object->state = state = new_state;
216 goto execute_work_state;
217 }
218 }
David Howells36c95592009-04-03 16:42:38 +0100219
David Howellscaaef692013-05-10 19:50:26 +0100220 /* The event mask didn't include all the tabled bits */
221 BUG();
David Howells36c95592009-04-03 16:42:38 +0100222 }
David Howellscaaef692013-05-10 19:50:26 +0100223 /* Randomly woke up */
224 goto unmask_events;
David Howells36c95592009-04-03 16:42:38 +0100225 }
226
David Howellscaaef692013-05-10 19:50:26 +0100227execute_work_state:
228 _debug("{OBJ%x} exec %s", object->debug_id, state->name);
229
230 new_state = state->work(object, event);
231 event = -1;
232 if (new_state == NO_TRANSIT) {
233 _debug("{OBJ%x} %s notrans", object->debug_id, state->name);
234 fscache_enqueue_object(object);
235 event_mask = object->oob_event_mask;
236 goto unmask_events;
David Howells36c95592009-04-03 16:42:38 +0100237 }
238
David Howellscaaef692013-05-10 19:50:26 +0100239 _debug("{OBJ%x} %s -> %s",
240 object->debug_id, state->name, new_state->name);
241 object->state = state = new_state;
242
243 if (state->work) {
244 if (unlikely(state->work == ((void *)2UL))) {
245 _leave(" [dead]");
246 return;
247 }
248 goto restart_masked;
David Howells36c95592009-04-03 16:42:38 +0100249 }
250
David Howellscaaef692013-05-10 19:50:26 +0100251 /* Transited to wait state */
252 event_mask = object->oob_event_mask;
253 for (t = state->transitions; t->events; t++)
254 event_mask |= t->events;
David Howells36c95592009-04-03 16:42:38 +0100255
David Howellscaaef692013-05-10 19:50:26 +0100256unmask_events:
257 object->event_mask = event_mask;
258 smp_mb();
259 events = object->events;
260 if (events & event_mask)
261 goto restart;
262 _leave(" [msk %lx]", event_mask);
David Howells36c95592009-04-03 16:42:38 +0100263}
264
265/*
266 * execute an object
267 */
David Howells610be242013-05-10 19:50:25 +0100268static void fscache_object_work_func(struct work_struct *work)
David Howells36c95592009-04-03 16:42:38 +0100269{
270 struct fscache_object *object =
271 container_of(work, struct fscache_object, work);
272 unsigned long start;
273
274 _enter("{OBJ%x}", object->debug_id);
275
David Howells36c95592009-04-03 16:42:38 +0100276 start = jiffies;
David Howellscaaef692013-05-10 19:50:26 +0100277 fscache_object_sm_dispatcher(object);
David Howells36c95592009-04-03 16:42:38 +0100278 fscache_hist(fscache_objs_histogram, start);
Tejun Heo8b8edef2010-07-20 22:09:01 +0200279 fscache_put_object(object);
David Howells36c95592009-04-03 16:42:38 +0100280}
David Howells610be242013-05-10 19:50:25 +0100281
282/**
283 * fscache_object_init - Initialise a cache object description
284 * @object: Object description
285 * @cookie: Cookie object will be attached to
286 * @cache: Cache in which backing object will be found
287 *
288 * Initialise a cache object description to its basic values.
289 *
290 * See Documentation/filesystems/caching/backend-api.txt for a complete
291 * description.
292 */
293void fscache_object_init(struct fscache_object *object,
294 struct fscache_cookie *cookie,
295 struct fscache_cache *cache)
296{
David Howellscaaef692013-05-10 19:50:26 +0100297 const struct fscache_transition *t;
298
David Howells610be242013-05-10 19:50:25 +0100299 atomic_inc(&cache->object_count);
300
David Howellscaaef692013-05-10 19:50:26 +0100301 object->state = STATE(WAIT_FOR_INIT);
302 object->oob_table = fscache_osm_init_oob;
303 object->flags = 1 << FSCACHE_OBJECT_IS_LIVE;
David Howells610be242013-05-10 19:50:25 +0100304 spin_lock_init(&object->lock);
305 INIT_LIST_HEAD(&object->cache_link);
306 INIT_HLIST_NODE(&object->cookie_link);
307 INIT_WORK(&object->work, fscache_object_work_func);
308 INIT_LIST_HEAD(&object->dependents);
309 INIT_LIST_HEAD(&object->dep_link);
310 INIT_LIST_HEAD(&object->pending_ops);
311 object->n_children = 0;
312 object->n_ops = object->n_in_progress = object->n_exclusive = 0;
David Howellscaaef692013-05-10 19:50:26 +0100313 object->events = 0;
David Howells610be242013-05-10 19:50:25 +0100314 object->store_limit = 0;
315 object->store_limit_l = 0;
316 object->cache = cache;
317 object->cookie = cookie;
318 object->parent = NULL;
David Howellscaaef692013-05-10 19:50:26 +0100319
320 object->oob_event_mask = 0;
321 for (t = object->oob_table; t->events; t++)
322 object->oob_event_mask |= t->events;
323 object->event_mask = object->oob_event_mask;
324 for (t = object->state->transitions; t->events; t++)
325 object->event_mask |= t->events;
David Howells610be242013-05-10 19:50:25 +0100326}
327EXPORT_SYMBOL(fscache_object_init);
David Howells440f0af2009-11-19 18:11:01 +0000328
329/*
David Howellscaaef692013-05-10 19:50:26 +0100330 * Abort object initialisation before we start it.
331 */
332static const struct fscache_state *fscache_abort_initialisation(struct fscache_object *object,
333 int event)
334{
335 struct fscache_cookie *cookie;
336
337 _enter("{OBJ%x},%d", object->debug_id, event);
338
339 object->oob_event_mask = 0;
340 clear_bit(FSCACHE_OBJECT_IS_LIVE, &object->flags);
341
342 fscache_dequeue_object(object);
343
344 spin_lock(&object->lock);
345 cookie = object->cookie;
346 clear_bit_unlock(FSCACHE_COOKIE_CREATING, &cookie->flags);
347 spin_unlock(&object->lock);
348
349 wake_up_bit(&cookie->flags, FSCACHE_COOKIE_CREATING);
350
351 return transit_to(KILL_OBJECT);
352}
353
354/*
David Howells36c95592009-04-03 16:42:38 +0100355 * initialise an object
356 * - check the specified object's parent to see if we can make use of it
357 * immediately to do a creation
358 * - we may need to start the process of creating a parent and we need to wait
359 * for the parent's lookup and creation to complete if it's not there yet
360 * - an object's cookie is pinned until we clear FSCACHE_COOKIE_CREATING on the
361 * leaf-most cookies of the object and all its children
362 */
David Howellscaaef692013-05-10 19:50:26 +0100363static const struct fscache_state *fscache_initialise_object(struct fscache_object *object,
364 int event)
David Howells36c95592009-04-03 16:42:38 +0100365{
366 struct fscache_object *parent;
David Howellscaaef692013-05-10 19:50:26 +0100367 bool success;
David Howells36c95592009-04-03 16:42:38 +0100368
David Howellscaaef692013-05-10 19:50:26 +0100369 _enter("{OBJ%x},%d", object->debug_id, event);
David Howells36c95592009-04-03 16:42:38 +0100370
David Howellscaaef692013-05-10 19:50:26 +0100371 ASSERT(list_empty(&object->dep_link));
David Howells36c95592009-04-03 16:42:38 +0100372
373 parent = object->parent;
374 if (!parent) {
David Howellscaaef692013-05-10 19:50:26 +0100375 _leave(" [no parent]");
376 return transit_to(DETACH_FROM_COOKIE);
David Howells36c95592009-04-03 16:42:38 +0100377 }
378
David Howellscaaef692013-05-10 19:50:26 +0100379 _debug("parent %s", parent->state->name);
380
381 if (fscache_object_is_dying(parent)) {
382 _leave(" [bad parent]");
383 return transit_to(DETACH_FROM_COOKIE);
384 }
385
386 if (fscache_object_is_available(parent)) {
387 _leave(" [ready]");
388 return transit_to(PARENT_READY);
389 }
390
391 _debug("wait");
392
393 spin_lock(&parent->lock);
394 fscache_stat(&fscache_n_cop_grab_object);
395 success = false;
396 if (fscache_object_is_live(parent) &&
397 object->cache->ops->grab_object(object)) {
398 list_add(&object->dep_link, &parent->dependents);
399 success = true;
400 }
401 fscache_stat_d(&fscache_n_cop_grab_object);
402 spin_unlock(&parent->lock);
403 if (!success) {
404 _leave(" [grab failed]");
405 return transit_to(DETACH_FROM_COOKIE);
406 }
407
408 /* fscache_acquire_non_index_cookie() uses this
409 * to wake the chain up */
410 fscache_raise_event(parent, FSCACHE_OBJECT_EV_NEW_CHILD);
411 _leave(" [wait]");
412 return transit_to(WAIT_FOR_PARENT);
413}
414
415/*
416 * Once the parent object is ready, we should kick off our lookup op.
417 */
418static const struct fscache_state *fscache_parent_ready(struct fscache_object *object,
419 int event)
420{
421 struct fscache_object *parent = object->parent;
422
423 _enter("{OBJ%x},%d", object->debug_id, event);
424
425 ASSERT(parent != NULL);
426
427 spin_lock(&parent->lock);
428 parent->n_ops++;
429 parent->n_obj_ops++;
430 object->lookup_jif = jiffies;
431 spin_unlock(&parent->lock);
432
David Howells36c95592009-04-03 16:42:38 +0100433 _leave("");
David Howellscaaef692013-05-10 19:50:26 +0100434 return transit_to(LOOK_UP_OBJECT);
David Howells36c95592009-04-03 16:42:38 +0100435}
436
437/*
438 * look an object up in the cache from which it was allocated
439 * - we hold an "access lock" on the parent object, so the parent object cannot
440 * be withdrawn by either party till we've finished
441 * - an object's cookie is pinned until we clear FSCACHE_COOKIE_CREATING on the
442 * leaf-most cookies of the object and all its children
443 */
David Howellscaaef692013-05-10 19:50:26 +0100444static const struct fscache_state *fscache_look_up_object(struct fscache_object *object,
445 int event)
David Howells36c95592009-04-03 16:42:38 +0100446{
447 struct fscache_cookie *cookie = object->cookie;
David Howellscaaef692013-05-10 19:50:26 +0100448 struct fscache_object *parent = object->parent;
David Howellsfee096d2009-11-19 18:12:05 +0000449 int ret;
David Howells36c95592009-04-03 16:42:38 +0100450
David Howellscaaef692013-05-10 19:50:26 +0100451 _enter("{OBJ%x},%d", object->debug_id, event);
David Howells36c95592009-04-03 16:42:38 +0100452
David Howellscaaef692013-05-10 19:50:26 +0100453 object->oob_table = fscache_osm_lookup_oob;
454
David Howells36c95592009-04-03 16:42:38 +0100455 ASSERT(parent != NULL);
456 ASSERTCMP(parent->n_ops, >, 0);
457 ASSERTCMP(parent->n_obj_ops, >, 0);
458
459 /* make sure the parent is still available */
David Howells493f7bc2013-05-10 19:50:26 +0100460 ASSERT(fscache_object_is_available(parent));
David Howells36c95592009-04-03 16:42:38 +0100461
David Howells493f7bc2013-05-10 19:50:26 +0100462 if (fscache_object_is_dying(parent) ||
David Howells36c95592009-04-03 16:42:38 +0100463 test_bit(FSCACHE_IOERROR, &object->cache->flags)) {
David Howellscaaef692013-05-10 19:50:26 +0100464 _leave(" [unavailable]");
465 return transit_to(LOOKUP_FAILURE);
David Howells36c95592009-04-03 16:42:38 +0100466 }
467
468 _debug("LOOKUP \"%s/%s\" in \"%s\"",
469 parent->cookie->def->name, cookie->def->name,
470 object->cache->tag->name);
471
472 fscache_stat(&fscache_n_object_lookups);
David Howells52bd75f2009-11-19 18:11:08 +0000473 fscache_stat(&fscache_n_cop_lookup_object);
David Howellsfee096d2009-11-19 18:12:05 +0000474 ret = object->cache->ops->lookup_object(object);
David Howells52bd75f2009-11-19 18:11:08 +0000475 fscache_stat_d(&fscache_n_cop_lookup_object);
David Howells36c95592009-04-03 16:42:38 +0100476
477 if (test_bit(FSCACHE_OBJECT_EV_ERROR, &object->events))
478 set_bit(FSCACHE_COOKIE_UNAVAILABLE, &cookie->flags);
479
David Howellsfee096d2009-11-19 18:12:05 +0000480 if (ret == -ETIMEDOUT) {
481 /* probably stuck behind another object, so move this one to
482 * the back of the queue */
483 fscache_stat(&fscache_n_object_lookups_timed_out);
David Howellscaaef692013-05-10 19:50:26 +0100484 _leave(" [timeout]");
485 return NO_TRANSIT;
David Howellsfee096d2009-11-19 18:12:05 +0000486 }
487
David Howellscaaef692013-05-10 19:50:26 +0100488 if (ret < 0) {
489 _leave(" [error]");
490 return transit_to(LOOKUP_FAILURE);
491 }
492
493 _leave(" [ok]");
494 return transit_to(OBJECT_AVAILABLE);
David Howells36c95592009-04-03 16:42:38 +0100495}
496
497/**
498 * fscache_object_lookup_negative - Note negative cookie lookup
499 * @object: Object pointing to cookie to mark
500 *
501 * Note negative lookup, permitting those waiting to read data from an already
502 * existing backing object to continue as there's no data for them to read.
503 */
504void fscache_object_lookup_negative(struct fscache_object *object)
505{
506 struct fscache_cookie *cookie = object->cookie;
507
David Howellscaaef692013-05-10 19:50:26 +0100508 _enter("{OBJ%x,%s}", object->debug_id, object->state->name);
David Howells36c95592009-04-03 16:42:38 +0100509
David Howellscaaef692013-05-10 19:50:26 +0100510 if (!test_and_set_bit(FSCACHE_OBJECT_IS_LOOKED_UP, &object->flags)) {
David Howells36c95592009-04-03 16:42:38 +0100511 fscache_stat(&fscache_n_object_lookups_negative);
512
David Howellscaaef692013-05-10 19:50:26 +0100513 /* Allow write requests to begin stacking up and read requests to begin
514 * returning ENODATA.
515 */
David Howells36c95592009-04-03 16:42:38 +0100516 set_bit(FSCACHE_COOKIE_NO_DATA_YET, &cookie->flags);
517
518 _debug("wake up lookup %p", &cookie->flags);
David Howellscaaef692013-05-10 19:50:26 +0100519 clear_bit_unlock(FSCACHE_COOKIE_LOOKING_UP, &cookie->flags);
David Howells36c95592009-04-03 16:42:38 +0100520 wake_up_bit(&cookie->flags, FSCACHE_COOKIE_LOOKING_UP);
David Howells36c95592009-04-03 16:42:38 +0100521 }
David Howells36c95592009-04-03 16:42:38 +0100522 _leave("");
523}
524EXPORT_SYMBOL(fscache_object_lookup_negative);
525
526/**
527 * fscache_obtained_object - Note successful object lookup or creation
528 * @object: Object pointing to cookie to mark
529 *
530 * Note successful lookup and/or creation, permitting those waiting to write
531 * data to a backing object to continue.
532 *
533 * Note that after calling this, an object's cookie may be relinquished by the
534 * netfs, and so must be accessed with object lock held.
535 */
536void fscache_obtained_object(struct fscache_object *object)
537{
538 struct fscache_cookie *cookie = object->cookie;
539
David Howellscaaef692013-05-10 19:50:26 +0100540 _enter("{OBJ%x,%s}", object->debug_id, object->state->name);
David Howells36c95592009-04-03 16:42:38 +0100541
542 /* if we were still looking up, then we must have a positive lookup
543 * result, in which case there may be data available */
David Howellscaaef692013-05-10 19:50:26 +0100544 if (!test_and_set_bit(FSCACHE_OBJECT_IS_LOOKED_UP, &object->flags)) {
David Howells36c95592009-04-03 16:42:38 +0100545 fscache_stat(&fscache_n_object_lookups_positive);
546
David Howellscaaef692013-05-10 19:50:26 +0100547 /* We do (presumably) have data */
548 clear_bit_unlock(FSCACHE_COOKIE_NO_DATA_YET, &cookie->flags);
David Howells36c95592009-04-03 16:42:38 +0100549
David Howellscaaef692013-05-10 19:50:26 +0100550 /* Allow write requests to begin stacking up and read requests
551 * to begin shovelling data.
552 */
553 clear_bit_unlock(FSCACHE_COOKIE_LOOKING_UP, &cookie->flags);
David Howells36c95592009-04-03 16:42:38 +0100554 wake_up_bit(&cookie->flags, FSCACHE_COOKIE_LOOKING_UP);
David Howells36c95592009-04-03 16:42:38 +0100555 } else {
David Howells36c95592009-04-03 16:42:38 +0100556 fscache_stat(&fscache_n_object_created);
David Howells36c95592009-04-03 16:42:38 +0100557 }
558
David Howellscaaef692013-05-10 19:50:26 +0100559 set_bit(FSCACHE_OBJECT_IS_AVAILABLE, &object->flags);
560
561 /* Permit __fscache_relinquish_cookie() to proceed */
562 clear_bit_unlock(FSCACHE_COOKIE_CREATING, &cookie->flags);
563 wake_up_bit(&cookie->flags, FSCACHE_COOKIE_CREATING);
David Howells36c95592009-04-03 16:42:38 +0100564
565 _leave("");
566}
567EXPORT_SYMBOL(fscache_obtained_object);
568
569/*
570 * handle an object that has just become available
571 */
David Howellscaaef692013-05-10 19:50:26 +0100572static const struct fscache_state *fscache_object_available(struct fscache_object *object,
573 int event)
David Howells36c95592009-04-03 16:42:38 +0100574{
David Howellscaaef692013-05-10 19:50:26 +0100575 struct fscache_cookie *cookie = object->cookie;
576
577 _enter("{OBJ%x},%d", object->debug_id, event);
578
579 object->oob_table = fscache_osm_run_oob;
David Howells36c95592009-04-03 16:42:38 +0100580
581 spin_lock(&object->lock);
582
David Howellscaaef692013-05-10 19:50:26 +0100583 ASSERTIF(cookie, !test_bit(FSCACHE_COOKIE_CREATING, &object->cookie->flags));
David Howells36c95592009-04-03 16:42:38 +0100584
585 fscache_done_parent_op(object);
586 if (object->n_in_progress == 0) {
587 if (object->n_ops > 0) {
588 ASSERTCMP(object->n_ops, >=, object->n_obj_ops);
David Howells36c95592009-04-03 16:42:38 +0100589 fscache_start_operations(object);
590 } else {
591 ASSERT(list_empty(&object->pending_ops));
592 }
593 }
594 spin_unlock(&object->lock);
595
David Howells52bd75f2009-11-19 18:11:08 +0000596 fscache_stat(&fscache_n_cop_lookup_complete);
David Howells36c95592009-04-03 16:42:38 +0100597 object->cache->ops->lookup_complete(object);
David Howells52bd75f2009-11-19 18:11:08 +0000598 fscache_stat_d(&fscache_n_cop_lookup_complete);
David Howells36c95592009-04-03 16:42:38 +0100599
600 fscache_hist(fscache_obj_instantiate_histogram, object->lookup_jif);
601 fscache_stat(&fscache_n_object_avail);
602
603 _leave("");
David Howellscaaef692013-05-10 19:50:26 +0100604 return transit_to(JUMPSTART_DEPS);
David Howells36c95592009-04-03 16:42:38 +0100605}
606
607/*
David Howellscaaef692013-05-10 19:50:26 +0100608 * Wake up this object's dependent objects now that we've become available.
David Howells36c95592009-04-03 16:42:38 +0100609 */
David Howellscaaef692013-05-10 19:50:26 +0100610static const struct fscache_state *fscache_jumpstart_dependents(struct fscache_object *object,
611 int event)
612{
613 _enter("{OBJ%x},%d", object->debug_id, event);
614
615 if (!fscache_enqueue_dependents(object, FSCACHE_OBJECT_EV_PARENT_READY))
616 return NO_TRANSIT; /* Not finished; requeue */
617 return transit_to(WAIT_FOR_CMD);
618}
619
620/*
621 * Handle lookup or creation failute.
622 */
623static const struct fscache_state *fscache_lookup_failure(struct fscache_object *object,
624 int event)
625{
626 struct fscache_cookie *cookie;
627 bool wake_looking_up = false;
628
629 _enter("{OBJ%x},%d", object->debug_id, event);
630
631 object->oob_event_mask = 0;
632
633 fscache_stat(&fscache_n_cop_lookup_complete);
634 object->cache->ops->lookup_complete(object);
635 fscache_stat_d(&fscache_n_cop_lookup_complete);
636
637 spin_lock(&object->lock);
638 cookie = object->cookie;
639 set_bit(FSCACHE_COOKIE_UNAVAILABLE, &cookie->flags);
640 if (cookie) {
641 if (test_and_clear_bit(FSCACHE_COOKIE_LOOKING_UP, &cookie->flags))
642 wake_looking_up = true;
643 clear_bit_unlock(FSCACHE_COOKIE_CREATING, &cookie->flags);
644 }
645 spin_unlock(&object->lock);
646
647 if (wake_looking_up)
648 wake_up_bit(&cookie->flags, FSCACHE_COOKIE_LOOKING_UP);
649 wake_up_bit(&cookie->flags, FSCACHE_COOKIE_CREATING);
650
651 fscache_done_parent_op(object);
652 return transit_to(KILL_OBJECT);
653}
654
655/*
656 * Wait for completion of all active operations on this object and the death of
657 * all child objects of this object.
658 */
659static const struct fscache_state *fscache_kill_object(struct fscache_object *object,
660 int event)
661{
662 _enter("{OBJ%x,%d,%d},%d",
663 object->debug_id, object->n_ops, object->n_children, event);
664
665 object->oob_event_mask = 0;
666
667 spin_lock(&object->lock);
668 clear_bit(FSCACHE_OBJECT_IS_LIVE, &object->flags);
669 spin_unlock(&object->lock);
670
671 if (list_empty(&object->dependents) &&
672 object->n_ops == 0 &&
673 object->n_children == 0)
674 return object->cookie ?
675 transit_to(DETACH_FROM_COOKIE) : transit_to(DROP_OBJECT);
676
677 spin_lock(&object->lock);
678 fscache_start_operations(object);
679 spin_unlock(&object->lock);
680
681 if (!list_empty(&object->dependents))
682 return transit_to(KILL_DEPENDENTS);
683
684 return transit_to(WAIT_FOR_CLEARANCE);
685}
686
687/*
688 * Kill dependent objects.
689 */
690static const struct fscache_state *fscache_kill_dependents(struct fscache_object *object,
691 int event)
692{
693 _enter("{OBJ%x},%d", object->debug_id, event);
694
695 if (!fscache_enqueue_dependents(object, FSCACHE_OBJECT_EV_KILL))
696 return NO_TRANSIT; /* Not finished */
697 return transit_to(WAIT_FOR_CLEARANCE);
698}
699
700/*
701 * withdraw an object from active service
702 */
703static const struct fscache_state *fscache_detach_from_cookie(struct fscache_object *object,
704 int event)
705{
706 struct fscache_cookie *cookie;
707 bool detached = false, awaken = false;
708
709 _enter("{OBJ%x},%d", object->debug_id, event);
710
711 spin_lock(&object->lock);
712 cookie = object->cookie;
713 if (cookie) {
714 /* need to get the cookie lock before the object lock, starting
715 * from the object pointer */
716 atomic_inc(&cookie->usage);
717 spin_unlock(&object->lock);
718
719 spin_lock(&cookie->lock);
720 spin_lock(&object->lock);
721
722 if (object->cookie == cookie) {
723 hlist_del_init(&object->cookie_link);
724 object->cookie = NULL;
725 if (test_and_clear_bit(FSCACHE_COOKIE_INVALIDATING,
726 &cookie->flags))
727 awaken = true;
728 detached = true;
729 }
730 spin_unlock(&cookie->lock);
731 fscache_cookie_put(cookie);
732 if (detached)
733 fscache_cookie_put(cookie);
734 }
735
736 spin_unlock(&object->lock);
737
738 if (awaken)
739 wake_up_bit(&cookie->flags, FSCACHE_COOKIE_INVALIDATING);
740
741 fscache_stat(&fscache_n_object_dead);
742 _leave("");
743 return transit_to(DROP_OBJECT);
744}
745
746/*
747 * Drop an object's attachments
748 */
749static const struct fscache_state *fscache_drop_object(struct fscache_object *object,
750 int event)
David Howells36c95592009-04-03 16:42:38 +0100751{
752 struct fscache_object *parent = object->parent;
753 struct fscache_cache *cache = object->cache;
754
David Howellscaaef692013-05-10 19:50:26 +0100755 _enter("{OBJ%x,%d},%d", object->debug_id, object->n_children, event);
David Howells36c95592009-04-03 16:42:38 +0100756
David Howells6897e3d2009-11-19 18:11:22 +0000757 ASSERTCMP(object->cookie, ==, NULL);
758 ASSERT(hlist_unhashed(&object->cookie_link));
759
David Howellscaaef692013-05-10 19:50:26 +0100760 /* Prevent a race with our last child, which has to signal EV_CLEARED
761 * before dropping our spinlock.
762 */
763 spin_lock(&object->lock);
764 spin_unlock(&object->lock);
765
766 /* Discard from the cache's collection of objects */
David Howells36c95592009-04-03 16:42:38 +0100767 spin_lock(&cache->object_list_lock);
768 list_del_init(&object->cache_link);
769 spin_unlock(&cache->object_list_lock);
770
David Howells52bd75f2009-11-19 18:11:08 +0000771 fscache_stat(&fscache_n_cop_drop_object);
David Howells36c95592009-04-03 16:42:38 +0100772 cache->ops->drop_object(object);
David Howells52bd75f2009-11-19 18:11:08 +0000773 fscache_stat_d(&fscache_n_cop_drop_object);
David Howells36c95592009-04-03 16:42:38 +0100774
David Howellscaaef692013-05-10 19:50:26 +0100775 /* The parent object wants to know when all it dependents have gone */
David Howells36c95592009-04-03 16:42:38 +0100776 if (parent) {
777 _debug("release parent OBJ%x {%d}",
778 parent->debug_id, parent->n_children);
779
780 spin_lock(&parent->lock);
781 parent->n_children--;
782 if (parent->n_children == 0)
783 fscache_raise_event(parent, FSCACHE_OBJECT_EV_CLEARED);
784 spin_unlock(&parent->lock);
785 object->parent = NULL;
786 }
787
Tejun Heo8b8edef2010-07-20 22:09:01 +0200788 /* this just shifts the object release to the work processor */
789 fscache_put_object(object);
David Howellscaaef692013-05-10 19:50:26 +0100790 fscache_stat(&fscache_n_object_dead);
David Howells36c95592009-04-03 16:42:38 +0100791
792 _leave("");
David Howellscaaef692013-05-10 19:50:26 +0100793 return transit_to(OBJECT_DEAD);
David Howells36c95592009-04-03 16:42:38 +0100794}
795
796/*
Tejun Heo8b8edef2010-07-20 22:09:01 +0200797 * get a ref on an object
David Howells36c95592009-04-03 16:42:38 +0100798 */
Tejun Heo8b8edef2010-07-20 22:09:01 +0200799static int fscache_get_object(struct fscache_object *object)
David Howells36c95592009-04-03 16:42:38 +0100800{
David Howells52bd75f2009-11-19 18:11:08 +0000801 int ret;
David Howells36c95592009-04-03 16:42:38 +0100802
David Howells52bd75f2009-11-19 18:11:08 +0000803 fscache_stat(&fscache_n_cop_grab_object);
804 ret = object->cache->ops->grab_object(object) ? 0 : -EAGAIN;
805 fscache_stat_d(&fscache_n_cop_grab_object);
806 return ret;
David Howells36c95592009-04-03 16:42:38 +0100807}
808
809/*
David Howellscaaef692013-05-10 19:50:26 +0100810 * Discard a ref on an object
David Howells36c95592009-04-03 16:42:38 +0100811 */
Tejun Heo8b8edef2010-07-20 22:09:01 +0200812static void fscache_put_object(struct fscache_object *object)
David Howells36c95592009-04-03 16:42:38 +0100813{
David Howells52bd75f2009-11-19 18:11:08 +0000814 fscache_stat(&fscache_n_cop_put_object);
815 object->cache->ops->put_object(object);
816 fscache_stat_d(&fscache_n_cop_put_object);
David Howells36c95592009-04-03 16:42:38 +0100817}
818
819/*
820 * enqueue an object for metadata-type processing
821 */
822void fscache_enqueue_object(struct fscache_object *object)
823{
824 _enter("{OBJ%x}", object->debug_id);
825
Tejun Heo8b8edef2010-07-20 22:09:01 +0200826 if (fscache_get_object(object) >= 0) {
827 wait_queue_head_t *cong_wq =
828 &get_cpu_var(fscache_object_cong_wait);
829
830 if (queue_work(fscache_object_wq, &object->work)) {
831 if (fscache_object_congested())
832 wake_up(cong_wq);
833 } else
834 fscache_put_object(object);
835
836 put_cpu_var(fscache_object_cong_wait);
837 }
David Howells36c95592009-04-03 16:42:38 +0100838}
839
Tejun Heo8b8edef2010-07-20 22:09:01 +0200840/**
841 * fscache_object_sleep_till_congested - Sleep until object wq is congested
David Howellscaaef692013-05-10 19:50:26 +0100842 * @timeoutp: Scheduler sleep timeout
Tejun Heo8b8edef2010-07-20 22:09:01 +0200843 *
844 * Allow an object handler to sleep until the object workqueue is congested.
845 *
846 * The caller must set up a wake up event before calling this and must have set
847 * the appropriate sleep mode (such as TASK_UNINTERRUPTIBLE) and tested its own
848 * condition before calling this function as no test is made here.
849 *
850 * %true is returned if the object wq is congested, %false otherwise.
851 */
852bool fscache_object_sleep_till_congested(signed long *timeoutp)
853{
854 wait_queue_head_t *cong_wq = &__get_cpu_var(fscache_object_cong_wait);
855 DEFINE_WAIT(wait);
856
857 if (fscache_object_congested())
858 return true;
859
860 add_wait_queue_exclusive(cong_wq, &wait);
861 if (!fscache_object_congested())
862 *timeoutp = schedule_timeout(*timeoutp);
863 finish_wait(cong_wq, &wait);
864
865 return fscache_object_congested();
866}
867EXPORT_SYMBOL_GPL(fscache_object_sleep_till_congested);
868
David Howells36c95592009-04-03 16:42:38 +0100869/*
David Howellscaaef692013-05-10 19:50:26 +0100870 * Enqueue the dependents of an object for metadata-type processing.
871 *
872 * If we don't manage to finish the list before the scheduler wants to run
873 * again then return false immediately. We return true if the list was
874 * cleared.
David Howells36c95592009-04-03 16:42:38 +0100875 */
David Howellscaaef692013-05-10 19:50:26 +0100876static bool fscache_enqueue_dependents(struct fscache_object *object, int event)
David Howells36c95592009-04-03 16:42:38 +0100877{
878 struct fscache_object *dep;
David Howellscaaef692013-05-10 19:50:26 +0100879 bool ret = true;
David Howells36c95592009-04-03 16:42:38 +0100880
881 _enter("{OBJ%x}", object->debug_id);
882
883 if (list_empty(&object->dependents))
David Howellscaaef692013-05-10 19:50:26 +0100884 return true;
David Howells36c95592009-04-03 16:42:38 +0100885
886 spin_lock(&object->lock);
887
888 while (!list_empty(&object->dependents)) {
889 dep = list_entry(object->dependents.next,
890 struct fscache_object, dep_link);
891 list_del_init(&dep->dep_link);
892
David Howellscaaef692013-05-10 19:50:26 +0100893 fscache_raise_event(dep, event);
Tejun Heo8b8edef2010-07-20 22:09:01 +0200894 fscache_put_object(dep);
David Howells36c95592009-04-03 16:42:38 +0100895
David Howellscaaef692013-05-10 19:50:26 +0100896 if (!list_empty(&object->dependents) && need_resched()) {
897 ret = false;
898 break;
899 }
David Howells36c95592009-04-03 16:42:38 +0100900 }
901
902 spin_unlock(&object->lock);
David Howellscaaef692013-05-10 19:50:26 +0100903 return ret;
David Howells36c95592009-04-03 16:42:38 +0100904}
905
906/*
907 * remove an object from whatever queue it's waiting on
David Howells36c95592009-04-03 16:42:38 +0100908 */
David Howellscaaef692013-05-10 19:50:26 +0100909static void fscache_dequeue_object(struct fscache_object *object)
David Howells36c95592009-04-03 16:42:38 +0100910{
911 _enter("{OBJ%x}", object->debug_id);
912
913 if (!list_empty(&object->dep_link)) {
914 spin_lock(&object->parent->lock);
915 list_del_init(&object->dep_link);
916 spin_unlock(&object->parent->lock);
917 }
918
919 _leave("");
920}
921
922/**
923 * fscache_check_aux - Ask the netfs whether an object on disk is still valid
924 * @object: The object to ask about
925 * @data: The auxiliary data for the object
926 * @datalen: The size of the auxiliary data
927 *
928 * This function consults the netfs about the coherency state of an object
929 */
930enum fscache_checkaux fscache_check_aux(struct fscache_object *object,
931 const void *data, uint16_t datalen)
932{
933 enum fscache_checkaux result;
934
935 if (!object->cookie->def->check_aux) {
936 fscache_stat(&fscache_n_checkaux_none);
937 return FSCACHE_CHECKAUX_OKAY;
938 }
939
940 result = object->cookie->def->check_aux(object->cookie->netfs_data,
941 data, datalen);
942 switch (result) {
943 /* entry okay as is */
944 case FSCACHE_CHECKAUX_OKAY:
945 fscache_stat(&fscache_n_checkaux_okay);
946 break;
947
948 /* entry requires update */
949 case FSCACHE_CHECKAUX_NEEDS_UPDATE:
950 fscache_stat(&fscache_n_checkaux_update);
951 break;
952
953 /* entry requires deletion */
954 case FSCACHE_CHECKAUX_OBSOLETE:
955 fscache_stat(&fscache_n_checkaux_obsolete);
956 break;
957
958 default:
959 BUG();
960 }
961
962 return result;
963}
964EXPORT_SYMBOL(fscache_check_aux);
David Howellsef778e72012-12-20 21:52:36 +0000965
966/*
967 * Asynchronously invalidate an object.
968 */
David Howellscaaef692013-05-10 19:50:26 +0100969static const struct fscache_state *_fscache_invalidate_object(struct fscache_object *object,
970 int event)
David Howellsef778e72012-12-20 21:52:36 +0000971{
972 struct fscache_operation *op;
973 struct fscache_cookie *cookie = object->cookie;
974
David Howellscaaef692013-05-10 19:50:26 +0100975 _enter("{OBJ%x},%d", object->debug_id, event);
976
David Howellsef778e72012-12-20 21:52:36 +0000977
978 /* Reject any new read/write ops and abort any that are pending. */
979 fscache_invalidate_writes(cookie);
980 clear_bit(FSCACHE_OBJECT_PENDING_WRITE, &object->flags);
981 fscache_cancel_all_ops(object);
982
983 /* Now we have to wait for in-progress reads and writes */
984 op = kzalloc(sizeof(*op), GFP_KERNEL);
985 if (!op) {
David Howellscaaef692013-05-10 19:50:26 +0100986 clear_bit(FSCACHE_OBJECT_IS_LIVE, &object->flags);
David Howellsef778e72012-12-20 21:52:36 +0000987 _leave(" [ENOMEM]");
David Howellscaaef692013-05-10 19:50:26 +0100988 return transit_to(KILL_OBJECT);
David Howellsef778e72012-12-20 21:52:36 +0000989 }
990
991 fscache_operation_init(op, object->cache->ops->invalidate_object, NULL);
992 op->flags = FSCACHE_OP_ASYNC | (1 << FSCACHE_OP_EXCLUSIVE);
993
994 spin_lock(&cookie->lock);
995 if (fscache_submit_exclusive_op(object, op) < 0)
David Howells8d763492012-12-05 13:34:48 +0000996 goto submit_op_failed;
David Howellsef778e72012-12-20 21:52:36 +0000997 spin_unlock(&cookie->lock);
998 fscache_put_operation(op);
999
1000 /* Once we've completed the invalidation, we know there will be no data
1001 * stored in the cache and thus we can reinstate the data-check-skip
1002 * optimisation.
1003 */
1004 set_bit(FSCACHE_COOKIE_NO_DATA_YET, &cookie->flags);
1005
1006 /* We can allow read and write requests to come in once again. They'll
1007 * queue up behind our exclusive invalidation operation.
1008 */
David Howellscaaef692013-05-10 19:50:26 +01001009 if (test_and_clear_bit(FSCACHE_COOKIE_INVALIDATING, &cookie->flags))
1010 wake_up_bit(&cookie->flags, FSCACHE_COOKIE_INVALIDATING);
1011 _leave(" [ok]");
1012 return transit_to(UPDATE_OBJECT);
David Howells8d763492012-12-05 13:34:48 +00001013
1014submit_op_failed:
David Howellscaaef692013-05-10 19:50:26 +01001015 clear_bit(FSCACHE_OBJECT_IS_LIVE, &object->flags);
David Howells8d763492012-12-05 13:34:48 +00001016 spin_unlock(&cookie->lock);
1017 kfree(op);
David Howells8d763492012-12-05 13:34:48 +00001018 _leave(" [EIO]");
David Howellscaaef692013-05-10 19:50:26 +01001019 return transit_to(KILL_OBJECT);
1020}
1021
1022static const struct fscache_state *fscache_invalidate_object(struct fscache_object *object,
1023 int event)
1024{
1025 const struct fscache_state *s;
1026
1027 fscache_stat(&fscache_n_invalidates_run);
1028 fscache_stat(&fscache_n_cop_invalidate_object);
1029 s = _fscache_invalidate_object(object, event);
1030 fscache_stat_d(&fscache_n_cop_invalidate_object);
1031 return s;
1032}
1033
1034/*
1035 * Asynchronously update an object.
1036 */
1037static const struct fscache_state *fscache_update_object(struct fscache_object *object,
1038 int event)
1039{
1040 _enter("{OBJ%x},%d", object->debug_id, event);
1041
1042 fscache_stat(&fscache_n_updates_run);
1043 fscache_stat(&fscache_n_cop_update_object);
1044 object->cache->ops->update_object(object);
1045 fscache_stat_d(&fscache_n_cop_update_object);
1046
1047 _leave("");
1048 return transit_to(WAIT_FOR_CMD);
David Howellsef778e72012-12-20 21:52:36 +00001049}