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)
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
Unknown Object (File)
Dec 18 2023, 7:30 PM
Unknown Object (File)
Sep 19 2023, 3:10 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.