Page MenuHomeFreeBSD

NDFREE(): Fix unlocking for LOCKPARENT|LOCKLEAF and ndp->ni_dvp == ndp->ni_vp
ClosedPublic

Authored by kib on May 18 2019, 5:57 PM.
Tags
None
Referenced Files
Unknown Object (File)
Thu, Mar 28, 8:45 AM
Unknown Object (File)
Feb 5 2024, 10:22 PM
Unknown Object (File)
Dec 20 2023, 12:23 AM
Unknown Object (File)
Oct 24 2023, 1:10 PM
Unknown Object (File)
Aug 7 2023, 10:23 AM
Unknown Object (File)
Apr 23 2023, 10:36 PM
Unknown Object (File)
Jan 2 2023, 3:52 AM
Subscribers

Details

Summary

NDFREE() calculates unlock_dvp after ndp->ni_vp is unlocked and zeroed out. This makes the comparision of ni_dvp with ni_vp always fail.

Move the calculation of unlock_dvp right after unlock_vp, so that the code sees correct ni_vp value.

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Skipped
Unit
Tests Skipped
Build Status
Buildable 24301

Event Timeline

So if ni_dvp == ni_vp, does the caller hold two references on vp or one? It was not clear to me from some quick reading of the code.

So if ni_dvp == ni_vp, does the caller hold two references on vp or one? It was not clear to me from some quick reading of the code.

dvp == vp means that this was either dot lookup, or dotdot with vp == rootvp. For dotdot case, lookup() itself does the following:

				ndp->ni_dvp = dp;
				ndp->ni_vp = dp;
				VREF(dp);

for the root directory case (also chroot, jail pseudo-roots).

For UFS, ufs_lookup() takes a reference on the dvp directly in case of dot, see ufs_lookup().

So vp holds two references, but In either case, the code does not recurse on lock.

This revision is now accepted and ready to land.May 18 2019, 9:51 PM

This change looks correct to me.

I reproduced the problem and verified that the patch fixes it.
I ran all of the stress2 tests on both amd64 and i386.
No problems seen.

This revision was automatically updated to reflect the committed changes.