[CRIU] [PATCH v5 16/33] files: Add fdinfo_list_entry::stage
Kirill Tkhai
ktkhai at virtuozzo.com
Mon Dec 26 06:27:19 PST 2016
Add fle open stages. Set a stage after every operation.
v2: Do not merge filetype specific state with generic.
Signed-off-by: Kirill Tkhai <ktkhai at virtuozzo.com>
---
criu/files.c | 13 ++++++++++---
criu/include/files.h | 9 +++++++++
2 files changed, 19 insertions(+), 3 deletions(-)
diff --git a/criu/files.c b/criu/files.c
index 87d8fc655..8e04309b6 100644
--- a/criu/files.c
+++ b/criu/files.c
@@ -1005,12 +1005,16 @@ static int post_open_fd(int pid, struct fdinfo_list_entry *fle)
return -1;
}
if (!is_service_fd(fle->fe->fd, CTL_TTY_OFF))
- return 0;
+ goto out;
}
if (!d->ops->post_open)
- return 0;
- return d->ops->post_open(d, fle->fe->fd);
+ goto out;
+ if (d->ops->post_open(d, fle->fe->fd))
+ return -1;
+out:
+ fle->stage = FLE_RESTORED;
+ return 0;
}
@@ -1058,6 +1062,9 @@ static int open_fd(int pid, struct fdinfo_list_entry *fle)
return -1;
}
+ if (fle->stage < FLE_OPEN)
+ fle->stage = FLE_OPEN;
+
return serve_out_fd(pid, fle->fe->fd, d);
}
diff --git a/criu/include/files.h b/criu/include/files.h
index 1b44960de..5fffed6a8 100644
--- a/criu/include/files.h
+++ b/criu/include/files.h
@@ -64,6 +64,13 @@ extern int fill_fdlink(int lfd, const struct fd_parms *p, struct fd_link *link);
struct file_desc;
+enum {
+ FLE_INITIALIZED,
+ FLE_OPEN,
+ FLE_RESTORING,
+ FLE_RESTORED,
+};
+
struct fdinfo_list_entry {
struct list_head desc_list; /* To chain on @fd_info_head */
struct file_desc *desc; /* Associated file descriptor */
@@ -72,6 +79,7 @@ struct fdinfo_list_entry {
int pid;
FdinfoEntry *fe;
u8 received:1;
+ u8 stage:3;
};
static inline void fle_init(struct fdinfo_list_entry *fle, int pid, FdinfoEntry *fe)
@@ -79,6 +87,7 @@ static inline void fle_init(struct fdinfo_list_entry *fle, int pid, FdinfoEntry
fle->pid = pid;
fle->fe = fe;
fle->received = 0;
+ fle->stage = FLE_INITIALIZED;
}
/* reports whether fd_a takes prio over fd_b */
More information about the CRIU
mailing list