Subject: Re: namei caching of newly created files?
To: None <tech-perform@NetBSD.org>
From: Havard Eidnes <he@uninett.no>
List: tech-kern
Date: 01/20/2005 00:28:15
Hm,

it seems that <sys/namei.h> already has cache_enter().  I wonder
if this patch looks sane and safe:

Index: vfs_vnops.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
RCS file: /cvsroot/src/sys/kern/vfs_vnops.c,v
retrieving revision 1.85
diff -u -u -1 -0 -r1.85 vfs_vnops.c
--- vfs_vnops.c 2 Jan 2005 16:08:29 -0000       1.85
+++ vfs_vnops.c 19 Jan 2005 23:26:20 -0000
@@ -135,20 +135,21 @@
                                goto restart;
                        }
                        VOP_LEASE(ndp->ni_dvp, p, cred, LEASE_WRITE);
                        error =3D VOP_CREATE(ndp->ni_dvp, &ndp->ni_vp,
                                           &ndp->ni_cnd, &va);
                        vn_finished_write(mp, 0);
                        if (error)
                                return (error);
                        fmode &=3D ~O_TRUNC;
                        vp =3D ndp->ni_vp;
+                       cache_enter(ndp->ni_dvp, vp, &ndp->ni_cnd);
                } else {
                        VOP_ABORTOP(ndp->ni_dvp, &ndp->ni_cnd);
                        if (ndp->ni_dvp =3D=3D ndp->ni_vp)
                                vrele(ndp->ni_dvp);
                        else
                                vput(ndp->ni_dvp);
                        ndp->ni_dvp =3D NULL;
                        vp =3D ndp->ni_vp;
                        if (fmode & O_EXCL) {
                                error =3D EEXIST;

Regards,

- H=E5vard