Commit c94d0cac authored by Pavel Emelyanov's avatar Pavel Emelyanov Committed by Andrei Vagin

eventfd: Rework parse_fdinfo not to use callback

Signed-off-by: 's avatarPavel Emelyanov <xemul@virtuozzo.com>
Signed-off-by: 's avatarAndrei Vagin <avagin@virtuozzo.com>
parent 0dcb780a
...@@ -272,16 +272,11 @@ static int check_proc_stat(void) ...@@ -272,16 +272,11 @@ static int check_proc_stat(void)
return 0; return 0;
} }
static int check_one_fdinfo(union fdinfo_entries *e, void *arg)
{
*(int *)arg = (int)e->efd.counter;
return 0;
}
static int check_fdinfo_eventfd(void) static int check_fdinfo_eventfd(void)
{ {
int fd, ret; int fd, ret;
int cnt = 13, proc_cnt = 0; int cnt = 13;
EventfdFileEntry fe = EVENTFD_FILE_ENTRY__INIT;
fd = eventfd(cnt, 0); fd = eventfd(cnt, 0);
if (fd < 0) { if (fd < 0) {
...@@ -289,7 +284,7 @@ static int check_fdinfo_eventfd(void) ...@@ -289,7 +284,7 @@ static int check_fdinfo_eventfd(void)
return -1; return -1;
} }
ret = parse_fdinfo(fd, FD_TYPES__EVENTFD, check_one_fdinfo, &proc_cnt); ret = parse_fdinfo(fd, FD_TYPES__EVENTFD, NULL, &fe);
close(fd); close(fd);
if (ret) { if (ret) {
...@@ -297,13 +292,13 @@ static int check_fdinfo_eventfd(void) ...@@ -297,13 +292,13 @@ static int check_fdinfo_eventfd(void)
return -1; return -1;
} }
if (proc_cnt != cnt) { if (fe.counter != cnt) {
pr_err("Counter mismatch (or not met) %d want %d\n", pr_err("Counter mismatch (or not met) %d want %d\n",
proc_cnt, cnt); (int)fe.counter, cnt);
return -1; return -1;
} }
pr_info("Eventfd fdinfo works OK (%d vs %d)\n", cnt, proc_cnt); pr_info("Eventfd fdinfo works OK (%d vs %d)\n", cnt, (int)fe.counter);
return 0; return 0;
} }
......
...@@ -43,35 +43,20 @@ static void pr_info_eventfd(char *action, EventfdFileEntry *efe) ...@@ -43,35 +43,20 @@ static void pr_info_eventfd(char *action, EventfdFileEntry *efe)
action, efe->id, efe->flags, efe->counter); action, efe->id, efe->flags, efe->counter);
} }
struct eventfd_dump_arg { static int dump_one_eventfd(int lfd, u32 id, const struct fd_parms *p)
u32 id;
const struct fd_parms *p;
bool dumped;
};
static int dump_eventfd_entry(union fdinfo_entries *e, void *arg)
{ {
struct eventfd_dump_arg *da = arg; EventfdFileEntry efd = EVENTFD_FILE_ENTRY__INIT;
if (da->dumped) { if (parse_fdinfo(lfd, FD_TYPES__EVENTFD, NULL, &efd))
pr_err("Several counters in a file?\n");
return -1; return -1;
}
da->dumped = true; efd.id = id;
e->efd.id = da->id; efd.flags = p->flags;
e->efd.flags = da->p->flags; efd.fown = (FownEntry *)&p->fown;
e->efd.fown = (FownEntry *)&da->p->fown;
pr_info_eventfd("Dumping ", &e->efd); pr_info_eventfd("Dumping ", &efd);
return pb_write_one(img_from_set(glob_imgset, CR_FD_EVENTFD_FILE), return pb_write_one(img_from_set(glob_imgset, CR_FD_EVENTFD_FILE),
&e->efd, PB_EVENTFD_FILE); &efd, PB_EVENTFD_FILE);
}
static int dump_one_eventfd(int lfd, u32 id, const struct fd_parms *p)
{
struct eventfd_dump_arg da = { .id = id, .p = p, };
return parse_fdinfo(lfd, FD_TYPES__EVENTFD, dump_eventfd_entry, &da);
} }
const struct fdtype_ops eventfd_dump_ops = { const struct fdtype_ops eventfd_dump_ops = {
......
...@@ -31,7 +31,6 @@ struct eventpoll_tfd_entry { ...@@ -31,7 +31,6 @@ struct eventpoll_tfd_entry {
}; };
union fdinfo_entries { union fdinfo_entries {
EventfdFileEntry efd;
SignalfdEntry sfd; SignalfdEntry sfd;
struct inotify_wd_entry ify; struct inotify_wd_entry ify;
struct fanotify_mark_entry ffy; struct fanotify_mark_entry ffy;
......
...@@ -1715,17 +1715,14 @@ static int parse_fdinfo_pid_s(int pid, int fd, int type, ...@@ -1715,17 +1715,14 @@ static int parse_fdinfo_pid_s(int pid, int fd, int type,
continue; continue;
if (fdinfo_field(str, "eventfd-count")) { if (fdinfo_field(str, "eventfd-count")) {
eventfd_file_entry__init(&entry.efd); EventfdFileEntry *efd = arg;
if (type != FD_TYPES__EVENTFD) if (type != FD_TYPES__EVENTFD)
goto parse_err; goto parse_err;
ret = sscanf(str, "eventfd-count: %"PRIx64, ret = sscanf(str, "eventfd-count: %"PRIx64,
&entry.efd.counter); &efd->counter);
if (ret != 1) if (ret != 1)
goto parse_err; goto parse_err;
ret = cb(&entry, arg);
if (ret)
goto out;
entry_met = true; entry_met = true;
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