Lines Matching defs:object
29 * object and processor if needed.
56 * This will get its own ref on the object.
60 struct fscache_cookie *cookie = op->object->cookie;
63 op->object->debug_id, op->debug_id, atomic_read(&op->usage));
67 ASSERT(fscache_object_is_available(op->object));
96 static void fscache_run_op(struct fscache_object *object,
102 object->n_in_progress++;
108 trace_fscache_op(object->cookie, op, fscache_op_run);
115 static void fscache_report_unexpected_submission(struct fscache_object *object,
128 op->debug_id, object->debug_id, object->state->name);
129 kdebug("objstate=%s [%s]", object->state->name, ostate->name);
130 kdebug("objflags=%lx", object->flags);
131 kdebug("objevent=%lx [%lx]", object->events, object->event_mask);
133 object->n_ops, object->n_in_progress, object->n_exclusive);
135 if (!list_empty(&object->pending_ops)) {
137 list_for_each_entry(p, &object->pending_ops, pend_link) {
138 ASSERTCMP(p->object, ==, object);
150 * submit an exclusive operation for an object
154 int fscache_submit_exclusive_op(struct fscache_object *object,
161 _enter("{OBJ%x OP%x},", object->debug_id, op->debug_id);
163 trace_fscache_op(object->cookie, op, fscache_op_submit_ex);
168 spin_lock(&object->lock);
169 ASSERTCMP(object->n_ops, >=, object->n_in_progress);
170 ASSERTCMP(object->n_ops, >=, object->n_exclusive);
173 ostate = object->state;
177 flags = READ_ONCE(object->flags);
183 } else if (unlikely(fscache_cache_is_broken(object))) {
188 op->object = object;
189 object->n_ops++;
190 object->n_exclusive++; /* reads and writes must wait */
192 if (object->n_in_progress > 0) {
194 list_add_tail(&op->pend_link, &object->pending_ops);
196 } else if (!list_empty(&object->pending_ops)) {
198 list_add_tail(&op->pend_link, &object->pending_ops);
200 fscache_start_operations(object);
202 ASSERTCMP(object->n_in_progress, ==, 0);
203 fscache_run_op(object, op);
207 clear_bit(FSCACHE_OBJECT_PENDING_WRITE, &object->flags);
210 op->object = object;
211 object->n_ops++;
212 object->n_exclusive++; /* reads and writes must wait */
214 list_add_tail(&op->pend_link, &object->pending_ops);
222 fscache_report_unexpected_submission(object, op, ostate);
228 spin_unlock(&object->lock);
233 * submit an operation for an object
235 * - during object creation (write ops may be submitted)
236 * - whilst the object is active
240 int fscache_submit_op(struct fscache_object *object,
248 object->debug_id, op->debug_id, atomic_read(&op->usage));
250 trace_fscache_op(object->cookie, op, fscache_op_submit);
255 spin_lock(&object->lock);
256 ASSERTCMP(object->n_ops, >=, object->n_in_progress);
257 ASSERTCMP(object->n_ops, >=, object->n_exclusive);
260 ostate = object->state;
264 flags = READ_ONCE(object->flags);
270 } else if (unlikely(fscache_cache_is_broken(object))) {
275 op->object = object;
276 object->n_ops++;
278 if (object->n_exclusive > 0) {
280 list_add_tail(&op->pend_link, &object->pending_ops);
282 } else if (!list_empty(&object->pending_ops)) {
284 list_add_tail(&op->pend_link, &object->pending_ops);
286 fscache_start_operations(object);
288 ASSERTCMP(object->n_exclusive, ==, 0);
289 fscache_run_op(object, op);
293 op->object = object;
294 object->n_ops++;
296 list_add_tail(&op->pend_link, &object->pending_ops);
304 fscache_report_unexpected_submission(object, op, ostate);
305 ASSERT(!fscache_object_is_active(object));
311 spin_unlock(&object->lock);
316 * queue an object for withdrawal on error, aborting all following asynchronous
319 void fscache_abort_object(struct fscache_object *object)
321 _enter("{OBJ%x}", object->debug_id);
323 fscache_raise_event(object, FSCACHE_OBJECT_EV_ERROR);
327 * Jump start the operation processing on an object. The caller must hold
328 * object->lock.
330 void fscache_start_operations(struct fscache_object *object)
335 while (!list_empty(&object->pending_ops) && !stop) {
336 op = list_entry(object->pending_ops.next,
340 if (object->n_in_progress > 0)
345 fscache_run_op(object, op);
347 /* the pending queue was holding a ref on the object */
351 ASSERTCMP(object->n_in_progress, <=, object->n_ops);
354 object->n_in_progress, object->debug_id);
358 * cancel an operation that's pending on an object
363 struct fscache_object *object = op->object;
367 _enter("OBJ%x OP%x}", op->object->debug_id, op->debug_id);
369 trace_fscache_op(object->cookie, op, fscache_op_cancel);
375 spin_lock(&object->lock);
387 object->n_exclusive--;
392 ASSERTCMP(object->n_in_progress, >, 0);
394 object->n_exclusive--;
395 object->n_in_progress--;
396 if (object->n_in_progress == 0)
397 fscache_start_operations(object);
403 object->n_exclusive--;
411 spin_unlock(&object->lock);
417 * Cancel all pending operations on an object
419 void fscache_cancel_all_ops(struct fscache_object *object)
423 _enter("OBJ%x", object->debug_id);
425 spin_lock(&object->lock);
427 while (!list_empty(&object->pending_ops)) {
428 op = list_entry(object->pending_ops.next,
433 trace_fscache_op(object->cookie, op, fscache_op_cancel_all);
440 object->n_exclusive--;
444 cond_resched_lock(&object->lock);
447 spin_unlock(&object->lock);
456 struct fscache_object *object = op->object;
458 _enter("OBJ%x", object->debug_id);
461 ASSERTCMP(object->n_in_progress, >, 0);
463 object->n_exclusive, >, 0);
465 object->n_in_progress, ==, 1);
467 spin_lock(&object->lock);
470 trace_fscache_op(object->cookie, op, fscache_op_completed);
474 trace_fscache_op(object->cookie, op, fscache_op_cancelled);
479 object->n_exclusive--;
480 object->n_in_progress--;
481 if (object->n_in_progress == 0)
482 fscache_start_operations(object);
484 spin_unlock(&object->lock);
495 struct fscache_object *object;
499 op->object ? op->object->debug_id : 0,
507 trace_fscache_op(op->object ? op->object->cookie : NULL, op, fscache_op_put);
522 object = op->object;
523 if (likely(object)) {
525 atomic_dec(&object->n_reads);
527 fscache_unuse_cookie(object);
529 /* now... we may get called with the object spinlock held, so we
532 if (!spin_trylock(&object->lock)) {
536 cache = object->cache;
545 ASSERTCMP(object->n_ops, >, 0);
546 object->n_ops--;
547 if (object->n_ops == 0)
548 fscache_raise_event(object, FSCACHE_OBJECT_EV_CLEARED);
550 spin_unlock(&object->lock);
564 struct fscache_object *object;
583 object = op->object;
584 trace_fscache_op(object->cookie, op, fscache_op_gc);
586 spin_lock(&object->lock);
589 object->debug_id, op->debug_id);
595 ASSERTCMP(object->n_ops, >, 0);
596 object->n_ops--;
597 if (object->n_ops == 0)
598 fscache_raise_event(object, FSCACHE_OBJECT_EV_CLEARED);
600 spin_unlock(&object->lock);
613 * the caller holds a ref to this object, so we don't need to hold one
622 op->object->debug_id, op->debug_id, atomic_read(&op->usage));
624 trace_fscache_op(op->object->cookie, op, fscache_op_work);