Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 106034
b: refs/heads/master
c: bde74e4
h: refs/heads/master
v: v3
  • Loading branch information
Miklos Szeredi authored and Linus Torvalds committed Jul 25, 2008
1 parent 2a7de6b commit 2ca0bfc
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 25 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: cc77b1521d06be07c9bb1a4a3e1f775dcaa15093
refs/heads/master: bde74e4bc64415b142e556a34d295a52a1b7da9d
2 changes: 1 addition & 1 deletion trunk/fs/dlm/plock.c
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ int dlm_posix_lock(dlm_lockspace_t *lockspace, u64 number, struct file *file,
if (xop->callback == NULL)
wait_event(recv_wq, (op->done != 0));
else {
rv = -EINPROGRESS;
rv = FILE_LOCK_DEFERRED;
goto out;
}

Expand Down
13 changes: 4 additions & 9 deletions trunk/fs/lockd/svclock.c
Original file line number Diff line number Diff line change
Expand Up @@ -418,8 +418,8 @@ nlmsvc_lock(struct svc_rqst *rqstp, struct nlm_file *file,
goto out;
case -EAGAIN:
ret = nlm_lck_denied;
break;
case -EINPROGRESS:
goto out;
case FILE_LOCK_DEFERRED:
if (wait)
break;
/* Filesystem lock operation is in progress
Expand All @@ -434,10 +434,6 @@ nlmsvc_lock(struct svc_rqst *rqstp, struct nlm_file *file,
goto out;
}

ret = nlm_lck_denied;
if (!wait)
goto out;

ret = nlm_lck_blocked;

/* Append to list of blocked */
Expand Down Expand Up @@ -507,7 +503,7 @@ nlmsvc_testlock(struct svc_rqst *rqstp, struct nlm_file *file,
}

error = vfs_test_lock(file->f_file, &lock->fl);
if (error == -EINPROGRESS) {
if (error == FILE_LOCK_DEFERRED) {
ret = nlmsvc_defer_lock_rqst(rqstp, block);
goto out;
}
Expand Down Expand Up @@ -731,8 +727,7 @@ nlmsvc_grant_blocked(struct nlm_block *block)
switch (error) {
case 0:
break;
case -EAGAIN:
case -EINPROGRESS:
case FILE_LOCK_DEFERRED:
dprintk("lockd: lock still blocked error %d\n", error);
nlmsvc_insert_block(block, NLM_NEVER);
nlmsvc_release_block(block);
Expand Down
28 changes: 14 additions & 14 deletions trunk/fs/locks.c
Original file line number Diff line number Diff line change
Expand Up @@ -779,8 +779,10 @@ static int flock_lock_file(struct file *filp, struct file_lock *request)
if (!flock_locks_conflict(request, fl))
continue;
error = -EAGAIN;
if (request->fl_flags & FL_SLEEP)
locks_insert_block(fl, request);
if (!(request->fl_flags & FL_SLEEP))
goto out;
error = FILE_LOCK_DEFERRED;
locks_insert_block(fl, request);
goto out;
}
if (request->fl_flags & FL_ACCESS)
Expand Down Expand Up @@ -836,7 +838,7 @@ static int __posix_lock_file(struct inode *inode, struct file_lock *request, str
error = -EDEADLK;
if (posix_locks_deadlock(request, fl))
goto out;
error = -EAGAIN;
error = FILE_LOCK_DEFERRED;
locks_insert_block(fl, request);
goto out;
}
Expand Down Expand Up @@ -1035,7 +1037,7 @@ int posix_lock_file_wait(struct file *filp, struct file_lock *fl)
might_sleep ();
for (;;) {
error = posix_lock_file(filp, fl, NULL);
if ((error != -EAGAIN) || !(fl->fl_flags & FL_SLEEP))
if (error != FILE_LOCK_DEFERRED)
break;
error = wait_event_interruptible(fl->fl_wait, !fl->fl_next);
if (!error)
Expand Down Expand Up @@ -1107,9 +1109,7 @@ int locks_mandatory_area(int read_write, struct inode *inode,

for (;;) {
error = __posix_lock_file(inode, &fl, NULL);
if (error != -EAGAIN)
break;
if (!(fl.fl_flags & FL_SLEEP))
if (error != FILE_LOCK_DEFERRED)
break;
error = wait_event_interruptible(fl.fl_wait, !fl.fl_next);
if (!error) {
Expand Down Expand Up @@ -1531,7 +1531,7 @@ int flock_lock_file_wait(struct file *filp, struct file_lock *fl)
might_sleep();
for (;;) {
error = flock_lock_file(filp, fl);
if ((error != -EAGAIN) || !(fl->fl_flags & FL_SLEEP))
if (error != FILE_LOCK_DEFERRED)
break;
error = wait_event_interruptible(fl->fl_wait, !fl->fl_next);
if (!error)
Expand Down Expand Up @@ -1716,17 +1716,17 @@ int fcntl_getlk(struct file *filp, struct flock __user *l)
* fl_grant is set. Callers expecting ->lock() to return asynchronously
* will only use F_SETLK, not F_SETLKW; they will set FL_SLEEP if (and only if)
* the request is for a blocking lock. When ->lock() does return asynchronously,
* it must return -EINPROGRESS, and call ->fl_grant() when the lock
* it must return FILE_LOCK_DEFERRED, and call ->fl_grant() when the lock
* request completes.
* If the request is for non-blocking lock the file system should return
* -EINPROGRESS then try to get the lock and call the callback routine with
* the result. If the request timed out the callback routine will return a
* FILE_LOCK_DEFERRED then try to get the lock and call the callback routine
* with the result. If the request timed out the callback routine will return a
* nonzero return code and the file system should release the lock. The file
* system is also responsible to keep a corresponding posix lock when it
* grants a lock so the VFS can find out which locks are locally held and do
* the correct lock cleanup when required.
* The underlying filesystem must not drop the kernel lock or call
* ->fl_grant() before returning to the caller with a -EINPROGRESS
* ->fl_grant() before returning to the caller with a FILE_LOCK_DEFERRED
* return code.
*/
int vfs_lock_file(struct file *filp, unsigned int cmd, struct file_lock *fl, struct file_lock *conf)
Expand Down Expand Up @@ -1804,7 +1804,7 @@ int fcntl_setlk(unsigned int fd, struct file *filp, unsigned int cmd,
else {
for (;;) {
error = posix_lock_file(filp, file_lock, NULL);
if (error != -EAGAIN || cmd == F_SETLK)
if (error != FILE_LOCK_DEFERRED)
break;
error = wait_event_interruptible(file_lock->fl_wait,
!file_lock->fl_next);
Expand Down Expand Up @@ -1941,7 +1941,7 @@ int fcntl_setlk64(unsigned int fd, struct file *filp, unsigned int cmd,
else {
for (;;) {
error = posix_lock_file(filp, file_lock, NULL);
if (error != -EAGAIN || cmd == F_SETLK64)
if (error != FILE_LOCK_DEFERRED)
break;
error = wait_event_interruptible(file_lock->fl_wait,
!file_lock->fl_next);
Expand Down
6 changes: 6 additions & 0 deletions trunk/include/linux/fs.h
Original file line number Diff line number Diff line change
Expand Up @@ -885,6 +885,12 @@ static inline int file_check_writeable(struct file *filp)
#define FL_CLOSE 64 /* unlock on close */
#define FL_SLEEP 128 /* A blocking lock */

/*
* Special return value from posix_lock_file() and vfs_lock_file() for
* asynchronous locking.
*/
#define FILE_LOCK_DEFERRED 1

/*
* The POSIX file lock owner is determined by
* the "struct files_struct" in the thread group
Expand Down

0 comments on commit 2ca0bfc

Please sign in to comment.