NetBSD Problem Report #60187

From www@netbsd.org  Sun Apr 12 14:09:00 2026
Return-Path: <www@netbsd.org>
Received: from mail.netbsd.org (mail.netbsd.org [199.233.217.200])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
	 key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256
	 client-signature RSA-PSS (2048 bits) client-digest SHA256)
	(Client CN "mail.netbsd.org", Issuer "R12" (not verified))
	by mollari.NetBSD.org (Postfix) with ESMTPS id 41A6E1A923A
	for <gnats-bugs@gnats.NetBSD.org>; Sun, 12 Apr 2026 14:09:00 +0000 (UTC)
Message-Id: <20260412140859.10A0C1A923E@mollari.NetBSD.org>
Date: Sun, 12 Apr 2026 14:08:59 +0000 (UTC)
From: campbell+netbsd@mumble.net
Reply-To: campbell+netbsd@mumble.net
To: gnats-bugs@NetBSD.org
Subject: diagnostic tool to find who holds what file locks
X-Send-Pr-Version: www-1.0
X-From4GNATS: "campbell+netbsd@mumble.net via gnats" <gnats-admin@NetBSD.org>

>Number:         60187
>Category:       bin
>Synopsis:       diagnostic tool to find who holds what file locks
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    bin-bug-people
>State:          open
>Class:          change-request
>Submitter-Id:   net
>Arrival-Date:   Sun Apr 12 14:10:00 +0000 2026
>Originator:     Taylor R Campbell
>Release:        current
>Organization:
The NetBSD Foundalock
>Environment:
>Description:

	When a set of processes hangs because they're all waiting for a
	file lock, it would be nice to know who holds the lock.

	For POSIX file locks, fcntl(F_SETLK), one can query which
	process holds a lock by fcntl(F_GETLK).  But that's only for
	the `completely stupid' SysV/POSIX semantics of file locks,
	which most applications -- including the flock(1) utility --
	don't use.  Applications that use BSD file locks instead, with
	flock(2), don't expose this information.

	There should be a diagnostic tool (even if it is not reliable
	for applications to make decisions, much like the kernel
	mutex_owner function) for finding what processes hold open
	files with locks that would cause another process trying to
	take a lock to hang.

	There should maybe also be a diagnostic tool to just print all
	the file locks that are currently held.  This is a little
	tricky because there is no vfs-generic way to find file locks:
	all the file locking records are per-fs, for reasons unclear to
	me since they all seem to defer to the lf_advlock(9) function.

>How-To-Repeat:

	try to diagnose why an application is hanging on file locks

>Fix:

	Yes, please!

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.47 2022/09/11 19:34:41 kim Exp $
$NetBSD: gnats_config.sh,v 1.9 2014/08/02 14:16:04 spz Exp $
Copyright © 1994-2026 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.