[CRIU] [PATCH v4 06/17] pipes: treat autofs packetized pipes as regular
Stanislav Kinsburskiy
skinsbursky at virtuozzo.com
Thu Jan 7 08:09:48 PST 2016
Autofs uses packetized pipe (with O_DIRECT), which are not supported by CRIU.
After investigation of possibility of packetized pipes migration, it became
clear, that it's a very tricky operation, requiring a lot of changes to
pipes-related part of CRIU code.
So, instead of supporting of packetized pipes, let's gather autofs pipes into
list during parse stage and check on packetized pipe dump, whether it belongs
to autofs on not. IT yes, then just treat it as a regular pipe, or break dump
otherwise.
It's a dirty trick, but in this case it works:
1) We don't migrate pipe content in case of autofs.
2) We don't need to set O_DIRECT flag on pipe (kernel will do it internally).
Signed-off-by: Stanislav Kinsburskiy <skinsbursky at virtuozzo.com>
---
autofs.c | 33 +++++++++++++++++++++++++++++++++
include/autofs.h | 2 ++
pipes.c | 5 +++--
3 files changed, 38 insertions(+), 2 deletions(-)
diff --git a/autofs.c b/autofs.c
index 4133ebf..c2aafa6 100644
--- a/autofs.c
+++ b/autofs.c
@@ -219,6 +219,36 @@ static int parse_options(char *options, int32_t *fd, int32_t *timeout,
return 0;
}
+struct autofs_pipe_s {
+ struct list_head list;
+ unsigned long inode;
+};
+
+struct list_head autofs_pipes = LIST_HEAD_INIT(autofs_pipes);
+
+bool is_autofs_pipe(unsigned long inode)
+{
+ struct autofs_pipe_s *p;
+
+ list_for_each_entry(p, &autofs_pipes, list) {
+ if (p->inode == inode)
+ return true;
+ }
+ return false;
+}
+
+static int autofs_gather_pipe(unsigned long inode)
+{
+ struct autofs_pipe_s *pipe;
+
+ pipe = xmalloc(sizeof(*pipe));
+ if (!pipe)
+ return -1;
+ pipe->inode = inode;
+ list_add_tail(&pipe->list, &autofs_pipes);
+ return 0;
+}
+
int autofs_parse(struct mount_info *pm, bool for_dump)
{
AutofsEntry *entry;
@@ -263,6 +293,9 @@ int autofs_parse(struct mount_info *pm, bool for_dump)
}
}
+ if (autofs_gather_pipe(pipe_ino))
+ return -1;
+
pm->autofs = entry;
return 0;
diff --git a/include/autofs.h b/include/autofs.h
index 9770835..ac7ae5e 100644
--- a/include/autofs.h
+++ b/include/autofs.h
@@ -5,6 +5,8 @@
#define AUTOFS_MINOR 235
#endif
+bool is_autofs_pipe(unsigned long inode);
+
struct mount_info;
int autofs_parse(struct mount_info *pm, bool for_dump);
diff --git a/pipes.c b/pipes.c
index 4631231..121a556 100644
--- a/pipes.c
+++ b/pipes.c
@@ -10,6 +10,7 @@
#include "files.h"
#include "pipes.h"
#include "util-pie.h"
+#include "autofs.h"
#include "protobuf.h"
#include "protobuf/pipe.pb-c.h"
@@ -516,14 +517,14 @@ static int dump_one_pipe(int lfd, u32 id, const struct fd_parms *p)
pr_info("Dumping pipe %d with id %#x pipe_id %#x\n",
lfd, id, pipe_id(p));
- if (p->flags & O_DIRECT) {
+ if ((p->flags & O_DIRECT) && !is_autofs_pipe(pipe_id(p))) {
pr_err("The packetized mode for pipes is not supported yet\n");
return -1;
}
pe.id = id;
pe.pipe_id = pipe_id(p);
- pe.flags = p->flags;
+ pe.flags = p->flags & ~O_DIRECT;
pe.fown = (FownEntry *)&p->fown;
if (pb_write_one(img_from_set(glob_imgset, CR_FD_PIPES), &pe, PB_PIPE))
More information about the CRIU
mailing list