Page MenuHomeFreeBSD

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

Authored by damjan.jov_gmail.com on Feb 20 2022, 12:54 PM.
Referenced Files
Unknown Object (File)
Sat, Dec 14, 1:43 PM
Unknown Object (File)
Fri, Dec 6, 10:34 AM
Unknown Object (File)
Nov 23 2024, 10:35 AM
Unknown Object (File)
Nov 14 2024, 5:45 PM
Unknown Object (File)
Nov 14 2024, 5:19 PM
Unknown Object (File)
Nov 14 2024, 4:09 PM
Unknown Object (File)
Nov 14 2024, 4:09 PM
Unknown Object (File)
Nov 14 2024, 5:33 AM

Details

Reviewers
se
Group Reviewers
Contributor Reviews (src)
Summary

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

Repository
rG FreeBSD src repository
Lint
Lint Skipped
Unit
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
sys/kern/vfs_subr.c
4747

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.