diff options
author | Trond Myklebust <Trond.Myklebust@netapp.com> | 2006-06-29 16:38:32 -0400 |
---|---|---|
committer | Trond Myklebust <Trond.Myklebust@netapp.com> | 2006-07-05 13:13:17 -0400 |
commit | f475ae957db66650db66916c62604ac27409d884 (patch) | |
tree | 3b9c40dd20f1b7f3fcc59035941c4a084ce71a19 /fs/locks.c | |
parent | 5e66dd6d66ffe758b39b6dcadf2330753ee1159b (diff) |
VFS: Allow caller to determine if BSD or posix locks were actually freed
Change posix_lock_file_conf(), and flock_lock_file() so that if called
with an F_UNLCK argument, and the FL_EXISTS flag they will indicate
whether or not any locks were actually freed by returning 0 or -ENOENT.
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
Diffstat (limited to 'fs/locks.c')
-rw-r--r-- | fs/locks.c | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/fs/locks.c b/fs/locks.c index 1ad29c9b6252..50cb0a2b74d9 100644 --- a/fs/locks.c +++ b/fs/locks.c | |||
@@ -725,6 +725,10 @@ next_task: | |||
725 | /* Try to create a FLOCK lock on filp. We always insert new FLOCK locks | 725 | /* Try to create a FLOCK lock on filp. We always insert new FLOCK locks |
726 | * at the head of the list, but that's secret knowledge known only to | 726 | * at the head of the list, but that's secret knowledge known only to |
727 | * flock_lock_file and posix_lock_file. | 727 | * flock_lock_file and posix_lock_file. |
728 | * | ||
729 | * Note that if called with an FL_EXISTS argument, the caller may determine | ||
730 | * whether or not a lock was successfully freed by testing the return | ||
731 | * value for -ENOENT. | ||
728 | */ | 732 | */ |
729 | static int flock_lock_file(struct file *filp, struct file_lock *request) | 733 | static int flock_lock_file(struct file *filp, struct file_lock *request) |
730 | { | 734 | { |
@@ -750,8 +754,11 @@ static int flock_lock_file(struct file *filp, struct file_lock *request) | |||
750 | break; | 754 | break; |
751 | } | 755 | } |
752 | 756 | ||
753 | if (request->fl_type == F_UNLCK) | 757 | if (request->fl_type == F_UNLCK) { |
758 | if ((request->fl_flags & FL_EXISTS) && !found) | ||
759 | error = -ENOENT; | ||
754 | goto out; | 760 | goto out; |
761 | } | ||
755 | 762 | ||
756 | error = -ENOMEM; | 763 | error = -ENOMEM; |
757 | new_fl = locks_alloc_lock(); | 764 | new_fl = locks_alloc_lock(); |
@@ -948,8 +955,11 @@ static int __posix_lock_file_conf(struct inode *inode, struct file_lock *request | |||
948 | 955 | ||
949 | error = 0; | 956 | error = 0; |
950 | if (!added) { | 957 | if (!added) { |
951 | if (request->fl_type == F_UNLCK) | 958 | if (request->fl_type == F_UNLCK) { |
959 | if (request->fl_flags & FL_EXISTS) | ||
960 | error = -ENOENT; | ||
952 | goto out; | 961 | goto out; |
962 | } | ||
953 | 963 | ||
954 | if (!new_fl) { | 964 | if (!new_fl) { |
955 | error = -ENOLCK; | 965 | error = -ENOLCK; |
@@ -996,6 +1006,10 @@ static int __posix_lock_file_conf(struct inode *inode, struct file_lock *request | |||
996 | * Add a POSIX style lock to a file. | 1006 | * Add a POSIX style lock to a file. |
997 | * We merge adjacent & overlapping locks whenever possible. | 1007 | * We merge adjacent & overlapping locks whenever possible. |
998 | * POSIX locks are sorted by owner task, then by starting address | 1008 | * POSIX locks are sorted by owner task, then by starting address |
1009 | * | ||
1010 | * Note that if called with an FL_EXISTS argument, the caller may determine | ||
1011 | * whether or not a lock was successfully freed by testing the return | ||
1012 | * value for -ENOENT. | ||
999 | */ | 1013 | */ |
1000 | int posix_lock_file(struct file *filp, struct file_lock *fl) | 1014 | int posix_lock_file(struct file *filp, struct file_lock *fl) |
1001 | { | 1015 | { |