[CRIU] Re: [PATCH 3/7] sockets, unix: Use general machnism for checkpoint/restore

Pavel Emelyanov xemul at parallels.com
Tue May 15 16:50:42 EDT 2012


On 05/12/2012 07:47 PM, Cyrill Gorcunov wrote:
> 
> Use fdtype_ops facility to c/r unix sockets.
> 
> Signed-off-by: Cyrill Gorcunov <gorcunov at openvz.org>
> ---
>  files.c           |   21 +++++++++++
>  include/files.h   |    4 ++
>  include/image.h   |    1 +
>  include/sockets.h |    3 +-
>  sk-unix.c         |   96 ++++++++++++++++++++++++++++++----------------------
>  sockets.c         |   19 +++++++---
>  6 files changed, 95 insertions(+), 49 deletions(-)
> 

> +struct file_desc *
> +find_file_desc_slow_by(int type, void *p,
> +		       int (*cb)(struct file_desc *d, void *p))
> +{
> +	struct file_desc *d;
> +	struct list_head *chain;
> +	unsigned int i;
> +
> +	for (i = 0; i < ARRAY_SIZE(file_descs); i++) {
> +		chain = &file_descs[i];
> +		list_for_each_entry(d, chain, hash) {
> +			if (d->ops->type == type) {
> +				if (cb(d, p))
> +					return d;
> +			}
> +		}
> +	}
> +
> +	return NULL;
> +}
> +

Don't obfuscate fdinfo_desc hash please. Use separate list/hash of unix sockets
if required.

> -struct socket_desc *lookup_socket(int ino)
> +static struct socket_desc *__lookup_socket(int ino)
>  {
>  	struct socket_desc *sd;
>  
> @@ -52,6 +52,16 @@ struct socket_desc *lookup_socket(int ino)
>  	return NULL;
>  }
>  
> +struct socket_desc *lookup_socket(int ino)
> +{
> +	struct socket_desc *sk;
> +
> +	sk = __lookup_socket(ino);
> +	if (!sk)
> +		pr_err("Uncollected socket 0x%8x\n", ino);
> +	return sk;
> +}
> +
>  int sk_collect_one(int ino, int family, struct socket_desc *d)
>  {
>  	struct socket_desc **chain;
> @@ -125,16 +135,13 @@ int dump_socket_opts(int sk, struct sk_opts_entry *soe)
>  int dump_socket(struct fd_parms *p, int lfd, const struct cr_fdset *cr_fdset)
>  {
>  	struct socket_desc *sk;
> -
>  	sk = lookup_socket(p->stat.st_ino);
> -	if (!sk) {
> -		pr_err("Uncollected socket 0x%8x\n", (int)p->stat.st_ino);
> +	if (!sk)
>  		return -1;
> -	}

I don't understand this "tossing bits around" change set.

Thanks,
Pavel


More information about the CRIU mailing list