PERFORCE change 119250 for review
Marko Zec
zec at icir.org
Fri May 4 18:39:09 UTC 2007
On Friday 04 May 2007 20:25:25 Julian Elischer wrote:
> Marko Zec wrote:
> > http://perforce.freebsd.org/chv.cgi?CH=119250
> >
> > Change 119250 by zec at zec_zoo on 2007/05/04 17:59:15
> >
> > A set of kludges which allow for NFS netbooting. Basically
> > the key is to properly set / restore curvnet whenever necessary...
>
> so whenever the filesystem uses the network, we need to drop back to
> the base vimage, right?
Ideally, we shouln't be limited to vnet0, no. I haven't done much
testing doing NFS mounts from non-default / base vnet though -> TODO
list expanded...
> How about storing the vimage-at-mount-time in the mountpoint?
We already store a socket ptr in the nfs_mountsomething struct, and then
it's only one step away to resolving so->so_vnet... As a rule a socket
MUST always be permanently bound to some vnet during its entire
lifetime...
> May not be useful yet but migh tbecome useful if you allowed virtual
> machines to mount their own filesystems.. A real VM would have its
> own mount table I guess :-)
Yes we should be able to do this (one day).
Marko
> > Affected files ...
> >
> > .. //depot/projects/vimage/src/sys/nfsclient/nfs_diskless.c#5 edit
> > .. //depot/projects/vimage/src/sys/nfsclient/nfs_socket.c#4 edit
> > .. //depot/projects/vimage/src/sys/nfsclient/nfs_vfsops.c#5 edit
> > .. //depot/projects/vimage/src/sys/nfsclient/nfs_vnops.c#5 edit
> >
> > Differences ...
> >
> > ==== //depot/projects/vimage/src/sys/nfsclient/nfs_diskless.c#5
> > (text+ko) ====
> >
> > @@ -151,7 +151,7 @@
> > void
> > nfs_setup_diskless(void)
> > {
> > - INIT_VNET_NET(&vnet_0);
> > + INIT_VNET_NET(curvnet);
> > struct nfs_diskless *nd = &nfs_diskless;
> > struct ifnet *ifp;
> > struct ifaddr *ifa;
> >
> > ==== //depot/projects/vimage/src/sys/nfsclient/nfs_socket.c#4
> > (text+ko) ====
> >
> > @@ -40,6 +40,7 @@
> > */
> >
> > #include "opt_inet6.h"
> > +#include "opt_vimage.h"
> >
> > #include <sys/param.h>
> > #include <sys/systm.h>
> > @@ -58,6 +59,7 @@
> > #include <sys/sysctl.h>
> > #include <sys/syslog.h>
> > #include <sys/vnode.h>
> > +#include <sys/vimage.h>
> >
> > #include <netinet/in.h>
> > #include <netinet/tcp.h>
> > @@ -1454,6 +1456,7 @@
> > mtx_unlock(&nmp->nm_mtx);
> > continue;
> > }
> > + CURVNET_SET(so->so_vnet);
> > /*
> > * If there is enough space and the window allows..
> > * Resend it
> > @@ -1521,6 +1524,7 @@
> > mtx_unlock(&rep->r_mtx);
> > mtx_unlock(&nmp->nm_mtx);
> > }
> > + CURVNET_RESTORE();
> > }
> > mtx_unlock(&nfs_reqq_mtx);
> > callout_reset(&nfs_callout, nfs_ticks, nfs_timer, NULL);
> >
> > ==== //depot/projects/vimage/src/sys/nfsclient/nfs_vfsops.c#5
> > (text+ko) ====
> >
> > @@ -401,7 +401,7 @@
> > int
> > nfs_mountroot(struct mount *mp, struct thread *td)
> > {
> > - INIT_VPROCG(&vprocg_0);
> > + INIT_VPROCG(td->td_ucred->cr_vimage->v_procg);
> > struct nfsv3_diskless *nd = &nfsv3_diskless;
> > struct socket *so;
> > struct vnode *vp;
> > @@ -413,14 +413,17 @@
> >
> > NET_ASSERT_GIANT();
> >
> > + CURVNET_SET(td->td_ucred->cr_vimage->v_vnet);
> > #if defined(BOOTP_NFSROOT) && defined(BOOTP)
> > bootpc_init(); /* use bootp to get nfs_diskless filled in */
> > #elif defined(NFS_ROOT)
> > nfs_setup_diskless();
> > #endif
> >
> > - if (nfs_diskless_valid == 0)
> > + if (nfs_diskless_valid == 0) {
> > + CURVNET_RESTORE();
> > return (-1);
> > + }
> > if (nfs_diskless_valid == 1)
> > nfs_convert_diskless();
> >
> > @@ -502,6 +505,7 @@
> > printf("NFS ROOT: %s\n", buf);
> > if ((error = nfs_mountdiskless(buf, MNT_RDONLY,
> > &nd->root_saddr, &nd->root_args, td, &vp, mp)) != 0) {
> > + CURVNET_RESTORE();
> > return (error);
> > }
> >
> > @@ -516,6 +520,8 @@
> > if (V_hostname[i] == '\0')
> > break;
> > inittodr(ntohl(nd->root_time));
> > +
> > + CURVNET_RESTORE();
> > return (0);
> > }
> >
> >
> > ==== //depot/projects/vimage/src/sys/nfsclient/nfs_vnops.c#5
> > (text+ko) ====
> >
> > @@ -1351,7 +1351,6 @@
> > static int
> > nfs_create(struct vop_create_args *ap)
> > {
> > - INIT_VNET_INET(curvnet);
> > struct vnode *dvp = ap->a_dvp;
> > struct vattr *vap = ap->a_vap;
> > struct componentname *cnp = ap->a_cnp;
> > @@ -1390,6 +1389,7 @@
> > *tl = txdr_unsigned(NFSV3CREATE_EXCLUSIVE);
> > tl = nfsm_build(u_int32_t *, NFSX_V3CREATEVERF);
> > #ifdef INET
> > + INIT_VNET_INET(VFSTONFS(dvp->v_mount)->nm_so->so_vnet);
> > if (!TAILQ_EMPTY(&V_in_ifaddrhead))
> > *tl++ =
> > IA_SIN(TAILQ_FIRST(&V_in_ifaddrhead))->sin_addr.s_addr; else
More information about the p4-projects
mailing list