From owner-svn-src-head@FreeBSD.ORG Sun Dec 13 11:06:40 2009 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 2C8141065672; Sun, 13 Dec 2009 11:06:40 +0000 (UTC) (envelope-from bz@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 1B75A8FC19; Sun, 13 Dec 2009 11:06:40 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id nBDB6ere084722; Sun, 13 Dec 2009 11:06:40 GMT (envelope-from bz@svn.freebsd.org) Received: (from bz@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id nBDB6dOb084717; Sun, 13 Dec 2009 11:06:39 GMT (envelope-from bz@svn.freebsd.org) Message-Id: <200912131106.nBDB6dOb084717@svn.freebsd.org> From: "Bjoern A. Zeeb" Date: Sun, 13 Dec 2009 11:06:39 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r200471 - head/sys/nfsclient X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 13 Dec 2009 11:06:40 -0000 Author: bz Date: Sun Dec 13 11:06:39 2009 New Revision: 200471 URL: http://svn.freebsd.org/changeset/base/200471 Log: Add a few more V_hacks to nfsclient to allow machines with a VIMAGE kernel to boot from NFS. [1] Note: this is not a full virtualization of nfsclient. It is only does what advertised above and nothing more. Requested by: public demand [1] Tested by: kris, .. MFC after: 5 days Modified: head/sys/nfsclient/bootp_subr.c head/sys/nfsclient/krpc_subr.c head/sys/nfsclient/nfs_vfsops.c head/sys/nfsclient/nfs_vnops.c Modified: head/sys/nfsclient/bootp_subr.c ============================================================================== --- head/sys/nfsclient/bootp_subr.c Sun Dec 13 04:50:11 2009 (r200470) +++ head/sys/nfsclient/bootp_subr.c Sun Dec 13 11:06:39 2009 (r200471) @@ -584,6 +584,8 @@ bootpc_call(struct bootpc_globalcontext int retry; const char *s; + CURVNET_SET(TD_TO_VNET(td)); + /* * Create socket and set its recieve timeout. */ @@ -960,6 +962,7 @@ gotreply: out: soclose(so); out0: + CURVNET_RESTORE(); return error; } @@ -974,6 +977,8 @@ bootpc_fakeup_interface(struct bootpc_if struct ifaddr *ifa; struct sockaddr_dl *sdl; + CURVNET_SET(TD_TO_VNET(td)); + error = socreate(AF_INET, &ifctx->so, SOCK_DGRAM, 0, td->td_ucred, td); if (error != 0) panic("nfs_boot: socreate, error=%d", error); @@ -1048,6 +1053,8 @@ bootpc_fakeup_interface(struct bootpc_if ifctx->ireq.ifr_name); ifctx->sdl = sdl; + CURVNET_RESTORE(); + return error; } Modified: head/sys/nfsclient/krpc_subr.c ============================================================================== --- head/sys/nfsclient/krpc_subr.c Sun Dec 13 04:50:11 2009 (r200470) +++ head/sys/nfsclient/krpc_subr.c Sun Dec 13 11:06:39 2009 (r200471) @@ -55,6 +55,8 @@ __FBSDID("$FreeBSD$"); #include #include +#include + #include #include @@ -213,6 +215,8 @@ krpc_call(struct sockaddr_in *sa, u_int nam = mhead = NULL; from = NULL; + CURVNET_SET(TD_TO_VNET(td)); + /* * Create socket and set its recieve timeout. */ @@ -425,6 +429,7 @@ krpc_call(struct sockaddr_in *sa, u_int if (mhead) m_freem(mhead); if (from) free(from, M_SONAME); soclose(so); + CURVNET_RESTORE(); return error; } Modified: head/sys/nfsclient/nfs_vfsops.c ============================================================================== --- head/sys/nfsclient/nfs_vfsops.c Sun Dec 13 04:50:11 2009 (r200470) +++ head/sys/nfsclient/nfs_vfsops.c Sun Dec 13 11:06:39 2009 (r200471) @@ -64,6 +64,8 @@ __FBSDID("$FreeBSD$"); #include #include +#include + #include #include @@ -825,6 +827,8 @@ nfs_mount(struct mount *mp) has_fh_opt = 0; has_hostname_opt = 0; + CURVNET_SET(CRED_TO_VNET(curthread->td_ucred)); + if (vfs_filteropt(mp->mnt_optnew, nfs_opts)) { error = EINVAL; goto out; @@ -1124,6 +1128,7 @@ out: mp->mnt_kern_flag |= (MNTK_MPSAFE|MNTK_LOOKUP_SHARED); MNT_IUNLOCK(mp); } + CURVNET_RESTORE(); return (error); } Modified: head/sys/nfsclient/nfs_vnops.c ============================================================================== --- head/sys/nfsclient/nfs_vnops.c Sun Dec 13 04:50:11 2009 (r200470) +++ head/sys/nfsclient/nfs_vnops.c Sun Dec 13 11:06:39 2009 (r200471) @@ -1555,14 +1555,21 @@ nfs_create(struct vop_create_args *ap) struct vattr vattr; int v3 = NFS_ISV3(dvp); + CURVNET_SET(CRED_TO_VNET(curthread->td_ucred)); + /* * Oops, not for me.. */ - if (vap->va_type == VSOCK) - return (nfs_mknodrpc(dvp, ap->a_vpp, cnp, vap)); + if (vap->va_type == VSOCK) { + error = nfs_mknodrpc(dvp, ap->a_vpp, cnp, vap); + CURVNET_RESTORE(); + return (error); + } - if ((error = VOP_GETATTR(dvp, &vattr, cnp->cn_cred)) != 0) + if ((error = VOP_GETATTR(dvp, &vattr, cnp->cn_cred)) != 0) { + CURVNET_RESTORE(); return (error); + } if (vap->va_vaflags & VA_EXCLUSIVE) fmode |= O_EXCL; again: @@ -1658,6 +1665,7 @@ nfsmout: KDTRACE_NFS_ATTRCACHE_FLUSH_DONE(dvp); } mtx_unlock(&(VTONFS(dvp))->n_mtx); + CURVNET_RESTORE(); return (error); }