[Devel] mounts: support only shared NFS mounts in inits mount namespace

Submitted by Stanislav Kinsburskiy on June 29, 2017, 12:14 p.m.

Details

Message ID 20170629121413.595099.56100.stgit@skinsbursky-vz7.qa.sw.ru
State New
Series "mounts: support only shared NFS mounts in inits mount namespace"
Headers show

Commit Message

Stanislav Kinsburskiy June 29, 2017, 12:14 p.m.
The intention of this patch is to define different NFS mount cases and forbid
most ot them.
The reason behind this is that the only mount point we can migrate right now
is:
1) created in init mount namespace
2) shared (beacuse it's default)

All the other cases are not supported by spfs manager so far and migration
attempt can lead to different issues after restore is completed by CRIU.

https://jira.sw.ru/browse/PSBM-66945

Signed-off-by: Stanislav Kinsburskiy <skinsbursky@virtuozzo.com>
---
 criu/mount.c |   67 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 66 insertions(+), 1 deletion(-)

Patch hide | download patch | download mbox

diff --git a/criu/mount.c b/criu/mount.c
index 6916974..3399aa5 100644
--- a/criu/mount.c
+++ b/criu/mount.c
@@ -746,6 +746,70 @@  static bool nfs_mount(const struct mount_info *m)
 
 }
 
+static char *mnt_mark(const struct mount_info *m)
+{
+	static char *shared = "shared";
+	static char *private = "private";
+	static char *slave = "slave";
+
+	if (m->flags & MS_SHARED)
+		return shared;
+
+	if (m->flags & MS_SLAVE)
+		return slave;
+
+	return private;
+}
+
+static bool unsupported_nfs_mount(const struct mount_info *m)
+{
+	const struct mount_info *bm;
+
+	switch (m->nsid->type) {
+		case NS_ROOT:
+			if (m->flags & MS_SHARED)
+				return false;
+
+			pr_err("NFS mount [%s] in init mount namespace "
+				"is marked as \"%s\".\n",
+				m->mountpoint, mnt_mark(m));
+			pr_err("Only shared NFS mounts in init mount "
+				"namespace are supported yet.\n");
+			break;
+		case NS_OTHER:
+			if (m->flags & MS_SLAVE) {
+				list_for_each_entry(bm, &m->mnt_bind, mnt_bind) {
+					if (unsupported_nfs_mount(bm))
+						continue;
+					return false;
+				}
+				break;
+			}
+
+			pr_err("NFS mount [%s] in non-init mount namespace "
+				"is marked as \"%s\".\n",
+				m->mountpoint, mnt_mark(m));
+			pr_err("Only slave NFS mounts in non-init mount "
+				"namespace are supported yet.\n");
+			break;
+		case NS_CRIU:
+			pr_err("NFS mount [%s] in CRIU namespace is "
+					"unsupported.\n", m->mountpoint);
+			break;
+		case NS_UNKNOWN:
+			pr_err("Unknown NFS mount [%s] namespace type: %d\n",
+					m->mountpoint, m->nsid->type);
+			break;
+		default:
+			pr_err("Invalid NFS mount [%s] namespace type: %d\n",
+					m->mountpoint, m->nsid->type);
+			break;
+	}
+
+
+	return true;
+}
+
 static bool unsupported_mount(const struct mount_info *m)
 {
 	struct mount_info *parent = m->parent;
@@ -760,7 +824,8 @@  static bool unsupported_mount(const struct mount_info *m)
 
 		return true;
 	}
-	return false;
+
+	return nfs_mount(m) ? unsupported_nfs_mount(m) : false;
 }
 
 static int validate_mounts(struct mount_info *info, bool for_dump)

Comments

