diff options
author | Mateusz Guzik <mjg@FreeBSD.org> | 2017-01-21 18:38:16 +0000 |
---|---|---|
committer | Mateusz Guzik <mjg@FreeBSD.org> | 2017-01-21 18:38:16 +0000 |
commit | 1091fb52c11aaa900686bc25bed25e11d95b3a3b (patch) | |
tree | cd691ba97c501ee7b522538324a1e823c29ab700 /sys/kern/vfs_vnops.c | |
parent | 21dff1801f13b22d348f7e833e6714aa31d3aa59 (diff) | |
download | src-1091fb52c11aaa900686bc25bed25e11d95b3a3b.tar.gz src-1091fb52c11aaa900686bc25bed25e11d95b3a3b.zip |
vfs: refactor _vn_lock
Stop testing for LK_RETRY and error multiple times. Also postpone the
VI_DOOMED until after LK_RETRY was seen as it reads from the vnode.
No functional changes.
Notes
Notes:
svn path=/head/; revision=312600
Diffstat (limited to 'sys/kern/vfs_vnops.c')
-rw-r--r-- | sys/kern/vfs_vnops.c | 29 |
1 files changed, 13 insertions, 16 deletions
diff --git a/sys/kern/vfs_vnops.c b/sys/kern/vfs_vnops.c index 026837be9edd..2e1b857fec02 100644 --- a/sys/kern/vfs_vnops.c +++ b/sys/kern/vfs_vnops.c @@ -1539,27 +1539,24 @@ _vn_lock(struct vnode *vp, int flags, char *file, int line) VNASSERT((flags & LK_TYPE_MASK) != 0, vp, ("vn_lock called with no locktype.")); - do { #ifdef DEBUG_VFS_LOCKS - KASSERT(vp->v_holdcnt != 0, - ("vn_lock %p: zero hold count", vp)); + KASSERT(vp->v_holdcnt != 0, + ("vn_lock %p: zero hold count", vp)); #endif - error = VOP_LOCK1(vp, flags, file, line); - flags &= ~LK_INTERLOCK; /* Interlock is always dropped. */ - KASSERT((flags & LK_RETRY) == 0 || error == 0, - ("LK_RETRY set with incompatible flags (0x%x) or an error occurred (%d)", - flags, error)); - /* - * Callers specify LK_RETRY if they wish to get dead vnodes. - * If RETRY is not set, we return ENOENT instead. - */ - if (error == 0 && vp->v_iflag & VI_DOOMED && - (flags & LK_RETRY) == 0) { +retry: + error = VOP_LOCK1(vp, flags, file, line); + flags &= ~LK_INTERLOCK; /* Interlock is always dropped. */ + KASSERT((flags & LK_RETRY) == 0 || error == 0, + ("LK_RETRY set with incompatible flags (0x%x) or an error occurred (%d)", + flags, error)); + if (flags & LK_RETRY) { + if ((error != 0)) + goto retry; + if ((vp->v_iflag & VI_DOOMED)) { VOP_UNLOCK(vp, 0); error = ENOENT; - break; } - } while (flags & LK_RETRY && error != 0); + } return (error); } |