From: Oren Laadan <orenl@cs.columbia.edu>
To: "Serge E. Hallyn" <serue@us.ibm.com>
Cc: dave@linux.vnet.ibm.com, containers@lists.linux-foundation.org,
jeremy@goop.org, linux-kernel@vger.kernel.org, arnd@arndb.de
Subject: Re: [RFC v5][PATCH 9/9] Restore open file descriprtors
Date: Tue, 16 Sep 2008 20:11:05 -0400 [thread overview]
Message-ID: <48D04B19.9060502@cs.columbia.edu> (raw)
In-Reply-To: <20080916230850.GB25445@us.ibm.com>
Serge E. Hallyn wrote:
> Quoting Oren Laadan (orenl@cs.columbia.edu):
>> Restore open file descriptors: for each FD read 'struct cr_hdr_fd_ent'
>> and lookup objref in the hash table; if not found (first occurence), read
>> in 'struct cr_hdr_fd_data', create a new FD and register in the hash.
>> Otherwise attach the file pointer from the hash as an FD.
>>
>> This patch only handles basic FDs - regular files, directories and also
>> symbolic links.
>>
>> Signed-off-by: Oren Laadan <orenl@cs.columbia.edu>
>> ---
>> checkpoint/Makefile | 2 +-
>> checkpoint/restart.c | 4 +
>> checkpoint/rstr_file.c | 202 ++++++++++++++++++++++++++++++++++++++++++++
>> include/linux/checkpoint.h | 1 +
>> 4 files changed, 208 insertions(+), 1 deletions(-)
>> create mode 100644 checkpoint/rstr_file.c
>>
>> diff --git a/checkpoint/Makefile b/checkpoint/Makefile
>> index 7496695..88bbc10 100644
>> --- a/checkpoint/Makefile
>> +++ b/checkpoint/Makefile
>> @@ -3,4 +3,4 @@
>> #
>>
>> obj-$(CONFIG_CHECKPOINT_RESTART) += sys.o checkpoint.o restart.o objhash.o \
>> - ckpt_mem.o rstr_mem.o ckpt_file.o
>> + ckpt_mem.o rstr_mem.o ckpt_file.o rstr_file.o
>> diff --git a/checkpoint/restart.c b/checkpoint/restart.c
>> index a0d5e60..956e274 100644
>> --- a/checkpoint/restart.c
>> +++ b/checkpoint/restart.c
>> @@ -212,6 +212,10 @@ static int cr_read_task(struct cr_ctx *ctx)
>> cr_debug("memory: ret %d\n", ret);
>> if (ret < 0)
>> goto out;
>> + ret = cr_read_files(ctx);
>> + cr_debug("files: ret %d\n", ret);
>> + if (ret < 0)
>> + goto out;
>> ret = cr_read_thread(ctx);
>> cr_debug("thread: ret %d\n", ret);
>> if (ret < 0)
>> diff --git a/checkpoint/rstr_file.c b/checkpoint/rstr_file.c
>> new file mode 100644
>> index 0000000..780c0fc
>> --- /dev/null
>> +++ b/checkpoint/rstr_file.c
>> @@ -0,0 +1,202 @@
>> +/*
>> + * Checkpoint file descriptors
>> + *
>> + * Copyright (C) 2008 Oren Laadan
>> + *
>> + * This file is subject to the terms and conditions of the GNU General Public
>> + * License. See the file COPYING in the main directory of the Linux
>> + * distribution for more details.
>> + */
>> +
>> +#include <linux/kernel.h>
>> +#include <linux/sched.h>
>> +#include <linux/fs.h>
>> +#include <linux/file.h>
>> +#include <linux/fdtable.h>
>> +#include <linux/fsnotify.h>
>> +#include <linux/syscalls.h>
>> +#include <linux/checkpoint.h>
>> +#include <linux/checkpoint_hdr.h>
>> +
>> +#include "checkpoint_file.h"
>> +
>> +static int cr_close_all_fds(struct files_struct *files)
>> +{
>> + int *fdtable;
>> + int nfds;
>> +
>> + nfds = cr_scan_fds(files, &fdtable);
>> + if (nfds < 0)
>> + return nfds;
>> + while (nfds--)
>> + sys_close(fdtable[nfds]);
>> + kfree(fdtable);
>> + return 0;
>> +}
>> +
>> +/**
>> + * cr_attach_file - attach a lonely file ptr to a file descriptor
>> + * @file: lonely file pointer
>> + */
>> +static int cr_attach_file(struct file *file)
>> +{
>> + int fd = get_unused_fd_flags(0);
>> +
>> + if (fd >= 0) {
>> + fsnotify_open(file->f_path.dentry);
>> + fd_install(fd, file);
>> + }
>> + return fd;
>> +}
>> +
>> +#define CR_SETFL_MASK (O_APPEND|O_NONBLOCK|O_NDELAY|FASYNC|O_DIRECT|O_NOATIME)
>> +
>> +/* cr_read_fd_data - restore the state of a given file pointer */
>> +static int
>> +cr_read_fd_data(struct cr_ctx *ctx, struct files_struct *files, int parent)
>> +{
>> + struct cr_hdr_fd_data *hh = cr_hbuf_get(ctx, sizeof(*hh));
>
> You're leaking hh in a whole slew of error paths.
No. (this was discussed earlier already).
cr_hbuf_get() "allocates" space inside a dedicated buffer for headers
in the checkpoint context (ctx->hbuf). It does not allocate new kernel
memory. Instead, it returns the current position in that buffer
ctx->hbuf[ctx->hpos], and advances ctx->hpos appropriately. On the
other side, cr_hbuf_put() reverses that effect, reducing ctx->hpos
accordingly.
If an error occurs, the checkpoint (or restart) operation is aborted,
and eventually the context (ctx) will be cleaned up; at that point the
special purpose buffer will be freed.
[...]
Oren.
next prev parent reply other threads:[~2008-09-17 0:12 UTC|newest]
Thread overview: 87+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-09-13 23:05 [RFC v5][PATCH 0/9] Kernel based checkpoint/restart Oren Laadan
2008-09-13 23:06 ` [RFC v5][PATCH 2/8] General infrastructure for checkpoint restart Oren Laadan
2008-09-15 17:54 ` Dave Hansen
[not found] ` <1221347167-9956-3-git-send-email-orenl-eQaUEPhvms7ENvBUuze7eA@public.gmane.org>
2008-09-15 17:54 ` Dave Hansen
2008-09-15 17:59 ` Dave Hansen
2008-09-15 18:00 ` Dave Hansen
2008-09-15 18:02 ` Dave Hansen
2008-09-15 21:15 ` Serge E. Hallyn
2008-09-15 17:59 ` Dave Hansen
2008-09-15 18:00 ` Dave Hansen
2008-09-15 18:02 ` Dave Hansen
2008-09-15 18:52 ` Oren Laadan
2008-09-15 19:13 ` Dave Hansen
[not found] ` <48CEAEF2.1050901-eQaUEPhvms7ENvBUuze7eA@public.gmane.org>
2008-09-15 19:13 ` Dave Hansen
2008-09-15 18:52 ` Oren Laadan
2008-09-16 12:27 ` Bastian Blank
2008-09-16 12:27 ` Bastian Blank
2008-09-15 21:15 ` Serge E. Hallyn
2008-09-13 23:06 ` [RFC v5][PATCH 4/8] Dump memory address space Oren Laadan
2008-09-17 6:48 ` MinChan Kim
[not found] ` <1221347167-9956-5-git-send-email-orenl-eQaUEPhvms7ENvBUuze7eA@public.gmane.org>
2008-09-17 6:48 ` MinChan Kim
[not found] ` <1221347167-9956-1-git-send-email-orenl-eQaUEPhvms7ENvBUuze7eA@public.gmane.org>
2008-09-13 23:05 ` [RFC v5][PATCH 1/8] Create syscalls: sys_checkpoint, sys_restart Oren Laadan
2008-09-13 23:05 ` Oren Laadan
[not found] ` <1221347167-9956-2-git-send-email-orenl-eQaUEPhvms7ENvBUuze7eA@public.gmane.org>
2008-09-15 20:28 ` Serge E. Hallyn
2008-09-15 20:28 ` Serge E. Hallyn
2008-09-13 23:06 ` [RFC v5][PATCH 2/8] General infrastructure for checkpoint restart Oren Laadan
2008-09-13 23:06 ` [RFC v5][PATCH 3/8] x86 support for checkpoint/restart Oren Laadan
2008-09-13 23:06 ` Oren Laadan
[not found] ` <1221347167-9956-4-git-send-email-orenl-eQaUEPhvms7ENvBUuze7eA@public.gmane.org>
2008-09-15 21:31 ` Serge E. Hallyn
2008-09-15 21:31 ` Serge E. Hallyn
2008-09-13 23:06 ` [RFC v5][PATCH 4/8] Dump memory address space Oren Laadan
2008-09-13 23:06 ` [RFC v5][PATCH 5/8] Restore " Oren Laadan
2008-09-13 23:06 ` Oren Laadan
2008-09-15 19:14 ` Dave Hansen
[not found] ` <1221347167-9956-6-git-send-email-orenl-eQaUEPhvms7ENvBUuze7eA@public.gmane.org>
2008-09-15 19:14 ` Dave Hansen
2008-09-13 23:06 ` [RFC v5][PATCH 6/8] Checkpoint/restart: initial documentation Oren Laadan
2008-09-13 23:06 ` Oren Laadan
2008-09-15 20:26 ` Serge E. Hallyn
2008-09-17 6:23 ` MinChan Kim
[not found] ` <1221347167-9956-7-git-send-email-orenl-eQaUEPhvms7ENvBUuze7eA@public.gmane.org>
2008-09-15 20:26 ` Serge E. Hallyn
2008-09-17 6:23 ` MinChan Kim
2008-09-13 23:06 ` [RFC v5][PATCH 7/8] Infrastructure for shared objects Oren Laadan
2008-09-13 23:06 ` Oren Laadan
[not found] ` <1221347167-9956-8-git-send-email-orenl-eQaUEPhvms7ENvBUuze7eA@public.gmane.org>
2008-09-16 16:48 ` Dave Hansen
2008-09-16 16:48 ` Dave Hansen
2008-09-17 7:31 ` MinChan Kim
2008-09-17 7:31 ` MinChan Kim
2008-09-16 20:54 ` Serge E. Hallyn
2008-09-16 20:54 ` Serge E. Hallyn
[not found] ` <20080916205459.GA7644-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
2008-09-16 21:36 ` Oren Laadan
2008-09-16 21:36 ` Oren Laadan
[not found] ` <48D026ED.3080109-eQaUEPhvms7ENvBUuze7eA@public.gmane.org>
2008-09-16 22:09 ` Serge E. Hallyn
2008-09-16 22:09 ` Serge E. Hallyn
2008-09-13 23:06 ` [RFC v5][PATCH 8/8] Dump open file descriptors Oren Laadan
2008-09-13 23:06 ` Oren Laadan
[not found] ` <1221347167-9956-9-git-send-email-orenl-eQaUEPhvms7ENvBUuze7eA@public.gmane.org>
2008-09-14 9:51 ` Bastian Blank
2008-09-16 15:54 ` Dave Hansen
2008-09-16 16:55 ` Dave Hansen
2008-09-14 9:51 ` Bastian Blank
2008-09-14 15:40 ` Oren Laadan
2008-09-16 23:03 ` Serge E. Hallyn
2008-09-22 15:31 ` Dave Hansen
[not found] ` <20080916230320.GA25445-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
2008-09-22 15:31 ` Dave Hansen
[not found] ` <48CD3069.7080200-eQaUEPhvms7ENvBUuze7eA@public.gmane.org>
2008-09-16 23:03 ` Serge E. Hallyn
[not found] ` <20080914095106.GA6300-0IJIQSrh9RL9UF0aPl6fsj8Kkb2uy4ct@public.gmane.org>
2008-09-14 15:40 ` Oren Laadan
2008-09-16 15:54 ` Dave Hansen
2008-09-16 16:55 ` Dave Hansen
2008-09-13 23:06 ` [RFC v5][PATCH 9/9] Restore open file descriprtors Oren Laadan
2008-09-13 23:22 ` Oren Laadan
2008-09-17 14:16 ` [RFC v5][PATCH 0/9] Kernel based checkpoint/restart Serge E. Hallyn
2008-09-24 21:42 ` Serge E. Hallyn
2008-09-13 23:06 ` [RFC v5][PATCH 9/9] Restore open file descriprtors Oren Laadan
2008-09-16 23:08 ` Serge E. Hallyn
2008-09-17 0:11 ` Oren Laadan [this message]
2008-09-17 4:56 ` Serge E. Hallyn
[not found] ` <48D04B19.9060502-eQaUEPhvms7ENvBUuze7eA@public.gmane.org>
2008-09-17 4:56 ` Serge E. Hallyn
2008-09-22 16:02 ` Dave Hansen
2008-09-22 16:02 ` Dave Hansen
[not found] ` <20080916230850.GB25445-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
2008-09-17 0:11 ` Oren Laadan
[not found] ` <1221347167-9956-10-git-send-email-orenl-eQaUEPhvms7ENvBUuze7eA@public.gmane.org>
2008-09-16 23:08 ` Serge E. Hallyn
2008-09-13 23:22 ` Oren Laadan
2008-09-17 14:16 ` [RFC v5][PATCH 0/9] Kernel based checkpoint/restart Serge E. Hallyn
[not found] ` <20080917141601.GA14010-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
2008-10-08 9:59 ` Oren Laadan
2008-10-08 9:59 ` Oren Laadan
2008-09-24 21:42 ` Serge E. Hallyn
2008-09-25 12:58 ` Cedric Le Goater
[not found] ` <20080924214242.GA27875-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
2008-09-25 12:58 ` Cedric Le Goater
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=48D04B19.9060502@cs.columbia.edu \
--to=orenl@cs.columbia.edu \
--cc=arnd@arndb.de \
--cc=containers@lists.linux-foundation.org \
--cc=dave@linux.vnet.ibm.com \
--cc=jeremy@goop.org \
--cc=linux-kernel@vger.kernel.org \
--cc=serue@us.ibm.com \
/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.