diff options
-rw-r--r-- | fs/locks.c | 24 | ||||
-rw-r--r-- | include/linux/fs.h | 1 |
2 files changed, 23 insertions, 2 deletions
diff --git a/fs/locks.c b/fs/locks.c index a65d85c1fdc2..94f5d8065e3a 100644 --- a/fs/locks.c +++ b/fs/locks.c | |||
@@ -1429,7 +1429,24 @@ out: | |||
1429 | * @lease: file_lock to use | 1429 | * @lease: file_lock to use |
1430 | * | 1430 | * |
1431 | * Call this to establish a lease on the file. | 1431 | * Call this to establish a lease on the file. |
1432 | * The fl_lmops fl_break function is required by break_lease | 1432 | * The (*lease)->fl_lmops->fl_break operation must be set; if not, |
1433 | * break_lease will oops! | ||
1434 | * | ||
1435 | * This will call the filesystem's setlease file method, if | ||
1436 | * defined. Note that there is no getlease method; instead, the | ||
1437 | * filesystem setlease method should call back to setlease() to | ||
1438 | * add a lease to the inode's lease list, where fcntl_getlease() can | ||
1439 | * find it. Since fcntl_getlease() only reports whether the current | ||
1440 | * task holds a lease, a cluster filesystem need only do this for | ||
1441 | * leases held by processes on this node. | ||
1442 | * | ||
1443 | * There is also no break_lease method; filesystems that | ||
1444 | * handle their own leases shoud break leases themselves from the | ||
1445 | * filesystem's open, create, and (on truncate) setattr methods. | ||
1446 | * | ||
1447 | * Warning: the only current setlease methods exist only to disable | ||
1448 | * leases in certain cases. More vfs changes may be required to | ||
1449 | * allow a full filesystem lease implementation. | ||
1433 | */ | 1450 | */ |
1434 | 1451 | ||
1435 | int vfs_setlease(struct file *filp, long arg, struct file_lock **lease) | 1452 | int vfs_setlease(struct file *filp, long arg, struct file_lock **lease) |
@@ -1437,7 +1454,10 @@ int vfs_setlease(struct file *filp, long arg, struct file_lock **lease) | |||
1437 | int error; | 1454 | int error; |
1438 | 1455 | ||
1439 | lock_kernel(); | 1456 | lock_kernel(); |
1440 | error = setlease(filp, arg, lease); | 1457 | if (filp->f_op && filp->f_op->setlease) |
1458 | error = filp->f_op->setlease(filp, arg, lease); | ||
1459 | else | ||
1460 | error = setlease(filp, arg, lease); | ||
1441 | unlock_kernel(); | 1461 | unlock_kernel(); |
1442 | 1462 | ||
1443 | return error; | 1463 | return error; |
diff --git a/include/linux/fs.h b/include/linux/fs.h index a24f029accc0..c8ddf34e9710 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h | |||
@@ -1122,6 +1122,7 @@ struct file_operations { | |||
1122 | int (*flock) (struct file *, int, struct file_lock *); | 1122 | int (*flock) (struct file *, int, struct file_lock *); |
1123 | ssize_t (*splice_write)(struct pipe_inode_info *, struct file *, loff_t *, size_t, unsigned int); | 1123 | ssize_t (*splice_write)(struct pipe_inode_info *, struct file *, loff_t *, size_t, unsigned int); |
1124 | ssize_t (*splice_read)(struct file *, loff_t *, struct pipe_inode_info *, size_t, unsigned int); | 1124 | ssize_t (*splice_read)(struct file *, loff_t *, struct pipe_inode_info *, size_t, unsigned int); |
1125 | int (*setlease)(struct file *, long, struct file_lock **); | ||
1125 | }; | 1126 | }; |
1126 | 1127 | ||
1127 | struct inode_operations { | 1128 | struct inode_operations { |