git: 7dca8fd1cb3f - main - fdesc_lookup(): the condition to use vn_vget_ino() is always true
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Fri, 24 Mar 2023 17:47:43 UTC
The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=7dca8fd1cb3f91e7a3c07b7f57af6d9d43d0c71c commit 7dca8fd1cb3f91e7a3c07b7f57af6d9d43d0c71c Author: Konstantin Belousov <kib@FreeBSD.org> AuthorDate: 2023-03-23 19:28:08 +0000 Commit: Konstantin Belousov <kib@FreeBSD.org> CommitDate: 2023-03-24 17:47:16 +0000 fdesc_lookup(): the condition to use vn_vget_ino() is always true The ix number for the fdescfs root is 1, while any fd vnode has the ix value at least 3. Reviewed by: markj Tested by: pho Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D39207 --- sys/fs/fdescfs/fdesc_vnops.c | 38 ++++++++++++++++++-------------------- 1 file changed, 18 insertions(+), 20 deletions(-) diff --git a/sys/fs/fdescfs/fdesc_vnops.c b/sys/fs/fdescfs/fdesc_vnops.c index beef9295f11b..2713b070426c 100644 --- a/sys/fs/fdescfs/fdesc_vnops.c +++ b/sys/fs/fdescfs/fdesc_vnops.c @@ -337,26 +337,24 @@ fdesc_lookup(struct vop_lookup_args *ap) goto bad; fdropped = false; - /* Make sure we're not looking up the dvp itself. */ - if (VTOFDESC(dvp)->fd_ix != FD_DESC + fd) { - /* - * Unlock our root node (dvp) when doing this, since we might - * deadlock since the vnode might be locked by another thread - * and the root vnode lock will be obtained afterwards (in case - * we're looking up the fd of the root vnode), which will be the - * opposite lock order. Vhold the root vnode first so we don't - * lose it. - */ - arg.ftype = Fdesc; - arg.fd_fd = fd; - arg.ix = FD_DESC + fd; - arg.fp = fp; - arg.td = td; - arg.fdropped = fdropped; - error = vn_vget_ino_gen(dvp, fdesc_get_ino_alloc, &arg, - LK_EXCLUSIVE, &fvp); - fdropped = arg.fdropped; - } + /* + * Make sure we do not deadlock looking up the dvp itself. + * + * Unlock our root node (dvp) when doing this, since we might + * deadlock since the vnode might be locked by another thread + * and the root vnode lock will be obtained afterwards (in case + * we're looking up the fd of the root vnode), which will be the + * opposite lock order. + */ + arg.ftype = Fdesc; + arg.fd_fd = fd; + arg.ix = FD_DESC + fd; + arg.fp = fp; + arg.td = td; + arg.fdropped = fdropped; + error = vn_vget_ino_gen(dvp, fdesc_get_ino_alloc, &arg, + LK_EXCLUSIVE, &fvp); + fdropped = arg.fdropped; if (!fdropped) { /*