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