Re: 2.1.89-pre3:inode 08:03 still has locks... -> found one

Bill Hawes (whawes@star.net)
Fri, 27 Feb 1998 15:56:27 -0500


This is a multi-part message in MIME format.
--------------E9FF64698D5D3B766FF9DEE4
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

Manuel J. Galan wrote:

> /usr/X11R6/lib/X11/xdm/xdm-pid still has locks ...

I'm not sure whether xdm is using threads with locks, but could you try the
attached patch and see it it helps? It changes the field used to identify a
lock's owner so that the lock can be removed no matter which thread closes the
file.

Regards,
Bill
--------------E9FF64698D5D3B766FF9DEE4
Content-Type: text/plain; charset=us-ascii; name="locks_owner88-patch"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline; filename="locks_owner88-patch"

--- fs/locks.c.old Sat Feb 21 09:25:00 1998
+++ fs/locks.c Wed Feb 25 10:17:39 1998
@@ -176,7 +177,10 @@
(fl2->fl_end >= fl1->fl_start));
}

-/* Check whether two locks have the same owner
+/*
+ * Check whether two locks have the same owner
+ * N.B. Do we need the test on PID as well as owner?
+ * (Clone tasks should be considered as one "owner".)
*/
static inline int
locks_same_owner(struct file_lock *fl1, struct file_lock *fl2)
@@ -448,6 +474,7 @@
void locks_remove_posix(struct task_struct *task, struct file *filp)
{
struct inode * inode = filp->f_dentry->d_inode;
+ void * owner = task->files;
struct file_lock file_lock, *fl;
struct file_lock **before;

@@ -457,7 +484,7 @@
repeat:
before = &inode->i_flock;
while ((fl = *before) != NULL) {
- if ((fl->fl_flags & FL_POSIX) && fl->fl_owner == task) {
+ if ((fl->fl_flags & FL_POSIX) && fl->fl_owner == owner) {
int (*lock)(struct file *, int, struct file_lock *);
lock = filp->f_op->lock;
if (lock) {
@@ -548,6 +575,7 @@

int locks_mandatory_locked(struct inode *inode)
{
+ void * owner = current->files;
struct file_lock *fl;

/* Search the lock list for this inode for any POSIX locks.
@@ -555,7 +583,7 @@
for (fl = inode->i_flock; fl != NULL; fl = fl->fl_next) {
if (!(fl->fl_flags & FL_POSIX))
continue;
- if (fl->fl_owner != current)
+ if (fl->fl_owner != owner)
return (-EAGAIN);
}
return (0);
@@ -572,7 +600,7 @@

tfl.fl_file = filp;
tfl.fl_flags = FL_POSIX | FL_ACCESS;
- tfl.fl_owner = current;
+ tfl.fl_owner = current->files;
tfl.fl_pid = current->pid;
tfl.fl_type = (read_write == FLOCK_VERIFY_WRITE) ? F_WRLCK : F_RDLCK;
tfl.fl_start = offset;
@@ -656,7 +684,7 @@
fl->fl_end = OFFSET_MAX;

fl->fl_file = filp;
- fl->fl_owner = current;
+ fl->fl_owner = current->files;
fl->fl_pid = current->pid;

return (1);

--------------E9FF64698D5D3B766FF9DEE4--

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu