diff options
author | Jeff Layton <jlayton@primarydata.com> | 2014-08-22 10:40:25 -0400 |
---|---|---|
committer | Jeff Layton <jlayton@primarydata.com> | 2014-10-07 14:06:12 -0400 |
commit | e6f5c78930e409f3a6b37f5484313a416359ac7f (patch) | |
tree | e5465ac34a9251be44276f135c8a4f0a5ba4d42e | |
parent | 0c637be884f5eaa0ee53396ea7686ec0de03d126 (diff) |
locks: plumb a "priv" pointer into the setlease routines
In later patches, we're going to add a new lock_manager_operation to
finish setting up the lease while still holding the i_lock. To do
this, we'll need to pass a little bit of info in the fcntl setlease
case (primarily an fasync structure). Plumb the extra pointer into
there in advance of that.
We declare this pointer as a void ** to make it clear that this is
private info, and that the caller isn't required to set this unless
the lm_setup specifically requires it.
Signed-off-by: Jeff Layton <jlayton@primarydata.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
-rw-r--r-- | Documentation/filesystems/Locking | 2 | ||||
-rw-r--r-- | Documentation/filesystems/vfs.txt | 2 | ||||
-rw-r--r-- | fs/cifs/cifsfs.c | 7 | ||||
-rw-r--r-- | fs/libfs.c | 4 | ||||
-rw-r--r-- | fs/locks.c | 32 | ||||
-rw-r--r-- | fs/nfsd/nfs4state.c | 4 | ||||
-rw-r--r-- | include/linux/fs.h | 12 |
7 files changed, 37 insertions, 26 deletions
diff --git a/Documentation/filesystems/Locking b/Documentation/filesystems/Locking index f1997e9da61f..3d92049ae71d 100644 --- a/Documentation/filesystems/Locking +++ b/Documentation/filesystems/Locking | |||
@@ -464,7 +464,7 @@ prototypes: | |||
464 | size_t, unsigned int); | 464 | size_t, unsigned int); |
465 | ssize_t (*splice_read)(struct file *, loff_t *, struct pipe_inode_info *, | 465 | ssize_t (*splice_read)(struct file *, loff_t *, struct pipe_inode_info *, |
466 | size_t, unsigned int); | 466 | size_t, unsigned int); |
467 | int (*setlease)(struct file *, long, struct file_lock **); | 467 | int (*setlease)(struct file *, long, struct file_lock **, void **); |
468 | long (*fallocate)(struct file *, int, loff_t, loff_t); | 468 | long (*fallocate)(struct file *, int, loff_t, loff_t); |
469 | }; | 469 | }; |
470 | 470 | ||
diff --git a/Documentation/filesystems/vfs.txt b/Documentation/filesystems/vfs.txt index 61d65cc65c54..28ebd49f169f 100644 --- a/Documentation/filesystems/vfs.txt +++ b/Documentation/filesystems/vfs.txt | |||
@@ -826,7 +826,7 @@ struct file_operations { | |||
826 | int (*flock) (struct file *, int, struct file_lock *); | 826 | int (*flock) (struct file *, int, struct file_lock *); |
827 | ssize_t (*splice_write)(struct pipe_inode_info *, struct file *, size_t, unsigned int); | 827 | ssize_t (*splice_write)(struct pipe_inode_info *, struct file *, size_t, unsigned int); |
828 | ssize_t (*splice_read)(struct file *, struct pipe_inode_info *, size_t, unsigned int); | 828 | ssize_t (*splice_read)(struct file *, struct pipe_inode_info *, size_t, unsigned int); |
829 | int (*setlease)(struct file *, long arg, struct file_lock **); | 829 | int (*setlease)(struct file *, long arg, struct file_lock **, void **); |
830 | long (*fallocate)(struct file *, int mode, loff_t offset, loff_t len); | 830 | long (*fallocate)(struct file *, int mode, loff_t offset, loff_t len); |
831 | int (*show_fdinfo)(struct seq_file *m, struct file *f); | 831 | int (*show_fdinfo)(struct seq_file *m, struct file *f); |
832 | }; | 832 | }; |
diff --git a/fs/cifs/cifsfs.c b/fs/cifs/cifsfs.c index ac4f260155c8..85c70d5969ac 100644 --- a/fs/cifs/cifsfs.c +++ b/fs/cifs/cifsfs.c | |||
@@ -800,7 +800,8 @@ static loff_t cifs_llseek(struct file *file, loff_t offset, int whence) | |||
800 | return generic_file_llseek(file, offset, whence); | 800 | return generic_file_llseek(file, offset, whence); |
801 | } | 801 | } |
802 | 802 | ||
803 | static int cifs_setlease(struct file *file, long arg, struct file_lock **lease) | 803 | static int |
804 | cifs_setlease(struct file *file, long arg, struct file_lock **lease, void **priv) | ||
804 | { | 805 | { |
805 | /* | 806 | /* |
806 | * Note that this is called by vfs setlease with i_lock held to | 807 | * Note that this is called by vfs setlease with i_lock held to |
@@ -815,7 +816,7 @@ static int cifs_setlease(struct file *file, long arg, struct file_lock **lease) | |||
815 | /* check if file is oplocked */ | 816 | /* check if file is oplocked */ |
816 | if (((arg == F_RDLCK) && CIFS_CACHE_READ(CIFS_I(inode))) || | 817 | if (((arg == F_RDLCK) && CIFS_CACHE_READ(CIFS_I(inode))) || |
817 | ((arg == F_WRLCK) && CIFS_CACHE_WRITE(CIFS_I(inode)))) | 818 | ((arg == F_WRLCK) && CIFS_CACHE_WRITE(CIFS_I(inode)))) |
818 | return generic_setlease(file, arg, lease); | 819 | return generic_setlease(file, arg, lease, priv); |
819 | else if (tlink_tcon(cfile->tlink)->local_lease && | 820 | else if (tlink_tcon(cfile->tlink)->local_lease && |
820 | !CIFS_CACHE_READ(CIFS_I(inode))) | 821 | !CIFS_CACHE_READ(CIFS_I(inode))) |
821 | /* | 822 | /* |
@@ -826,7 +827,7 @@ static int cifs_setlease(struct file *file, long arg, struct file_lock **lease) | |||
826 | * knows that the file won't be changed on the server by anyone | 827 | * knows that the file won't be changed on the server by anyone |
827 | * else. | 828 | * else. |
828 | */ | 829 | */ |
829 | return generic_setlease(file, arg, lease); | 830 | return generic_setlease(file, arg, lease, priv); |
830 | else | 831 | else |
831 | return -EAGAIN; | 832 | return -EAGAIN; |
832 | } | 833 | } |
diff --git a/fs/libfs.c b/fs/libfs.c index 29012a303ef8..171d2846f2a3 100644 --- a/fs/libfs.c +++ b/fs/libfs.c | |||
@@ -1081,12 +1081,14 @@ EXPORT_SYMBOL(alloc_anon_inode); | |||
1081 | * @filp: file pointer | 1081 | * @filp: file pointer |
1082 | * @arg: type of lease to obtain | 1082 | * @arg: type of lease to obtain |
1083 | * @flp: new lease supplied for insertion | 1083 | * @flp: new lease supplied for insertion |
1084 | * @priv: private data for lm_setup operation | ||
1084 | * | 1085 | * |
1085 | * Generic helper for filesystems that do not wish to allow leases to be set. | 1086 | * Generic helper for filesystems that do not wish to allow leases to be set. |
1086 | * All arguments are ignored and it just returns -EINVAL. | 1087 | * All arguments are ignored and it just returns -EINVAL. |
1087 | */ | 1088 | */ |
1088 | int | 1089 | int |
1089 | simple_nosetlease(struct file *filp, long arg, struct file_lock **flp) | 1090 | simple_nosetlease(struct file *filp, long arg, struct file_lock **flp, |
1091 | void **priv) | ||
1090 | { | 1092 | { |
1091 | return -EINVAL; | 1093 | return -EINVAL; |
1092 | } | 1094 | } |
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 | |||
1301 | EXPORT_SYMBOL(lease_modify); | 1300 | EXPORT_SYMBOL(lease_modify); |
1302 | 1301 | ||
1303 | static bool past_time(unsigned long then) | 1302 | static 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 | ||
1546 | static int generic_add_lease(struct file *filp, long arg, struct file_lock **flp) | 1545 | static int |
1546 | generic_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; |
1634 | out: | 1634 | out: |
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; |
1638 | out_unlink: | ||
1639 | locks_unlink_lock(before); | ||
1640 | goto out; | ||
1638 | } | 1641 | } |
1639 | 1642 | ||
1640 | static int generic_delete_lease(struct file *filp) | 1643 | static 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 | */ |
1670 | int generic_setlease(struct file *filp, long arg, struct file_lock **flp) | 1674 | int 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 | } |
1700 | EXPORT_SYMBOL(generic_setlease); | 1705 | EXPORT_SYMBOL(generic_setlease); |
1701 | 1706 | ||
1702 | static int __vfs_setlease(struct file *filp, long arg, struct file_lock **lease) | 1707 | static 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 | ||
1723 | int vfs_setlease(struct file *filp, long arg, struct file_lock **lease) | 1730 | int |
1731 | vfs_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: | |||
1789 | int fcntl_setlease(unsigned int fd, struct file *filp, long arg) | 1797 | int 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 | ||
diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c index 188cd68aefb6..7c803db2a027 100644 --- a/fs/nfsd/nfs4state.c +++ b/fs/nfsd/nfs4state.c | |||
@@ -686,7 +686,7 @@ static void nfs4_put_deleg_lease(struct nfs4_file *fp) | |||
686 | spin_unlock(&fp->fi_lock); | 686 | spin_unlock(&fp->fi_lock); |
687 | 687 | ||
688 | if (filp) { | 688 | if (filp) { |
689 | vfs_setlease(filp, F_UNLCK, NULL); | 689 | vfs_setlease(filp, F_UNLCK, NULL, NULL); |
690 | fput(filp); | 690 | fput(filp); |
691 | } | 691 | } |
692 | } | 692 | } |
@@ -3792,7 +3792,7 @@ static int nfs4_setlease(struct nfs4_delegation *dp) | |||
3792 | } | 3792 | } |
3793 | fl->fl_file = filp; | 3793 | fl->fl_file = filp; |
3794 | ret = fl; | 3794 | ret = fl; |
3795 | status = vfs_setlease(filp, fl->fl_type, &ret); | 3795 | status = vfs_setlease(filp, fl->fl_type, &fl, NULL); |
3796 | if (status) { | 3796 | if (status) { |
3797 | locks_free_lock(fl); | 3797 | locks_free_lock(fl); |
3798 | goto out_fput; | 3798 | goto out_fput; |
diff --git a/include/linux/fs.h b/include/linux/fs.h index 96528f73dda4..f1870eb67b02 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h | |||
@@ -982,8 +982,8 @@ extern int vfs_cancel_lock(struct file *filp, struct file_lock *fl); | |||
982 | extern int flock_lock_file_wait(struct file *filp, struct file_lock *fl); | 982 | extern int flock_lock_file_wait(struct file *filp, struct file_lock *fl); |
983 | extern int __break_lease(struct inode *inode, unsigned int flags, unsigned int type); | 983 | extern int __break_lease(struct inode *inode, unsigned int flags, unsigned int type); |
984 | extern void lease_get_mtime(struct inode *, struct timespec *time); | 984 | extern void lease_get_mtime(struct inode *, struct timespec *time); |
985 | extern int generic_setlease(struct file *, long, struct file_lock **); | 985 | extern int generic_setlease(struct file *, long, struct file_lock **, void **priv); |
986 | extern int vfs_setlease(struct file *, long, struct file_lock **); | 986 | extern int vfs_setlease(struct file *, long, struct file_lock **, void **); |
987 | extern int lease_modify(struct file_lock **, int); | 987 | extern int lease_modify(struct file_lock **, int); |
988 | #else /* !CONFIG_FILE_LOCKING */ | 988 | #else /* !CONFIG_FILE_LOCKING */ |
989 | static inline int fcntl_getlk(struct file *file, unsigned int cmd, | 989 | static inline int fcntl_getlk(struct file *file, unsigned int cmd, |
@@ -1100,13 +1100,13 @@ static inline void lease_get_mtime(struct inode *inode, struct timespec *time) | |||
1100 | } | 1100 | } |
1101 | 1101 | ||
1102 | static inline int generic_setlease(struct file *filp, long arg, | 1102 | static inline int generic_setlease(struct file *filp, long arg, |
1103 | struct file_lock **flp) | 1103 | struct file_lock **flp, void **priv) |
1104 | { | 1104 | { |
1105 | return -EINVAL; | 1105 | return -EINVAL; |
1106 | } | 1106 | } |
1107 | 1107 | ||
1108 | static inline int vfs_setlease(struct file *filp, long arg, | 1108 | static inline int vfs_setlease(struct file *filp, long arg, |
1109 | struct file_lock **lease) | 1109 | struct file_lock **lease, void **priv) |
1110 | { | 1110 | { |
1111 | return -EINVAL; | 1111 | return -EINVAL; |
1112 | } | 1112 | } |
@@ -1494,7 +1494,7 @@ struct file_operations { | |||
1494 | int (*flock) (struct file *, int, struct file_lock *); | 1494 | int (*flock) (struct file *, int, struct file_lock *); |
1495 | ssize_t (*splice_write)(struct pipe_inode_info *, struct file *, loff_t *, size_t, unsigned int); | 1495 | ssize_t (*splice_write)(struct pipe_inode_info *, struct file *, loff_t *, size_t, unsigned int); |
1496 | ssize_t (*splice_read)(struct file *, loff_t *, struct pipe_inode_info *, size_t, unsigned int); | 1496 | ssize_t (*splice_read)(struct file *, loff_t *, struct pipe_inode_info *, size_t, unsigned int); |
1497 | int (*setlease)(struct file *, long, struct file_lock **); | 1497 | int (*setlease)(struct file *, long, struct file_lock **, void **); |
1498 | long (*fallocate)(struct file *file, int mode, loff_t offset, | 1498 | long (*fallocate)(struct file *file, int mode, loff_t offset, |
1499 | loff_t len); | 1499 | loff_t len); |
1500 | int (*show_fdinfo)(struct seq_file *m, struct file *f); | 1500 | int (*show_fdinfo)(struct seq_file *m, struct file *f); |
@@ -2599,7 +2599,7 @@ extern int simple_write_end(struct file *file, struct address_space *mapping, | |||
2599 | struct page *page, void *fsdata); | 2599 | struct page *page, void *fsdata); |
2600 | extern int always_delete_dentry(const struct dentry *); | 2600 | extern int always_delete_dentry(const struct dentry *); |
2601 | extern struct inode *alloc_anon_inode(struct super_block *); | 2601 | extern struct inode *alloc_anon_inode(struct super_block *); |
2602 | extern int simple_nosetlease(struct file *, long, struct file_lock **); | 2602 | extern int simple_nosetlease(struct file *, long, struct file_lock **, void **); |
2603 | extern const struct dentry_operations simple_dentry_operations; | 2603 | extern const struct dentry_operations simple_dentry_operations; |
2604 | 2604 | ||
2605 | extern struct dentry *simple_lookup(struct inode *, struct dentry *, unsigned int flags); | 2605 | extern struct dentry *simple_lookup(struct inode *, struct dentry *, unsigned int flags); |