From mboxrd@z Thu Jan 1 00:00:00 1970 From: Sukadev Bhattiprolu Subject: [RFC][PATCH 4/4][cr]: Restore file_owner info Date: Tue, 11 May 2010 15:38:20 -0700 Message-ID: <1273617500-13653-5-git-send-email-sukadev@linux.vnet.ibm.com> References: <1273617500-13653-1-git-send-email-sukadev@linux.vnet.ibm.com> Cc: Matt Helsley , serue@us.ibm.com, Containers , To: Oren Laadan Return-path: Received: from e3.ny.us.ibm.com ([32.97.182.143]:40554 "EHLO e3.ny.us.ibm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753613Ab0EKWct (ORCPT ); Tue, 11 May 2010 18:32:49 -0400 Received: from d01relay07.pok.ibm.com (d01relay07.pok.ibm.com [9.56.227.147]) by e3.ny.us.ibm.com (8.14.3/8.13.1) with ESMTP id o4BMK3Ej005860 for ; Tue, 11 May 2010 18:20:03 -0400 Received: from d01av04.pok.ibm.com (d01av04.pok.ibm.com [9.56.224.64]) by d01relay07.pok.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id o4BMWmPO1888334 for ; Tue, 11 May 2010 18:32:48 -0400 Received: from d01av04.pok.ibm.com (loopback [127.0.0.1]) by d01av04.pok.ibm.com (8.14.3/8.13.1/NCO v10.0 AVout) with ESMTP id o4BMWlvr000372 for ; Tue, 11 May 2010 18:32:47 -0400 In-Reply-To: <1273617500-13653-1-git-send-email-sukadev@linux.vnet.ibm.com> Sender: linux-fsdevel-owner@vger.kernel.org List-ID: Restore the file-owner information for each 'struct file'. This is essentially is like a new fcntl(F_SETOWN) and fcntl(F_SETSIG) calls, except that the pid, uid, euid and signum values are read from the checkpoint image. Signed-off-by: Sukadev Bhattiprolu --- fs/checkpoint.c | 34 ++++++++++++++++++++++++++++++++++ 1 files changed, 34 insertions(+), 0 deletions(-) diff --git a/fs/checkpoint.c b/fs/checkpoint.c index 0fa4ce8..73e2bc9 100644 --- a/fs/checkpoint.c +++ b/fs/checkpoint.c @@ -615,6 +615,36 @@ static int attach_file(struct file *file) return fd; } +static int restore_file_owner(struct ckpt_ctx *ctx, struct ckpt_hdr_file *h, + struct file *file) +{ + int ret; + struct pid *pid; + + ckpt_debug("restore_file_owner(): uid %u, euid %u, pid %d, type %d\n", + h->f_owner_uid, h->f_owner_euid, h->f_owner_pid, + h->f_owner_pid_type); + + rcu_read_lock(); + pid = find_vpid(h->f_owner_pid); + + /* + * TODO: Do we need to force==1 or can it be 0 ? 'force' is used to + * modify the owner, if one is already set. Can it be set when + * we restart an application ? + */ + ret = __f_setown_uid(file, pid, h->f_owner_pid_type, h->f_owner_uid, + h->f_owner_euid, 1); + rcu_read_unlock(); + + file->f_owner.signum = h->f_owner_signum; + + if (ret < 0) + ckpt_err(ctx, ret, "__fsetown_uid() failed\n"); + + return ret; +} + #define CKPT_SETFL_MASK \ (O_APPEND | O_NONBLOCK | O_NDELAY | FASYNC | O_DIRECT | O_NOATIME) @@ -648,6 +678,10 @@ int restore_file_common(struct ckpt_ctx *ctx, struct file *file, if (ret < 0) return ret; + ret = restore_file_owner(ctx, h, file); + if (ret < 0) + return ret; + /* * Normally f_mode is set by open, and modified only via * fcntl(), so its value now should match that at checkpoint. -- 1.6.0.4