mirror of
https://github.com/checkpoint-restore/criu
synced 2025-08-30 22:05:36 +00:00
eventfd: Rework parse_fdinfo not to use callback
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com> Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
This commit is contained in:
committed by
Andrei Vagin
parent
0dcb780a8f
commit
c94d0cacb4
@@ -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)
|
|||||||
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)
|
|||||||
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)
|
|||||||
action, efe->id, efe->flags, efe->counter);
|
action, efe->id, efe->flags, efe->counter);
|
||||||
}
|
}
|
||||||
|
|
||||||
struct eventfd_dump_arg {
|
|
||||||
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;
|
|
||||||
|
|
||||||
if (da->dumped) {
|
|
||||||
pr_err("Several counters in a file?\n");
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
da->dumped = true;
|
|
||||||
e->efd.id = da->id;
|
|
||||||
e->efd.flags = da->p->flags;
|
|
||||||
e->efd.fown = (FownEntry *)&da->p->fown;
|
|
||||||
|
|
||||||
pr_info_eventfd("Dumping ", &e->efd);
|
|
||||||
return pb_write_one(img_from_set(glob_imgset, CR_FD_EVENTFD_FILE),
|
|
||||||
&e->efd, PB_EVENTFD_FILE);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int dump_one_eventfd(int lfd, u32 id, const struct fd_parms *p)
|
static int dump_one_eventfd(int lfd, u32 id, const struct fd_parms *p)
|
||||||
{
|
{
|
||||||
struct eventfd_dump_arg da = { .id = id, .p = p, };
|
EventfdFileEntry efd = EVENTFD_FILE_ENTRY__INIT;
|
||||||
return parse_fdinfo(lfd, FD_TYPES__EVENTFD, dump_eventfd_entry, &da);
|
|
||||||
|
if (parse_fdinfo(lfd, FD_TYPES__EVENTFD, NULL, &efd))
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
efd.id = id;
|
||||||
|
efd.flags = p->flags;
|
||||||
|
efd.fown = (FownEntry *)&p->fown;
|
||||||
|
|
||||||
|
pr_info_eventfd("Dumping ", &efd);
|
||||||
|
return pb_write_one(img_from_set(glob_imgset, CR_FD_EVENTFD_FILE),
|
||||||
|
&efd, PB_EVENTFD_FILE);
|
||||||
}
|
}
|
||||||
|
|
||||||
const struct fdtype_ops eventfd_dump_ops = {
|
const struct fdtype_ops eventfd_dump_ops = {
|
||||||
|
@@ -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,
|
|||||||
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;
|
||||||
|
Reference in New Issue
Block a user