Re: [NFS] [PATCH] locks: share more common lease code

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, 2007-05-31 at 17:40 -0400, J. Bruce Fields wrote:
> From: J. Bruce Fields <bfields@xxxxxxxxxxxxxx>
> 
> Share more code between setlease (used by nfsd) and fcntl.
> 
> Also some minor cleanup.
> 
> Signed-off-by: "J. Bruce Fields" <bfields@xxxxxxxxxxxxxx>
> ---
>  fs/locks.c |   14 +++-----------
>  1 files changed, 3 insertions(+), 11 deletions(-)
> 
> diff --git a/fs/locks.c b/fs/locks.c
> index 431a8b8..3f366e1 100644
> --- a/fs/locks.c
> +++ b/fs/locks.c
> @@ -1469,14 +1469,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)
> @@ -1484,15 +1476,15 @@ int fcntl_setlease(unsigned int fd, struct file *filp, long arg)
>  
>  	lock_kernel();
>  
> -	error = __setlease(filp, arg, &flp);
> +	error = setlease(filp, arg, &flp);
>  	if (error || arg == F_UNLCK)
>  		goto out_unlock;
>  
>  	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;
>  	}

Why not move the security checks from setlease() into __setlease()? That
way you can continue to avoid the calls to (re)take the BKL, which are
redundant as far as fcntl_setlease() is concerned.

Cheers
  Trond

-
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [Samba]     [Device Mapper]     [CEPH Development]
  Powered by Linux