From mboxrd@z Thu Jan 1 00:00:00 1970 From: Sukadev Bhattiprolu Subject: [PATCH 03/17][cr][v4]: Checkpoint file-owner information Date: Mon, 16 Aug 2010 12:43:07 -0700 Message-ID: <1281987801-1293-4-git-send-email-sukadev@linux.vnet.ibm.com> References: <1281987801-1293-1-git-send-email-sukadev@linux.vnet.ibm.com> Cc: Serge Hallyn , Matt Helsley , Dan Smith , John Stultz , Matthew Wilcox , Jamie Lokier , Steven Whitehouse , , Containers To: Oren Laadan Return-path: Received: from e38.co.us.ibm.com ([32.97.110.159]:40879 "EHLO e38.co.us.ibm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756103Ab0HPThu (ORCPT ); Mon, 16 Aug 2010 15:37:50 -0400 Received: from d03relay04.boulder.ibm.com (d03relay04.boulder.ibm.com [9.17.195.106]) by e38.co.us.ibm.com (8.14.4/8.13.1) with ESMTP id o7GJUVs9029289 for ; Mon, 16 Aug 2010 13:30:31 -0600 Received: from d03av01.boulder.ibm.com (d03av01.boulder.ibm.com [9.17.195.167]) by d03relay04.boulder.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id o7GJbaiL073138 for ; Mon, 16 Aug 2010 13:37:37 -0600 Received: from d03av01.boulder.ibm.com (loopback [127.0.0.1]) by d03av01.boulder.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id o7GJbYcE014938 for ; Mon, 16 Aug 2010 13:37:36 -0600 In-Reply-To: <1281987801-1293-1-git-send-email-sukadev@linux.vnet.ibm.com> Sender: linux-fsdevel-owner@vger.kernel.org List-ID: Checkpoint the file->f_owner information for an open file. This information will be used to restore the file-owner information when the application is restarted from the checkpoint. The file->f_owner information is "private" to each 'struct file' i.e. fown_struct is not an external object shared with other file structures. So the information can directly be added to the 'ckpt_hdr_file' object. Signed-off-by: Sukadev Bhattiprolu --- fs/checkpoint.c | 27 +++++++++++---------------- include/linux/checkpoint_hdr.h | 5 +++++ 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/fs/checkpoint.c b/fs/checkpoint.c index 87d7c6e..ce1b4af 100644 --- a/fs/checkpoint.c +++ b/fs/checkpoint.c @@ -168,12 +168,19 @@ int checkpoint_file_common(struct ckpt_ctx *ctx, struct file *file, struct ckpt_hdr_file *h) { struct cred *f_cred = (struct cred *) file->f_cred; + struct pid *pid = file->f_owner.pid; h->f_flags = file->f_flags; h->f_mode = file->f_mode; h->f_pos = file->f_pos; h->f_version = file->f_version; + h->f_owner_pid = pid_nr_ns(pid, ns_of_pid(pid)); + h->f_owner_pid_type = file->f_owner.pid_type; + h->f_owner_uid = file->f_owner.uid; + h->f_owner_euid = file->f_owner.euid; + h->f_owner_signum = file->f_owner.signum; + h->f_credref = checkpoint_obj(ctx, f_cred, CKPT_OBJ_CRED); if (h->f_credref < 0) return h->f_credref; @@ -184,10 +191,10 @@ int checkpoint_file_common(struct ckpt_ctx *ctx, struct file *file, return h->f_secref; } - ckpt_debug("file %s credref %d secref %d\n", - file->f_dentry->d_name.name, h->f_credref, h->f_secref); - - /* FIX: need also file->f_owner, etc */ + ckpt_debug("file %s credref %d secref %d, fowner-pid %d, type %d, " + "fowner-signum %d\n", file->f_dentry->d_name.name, + h->f_credref, h->f_secref, h->f_owner_pid, + h->f_owner_pid_type, h->f_owner_signum); return 0; } @@ -267,7 +274,6 @@ static int checkpoint_file_desc(struct ckpt_ctx *ctx, struct fdtable *fdt; int objref, ret; int coe = 0; /* avoid gcc warning */ - pid_t pid; h = ckpt_hdr_get_type(ctx, sizeof(*h), CKPT_HDR_FILE_DESC); if (!h) @@ -302,17 +308,6 @@ static int checkpoint_file_desc(struct ckpt_ctx *ctx, } /* - * TODO: Implement c/r of fowner and f_sigio. Should be - * trivial, but for now we just refuse its checkpoint - */ - pid = f_getown(file); - if (pid) { - ret = -EBUSY; - ckpt_err(ctx, ret, "%(T)fd %d has an owner (%d)\n", fd); - goto out; - } - - /* * if seen first time, this will add 'file' to the objhash, keep * a reference to it, dump its state while at it. */ diff --git a/include/linux/checkpoint_hdr.h b/include/linux/checkpoint_hdr.h index 9e8d518..0381019 100644 --- a/include/linux/checkpoint_hdr.h +++ b/include/linux/checkpoint_hdr.h @@ -575,6 +575,11 @@ struct ckpt_hdr_file { __u64 f_pos; __u64 f_version; __s32 f_secref; + __s32 f_owner_pid; + __u32 f_owner_pid_type; + __u32 f_owner_uid; + __u32 f_owner_euid; + __s32 f_owner_signum; } __attribute__((aligned(8))); struct ckpt_hdr_file_generic { -- 1.6.0.4