save works

This commit is contained in:
Rongsong Shen 2026-03-05 16:03:37 +08:00
parent 3f74f14687
commit 47fc32b02c
6 changed files with 155 additions and 25 deletions

View file

@ -79,9 +79,87 @@ static void lock_objs(xlist_t* l, int op)
for (i = 0; i < l->count; i++) {
var obj = xlist_get(l, i);
if (obj != NULL) {
lock(obj, op);
if (obj == NULL) {
continue;
}
lock(obj, op);
}
}
static void lock_collect_queues(xlist_t* l, int op)
{
int i;
for (i = 0; i < l->count; i++) {
xce_queue_t* q = (xce_queue_t*)xlist_get(l, i);
queue_t* q1;
if (q == NULL) {
continue;
}
q1 = CONTAINER_OF(q, queue_t, queue);
lock(q1, op);
}
}
static void lock_collect_workers(xlist_t* l, int op)
{
int i;
for (i = 0; i < l->count; i++) {
xce_worker_t* w = (xce_worker_t*)xlist_get(l, i);
worker_t* w1;
if (w == NULL) {
continue;
}
w1 = CONTAINER_OF(w, worker_t, host);
lock(w1, op);
}
}
static void lock_collect_jobs(xlist_t* l, int op)
{
int i;
for (i = 0; i < l->count; i++) {
xce_job_t* j = (xce_job_t*)xlist_get(l, i);
job_t* j1;
if (j == NULL) {
continue;
}
j1 = CONTAINER_OF(j, job_t, job);
lock(j1, op);
}
}
static void collect_resvals_workers(xlist_t* l)
{
int i;
for (i = 0; i < l->count; i++) {
xlist_t lst;
xce_worker_t* w = xlist_get(l, i);
void* p = NULL;
if (w == NULL) {
continue;
}
xlist_init(&lst, 128);
collect_resval_with_idx(&(w->resvals), &lst);
w->nresvals_to_sched = lst.count;
MOVE_PTR(p, lst.data);
w->resvals_to_sched = (xce_val_with_idx_t**)p;
xlist_fini(&lst);
}
}
@ -157,7 +235,7 @@ void collect_queues(cluster_t* c, collect_check_fn_t fn, xlist_t* l)
iter_destroy(&it);
unlock(c->qmgr);
lock_objs(l, RTTI_LOCK_READ);
lock_collect_queues(l, RTTI_LOCK_READ);
}
void collect_resources(cluster_t* c, collect_check_fn_t fn, xlist_t* l)
@ -233,7 +311,7 @@ void collect_jobs(cluster_t* c, collect_check_fn_t fn, xlist_t* l)
iter_destroy(&it);
unlock(c->jobmgr);
lock_objs(l, RTTI_LOCK_READ);
lock_collect_jobs(l, RTTI_LOCK_READ);
return;
}
@ -272,7 +350,9 @@ void collect_workers(cluster_t* c, collect_check_fn_t fn, xlist_t* l)
iter_destroy(&it);
unlock(c->workermgr);
lock_objs(l, RTTI_LOCK_READ);
lock_collect_workers(l, RTTI_LOCK_WRITE);
collect_resvals_workers(l);
return;
}
@ -321,6 +401,8 @@ void unlock_collect_workers(xlist_t* l)
continue;
}
free_resval_with_idx_list(&(w->resvals_to_sched), w->nresvals_to_sched);
w1 = CONTAINER_OF(w, worker_t, host);
unlock(w1);