Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 106035
b: refs/heads/master
c: b648a6d
h: refs/heads/master
i:
  106033: 2a7de6b
  106031: 732772b
v: v3
  • Loading branch information
Miklos Szeredi authored and Linus Torvalds committed Jul 25, 2008
1 parent 2ca0bfc commit a549c8d
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 41 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: bde74e4bc64415b142e556a34d295a52a1b7da9d
refs/heads/master: b648a6de00770cc325c22f43bdd4e935f6a2ee55
71 changes: 31 additions & 40 deletions trunk/fs/locks.c
Original file line number Diff line number Diff line change
Expand Up @@ -1738,6 +1738,35 @@ int vfs_lock_file(struct file *filp, unsigned int cmd, struct file_lock *fl, str
}
EXPORT_SYMBOL_GPL(vfs_lock_file);

static int do_lock_file_wait(struct file *filp, unsigned int cmd,
struct file_lock *fl)
{
int error;

error = security_file_lock(filp, fl->fl_type);
if (error)
return error;

if (filp->f_op && filp->f_op->lock != NULL)
error = filp->f_op->lock(filp, cmd, fl);
else {
for (;;) {
error = posix_lock_file(filp, fl, NULL);
if (error != FILE_LOCK_DEFERRED)
break;
error = wait_event_interruptible(fl->fl_wait,
!fl->fl_next);
if (!error)
continue;

locks_delete_block(fl);
break;
}
}

return error;
}

/* Apply the lock described by l to an open file descriptor.
* This implements both the F_SETLK and F_SETLKW commands of fcntl().
*/
Expand Down Expand Up @@ -1795,26 +1824,7 @@ int fcntl_setlk(unsigned int fd, struct file *filp, unsigned int cmd,
goto out;
}

error = security_file_lock(filp, file_lock->fl_type);
if (error)
goto out;

if (filp->f_op && filp->f_op->lock != NULL)
error = filp->f_op->lock(filp, cmd, file_lock);
else {
for (;;) {
error = posix_lock_file(filp, file_lock, NULL);
if (error != FILE_LOCK_DEFERRED)
break;
error = wait_event_interruptible(file_lock->fl_wait,
!file_lock->fl_next);
if (!error)
continue;

locks_delete_block(file_lock);
break;
}
}
error = do_lock_file_wait(filp, cmd, file_lock);

/*
* Attempt to detect a close/fcntl race and recover by
Expand Down Expand Up @@ -1932,26 +1942,7 @@ int fcntl_setlk64(unsigned int fd, struct file *filp, unsigned int cmd,
goto out;
}

error = security_file_lock(filp, file_lock->fl_type);
if (error)
goto out;

if (filp->f_op && filp->f_op->lock != NULL)
error = filp->f_op->lock(filp, cmd, file_lock);
else {
for (;;) {
error = posix_lock_file(filp, file_lock, NULL);
if (error != FILE_LOCK_DEFERRED)
break;
error = wait_event_interruptible(file_lock->fl_wait,
!file_lock->fl_next);
if (!error)
continue;

locks_delete_block(file_lock);
break;
}
}
error = do_lock_file_wait(filp, cmd, file_lock);

/*
* Attempt to detect a close/fcntl race and recover by
Expand Down

0 comments on commit a549c8d

Please sign in to comment.