Re: [PATCH] fs/locks.c: Fix posix locking for threaded tasks

From: Andreas Dilger (
Date: Mon Jun 10 2002 - 01:41:20 EST

On Jun 10, 2002 03:48 +0100, Matthew Wilcox wrote:
> Saurabh Desai believes that locks created by threads should not conflict
> with each other. I'm inclined to agree; I don't know why the test for
> ->fl_pid was added, but the comment suggests that whoever added it wasn't
> sure either.
> Frankly, I have no clue about the intended semantics for threads, and
> SUS v3 does not offer any enlightenment. But it seems reasonable that
> processes which share a files_struct should share locks. After all,
> if one process closes the fd, they'll remove locks belonging to the
> other process.

I would pass this by the Samba folks first. I seem to recall them
complaining about this area. The "one thread closing a file removes
locks from another thread" is one area that I'm sure they don't like.
Making it so that multiple threads ignore file locks is probably
not going to make them happy either. I believe one of the issues is
that Samba is running server threads for many remote processes, and
it needs to be able to enforce these locks.

Otherwise, this change makes it impossible to write a multi-threaded
program that _does_ allow you use locking between threads. If anything,
this PID check could be conditional on some extra lock flag (e.g.

Cheers, Andreas

Andreas Dilger

- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to More majordomo info at Please read the FAQ at

This archive was generated by hypermail 2b29 : Sat Jun 15 2002 - 22:00:16 EST