/** Create a regular file struct from a Kerrighed file descriptor. * @author Renaud Lottiaux, Matthieu Fertré * * @param task Task to create the file for. * @param desc Kerrighed file descriptor. * * @return 0 if everything ok. * Negative value otherwise. */ static struct file *import_regular_file_from_krg_desc( struct epm_action *action, struct task_struct *task, struct regular_file_krg_desc *desc) { struct file *file; BUG_ON (!task); BUG_ON (!desc); if (desc->type == PIPE) file = reopen_pipe_file_entry_from_krg_desc(task, desc); #ifdef CONFIG_KRG_IPC else if (desc->type == SHM) file = reopen_shm_file_entry_from_krg_desc(task, desc); #endif else { desc->file.filename = (char *) &desc[1]; if (desc->file.ctnrid != KDDM_SET_UNUSED) file = create_file_entry_from_krg_desc(task, desc); else file = reopen_file_entry_from_krg_desc(task, desc); if (IS_ERR(file)) ckpt_err(action, PTR_ERR(file), "App %ld - Fail to import file %s", action->restart.app->app_id, desc->file.filename); } return file; }
int cr_link_to_file(struct epm_action *action, ghost_t *ghost, struct task_struct *task, struct file **returned_file) { int r; long key; enum shared_obj_type type; struct cr_file_link *file_link; BUG_ON(action->type != EPM_CHECKPOINT); /* files are linked while loading files_struct or mm_struct */ BUG_ON(action->restart.shared != CR_LOAD_NOW); r = ghost_read(ghost, &type, sizeof(enum shared_obj_type)); if (r) goto error; if (type != LOCAL_FILE && type != DVFS_FILE) goto err_bad_data; r = ghost_read(ghost, &key, sizeof(long)); if (r) goto error; /* look in the table to find the new allocated data * imported in import_shared_objects */ file_link = get_imported_shared_object(action->restart.app, type, key); if (file_link->desc_type == CR_FILE_NONE) { *returned_file = NULL; r = 0; } else r = __cr_link_to_file(action, ghost, task, file_link, returned_file); error: if (r) ckpt_err(NULL, r, "Fail to relink process %d of application %ld" " to file %d:%lu", task_pid_knr(task), action->restart.app->app_id, type, key); return r; err_bad_data: r = -E_CR_BADDATA; goto error; }
static int cr_export_now_file(struct epm_action *action, ghost_t *ghost, struct task_struct *task, union export_args *args) { int r, supported; supported = can_checkpoint_file(args->file_args.file); r = ghost_write(ghost, &supported, sizeof(supported)); if (r) goto error; if (supported) r = regular_file_export(action, ghost, task, args->file_args.index, args->file_args.file); error: if (r) { char *buffer, *filename; filename = alloc_filename(args->file_args.file, &buffer); if (!IS_ERR(filename)) { ckpt_err(action, r, "Fail to save information needed to reopen " "file %s as fd %d of process %d (%s)", filename, args->file_args.index, task_pid_knr(task), task->comm); free_filename(buffer); } else { ckpt_err(action, r, "Fail to save information needed to reopen " "fd %d of process %d (%s)", args->file_args.index, task_pid_knr(task), task->comm); } } return r; }
int reserve_pid(pid_t pid) { int r; kerrighed_node_t orig_node = ORIG_NODE(pid); kerrighed_node_t host_node; struct pid_reservation_msg msg; msg.requester = kerrighed_node_id; msg.pid = pid; r = pidmap_map_read_lock(); if (r) goto out; host_node = pidmap_node(orig_node); if (host_node == KERRIGHED_NODE_ID_NONE) { pidmap_map_read_unlock(); r = pidmap_map_alloc(orig_node); if (r) goto out; pidmap_map_read_lock(); host_node = pidmap_node(orig_node); BUG_ON(host_node == KERRIGHED_NODE_ID_NONE); } r = rpc_sync(PROC_RESERVE_PID, host_node, &msg, sizeof(msg)); pidmap_map_read_unlock(); out: if (r) ckpt_err(NULL, r, "Fail to reserve pid %d", pid); return r; }