summaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorJ. Bruce Fields <bfields@citi.umich.edu>2007-05-31 17:03:46 -0400
committerJ. Bruce Fields <bfields@citi.umich.edu>2007-07-18 19:09:27 -0400
commit6d5e8b05caf074ae5676ad9aaf92e381226a14a7 (patch)
tree6837ed4232f3eefccf054e6ae94dab70938c8e4f /fs
parente32b8ee27b486f682a6d13533cfe6549c8abcdef (diff)
downloadop-kernel-dev-6d5e8b05caf074ae5676ad9aaf92e381226a14a7.zip
op-kernel-dev-6d5e8b05caf074ae5676ad9aaf92e381226a14a7.tar.gz
locks: share more common lease code
Share more code between setlease (used by nfsd) and fcntl. Also some minor cleanup. Signed-off-by: "J. Bruce Fields" <bfields@citi.umich.edu> Acked-by: Christoph Hellwig <hch@infradead.org>
Diffstat (limited to 'fs')
-rw-r--r--fs/locks.c30
1 files changed, 10 insertions, 20 deletions
diff --git a/fs/locks.c b/fs/locks.c
index 838ca54..0e5873b 100644
--- a/fs/locks.c
+++ b/fs/locks.c
@@ -1343,6 +1343,14 @@ static int __setlease(struct file *filp, long arg, struct file_lock **flp)
struct inode *inode = dentry->d_inode;
int error, rdlease_count = 0, wrlease_count = 0;
+ if ((current->fsuid != inode->i_uid) && !capable(CAP_LEASE))
+ return -EACCES;
+ if (!S_ISREG(inode->i_mode))
+ return -EINVAL;
+ error = security_file_lock(filp, arg);
+ if (error)
+ return error;
+
time_out_leases(inode);
BUG_ON(!(*flp)->fl_lmops->fl_break);
@@ -1426,18 +1434,8 @@ out:
int setlease(struct file *filp, long arg, struct file_lock **lease)
{
- struct dentry *dentry = filp->f_path.dentry;
- struct inode *inode = dentry->d_inode;
int error;
- if ((current->fsuid != inode->i_uid) && !capable(CAP_LEASE))
- return -EACCES;
- if (!S_ISREG(inode->i_mode))
- return -EINVAL;
- error = security_file_lock(filp, arg);
- if (error)
- return error;
-
lock_kernel();
error = __setlease(filp, arg, lease);
unlock_kernel();
@@ -1464,14 +1462,6 @@ int fcntl_setlease(unsigned int fd, struct file *filp, long arg)
struct inode *inode = dentry->d_inode;
int error;
- if ((current->fsuid != inode->i_uid) && !capable(CAP_LEASE))
- return -EACCES;
- if (!S_ISREG(inode->i_mode))
- return -EINVAL;
- error = security_file_lock(filp, arg);
- if (error)
- return error;
-
locks_init_lock(&fl);
error = lease_init(filp, arg, &fl);
if (error)
@@ -1485,9 +1475,9 @@ int fcntl_setlease(unsigned int fd, struct file *filp, long arg)
error = fasync_helper(fd, filp, 1, &flp->fl_fasync);
if (error < 0) {
- /* remove lease just inserted by __setlease */
+ /* remove lease just inserted by setlease */
flp->fl_type = F_UNLCK | F_INPROGRESS;
- flp->fl_break_time = jiffies- 10;
+ flp->fl_break_time = jiffies - 10;
time_out_leases(inode);
goto out_unlock;
}
OpenPOWER on IntegriCloud