From owner-svn-src-all@FreeBSD.ORG Mon Apr 25 23:12:18 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id D0CED1065672; Mon, 25 Apr 2011 23:12:18 +0000 (UTC) (envelope-from rmacklem@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id BF1FC8FC0A; Mon, 25 Apr 2011 23:12:18 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p3PNCIgZ096593; Mon, 25 Apr 2011 23:12:18 GMT (envelope-from rmacklem@svn.freebsd.org) Received: (from rmacklem@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p3PNCIh1096589; Mon, 25 Apr 2011 23:12:18 GMT (envelope-from rmacklem@svn.freebsd.org) Message-Id: <201104252312.p3PNCIh1096589@svn.freebsd.org> From: Rick Macklem Date: Mon, 25 Apr 2011 23:12:18 +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: r221040 - in head/sys/fs: nfs nfsclient X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 25 Apr 2011 23:12:18 -0000 Author: rmacklem Date: Mon Apr 25 23:12:18 2011 New Revision: 221040 URL: http://svn.freebsd.org/changeset/base/221040 Log: Modify the experimental (newnfs) NFS client so that it uses the same diskless NFS root code as the regular client, which was moved to sys/nfs by r221032. This fixes the newnfs client so that it can do an NFSv3 diskless root file system. MFC after: 2 weeks Deleted: head/sys/fs/nfsclient/nfsdiskless.h Modified: head/sys/fs/nfs/nfs_var.h head/sys/fs/nfsclient/nfs.h head/sys/fs/nfsclient/nfs_clvfsops.c Modified: head/sys/fs/nfs/nfs_var.h ============================================================================== --- head/sys/fs/nfs/nfs_var.h Mon Apr 25 22:56:53 2011 (r221039) +++ head/sys/fs/nfs/nfs_var.h Mon Apr 25 23:12:18 2011 (r221040) @@ -41,7 +41,6 @@ struct ucred; struct nfscred; NFSPROC_T; struct buf; -struct nfs_diskless; struct sockaddr_in; struct nfs_dlmount; struct file; Modified: head/sys/fs/nfsclient/nfs.h ============================================================================== --- head/sys/fs/nfsclient/nfs.h Mon Apr 25 22:56:53 2011 (r221039) +++ head/sys/fs/nfsclient/nfs.h Mon Apr 25 23:12:18 2011 (r221040) @@ -101,7 +101,6 @@ int ncl_fsinfo(struct nfsmount *, struct struct thread *); int ncl_init(struct vfsconf *); int ncl_uninit(struct vfsconf *); -int ncl_mountroot(struct mount *); void ncl_nfsiodnew(void); void ncl_nfsiodnew_tq(__unused void *, int); Modified: head/sys/fs/nfsclient/nfs_clvfsops.c ============================================================================== --- head/sys/fs/nfsclient/nfs_clvfsops.c Mon Apr 25 22:56:53 2011 (r221039) +++ head/sys/fs/nfsclient/nfs_clvfsops.c Mon Apr 25 23:12:18 2011 (r221040) @@ -72,7 +72,7 @@ __FBSDID("$FreeBSD$"); #include #include #include -#include +#include FEATURE(nfscl, "NFSv4 client"); @@ -97,6 +97,7 @@ static int nfs_tprintf_delay = NFS_TPRIN SYSCTL_INT(_vfs_newnfs, NFS_TPRINTF_DELAY, downdelayinterval, CTLFLAG_RW, &nfs_tprintf_delay, 0, ""); +static int nfs_mountroot(struct mount *); static void nfs_sec_name(char *, int *); static void nfs_decode_args(struct mount *mp, struct nfsmount *nmp, struct nfs_args *argp, const char *, struct ucred *, @@ -140,19 +141,15 @@ MODULE_VERSION(newnfs, 1); * server for a diskless/dataless machine. It is initialized below just * to ensure that it is allocated to initialized data (.data not .bss). */ -struct nfs_diskless newnfs_diskless = { { { 0 } } }; -struct nfsv3_diskless newnfsv3_diskless = { { { 0 } } }; -int newnfs_diskless_valid = 0; - SYSCTL_INT(_vfs_newnfs, OID_AUTO, diskless_valid, CTLFLAG_RD, - &newnfs_diskless_valid, 0, + &nfs_diskless_valid, 0, "Has the diskless struct been filled correctly"); SYSCTL_STRING(_vfs_newnfs, OID_AUTO, diskless_rootpath, CTLFLAG_RD, - newnfsv3_diskless.root_hostnam, 0, "Path to nfs root"); + nfsv3_diskless.root_hostnam, 0, "Path to nfs root"); SYSCTL_OPAQUE(_vfs_newnfs, OID_AUTO, diskless_rootaddr, CTLFLAG_RD, - &newnfsv3_diskless.root_saddr, sizeof newnfsv3_diskless.root_saddr, + &nfsv3_diskless.root_saddr, sizeof(nfsv3_diskless.root_saddr), "%Ssockaddr_in", "Diskless root nfs address"); @@ -230,29 +227,25 @@ static void nfs_convert_diskless(void) { - bcopy(&newnfs_diskless.myif, &newnfsv3_diskless.myif, - sizeof (struct ifaliasreq)); - bcopy(&newnfs_diskless.mygateway, &newnfsv3_diskless.mygateway, - sizeof (struct sockaddr_in)); - nfs_convert_oargs(&newnfsv3_diskless.root_args, - &newnfs_diskless.root_args); - if (newnfsv3_diskless.root_args.flags & NFSMNT_NFSV3) { - newnfsv3_diskless.root_fhsize = NFSX_MYFH; - bcopy(newnfs_diskless.root_fh, newnfsv3_diskless.root_fh, - NFSX_MYFH); + bcopy(&nfs_diskless.myif, &nfsv3_diskless.myif, + sizeof(struct ifaliasreq)); + bcopy(&nfs_diskless.mygateway, &nfsv3_diskless.mygateway, + sizeof(struct sockaddr_in)); + nfs_convert_oargs(&nfsv3_diskless.root_args,&nfs_diskless.root_args); + if (nfsv3_diskless.root_args.flags & NFSMNT_NFSV3) { + nfsv3_diskless.root_fhsize = NFSX_MYFH; + bcopy(nfs_diskless.root_fh, nfsv3_diskless.root_fh, NFSX_MYFH); } else { - newnfsv3_diskless.root_fhsize = NFSX_V2FH; - bcopy(newnfs_diskless.root_fh, newnfsv3_diskless.root_fh, - NFSX_V2FH); - } - bcopy(&newnfs_diskless.root_saddr,&newnfsv3_diskless.root_saddr, - sizeof(struct sockaddr_in)); - bcopy(newnfs_diskless.root_hostnam, newnfsv3_diskless.root_hostnam, - MNAMELEN); - newnfsv3_diskless.root_time = newnfs_diskless.root_time; - bcopy(newnfs_diskless.my_hostnam, newnfsv3_diskless.my_hostnam, - MAXHOSTNAMELEN); - newnfs_diskless_valid = 3; + nfsv3_diskless.root_fhsize = NFSX_V2FH; + bcopy(nfs_diskless.root_fh, nfsv3_diskless.root_fh, NFSX_V2FH); + } + bcopy(&nfs_diskless.root_saddr,&nfsv3_diskless.root_saddr, + sizeof(struct sockaddr_in)); + bcopy(nfs_diskless.root_hostnam, nfsv3_diskless.root_hostnam, MNAMELEN); + nfsv3_diskless.root_time = nfs_diskless.root_time; + bcopy(nfs_diskless.my_hostnam, nfsv3_diskless.my_hostnam, + MAXHOSTNAMELEN); + nfs_diskless_valid = 3; } /* @@ -358,12 +351,12 @@ ncl_fsinfo(struct nfsmount *nmp, struct /* * Mount a remote root fs via. nfs. This depends on the info in the - * newnfs_diskless structure that has been filled in properly by some primary + * nfs_diskless structure that has been filled in properly by some primary * bootstrap. * It goes something like this: * - do enough of "ifconfig" by calling ifioctl() so that the system * can talk to the server - * - If newnfs_diskless.mygateway is filled in, use that address as + * - If nfs_diskless.mygateway is filled in, use that address as * a default gateway. * - build the rootfs mount point and call mountnfs() to do the rest. * @@ -372,11 +365,11 @@ ncl_fsinfo(struct nfsmount *nmp, struct * nfs_mountroot() will be called once in the boot before any other NFS * client activity occurs. */ -int -ncl_mountroot(struct mount *mp) +static int +nfs_mountroot(struct mount *mp) { struct thread *td = curthread; - struct nfsv3_diskless *nd = &newnfsv3_diskless; + struct nfsv3_diskless *nd = &nfsv3_diskless; struct socket *so; struct vnode *vp; struct ifreq ir; @@ -391,9 +384,9 @@ ncl_mountroot(struct mount *mp) nfs_setup_diskless(); #endif - if (newnfs_diskless_valid == 0) + if (nfs_diskless_valid == 0) return (-1); - if (newnfs_diskless_valid == 1) + if (nfs_diskless_valid == 1) nfs_convert_diskless(); /* @@ -767,7 +760,7 @@ nfs_mount(struct mount *mp) td = curthread; if ((mp->mnt_flag & (MNT_ROOTFS | MNT_UPDATE)) == MNT_ROOTFS) { - error = ncl_mountroot(mp); + error = nfs_mountroot(mp); goto out; }