Date: Fri, 4 May 2007 20:39:02 +0200 From: Marko Zec <zec@icir.org> To: perforce@freebsd.org Subject: Re: PERFORCE change 119250 for review Message-ID: <200705042039.02884.zec@icir.org> In-Reply-To: <463B7A95.3010009@elischer.org> References: <200705041800.l44I07UI051520@repoman.freebsd.org> <463B7A95.3010009@elischer.org>
next in thread | previous in thread | raw e-mail | index | archive | help
On Friday 04 May 2007 20:25:25 Julian Elischer wrote: > Marko Zec wrote: > > http://perforce.freebsd.org/chv.cgi?CH=3D119250 > > > > Change 119250 by zec@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. =A0I haven't done much=20 testing doing NFS mounts from non-default / base vnet though -> TODO=20 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=20 it's only one step away to resolving so->so_vnet... =A0As a rule a socket=20 MUST always be permanently bound to some vnet during its entire=20 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 ... > > > > =3D=3D=3D=3D //depot/projects/vimage/src/sys/nfsclient/nfs_diskless.c#5 > > (text+ko) =3D=3D=3D=3D > > > > @@ -151,7 +151,7 @@ > > void > > nfs_setup_diskless(void) > > { > > - INIT_VNET_NET(&vnet_0); > > + INIT_VNET_NET(curvnet); > > struct nfs_diskless *nd =3D &nfs_diskless; > > struct ifnet *ifp; > > struct ifaddr *ifa; > > > > =3D=3D=3D=3D //depot/projects/vimage/src/sys/nfsclient/nfs_socket.c#4 > > (text+ko) =3D=3D=3D=3D > > > > @@ -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); > > > > =3D=3D=3D=3D //depot/projects/vimage/src/sys/nfsclient/nfs_vfsops.c#5 > > (text+ko) =3D=3D=3D=3D > > > > @@ -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 =3D &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 =3D=3D 0) > > + if (nfs_diskless_valid =3D=3D 0) { > > + CURVNET_RESTORE(); > > return (-1); > > + } > > if (nfs_diskless_valid =3D=3D 1) > > nfs_convert_diskless(); > > > > @@ -502,6 +505,7 @@ > > printf("NFS ROOT: %s\n", buf); > > if ((error =3D nfs_mountdiskless(buf, MNT_RDONLY, > > &nd->root_saddr, &nd->root_args, td, &vp, mp)) !=3D 0) { > > + CURVNET_RESTORE(); > > return (error); > > } > > > > @@ -516,6 +520,8 @@ > > if (V_hostname[i] =3D=3D '\0') > > break; > > inittodr(ntohl(nd->root_time)); > > + > > + CURVNET_RESTORE(); > > return (0); > > } > > > > > > =3D=3D=3D=3D //depot/projects/vimage/src/sys/nfsclient/nfs_vnops.c#5 > > (text+ko) =3D=3D=3D=3D > > > > @@ -1351,7 +1351,6 @@ > > static int > > nfs_create(struct vop_create_args *ap) > > { > > - INIT_VNET_INET(curvnet); > > struct vnode *dvp =3D ap->a_dvp; > > struct vattr *vap =3D ap->a_vap; > > struct componentname *cnp =3D ap->a_cnp; > > @@ -1390,6 +1389,7 @@ > > *tl =3D txdr_unsigned(NFSV3CREATE_EXCLUSIVE); > > tl =3D 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++ =3D > > IA_SIN(TAILQ_FIRST(&V_in_ifaddrhead))->sin_addr.s_addr; else
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200705042039.02884.zec>