All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dave Hansen <dave-23VcF4HTsmIX0ybBhKVfKdBPR1lH4CV8@public.gmane.org>
To: Ingo Molnar <mingo-X9Un+BFzKDI@public.gmane.org>
Cc: containers
	<containers-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org>,
	"linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org"
	<linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
	Dave Hansen
	<dave-23VcF4HTsmIX0ybBhKVfKdBPR1lH4CV8@public.gmane.org>,
	Christoph Hellwig <hch-wEGCiKHe2LqWVfeAwA7xHQ@public.gmane.org>,
	Alexey Dobriyan
	<adobriyan-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
Subject: [RFC][PATCH 03/11] Introduce generic_file_checkpoint()
Date: Thu, 05 Mar 2009 08:39:01 -0800	[thread overview]
Message-ID: <20090305163901.02518456@kernel> (raw)
In-Reply-To: <20090305163857.0C18F3FD@kernel>


In a bit we will introduce a f_op to do per-file
checkpointing.  But, before I do that, I want to
demonstrate how it splices in here.

So, introduce generic_file_checkpoint() and use it
only for regular files.

I'm also removing the CR_FD_DIR type.  We treat
normal files and directories the same way, so just
call it CR_FD_GENERIC to make it more clear that
we always follow the same generic behavior.

Signed-off-by: Dave Hansen <dave-23VcF4HTsmIX0ybBhKVfKdBPR1lH4CV8@public.gmane.org>
---

 linux-2.6.git-dave/checkpoint/ckpt_file.c         |   50 ++++++++++++----------
 linux-2.6.git-dave/checkpoint/rstr_file.c         |    3 -
 linux-2.6.git-dave/include/linux/checkpoint_hdr.h |    4 -
 3 files changed, 32 insertions(+), 25 deletions(-)

diff -puN checkpoint/ckpt_file.c~generic_file_checkpoint checkpoint/ckpt_file.c
--- linux-2.6.git/checkpoint/ckpt_file.c~generic_file_checkpoint	2009-03-05 08:37:00.000000000 -0800
+++ linux-2.6.git-dave/checkpoint/ckpt_file.c	2009-03-05 08:37:00.000000000 -0800
@@ -72,42 +72,50 @@ int cr_scan_fds(struct files_struct *fil
 	return n;
 }
 
