提交 ff7b86b8 编写于 作者: M Miklos Szeredi 提交者: Linus Torvalds

[PATCH] locks: clean up locks_remove_posix()

locks_remove_posix() can use posix_lock_file() instead of doing the lock
removal by hand.  posix_lock_file() now does exacly the same.

The comment about pids no longer applies, posix_lock_file() takes only the
owner into account.
Signed-off-by: NMiklos Szeredi <miklos@szeredi.hu>
Cc: Trond Myklebust <trond.myklebust@fys.uio.no>
Signed-off-by: NAndrew Morton <akpm@osdl.org>
Signed-off-by: NLinus Torvalds <torvalds@osdl.org>
上级 39005d02
......@@ -1896,15 +1896,14 @@ int fcntl_setlk64(unsigned int fd, struct file *filp, unsigned int cmd,
*/
void locks_remove_posix(struct file *filp, fl_owner_t owner)
{
struct file_lock lock, **before;
struct file_lock lock;
/*
* If there are no locks held on this file, we don't need to call
* posix_lock_file(). Another process could be setting a lock on this
* file at the same time, but we wouldn't remove that lock anyway.
*/
before = &filp->f_dentry->d_inode->i_flock;
if (*before == NULL)
if (!filp->f_dentry->d_inode->i_flock)
return;
lock.fl_type = F_UNLCK;
......@@ -1917,25 +1916,11 @@ 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) {
if (filp->f_op && filp->f_op->lock != NULL)
filp->f_op->lock(filp, F_SETLK, &lock);
goto out;
}
else
posix_lock_file(filp, &lock);
/* Can't use posix_lock_file here; we need to remove it no matter
* which pid we have.
*/
lock_kernel();
while (*before != NULL) {
struct file_lock *fl = *before;
if (IS_POSIX(fl) && posix_same_owner(fl, &lock)) {
locks_delete_lock(before);
continue;
}
before = &fl->fl_next;
}
unlock_kernel();
out:
if (lock.fl_ops && lock.fl_ops->fl_release_private)
lock.fl_ops->fl_release_private(&lock);
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册