]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/commit
Add non-blocking trylock variants for the rangelock functions.
authorrmacklem <rmacklem@FreeBSD.org>
Thu, 27 Jun 2019 23:10:40 +0000 (23:10 +0000)
committerrmacklem <rmacklem@FreeBSD.org>
Thu, 27 Jun 2019 23:10:40 +0000 (23:10 +0000)
commitbfcb2b538f63d58ec83cd0661930a3baf1a96533
tree6cc62f585e50994dc16e10747edd1c78b3aebfc0
parent3fda21ad0ec3964fb9f350275682883360ca776e
Add non-blocking trylock variants for the rangelock functions.

A future patch that will add a Linux compatible copy_file_range(2) syscall
needs to be able to lock the byte ranges of two files concurrently.
To do this without a risk of deadlock, a non-blocking variant of
vn_rangelock_rlock() called vn_rangelock_tryrlock() was needed.
This patch adds this, along with vn_rangelock_trywlock(), in order to
do this.
The patch also adds a couple of comments, that I hope clarify how the
algorithm used in kern_rangelock.c works.

Reviewed by: kib, asomers (previous version)
Differential Revision: https://reviews.freebsd.org/D20645
sys/kern/kern_rangelock.c
sys/sys/rangelock.h
sys/sys/vnode.h