aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@lst.de>2015-01-21 13:17:03 -0500
committerChristoph Hellwig <hch@lst.de>2015-02-02 12:09:38 -0500
commit11afe9f76e121e960445deee5b7f26f0787a1990 (patch)
tree512e3b9dd23b394b826a18eca3947df9487c28bc /include/linux
parent2ab99ee12440e66ec1efd2a98599010471de785e (diff)
fs: add FL_LAYOUT lease type
This (ab-)uses the file locking code to allow filesystems to recall outstanding pNFS layouts on a file. This new lease type is similar but not quite the same as FL_DELEG. A FL_LAYOUT lease can always be granted, an a per-filesystem lock (XFS iolock for the initial implementation) ensures not FL_LAYOUT leases granted when we would need to recall them. Also included are changes that allow multiple outstanding read leases of different types on the same file as long as they have a differnt owner. This wasn't a problem until now as nfsd never set FL_LEASE leases, and no one else used FL_DELEG leases, but given that nfsd will also issues FL_LAYOUT leases we will have to handle it now. Signed-off-by: Christoph Hellwig <hch@lst.de>
Diffstat (limited to 'include/linux')
-rw-r--r--include/linux/fs.h16
1 files changed, 16 insertions, 0 deletions
diff --git a/include/linux/fs.h b/include/linux/fs.h
index ddd2fa7cefd3..84740145f835 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -875,6 +875,7 @@ static inline struct file *get_file(struct file *f)
875#define FL_DOWNGRADE_PENDING 256 /* Lease is being downgraded */ 875#define FL_DOWNGRADE_PENDING 256 /* Lease is being downgraded */
876#define FL_UNLOCK_PENDING 512 /* Lease is being broken */ 876#define FL_UNLOCK_PENDING 512 /* Lease is being broken */
877#define FL_OFDLCK 1024 /* lock is "owned" by struct file */ 877#define FL_OFDLCK 1024 /* lock is "owned" by struct file */
878#define FL_LAYOUT 2048 /* outstanding pNFS layout */
878 879
879/* 880/*
880 * Special return value from posix_lock_file() and vfs_lock_file() for 881 * Special return value from posix_lock_file() and vfs_lock_file() for
@@ -2037,6 +2038,16 @@ static inline int break_deleg_wait(struct inode **delegated_inode)
2037 return ret; 2038 return ret;
2038} 2039}
2039 2040
2041static inline int break_layout(struct inode *inode, bool wait)
2042{
2043 smp_mb();
2044 if (inode->i_flctx && !list_empty_careful(&inode->i_flctx->flc_lease))
2045 return __break_lease(inode,
2046 wait ? O_WRONLY : O_WRONLY | O_NONBLOCK,
2047 FL_LAYOUT);
2048 return 0;
2049}
2050
2040#else /* !CONFIG_FILE_LOCKING */ 2051#else /* !CONFIG_FILE_LOCKING */
2041static inline int locks_mandatory_locked(struct file *file) 2052static inline int locks_mandatory_locked(struct file *file)
2042{ 2053{
@@ -2092,6 +2103,11 @@ static inline int break_deleg_wait(struct inode **delegated_inode)
2092 return 0; 2103 return 0;
2093} 2104}
2094 2105
2106static inline int break_layout(struct inode *inode, bool wait)
2107{
2108 return 0;
2109}
2110
2095#endif /* CONFIG_FILE_LOCKING */ 2111#endif /* CONFIG_FILE_LOCKING */
2096 2112
2097/* fs/open.c */ 2113/* fs/open.c */