Linux Container Development
 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 09/11] check files for checkpointability
Date: Thu, 05 Mar 2009 08:39:10 -0800	[thread overview]
Message-ID: <20090305163910.5960D190@kernel> (raw)
In-Reply-To: <20090305163857.0C18F3FD@kernel>


Introduce a files_struct counter to indicate whether a particular
file_struct has ever contained a file which can not be
checkpointed.  This flag is a one-way trip; once it is set, it may
not be unset.

We assume at allocation that a new files_struct is clean and may
be checkpointed.  However, as soon as it has had its files filled
from its parent's, we check it for real in __scan_files_for_cr().
At that point, we mark it if it contained any uncheckpointable
files.

We also check each 'struct file' when it is installed in a fd
slot.  This way, if anyone open()s or managed to dup() an
unsuppored file, we can catch it.

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

 linux-2.6.git-dave/fs/file.c                  |   19 +++++++++++++++++++
 linux-2.6.git-dave/fs/open.c                  |    5 +++++
 linux-2.6.git-dave/include/linux/checkpoint.h |   13 +++++++++++++
 linux-2.6.git-dave/include/linux/fdtable.h    |    3 +++
 4 files changed, 40 insertions(+)

diff -puN fs/file.c~242c7afafb1a81c0d9a41085536f2197d81146e7 fs/file.c
--- linux-2.6.git/fs/file.c~242c7afafb1a81c0d9a41085536f2197d81146e7	2009-03-05 08:37:04.000000000 -0800
+++ linux-2.6.git-dave/fs/file.c	2009-03-05 08:37:04.000000000 -0800
@@ -15,6 +15,7 @@
 #include <linux/file.h>
 #include <linux/fdtable.h>
 #include <linux/bitops.h>
+#include <linux/checkpoint.h>
 #include <linux/interrupt.h>
 #include <linux/spinlock.h>
 #include <linux/rcupdate.h>
@@ -285,6 +286,20 @@ static int count_open_files(struct fdtab
 	return i;
 }
 
+static void __scan_files_for_cr(struct files_struct *files)
+{
+	int i;
+
+	for (i = 0; i < files->fdtab.max_fds; i++) {
+		struct file *f = fcheck_files(files, i);
+		if (!f)
+			continue;
+		if (cr_file_supported(f))
+			continue;
+		files_deny_checkpointing(files);
+	}
+}
+
 /*
  * Allocate a new files structure and copy contents from the
  * passed in files structure.
@@ -303,6 +318,9 @@ struct files_struct *dup_fd(struct files
 		goto out;
 
 	atomic_set(&newf->count, 1);
+#ifdef CONFIG_CHECKPOINT_RESTART
+	newf->may_checkpoint = 1;
+#endif
 
 	spin_lock_init(&newf->file_lock);
 	newf->next_fd = 0;
@@ -396,6 +414,7 @@ struct files_struct *dup_fd(struct files
 
 	rcu_assign_pointer(newf->fdt, new_fdt);
 
+	__scan_files_for_cr(newf);
 	return newf;
 
 out_release:
diff -puN fs/open.c~242c7afafb1a81c0d9a41085536f2197d81146e7 fs/open.c
--- linux-2.6.git/fs/open.c~242c7afafb1a81c0d9a41085536f2197d81146e7	2009-03-05 08:37:04.000000000 -0800
+++ linux-2.6.git-dave/fs/open.c	2009-03-05 08:37:04.000000000 -0800
@@ -29,6 +29,7 @@
 #include <linux/rcupdate.h>
 #include <linux/audit.h>
 #include <linux/falloc.h>
+#include <linux/checkpoint.h>
 
 int vfs_statfs(struct dentry *dentry, struct kstatfs *buf)
 {
@@ -1015,6 +1016,10 @@ void fd_install(unsigned int fd, struct 
 {
 	struct files_struct *files = current->files;
 	struct fdtable *fdt;
+
+	if (!cr_file_supported(file))
+		files_deny_checkpointing(files);
+
 	spin_lock(&files->file_lock);
 	fdt = files_fdtable(files);
 	BUG_ON(fdt->fd[fd] != NULL);
diff -puN include/linux/checkpoint.h~242c7afafb1a81c0d9a41085536f2197d81146e7 include/linux/checkpoint.h
--- linux-2.6.git/include/linux/checkpoint.h~242c7afafb1a81c0d9a41085536f2197d81146e7	2009-03-05 08:37:04.000000000 -0800
+++ linux-2.6.git-dave/include/linux/checkpoint.h	2009-03-05 08:37:04.000000000 -0800
@@ -12,6 +12,7 @@
 
 #include <linux/path.h>
 #include <linux/fs.h>
+#include <linux/fdtable.h>
 
 #ifdef CONFIG_CHECKPOINT_RESTART
 
@@ -101,11 +102,23 @@ extern int cr_read_files(struct cr_ctx *
 
 #define pr_fmt(fmt) "[%d:c/r:%s] " fmt, task_pid_vnr(current), __func__
 
+static inline void __files_deny_checkpointing(struct files_struct *files,
+		char *file, int line)
+{
+	if (!test_and_clear_bit(0, &files->may_checkpoint))
+		return;
+	printk(KERN_INFO "process performed an action that can not be "
+			"checkpointed at: %s:%d\n", file, line);
+}
+#define files_deny_checkpointing(f)  \
+	__files_deny_checkpointing(f, __FILE__, __LINE__)
+
 int cr_explain_file(struct file *file, char *explain, int left);
 int cr_file_supported(struct file *file);
 
 #else /* !CONFIG_CHECKPOINT_RESTART */
 
