From owner-dev-commits-src-branches@freebsd.org Thu Feb 25 20:52:12 2021 Return-Path: Delivered-To: dev-commits-src-branches@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 29A5A56FC77; Thu, 25 Feb 2021 20:52:12 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4DmlMv4ntdz3NhM; Thu, 25 Feb 2021 20:52:11 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id B9D8B1E540; Thu, 25 Feb 2021 20:52:10 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 11PKqAWV079092; Thu, 25 Feb 2021 20:52:10 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 11PKqACx079091; Thu, 25 Feb 2021 20:52:10 GMT (envelope-from git) Date: Thu, 25 Feb 2021 20:52:10 GMT Message-Id: <202102252052.11PKqACx079091@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Konstantin Belousov Subject: git: fc54784b47b6 - releng/13.0 - ffs_inotovp(): interface to convert (ino, gen) into alive vnode MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/releng/13.0 X-Git-Reftype: branch X-Git-Commit: fc54784b47b6876e03527fbfff317fcc4764c1b1 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 25 Feb 2021 20:52:12 -0000 The branch releng/13.0 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=fc54784b47b6876e03527fbfff317fcc4764c1b1 commit fc54784b47b6876e03527fbfff317fcc4764c1b1 Author: Konstantin Belousov AuthorDate: 2021-01-26 11:52:59 +0000 Commit: Konstantin Belousov CommitDate: 2021-02-25 20:47:47 +0000 ffs_inotovp(): interface to convert (ino, gen) into alive vnode Approved by: re (delphij, gjb) (cherry picked from commit 5952c86c78b177b5e904bf139e6b56519897c7e0) --- sys/ufs/ffs/ffs_extern.h | 2 ++ sys/ufs/ffs/ffs_vfsops.c | 44 ++++++++++++++++++++++++++++++++------------ sys/ufs/ufs/ufs_extern.h | 2 +- sys/ufs/ufs/ufs_vfsops.c | 21 +++++---------------- 4 files changed, 40 insertions(+), 29 deletions(-) diff --git a/sys/ufs/ffs/ffs_extern.h b/sys/ufs/ffs/ffs_extern.h index bdb3f533e1ad..9694489266b6 100644 --- a/sys/ufs/ffs/ffs_extern.h +++ b/sys/ufs/ffs/ffs_extern.h @@ -80,6 +80,8 @@ int ffs_freefile(struct ufsmount *, struct fs *, struct vnode *, ino_t, void ffs_fserr(struct fs *, ino_t, char *); int ffs_getcg(struct fs *, struct vnode *, u_int, int, struct buf **, struct cg **); +int ffs_inotovp(struct mount *, ino_t, u_int64_t, int, struct vnode **, + int); int ffs_isblock(struct fs *, u_char *, ufs1_daddr_t); int ffs_isfreeblock(struct fs *, u_char *, ufs1_daddr_t); void ffs_oldfscompat_write(struct fs *, struct ufsmount *); diff --git a/sys/ufs/ffs/ffs_vfsops.c b/sys/ufs/ffs/ffs_vfsops.c index 91b8c30f0919..596e2f4b4b5f 100644 --- a/sys/ufs/ffs/ffs_vfsops.c +++ b/sys/ufs/ffs/ffs_vfsops.c @@ -2153,35 +2153,55 @@ ffs_fhtovp(mp, fhp, flags, vpp) struct vnode **vpp; { struct ufid *ufhp; + + ufhp = (struct ufid *)fhp; + return (ffs_inotovp(mp, ufhp->ufid_ino, ufhp->ufid_gen, flags, + vpp, 0)); +} + +int +ffs_inotovp(mp, ino, gen, lflags, vpp, ffs_flags) + struct mount *mp; + ino_t ino; + u_int64_t gen; + int lflags; + struct vnode **vpp; + int ffs_flags; +{ struct ufsmount *ump; + struct vnode *nvp; struct fs *fs; struct cg *cgp; struct buf *bp; - ino_t ino; u_int cg; int error; - ufhp = (struct ufid *)fhp; - ino = ufhp->ufid_ino; ump = VFSTOUFS(mp); fs = ump->um_fs; if (ino < UFS_ROOTINO || ino >= fs->fs_ncg * fs->fs_ipg) return (ESTALE); + /* * Need to check if inode is initialized because UFS2 does lazy * initialization and nfs_fhtovp can offer arbitrary inode numbers. */ - if (fs->fs_magic != FS_UFS2_MAGIC) - return (ufs_fhtovp(mp, ufhp, flags, vpp)); - cg = ino_to_cg(fs, ino); - if ((error = ffs_getcg(fs, ump->um_devvp, cg, 0, &bp, &cgp)) != 0) - return (error); - if (ino >= cg * fs->fs_ipg + cgp->cg_initediblk) { + if (fs->fs_magic == FS_UFS2_MAGIC) { + cg = ino_to_cg(fs, ino); + error = ffs_getcg(fs, ump->um_devvp, cg, 0, &bp, &cgp); + if (error != 0) + return (error); + if (ino >= cg * fs->fs_ipg + cgp->cg_initediblk) { + brelse(bp); + return (ESTALE); + } brelse(bp); - return (ESTALE); } - brelse(bp); - return (ufs_fhtovp(mp, ufhp, flags, vpp)); + + error = ffs_vgetf(mp, ino, lflags, &nvp, ffs_flags); + if (error == 0) + error = ufs_fhtovp(mp, nvp, gen); + *vpp = error == 0 ? nvp : NULLVP; + return (error); } /* diff --git a/sys/ufs/ufs/ufs_extern.h b/sys/ufs/ufs/ufs_extern.h index a28fcffabd2e..ab26750455e8 100644 --- a/sys/ufs/ufs/ufs_extern.h +++ b/sys/ufs/ufs/ufs_extern.h @@ -59,7 +59,7 @@ int ufs_bmap(struct vop_bmap_args *); int ufs_bmaparray(struct vnode *, ufs2_daddr_t, ufs2_daddr_t *, struct buf *, int *, int *); int ufs_bmap_seekdata(struct vnode *, off_t *); -int ufs_fhtovp(struct mount *, struct ufid *, int, struct vnode **); +int ufs_fhtovp(struct mount *, struct vnode *, u_int64_t); int ufs_checkpath(ino_t, ino_t, struct inode *, struct ucred *, ino_t *); void ufs_dirbad(struct inode *, doff_t, char *); int ufs_dirbadentry(struct vnode *, struct direct *, int); diff --git a/sys/ufs/ufs/ufs_vfsops.c b/sys/ufs/ufs/ufs_vfsops.c index 4813ac7db763..1a63e92b3e2c 100644 --- a/sys/ufs/ufs/ufs_vfsops.c +++ b/sys/ufs/ufs/ufs_vfsops.c @@ -222,31 +222,20 @@ ufs_uninit(vfsp) * Call the VFS_CHECKEXP beforehand to verify access. */ int -ufs_fhtovp(mp, ufhp, flags, vpp) +ufs_fhtovp(mp, nvp, gen) struct mount *mp; - struct ufid *ufhp; - int flags; - struct vnode **vpp; + struct vnode *nvp; + u_int64_t gen; { struct inode *ip; - struct vnode *nvp; - int error; - error = VFS_VGET(mp, ufhp->ufid_ino, flags, &nvp); - if (error) { - *vpp = NULLVP; - return (error); - } ip = VTOI(nvp); - if (ip->i_mode == 0 || ip->i_gen != ufhp->ufid_gen || - ip->i_effnlink <= 0) { + if (ip->i_mode == 0 || ip->i_gen != gen || ip->i_effnlink <= 0) { if (ip->i_mode == 0) vgone(nvp); vput(nvp); - *vpp = NULLVP; return (ESTALE); } - *vpp = nvp; - vnode_create_vobject(*vpp, DIP(ip, i_size), curthread); + vnode_create_vobject(nvp, DIP(ip, i_size), curthread); return (0); }