Commit 118f1b6c authored by Kirill Tkhai's avatar Kirill Tkhai Committed by Pavel Emelyanov

eventpoll: Make post_open stage may fail

Currently, it's just an additional check. But later this will be used
int the following way. Return value "1" means, that fle is not ready
for restore, and the caller should recall this method once again later.
See "[PATCH] files: Kill struct file_desc_ops::post_open" for the details.

v5: Use "1" for return

v2: Use generic FLE_OPEN and FLE_RESTORED to determ if a fle is ready
Signed-off-by: 's avatarKirill Tkhai <ktkhai@virtuozzo.com>
Signed-off-by: 's avatarPavel Emelyanov <xemul@virtuozzo.com>
parent 75740281
...@@ -21,6 +21,7 @@ ...@@ -21,6 +21,7 @@
#include "image.h" #include "image.h"
#include "util.h" #include "util.h"
#include "log.h" #include "log.h"
#include "pstree.h"
#include "protobuf.h" #include "protobuf.h"
#include "images/eventpoll.pb-c.h" #include "images/eventpoll.pb-c.h"
...@@ -140,6 +141,24 @@ err_close: ...@@ -140,6 +141,24 @@ err_close:
close(tmp); close(tmp);
return -1; return -1;
} }
static int epoll_not_ready_tfd(EventpollTfdEntry *tdefe)
{
struct fdinfo_list_entry *fle;
list_for_each_entry(fle, &rsti(current)->used, used_list) {
if (tdefe->tfd != fle->fe->fd)
continue;
if (fle->desc->ops->type == FD_TYPES__EVENTPOLL)
return (fle->stage != FLE_OPEN);
else
return (fle->stage != FLE_RESTORED);
}
BUG();
return 0;
}
static int eventpoll_retore_tfd(int fd, int id, EventpollTfdEntry *tdefe) static int eventpoll_retore_tfd(int fd, int id, EventpollTfdEntry *tdefe)
{ {
struct epoll_event event; struct epoll_event event;
...@@ -164,11 +183,19 @@ static int eventpoll_post_open(struct file_desc *d, int fd) ...@@ -164,11 +183,19 @@ static int eventpoll_post_open(struct file_desc *d, int fd)
info = container_of(d, struct eventpoll_file_info, d); info = container_of(d, struct eventpoll_file_info, d);
for (i = 0; i < info->efe->n_tfd; i++) {
if (epoll_not_ready_tfd(info->efe->tfd[i]))
return 1;
}
for (i = 0; i < info->efe->n_tfd; i++) { for (i = 0; i < info->efe->n_tfd; i++) {
if (eventpoll_retore_tfd(fd, info->efe->id, info->efe->tfd[i])) if (eventpoll_retore_tfd(fd, info->efe->id, info->efe->tfd[i]))
return -1; return -1;
} }
list_for_each_entry(td_info, &eventpoll_tfds, list) {
if (epoll_not_ready_tfd(td_info->tdefe))
return 1;
}
list_for_each_entry(td_info, &eventpoll_tfds, list) { list_for_each_entry(td_info, &eventpoll_tfds, list) {
if (td_info->tdefe->id != info->efe->id) if (td_info->tdefe->id != info->efe->id)
continue; continue;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment