From owner-p4-projects@FreeBSD.ORG Fri May 4 18:00:08 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 91B1316A406; Fri, 4 May 2007 18:00:08 +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 5154E16A401 for ; Fri, 4 May 2007 18:00:08 +0000 (UTC) (envelope-from zec@FreeBSD.org) Received: from repoman.freebsd.org (repoman.freebsd.org [69.147.83.41]) by mx1.freebsd.org (Postfix) with ESMTP id 3327A13C44B for ; Fri, 4 May 2007 18:00:08 +0000 (UTC) (envelope-from zec@FreeBSD.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.13.8/8.13.8) with ESMTP id l44I08G6051523 for ; Fri, 4 May 2007 18:00:08 GMT (envelope-from zec@FreeBSD.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.13.8/8.13.8/Submit) id l44I07UI051520 for perforce@freebsd.org; Fri, 4 May 2007 18:00:07 GMT (envelope-from zec@FreeBSD.org) Date: Fri, 4 May 2007 18:00:07 GMT Message-Id: <200705041800.l44I07UI051520@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to zec@FreeBSD.org using -f From: Marko Zec To: Perforce Change Reviews Cc: Subject: 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:00:08 -0000 http://perforce.freebsd.org/chv.cgi?CH=119250 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... 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 #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); ==== //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