Re: [NFS client] NFS locks not released on abnormal process termination

From: Philippe Troin
Date: Sat Dec 06 2003 - 14:52:01 EST

Kenny Simpson <theonetruekenny@xxxxxxxxx> writes:

> I have a up-to-date RH9 (kernel 2.4.20-24.9, nfs utils 1.0.1-3.9) I'm using as
> an NFS client (the server is a NetApp), and I'm trying to use advisory locking
> of a file.
> If the process that locks the file exits normally, the lock is released, and
> everything is fine.
> However, if the process aborts, the lock is left with no clear way to remove
> it. I must remove the file to get rid of the lock.
> Details:
> Here is a test case:
> int main()
> {
> int fd = open("file", O_RDWR);
> if (lockf( fd, F_TLOCK, 0 ) < 0)
> .... print error message query owner
> pause();
> close( fd );
> }
> If I run this, when it gets to the pause(), I can clearly see in /proc/locks
> the process owning the lock.
> If I then kill -ABRT <pid>, the entry in /proc/locks goes away, but the lock is
> not removed from the server.
> When I run the program a second time, the lock acquire failes, and it says the
> (now defunct) old process still owns the lock. Since I cannot easily make
> another process with the id of the original, I seem to have no way to
> explicitly release the lock.

I've also seen this behavior witht the stock 2.4.22 and 2.4.23

See the thread:

> I even ran ethereal to watch which NLM requests were being made. No unlock
> request was ever sent, so I don't think this can be a server issue.
> Any ideas? Is it supposed to work this way?

No and no.

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