[CRIU] [PATCH v4 07/17] autofs: dump stage introduced

Stanislav Kinsburskiy skinsbursky at virtuozzo.com
Thu Jan 7 08:09:54 PST 2016


AutoFS mount point is managed by user space daemon, which receives requests
from kernel via pipe, passed on mount operation.
Kernel hold write end, while user space process - read end.
Thus, for successfull AutoFS migration, this connection has to be restored.

The major trick for dump stage is that mount points are collected (parsed)
from initial pid namespace, which leads to real pgrp value in AutoFS options
instead of virtual one. This have to be fixed.

Note: we don't care about virtual pgrp in case of catatonic mounts

Signed-off-by: Stanislav Kinsburskiy <skinsbursky at virtuozzo.com>
---
 autofs.c         |   24 ++++++++++++++++++++++++
 include/autofs.h |    1 +
 mount.c          |    1 +
 3 files changed, 26 insertions(+)

diff --git a/autofs.c b/autofs.c
index c2aafa6..1f7509f 100644
--- a/autofs.c
+++ b/autofs.c
@@ -300,3 +300,27 @@ int autofs_parse(struct mount_info *pm, bool for_dump)
 
 	return 0;
 }
+
+int autofs_dump(struct mount_info *pm)
+{
+	AutofsEntry *entry = pm->autofs;
+	struct mount_info *mi;
+
+	if (entry->fd == AUTOFS_CATATONIC_FD)
+		return 0;
+
+	/* We need to get virtual pgrp to restore mount */
+	entry->pgrp = pid_to_virt(entry->pgrp);
+	if (!entry->pgrp) {
+		pr_err("failed to find pstree item with pid %d\n",
+				entry->pgrp);
+		pr_err("Non-catatonic mount without master?\n");
+		return -1;
+	}
+
+	/* Fix pgrp for all bind-mounts */
+	list_for_each_entry(mi, &pm->mnt_bind, mnt_bind)
+		mi->autofs->pgrp = entry->pgrp;
+
+	return 0;
+}
diff --git a/include/autofs.h b/include/autofs.h
index ac7ae5e..e547f55 100644
--- a/include/autofs.h
+++ b/include/autofs.h
@@ -9,5 +9,6 @@ bool is_autofs_pipe(unsigned long inode);
 
 struct mount_info;
 int autofs_parse(struct mount_info *pm, bool for_dump);
+int autofs_dump(struct mount_info *pm);
 
 #endif
diff --git a/mount.c b/mount.c
index 69c69e1..f79f991 100644
--- a/mount.c
+++ b/mount.c
@@ -1699,6 +1699,7 @@ static struct fstype fstypes[32] = {
 		.name = "autofs",
 		.code = FSTYPE__AUTOFS,
 		.parse = autofs_parse,
+		.dump = autofs_dump,
 		.restore = always_fail,
 	},
 };



More information about the CRIU mailing list