From owner-freebsd-hackers@FreeBSD.ORG Tue Aug 2 01:35:32 2005 Return-Path: X-Original-To: hackers@freebsd.org Delivered-To: freebsd-hackers@FreeBSD.ORG Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 6C0A816A41F; Tue, 2 Aug 2005 01:35:32 +0000 (GMT) (envelope-from dillon@apollo.backplane.com) Received: from apollo.backplane.com (apollo.backplane.com [216.240.41.2]) by mx1.FreeBSD.org (Postfix) with ESMTP id 2036243D48; Tue, 2 Aug 2005 01:35:31 +0000 (GMT) (envelope-from dillon@apollo.backplane.com) Received: from apollo.backplane.com (localhost [127.0.0.1]) by apollo.backplane.com (8.12.9p2/8.12.9) with ESMTP id j721ZVYk035932; Mon, 1 Aug 2005 18:35:31 -0700 (PDT) (envelope-from dillon@apollo.backplane.com) Received: (from dillon@localhost) by apollo.backplane.com (8.12.9p2/8.12.9/Submit) id j721ZVpf035931; Mon, 1 Aug 2005 18:35:31 -0700 (PDT) (envelope-from dillon) Date: Mon, 1 Aug 2005 18:35:31 -0700 (PDT) From: Matthew Dillon Message-Id: <200508020135.j721ZVpf035931@apollo.backplane.com> To: Igor Shmukler References: <6533c1c9050721121030016b7d@mail.gmail.com> <200507211926.j6LJQ55D071115@apollo.backplane.com> <6533c1c905080111026f1f07ca@mail.gmail.com> Cc: hackers@freebsd.org, fs@freebsd.org Subject: Re: per file lock list X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 02 Aug 2005 01:35:32 -0000 : :Matt, : :Thank you very much for response. This is a general solution, but it :not sufficient for our needs. I guess I should have been more clear :while explaining what we need. : :We want list of these locks for a group of processes. : :We made an implementation based on your suggestion, but there is one problem... : :Unfortunately this method does not return all shared locks for a :range. For example, if several processes have placed a shared lock on :a :range [1000 - 2000], F_GETLK returns a flock structure where l_pid field :contains a pid of process that takes the lock first. While, we want :to know all processes that takes this lock. Is there any way to retrieve :such information without using of internal kernel structures (inode :information)? : :Thank you in advance, : :igor I'm pretty sure there is no way to get a list of all shared users of a particular lock range short of going through kmem. You would need to program a new fcntl feature to get access to all the related locks. If you need the information just for debugging purposes then scanning the list via kmem might suffice, but it obviously isn't the best solution due to races. What I would recommend is that you create a new fcntl, say call it F_GETLKM, and hand it an extended flock structure which contains additional information...an index and a chaining field that the kernel can use to safely sequence through all related locks. That would allow the kernel to detect races with other processes changing the locking state at the same time. -Matt