aboutsummaryrefslogtreecommitdiffstats
path: root/fs/locks.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/locks.c')
-rw-r--r--fs/locks.c32
1 files changed, 20 insertions, 12 deletions
diff --git a/fs/locks.c b/fs/locks.c
index e16c2c61a44f..4fa269b0bdef 100644
--- a/fs/locks.c
+++ b/fs/locks.c
@@ -1297,7 +1297,6 @@ int lease_modify(struct file_lock **before, int arg)
1297 } 1297 }
1298 return 0; 1298 return 0;
1299} 1299}
1300
1301EXPORT_SYMBOL(lease_modify); 1300EXPORT_SYMBOL(lease_modify);
1302 1301
1303static bool past_time(unsigned long then) 1302static bool past_time(unsigned long then)
@@ -1543,7 +1542,8 @@ check_conflicting_open(const struct dentry *dentry, const long arg)
1543 return ret; 1542 return ret;
1544} 1543}
1545 1544
1546static int generic_add_lease(struct file *filp, long arg, struct file_lock **flp) 1545static int
1546generic_add_lease(struct file *filp, long arg, struct file_lock **flp, void **priv)
1547{ 1547{
1548 struct file_lock *fl, **before, **my_before = NULL, *lease; 1548 struct file_lock *fl, **before, **my_before = NULL, *lease;
1549 struct dentry *dentry = filp->f_path.dentry; 1549 struct dentry *dentry = filp->f_path.dentry;
@@ -1630,11 +1630,14 @@ static int generic_add_lease(struct file *filp, long arg, struct file_lock **flp
1630 smp_mb(); 1630 smp_mb();
1631 error = check_conflicting_open(dentry, arg); 1631 error = check_conflicting_open(dentry, arg);
1632 if (error) 1632 if (error)
1633 locks_unlink_lock(before); 1633 goto out_unlink;
1634out: 1634out:
1635 if (is_deleg) 1635 if (is_deleg)
1636 mutex_unlock(&inode->i_mutex); 1636 mutex_unlock(&inode->i_mutex);
1637 return error; 1637 return error;
1638out_unlink:
1639 locks_unlink_lock(before);
1640 goto out;
1638} 1641}
1639 1642
1640static int generic_delete_lease(struct file *filp) 1643static int generic_delete_lease(struct file *filp)
@@ -1661,13 +1664,15 @@ static int generic_delete_lease(struct file *filp)
1661 * @filp: file pointer 1664 * @filp: file pointer
1662 * @arg: type of lease to obtain 1665 * @arg: type of lease to obtain
1663 * @flp: input - file_lock to use, output - file_lock inserted 1666 * @flp: input - file_lock to use, output - file_lock inserted
1667 * @priv: private data for lm_setup
1664 * 1668 *
1665 * The (input) flp->fl_lmops->lm_break function is required 1669 * The (input) flp->fl_lmops->lm_break function is required
1666 * by break_lease(). 1670 * by break_lease().
1667 * 1671 *
1668 * Called with inode->i_lock held. 1672 * Called with inode->i_lock held.
1669 */ 1673 */
1670int generic_setlease(struct file *filp, long arg, struct file_lock **flp) 1674int generic_setlease(struct file *filp, long arg, struct file_lock **flp,
1675 void **priv)
1671{ 1676{
1672 struct dentry *dentry = filp->f_path.dentry; 1677 struct dentry *dentry = filp->f_path.dentry;
1673 struct inode *inode = dentry->d_inode; 1678 struct inode *inode = dentry->d_inode;
@@ -1692,19 +1697,20 @@ int generic_setlease(struct file *filp, long arg, struct file_lock **flp)
1692 WARN_ON_ONCE(1); 1697 WARN_ON_ONCE(1);
1693 return -ENOLCK; 1698 return -ENOLCK;
1694 } 1699 }
1695 return generic_add_lease(filp, arg, flp); 1700 return generic_add_lease(filp, arg, flp, priv);
1696 default: 1701 default:
1697 return -EINVAL; 1702 return -EINVAL;
1698 } 1703 }
1699} 1704}
1700EXPORT_SYMBOL(generic_setlease); 1705EXPORT_SYMBOL(generic_setlease);
1701 1706
1702static int __vfs_setlease(struct file *filp, long arg, struct file_lock **lease) 1707static int
1708__vfs_setlease(struct file *filp, long arg, struct file_lock **lease, void **priv)
1703{ 1709{
1704 if (filp->f_op->setlease) 1710 if (filp->f_op->setlease)
1705 return filp->f_op->setlease(filp, arg, lease); 1711 return filp->f_op->setlease(filp, arg, lease, priv);
1706 else 1712 else
1707 return generic_setlease(filp, arg, lease); 1713 return generic_setlease(filp, arg, lease, priv);
1708} 1714}
1709 1715
1710/** 1716/**
@@ -1712,6 +1718,7 @@ static int __vfs_setlease(struct file *filp, long arg, struct file_lock **lease)
1712 * @filp: file pointer 1718 * @filp: file pointer
1713 * @arg: type of lease to obtain 1719 * @arg: type of lease to obtain
1714 * @lease: file_lock to use when adding a lease 1720 * @lease: file_lock to use when adding a lease
1721 * @priv: private info for lm_setup when adding a lease
1715 * 1722 *
1716 * Call this to establish a lease on the file. The "lease" argument is not 1723 * Call this to establish a lease on the file. The "lease" argument is not
1717 * used for F_UNLCK requests and may be NULL. For commands that set or alter 1724 * used for F_UNLCK requests and may be NULL. For commands that set or alter
@@ -1720,13 +1727,14 @@ static int __vfs_setlease(struct file *filp, long arg, struct file_lock **lease)
1720 * stack trace). 1727 * stack trace).
1721 */ 1728 */
1722 1729
1723int vfs_setlease(struct file *filp, long arg, struct file_lock **lease) 1730int
1731vfs_setlease(struct file *filp, long arg, struct file_lock **lease, void **priv)
1724{ 1732{
1725 struct inode *inode = file_inode(filp); 1733 struct inode *inode = file_inode(filp);
1726 int error; 1734 int error;
1727 1735
1728 spin_lock(&inode->i_lock); 1736 spin_lock(&inode->i_lock);
1729 error = __vfs_setlease(filp, arg, lease); 1737 error = __vfs_setlease(filp, arg, lease, priv);
1730 spin_unlock(&inode->i_lock); 1738 spin_unlock(&inode->i_lock);
1731 1739
1732 return error; 1740 return error;
@@ -1751,7 +1759,7 @@ static int do_fcntl_add_lease(unsigned int fd, struct file *filp, long arg)
1751 } 1759 }
1752 ret = fl; 1760 ret = fl;
1753 spin_lock(&inode->i_lock); 1761 spin_lock(&inode->i_lock);
1754 error = __vfs_setlease(filp, arg, &ret); 1762 error = __vfs_setlease(filp, arg, &ret, NULL);
1755 if (error) 1763 if (error)
1756 goto out_unlock; 1764 goto out_unlock;
1757 if (ret == fl) 1765 if (ret == fl)
@@ -1789,7 +1797,7 @@ out_unlock:
1789int fcntl_setlease(unsigned int fd, struct file *filp, long arg) 1797int fcntl_setlease(unsigned int fd, struct file *filp, long arg)
1790{ 1798{
1791 if (arg == F_UNLCK) 1799 if (arg == F_UNLCK)
1792 return vfs_setlease(filp, F_UNLCK, NULL); 1800 return vfs_setlease(filp, F_UNLCK, NULL, NULL);
1793 return do_fcntl_add_lease(fd, filp, arg); 1801 return do_fcntl_add_lease(fd, filp, arg);
1794} 1802}
1795 1803