linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Fix up broken POSIX locks...
@ 2004-06-23 16:54 Trond Myklebust
  0 siblings, 0 replies; only message in thread
From: Trond Myklebust @ 2004-06-23 16:54 UTC (permalink / raw)
  To: Andrew Morton, linux-fsdevel; +Cc: linux-kernel

[-- Attachment #1: Type: text/plain, Size: 182 bytes --]

The following patch fixes up two nasty inconsistencies in the POSIX
byte-range locking code. The lockowner alone is NOT sufficient to
determine ownership of a lock.

Cheers,
  Trond

[-- Attachment #2: linux-2.6.7-01-fix_locks.dif --]
[-- Type: text/plain, Size: 1068 bytes --]

 locks.c |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletion(-)

diff -u --recursive --new-file --show-c-function linux-2.6.7/fs/locks.c linux-2.6.7-00-fix_locks/fs/locks.c
--- linux-2.6.7/fs/locks.c	2004-06-16 14:58:27.000000000 -0400
+++ linux-2.6.7-00-fix_locks/fs/locks.c	2004-06-23 12:46:29.000000000 -0400
@@ -921,6 +921,7 @@ int posix_lock_file(struct file *filp, s
 int locks_mandatory_locked(struct inode *inode)
 {
 	fl_owner_t owner = current->files;
+	unsigned int pid = current->tgid;
 	struct file_lock *fl;
 
 	/*
@@ -932,6 +933,8 @@ int locks_mandatory_locked(struct inode 
 			continue;
 		if (fl->fl_owner != owner)
 			break;
+		if (fl->fl_pid != pid)
+			break;
 	}
 	unlock_kernel();
 	return fl ? -EAGAIN : 0;
@@ -1684,7 +1687,7 @@ void locks_remove_posix(struct file *fil
 	lock_kernel();
 	while (*before != NULL) {
 		struct file_lock *fl = *before;
-		if (IS_POSIX(fl) && (fl->fl_owner == owner)) {
+		if (IS_POSIX(fl) && posix_same_owner(fl, &lock)) {
 			locks_delete_lock(before);
 			continue;
 		}

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2004-06-23 16:54 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-06-23 16:54 [PATCH] Fix up broken POSIX locks Trond Myklebust

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).