Dmitry Safonov June 29, 2017, 12:46 p.m.
On 06/29/2017 03:14 PM, Stanislav Kinsburskiy wrote:
> The intention of this patch is to define different NFS mount cases and forbid
> most ot them.
> The reason behind this is that the only mount point we can migrate right now
> is:
> 1) created in init mount namespace
> 2) shared (beacuse it's default)
> 
> All the other cases are not supported by spfs manager so far and migration
> attempt can lead to different issues after restore is completed by CRIU.
> 
> https://jira.sw.ru/browse/PSBM-66945
> 
> Signed-off-by: Stanislav Kinsburskiy <skinsbursky@virtuozzo.com>
> ---
>   criu/mount.c |   67 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
>   1 file changed, 66 insertions(+), 1 deletion(-)

Andrew, could you review it, please?

> 
> diff --git a/criu/mount.c b/criu/mount.c
> index 6916974..3399aa5 100644
> --- a/criu/mount.c
> +++ b/criu/mount.c
> @@ -746,6 +746,70 @@ static bool nfs_mount(const struct mount_info *m)
>   
>   }
>   
> +static char *mnt_mark(const struct mount_info *m)
> +{
> +	static char *shared = "shared";
> +	static char *private = "private";
> +	static char *slave = "slave";
> +
> +	if (m->flags & MS_SHARED)
> +		return shared;
> +
> +	if (m->flags & MS_SLAVE)
> +		return slave;
> +
> +	return private;
> +}
> +
> +static bool unsupported_nfs_mount(const struct mount_info *m)
> +{
> +	const struct mount_info *bm;
> +
> +	switch (m->nsid->type) {
> +		case NS_ROOT:
> +			if (m->flags & MS_SHARED)
> +				return false;
> +
> +			pr_err("NFS mount [%s] in init mount namespace "
> +				"is marked as \"%s\".\n",
> +				m->mountpoint, mnt_mark(m));
> +			pr_err("Only shared NFS mounts in init mount "
> +				"namespace are supported yet.\n");
> +			break;
> +		case NS_OTHER:
> +			if (m->flags & MS_SLAVE) {
> +				list_for_each_entry(bm, &m->mnt_bind, mnt_bind) {
> +					if (unsupported_nfs_mount(bm))
> +						continue;
> +					return false;
> +				}
> +				break;
> +			}
> +
> +			pr_err("NFS mount [%s] in non-init mount namespace "
> +				"is marked as \"%s\".\n",
> +				m->mountpoint, mnt_mark(m));
> +			pr_err("Only slave NFS mounts in non-init mount "
> +				"namespace are supported yet.\n");
> +			break;
> +		case NS_CRIU:
> +			pr_err("NFS mount [%s] in CRIU namespace is "
> +					"unsupported.\n", m->mountpoint);
> +			break;
> +		case NS_UNKNOWN:
> +			pr_err("Unknown NFS mount [%s] namespace type: %d\n",
> +					m->mountpoint, m->nsid->type);
> +			break;
> +		default:
> +			pr_err("Invalid NFS mount [%s] namespace type: %d\n",
> +					m->mountpoint, m->nsid->type);
> +			break;
> +	}
> +
> +
> +	return true;
> +}
> +
>   static bool unsupported_mount(const struct mount_info *m)
>   {
>   	struct mount_info *parent = m->parent;
> @@ -760,7 +824,8 @@ static bool unsupported_mount(const struct mount_info *m)
>   
>   		return true;
>   	}
> -	return false;
> +
> +	return nfs_mount(m) ? unsupported_nfs_mount(m) : false;
>   }
>   
>   static int validate_mounts(struct mount_info *info, bool for_dump)
>
Andrey Vagin July 3, 2017, 5:43 p.m.
On Thu, Jun 29, 2017 at 03:14:19PM +0300, Stanislav Kinsburskiy wrote:
> The intention of this patch is to define different NFS mount cases and forbid
> most ot them.
> The reason behind this is that the only mount point we can migrate right now
> is:
> 1) created in init mount namespace
> 2) shared (beacuse it's default)
> 
> All the other cases are not supported by spfs manager so far and migration
> attempt can lead to different issues after restore is completed by CRIU.
> 
> https://jira.sw.ru/browse/PSBM-66945
> 
> Signed-off-by: Stanislav Kinsburskiy <skinsbursky@virtuozzo.com>
> ---
>  criu/mount.c |   67 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
>  1 file changed, 66 insertions(+), 1 deletion(-)
> 
> diff --git a/criu/mount.c b/criu/mount.c
> index 6916974..3399aa5 100644
> --- a/criu/mount.c
> +++ b/criu/mount.c
> @@ -746,6 +746,70 @@ static bool nfs_mount(const struct mount_info *m)
>  
>  }
>  
> +static char *mnt_mark(const struct mount_info *m)
> +{
> +	static char *shared = "shared";
> +	static char *private = "private";
> +	static char *slave = "slave";
> +
> +	if (m->flags & MS_SHARED)
> +		return shared;
> +
> +	if (m->flags & MS_SLAVE)
> +		return slave;
> +
> +	return private;
> +}
> +
> +static bool unsupported_nfs_mount(const struct mount_info *m)
> +{
> +	const struct mount_info *bm;
> +
> +	switch (m->nsid->type) {
> +		case NS_ROOT:
> +			if (m->flags & MS_SHARED)
> +				return false;
> +
> +			pr_err("NFS mount [%s] in init mount namespace "
> +				"is marked as \"%s\".\n",
> +				m->mountpoint, mnt_mark(m));
> +			pr_err("Only shared NFS mounts in init mount "
> +				"namespace are supported yet.\n");
> +			break;
> +		case NS_OTHER:
> +			if (m->flags & MS_SLAVE) {
> +				list_for_each_entry(bm, &m->mnt_bind, mnt_bind) {

You have to check that these mounts live in the same shared group

something like this: m->master_id == bm->shared_id

And pls write a comment why you do this check.
> +					if (unsupported_nfs_mount(bm))
> +						continue;
> +					return false;
> +				}
> +				break;
> +			}
> +
> +			pr_err("NFS mount [%s] in non-init mount namespace "
> +				"is marked as \"%s\".\n",
> +				m->mountpoint, mnt_mark(m));
> +			pr_err("Only slave NFS mounts in non-init mount "
> +				"namespace are supported yet.\n");
> +			break;
> +		case NS_CRIU:
> +			pr_err("NFS mount [%s] in CRIU namespace is "
> +					"unsupported.\n", m->mountpoint);
> +			break;
> +		case NS_UNKNOWN:
> +			pr_err("Unknown NFS mount [%s] namespace type: %d\n",
> +					m->mountpoint, m->nsid->type);
> +			break;
> +		default:
> +			pr_err("Invalid NFS mount [%s] namespace type: %d\n",
> +					m->mountpoint, m->nsid->type);
> +			break;
> +	}
> +
> +
> +	return true;
> +}
> +
>  static bool unsupported_mount(const struct mount_info *m)
>  {
>  	struct mount_info *parent = m->parent;
> @@ -760,7 +824,8 @@ static bool unsupported_mount(const struct mount_info *m)
>  
>  		return true;
>  	}
> -	return false;
> +
> +	return nfs_mount(m) ? unsupported_nfs_mount(m) : false;
>  }
>  
>  static int validate_mounts(struct mount_info *info, bool for_dump)
>