Page MenuHomeFreeBSD

Add a kern.lockf sysctl to list the advisory byte-range locks on a specific vnode

Authored by on Feb 20 2022, 12:54 PM.
Referenced Files
Unknown Object (File)
Fri, May 10, 8:10 AM
Unknown Object (File)
Fri, May 3, 4:35 PM
Unknown Object (File)
Fri, Apr 26, 6:13 PM
Unknown Object (File)
Jan 30 2024, 4:24 AM
Unknown Object (File)
Jan 14 2024, 8:28 AM
Unknown Object (File)
Jan 13 2024, 7:43 PM
Unknown Object (File)
Dec 25 2023, 12:43 PM
Unknown Object (File)
Dec 20 2023, 2:56 AM


Group Reviewers
Contributor Reviews (src)

Add a kern.lockf sysctl to list the advisory byte-range locks on a
specific vnode, described by its pid and file descriptor arguments.

A new struct xlockf is added, which contains fields from struct
flock with the addition of xl_id, the address of struct file for
the F_FLOCK locks which have pids of -1.

lf_iteratelocks_sysid() and lf_iteratelocks_vnode() are changed to
use struct xlockf, and to set the real lock type instead of
F_UNLCK so we can report on it, while its other callers overwrite
that type with F_UNLCK as needed.

Bump __FreeBSD_version.

Test Plan

The patched version of lsof will list these correctly, but we may wish to add a procstat option to list locks on a file too.

Diff Detail

rG FreeBSD src repository
Lint Skipped
Tests Skipped

Event Timeline

This is probably irrelevant now that D34756 added a more general way to retrieve advisory lock info.

se accepted this revision.EditedJun 12 2022, 8:59 PM
se added a subscriber: se.

The patch applied cleanly except for the version update in param.h and the kernel built with this patch and D34184 applied provides the required functionality for ZFS support in lsof-4.85.0.

This revision is now accepted and ready to land.Jun 12 2022, 8:59 PM

The first argument of fget_unlocked() must be a thread pointer ...

I have accepted this review, but the author points out that it should not be applied since D34576 provides a better implementation.

IMHO, this review should be closed by the originator, then - I do not know how to revoke the acceptance of this revision.