PERFORCE change 178702 for review
Efstratios Karatzas
gpf at FreeBSD.org
Mon May 24 11:27:54 UTC 2010
http://p4web.freebsd.org/@@178702?ac=10
Change 178702 by gpf at gpf_desktop on 2010/05/24 11:27:15
vn_fullpath_nocache(9) can be supplied with a ino_t hint for the
parent directory that may contain the file in question. This
facilitates the search.
Since we are using NFS file handles and we have room to spare inside
those file handles, the best way seems to include this hint inside
the file handle.
- I altered VOP_VPTOFH(9) and added an extra argument which is
a vnode pointer to the directory in question. If it's not null,
UFS' ffs_vptofh(), will add the hint ino_t inside the file handle.
So I had to change vnode_if.src as well as every part of the kernel
that calls VOP_VPTOFH(); I just added a NULL parameter in those cases.
This way, this functionality can be easily added to other filesystems
as well.
- Changed every part of the current NFS implementation that creates
new file handles so that a directory 'vnode *' will be used for the
hint. It works fine with ufs so the only thing left to do is finish
up vn_fullpath_nocache(), place it inside the kernel and
call it every time that vn_fullpath_global() fails in NFS code.
Affected files ...
.. //depot/projects/soc2010/gpf_audit/freebsd/src/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ctldir.c#2 edit
.. //depot/projects/soc2010/gpf_audit/freebsd/src/sys/fs/nfsserver/nfs_nfsdport.c#2 edit
.. //depot/projects/soc2010/gpf_audit/freebsd/src/sys/fs/nullfs/null_vnops.c#2 edit
.. //depot/projects/soc2010/gpf_audit/freebsd/src/sys/kern/vfs_export.c#2 edit
.. //depot/projects/soc2010/gpf_audit/freebsd/src/sys/kern/vfs_syscalls.c#2 edit
.. //depot/projects/soc2010/gpf_audit/freebsd/src/sys/kern/vnode_if.src#2 edit
.. //depot/projects/soc2010/gpf_audit/freebsd/src/sys/nfsserver/nfs_serv.c#8 edit
.. //depot/projects/soc2010/gpf_audit/freebsd/src/sys/ufs/ffs/ffs_vnops.c#2 edit
.. //depot/projects/soc2010/gpf_audit/freebsd/src/sys/ufs/ufs/inode.h#2 edit
Differences ...
==== //depot/projects/soc2010/gpf_audit/freebsd/src/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ctldir.c#2 (text+ko) ====
@@ -1176,7 +1176,7 @@
err = zfsctl_traverse_begin(&vp, LK_SHARED | LK_RETRY);
if (err == 0)
- err = VOP_VPTOFH(vp, (void *)ap->a_fid);
+ err = VOP_VPTOFH(vp, (void *)ap->a_fid, NULL);
zfsctl_traverse_end(vp, err);
return (err);
}
==== //depot/projects/soc2010/gpf_audit/freebsd/src/sys/fs/nfsserver/nfs_nfsdport.c#2 (text+ko) ====
@@ -124,7 +124,7 @@
NFSBZERO((caddr_t)fhp, sizeof(fhandle_t));
fhp->fh_fsid = vp->v_mount->mnt_stat.f_fsid;
- error = VOP_VPTOFH(vp, &fhp->fh_fid);
+ error = VOP_VPTOFH(vp, &fhp->fh_fid, NULL);
return (error);
}
==== //depot/projects/soc2010/gpf_audit/freebsd/src/sys/fs/nullfs/null_vnops.c#2 (text+ko) ====
@@ -738,7 +738,7 @@
struct vnode *lvp;
lvp = NULLVPTOLOWERVP(ap->a_vp);
- return VOP_VPTOFH(lvp, ap->a_fhp);
+ return VOP_VPTOFH(lvp, ap->a_fhp, NULL);
}
static int
==== //depot/projects/soc2010/gpf_audit/freebsd/src/sys/kern/vfs_export.c#2 (text+ko) ====
@@ -377,7 +377,7 @@
if ((error = VFS_ROOT(mp, LK_EXCLUSIVE, &rvp)))
return (error);
- if ((error = VOP_VPTOFH(rvp, &nfs_pub.np_handle.fh_fid)))
+ if ((error = VOP_VPTOFH(rvp, &nfs_pub.np_handle.fh_fid, NULL)))
return (error);
vput(rvp);
==== //depot/projects/soc2010/gpf_audit/freebsd/src/sys/kern/vfs_syscalls.c#2 (text+ko) ====
@@ -4298,7 +4298,7 @@
vp = nd.ni_vp;
bzero(&fh, sizeof(fh));
fh.fh_fsid = vp->v_mount->mnt_stat.f_fsid;
- error = VOP_VPTOFH(vp, &fh.fh_fid);
+ error = VOP_VPTOFH(vp, &fh.fh_fid, NULL);
vput(vp);
VFS_UNLOCK_GIANT(vfslocked);
if (error)
@@ -4337,7 +4337,7 @@
vp = nd.ni_vp;
bzero(&fh, sizeof(fh));
fh.fh_fsid = vp->v_mount->mnt_stat.f_fsid;
- error = VOP_VPTOFH(vp, &fh.fh_fid);
+ error = VOP_VPTOFH(vp, &fh.fh_fid, NULL);
vput(vp);
VFS_UNLOCK_GIANT(vfslocked);
if (error)
==== //depot/projects/soc2010/gpf_audit/freebsd/src/sys/kern/vnode_if.src#2 (text+ko) ====
@@ -599,6 +599,7 @@
vop_vptofh {
IN struct vnode *vp;
IN struct fid *fhp;
+ IN struct vnode *dvp;
};
%% vptocnp vp L L L
==== //depot/projects/soc2010/gpf_audit/freebsd/src/sys/nfsserver/nfs_serv.c#8 (text+ko) ====
@@ -572,7 +572,7 @@
nd.ni_cnd.cn_cred = cred;
nd.ni_cnd.cn_nameiop = LOOKUP;
- nd.ni_cnd.cn_flags = LOCKLEAF | SAVESTART | MPSAFE;
+ nd.ni_cnd.cn_flags = LOCKLEAF | SAVESTART | MPSAFE | WANTPARENT;
error = nfs_namei(&nd, nfsd, fhp, len, slp, nam, &md, &dpos,
&dirp, v3, &dirattr, &dirattr_ret, pubflag);
vfslocked = NDHASGIANT(&nd);
@@ -683,7 +683,7 @@
bzero((caddr_t)fhp, sizeof(nfh));
fhp->fh_fsid = vp->v_mount->mnt_stat.f_fsid;
- error = VOP_VPTOFH(vp, &fhp->fh_fid);
+ error = VOP_VPTOFH(vp, &fhp->fh_fid, ndp->ni_dvp);
if (!error)
error = VOP_GETATTR(vp, vap, cred);
@@ -718,6 +718,8 @@
if (ndp->ni_startdir)
vrele(ndp->ni_startdir);
}
+ if (ndp->ni_dvp)
+ vrele(ndp->ni_dvp);
NDFREE(&nd, NDF_ONLY_PNBUF);
VFS_UNLOCK_GIANT(vfslocked);
@@ -1081,6 +1083,7 @@
uiop->uio_resid = len;
uiop->uio_rw = UIO_READ;
uiop->uio_segflg = UIO_SYSSPACE;
+ AUDIT_ARG_FFLAGS(IO_NODELOCKED | ioflag);
error = VOP_READ(vp, uiop, IO_NODELOCKED | ioflag, cred);
off = uiop->uio_offset;
nh->nh_nextr = off;
@@ -1626,7 +1629,7 @@
if (!error) {
bzero((caddr_t)fhp, sizeof(nfh));
fhp->fh_fsid = nd.ni_vp->v_mount->mnt_stat.f_fsid;
- error = VOP_VPTOFH(nd.ni_vp, &fhp->fh_fid);
+ error = VOP_VPTOFH(nd.ni_vp, &fhp->fh_fid, nd.ni_dvp);
if (!error)
error = VOP_GETATTR(nd.ni_vp, vap, cred);
}
@@ -1875,7 +1878,7 @@
if (!error) {
bzero((caddr_t)fhp, sizeof(nfh));
fhp->fh_fsid = vp->v_mount->mnt_stat.f_fsid;
- error = VOP_VPTOFH(vp, &fhp->fh_fid);
+ error = VOP_VPTOFH(vp, &fhp->fh_fid, AUDIT_dvp);
if (!error)
error = VOP_GETATTR(vp, vap, cred);
}
@@ -2741,7 +2744,7 @@
if (error == 0) {
bzero((caddr_t)fhp, sizeof(nfh));
fhp->fh_fsid = nd.ni_vp->v_mount->mnt_stat.f_fsid;
- error = VOP_VPTOFH(nd.ni_vp, &fhp->fh_fid);
+ error = VOP_VPTOFH(nd.ni_vp, &fhp->fh_fid, parent_dir_vp);
if (!error)
error = VOP_GETATTR(nd.ni_vp, vap, cred);
vput(nd.ni_vp);
@@ -2934,7 +2937,7 @@
if (!error) {
bzero((caddr_t)fhp, sizeof(nfh));
fhp->fh_fsid = nd.ni_vp->v_mount->mnt_stat.f_fsid;
- error = VOP_VPTOFH(nd.ni_vp, &fhp->fh_fid);
+ error = VOP_VPTOFH(nd.ni_vp, &fhp->fh_fid, parent_dir_vp);
if (!error)
error = VOP_GETATTR(nd.ni_vp, vap, cred);
}
@@ -3773,11 +3776,11 @@
*/
KASSERT(nvp->v_mount == vp->v_mount,
("nfsrv_readdirplus: nvp mount != vp mount"));
- if (VOP_VPTOFH(nvp, &nfhp->fh_fid)) {
+ if (VOP_VPTOFH(nvp, &nfhp->fh_fid, vp)) {
vput(nvp);
nvp = NULL;
goto invalid;
- }
+ }
if (VOP_GETATTR(nvp, vap, cred)) {
vput(nvp);
nvp = NULL;
==== //depot/projects/soc2010/gpf_audit/freebsd/src/sys/ufs/ffs/ffs_vnops.c#2 (text+ko) ====
@@ -1771,16 +1771,21 @@
vop_vptofh {
IN struct vnode *a_vp;
IN struct fid *a_fhp;
+ IN struct vnode *a_dvp;
};
*/
{
- struct inode *ip;
+ struct inode *ip, *dip;
struct ufid *ufhp;
ip = VTOI(ap->a_vp);
ufhp = (struct ufid *)ap->a_fhp;
ufhp->ufid_len = sizeof(struct ufid);
ufhp->ufid_ino = ip->i_number;
- ufhp->ufid_gen = ip->i_gen;
+ ufhp->ufid_gen = ip->i_gen;
+ if (ap->a_dvp != NULL) {
+ dip = VTOI(ap->a_dvp);
+ ufhp->ufid_dino = dip->i_number;
+ }
return (0);
}
==== //depot/projects/soc2010/gpf_audit/freebsd/src/sys/ufs/ufs/inode.h#2 (text+ko) ====
@@ -183,6 +183,8 @@
u_int16_t ufid_pad; /* Force 32-bit alignment. */
ino_t ufid_ino; /* File number (ino). */
int32_t ufid_gen; /* Generation number. */
+ ino_t ufid_dino; /* ino of a directory that probably contains the inode */
+
};
#endif /* _KERNEL */
More information about the p4-projects
mailing list