locks: implement delegations

Implement NFSv4 delegations at the vfs level using the new FL_DELEG lock
type.

Note nfsd is the only delegation user and is only using read
delegations.  Warn on any attempt to set a write delegation for now.
We'll come back to that case later.

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>
This commit is contained in:
J. Bruce Fields 2012-03-05 13:18:59 -05:00 committed by Al Viro
parent 617588d518
commit df4e8d2c1d
2 changed files with 60 additions and 13 deletions

View file

@ -1022,7 +1022,7 @@ extern int vfs_test_lock(struct file *, struct file_lock *);
extern int vfs_lock_file(struct file *, unsigned int, struct file_lock *, struct file_lock *);
extern int vfs_cancel_lock(struct file *filp, struct file_lock *fl);
extern int flock_lock_file_wait(struct file *filp, struct file_lock *fl);
extern int __break_lease(struct inode *inode, unsigned int flags);
extern int __break_lease(struct inode *inode, unsigned int flags, unsigned int type);
extern void lease_get_mtime(struct inode *, struct timespec *time);
extern int generic_setlease(struct file *, long, struct file_lock **);
extern int vfs_setlease(struct file *, long, struct file_lock **);
@ -1131,7 +1131,7 @@ static inline int flock_lock_file_wait(struct file *filp,
return -ENOLCK;
}
static inline int __break_lease(struct inode *inode, unsigned int mode)
static inline int __break_lease(struct inode *inode, unsigned int mode, unsigned int type)
{
return 0;
}
@ -1961,9 +1961,17 @@ static inline int locks_verify_truncate(struct inode *inode,
static inline int break_lease(struct inode *inode, unsigned int mode)
{
if (inode->i_flock)
return __break_lease(inode, mode);
return __break_lease(inode, mode, FL_LEASE);
return 0;
}
static inline int break_deleg(struct inode *inode, unsigned int mode)
{
if (inode->i_flock)
return __break_lease(inode, mode, FL_DELEG);
return 0;
}
#else /* !CONFIG_FILE_LOCKING */
static inline int locks_mandatory_locked(struct inode *inode)
{
@ -2003,6 +2011,10 @@ static inline int break_lease(struct inode *inode, unsigned int mode)
return 0;
}
static inline int break_deleg(struct inode *inode, unsigned int mode)
{
return 0;
}
#endif /* CONFIG_FILE_LOCKING */
/* fs/open.c */