mirror of
https://github.com/freebsd/freebsd-src
synced 2024-11-05 18:22:52 +00:00
Add sysctl debug.dircheck to allow directory sanity checking to be turned
on with a sysctl. Fix two bugs in ufs_lookup that can cause deadlocks due to out-of-order locking. This fix was tested for a few days prior to commit.
This commit is contained in:
parent
10c2a9dbbd
commit
f9eb66d73a
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=52641
1 changed files with 11 additions and 0 deletions
|
@ -48,6 +48,7 @@
|
|||
#include <sys/stat.h>
|
||||
#include <sys/mount.h>
|
||||
#include <sys/vnode.h>
|
||||
#include <sys/sysctl.h>
|
||||
|
||||
#include <vm/vm.h>
|
||||
#include <vm/vm_extern.h>
|
||||
|
@ -64,6 +65,8 @@ int dirchk = 1;
|
|||
int dirchk = 0;
|
||||
#endif
|
||||
|
||||
SYSCTL_INT(_debug, OID_AUTO, dircheck, CTLFLAG_RW, &dirchk, 0, "");
|
||||
|
||||
/* true if old FS format...*/
|
||||
#define OFSFMT(vp) ((vp)->v_mount->mnt_maxsymlinklen <= 0)
|
||||
|
||||
|
@ -452,7 +455,11 @@ ufs_lookup(ap)
|
|||
*vpp = vdp;
|
||||
return (0);
|
||||
}
|
||||
if (flags & ISDOTDOT)
|
||||
VOP_UNLOCK(vdp, 0, p); /* race to get the inode */
|
||||
error = VFS_VGET(vdp->v_mount, dp->i_ino, &tdp);
|
||||
if (flags & ISDOTDOT)
|
||||
vn_lock(vdp, LK_EXCLUSIVE | LK_RETRY, p);
|
||||
if (error)
|
||||
return (error);
|
||||
/*
|
||||
|
@ -489,7 +496,11 @@ ufs_lookup(ap)
|
|||
*/
|
||||
if (dp->i_number == dp->i_ino)
|
||||
return (EISDIR);
|
||||
if (flags & ISDOTDOT)
|
||||
VOP_UNLOCK(vdp, 0, p); /* race to get the inode */
|
||||
error = VFS_VGET(vdp->v_mount, dp->i_ino, &tdp);
|
||||
if (flags & ISDOTDOT)
|
||||
vn_lock(vdp, LK_EXCLUSIVE | LK_RETRY, p);
|
||||
if (error)
|
||||
return (error);
|
||||
*vpp = tdp;
|
||||
|
|
Loading…
Reference in a new issue