diff options
Diffstat (limited to 'fs/locks.c')
| -rw-r--r-- | fs/locks.c | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/fs/locks.c b/fs/locks.c index dce8c747371c..1ce57b4b362c 100644 --- a/fs/locks.c +++ b/fs/locks.c | |||
| @@ -779,8 +779,10 @@ find_conflict: | |||
| 779 | if (!flock_locks_conflict(request, fl)) | 779 | if (!flock_locks_conflict(request, fl)) |
| 780 | continue; | 780 | continue; |
| 781 | error = -EAGAIN; | 781 | error = -EAGAIN; |
| 782 | if (request->fl_flags & FL_SLEEP) | 782 | if (!(request->fl_flags & FL_SLEEP)) |
| 783 | locks_insert_block(fl, request); | 783 | goto out; |
| 784 | error = FILE_LOCK_DEFERRED; | ||
| 785 | locks_insert_block(fl, request); | ||
| 784 | goto out; | 786 | goto out; |
| 785 | } | 787 | } |
| 786 | if (request->fl_flags & FL_ACCESS) | 788 | if (request->fl_flags & FL_ACCESS) |
| @@ -836,7 +838,7 @@ static int __posix_lock_file(struct inode *inode, struct file_lock *request, str | |||
| 836 | error = -EDEADLK; | 838 | error = -EDEADLK; |
| 837 | if (posix_locks_deadlock(request, fl)) | 839 | if (posix_locks_deadlock(request, fl)) |
| 838 | goto out; | 840 | goto out; |
| 839 | error = -EAGAIN; | 841 | error = FILE_LOCK_DEFERRED; |
| 840 | locks_insert_block(fl, request); | 842 | locks_insert_block(fl, request); |
| 841 | goto out; | 843 | goto out; |
| 842 | } | 844 | } |
| @@ -1035,7 +1037,7 @@ int posix_lock_file_wait(struct file *filp, struct file_lock *fl) | |||
| 1035 | might_sleep (); | 1037 | might_sleep (); |
| 1036 | for (;;) { | 1038 | for (;;) { |
| 1037 | error = posix_lock_file(filp, fl, NULL); | 1039 | error = posix_lock_file(filp, fl, NULL); |
| 1038 | if ((error != -EAGAIN) || !(fl->fl_flags & FL_SLEEP)) | 1040 | if (error != FILE_LOCK_DEFERRED) |
| 1039 | break; | 1041 | break; |
| 1040 | error = wait_event_interruptible(fl->fl_wait, !fl->fl_next); | 1042 | error = wait_event_interruptible(fl->fl_wait, !fl->fl_next); |
| 1041 | if (!error) | 1043 | if (!error) |
| @@ -1107,9 +1109,7 @@ int locks_mandatory_area(int read_write, struct inode *inode, | |||
| 1107 | 1109 | ||
| 1108 | for (;;) { | 1110 | for (;;) { |
| 1109 | error = __posix_lock_file(inode, &fl, NULL); | 1111 | error = __posix_lock_file(inode, &fl, NULL); |
| 1110 | if (error != -EAGAIN) | 1112 | if (error != FILE_LOCK_DEFERRED) |
| 1111 | break; | ||
| 1112 | if (!(fl.fl_flags & FL_SLEEP)) | ||
| 1113 | break; | 1113 | break; |
| 1114 | error = wait_event_interruptible(fl.fl_wait, !fl.fl_next); | 1114 | error = wait_event_interruptible(fl.fl_wait, !fl.fl_next); |
| 1115 | if (!error) { | 1115 | if (!error) { |
| @@ -1531,7 +1531,7 @@ int flock_lock_file_wait(struct file *filp, struct file_lock *fl) | |||
| 1531 | might_sleep(); | 1531 | might_sleep(); |
| 1532 | for (;;) { | 1532 | for (;;) { |
| 1533 | error = flock_lock_file(filp, fl); | 1533 | error = flock_lock_file(filp, fl); |
| 1534 | if ((error != -EAGAIN) || !(fl->fl_flags & FL_SLEEP)) | 1534 | if (error != FILE_LOCK_DEFERRED) |
| 1535 | break; | 1535 | break; |
| 1536 | error = wait_event_interruptible(fl->fl_wait, !fl->fl_next); | 1536 | error = wait_event_interruptible(fl->fl_wait, !fl->fl_next); |
| 1537 | if (!error) | 1537 | if (!error) |
| @@ -1716,17 +1716,17 @@ out: | |||
| 1716 | * fl_grant is set. Callers expecting ->lock() to return asynchronously | 1716 | * fl_grant is set. Callers expecting ->lock() to return asynchronously |
| 1717 | * will only use F_SETLK, not F_SETLKW; they will set FL_SLEEP if (and only if) | 1717 | * will only use F_SETLK, not F_SETLKW; they will set FL_SLEEP if (and only if) |
| 1718 | * the request is for a blocking lock. When ->lock() does return asynchronously, | 1718 | * the request is for a blocking lock. When ->lock() does return asynchronously, |
| 1719 | * it must return -EINPROGRESS, and call ->fl_grant() when the lock | 1719 | * it must return FILE_LOCK_DEFERRED, and call ->fl_grant() when the lock |
| 1720 | * request completes. | 1720 | * request completes. |
| 1721 | * If the request is for non-blocking lock the file system should return | 1721 | * If the request is for non-blocking lock the file system should return |
| 1722 | * -EINPROGRESS then try to get the lock and call the callback routine with | 1722 | * FILE_LOCK_DEFERRED then try to get the lock and call the callback routine |
| 1723 | * the result. If the request timed out the callback routine will return a | 1723 | * with the result. If the request timed out the callback routine will return a |
| 1724 | * nonzero return code and the file system should release the lock. The file | 1724 | * nonzero return code and the file system should release the lock. The file |
| 1725 | * system is also responsible to keep a corresponding posix lock when it | 1725 | * system is also responsible to keep a corresponding posix lock when it |
| 1726 | * grants a lock so the VFS can find out which locks are locally held and do | 1726 | * grants a lock so the VFS can find out which locks are locally held and do |
| 1727 | * the correct lock cleanup when required. | 1727 | * the correct lock cleanup when required. |
| 1728 | * The underlying filesystem must not drop the kernel lock or call | 1728 | * The underlying filesystem must not drop the kernel lock or call |
| 1729 | * ->fl_grant() before returning to the caller with a -EINPROGRESS | 1729 | * ->fl_grant() before returning to the caller with a FILE_LOCK_DEFERRED |
| 1730 | * return code. | 1730 | * return code. |
| 1731 | */ | 1731 | */ |
| 1732 | int vfs_lock_file(struct file *filp, unsigned int cmd, struct file_lock *fl, struct file_lock *conf) | 1732 | int vfs_lock_file(struct file *filp, unsigned int cmd, struct file_lock *fl, struct file_lock *conf) |
| @@ -1804,7 +1804,7 @@ again: | |||
| 1804 | else { | 1804 | else { |
| 1805 | for (;;) { | 1805 | for (;;) { |
| 1806 | error = posix_lock_file(filp, file_lock, NULL); | 1806 | error = posix_lock_file(filp, file_lock, NULL); |
| 1807 | if (error != -EAGAIN || cmd == F_SETLK) | 1807 | if (error != FILE_LOCK_DEFERRED) |
| 1808 | break; | 1808 | break; |
| 1809 | error = wait_event_interruptible(file_lock->fl_wait, | 1809 | error = wait_event_interruptible(file_lock->fl_wait, |
| 1810 | !file_lock->fl_next); | 1810 | !file_lock->fl_next); |
| @@ -1941,7 +1941,7 @@ again: | |||
| 1941 | else { | 1941 | else { |
| 1942 | for (;;) { | 1942 | for (;;) { |
| 1943 | error = posix_lock_file(filp, file_lock, NULL); | 1943 | error = posix_lock_file(filp, file_lock, NULL); |
| 1944 | if (error != -EAGAIN || cmd == F_SETLK64) | 1944 | if (error != FILE_LOCK_DEFERRED) |
| 1945 | break; | 1945 | break; |
| 1946 | error = wait_event_interruptible(file_lock->fl_wait, | 1946 | error = wait_event_interruptible(file_lock->fl_wait, |
| 1947 | !file_lock->fl_next); | 1947 | !file_lock->fl_next); |
