Linux Container Development
 help / color / mirror / Atom feed
From: Cedric Le Goater <clg-NmTC/0ZBporQT0dZR+AlfA@public.gmane.org>
To: Oren Laadan <orenl-eQaUEPhvms7ENvBUuze7eA@public.gmane.org>
Cc: containers-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org,
	Dave Hansen
	<dave-23VcF4HTsmIX0ybBhKVfKdBPR1lH4CV8@public.gmane.org>
Subject: Re: [RFC cr-pipe-v13][PATCH 2/3] Checkpoint open pipes
Date: Thu, 05 Feb 2009 10:45:55 +0100	[thread overview]
Message-ID: <498AB553.3090902@fr.ibm.com> (raw)
In-Reply-To: <1233091395-24582-4-git-send-email-orenl-eQaUEPhvms7ENvBUuze7eA@public.gmane.org>

>  
> +/* cr_write_pipebuf - dump contents of a pipe/fifo (assume i_mutex taken) */
> +static int cr_write_pipebuf(struct cr_ctx *ctx, struct pipe_inode_info *pipe)
> +{
> +	struct cr_hdr h;
> +	void *kbuf, *addr;
> +	int i, ret = 0;
> +
> +	kbuf = (void *) __get_free_page(GFP_KERNEL);

this can sleep and inode->i_mutex is locked.

> +	if (!kbuf)
> +		return -ENOMEM;
> +
> +	/* this is a simplified fs/pipe.c:read_pipe() */
> +
> +	for (i = 0; i < pipe->nrbufs; i++) {
> +		int nn = (pipe->curbuf + i) & (PIPE_BUFFERS-1);
> +		struct pipe_buffer *pbuf = pipe->bufs + nn;
> +		const struct pipe_buf_operations *ops = pbuf->ops;
> +
> +		ret = ops->confirm(pipe, pbuf);
> +		if (ret < 0)
> +			break;
> +
> +		addr = ops->map(pipe, pbuf, 1);
> +		memcpy(kbuf, addr + pbuf->offset, pbuf->len);
> +		ops->unmap(pipe, pbuf, addr);
> +
> +		h.type = CR_HDR_BUFFER;
> +		h.len = pbuf->len;
> +		h.parent = 0;
> +
> +		ret = cr_write_obj(ctx, &h, kbuf);

same here.
 
> +		if (ret < 0)
> +			break;
> +	}
> +
> +	free_page((unsigned long) kbuf);
> +	return ret;
> +}

I think that cr_write_pipebuf() should be a service from fs/pipe.c. It
exposes a lot of pipe internals.

a 'dump' and 'restore' inode operations might be could solution to the
general problem of dumping and restoring inode contents. other file types
will have similar needs. 

C.

  parent reply	other threads:[~2009-02-05  9:45 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-01-27 21:23 [RFC cr-pipe-v13][PATCH 0/3] c/r of open pipes Oren Laadan
     [not found] ` <1233091395-24582-1-git-send-email-orenl-eQaUEPhvms7ENvBUuze7eA@public.gmane.org>
2009-01-27 21:23   ` Oren Laadan
2009-01-27 21:23   ` [RFC cr-pipe-v13][PATCH 1/3] A new file type (CR_FD_OBJREF) for a file descriptor already setup Oren Laadan
2009-01-27 21:23   ` [RFC cr-pipe-v13][PATCH 2/3] Checkpoint open pipes Oren Laadan
     [not found]     ` <1233091395-24582-4-git-send-email-orenl-eQaUEPhvms7ENvBUuze7eA@public.gmane.org>
2009-02-05  9:45       ` Cedric Le Goater [this message]
     [not found]         ` <498AB553.3090902-NmTC/0ZBporQT0dZR+AlfA@public.gmane.org>
2009-02-06  2:26           ` Nathan Lynch
     [not found]             ` <20090205202637.4d4f4a29-4v5LP+xe+1byhTdZtsIeww@public.gmane.org>
2009-02-06 13:05               ` Cedric Le Goater
2009-02-06 17:11               ` Dave Hansen
2009-02-06 17:20                 ` Cedric Le Goater
     [not found]                   ` <498C715B.4050303-NmTC/0ZBporQT0dZR+AlfA@public.gmane.org>
2009-02-06 17:24                     ` Dave Hansen
2009-02-07 12:54                       ` Cedric Le Goater
     [not found]                         ` <498D8489.6090904-NmTC/0ZBporQT0dZR+AlfA@public.gmane.org>
2009-02-09 14:39                           ` Cedric Le Goater
2009-01-27 21:23   ` [RFC cr-pipe-v13][PATCH 3/3] Restore " Oren Laadan
     [not found]     ` <1233091395-24582-5-git-send-email-orenl-eQaUEPhvms7ENvBUuze7eA@public.gmane.org>
2009-02-02 17:43       ` Dan Smith
     [not found]         ` <87k5887n16.fsf-FLMGYpZoEPULwtHQx/6qkW3U47Q5hpJU@public.gmane.org>
2009-02-03  0:02           ` Oren Laadan
     [not found]             ` <498789B1.80601-eQaUEPhvms7ENvBUuze7eA@public.gmane.org>
2009-02-03 16:23               ` Dan Smith
2009-01-27 21:29   ` [RFC cr-pipe-v13][PATCH 0/3] c/r of " Oren Laadan

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=498AB553.3090902@fr.ibm.com \
    --to=clg-nmtc/0zbporqt0dzr+alfa@public.gmane.org \
    --cc=containers-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org \
    --cc=dave-23VcF4HTsmIX0ybBhKVfKdBPR1lH4CV8@public.gmane.org \
    --cc=orenl-eQaUEPhvms7ENvBUuze7eA@public.gmane.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox