per file lock list

Matthew Dillon dillon at apollo.backplane.com
Tue Aug 2 01:35:32 GMT 2005


:
: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


More information about the freebsd-hackers mailing list