[CRIU] [PATCH 3/4] fsnotify: Kill fsnotify lists
Pavel Emelyanov
xemul at virtuozzo.com
Mon May 15 07:01:47 PDT 2017
The lists are only needed to collect marks (deprecated) into
notify objects. The latter ones are stored in fdsec hash, so
for this legacy case we can find them there.
Signed-off-by: Pavel Emelyanov <xemul at virtuozzo.com>
---
criu/fsnotify.c | 51 ++++++++++-----------------------------------------
1 file changed, 10 insertions(+), 41 deletions(-)
diff --git a/criu/fsnotify.c b/criu/fsnotify.c
index 3487d68..491816e 100644
--- a/criu/fsnotify.c
+++ b/criu/fsnotify.c
@@ -61,7 +61,6 @@ struct fsnotify_mark_info {
};
struct fsnotify_file_info {
- struct list_head list;
union {
InotifyFileEntry *ife;
FanotifyFileEntry *ffe;
@@ -77,9 +76,6 @@ typedef struct {
u64 __handle[16];
} fh_t;
-static LIST_HEAD(inotify_info_head);
-static LIST_HEAD(fanotify_info_head);
-
/* Checks if file descriptor @lfd is inotify */
int is_inotify_link(char *link)
{
@@ -752,31 +748,6 @@ static struct file_desc_ops fanotify_desc_ops = {
.open = open_fanotify_fd,
};
-static struct fsnotify_file_info *find_inotify_info(unsigned id)
-{
- struct fsnotify_file_info *p;
- static struct fsnotify_file_info *last = NULL;
-
- if (last && last->ife->id == id) {
- /*
- * An optimization for clean dump image -- criu puts
- * wd-s for one inotify in one row, thus sometimes
- * we can avoid scanning the inotify_info_head.
- */
- pr_debug("\t\tlast ify for %#08x found\n", id);
- return last;
- }
-
- list_for_each_entry(p, &inotify_info_head, list)
- if (p->ife->id == id) {
- last = p;
- return p;
- }
-
- pr_err("Can't find inotify with id %#08x\n", id);
- return NULL;
-}
-
static int __collect_inotify_mark(struct fsnotify_file_info *p, struct fsnotify_mark_info *mark)
{
struct fsnotify_mark_info *m;
@@ -796,13 +767,14 @@ static int __collect_inotify_mark(struct fsnotify_file_info *p, struct fsnotify_
static int collect_inotify_mark(struct fsnotify_mark_info *mark)
{
- struct fsnotify_file_info *p;
+ struct file_desc *d;
- p = find_inotify_info(mark->iwe->id);
- if (!p)
- return -1;
+ d = find_file_desc_raw(FD_TYPES__INOTIFY, mark->iwe->id);
+ if (d)
+ return __collect_inotify_mark(container_of(d, struct fsnotify_file_info, d), mark);
- return __collect_inotify_mark(p, mark);
+ pr_err("Can't find inotify with id %#08x\n", mark->iwe->id);
+ return -1;
}
static int __collect_fanotify_mark(struct fsnotify_file_info *p,
@@ -817,12 +789,11 @@ static int __collect_fanotify_mark(struct fsnotify_file_info *p,
static int collect_fanotify_mark(struct fsnotify_mark_info *mark)
{
- struct fsnotify_file_info *p;
+ struct file_desc *d;
- list_for_each_entry(p, &fanotify_info_head, list) {
- if (p->ffe->id == mark->fme->id)
- return __collect_fanotify_mark(p, mark);
- }
+ d = find_file_desc_raw(FD_TYPES__FANOTIFY, mark->fme->id);
+ if (d)
+ return __collect_fanotify_mark(container_of(d, struct fsnotify_file_info, d), mark);
pr_err("Can't find fanotify with id %#08x\n", mark->fme->id);
return -1;
@@ -835,7 +806,6 @@ static int collect_one_inotify(void *o, ProtobufCMessage *msg, struct cr_img *im
info->ife = pb_msg(msg, InotifyFileEntry);
INIT_LIST_HEAD(&info->marks);
- list_add(&info->list, &inotify_info_head);
pr_info("Collected id %#08x flags %#08x\n", info->ife->id, info->ife->flags);
for (i = 0; i < info->ife->n_wd; i++) {
@@ -870,7 +840,6 @@ static int collect_one_fanotify(void *o, ProtobufCMessage *msg, struct cr_img *i
info->ffe = pb_msg(msg, FanotifyFileEntry);
INIT_LIST_HEAD(&info->marks);
- list_add(&info->list, &fanotify_info_head);
pr_info("Collected id %#08x flags %#08x\n", info->ffe->id, info->ffe->flags);
for (i = 0; i < info->ffe->n_mark; i++) {
--
2.1.4
More information about the CRIU
mailing list