+int generic_file_checkpoint(struct file *file, struct cr_ctx *ctx,
+			    struct cr_hdr_fd *hh)
+{
+	hh->f_flags = file->f_flags;
+	hh->f_mode = file->f_mode;
+	hh->f_pos = file->f_pos;
+	hh->f_version = file->f_version;
+	/* FIX: need also file->uid, file->gid, file->f_owner, etc */
+
+	/*
+	 * CR_FD_GENERIC basically means that this can simply be
+	 * open()'d on restore.  Nothing special.  Note that this
+	 * includes directories.
+	 */
+	hh->fd_type = CR_FD_GENERIC;
+
+	/* FIX: check if the file/dir/link is unlinked */
+
+	return 0;
+}
+
 /* cr_write_fd_data - dump the state of a given file pointer */
 static int cr_write_fd_data(struct cr_ctx *ctx, struct file *file, int parent)
 {
 	struct cr_hdr h;
 	struct cr_hdr_fd *hh = cr_hbuf_get(ctx, sizeof(*hh));
-	struct dentry *dent = file->f_dentry;
-	struct inode *inode = dent->d_inode;
-	enum fd_type fd_type;
 	int ret;
 
 	h.type = CR_HDR_FD_DATA;
 	h.len = sizeof(*hh);
 	h.parent = parent;
 
-	hh->f_flags = file->f_flags;
-	hh->f_mode = file->f_mode;
-	hh->f_pos = file->f_pos;
-	hh->f_version = file->f_version;
-	/* FIX: need also file->uid, file->gid, file->f_owner, etc */
+	hh->fd_type = CR_FD_UNSET;
+	ret = -EBADF;
+	if ((file->f_dentry->d_inode->i_mode & S_IFMT) == S_IFREG)
+		ret = generic_file_checkpoint(file, ctx, hh);
 
-	switch (inode->i_mode & S_IFMT) {
-	case S_IFREG:
-		fd_type = CR_FD_FILE;
-		break;
-	case S_IFDIR:
-		fd_type = CR_FD_DIR;
-		break;
-	default:
-		cr_hbuf_put(ctx, sizeof(*hh));
-		return -EBADF;
-	}
+	if (ret)
+		goto out;
 
-	/* FIX: check if the file/dir/link is unlinked */
-	hh->fd_type = fd_type;
+	WARN_ON(hh->fd_type == CR_FD_UNSET);
 
 	ret = cr_write_obj(ctx, &h, hh);
+out:
 	cr_hbuf_put(ctx, sizeof(*hh));
 	if (ret < 0)
 		return ret;
diff -puN checkpoint/rstr_file.c~generic_file_checkpoint checkpoint/rstr_file.c
--- linux-2.6.git/checkpoint/rstr_file.c~generic_file_checkpoint	2009-03-05 08:37:00.000000000 -0800
+++ linux-2.6.git-dave/checkpoint/rstr_file.c	2009-03-05 08:37:00.000000000 -0800
@@ -92,8 +92,7 @@ cr_read_fd_data(struct cr_ctx *ctx, stru
 	/* FIX: more sanity checks on f_flags, f_mode etc */
 
 	switch (hh->fd_type) {
-	case CR_FD_FILE:
-	case CR_FD_DIR:
+	case CR_FD_GENERIC:
 		file = cr_read_open_fname(ctx, hh->f_flags, hh->f_mode);
 		break;
 	default:
diff -puN include/linux/checkpoint_hdr.h~generic_file_checkpoint include/linux/checkpoint_hdr.h
--- linux-2.6.git/include/linux/checkpoint_hdr.h~generic_file_checkpoint	2009-03-05 08:37:00.000000000 -0800
+++ linux-2.6.git-dave/include/linux/checkpoint_hdr.h	2009-03-05 08:37:00.000000000 -0800
@@ -133,8 +133,8 @@ struct cr_hdr_fd_ent {
 
 /* fd types */
 enum  fd_type {
-	CR_FD_FILE = 1,
-	CR_FD_DIR,
+	CR_FD_UNSET   = 0,
+	CR_FD_GENERIC = 1,
 };
 
 struct cr_hdr_fd {
_

WARNING: multiple messages have this Message-ID (diff)
From: Dave Hansen <dave@linux.vnet.ibm.com>
To: Ingo Molnar <mingo@elte.hu>
Cc: containers <containers@lists.linux-foundation.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"Serge E. Hallyn" <serue@us.ibm.com>,
	Oren Laadan <orenl@cs.columbia.edu>,
	Alexey Dobriyan <adobriyan@gmail.com>,
	Christoph Hellwig <hch@infradead.org>,
	Dave Hansen <dave@linux.vnet.ibm.com>
Subject: [RFC][PATCH 03/11] Introduce generic_file_checkpoint()
Date: Thu, 05 Mar 2009 08:39:01 -0800	[thread overview]
Message-ID: <20090305163901.02518456@kernel> (raw)
In-Reply-To: <20090305163857.0C18F3FD@kernel>


In a bit we will introduce a f_op to do per-file
checkpointing.  But, before I do that, I want to
demonstrate how it splices in here.

So, introduce generic_file_checkpoint() and use it
only for regular files.

I'm also removing the CR_FD_DIR type.  We treat
normal files and directories the same way, so just
call it CR_FD_GENERIC to make it more clear that
we always follow the same generic behavior.

Signed-off-by: Dave Hansen <dave@linux.vnet.ibm.com>
---

 linux-2.6.git-dave/checkpoint/ckpt_file.c         |   50 ++++++++++++----------
 linux-2.6.git-dave/checkpoint/rstr_file.c         |    3 -
 linux-2.6.git-dave/include/linux/checkpoint_hdr.h |    4 -
 3 files changed, 32 insertions(+), 25 deletions(-)

diff -puN checkpoint/ckpt_file.c~generic_file_checkpoint checkpoint/ckpt_file.c
--- linux-2.6.git/checkpoint/ckpt_file.c~generic_file_checkpoint	2009-03-05 08:37:00.000000000 -0800
+++ linux-2.6.git-dave/checkpoint/ckpt_file.c	2009-03-05 08:37:00.000000000 -0800
@@ -72,42 +72,50 @@ int cr_scan_fds(struct files_struct *fil
 	return n;
 }
 
+int generic_file_checkpoint(struct file *file, struct cr_ctx *ctx,
+			    struct cr_hdr_fd *hh)
+{
+	hh->f_flags = file->f_flags;
+	hh->f_mode = file->f_mode;
+	hh->f_pos = file->f_pos;
+	hh->f_version = file->f_version;
+	/* FIX: need also file->uid, file->gid, file->f_owner, etc */
+
+	/*
+	 * CR_FD_GENERIC basically means that this can simply be
+	 * open()'d on restore.  Nothing special.  Note that this
+	 * includes directories.
+	 */
+	hh->fd_type = CR_FD_GENERIC;
+
+	/* FIX: check if the file/dir/link is unlinked */
+
+	return 0;
+}
+
 /* cr_write_fd_data - dump the state of a given file pointer */
 static int cr_write_fd_data(struct cr_ctx *ctx, struct file *file, int parent)
 {
 	struct cr_hdr h;
 	struct cr_hdr_fd *hh = cr_hbuf_get(ctx, sizeof(*hh));
-	struct dentry *dent = file->f_dentry;
-	struct inode *inode = dent->d_inode;
-	enum fd_type fd_type;
 	int ret;
 
 	h.type = CR_HDR_FD_DATA;
 	h.len = sizeof(*hh);
 	h.parent = parent;
 
-	hh->f_flags = file->f_flags;
-	hh->f_mode = file->f_mode;
-	hh->f_pos = file->f_pos;
-	hh->f_version = file->f_version;
-	/* FIX: need also file->uid, file->gid, file->f_owner, etc */
+	hh->fd_type = CR_FD_UNSET;
+	ret = -EBADF;
+	if ((file->f_dentry->d_inode->i_mode & S_IFMT) == S_IFREG)
+		ret = generic_file_checkpoint(file, ctx, hh);
 
-	switch (inode->i_mode & S_IFMT) {
-	case S_IFREG:
-		fd_type = CR_FD_FILE;
-		break;
-	case S_IFDIR:
-		fd_type = CR_FD_DIR;
-		break;
-	default:
-		cr_hbuf_put(ctx, sizeof(*hh));
-		return -EBADF;
-	}
+	if (ret)
+		goto out;
 
-	/* FIX: check if the file/dir/link is unlinked */
-	hh->fd_type = fd_type;
+	WARN_ON(hh->fd_type == CR_FD_UNSET);
 
 	ret = cr_write_obj(ctx, &h, hh);
+out:
 	cr_hbuf_put(ctx, sizeof(*hh));
 	if (ret < 0)
 		return ret;
diff -puN checkpoint/rstr_file.c~generic_file_checkpoint checkpoint/rstr_file.c
--- linux-2.6.git/checkpoint/rstr_file.c~generic_file_checkpoint	2009-03-05 08:37:00.000000000 -0800
+++ linux-2.6.git-dave/checkpoint/rstr_file.c	2009-03-05 08:37:00.000000000 -0800
@@ -92,8 +92,7 @@ cr_read_fd_data(struct cr_ctx *ctx, stru
 	/* FIX: more sanity checks on f_flags, f_mode etc */
 
 	switch (hh->fd_type) {
-	case CR_FD_FILE:
-	case CR_FD_DIR:
+	case CR_FD_GENERIC:
 		file = cr_read_open_fname(ctx, hh->f_flags, hh->f_mode);
 		break;
 	default:
diff -puN include/linux/checkpoint_hdr.h~generic_file_checkpoint include/linux/checkpoint_hdr.h
--- linux-2.6.git/include/linux/checkpoint_hdr.h~generic_file_checkpoint	2009-03-05 08:37:00.000000000 -0800
+++ linux-2.6.git-dave/include/linux/checkpoint_hdr.h	2009-03-05 08:37:00.000000000 -0800
@@ -133,8 +133,8 @@ struct cr_hdr_fd_ent {
 
 /* fd types */
 enum  fd_type {
-	CR_FD_FILE = 1,
-	CR_FD_DIR,
+	CR_FD_UNSET   = 0,
+	CR_FD_GENERIC = 1,
 };
 
 struct cr_hdr_fd {
_

  parent reply	other threads:[~2009-03-05 16:39 UTC|newest]

Thread overview: 93+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-03-05 16:38 [RFC][PATCH 00/11] track files for checkpointability Dave Hansen
2009-03-05 16:38 ` Dave Hansen
2009-03-05 16:38 ` [RFC][PATCH 01/11] kill '_data' in cr_hdr_fd_data name Dave Hansen
2009-03-05 16:38   ` Dave Hansen
2009-03-05 16:38 ` [RFC][PATCH 02/11] breakout fdinfo sprintf() into its own function Dave Hansen
2009-03-05 16:38 ` Dave Hansen
2009-03-05 16:39 ` Dave Hansen [this message]
2009-03-05 16:39   ` [RFC][PATCH 03/11] Introduce generic_file_checkpoint() Dave Hansen
2009-03-05 16:39 ` [RFC][PATCH 04/11] actually use f_op in checkpoint code Dave Hansen
2009-03-05 16:39   ` Dave Hansen
2009-03-05 16:39 ` [RFC][PATCH 05/11] add generic checkpoint f_op to ext fses Dave Hansen
2009-03-05 16:39   ` Dave Hansen
2009-03-13  2:50   ` Oren Laadan
2009-03-13  2:50     ` Oren Laadan
2009-03-05 16:39 ` [RFC][PATCH 06/11] add checkpoint_file_generic() to /proc Dave Hansen
2009-03-05 16:39   ` Dave Hansen
2009-03-05 16:39 ` [RFC][PATCH 07/11] file c/r: expose functions to query fs support Dave Hansen
2009-03-05 16:39   ` Dave Hansen
2009-03-05 16:39 ` [RFC][PATCH 08/11] expose file checkpointability and reasoning in /proc Dave Hansen
2009-03-05 16:39   ` Dave Hansen
2009-03-05 16:39 ` [RFC][PATCH 09/11] check files for checkpointability Dave Hansen
2009-03-05 16:39   ` Dave Hansen
2009-03-09 17:38   ` Matt Helsley
     [not found]     ` <20090309173837.GC7561-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
2009-03-12 19:14       ` Dave Hansen
2009-03-12 19:14     ` Dave Hansen
2009-03-09 17:38   ` Matt Helsley
2009-03-05 16:39 ` [RFC][PATCH 10/11] add checkpoint/restart compile helper Dave Hansen
2009-03-05 16:39   ` Dave Hansen
2009-03-05 16:39 ` [RFC][PATCH 11/11] optimize c/r check in dup_fd() Dave Hansen
2009-03-05 16:39   ` Dave Hansen
2009-03-05 17:40 ` [RFC][PATCH 00/11] track files for checkpointability Alexey Dobriyan
     [not found]   ` <20090305174037.GA2274-2ev+ksY9ol182hYKe6nXyg@public.gmane.org>
2009-03-05 19:16     ` Dave Hansen
2009-03-05 19:16       ` Dave Hansen
2009-03-05 21:08       ` Alexey Dobriyan
2009-03-05 21:08         ` Alexey Dobriyan
2009-03-05 21:27         ` Dave Hansen
2009-03-05 22:00           ` Alexey Dobriyan
     [not found]             ` <20090305220044.GA2819-2ev+ksY9ol182hYKe6nXyg@public.gmane.org>
2009-03-05 22:24               ` Dave Hansen
2009-03-06 15:08               ` Greg Kurz
2009-03-05 22:24             ` Dave Hansen
2009-03-06 14:34               ` Serge E. Hallyn
2009-03-06 14:34               ` Serge E. Hallyn
     [not found]                 ` <20090306143425.GA31250-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
2009-03-06 15:48                   ` Dave Hansen
2009-03-13  3:05                   ` Oren Laadan
2009-03-06 15:48                 ` Dave Hansen
2009-03-06 16:23                   ` Serge E. Hallyn
2009-03-06 16:23                     ` Serge E. Hallyn
     [not found]                     ` <20090306162337.GA3040-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
2009-03-06 16:46                       ` Dave Hansen
2009-03-06 16:46                     ` Dave Hansen
2009-03-06 18:24                       ` Serge E. Hallyn
2009-03-06 19:42                         ` Dave Hansen
     [not found]                         ` <20090306182451.GA6307-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
2009-03-06 19:42                           ` Dave Hansen
2009-03-06 18:24                       ` Serge E. Hallyn
2009-03-13  3:05                 ` Oren Laadan
2009-03-06 15:08             ` Greg Kurz
2009-03-06 15:35               ` Serge E. Hallyn
2009-03-06 15:35               ` Serge E. Hallyn
     [not found]                 ` <20090306153549.GA898-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
2009-03-06 17:36                   ` Cedric Le Goater
2009-03-06 17:36                     ` Cedric Le Goater
     [not found]                     ` <49B15F35.2010909-GANU6spQydw@public.gmane.org>
2009-03-06 18:30                       ` Serge E. Hallyn
2009-03-06 18:30                     ` Serge E. Hallyn
     [not found]                       ` <20090306183055.GA6729-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
2009-03-11  7:51                         ` Cedric Le Goater
2009-03-11  7:51                       ` Cedric Le Goater
     [not found]                         ` <49B76D91.1020807-GANU6spQydw@public.gmane.org>
2009-03-12 15:30                           ` Serge E. Hallyn
2009-03-12 15:30                             ` Serge E. Hallyn
2009-03-13  6:36                             ` Ensuring c/r maintainability (WAS Re: [RFC][PATCH 00/11] track files for checkpointability) Matt Helsley
2009-03-13 17:53                               ` Serge E. Hallyn
2009-03-05 22:00           ` [RFC][PATCH 00/11] track files for checkpointability Alexey Dobriyan
     [not found]         ` <20090305210840.GA2499-2ev+ksY9ol182hYKe6nXyg@public.gmane.org>
2009-03-05 21:27           ` Dave Hansen
2009-03-05 19:44     ` Dave Hansen
2009-03-05 19:44   ` Dave Hansen
2009-03-05 17:40 ` Alexey Dobriyan
2009-03-05 18:13 ` Serge E. Hallyn
2009-03-05 18:13 ` Serge E. Hallyn
     [not found]   ` <20090305181325.GA10666-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
2009-03-05 18:16     ` Dave Hansen
2009-03-05 18:16   ` Dave Hansen
2009-03-10 15:57 ` Nathan Lynch
2009-03-10 15:57 ` Nathan Lynch
2009-03-10 16:00   ` Nathan Lynch
2009-03-10 16:23     ` Serge E. Hallyn
     [not found]     ` <20090310110000.24893e0c-4v5LP+xe+1byhTdZtsIeww@public.gmane.org>
2009-03-10 16:23       ` Serge E. Hallyn
     [not found]   ` <20090310105702.43eb1402-4v5LP+xe+1byhTdZtsIeww@public.gmane.org>
2009-03-10 16:00     ` Nathan Lynch
2009-03-10 16:20     ` Serge E. Hallyn
2009-03-10 16:22     ` Dave Hansen
2009-03-10 16:20   ` Serge E. Hallyn
2009-03-10 17:23     ` Nathan Lynch
     [not found]       ` <20090310122320.313491ce-4v5LP+xe+1byhTdZtsIeww@public.gmane.org>
2009-03-10 17:45         ` Serge E. Hallyn
2009-03-10 17:45       ` Serge E. Hallyn
     [not found]         ` <20090310174517.GA12101-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
2009-03-10 17:47           ` Dave Hansen
2009-03-10 17:47         ` Dave Hansen
2009-03-10 22:54           ` what is CONFIG_VZ_GENCALLS Zhaohui Wang
     [not found]     ` <20090310162026.GA9354-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
2009-03-10 17:23       ` [RFC][PATCH 00/11] track files for checkpointability Nathan Lynch
2009-03-10 16:22   ` Dave Hansen

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=20090305163901.02518456@kernel \
    --to=dave-23vcf4htsmix0ybbhkvfkdbpr1lh4cv8@public.gmane.org \
    --cc=adobriyan-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
    --cc=containers-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org \
    --cc=hch-wEGCiKHe2LqWVfeAwA7xHQ@public.gmane.org \
    --cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=mingo-X9Un+BFzKDI@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.