[CRIU] [PATCH 1/2] fsnotify: don't save mnt_id if a mount namepsace isn't dumped

Andrei Vagin avagin at virtuozzo.com
Tue May 16 09:57:42 PDT 2017


Applied

On Fri, Apr 28, 2017 at 03:59:30AM +0300, Andrei Vagin wrote:
> From: Andrei Vagin <avagin at virtuozzo.com>
> 
> Processes can be restored in another mntns, so mnt_id will be
> useless in this case. If mntns isn't dumped, we have to dump a path
> to a mount point.
> 
> Cc: Cyrill Gorcunov <gorcunov at openvz.org>
> Signed-off-by: Andrei Vagin <avagin at virtuozzo.com>
> ---
>  criu/fsnotify.c       | 31 ++++++++++++++++++++-----------
>  images/fsnotify.proto |  1 +
>  2 files changed, 21 insertions(+), 11 deletions(-)
> 
> diff --git a/criu/fsnotify.c b/criu/fsnotify.c
> index 65833ca..a127218 100644
> --- a/criu/fsnotify.c
> +++ b/criu/fsnotify.c
> @@ -180,9 +180,10 @@ static char *alloc_openable(unsigned int s_dev, unsigned long i_ino, FhEntry *f_
>  				path = xstrdup(buf);
>  				if (path == NULL)
>  					goto err;
> -
> -				f_handle->has_mnt_id = true;
> -				f_handle->mnt_id = m->mnt_id;
> +				if (root_ns_mask & CLONE_NEWNS) {
> +					f_handle->has_mnt_id = true;
> +					f_handle->mnt_id = m->mnt_id;
> +				}
>  				return path;
>  			}
>  		} else
> @@ -425,6 +426,8 @@ static int dump_fanotify_entry(union fdinfo_entries *e, void *arg)
>  			pr_err("Can't find mnt_id 0x%x\n", fme->me->mnt_id);
>  			goto out;
>  		}
> +		if (!(root_ns_mask & CLONE_NEWNS))
> +			fme->me->path = m->mountpoint + 1;
>  		fme->s_dev = m->s_dev;
>  
>  		pr_info("mark: s_dev %#08x mnt_id  %#08x mask %#08x\n",
> @@ -621,18 +624,24 @@ static int restore_one_fanotify(int fd, struct fsnotify_mark_info *mark)
>  	if (fme->type == MARK_TYPE__MOUNT) {
>  		struct mount_info *m;
>  		int mntns_root;
> -
> -		m = lookup_mnt_id(fme->me->mnt_id);
> -		if (!m) {
> -			pr_err("Can't find mount mnt_id 0x%x\n", fme->me->mnt_id);
> -			return -1;
> +		char *p = fme->me->path;
> +		struct ns_id *nsid = NULL;
> +
> +		if (root_ns_mask & CLONE_NEWNS) {
> +			m = lookup_mnt_id(fme->me->mnt_id);
> +			if (!m) {
> +				pr_err("Can't find mount mnt_id 0x%x\n", fme->me->mnt_id);
> +				return -1;
> +			}
> +			nsid = m->nsid;
> +			p = m->ns_mountpoint;
>  		}
>  
> -		mntns_root = mntns_get_root_fd(m->nsid);
> +		mntns_root = mntns_get_root_fd(nsid);
>  
> -		target = openat(mntns_root, m->ns_mountpoint, O_PATH);
> +		target = openat(mntns_root, p, O_PATH);
>  		if (target == -1) {
> -			pr_perror("Unable to open %s", m->ns_mountpoint);
> +			pr_perror("Unable to open %s", p);
>  			goto err;
>  		}
>  
> diff --git a/images/fsnotify.proto b/images/fsnotify.proto
> index 1f73d9b..399a449 100644
> --- a/images/fsnotify.proto
> +++ b/images/fsnotify.proto
> @@ -33,6 +33,7 @@ message fanotify_inode_mark_entry {
>  
>  message fanotify_mount_mark_entry {
>  	required uint32		mnt_id		= 1;
> +	optional string		path		= 2;
>  }
>  
>  message fanotify_mark_entry {
> -- 
> 2.9.3
> 


More information about the CRIU mailing list