[CRIU] [PATCH 04/28] files: Kill file_desc_options::collect_fd()

Andrei Vagin avagin at virtuozzo.com
Tue Jun 6 20:53:14 MSK 2017


Applied

On Mon, Jun 05, 2017 at 08:24:01PM +0300, Kirill Tkhai wrote:
> The only user is fifo, but it uses collect_fd()
> to do read only actions (the only change is
> fifo_info::reg_d population, which may be easily
> moved to open_fifo_fd()).
> 
> So, move the collect_special_file() functionality
> from collect_fifo_fd() to open_fifo_fd() and
> kill collect_fd method at all.
> 
> Signed-off-by: Kirill Tkhai <ktkhai at virtuozzo.com>
> ---
>  criu/fifo.c          |   18 +++++-------------
>  criu/files.c         |    3 ---
>  criu/include/files.h |    7 -------
>  3 files changed, 5 insertions(+), 23 deletions(-)
> 
> diff --git a/criu/fifo.c b/criu/fifo.c
> index 5e2b44ff5..238acece4 100644
> --- a/criu/fifo.c
> +++ b/criu/fifo.c
> @@ -33,7 +33,6 @@ struct fifo_info {
>  	struct file_desc	d;
>  	FifoEntry		*fe;
>  	bool			restore_data;
> -	struct file_desc	*reg_d;
>  };
>  
>  static LIST_HEAD(fifo_head);
> @@ -109,29 +108,22 @@ static int do_open_fifo(int ns_root_fd, struct reg_file_info *rfi, void *arg)
>  static int open_fifo_fd(struct file_desc *d, int *new_fd)
>  {
>  	struct fifo_info *info = container_of(d, struct fifo_info, d);
> +	struct file_desc *reg_d;
>  	int fd;
>  
> -	fd = open_path(info->reg_d, do_open_fifo, info);
> +	reg_d = find_file_desc_raw(FD_TYPES__REG, info->fe->id);
> +	BUG_ON(!reg_d);
> +
> +	fd = open_path(reg_d, do_open_fifo, info);
>  	if (fd < 0)
>  		return -1;
>  	*new_fd = fd;
>  	return 0;
>  }
>  
> -static void collect_fifo_fd(struct file_desc *d,
> -		struct fdinfo_list_entry *fle, struct rst_info *ri)
> -{
> -	struct fifo_info *info;
> -
> -	info = container_of(d, struct fifo_info, d);
> -	info->reg_d = collect_special_file(info->fe->id);
> -	BUG_ON(info->reg_d == NULL);
> -}
> -
>  static struct file_desc_ops fifo_desc_ops = {
>  	.type		= FD_TYPES__FIFO,
>  	.open		= open_fifo_fd,
> -	.collect_fd	= collect_fifo_fd,
>  };
>  
>  static int collect_one_fifo(void *o, ProtobufCMessage *base, struct cr_img *i)
> diff --git a/criu/files.c b/criu/files.c
> index 8911efa3e..6aa88ba8b 100644
> --- a/criu/files.c
> +++ b/criu/files.c
> @@ -709,9 +709,6 @@ int collect_fd(int pid, FdinfoEntry *e, struct rst_info *rst_info)
>  		if (pid_rst_prio(new_le->pid, le->pid))
>  			break;
>  
> -	if (fdesc->ops->collect_fd)
> -		fdesc->ops->collect_fd(fdesc, new_le, rst_info);
> -
>  	collect_task_fd(new_le, rst_info);
>  
>  	list_add_tail(&new_le->desc_list, &le->desc_list);
> diff --git a/criu/include/files.h b/criu/include/files.h
> index 01eb72730..9cb4aef26 100644
> --- a/criu/include/files.h
> +++ b/criu/include/files.h
> @@ -104,13 +104,6 @@ struct file_desc_ops {
>  	 * so it shouldn't be saved for any post-actions.
>  	 */
>  	int			(*open)(struct file_desc *d, int *new_fd);
> -	/*
> -	 * Called to collect a new fd before adding it on desc. Clients
> -	 * may chose to collect it to some specific rst_info list. See
> -	 * prepare_fds() for details.
> -	 */
> -	void			(*collect_fd)(struct file_desc *, struct fdinfo_list_entry *,
> -						struct rst_info *);
>  	char *			(*name)(struct file_desc *, char *b, size_t s);
>  };
>  
> 


More information about the CRIU mailing list