Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 54488
b: refs/heads/master
c: 7723ec9
h: refs/heads/master
v: v3
  • Loading branch information
Marc Eshel authored and J. Bruce Fields committed May 6, 2007
1 parent 37870a2 commit 964f953
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 33 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: 3ee17abd14c728d4e0ca7a991c58f2250cb091af
refs/heads/master: 7723ec9777d9832849b76475b1a21a2872a40d20
68 changes: 36 additions & 32 deletions trunk/fs/locks.c
Original file line number Diff line number Diff line change
Expand Up @@ -1698,6 +1698,21 @@ int fcntl_getlk(struct file *filp, struct flock __user *l)
return error;
}

/**
* vfs_lock_file - file byte range lock
* @filp: The file to apply the lock to
* @cmd: type of locking operation (F_SETLK, F_GETLK, etc.)
* @fl: The lock to be applied
*/
int vfs_lock_file(struct file *filp, unsigned int cmd, struct file_lock *fl)
{
if (filp->f_op && filp->f_op->lock)
return filp->f_op->lock(filp, cmd, fl);
else
return posix_lock_file(filp, fl);
}
EXPORT_SYMBOL_GPL(vfs_lock_file);

/* 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 @@ -1760,21 +1775,17 @@ int fcntl_setlk(unsigned int fd, struct file *filp, unsigned int cmd,
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);
if (error != -EAGAIN || cmd == F_SETLK)
break;
error = wait_event_interruptible(file_lock->fl_wait,
!file_lock->fl_next);
if (!error)
continue;

locks_delete_block(file_lock);
for (;;) {
error = vfs_lock_file(filp, cmd, file_lock);
if (error != -EAGAIN || cmd == F_SETLK)
break;
}
error = wait_event_interruptible(file_lock->fl_wait,
!file_lock->fl_next);
if (!error)
continue;

locks_delete_block(file_lock);
break;
}

/*
Expand Down Expand Up @@ -1890,21 +1901,17 @@ int fcntl_setlk64(unsigned int fd, struct file *filp, unsigned int cmd,
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);
if (error != -EAGAIN || cmd == F_SETLK64)
break;
error = wait_event_interruptible(file_lock->fl_wait,
!file_lock->fl_next);
if (!error)
continue;

locks_delete_block(file_lock);
for (;;) {
error = vfs_lock_file(filp, cmd, file_lock);
if (error != -EAGAIN || cmd == F_SETLK64)
break;
}
error = wait_event_interruptible(file_lock->fl_wait,
!file_lock->fl_next);
if (!error)
continue;

locks_delete_block(file_lock);
break;
}

/*
Expand Down Expand Up @@ -1949,10 +1956,7 @@ void locks_remove_posix(struct file *filp, fl_owner_t owner)
lock.fl_ops = NULL;
lock.fl_lmops = NULL;

if (filp->f_op && filp->f_op->lock != NULL)
filp->f_op->lock(filp, F_SETLK, &lock);
else
posix_lock_file(filp, &lock);
vfs_lock_file(filp, F_SETLK, &lock);

if (lock.fl_ops && lock.fl_ops->fl_release_private)
lock.fl_ops->fl_release_private(&lock);
Expand Down
1 change: 1 addition & 0 deletions trunk/include/linux/fs.h
Original file line number Diff line number Diff line change
Expand Up @@ -857,6 +857,7 @@ extern int posix_lock_file(struct file *, struct file_lock *);
extern int posix_lock_file_wait(struct file *, struct file_lock *);
extern int posix_unblock_lock(struct file *, struct file_lock *);
extern int vfs_test_lock(struct file *, struct file_lock *);
extern int vfs_lock_file(struct file *, unsigned int, struct file_lock *);
extern int flock_lock_file_wait(struct file *filp, struct file_lock *fl);
extern int __break_lease(struct inode *inode, unsigned int flags);
extern void lease_get_mtime(struct inode *, struct timespec *time);
Expand Down

0 comments on commit 964f953

Please sign in to comment.