+static inline void files_deny_checkpointing(struct files_struct *files) {}
 static inline int cr_explain_file(struct file *file, char *explain, int left)
 {
 	return 0;
diff -puN include/linux/fdtable.h~242c7afafb1a81c0d9a41085536f2197d81146e7 include/linux/fdtable.h
--- linux-2.6.git/include/linux/fdtable.h~242c7afafb1a81c0d9a41085536f2197d81146e7	2009-03-05 08:37:04.000000000 -0800
+++ linux-2.6.git-dave/include/linux/fdtable.h	2009-03-05 08:37:04.000000000 -0800
@@ -45,6 +45,9 @@ struct files_struct {
 	atomic_t count;
 	struct fdtable *fdt;
 	struct fdtable fdtab;
+#ifdef CONFIG_CHECKPOINT_RESTART
+	unsigned long may_checkpoint;
+#endif
   /*
    * written part on a separate cache line in SMP
    */
_

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

Thread overview: 48+ 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 ` [RFC][PATCH 01/11] kill '_data' in cr_hdr_fd_data name Dave Hansen
2009-03-05 16:38 ` [RFC][PATCH 02/11] breakout fdinfo sprintf() into its own function Dave Hansen
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 ` [RFC][PATCH 05/11] add generic checkpoint f_op to ext fses Dave Hansen
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 ` [RFC][PATCH 07/11] file c/r: expose functions to query fs support 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 [this message]
2009-03-09 17:38   ` [RFC][PATCH 09/11] check files for checkpointability Matt Helsley
2009-03-05 16:39 ` [RFC][PATCH 10/11] add checkpoint/restart compile helper Dave Hansen
2009-03-05 16:39 ` [RFC][PATCH 11/11] optimize c/r check in dup_fd() Dave Hansen
2009-03-05 17:40 ` [RFC][PATCH 00/11] track files for checkpointability Alexey Dobriyan
2009-03-05 18:13 ` Serge E. Hallyn
     [not found] ` <20090305181325.GA10666@us.ibm.com>
     [not found]   ` <20090305181325.GA10666-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
2009-03-05 18:16     ` Dave Hansen
     [not found] ` <20090305174037.GA2274@x200.localdomain>
     [not found]   ` <20090305174037.GA2274-2ev+ksY9ol182hYKe6nXyg@public.gmane.org>
2009-03-05 19:16     ` Dave Hansen
2009-03-05 21:08       ` Alexey Dobriyan
     [not found]         ` <20090305210840.GA2499-2ev+ksY9ol182hYKe6nXyg@public.gmane.org>
2009-03-05 21:27           ` Dave Hansen
     [not found]         ` <1236288427.22399.122.camel@nimitz>
2009-03-05 22:00           ` Alexey Dobriyan
     [not found]           ` <20090305220044.GA2819@x200.localdomain>
     [not found]             ` <20090305220044.GA2819-2ev+ksY9ol182hYKe6nXyg@public.gmane.org>
2009-03-05 22:24               ` Dave Hansen
2009-03-06 15:08               ` Greg Kurz
     [not found]             ` <1236291865.22399.139.camel@nimitz>
2009-03-06 14:34               ` Serge E. Hallyn
     [not found]               ` <20090306143425.GA31250@us.ibm.com>
     [not found]                 ` <1236354509.10626.29.camel@nimitz>
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
     [not found]                     ` <1236357965.10626.51.camel@nimitz>
2009-03-06 18:24                       ` Serge E. Hallyn
     [not found]                       ` <20090306182451.GA6307@us.ibm.com>
     [not found]                         ` <20090306182451.GA6307-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
2009-03-06 19:42                           ` Dave Hansen
     [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
     [not found]             ` <1236352121.5732.80.camel@bahia>
2009-03-06 15:35               ` Serge E. Hallyn
     [not found]               ` <20090306153549.GA898@us.ibm.com>
     [not found]                 ` <20090306153549.GA898-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
2009-03-06 17:36                   ` Cedric Le Goater
     [not found]                     ` <49B15F35.2010909-GANU6spQydw@public.gmane.org>
2009-03-06 18:30                       ` Serge E. Hallyn
     [not found]                     ` <20090306183055.GA6729@us.ibm.com>
     [not found]                       ` <20090306183055.GA6729-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
2009-03-11  7:51                         ` Cedric Le Goater
     [not found]                       ` <49B76D91.1020807@free.fr>
     [not found]                         ` <49B76D91.1020807-GANU6spQydw@public.gmane.org>
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 19:44     ` [RFC][PATCH 00/11] track files for checkpointability Dave Hansen
2009-03-10 15:57 ` Nathan Lynch
     [not found] ` <20090310105702.43eb1402@thinkcentre.lan>
     [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
     [not found]   ` <20090310110000.24893e0c@thinkcentre.lan>
     [not found]     ` <20090310110000.24893e0c-4v5LP+xe+1byhTdZtsIeww@public.gmane.org>
2009-03-10 16:23       ` Serge E. Hallyn
     [not found]   ` <20090310162026.GA9354@us.ibm.com>
     [not found]     ` <20090310162026.GA9354-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
2009-03-10 17:23       ` Nathan Lynch
     [not found]     ` <20090310122320.313491ce@thinkcentre.lan>
     [not found]       ` <20090310122320.313491ce-4v5LP+xe+1byhTdZtsIeww@public.gmane.org>
2009-03-10 17:45         ` Serge E. Hallyn
     [not found]       ` <20090310174517.GA12101@us.ibm.com>
     [not found]         ` <20090310174517.GA12101-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
2009-03-10 17:47           ` Dave Hansen
     [not found]         ` <1236707250.10626.174.camel@nimitz>
2009-03-10 22:54           ` what is CONFIG_VZ_GENCALLS Zhaohui Wang
     [not found] <20090309173837.GC7561@us.ibm.com>
     [not found] ` <20090309173837.GC7561-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
2009-03-12 19:14   ` [RFC][PATCH 09/11] check files for checkpointability 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=20090305163910.5960D190@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox