Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 72888
b: refs/heads/master
c: 97855b4
h: refs/heads/master
v: v3
  • Loading branch information
J. Bruce Fields authored and Linus Torvalds committed Oct 30, 2007
1 parent a2585b1 commit fdb7e0a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: fb7267acfef1de3e49d4e0c80be3cc603e974b3b
refs/heads/master: 97855b49b6bac0bd25f16b017883634d13591d00
11 changes: 11 additions & 0 deletions trunk/fs/locks.c
Original file line number Diff line number Diff line change
Expand Up @@ -696,17 +696,28 @@ EXPORT_SYMBOL(posix_test_lock);
* Note: the above assumption may not be true when handling lock requests
* from a broken NFS client. But broken NFS clients have a lot more to
* worry about than proper deadlock detection anyway... --okir
*
* However, the failure of this assumption (also possible in the case of
* multiple tasks sharing the same open file table) also means there's no
* guarantee that the loop below will terminate. As a hack, we give up
* after a few iterations.
*/

#define MAX_DEADLK_ITERATIONS 10

static int posix_locks_deadlock(struct file_lock *caller_fl,
struct file_lock *block_fl)
{
struct file_lock *fl;
int i = 0;

next_task:
if (posix_same_owner(caller_fl, block_fl))
return 1;
list_for_each_entry(fl, &blocked_list, fl_link) {
if (posix_same_owner(fl, block_fl)) {
if (i++ > MAX_DEADLK_ITERATIONS)
return 0;
fl = fl->fl_next;
block_fl = fl;
goto next_task;
Expand Down

0 comments on commit fdb7e0a

Please sign in to comment.