Commit f9ffed26 authored by J. Bruce Fields's avatar J. Bruce Fields Committed by J. Bruce Fields

locks: provide a file lease method enabling cluster-coherent leases

Currently leases are only kept locally, so there's no way for a distributed
filesystem to enforce them against multiple clients.  We're particularly
interested in the case of nfsd exporting a cluster filesystem, in which
case nfsd needs cluster-coherent leases in order to implement delegations
correctly.

Also add some documentation.
Signed-off-by: default avatarJ. Bruce Fields <bfields@citi.umich.edu>
parent a9933cea
...@@ -1429,7 +1429,24 @@ static int setlease(struct file *filp, long arg, struct file_lock **flp) ...@@ -1429,7 +1429,24 @@ static int setlease(struct file *filp, long arg, struct file_lock **flp)
* @lease: file_lock to use * @lease: file_lock to use
* *
* Call this to establish a lease on the file. * Call this to establish a lease on the file.
* The fl_lmops fl_break function is required by break_lease * The (*lease)->fl_lmops->fl_break operation must be set; if not,
* break_lease will oops!
*
* This will call the filesystem's setlease file method, if
* defined. Note that there is no getlease method; instead, the
* filesystem setlease method should call back to setlease() to
* add a lease to the inode's lease list, where fcntl_getlease() can
* find it. Since fcntl_getlease() only reports whether the current
* task holds a lease, a cluster filesystem need only do this for
* leases held by processes on this node.
*
* There is also no break_lease method; filesystems that
* handle their own leases shoud break leases themselves from the
* filesystem's open, create, and (on truncate) setattr methods.
*
* Warning: the only current setlease methods exist only to disable
* leases in certain cases. More vfs changes may be required to
* allow a full filesystem lease implementation.
*/ */
int vfs_setlease(struct file *filp, long arg, struct file_lock **lease) int vfs_setlease(struct file *filp, long arg, struct file_lock **lease)
...@@ -1437,6 +1454,9 @@ int vfs_setlease(struct file *filp, long arg, struct file_lock **lease) ...@@ -1437,6 +1454,9 @@ int vfs_setlease(struct file *filp, long arg, struct file_lock **lease)
int error; int error;
lock_kernel(); lock_kernel();
if (filp->f_op && filp->f_op->setlease)
error = filp->f_op->setlease(filp, arg, lease);
else
error = setlease(filp, arg, lease); error = setlease(filp, arg, lease);
unlock_kernel(); unlock_kernel();
......
...@@ -1122,6 +1122,7 @@ struct file_operations { ...@@ -1122,6 +1122,7 @@ struct file_operations {
int (*flock) (struct file *, int, struct file_lock *); int (*flock) (struct file *, int, struct file_lock *);
ssize_t (*splice_write)(struct pipe_inode_info *, struct file *, loff_t *, size_t, unsigned int); ssize_t (*splice_write)(struct pipe_inode_info *, struct file *, loff_t *, size_t, unsigned int);
ssize_t (*splice_read)(struct file *, loff_t *, struct pipe_inode_info *, size_t, unsigned int); ssize_t (*splice_read)(struct file *, loff_t *, struct pipe_inode_info *, size_t, unsigned int);
int (*setlease)(struct file *, long, struct file_lock **);
}; };
struct inode_operations { struct inode_operations {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment