Lines Matching refs:j
14 static void transaction_unlink_job(Transaction *tr, Job *j, bool delete_dependencies);
16 static void transaction_delete_job(Transaction *tr, Job *j, bool delete_dependencies) { in transaction_delete_job() argument
18 assert(j); in transaction_delete_job()
22 transaction_unlink_job(tr, j, delete_dependencies); in transaction_delete_job()
24 job_free(j); in transaction_delete_job()
28 Job *j; in transaction_delete_unit() local
33 while ((j = hashmap_get(tr->jobs, u))) in transaction_delete_unit()
34 transaction_delete_job(tr, j, true); in transaction_delete_unit()
38 Job *j; in transaction_abort() local
42 while ((j = hashmap_first(tr->jobs))) in transaction_abort()
43 transaction_delete_job(tr, j, false); in transaction_abort()
48 static void transaction_find_jobs_that_matter_to_anchor(Job *j, unsigned generation) { in transaction_find_jobs_that_matter_to_anchor() argument
49 assert(j); in transaction_find_jobs_that_matter_to_anchor()
56 j->matters_to_anchor = true; in transaction_find_jobs_that_matter_to_anchor()
57 j->generation = generation; in transaction_find_jobs_that_matter_to_anchor()
59 LIST_FOREACH(subject, l, j->subject_list) { in transaction_find_jobs_that_matter_to_anchor()
73 static void transaction_merge_and_delete_job(Transaction *tr, Job *j, Job *other, JobType t) { in transaction_merge_and_delete_job() argument
76 assert(j); in transaction_merge_and_delete_job()
78 assert(j->unit == other->unit); in transaction_merge_and_delete_job()
79 assert(!j->installed); in transaction_merge_and_delete_job()
83 j->type = t; in transaction_merge_and_delete_job()
84 j->state = JOB_WAITING; in transaction_merge_and_delete_job()
85 j->irreversible = j->irreversible || other->irreversible; in transaction_merge_and_delete_job()
86 j->matters_to_anchor = j->matters_to_anchor || other->matters_to_anchor; in transaction_merge_and_delete_job()
92 l->subject = j; in transaction_merge_and_delete_job()
98 last->subject_next = j->subject_list; in transaction_merge_and_delete_job()
99 if (j->subject_list) in transaction_merge_and_delete_job()
100 j->subject_list->subject_prev = last; in transaction_merge_and_delete_job()
101 j->subject_list = other->subject_list; in transaction_merge_and_delete_job()
108 l->object = j; in transaction_merge_and_delete_job()
114 last->object_next = j->object_list; in transaction_merge_and_delete_job()
115 if (j->object_list) in transaction_merge_and_delete_job()
116 j->object_list->object_prev = last; in transaction_merge_and_delete_job()
117 j->object_list = other->object_list; in transaction_merge_and_delete_job()
126 _pure_ static bool job_is_conflicted_by(Job *j) { in job_is_conflicted_by() argument
127 assert(j); in job_is_conflicted_by()
132 LIST_FOREACH(object, l, j->object_list) in job_is_conflicted_by()
149 LIST_FOREACH(transaction, j, job) in delete_one_unmergeable_job()
150 LIST_FOREACH(transaction, k, j->transaction_next) { in delete_one_unmergeable_job()
154 if (job_type_is_mergeable(j->type, k->type)) in delete_one_unmergeable_job()
159 if (!j->matters_to_anchor && !k->matters_to_anchor) { in delete_one_unmergeable_job()
170 log_unit_debug(j->unit, in delete_one_unmergeable_job()
172 j->unit->id, job_type_to_string(j->type), in delete_one_unmergeable_job()
173 … yes_no(j->type == JOB_STOP && job_is_conflicted_by(j))); in delete_one_unmergeable_job()
179 if (j->type == JOB_STOP) { in delete_one_unmergeable_job()
181 if (job_is_conflicted_by(j)) in delete_one_unmergeable_job()
184 d = j; in delete_one_unmergeable_job()
189 d = j; in delete_one_unmergeable_job()
193 d = j; in delete_one_unmergeable_job()
195 } else if (!j->matters_to_anchor) in delete_one_unmergeable_job()
196 d = j; in delete_one_unmergeable_job()
205 j->unit->id, job_type_to_string(j->type), in delete_one_unmergeable_job()
216 Job *j; in transaction_merge_jobs() local
223 HASHMAP_FOREACH(j, tr->jobs) { in transaction_merge_jobs()
226 t = j->type; in transaction_merge_jobs()
227 LIST_FOREACH(transaction, k, j->transaction_next) { in transaction_merge_jobs()
228 if (job_type_merge_and_collapse(&t, k->type, j->unit) >= 0) in transaction_merge_jobs()
235 r = delete_one_unmergeable_job(tr, j); in transaction_merge_jobs()
253 HASHMAP_FOREACH(j, tr->jobs) { in transaction_merge_jobs()
254 JobType t = j->type; in transaction_merge_jobs()
257 LIST_FOREACH(transaction, k, j->transaction_next) in transaction_merge_jobs()
258 assert_se(job_type_merge_and_collapse(&t, k->type, j->unit) == 0); in transaction_merge_jobs()
261 while ((k = j->transaction_next)) { in transaction_merge_jobs()
263 transaction_merge_and_delete_job(tr, k, j, t); in transaction_merge_jobs()
264 j = k; in transaction_merge_jobs()
266 transaction_merge_and_delete_job(tr, j, k, t); in transaction_merge_jobs()
269 assert(!j->transaction_next); in transaction_merge_jobs()
270 assert(!j->transaction_prev); in transaction_merge_jobs()
285 Job *j; in transaction_drop_redundant() local
289 HASHMAP_FOREACH(j, tr->jobs) { in transaction_drop_redundant()
292 LIST_FOREACH(transaction, k, j) in transaction_drop_redundant()
302 j->unit->id, job_type_to_string(j->type)); in transaction_drop_redundant()
303 transaction_delete_job(tr, j, false); in transaction_drop_redundant()
319 LIST_FOREACH(transaction, j, job) in unit_matters_to_anchor()
320 if (j->matters_to_anchor) in unit_matters_to_anchor()
344 static int transaction_verify_order_one(Transaction *tr, Job *j, Job *from, unsigned generation, sd… in transaction_verify_order_one() argument
354 assert(j); in transaction_verify_order_one()
355 assert(!j->transaction_prev); in transaction_verify_order_one()
361 if (j->generation == generation) { in transaction_verify_order_one()
367 if (!j->marker) in transaction_verify_order_one()
384 if (k == j) in transaction_verify_order_one()
388 unit_ids = merge_unit_ids(j->manager->unit_log_field, array); /* ignore error */ in transaction_verify_order_one()
393 LOG_UNIT_MESSAGE(j->unit, in transaction_verify_order_one()
403 LOG_UNIT_MESSAGE(j->unit, in transaction_verify_order_one()
406 j->unit->id, job_type_to_string(j->type)), in transaction_verify_order_one()
424 LOG_UNIT_MESSAGE(j->unit, "Unable to break cycle starting with %s/%s", in transaction_verify_order_one()
425 j->unit->id, job_type_to_string(j->type)), in transaction_verify_order_one()
436 j->marker = from ? from : j; in transaction_verify_order_one()
437 j->generation = generation; in transaction_verify_order_one()
446 UNIT_FOREACH_DEPENDENCY(u, j->unit, directions[d]) { in transaction_verify_order_one()
460 if (job_compare(j, o, directions[d]) >= 0) in transaction_verify_order_one()
463 r = transaction_verify_order_one(tr, o, j, generation, e); in transaction_verify_order_one()
471 j->marker = NULL; in transaction_verify_order_one()
477 Job *j; in transaction_verify_order() local
489 HASHMAP_FOREACH(j, tr->jobs) { in transaction_verify_order()
490 r = transaction_verify_order_one(tr, j, NULL, g, e); in transaction_verify_order()
506 Job *j; in transaction_collect_garbage() local
510 HASHMAP_FOREACH(j, tr->jobs) { in transaction_collect_garbage()
511 if (tr->anchor_job == j) in transaction_collect_garbage()
514 if (!j->object_list) { in transaction_collect_garbage()
515 … log_trace("Garbage collecting job %s/%s", j->unit->id, job_type_to_string(j->type)); in transaction_collect_garbage()
516 transaction_delete_job(tr, j, true); in transaction_collect_garbage()
522 j->unit->id, job_type_to_string(j->type), in transaction_collect_garbage()
523 … j->object_list->subject ? j->object_list->subject->unit->id : "root", in transaction_collect_garbage()
524 … j->object_list->subject ? job_type_to_string(j->object_list->subject->type) : "root"); in transaction_collect_garbage()
531 Job *j; in transaction_is_destructive() local
538 HASHMAP_FOREACH(j, tr->jobs) { in transaction_is_destructive()
541 assert(!j->transaction_prev); in transaction_is_destructive()
542 assert(!j->transaction_next); in transaction_is_destructive()
544 if (j->unit->job && (mode == JOB_FAIL || j->unit->job->irreversible) && in transaction_is_destructive()
545 job_type_is_conflicting(j->unit->job->type, j->type)) in transaction_is_destructive()
549 … j->unit->id, job_type_to_string(j->unit->job->type), job_type_to_string(j->type)); in transaction_is_destructive()
565 LIST_FOREACH(transaction, j, head) { in transaction_minimize_impact()
569 if (j->matters_to_anchor) in transaction_minimize_impact()
577 … j->type == JOB_STOP && UNIT_IS_ACTIVE_OR_ACTIVATING(unit_active_state(j->unit)); in transaction_minimize_impact()
580 j->unit->job && in transaction_minimize_impact()
581 job_type_is_conflicting(j->type, j->unit->job->type); in transaction_minimize_impact()
587 log_unit_debug(j->unit, in transaction_minimize_impact()
589 j->unit->id, job_type_to_string(j->type)); in transaction_minimize_impact()
592 log_unit_debug(j->unit, in transaction_minimize_impact()
594 j->unit->id, job_type_to_string(j->type)); in transaction_minimize_impact()
597 log_unit_debug(j->unit, in transaction_minimize_impact()
599 j->unit->id, job_type_to_string(j->type)); in transaction_minimize_impact()
601 transaction_delete_job(tr, j, true); in transaction_minimize_impact()
613 Job *j; in transaction_apply() local
622 HASHMAP_FOREACH(j, m->jobs) { in transaction_apply()
623 assert(j->installed); in transaction_apply()
625 if (j->unit->ignore_on_isolate) in transaction_apply()
628 if (hashmap_get(tr->jobs, j->unit)) in transaction_apply()
634 job_finish_and_invalidate(j, JOB_CANCELED, false, false); in transaction_apply()
638 HASHMAP_FOREACH(j, tr->jobs) { in transaction_apply()
640 assert(!j->transaction_prev); in transaction_apply()
641 assert(!j->transaction_next); in transaction_apply()
643 r = hashmap_ensure_put(&m->jobs, NULL, UINT32_TO_PTR(j->id), j); in transaction_apply()
648 while ((j = hashmap_steal_first(tr->jobs))) { in transaction_apply()
652 transaction_unlink_job(tr, j, false); in transaction_apply()
654 installed_job = job_install(j); in transaction_apply()
655 if (installed_job != j) { in transaction_apply()
657 if (tr->anchor_job == j) in transaction_apply()
659 hashmap_remove(m->jobs, UINT32_TO_PTR(j->id)); in transaction_apply()
660 job_free(j); in transaction_apply()
661 j = installed_job; in transaction_apply()
664 job_add_to_run_queue(j); in transaction_apply()
665 job_add_to_dbus_queue(j); in transaction_apply()
666 job_start_timer(j, false); in transaction_apply()
667 job_shutdown_magic(j); in transaction_apply()
672 (void) set_put(affected_jobs, j); in transaction_apply()
679 HASHMAP_FOREACH(j, tr->jobs) in transaction_apply()
680 hashmap_remove(m->jobs, UINT32_TO_PTR(j->id)); in transaction_apply()
692 Job *j; in transaction_activate() local
704 HASHMAP_FOREACH(j, m->jobs) in transaction_activate()
705 j->generation = 0; in transaction_activate()
791 Job *j, *f; in transaction_add_one_job() local
812 j = job_new(unit, type); in transaction_add_one_job()
813 if (!j) in transaction_add_one_job()
816 j->generation = 0; in transaction_add_one_job()
817 j->marker = NULL; in transaction_add_one_job()
818 j->matters_to_anchor = false; in transaction_add_one_job()
819 j->irreversible = tr->irreversible; in transaction_add_one_job()
821 LIST_PREPEND(transaction, f, j); in transaction_add_one_job()
824 LIST_REMOVE(transaction, f, j); in transaction_add_one_job()
825 job_free(j); in transaction_add_one_job()
834 return j; in transaction_add_one_job()
837 static void transaction_unlink_job(Transaction *tr, Job *j, bool delete_dependencies) { in transaction_unlink_job() argument
839 assert(j); in transaction_unlink_job()
841 if (j->transaction_prev) in transaction_unlink_job()
842 j->transaction_prev->transaction_next = j->transaction_next; in transaction_unlink_job()
843 else if (j->transaction_next) in transaction_unlink_job()
844 hashmap_replace(tr->jobs, j->unit, j->transaction_next); in transaction_unlink_job()
846 hashmap_remove_value(tr->jobs, j->unit, j); in transaction_unlink_job()
848 if (j->transaction_next) in transaction_unlink_job()
849 j->transaction_next->transaction_prev = j->transaction_prev; in transaction_unlink_job()
851 j->transaction_prev = j->transaction_next = NULL; in transaction_unlink_job()
853 while (j->subject_list) in transaction_unlink_job()
854 job_dependency_free(j->subject_list); in transaction_unlink_job()
856 while (j->object_list) { in transaction_unlink_job()
857 Job *other = j->object_list->matters ? j->object_list->subject : NULL; in transaction_unlink_job()
859 job_dependency_free(j->object_list); in transaction_unlink_job()
865 j->unit->id, job_type_to_string(j->type)); in transaction_unlink_job()