Lines Matching refs:op

19 static void fscache_operation_dummy_cancel(struct fscache_operation *op)
25 * @op: The operation to initialise
32 struct fscache_operation *op,
37 INIT_WORK(&op->work, fscache_op_work_func);
38 atomic_set(&op->usage, 1);
39 op->state = FSCACHE_OP_ST_INITIALISED;
40 op->debug_id = atomic_inc_return(&fscache_op_debug_id);
41 op->processor = processor;
42 op->cancel = cancel ?: fscache_operation_dummy_cancel;
43 op->release = release;
44 INIT_LIST_HEAD(&op->pend_link);
46 trace_fscache_op(cookie, op, fscache_op_init);
52 * @op: The operation to enqueue
58 void fscache_enqueue_operation(struct fscache_operation *op)
60 struct fscache_cookie *cookie = op->object->cookie;
63 op->object->debug_id, op->debug_id, atomic_read(&op->usage));
65 ASSERT(list_empty(&op->pend_link));
66 ASSERT(op->processor != NULL);
67 ASSERT(fscache_object_is_available(op->object));
68 ASSERTCMP(atomic_read(&op->usage), >, 0);
69 ASSERTIFCMP(op->state != FSCACHE_OP_ST_IN_PROGRESS,
70 op->state, ==, FSCACHE_OP_ST_CANCELLED);
73 switch (op->flags & FSCACHE_OP_TYPE) {
75 trace_fscache_op(cookie, op, fscache_op_enqueue_async);
77 atomic_inc(&op->usage);
78 if (!queue_work(fscache_op_wq, &op->work))
79 fscache_put_operation(op);
82 trace_fscache_op(cookie, op, fscache_op_enqueue_mythread);
86 pr_err("Unexpected op type %lx", op->flags);
94 * start an op running
97 struct fscache_operation *op)
99 ASSERTCMP(op->state, ==, FSCACHE_OP_ST_PENDING);
101 op->state = FSCACHE_OP_ST_IN_PROGRESS;
103 if (test_and_clear_bit(FSCACHE_OP_WAITING, &op->flags))
104 wake_up_bit(&op->flags, FSCACHE_OP_WAITING);
105 if (op->processor)
106 fscache_enqueue_operation(op);
108 trace_fscache_op(object->cookie, op, fscache_op_run);
116 struct fscache_operation *op,
128 op->debug_id, object->debug_id, object->state->name);
139 kdebug("%p %p", op->processor, op->release);
152 * - this gets any extra refs it needs on an op
155 struct fscache_operation *op)
161 _enter("{OBJ%x OP%x},", object->debug_id, op->debug_id);
163 trace_fscache_op(object->cookie, op, fscache_op_submit_ex);
165 ASSERTCMP(op->state, ==, FSCACHE_OP_ST_INITIALISED);
166 ASSERTCMP(atomic_read(&op->usage), >, 0);
171 ASSERT(list_empty(&op->pend_link));
176 op->state = FSCACHE_OP_ST_PENDING;
180 op->cancel(op);
181 op->state = FSCACHE_OP_ST_CANCELLED;
184 op->cancel(op);
185 op->state = FSCACHE_OP_ST_CANCELLED;
188 op->object = object;
193 atomic_inc(&op->usage);
194 list_add_tail(&op->pend_link, &object->pending_ops);
197 atomic_inc(&op->usage);
198 list_add_tail(&op->pend_link, &object->pending_ops);
203 fscache_run_op(object, op);
206 /* need to issue a new write op after this */
210 op->object = object;
213 atomic_inc(&op->usage);
214 list_add_tail(&op->pend_link, &object->pending_ops);
218 op->cancel(op);
219 op->state = FSCACHE_OP_ST_CANCELLED;
222 fscache_report_unexpected_submission(object, op, ostate);
223 op->cancel(op);
224 op->state = FSCACHE_OP_ST_CANCELLED;
237 * - after an I/O error incurred in one of the two above states (op rejected)
238 * - this gets any extra refs it needs on an op
241 struct fscache_operation *op)
248 object->debug_id, op->debug_id, atomic_read(&op->usage));
250 trace_fscache_op(object->cookie, op, fscache_op_submit);
252 ASSERTCMP(op->state, ==, FSCACHE_OP_ST_INITIALISED);
253 ASSERTCMP(atomic_read(&op->usage), >, 0);
258 ASSERT(list_empty(&op->pend_link));
263 op->state = FSCACHE_OP_ST_PENDING;
267 op->cancel(op);
268 op->state = FSCACHE_OP_ST_CANCELLED;
271 op->cancel(op);
272 op->state = FSCACHE_OP_ST_CANCELLED;
275 op->object = object;
279 atomic_inc(&op->usage);
280 list_add_tail(&op->pend_link, &object->pending_ops);
283 atomic_inc(&op->usage);
284 list_add_tail(&op->pend_link, &object->pending_ops);
289 fscache_run_op(object, op);
293 op->object = object;
295 atomic_inc(&op->usage);
296 list_add_tail(&op->pend_link, &object->pending_ops);
300 op->cancel(op);
301 op->state = FSCACHE_OP_ST_CANCELLED;
304 fscache_report_unexpected_submission(object, op, ostate);
306 op->cancel(op);
307 op->state = FSCACHE_OP_ST_CANCELLED;
332 struct fscache_operation *op;
336 op = list_entry(object->pending_ops.next,
339 if (test_bit(FSCACHE_OP_EXCLUSIVE, &op->flags)) {
344 list_del_init(&op->pend_link);
345 fscache_run_op(object, op);
348 fscache_put_operation(op);
360 int fscache_cancel_op(struct fscache_operation *op,
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);
371 ASSERTCMP(op->state, >=, FSCACHE_OP_ST_PENDING);
372 ASSERTCMP(op->state, !=, FSCACHE_OP_ST_CANCELLED);
373 ASSERTCMP(atomic_read(&op->usage), >, 0);
378 if (op->state == FSCACHE_OP_ST_PENDING) {
379 ASSERT(!list_empty(&op->pend_link));
380 list_del_init(&op->pend_link);
384 op->cancel(op);
385 op->state = FSCACHE_OP_ST_CANCELLED;
386 if (test_bit(FSCACHE_OP_EXCLUSIVE, &op->flags))
388 if (test_and_clear_bit(FSCACHE_OP_WAITING, &op->flags))
389 wake_up_bit(&op->flags, FSCACHE_OP_WAITING);
391 } else if (op->state == FSCACHE_OP_ST_IN_PROGRESS && cancel_in_progress_op) {
393 if (test_bit(FSCACHE_OP_EXCLUSIVE, &op->flags))
400 op->cancel(op);
401 op->state = FSCACHE_OP_ST_CANCELLED;
402 if (test_bit(FSCACHE_OP_EXCLUSIVE, &op->flags))
404 if (test_and_clear_bit(FSCACHE_OP_WAITING, &op->flags))
405 wake_up_bit(&op->flags, FSCACHE_OP_WAITING);
410 fscache_put_operation(op);
421 struct fscache_operation *op;
428 op = list_entry(object->pending_ops.next,
431 list_del_init(&op->pend_link);
433 trace_fscache_op(object->cookie, op, fscache_op_cancel_all);
435 ASSERTCMP(op->state, ==, FSCACHE_OP_ST_PENDING);
436 op->cancel(op);
437 op->state = FSCACHE_OP_ST_CANCELLED;
439 if (test_bit(FSCACHE_OP_EXCLUSIVE, &op->flags))
441 if (test_and_clear_bit(FSCACHE_OP_WAITING, &op->flags))
442 wake_up_bit(&op->flags, FSCACHE_OP_WAITING);
443 fscache_put_operation(op);
454 void fscache_op_complete(struct fscache_operation *op, bool cancelled)
456 struct fscache_object *object = op->object;
460 ASSERTCMP(op->state, ==, FSCACHE_OP_ST_IN_PROGRESS);
462 ASSERTIFCMP(test_bit(FSCACHE_OP_EXCLUSIVE, &op->flags),
464 ASSERTIFCMP(test_bit(FSCACHE_OP_EXCLUSIVE, &op->flags),
470 trace_fscache_op(object->cookie, op, fscache_op_completed);
471 op->state = FSCACHE_OP_ST_COMPLETE;
473 op->cancel(op);
474 trace_fscache_op(object->cookie, op, fscache_op_cancelled);
475 op->state = FSCACHE_OP_ST_CANCELLED;
478 if (test_bit(FSCACHE_OP_EXCLUSIVE, &op->flags))
491 * - queues pending ops if this is the last in-progress op
493 void fscache_put_operation(struct fscache_operation *op)
499 op->object ? op->object->debug_id : 0,
500 op->debug_id, atomic_read(&op->usage));
502 ASSERTCMP(atomic_read(&op->usage), >, 0);
504 if (!atomic_dec_and_test(&op->usage))
507 trace_fscache_op(op->object ? op->object->cookie : NULL, op, fscache_op_put);
510 ASSERTIFCMP(op->state != FSCACHE_OP_ST_INITIALISED &&
511 op->state != FSCACHE_OP_ST_COMPLETE,
512 op->state, ==, FSCACHE_OP_ST_CANCELLED);
516 if (op->release) {
517 op->release(op);
518 op->release = NULL;
520 op->state = FSCACHE_OP_ST_DEAD;
522 object = op->object;
524 if (test_bit(FSCACHE_OP_DEC_READ_CNT, &op->flags))
526 if (test_bit(FSCACHE_OP_UNUSE_COOKIE, &op->flags))
538 list_add_tail(&op->pend_link, &cache->op_gc_list);
553 kfree(op);
563 struct fscache_operation *op;
578 op = list_entry(cache->op_gc_list.next,
580 list_del(&op->pend_link);
583 object = op->object;
584 trace_fscache_op(object->cookie, op, fscache_op_gc);
589 object->debug_id, op->debug_id);
592 ASSERTCMP(atomic_read(&op->usage), ==, 0);
593 ASSERTCMP(op->state, ==, FSCACHE_OP_ST_DEAD);
601 kfree(op);
617 struct fscache_operation *op =
622 op->object->debug_id, op->debug_id, atomic_read(&op->usage));
624 trace_fscache_op(op->object->cookie, op, fscache_op_work);
626 ASSERT(op->processor != NULL);
628 op->processor(op);
630 fscache_put_operation(op);