Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755397AbZGVKSk (ORCPT ); Wed, 22 Jul 2009 06:18:40 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1754199AbZGVKKk (ORCPT ); Wed, 22 Jul 2009 06:10:40 -0400 Received: from smtp161.dfw.emailsrvr.com ([67.192.241.161]:40236 "EHLO smtp161.dfw.emailsrvr.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754174AbZGVKKi (ORCPT ); Wed, 22 Jul 2009 06:10:38 -0400 From: Oren Laadan To: Andrew Morton Cc: Linus Torvalds , containers@lists.linux-foundation.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-api@vger.kernel.org, Serge Hallyn , Dave Hansen , Ingo Molnar , "H. Peter Anvin" , Alexander Viro , Pavel Emelyanov , Alexey Dobriyan , Oren Laadan , Oren Laadan Subject: [RFC v17][PATCH 32/60] c/r: introduce '->checkpoint()' method in 'struct file_operations' Date: Wed, 22 Jul 2009 05:59:54 -0400 Message-Id: <1248256822-23416-33-git-send-email-orenl@librato.com> X-Mailer: git-send-email 1.6.0.4 In-Reply-To: <1248256822-23416-1-git-send-email-orenl@librato.com> References: <1248256822-23416-1-git-send-email-orenl@librato.com> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 3432 Lines: 110 While we assume all normal files and directories can be checkpointed, there are, as usual in the VFS, specialized places that will always need an ability to override these defaults. Although we could do this completely in the checkpoint code, that would bitrot quickly. This adds a new 'file_operations' function for checkpointing a file. It is assumed that there should be a dirt-simple way to make something (un)checkpointable that fits in with current code. As you can see in the ext[234] patches down the road, all that we have to do to make something simple be supported is add a single "generic" f_op entry. Also introduce vfs_fcntl() so that it can be called from restart (see patch adding restart of files). Changelog[v17] - Forward-declare 'ckpt_ctx' et-al, don't use checkpoint_types.h Signed-off-by: Oren Laadan --- fs/fcntl.c | 21 +++++++++++++-------- include/linux/fs.h | 6 ++++++ 2 files changed, 19 insertions(+), 8 deletions(-) diff --git a/fs/fcntl.c b/fs/fcntl.c index ae41308..78d3116 100644 --- a/fs/fcntl.c +++ b/fs/fcntl.c @@ -339,6 +339,18 @@ static long do_fcntl(int fd, unsigned int cmd, unsigned long arg, return err; } +int vfs_fcntl(int fd, unsigned int cmd, unsigned long arg, struct file *filp) +{ + int err; + + err = security_file_fcntl(filp, cmd, arg); + if (err) + goto out; + err = do_fcntl(fd, cmd, arg, filp); + out: + return err; +} + SYSCALL_DEFINE3(fcntl, unsigned int, fd, unsigned int, cmd, unsigned long, arg) { struct file *filp; @@ -348,14 +360,7 @@ SYSCALL_DEFINE3(fcntl, unsigned int, fd, unsigned int, cmd, unsigned long, arg) if (!filp) goto out; - err = security_file_fcntl(filp, cmd, arg); - if (err) { - fput(filp); - return err; - } - - err = do_fcntl(fd, cmd, arg, filp); - + err = vfs_fcntl(fd, cmd, arg, filp); fput(filp); out: return err; diff --git a/include/linux/fs.h b/include/linux/fs.h index d88d4fc..05d4745 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -388,6 +388,7 @@ struct kstatfs; struct vm_area_struct; struct vfsmount; struct cred; +struct ckpt_ctx; extern void __init inode_init(void); extern void __init inode_init_early(void); @@ -1088,6 +1089,8 @@ struct file_lock { #include +extern int vfs_fcntl(int fd, unsigned cmd, unsigned long arg, struct file *fp); + extern void send_sigio(struct fown_struct *fown, int fd, int band); /* fs/sync.c */ @@ -1510,6 +1513,7 @@ struct file_operations { ssize_t (*splice_write)(struct pipe_inode_info *, struct file *, loff_t *, size_t, unsigned int); ssize_t (*splice_read)(struct file *, loff_t *, struct pipe_inode_info *, size_t, unsigned int); int (*setlease)(struct file *, long, struct file_lock **); + int (*checkpoint)(struct ckpt_ctx *, struct file *); }; struct inode_operations { @@ -2309,6 +2313,8 @@ void inode_sub_bytes(struct inode *inode, loff_t bytes); loff_t inode_get_bytes(struct inode *inode); void inode_set_bytes(struct inode *inode, loff_t bytes); +#define generic_file_checkpoint NULL + extern int vfs_readdir(struct file *, filldir_t, void *); extern int vfs_stat(char __user *, struct kstat *); -- 1.6.0.4 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/