Commit 33c75d0d authored by Andrey Vagin's avatar Andrey Vagin Committed by Pavel Emelyanov

eventpoll: parse_fdinfo_pid_s() returns allocated object for eventpol tfd

We are going to collect all objects in a list and write them into
the eventpoll image. The eventpoll tfd image will be depricated.
Signed-off-by: 's avatarAndrey Vagin <avagin@openvz.org>
Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
parent 78a54bd8
...@@ -299,7 +299,8 @@ static int check_fdinfo_signalfd(void) ...@@ -299,7 +299,8 @@ static int check_fdinfo_signalfd(void)
static int check_one_epoll(union fdinfo_entries *e, void *arg) static int check_one_epoll(union fdinfo_entries *e, void *arg)
{ {
*(int *)arg = e->epl.tfd; *(int *)arg = e->epl.e.tfd;
free_event_poll_entry(e);
return 0; return 0;
} }
......
...@@ -59,12 +59,16 @@ static void pr_info_eventpoll(char *action, EventpollFileEntry *e) ...@@ -59,12 +59,16 @@ static void pr_info_eventpoll(char *action, EventpollFileEntry *e)
static int dump_eventpoll_entry(union fdinfo_entries *e, void *arg) static int dump_eventpoll_entry(union fdinfo_entries *e, void *arg)
{ {
EventpollTfdEntry *efd = &e->epl; EventpollTfdEntry *efd = &e->epl.e;
int ret;
efd->id = *(u32 *)arg; efd->id = *(u32 *)arg;
pr_info_eventpoll_tfd("Dumping: ", efd); pr_info_eventpoll_tfd("Dumping: ", efd);
return pb_write_one(fdset_fd(glob_fdset, CR_FD_EVENTPOLL_TFD), ret = pb_write_one(fdset_fd(glob_fdset, CR_FD_EVENTPOLL_TFD),
efd, PB_EVENTPOLL_TFD); efd, PB_EVENTPOLL_TFD);
free_event_poll_entry(e);
return ret;
} }
static int dump_one_eventpoll(int lfd, u32 id, const struct fd_parms *p) static int dump_one_eventpoll(int lfd, u32 id, const struct fd_parms *p)
......
...@@ -182,17 +182,23 @@ struct fanotify_mark_entry { ...@@ -182,17 +182,23 @@ struct fanotify_mark_entry {
}; };
}; };
struct eventpoll_tfd_entry {
EventpollTfdEntry e;
struct list_head node;
};
union fdinfo_entries { union fdinfo_entries {
EventfdFileEntry efd; EventfdFileEntry efd;
EventpollTfdEntry epl;
SignalfdEntry sfd; SignalfdEntry sfd;
struct inotify_wd_entry ify; struct inotify_wd_entry ify;
struct fanotify_mark_entry ffy; struct fanotify_mark_entry ffy;
struct eventpoll_tfd_entry epl;
TimerfdEntry tfy; TimerfdEntry tfy;
}; };
extern void free_inotify_wd_entry(union fdinfo_entries *e); extern void free_inotify_wd_entry(union fdinfo_entries *e);
extern void free_fanotify_mark_entry(union fdinfo_entries *e); extern void free_fanotify_mark_entry(union fdinfo_entries *e);
extern void free_event_poll_entry(union fdinfo_entries *e);
struct fdinfo_common { struct fdinfo_common {
off64_t pos; off64_t pos;
......
...@@ -1051,6 +1051,11 @@ void free_fanotify_mark_entry(union fdinfo_entries *e) ...@@ -1051,6 +1051,11 @@ void free_fanotify_mark_entry(union fdinfo_entries *e)
xfree(e); xfree(e);
} }
void free_event_poll_entry(union fdinfo_entries *e)
{
xfree(e);
}
static void parse_fhandle_encoded(char *tok, FhEntry *fh) static void parse_fhandle_encoded(char *tok, FhEntry *fh)
{ {
char *d = (char *)fh->handle; char *d = (char *)fh->handle;
...@@ -1195,15 +1200,24 @@ static int parse_fdinfo_pid_s(char *pid, int fd, int type, ...@@ -1195,15 +1200,24 @@ static int parse_fdinfo_pid_s(char *pid, int fd, int type,
continue; continue;
} }
if (fdinfo_field(str, "tfd")) { if (fdinfo_field(str, "tfd")) {
eventpoll_tfd_entry__init(&entry.epl); union fdinfo_entries *e;
if (type != FD_TYPES__EVENTPOLL) if (type != FD_TYPES__EVENTPOLL)
goto parse_err; goto parse_err;
e = xmalloc(sizeof(union fdinfo_entries));
if (!e)
goto out;
eventpoll_tfd_entry__init(&e->epl.e);
ret = sscanf(str, "tfd: %d events: %x data: %"PRIx64, ret = sscanf(str, "tfd: %d events: %x data: %"PRIx64,
&entry.epl.tfd, &entry.epl.events, &entry.epl.data); &e->epl.e.tfd, &e->epl.e.events, &e->epl.e.data);
if (ret != 3) if (ret != 3) {
free_event_poll_entry(e);
goto parse_err; goto parse_err;
ret = cb(&entry, arg); }
ret = cb(e, arg);
if (ret) if (ret)
goto out; goto out;
......
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