diff options
author | J. Bruce Fields <bfields@redhat.com> | 2012-08-28 10:50:40 -0400 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2013-11-09 00:16:42 -0500 |
commit | 5a14696c1795d3843673b5cf1982d0e5357a5bbf (patch) | |
tree | 8d0ec4f82f90fc5f3e50cfc8cdd78ee7a4fb2263 /include/linux/fs.h | |
parent | b21996e36c8e3b92a84e972378bde80b43acd890 (diff) |
locks: helper functions for delegation breaking
We'll need the same logic for rename and link.
Acked-by: Jeff Layton <jlayton@redhat.com>
Signed-off-by: J. Bruce Fields <bfields@redhat.com>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'include/linux/fs.h')
-rw-r--r-- | include/linux/fs.h | 39 |
1 files changed, 37 insertions, 2 deletions
diff --git a/include/linux/fs.h b/include/linux/fs.h index a5799233142a..931f919f44e1 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h | |||
@@ -1905,6 +1905,9 @@ extern bool fs_fully_visible(struct file_system_type *); | |||
1905 | 1905 | ||
1906 | extern int current_umask(void); | 1906 | extern int current_umask(void); |
1907 | 1907 | ||
1908 | extern void ihold(struct inode * inode); | ||
1909 | extern void iput(struct inode *); | ||
1910 | |||
1908 | /* /sys/fs */ | 1911 | /* /sys/fs */ |
1909 | extern struct kobject *fs_kobj; | 1912 | extern struct kobject *fs_kobj; |
1910 | 1913 | ||
@@ -1972,6 +1975,28 @@ static inline int break_deleg(struct inode *inode, unsigned int mode) | |||
1972 | return 0; | 1975 | return 0; |
1973 | } | 1976 | } |
1974 | 1977 | ||
1978 | static inline int try_break_deleg(struct inode *inode, struct inode **delegated_inode) | ||
1979 | { | ||
1980 | int ret; | ||
1981 | |||
1982 | ret = break_deleg(inode, O_WRONLY|O_NONBLOCK); | ||
1983 | if (ret == -EWOULDBLOCK && delegated_inode) { | ||
1984 | *delegated_inode = inode; | ||
1985 | ihold(inode); | ||
1986 | } | ||
1987 | return ret; | ||
1988 | } | ||
1989 | |||
1990 | static inline int break_deleg_wait(struct inode **delegated_inode) | ||
1991 | { | ||
1992 | int ret; | ||
1993 | |||
1994 | ret = break_deleg(*delegated_inode, O_WRONLY); | ||
1995 | iput(*delegated_inode); | ||
1996 | *delegated_inode = NULL; | ||
1997 | return ret; | ||
1998 | } | ||
1999 | |||
1975 | #else /* !CONFIG_FILE_LOCKING */ | 2000 | #else /* !CONFIG_FILE_LOCKING */ |
1976 | static inline int locks_mandatory_locked(struct inode *inode) | 2001 | static inline int locks_mandatory_locked(struct inode *inode) |
1977 | { | 2002 | { |
@@ -2015,6 +2040,18 @@ static inline int break_deleg(struct inode *inode, unsigned int mode) | |||
2015 | { | 2040 | { |
2016 | return 0; | 2041 | return 0; |
2017 | } | 2042 | } |
2043 | |||
2044 | static inline int try_break_deleg(struct inode *inode, struct inode **delegated_inode) | ||
2045 | { | ||
2046 | return 0; | ||
2047 | } | ||
2048 | |||
2049 | static inline int break_deleg_wait(struct inode **delegated_inode) | ||
2050 | { | ||
2051 | BUG(); | ||
2052 | return 0; | ||
2053 | } | ||
2054 | |||
2018 | #endif /* CONFIG_FILE_LOCKING */ | 2055 | #endif /* CONFIG_FILE_LOCKING */ |
2019 | 2056 | ||
2020 | /* fs/open.c */ | 2057 | /* fs/open.c */ |
@@ -2350,8 +2387,6 @@ extern loff_t vfs_llseek(struct file *file, loff_t offset, int whence); | |||
2350 | extern int inode_init_always(struct super_block *, struct inode *); | 2387 | extern int inode_init_always(struct super_block *, struct inode *); |
2351 | extern void inode_init_once(struct inode *); | 2388 | extern void inode_init_once(struct inode *); |
2352 | extern void address_space_init_once(struct address_space *mapping); | 2389 | extern void address_space_init_once(struct address_space *mapping); |
2353 | extern void ihold(struct inode * inode); | ||
2354 | extern void iput(struct inode *); | ||
2355 | extern struct inode * igrab(struct inode *); | 2390 | extern struct inode * igrab(struct inode *); |
2356 | extern ino_t iunique(struct super_block *, ino_t); | 2391 | extern ino_t iunique(struct super_block *, ino_t); |
2357 | extern int inode_needs_sync(struct inode *inode); | 2392 | extern int inode_needs_sync(struct inode *inode); |