From owner-p4-projects@FreeBSD.ORG Fri May 4 18:39:09 2007 Return-Path: X-Original-To: p4-projects@freebsd.org Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 86A5216A404; Fri, 4 May 2007 18:39:09 +0000 (UTC) X-Original-To: perforce@freebsd.org Delivered-To: perforce@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 2BD4816A401 for ; Fri, 4 May 2007 18:39:09 +0000 (UTC) (envelope-from zec@icir.org) Received: from xaqua.tel.fer.hr (xaqua.tel.fer.hr [161.53.19.25]) by mx1.freebsd.org (Postfix) with ESMTP id AF0D013C4B8 for ; Fri, 4 May 2007 18:39:08 +0000 (UTC) (envelope-from zec@icir.org) Received: by xaqua.tel.fer.hr (Postfix, from userid 20006) id 0E2A09B651; Fri, 4 May 2007 20:39:08 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.1.7 (2006-10-05) on xaqua.tel.fer.hr X-Spam-Level: X-Spam-Status: No, score=-4.3 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00 autolearn=ham version=3.1.7 Received: from [192.168.200.106] (zec2.tel.fer.hr [161.53.19.79]) by xaqua.tel.fer.hr (Postfix) with ESMTP id A72B19B644 for ; Fri, 4 May 2007 20:39:06 +0200 (CEST) From: Marko Zec To: perforce@freebsd.org Date: Fri, 4 May 2007 20:39:02 +0200 User-Agent: KMail/1.9.6 References: <200705041800.l44I07UI051520@repoman.freebsd.org> <463B7A95.3010009@elischer.org> In-Reply-To: <463B7A95.3010009@elischer.org> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Message-Id: <200705042039.02884.zec@icir.org> Cc: Subject: Re: PERFORCE change 119250 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 04 May 2007 18:39:09 -0000 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 > > #include > > @@ -58,6 +59,7 @@ > > #include > > #include > > #include > > +#include > > > > #include > > #include > > @@ -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