Lines Matching refs:op
23 static void fscache_operation_dummy_cancel(struct fscache_operation *op) in fscache_operation_dummy_cancel() argument
35 void fscache_operation_init(struct fscache_operation *op, in fscache_operation_init() argument
40 INIT_WORK(&op->work, fscache_op_work_func); in fscache_operation_init()
41 atomic_set(&op->usage, 1); in fscache_operation_init()
42 op->state = FSCACHE_OP_ST_INITIALISED; in fscache_operation_init()
43 op->debug_id = atomic_inc_return(&fscache_op_debug_id); in fscache_operation_init()
44 op->processor = processor; in fscache_operation_init()
45 op->cancel = cancel ?: fscache_operation_dummy_cancel; in fscache_operation_init()
46 op->release = release; in fscache_operation_init()
47 INIT_LIST_HEAD(&op->pend_link); in fscache_operation_init()
60 void fscache_enqueue_operation(struct fscache_operation *op) in fscache_enqueue_operation() argument
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 ASSERTCMP(op->state, ==, FSCACHE_OP_ST_IN_PROGRESS); in fscache_enqueue_operation()
72 switch (op->flags & FSCACHE_OP_TYPE) { in fscache_enqueue_operation()
75 atomic_inc(&op->usage); in fscache_enqueue_operation()
76 if (!queue_work(fscache_op_wq, &op->work)) in fscache_enqueue_operation()
77 fscache_put_operation(op); in fscache_enqueue_operation()
83 pr_err("Unexpected op type %lx", op->flags); in fscache_enqueue_operation()
94 struct fscache_operation *op) in fscache_run_op() argument
96 ASSERTCMP(op->state, ==, FSCACHE_OP_ST_PENDING); in fscache_run_op()
98 op->state = FSCACHE_OP_ST_IN_PROGRESS; in fscache_run_op()
100 if (test_and_clear_bit(FSCACHE_OP_WAITING, &op->flags)) in fscache_run_op()
101 wake_up_bit(&op->flags, FSCACHE_OP_WAITING); in fscache_run_op()
102 if (op->processor) in fscache_run_op()
103 fscache_enqueue_operation(op); in fscache_run_op()
111 struct fscache_operation *op, in fscache_report_unexpected_submission() argument
123 op->debug_id, object->debug_id, object->state->name); in fscache_report_unexpected_submission()
134 kdebug("%p %p", op->processor, op->release); in fscache_report_unexpected_submission()
150 struct fscache_operation *op) in fscache_submit_exclusive_op() argument
156 _enter("{OBJ%x OP%x},", object->debug_id, op->debug_id); in fscache_submit_exclusive_op()
158 ASSERTCMP(op->state, ==, FSCACHE_OP_ST_INITIALISED); in fscache_submit_exclusive_op()
159 ASSERTCMP(atomic_read(&op->usage), >, 0); in fscache_submit_exclusive_op()
164 ASSERT(list_empty(&op->pend_link)); in fscache_submit_exclusive_op()
169 op->state = FSCACHE_OP_ST_PENDING; in fscache_submit_exclusive_op()
173 op->cancel(op); in fscache_submit_exclusive_op()
174 op->state = FSCACHE_OP_ST_CANCELLED; in fscache_submit_exclusive_op()
177 op->cancel(op); in fscache_submit_exclusive_op()
178 op->state = FSCACHE_OP_ST_CANCELLED; in fscache_submit_exclusive_op()
181 op->object = object; in fscache_submit_exclusive_op()
186 atomic_inc(&op->usage); in fscache_submit_exclusive_op()
187 list_add_tail(&op->pend_link, &object->pending_ops); in fscache_submit_exclusive_op()
190 atomic_inc(&op->usage); in fscache_submit_exclusive_op()
191 list_add_tail(&op->pend_link, &object->pending_ops); in fscache_submit_exclusive_op()
196 fscache_run_op(object, op); in fscache_submit_exclusive_op()
203 op->object = object; in fscache_submit_exclusive_op()
206 atomic_inc(&op->usage); in fscache_submit_exclusive_op()
207 list_add_tail(&op->pend_link, &object->pending_ops); in fscache_submit_exclusive_op()
211 op->cancel(op); in fscache_submit_exclusive_op()
212 op->state = FSCACHE_OP_ST_CANCELLED; in fscache_submit_exclusive_op()
215 fscache_report_unexpected_submission(object, op, ostate); in fscache_submit_exclusive_op()
216 op->cancel(op); in fscache_submit_exclusive_op()
217 op->state = FSCACHE_OP_ST_CANCELLED; in fscache_submit_exclusive_op()
234 struct fscache_operation *op) in fscache_submit_op() argument
241 object->debug_id, op->debug_id, atomic_read(&op->usage)); in fscache_submit_op()
243 ASSERTCMP(op->state, ==, FSCACHE_OP_ST_INITIALISED); in fscache_submit_op()
244 ASSERTCMP(atomic_read(&op->usage), >, 0); in fscache_submit_op()
249 ASSERT(list_empty(&op->pend_link)); in fscache_submit_op()
254 op->state = FSCACHE_OP_ST_PENDING; in fscache_submit_op()
258 op->cancel(op); in fscache_submit_op()
259 op->state = FSCACHE_OP_ST_CANCELLED; in fscache_submit_op()
262 op->cancel(op); in fscache_submit_op()
263 op->state = FSCACHE_OP_ST_CANCELLED; in fscache_submit_op()
266 op->object = object; in fscache_submit_op()
270 atomic_inc(&op->usage); in fscache_submit_op()
271 list_add_tail(&op->pend_link, &object->pending_ops); in fscache_submit_op()
274 atomic_inc(&op->usage); in fscache_submit_op()
275 list_add_tail(&op->pend_link, &object->pending_ops); in fscache_submit_op()
280 fscache_run_op(object, op); in fscache_submit_op()
284 op->object = object; in fscache_submit_op()
286 atomic_inc(&op->usage); in fscache_submit_op()
287 list_add_tail(&op->pend_link, &object->pending_ops); in fscache_submit_op()
291 op->cancel(op); in fscache_submit_op()
292 op->state = FSCACHE_OP_ST_CANCELLED; in fscache_submit_op()
295 fscache_report_unexpected_submission(object, op, ostate); in fscache_submit_op()
297 op->cancel(op); in fscache_submit_op()
298 op->state = FSCACHE_OP_ST_CANCELLED; in fscache_submit_op()
323 struct fscache_operation *op; in fscache_start_operations() local
327 op = list_entry(object->pending_ops.next, in fscache_start_operations()
330 if (test_bit(FSCACHE_OP_EXCLUSIVE, &op->flags)) { in fscache_start_operations()
335 list_del_init(&op->pend_link); in fscache_start_operations()
336 fscache_run_op(object, op); in fscache_start_operations()
339 fscache_put_operation(op); in fscache_start_operations()
351 int fscache_cancel_op(struct fscache_operation *op, in fscache_cancel_op() argument
354 struct fscache_object *object = op->object; in fscache_cancel_op()
358 _enter("OBJ%x OP%x}", op->object->debug_id, op->debug_id); in fscache_cancel_op()
360 ASSERTCMP(op->state, >=, FSCACHE_OP_ST_PENDING); in fscache_cancel_op()
361 ASSERTCMP(op->state, !=, FSCACHE_OP_ST_CANCELLED); in fscache_cancel_op()
362 ASSERTCMP(atomic_read(&op->usage), >, 0); in fscache_cancel_op()
367 if (op->state == FSCACHE_OP_ST_PENDING) { in fscache_cancel_op()
368 ASSERT(!list_empty(&op->pend_link)); in fscache_cancel_op()
369 list_del_init(&op->pend_link); in fscache_cancel_op()
373 op->cancel(op); in fscache_cancel_op()
374 op->state = FSCACHE_OP_ST_CANCELLED; in fscache_cancel_op()
375 if (test_bit(FSCACHE_OP_EXCLUSIVE, &op->flags)) in fscache_cancel_op()
377 if (test_and_clear_bit(FSCACHE_OP_WAITING, &op->flags)) in fscache_cancel_op()
378 wake_up_bit(&op->flags, FSCACHE_OP_WAITING); in fscache_cancel_op()
380 } else if (op->state == FSCACHE_OP_ST_IN_PROGRESS && cancel_in_progress_op) { in fscache_cancel_op()
382 if (test_bit(FSCACHE_OP_EXCLUSIVE, &op->flags)) in fscache_cancel_op()
389 op->cancel(op); in fscache_cancel_op()
390 op->state = FSCACHE_OP_ST_CANCELLED; in fscache_cancel_op()
391 if (test_bit(FSCACHE_OP_EXCLUSIVE, &op->flags)) in fscache_cancel_op()
393 if (test_and_clear_bit(FSCACHE_OP_WAITING, &op->flags)) in fscache_cancel_op()
394 wake_up_bit(&op->flags, FSCACHE_OP_WAITING); in fscache_cancel_op()
399 fscache_put_operation(op); in fscache_cancel_op()
410 struct fscache_operation *op; in fscache_cancel_all_ops() local
417 op = list_entry(object->pending_ops.next, in fscache_cancel_all_ops()
420 list_del_init(&op->pend_link); in fscache_cancel_all_ops()
422 ASSERTCMP(op->state, ==, FSCACHE_OP_ST_PENDING); in fscache_cancel_all_ops()
423 op->cancel(op); in fscache_cancel_all_ops()
424 op->state = FSCACHE_OP_ST_CANCELLED; in fscache_cancel_all_ops()
426 if (test_bit(FSCACHE_OP_EXCLUSIVE, &op->flags)) in fscache_cancel_all_ops()
428 if (test_and_clear_bit(FSCACHE_OP_WAITING, &op->flags)) in fscache_cancel_all_ops()
429 wake_up_bit(&op->flags, FSCACHE_OP_WAITING); in fscache_cancel_all_ops()
430 fscache_put_operation(op); in fscache_cancel_all_ops()
441 void fscache_op_complete(struct fscache_operation *op, bool cancelled) in fscache_op_complete() argument
443 struct fscache_object *object = op->object; in fscache_op_complete()
447 ASSERTCMP(op->state, ==, FSCACHE_OP_ST_IN_PROGRESS); in fscache_op_complete()
449 ASSERTIFCMP(test_bit(FSCACHE_OP_EXCLUSIVE, &op->flags), in fscache_op_complete()
451 ASSERTIFCMP(test_bit(FSCACHE_OP_EXCLUSIVE, &op->flags), in fscache_op_complete()
457 op->state = FSCACHE_OP_ST_COMPLETE; in fscache_op_complete()
459 op->cancel(op); in fscache_op_complete()
460 op->state = FSCACHE_OP_ST_CANCELLED; in fscache_op_complete()
463 if (test_bit(FSCACHE_OP_EXCLUSIVE, &op->flags)) in fscache_op_complete()
478 void fscache_put_operation(struct fscache_operation *op) in fscache_put_operation() argument
484 op->object->debug_id, op->debug_id, atomic_read(&op->usage)); in fscache_put_operation()
486 ASSERTCMP(atomic_read(&op->usage), >, 0); in fscache_put_operation()
488 if (!atomic_dec_and_test(&op->usage)) in fscache_put_operation()
492 ASSERTIFCMP(op->state != FSCACHE_OP_ST_INITIALISED && in fscache_put_operation()
493 op->state != FSCACHE_OP_ST_COMPLETE, in fscache_put_operation()
494 op->state, ==, FSCACHE_OP_ST_CANCELLED); in fscache_put_operation()
498 if (op->release) { in fscache_put_operation()
499 op->release(op); in fscache_put_operation()
500 op->release = NULL; in fscache_put_operation()
502 op->state = FSCACHE_OP_ST_DEAD; in fscache_put_operation()
504 object = op->object; in fscache_put_operation()
506 if (test_bit(FSCACHE_OP_DEC_READ_CNT, &op->flags)) in fscache_put_operation()
508 if (test_bit(FSCACHE_OP_UNUSE_COOKIE, &op->flags)) in fscache_put_operation()
520 list_add_tail(&op->pend_link, &cache->op_gc_list); in fscache_put_operation()
535 kfree(op); in fscache_put_operation()
545 struct fscache_operation *op; in fscache_operation_gc() local
560 op = list_entry(cache->op_gc_list.next, in fscache_operation_gc()
562 list_del(&op->pend_link); in fscache_operation_gc()
565 object = op->object; in fscache_operation_gc()
569 object->debug_id, op->debug_id); in fscache_operation_gc()
572 ASSERTCMP(atomic_read(&op->usage), ==, 0); in fscache_operation_gc()
573 ASSERTCMP(op->state, ==, FSCACHE_OP_ST_DEAD); in fscache_operation_gc()
581 kfree(op); in fscache_operation_gc()
597 struct fscache_operation *op = in fscache_op_work_func() local
602 op->object->debug_id, op->debug_id, atomic_read(&op->usage)); in fscache_op_work_func()
604 ASSERT(op->processor != NULL); in fscache_op_work_func()
606 op->processor(op); in fscache_op_work_func()
608 fscache_put_operation(op); in fscache_op_work_func()