About upgrading vnode lock in VOP

Konstantin Belousov kostikbel at gmail.com
Wed Feb 3 19:44:27 UTC 2021


On Wed, Feb 03, 2021 at 10:43:10PM +0800, Ka Ho Ng wrote:
> Hi all,
> 
> Is it generally okay if an VOP upgrades the vnode lock from shared
> lock to exclusive lock in case it is held as shared lock? The reason
> behind is, the VOP would possibly extend the file size.
It is up to VOP.

As a note, you generally cannot upgrade from shared to exclusive without
dropping the lock.  This opens a possibility for the vnode to be reclaimed,
which means that VOP can no longer safely operate on the vnode.

If the scope is not just a VOP call from top of VFS, then again it might
be not safe to continue the operation.


More information about the freebsd-hackers mailing list