diff options
| -rw-r--r-- | fs/locks.c | 43 |
1 files changed, 30 insertions, 13 deletions
diff --git a/fs/locks.c b/fs/locks.c index 50ec15927aab..06c77734f589 100644 --- a/fs/locks.c +++ b/fs/locks.c | |||
| @@ -1441,7 +1441,8 @@ int generic_setlease(struct file *filp, long arg, struct file_lock **flp) | |||
| 1441 | return 0; | 1441 | return 0; |
| 1442 | 1442 | ||
| 1443 | out: | 1443 | out: |
| 1444 | locks_free_lock(lease); | 1444 | if (arg != F_UNLCK) |
| 1445 | locks_free_lock(lease); | ||
| 1445 | return error; | 1446 | return error; |
| 1446 | } | 1447 | } |
| 1447 | EXPORT_SYMBOL(generic_setlease); | 1448 | EXPORT_SYMBOL(generic_setlease); |
| @@ -1493,17 +1494,16 @@ int vfs_setlease(struct file *filp, long arg, struct file_lock **lease) | |||
| 1493 | } | 1494 | } |
| 1494 | EXPORT_SYMBOL_GPL(vfs_setlease); | 1495 | EXPORT_SYMBOL_GPL(vfs_setlease); |
| 1495 | 1496 | ||
| 1496 | /** | 1497 | static int do_fcntl_delete_lease(struct file *filp) |
| 1497 | * fcntl_setlease - sets a lease on an open file | 1498 | { |
| 1498 | * @fd: open file descriptor | 1499 | struct file_lock fl, *flp = &fl; |
| 1499 | * @filp: file pointer | 1500 | |
| 1500 | * @arg: type of lease to obtain | 1501 | lease_init(filp, F_UNLCK, flp); |
| 1501 | * | 1502 | |
| 1502 | * Call this fcntl to establish a lease on the file. | 1503 | return vfs_setlease(filp, F_UNLCK, &flp); |
| 1503 | * Note that you also need to call %F_SETSIG to | 1504 | } |
| 1504 | * receive a signal when the lease is broken. | 1505 | |
| 1505 | */ | 1506 | static int do_fcntl_add_lease(unsigned int fd, struct file *filp, long arg) |
| 1506 | int fcntl_setlease(unsigned int fd, struct file *filp, long arg) | ||
| 1507 | { | 1507 | { |
| 1508 | struct file_lock *fl; | 1508 | struct file_lock *fl; |
| 1509 | struct fasync_struct *new; | 1509 | struct fasync_struct *new; |
| @@ -1521,7 +1521,7 @@ int fcntl_setlease(unsigned int fd, struct file *filp, long arg) | |||
| 1521 | } | 1521 | } |
| 1522 | lock_flocks(); | 1522 | lock_flocks(); |
| 1523 | error = __vfs_setlease(filp, arg, &fl); | 1523 | error = __vfs_setlease(filp, arg, &fl); |
| 1524 | if (error || arg == F_UNLCK) | 1524 | if (error) |
| 1525 | goto out_unlock; | 1525 | goto out_unlock; |
| 1526 | 1526 | ||
| 1527 | /* | 1527 | /* |
| @@ -1550,6 +1550,23 @@ out_unlock: | |||
| 1550 | } | 1550 | } |
| 1551 | 1551 | ||
| 1552 | /** | 1552 | /** |
| 1553 | * fcntl_setlease - sets a lease on an open file | ||
| 1554 | * @fd: open file descriptor | ||
| 1555 | * @filp: file pointer | ||
| 1556 | * @arg: type of lease to obtain | ||
| 1557 | * | ||
| 1558 | * Call this fcntl to establish a lease on the file. | ||
| 1559 | * Note that you also need to call %F_SETSIG to | ||
| 1560 | * receive a signal when the lease is broken. | ||
| 1561 | */ | ||
| 1562 | int fcntl_setlease(unsigned int fd, struct file *filp, long arg) | ||
| 1563 | { | ||
| 1564 | if (arg == F_UNLCK) | ||
| 1565 | return do_fcntl_delete_lease(filp); | ||
| 1566 | return do_fcntl_add_lease(fd, filp, arg); | ||
| 1567 | } | ||
| 1568 | |||
| 1569 | /** | ||
| 1553 | * flock_lock_file_wait - Apply a FLOCK-style lock to a file | 1570 | * flock_lock_file_wait - Apply a FLOCK-style lock to a file |
| 1554 | * @filp: The file to apply the lock to | 1571 | * @filp: The file to apply the lock to |
| 1555 | * @fl: The lock to be applied | 1572 | * @fl: The lock to be applied |
