From mboxrd@z Thu Jan 1 00:00:00 1970 From: Sukadev Bhattiprolu Subject: [PATCH 15/17][cr][v4]: Define do_setlease() Date: Mon, 16 Aug 2010 12:43:19 -0700 Message-ID: <1281987801-1293-16-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]:40970 "EHLO e38.co.us.ibm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755750Ab0HPTiK (ORCPT ); Mon, 16 Aug 2010 15:38:10 -0400 Received: from d03relay05.boulder.ibm.com (d03relay05.boulder.ibm.com [9.17.195.107]) by e38.co.us.ibm.com (8.14.4/8.13.1) with ESMTP id o7GJUoTP029516 for ; Mon, 16 Aug 2010 13:30:50 -0600 Received: from d03av01.boulder.ibm.com (d03av01.boulder.ibm.com [9.17.195.167]) by d03relay05.boulder.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id o7GJboTc075716 for ; Mon, 16 Aug 2010 13:37:53 -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 o7GJbmEr016249 for ; Mon, 16 Aug 2010 13:37:50 -0600 In-Reply-To: <1281987801-1293-1-git-send-email-sukadev@linux.vnet.ibm.com> Sender: linux-fsdevel-owner@vger.kernel.org List-ID: Move the core functionality of fcntl_setlease() into a new function, do_setlease(). do_setlease() is, same as fcntl_setlease(), except for two new parameters, 'notified' and 'break_time'. do_setlease() is used, in a follow-on patch when restoring file leases. These new parameters are needed if the lease was being broken when the process was checkpointed. The parameter 'notified' is used to notify the lease-holder exactly once, even if the lease was checkpointed during a lease-break and then restarted. The parameter, 'break_time' specifies the new break-time for the lease. (i.e if the process had 10-seconds remaining on the lease when it was checkpointed, the 'break_time' is used give the process 10 seconds on the lease after the process is restarted). Signed-off-by: Sukadev Bhattiprolu --- fs/locks.c | 31 ++++++++++++++++++++----------- include/linux/fs.h | 2 ++ 2 files changed, 22 insertions(+), 11 deletions(-) diff --git a/fs/locks.c b/fs/locks.c index b5eb4c0..6e84d90 100644 --- a/fs/locks.c +++ b/fs/locks.c @@ -1490,17 +1490,8 @@ int vfs_setlease(struct file *filp, long arg, struct file_lock **lease) } EXPORT_SYMBOL_GPL(vfs_setlease); -/** - * fcntl_setlease - sets a lease on an open file - * @fd: open file descriptor - * @filp: file pointer - * @arg: type of lease to obtain - * - * Call this fcntl to establish a lease on the file. - * Note that you also need to call %F_SETSIG to - * receive a signal when the lease is broken. - */ -int fcntl_setlease(unsigned int fd, struct file *filp, long arg) +int do_setlease(unsigned int fd, struct file *filp, long arg, + unsigned long break_time, int notified) { struct file_lock fl, *flp = &fl; struct inode *inode = filp->f_path.dentry->d_inode; @@ -1511,6 +1502,9 @@ int fcntl_setlease(unsigned int fd, struct file *filp, long arg) if (error) return error; + fl.fl_break_notified = notified; + fl.fl_break_time = break_time; + lock_kernel(); error = vfs_setlease(filp, arg, &flp); @@ -1534,6 +1528,21 @@ out_unlock: } /** + * fcntl_setlease - sets a lease on an open file + * @fd: open file descriptor + * @filp: file pointer + * @arg: type of lease to obtain + * + * Call this fcntl to establish a lease on the file. + * Note that you also need to call %F_SETSIG to + * receive a signal when the lease is broken. + */ +int fcntl_setlease(unsigned int fd, struct file *filp, long arg) +{ + return do_setlease(fd, filp, arg, 0UL, 0); +} + +/** * flock_lock_file_wait - Apply a FLOCK-style lock to a file * @filp: The file to apply the lock to * @fl: The lock to be applied diff --git a/include/linux/fs.h b/include/linux/fs.h index c21f002..5056477 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -1124,6 +1124,8 @@ extern int flock64_set(unsigned int, struct file *, unsigned int, struct flock64 *); #endif +extern int do_setlease(unsigned int fd, struct file *filp, long arg, + unsigned long break_time, int notified); extern int fcntl_setlease(unsigned int fd, struct file *filp, long arg); extern int fcntl_getlease(struct file *filp); -- 1.6.0.4